mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-02-13 01:51:19 +01:00
Added an option to the explorer GUI: keep the scrolling area empty even without scrolls.
To be able to place controls, or by style/coherence if the developer wants that. * NEW: added explicit options to keep the scrolling area empty even without scrolls.
This commit is contained in:
parent
149e1225c1
commit
a403efcd4e
@ -64,7 +64,10 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
private int viewSize;
|
private int viewSize;
|
||||||
private int viewHeight;
|
private int viewHeight;
|
||||||
private int viewWidth;
|
private int viewWidth;
|
||||||
|
|
||||||
|
private boolean keepHorizontalScrollingSpace = false;
|
||||||
|
private boolean keepVerticalScrollingSpace = false;
|
||||||
|
|
||||||
private int currentPageX = 0;
|
private int currentPageX = 0;
|
||||||
private int currentPageY = 0;
|
private int currentPageY = 0;
|
||||||
|
|
||||||
@ -208,7 +211,7 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
onActionMove(event);
|
onActionMove(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDrag(InventoryDragEvent event)
|
protected void onDrag(InventoryDragEvent event)
|
||||||
{
|
{
|
||||||
@ -314,8 +317,9 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
viewHeight = Math.min((int)Math.ceil((double)dataLength / (double)viewWidth),
|
viewHeight = Math.min((int)Math.ceil((double)dataLength / (double)viewWidth),
|
||||||
MAX_INVENTORY_COLUMN_SIZE);
|
MAX_INVENTORY_COLUMN_SIZE);
|
||||||
|
|
||||||
if(hasActions() || dataLength > MAX_INVENTORY_SIZE)
|
if(hasActions() || dataLength > MAX_INVENTORY_SIZE || keepHorizontalScrollingSpace)
|
||||||
viewHeight--;
|
viewHeight--;
|
||||||
|
|
||||||
viewSize = viewWidth * viewHeight;
|
viewSize = viewWidth * viewHeight;
|
||||||
|
|
||||||
pageCountX = (int)Math.ceil((double)dataLength / (double)viewSize);
|
pageCountX = (int)Math.ceil((double)dataLength / (double)viewSize);
|
||||||
@ -329,8 +333,11 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
|
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
|
||||||
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
|
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
|
||||||
|
|
||||||
if(pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) viewWidth--;
|
if((pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) || keepVerticalScrollingSpace)
|
||||||
if(pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) viewHeight--;
|
viewWidth--;
|
||||||
|
|
||||||
|
if((pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) || keepHorizontalScrollingSpace)
|
||||||
|
viewHeight--;
|
||||||
|
|
||||||
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
|
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
|
||||||
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
|
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
|
||||||
@ -498,7 +505,7 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
if(canUse)
|
if(canUse)
|
||||||
{
|
{
|
||||||
meta.setLore(Collections.singletonList(
|
meta.setLore(Collections.singletonList(
|
||||||
ChatColor.GRAY + "Go to page " + ChatColor.WHITE + (newPage) + ChatColor.GRAY + " of " + ChatColor.WHITE + lastPage
|
ChatColor.GRAY + "Go to page " + ChatColor.WHITE + (newPage + 1) + ChatColor.GRAY + " of " + ChatColor.WHITE + lastPage
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,4 +626,32 @@ abstract public class ExplorerGui<T> extends ActionGui
|
|||||||
{
|
{
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to {@code true}, the horizontal scrolling line will remain empty even without
|
||||||
|
* scrolls (with one page typically), so you can place buttons or things like that in this
|
||||||
|
* area.
|
||||||
|
*
|
||||||
|
* Else, with one page, the place will be used to display an additional row of data.
|
||||||
|
*
|
||||||
|
* @param keepHorizontalScrollingSpace {@code true} if enabled.
|
||||||
|
*/
|
||||||
|
public void setKeepHorizontalScrollingSpace(boolean keepHorizontalScrollingSpace)
|
||||||
|
{
|
||||||
|
this.keepHorizontalScrollingSpace = keepHorizontalScrollingSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to {@code true}, the vertical scrolling line will remain empty even without
|
||||||
|
* scrolls (with one page typically), so you can place buttons or things like that in this
|
||||||
|
* area.
|
||||||
|
*
|
||||||
|
* Else, with one page, the place will be used to display an additional column of data.
|
||||||
|
*
|
||||||
|
* @param keepVerticalScrollingSpace {@code true} if enabled.
|
||||||
|
*/
|
||||||
|
public void setKeepVerticalScrollingSpace(boolean keepVerticalScrollingSpace)
|
||||||
|
{
|
||||||
|
this.keepVerticalScrollingSpace = keepVerticalScrollingSpace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,21 +18,15 @@
|
|||||||
|
|
||||||
package fr.moribus.imageonmap.guiproko.list;
|
package fr.moribus.imageonmap.guiproko.list;
|
||||||
|
|
||||||
import fr.moribus.imageonmap.guiproko.core.ExplorerGui;
|
import fr.moribus.imageonmap.guiproko.core.*;
|
||||||
import fr.moribus.imageonmap.guiproko.core.Gui;
|
import fr.moribus.imageonmap.map.*;
|
||||||
import fr.moribus.imageonmap.guiproko.core.GuiUtils;
|
import fr.moribus.imageonmap.ui.*;
|
||||||
import fr.moribus.imageonmap.map.ImageMap;
|
import org.bukkit.*;
|
||||||
import fr.moribus.imageonmap.map.MapManager;
|
import org.bukkit.inventory.*;
|
||||||
import fr.moribus.imageonmap.map.PosterMap;
|
|
||||||
import fr.moribus.imageonmap.map.SingleMap;
|
|
||||||
import fr.moribus.imageonmap.ui.MapItemManager;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class MapListGui extends ExplorerGui<ImageMap>
|
public class MapListGui extends ExplorerGui<ImageMap>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack getViewItem(ImageMap data)
|
protected ItemStack getViewItem(ImageMap data)
|
||||||
{
|
{
|
||||||
@ -60,7 +54,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
|||||||
return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName());
|
return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItemManager.give((Player) getPlayer(), map);
|
MapItemManager.give(getPlayer(), map);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +64,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
|||||||
ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId());
|
ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId());
|
||||||
setData(maps);
|
setData(maps);
|
||||||
setTitle("Your maps (" + maps.length + " total)");
|
setTitle("Your maps (" + maps.length + " total)");
|
||||||
|
|
||||||
|
setKeepHorizontalScrollingSpace(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user