From e5c7ece41fe19bc701b09fb77f6c785999fa2af1 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Thu, 10 Sep 2015 18:00:36 +0200 Subject: [PATCH] Updated explorer GUI to support manually placed data sets (with coordinates). * NEW: updated the way the data emptiness is determined to avoid a GUI with manually placed data being considered as empty. --- .../imageonmap/guiproko/core/ExplorerGui.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java b/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java index 39aeacf..7054210 100644 --- a/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java +++ b/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java @@ -71,8 +71,8 @@ abstract public class ExplorerGui extends ActionGui private int currentPageX = 0; private int currentPageY = 0; - private int dataHeight; - private int dataWidth; + private int dataHeight = 0; + private int dataWidth = 0; private int pageCountX; private int pageCountY; @@ -125,6 +125,17 @@ abstract public class ExplorerGui extends ActionGui { setData(data, 0); } + + /** + * Checks if this GUI contains data, either with the data entry or through + * {@link #getViewItem(int, int)} and {@link #setDataShape(int, int)}. + * + * @return {@code true} if this GUI contains some data. + */ + protected boolean hasData() + { + return (data == null || data.length == 0) && (dataWidth == 0 && dataHeight == 0); + } @Override protected void populate(Inventory inventory) @@ -141,7 +152,7 @@ abstract public class ExplorerGui extends ActionGui updateAction("down", getPageItem("down", canGoDown())); } - if(data != null && data.length > 0) + if(hasData()) { if (!isData2D) { @@ -181,7 +192,7 @@ abstract public class ExplorerGui extends ActionGui if(hasActions()) super.populate(inventory); } - + @Override protected void onClick(InventoryClickEvent event) { @@ -206,7 +217,7 @@ abstract public class ExplorerGui extends ActionGui // The user clicked in the GUI if(affectsGui(event)) { - if(data != null && data.length > 0) + if(hasData()) { switch (event.getAction()) { @@ -254,7 +265,7 @@ abstract public class ExplorerGui extends ActionGui for(int slot : event.getRawSlots()) { - //Clicked in the action bar + // Clicked in the action bar if(hasActions() && slot >= MAX_INVENTORY_SIZE - INVENTORY_ROW_SIZE && slot < MAX_INVENTORY_SIZE)