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.
This commit is contained in:
Amaury Carrade 2015-09-10 18:00:36 +02:00
parent 58abd17205
commit e5c7ece41f

View File

@ -71,8 +71,8 @@ abstract public class ExplorerGui<T> extends ActionGui
private int currentPageX = 0; private int currentPageX = 0;
private int currentPageY = 0; private int currentPageY = 0;
private int dataHeight; private int dataHeight = 0;
private int dataWidth; private int dataWidth = 0;
private int pageCountX; private int pageCountX;
private int pageCountY; private int pageCountY;
@ -126,6 +126,17 @@ abstract public class ExplorerGui<T> extends ActionGui
setData(data, 0); 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 @Override
protected void populate(Inventory inventory) protected void populate(Inventory inventory)
{ {
@ -141,7 +152,7 @@ abstract public class ExplorerGui<T> extends ActionGui
updateAction("down", getPageItem("down", canGoDown())); updateAction("down", getPageItem("down", canGoDown()));
} }
if(data != null && data.length > 0) if(hasData())
{ {
if (!isData2D) if (!isData2D)
{ {
@ -206,7 +217,7 @@ abstract public class ExplorerGui<T> extends ActionGui
// The user clicked in the GUI // The user clicked in the GUI
if(affectsGui(event)) if(affectsGui(event))
{ {
if(data != null && data.length > 0) if(hasData())
{ {
switch (event.getAction()) switch (event.getAction())
{ {