mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-29 05:26:18 +01:00
Updated the details GUI and fixed list GUI only opening the details GUI for posters.
* NEW: added icons from the olg details GUI. * NEW: rewrote the map parts items (from the old GUI). * BUG: the list GUI don't open the details one when a single map is right-clicked.
This commit is contained in:
parent
e5c7ece41f
commit
d25bf9bd0e
@ -20,15 +20,18 @@ package fr.moribus.imageonmap.guiproko.list;
|
||||
|
||||
import fr.moribus.imageonmap.guiproko.core.*;
|
||||
import fr.moribus.imageonmap.map.*;
|
||||
import fr.moribus.imageonmap.ui.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class MapDetailGui extends ExplorerGui<Void>
|
||||
{
|
||||
private final PosterMap map;
|
||||
public MapDetailGui(PosterMap map)
|
||||
private final ImageMap map;
|
||||
|
||||
public MapDetailGui(ImageMap map)
|
||||
{
|
||||
this.map = map;
|
||||
}
|
||||
@ -36,13 +39,88 @@ public class MapDetailGui extends ExplorerGui<Void>
|
||||
@Override
|
||||
protected ItemStack getViewItem(int x, int y)
|
||||
{
|
||||
return MapItemManager.createSubMapItem(map, x, y);
|
||||
Material partMaterial = Material.PAPER;
|
||||
if((y % 2 == 0 && x % 2 == 0) || (y % 2 == 1 && x % 2 == 1))
|
||||
partMaterial = Material.EMPTY_MAP;
|
||||
|
||||
ItemStack part = new ItemStack(partMaterial);
|
||||
ItemMeta meta = part.getItemMeta();
|
||||
|
||||
meta.setDisplayName(ChatColor.GREEN + "Map part");
|
||||
meta.setLore(Arrays.asList(
|
||||
ChatColor.GRAY + "Column: " + ChatColor.WHITE + (y + 1),
|
||||
ChatColor.GRAY + "Row: " + ChatColor.WHITE + (x + 1),
|
||||
"",
|
||||
ChatColor.GRAY + "» Click to get only this part"
|
||||
));
|
||||
|
||||
part.setItemMeta(meta);
|
||||
return part;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getEmptyViewItem()
|
||||
{
|
||||
if(map instanceof SingleMap)
|
||||
{
|
||||
return getViewItem(0, 0);
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUpdate()
|
||||
{
|
||||
setTitle("Your maps » " + ChatColor.BLACK + map.getName());
|
||||
setDataShape(map.getColumnCount(), map.getRowCount());
|
||||
setKeepHorizontalScrollingSpace(true);
|
||||
|
||||
if(map instanceof PosterMap)
|
||||
setDataShape(((PosterMap) map).getColumnCount(), ((PosterMap) map).getRowCount());
|
||||
else
|
||||
setData(null); // Fallback to the empty view item.
|
||||
|
||||
|
||||
ItemStack back = new ItemStack(Material.EMERALD);
|
||||
ItemMeta meta = back.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.GREEN + "« Back");
|
||||
meta.setLore(Collections.singletonList(
|
||||
ChatColor.GRAY + "Go back to the list."
|
||||
));
|
||||
back.setItemMeta(meta);
|
||||
|
||||
ItemStack rename = new ItemStack(Material.BOOK_AND_QUILL);
|
||||
meta = rename.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.BLUE + "Rename this image");
|
||||
meta.setLore(Arrays.asList(
|
||||
ChatColor.GRAY + "Click here to rename this image;",
|
||||
ChatColor.GRAY + "this is used for your own organization."
|
||||
));
|
||||
rename.setItemMeta(meta);
|
||||
|
||||
ItemStack delete = new ItemStack(Material.BARRIER);
|
||||
meta = delete.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.RED + "Delete this image");
|
||||
meta.setLore(Arrays.asList(
|
||||
ChatColor.GRAY + "Deletes this map " + ChatColor.WHITE + "forever" + ChatColor.GRAY + ".",
|
||||
ChatColor.GRAY + "This action cannot be undone!",
|
||||
"",
|
||||
ChatColor.GRAY + "You will be asked to confirm your",
|
||||
ChatColor.GRAY + "choice if you click here."
|
||||
));
|
||||
delete.setItemMeta(meta);
|
||||
|
||||
|
||||
action("rename", getSize() - 7, rename);
|
||||
action("delete", getSize() - 6, delete);
|
||||
|
||||
|
||||
// To keep the controls centered, the back button is shifted to the right when the
|
||||
// arrow isn't displayed, so when the map fit on the grid without sliders.
|
||||
int backSlot = getSize() - 4;
|
||||
|
||||
if(map instanceof PosterMap && ((PosterMap) map).getColumnCount() <= INVENTORY_ROW_SIZE)
|
||||
backSlot++;
|
||||
|
||||
action("back", backSlot, back);
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
@Override
|
||||
protected void onRightClick(ImageMap data)
|
||||
{
|
||||
if(data instanceof SingleMap) return;
|
||||
Gui.open(getPlayer(), new MapDetailGui((PosterMap)data));
|
||||
Gui.open(getPlayer(), new MapDetailGui(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user