Skip to content

Commit

Permalink
Close #112 Remember if item list overlay has been disabled, add config
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jan 14, 2016
1 parent 4334ef7 commit 00ef1d8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Expand Up @@ -2,5 +2,5 @@ mcversion=1.8.9
forgeversion=11.15.0.1697

version_major=2
version_minor=16
version_patch=2
version_minor=17
version_patch=0
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/ItemFilter.java
Expand Up @@ -173,7 +173,7 @@ private boolean isItemStackHiddenByMissingModel(@Nonnull ItemStack itemStack) {
return true;
}
} catch (RuntimeException e) {
Log.error("Couldn't get ItemModel for itemStack {}.", itemStack.getClass(), e);
Log.error("Couldn't get ItemModel for itemStack.", e);
return true;
}
return false;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/mezz/jei/config/Config.java
Expand Up @@ -21,6 +21,7 @@ public class Config {

public static LocalizedConfiguration configFile;

private static boolean overlayEnabled = true;
private static boolean cheatItemsEnabled = false;
private static boolean editModeEnabled = false;
private static boolean debugModeEnabled = false;
Expand All @@ -44,6 +45,21 @@ private Config() {

}

public static boolean isOverlayEnabled() {
return overlayEnabled;
}

public static void toggleOverlayEnabled() {
overlayEnabled = !overlayEnabled;

Property property = configFile.getConfiguration().get(CATEGORY_INTERFACE, "overlayEnabled", overlayEnabled);
property.set(overlayEnabled);

if (configFile.hasChanged()) {
configFile.save();
}
}

public static boolean isCheatItemsEnabled() {
return cheatItemsEnabled;
}
Expand Down Expand Up @@ -105,6 +121,8 @@ public static boolean syncConfig() {
configFile.addCategory(CATEGORY_ADVANCED);
configFile.addCategory(CATEGORY_ADDONS);

overlayEnabled = configFile.getBoolean(CATEGORY_INTERFACE, "overlayEnabled", overlayEnabled);

cheatItemsEnabled = configFile.getBoolean(CATEGORY_MODE, "cheatItemsEnabled", cheatItemsEnabled);
editModeEnabled = configFile.getBoolean(CATEGORY_MODE, "editEnabled", editModeEnabled);

Expand Down
7 changes: 1 addition & 6 deletions src/main/java/mezz/jei/gui/ItemListOverlay.java
Expand Up @@ -80,7 +80,6 @@ public class ItemListOverlay implements IShowsRecipeFocuses, IMouseHandler, IKey
private int screenHeight;

private boolean open = false;
private boolean enabled = true;

public ItemListOverlay(ItemFilter itemFilter) {
this.itemFilter = itemFilter;
Expand Down Expand Up @@ -427,10 +426,6 @@ public void close() {

@Override
public boolean isOpen() {
return open && enabled;
}

public void toggleEnabled() {
enabled = !enabled;
return open && Config.isOverlayEnabled();
}
}
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/input/InputHandler.java
Expand Up @@ -212,7 +212,7 @@ private boolean handleKeyDown(int eventKey) {

if (GuiScreen.isCtrlKeyDown()) {
if (eventKey == KeyBindings.toggleOverlay.getKeyCode()) {
itemListOverlay.toggleEnabled();
Config.toggleOverlayEnabled();
return false;
} else if (eventKey == Keyboard.KEY_F) {
itemListOverlay.setKeyboardFocus(true);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/jei/lang/en_US.lang
Expand Up @@ -32,6 +32,8 @@ config.jei.mode.editEnabled.comment=Hide and unhide items by clicking them in th

config.jei.interface=Interface
config.jei.interface.comment=Options relating to the User Interface.
config.jei.interface.overlayEnabled=Item List Overlay
config.jei.interface.overlayEnabled.comment=Show the list of items next to open guis.
config.jei.interface.recipeAnimationsEnabled=Recipe Animations
config.jei.interface.recipeAnimationsEnabled.comment=Show recipe animations (furnace fire, progress bars, etc)

Expand Down

0 comments on commit 00ef1d8

Please sign in to comment.