From 084d45530de3719c13daeabec46a564d9f617936 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 5 Feb 2014 23:08:05 -0600 Subject: [PATCH] Removed Sort By in security terminal. --- .../gui/implementations/GuiMEMonitorable.java | 29 ++++++++++++++++--- .../gui/implementations/GuiNetworkStatus.java | 19 ++++++++++-- client/gui/implementations/GuiSecurity.java | 8 +++++ client/gui/widgets/ISortSource.java | 10 +++++++ client/me/ItemRepo.java | 9 ++++-- 5 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 client/gui/widgets/ISortSource.java diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 4b8f54e8..161e2acc 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -13,6 +13,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.client.gui.AEBaseMEGui; import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiScrollbar; +import appeng.client.gui.widgets.ISortSource; import appeng.client.me.InternalSlotME; import appeng.client.me.ItemRepo; import appeng.container.implementations.ContainerMEMonitorable; @@ -24,7 +25,7 @@ import appeng.parts.reporting.PartTerminal; import appeng.tile.misc.TileSecurity; import appeng.util.Platform; -public class GuiMEMonitorable extends AEBaseMEGui +public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource { GuiTextField searchField; @@ -36,6 +37,7 @@ public class GuiMEMonitorable extends AEBaseMEGui int perRow = 9; int reservedSpace = 0; int lowerTextureOffset = 0; + boolean customSortOrder = true; int rows = 0; int maxRows = Integer.MAX_VALUE; @@ -48,7 +50,7 @@ public class GuiMEMonitorable extends AEBaseMEGui super( c ); myScrollBar = new GuiScrollbar(); - repo = new ItemRepo( myScrollBar ); + repo = new ItemRepo( myScrollBar, this ); xSize = 195; ySize = 204; @@ -111,8 +113,15 @@ public class GuiMEMonitorable extends AEBaseMEGui this.ySize = magicNumber + rows * 18 + reservedSpace; this.guiTop = top; - buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) ); - buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.SORT_DIRECTION, Configuration.instance.settings + int offset = guiTop + 8; + + if ( customSortOrder ) + { + buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) ); + offset += 20; + } + + buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, Configuration.instance.settings .getSetting( Settings.SORT_DIRECTION ) ) ); searchField = new GuiTextField( this.fontRenderer, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, this.fontRenderer.FONT_HEIGHT ); @@ -195,4 +204,16 @@ public class GuiMEMonitorable extends AEBaseMEGui fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); } + @Override + public Enum getSortBy() + { + return Configuration.instance.settings.getSetting( Settings.SORT_BY ); + } + + @Override + public Enum getSortDir() + { + return Configuration.instance.settings.getSetting( Settings.SORT_DIRECTION ); + } + } diff --git a/client/gui/implementations/GuiNetworkStatus.java b/client/gui/implementations/GuiNetworkStatus.java index 1e39c498..07fae3e5 100644 --- a/client/gui/implementations/GuiNetworkStatus.java +++ b/client/gui/implementations/GuiNetworkStatus.java @@ -9,17 +9,20 @@ import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; +import appeng.api.config.SortDir; +import appeng.api.config.SortOrder; import appeng.api.implementations.guiobjects.INetworkTool; import appeng.api.storage.data.IAEItemStack; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiScrollbar; +import appeng.client.gui.widgets.ISortSource; import appeng.client.me.ItemRepo; import appeng.client.me.SlotME; import appeng.container.implementations.ContainerNetworkStatus; import appeng.core.localization.GuiText; import appeng.util.Platform; -public class GuiNetworkStatus extends AEBaseGui +public class GuiNetworkStatus extends AEBaseGui implements ISortSource { ItemRepo repo; @@ -31,7 +34,7 @@ public class GuiNetworkStatus extends AEBaseGui this.ySize = 125; this.xSize = 195; myScrollBar = new GuiScrollbar(); - repo = new ItemRepo( myScrollBar ); + repo = new ItemRepo( myScrollBar, this ); repo.rowSize = 5; } @@ -245,4 +248,16 @@ public class GuiNetworkStatus extends AEBaseGui } super.drawItemStackTooltip( stack, x, y ); } + + @Override + public Enum getSortBy() + { + return SortOrder.NAME; + } + + @Override + public Enum getSortDir() + { + return SortDir.ASCENDING; + } } diff --git a/client/gui/implementations/GuiSecurity.java b/client/gui/implementations/GuiSecurity.java index a6c64f3e..6b4638ce 100644 --- a/client/gui/implementations/GuiSecurity.java +++ b/client/gui/implementations/GuiSecurity.java @@ -4,6 +4,7 @@ import java.io.IOException; import net.minecraft.entity.player.InventoryPlayer; import appeng.api.config.SecurityPermissions; +import appeng.api.config.SortOrder; import appeng.api.storage.IStorageMonitorable; import appeng.client.gui.widgets.GuiToggleButton; import appeng.container.implementations.ContainerSecurity; @@ -16,6 +17,7 @@ public class GuiSecurity extends GuiMEMonitorable public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) { super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) ); + customSortOrder = false; reservedSpace = 33; xSize += 50; } @@ -95,4 +97,10 @@ public class GuiSecurity extends GuiMEMonitorable fontRenderer.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 ); } + @Override + public Enum getSortBy() + { + return SortOrder.NAME; + } + } diff --git a/client/gui/widgets/ISortSource.java b/client/gui/widgets/ISortSource.java new file mode 100644 index 00000000..3fa74f2b --- /dev/null +++ b/client/gui/widgets/ISortSource.java @@ -0,0 +1,10 @@ +package appeng.client.gui.widgets; + +public interface ISortSource +{ + + Enum getSortBy(); + + Enum getSortDir(); + +} diff --git a/client/me/ItemRepo.java b/client/me/ItemRepo.java index ace3b6a4..6918add4 100644 --- a/client/me/ItemRepo.java +++ b/client/me/ItemRepo.java @@ -11,6 +11,7 @@ import appeng.api.config.YesNo; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.client.gui.widgets.IScrollSource; +import appeng.client.gui.widgets.ISortSource; import appeng.core.Configuration; import appeng.util.ItemSorters; import appeng.util.Platform; @@ -23,13 +24,15 @@ public class ItemRepo final private ArrayList view = new ArrayList(); final private ArrayList dsp = new ArrayList(); final private IScrollSource src; + final private ISortSource sortSrc; public int rowSize = 9; public String searchString = ""; - public ItemRepo(IScrollSource src) { + public ItemRepo(IScrollSource src, ISortSource sortSrc) { this.src = src; + this.sortSrc = sortSrc; } public IAEItemStack getRefrenceItem(int idx) @@ -125,8 +128,8 @@ public class ItemRepo */ } - Enum SortBy = Configuration.instance.settings.getSetting( Settings.SORT_BY ); - Enum SortDir = Configuration.instance.settings.getSetting( Settings.SORT_DIRECTION ); + Enum SortBy = sortSrc.getSortBy(); + Enum SortDir = sortSrc.getSortDir(); ItemSorters.Direction = (appeng.api.config.SortDir) SortDir;