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 c48de53..a98344f 100644 --- a/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java +++ b/src/main/java/fr/moribus/imageonmap/guiproko/core/ExplorerGui.java @@ -64,7 +64,10 @@ abstract public class ExplorerGui extends ActionGui private int viewSize; private int viewHeight; private int viewWidth; - + + private boolean keepHorizontalScrollingSpace = false; + private boolean keepVerticalScrollingSpace = false; + private int currentPageX = 0; private int currentPageY = 0; @@ -208,7 +211,7 @@ abstract public class ExplorerGui extends ActionGui onActionMove(event); } } - + @Override protected void onDrag(InventoryDragEvent event) { @@ -314,8 +317,9 @@ abstract public class ExplorerGui extends ActionGui viewHeight = Math.min((int)Math.ceil((double)dataLength / (double)viewWidth), MAX_INVENTORY_COLUMN_SIZE); - if(hasActions() || dataLength > MAX_INVENTORY_SIZE) + if(hasActions() || dataLength > MAX_INVENTORY_SIZE || keepHorizontalScrollingSpace) viewHeight--; + viewSize = viewWidth * viewHeight; pageCountX = (int)Math.ceil((double)dataLength / (double)viewSize); @@ -329,8 +333,11 @@ abstract public class ExplorerGui extends ActionGui pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth); pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight); - if(pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) viewWidth--; - if(pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) viewHeight--; + if((pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) || keepVerticalScrollingSpace) + viewWidth--; + + if((pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) || keepHorizontalScrollingSpace) + viewHeight--; pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth); pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight); @@ -498,7 +505,7 @@ abstract public class ExplorerGui extends ActionGui if(canUse) { 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 extends ActionGui { 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; + } } diff --git a/src/main/java/fr/moribus/imageonmap/guiproko/list/MapListGui.java b/src/main/java/fr/moribus/imageonmap/guiproko/list/MapListGui.java index 745d90f..fefeaf8 100644 --- a/src/main/java/fr/moribus/imageonmap/guiproko/list/MapListGui.java +++ b/src/main/java/fr/moribus/imageonmap/guiproko/list/MapListGui.java @@ -18,21 +18,15 @@ package fr.moribus.imageonmap.guiproko.list; -import fr.moribus.imageonmap.guiproko.core.ExplorerGui; -import fr.moribus.imageonmap.guiproko.core.Gui; -import fr.moribus.imageonmap.guiproko.core.GuiUtils; -import fr.moribus.imageonmap.map.ImageMap; -import fr.moribus.imageonmap.map.MapManager; -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; +import fr.moribus.imageonmap.guiproko.core.*; +import fr.moribus.imageonmap.map.*; +import fr.moribus.imageonmap.ui.*; +import org.bukkit.*; +import org.bukkit.inventory.*; public class MapListGui extends ExplorerGui { - + @Override protected ItemStack getViewItem(ImageMap data) { @@ -60,7 +54,7 @@ public class MapListGui extends ExplorerGui return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName()); } - MapItemManager.give((Player) getPlayer(), map); + MapItemManager.give(getPlayer(), map); return null; } @@ -70,6 +64,7 @@ public class MapListGui extends ExplorerGui ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId()); setData(maps); setTitle("Your maps (" + maps.length + " total)"); + + setKeepHorizontalScrollingSpace(true); } - }