diff --git a/src/main/java/appeng/api/config/Settings.java b/src/main/java/appeng/api/config/Settings.java index 58cf715d66a..17c10249ace 100644 --- a/src/main/java/appeng/api/config/Settings.java +++ b/src/main/java/appeng/api/config/Settings.java @@ -51,6 +51,7 @@ public enum Settings { LEVEL_TYPE(EnumSet.allOf(LevelType.class)), TERMINAL_STYLE(EnumSet.of(TerminalStyle.TALL, TerminalStyle.SMALL)), + HIDE_STORED(EnumSet.of(YesNo.YES, YesNo.NO)), COPY_MODE(EnumSet.allOf(CopyMode.class)), INTERFACE_TERMINAL(EnumSet.of(YesNo.YES, YesNo.NO)), diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java index 9c8851b5587..345eb16baf8 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java @@ -29,14 +29,17 @@ import com.google.common.base.Joiner; import appeng.api.AEApi; +import appeng.api.config.Settings; import appeng.api.config.SortDir; import appeng.api.config.SortOrder; import appeng.api.config.ViewItems; +import appeng.api.config.YesNo; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.api.util.DimensionalCoord; import appeng.client.gui.AEBaseGui; import appeng.client.gui.IGuiTooltipHandler; +import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiScrollbar; import appeng.client.gui.widgets.ISortSource; import appeng.client.gui.widgets.ITooltip; @@ -158,6 +161,9 @@ public int getStringWidth() { protected List visual = new ArrayList<>(); private GuiButton cancel; + protected List visualHiddenStored = new ArrayList<>(); + protected GuiImgButton toggleHideStored; + protected boolean hideStored; private int tooltip = -1; private final RemainingOperations remainingOperations = new RemainingOperations(); private ItemStack hoveredStack; @@ -172,6 +178,7 @@ protected GuiCraftingCPU(final ContainerCraftingCPU container) { this.craftingCpu = container; this.ySize = GUI_HEIGHT; this.xSize = GUI_WIDTH; + this.hideStored = AEConfig.instance.getConfigManager().getSetting(Settings.HIDE_STORED) == YesNo.YES; final GuiScrollbar scrollbar = new GuiScrollbar(); this.setScrollBar(scrollbar); @@ -182,12 +189,12 @@ public void clearItems() { this.active = AEApi.instance().storage().createItemList(); this.pending = AEApi.instance().storage().createItemList(); this.visual = new ArrayList<>(); + this.visualHiddenStored = new ArrayList<>(); } @Override protected void actionPerformed(final GuiButton btn) { super.actionPerformed(btn); - if (this.cancel == btn) { try { NetworkHandler.instance.sendToServer(new PacketValueConfig("TileCrafting.Cancel", "Cancel")); @@ -195,6 +202,14 @@ protected void actionPerformed(final GuiButton btn) { AELog.debug(e); } } + if (this.toggleHideStored == btn) { + this.hideStored ^= true; + AEConfig.instance.getConfigManager().putSetting(Settings.HIDE_STORED, hideStored ? YesNo.YES : YesNo.NO); + this.toggleHideStored.set(hideStored ? YesNo.YES : YesNo.NO); + hideStoredSorting(); + this.setScrollBar(); + } + } @Override @@ -224,12 +239,22 @@ public void initGui() { CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal()); + this.toggleHideStored = new GuiImgButton( + this.guiLeft + 221, + this.guiTop + this.ySize - 19, + Settings.HIDE_STORED, + AEConfig.instance.getConfigManager().getSetting(Settings.HIDE_STORED)); + this.buttonList.add(this.toggleHideStored); this.buttonList.add(this.cancel); } private void setScrollBar() { - final int size = this.visual.size(); - + int size; + if (this.hideStored) { + size = this.visualHiddenStored.size(); + } else { + size = this.visual.size(); + } this.getScrollBar().setTop(SCROLLBAR_TOP).setLeft(SCROLLBAR_LEFT).setHeight(SCROLLBAR_HEIGHT); this.getScrollBar().setRange(0, (size + 2) / ITEMS_PER_ROW - rows, 1); } @@ -323,8 +348,14 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final final int offY = 23; final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; - for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) { - final IAEItemStack refStack = this.visual.get(z); // repo.getReferenceItem( z ); + List visualTemp; + if (this.hideStored) { + visualTemp = this.visualHiddenStored; + } else { + visualTemp = this.visual; + } + for (int z = viewStart; z < Math.min(viewEnd, visualTemp.size()); z++) { + final IAEItemStack refStack = visualTemp.get(z); // repo.getReferenceItem( z ); if (refStack != null) { GL11.glPushMatrix(); GL11.glScaled(0.5, 0.5, 0.5); @@ -533,6 +564,7 @@ public void postUpdate(final List list, final byte ref) { } } + if (this.hideStored) this.hideStoredSorting(); this.setScrollBar(); } @@ -621,4 +653,18 @@ public Enum getSortDisplay() { public ItemStack getHoveredStack() { return hoveredStack; } + + private void hideStoredSorting() { + this.visualHiddenStored = new ArrayList<>(); + for (final IAEItemStack refStack : this.visual) { + if (refStack != null) { + final IAEItemStack activeStack = this.active.findPrecise(refStack); + final IAEItemStack pendingStack = this.pending.findPrecise(refStack); + if ((activeStack != null && activeStack.getStackSize() > 0) + || (pendingStack != null && pendingStack.getStackSize() > 0)) { + this.visualHiddenStored.add(refStack); + } + } + } + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index 306746b129f..c965533f79d 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -140,9 +140,13 @@ protected void actionPerformed(final GuiButton btn) { NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui)); } else if (btn == this.switchTallMode) { tallMode = !tallMode; + AEConfig.instance.getConfigManager() + .putSetting(Settings.TERMINAL_STYLE, tallMode ? TerminalStyle.TALL : TerminalStyle.SMALL); switchTallMode.set(tallMode ? TerminalStyle.TALL : TerminalStyle.SMALL); recalculateScreenSize(); this.setWorldAndResolution(mc, width, height); + } else if (btn == this.toggleHideStored) { + this.setScrollBar(); } } @@ -307,7 +311,12 @@ protected void recalculateScreenSize() { } private void setScrollBar() { - final int size = this.visual.size(); + int size; + if (this.hideStored) { + size = this.visualHiddenStored.size(); + } else { + size = this.visual.size(); + } this.getScrollBar().setTop(SCROLLBAR_TOP).setLeft(SCROLLBAR_LEFT).setHeight(ySize - 47); this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1); diff --git a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java index 729b12b4e43..d17c9b6d66e 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java @@ -296,6 +296,18 @@ public GuiImgButton(final int x, final int y, final Enum idx, final Enum val) { TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full); + this.registerApp( + 16 * 13 + 6, + Settings.HIDE_STORED, + YesNo.NO, + ButtonToolTips.HideStored, + ButtonToolTips.Disabled); + this.registerApp( + 16 * 13 + 7, + Settings.HIDE_STORED, + YesNo.YES, + ButtonToolTips.HideStored, + ButtonToolTips.Enable); this.registerApp(64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName); this.registerApp( diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index 5f8eeaf5200..1d76f30d3ce 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -153,6 +153,7 @@ public AEConfig(final File configFile) { this.settings.registerSetting(Settings.SEARCH_TOOLTIPS, YesNo.YES); this.settings.registerSetting(Settings.TERMINAL_STYLE, TerminalStyle.TALL); + this.settings.registerSetting(Settings.HIDE_STORED, YesNo.NO); this.settings.registerSetting(Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH); this.settings.registerSetting(Settings.SAVE_SEARCH, YesNo.NO); this.settings.registerSetting(Settings.CRAFTING_STATUS, CraftingStatus.TILE); diff --git a/src/main/java/appeng/core/localization/ButtonToolTips.java b/src/main/java/appeng/core/localization/ButtonToolTips.java index 9da2963e6a8..c2963ad0118 100644 --- a/src/main/java/appeng/core/localization/ButtonToolTips.java +++ b/src/main/java/appeng/core/localization/ButtonToolTips.java @@ -97,6 +97,7 @@ public enum ButtonToolTips { TerminalStyle_Tall, TerminalStyle_Small, SaveAsImage, + HideStored, Stash, StashDesc, diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang index 6b4ca613713..370527f7d57 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang @@ -425,6 +425,7 @@ gui.tooltips.appliedenergistics2.TerminalStyle_Full=Full Screen Terminal gui.tooltips.appliedenergistics2.TerminalStyle_Tall=Tall Centered Terminal gui.tooltips.appliedenergistics2.TerminalStyle_Small=Small Centered Terminal gui.tooltips.appliedenergistics2.SaveAsImage=Save as image +gui.tooltips.appliedenergistics2.HideStored=Hide Stored Items gui.tooltips.appliedenergistics2.DoesntDespawn=This item won't de-spawn. gui.tooltips.appliedenergistics2.EmitterMode=Crafting Emitter Mode diff --git a/src/main/resources/assets/appliedenergistics2/textures/guis/states.png b/src/main/resources/assets/appliedenergistics2/textures/guis/states.png index 017596ba903..b564b8ff0d7 100644 Binary files a/src/main/resources/assets/appliedenergistics2/textures/guis/states.png and b/src/main/resources/assets/appliedenergistics2/textures/guis/states.png differ