Revert "Replace the old menu layout with direct actions from the supplied design"
This reverts commit 121b4c7d46.
This commit is contained in:
parent
121b4c7d46
commit
6aa77a3d65
9 changed files with 107 additions and 276 deletions
|
|
@ -275,7 +275,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
var visible = new ArrayList<>(controls.subList(start, end));
|
||||
while (visible.size() < CHECKOUT_CONTROLS) visible.add(new Card(EMPTY, "", List.of(), false));
|
||||
for (int slot : new int[]{CHECKOUT_BACK,CHECKOUT_PRIMARY}) {
|
||||
visible.add(document.cards().stream().filter(card -> card.slot() == slot).findFirst().orElse(new Card(EMPTY, "", List.of(), false)));
|
||||
visible.add(document.cards().stream().filter(card -> card.slot() == slot).findFirst().orElseThrow());
|
||||
}
|
||||
if (controls.size() > CHECKOUT_CONTROLS) {
|
||||
String number = "Page " + (index + 1) + " / " + ((controls.size() + CHECKOUT_CONTROLS - 1) / CHECKOUT_CONTROLS);
|
||||
|
|
@ -685,7 +685,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
if (!wrap(graphics, styledTitle(document), 500, 1).complete) return false;
|
||||
if (document.style() == Style.EXCHANGE_CHECKOUT) {
|
||||
if (document.description().isBlank() || !hasCheckoutAction(document, CHECKOUT_BACK) ||
|
||||
(!document.title().equals("Exchange · Price") && !hasCheckoutAction(document, CHECKOUT_PRIMARY))) return false;
|
||||
!hasCheckoutAction(document, CHECKOUT_PRIMARY)) return false;
|
||||
graphics.setFont(CHECKOUT_TERMS);
|
||||
var terms = checkoutTerms(graphics, document.description());
|
||||
if (terms.isEmpty() || terms.size() > 9) return false;
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
String title="Spacing Guild · Imperial passage";
|
||||
int own=Arrays.asList(IDS).indexOf(house);Screen screen=screen(p,title,0xE330+own);
|
||||
var allowedDestinations=quotedDestinations(data.getAsJsonObject("guildQuote"));
|
||||
var routeCards=new ArrayList<DecisionsViewTransport.Card>();
|
||||
for(int i=0;i<GuildRoutes.ALL.size();i++){
|
||||
var route=GuildRoutes.ALL.get(i);boolean allowed=allowedDestinations.contains(route.world());
|
||||
String unavailable="Unavailable · another House world";
|
||||
|
|
@ -199,20 +200,26 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
screen.inventory.setItem(slot,item.clone());
|
||||
if(allowed)screen.actions.put(slot,()->bookPassage(p,data,route.world()));
|
||||
}
|
||||
|
||||
routeCards.add(new DecisionsViewTransport.Card(centre,route.name(),List.of(allowed?
|
||||
(route.house().equals(house)?"Your House":"Imperial passage"):unavailable),allowed,
|
||||
"guild_world_"+route.world()+(allowed?"":"_locked")));
|
||||
}
|
||||
String cancellation="No fare is taken for a cancelled booking";
|
||||
String adviser="Return to your House adviser";
|
||||
button(screen,p,45,"Your Mentat",adviser,Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
|
||||
routeCards.add(new DecisionsViewTransport.Card(45,"Your Mentat",List.of(adviser),true));
|
||||
button(screen,p,49,"Cancel booking",cancellation,Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});
|
||||
for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
|
||||
routeCards.add(new DecisionsViewTransport.Card(49,"Cancel booking",List.of(cancellation),true));
|
||||
if(guild!=null){
|
||||
String bookingLabel=booked==null?"Book passage":"Review booked passage";
|
||||
button(screen,p,53,bookingLabel,detail,Material.EMERALD,()->bookPassage(p,data));screen.actions.put(52,screen.actions.get(53));
|
||||
routeCards.add(new DecisionsViewTransport.Card(53,bookingLabel,List.of(),true));
|
||||
}
|
||||
String nativeDetail=detail;
|
||||
if(booked!=null)nativeDetail+="\nBooked to "+booked.world()+" · "+String.format(Locale.ROOT,"%.2f DM",booked.fare()/100.0);
|
||||
if(MCGUIMenus.show(p,title,nativeDetail,screen.inventory,screen.actions,screen.gate))return;
|
||||
if(NativeMenus.showGuild(this,p,title,nativeDetail,routeCards,screen.actions,screen.gate))return;
|
||||
if(MCGUIMenus.show(p,"Spacing Guild · Imperial passage","",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
private void cancelBooking(Player p){boolean removed=bookings.cancel(p.getUniqueId());removed=boarding.remove(p.getUniqueId())||removed;p.sendMessage(removed?"Guild passage cancelled. No fare was charged.":"You have no pending Guild booking.");}
|
||||
|
|
|
|||
|
|
@ -1,223 +0,0 @@
|
|||
package com.dunerealms.gui;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import static com.dunerealms.gui.MenuDocument.escape;
|
||||
|
||||
/** Designs from the supplied menu previews. Only existing document slots can be selected. */
|
||||
final class DuneMenuDesign {
|
||||
private static final Pattern PROGRESS = Pattern.compile("(?:Progress: )?([0-9]{1,15}) / ([0-9]{1,15})");
|
||||
private static final Set<String> JOURNAL_CONTROLS = Set.of("Back", "Branches", "Previous", "Next", "Refresh");
|
||||
private static final List<Integer> CONCOURSE_ORDER = List.of(43,40,34,31,19,22,25,28,32,37,4,8);
|
||||
|
||||
private DuneMenuDesign() {}
|
||||
|
||||
static String concourse(List<MenuDocument.Card> cards, Path root) {
|
||||
StringBuilder out = header("The Imperial Concourse", "concourse");
|
||||
var rescue = cards.stream().filter(card -> card.slot() == 8).findFirst();
|
||||
out.append("<main aria-label=\"Imperial services\">");
|
||||
rescue.ifPresent(card -> {
|
||||
out.append("<div class=\"rescue\">");
|
||||
card(out, card, root, false);
|
||||
out.append("</div>");
|
||||
});
|
||||
out.append("<section class=\"crest\">");
|
||||
cards.stream().filter(card -> card.slot() == 43).findFirst().ifPresent(card -> card(out,card,root,false));
|
||||
out.append("</section>");
|
||||
for (int from = 1; from < CONCOURSE_ORDER.size() - 1; from += 4) {
|
||||
out.append("<section class=\"doors\">");
|
||||
for (int slot : CONCOURSE_ORDER.subList(from, Math.min(from + 4, CONCOURSE_ORDER.size() - 1)))
|
||||
cards.stream().filter(card -> card.slot() == slot).findFirst().ifPresent(card -> card(out,card,root,false));
|
||||
if(from==9)
|
||||
cards.stream().filter(card -> !CONCOURSE_ORDER.contains(card.slot()) && !card.title().equals("Close"))
|
||||
.forEach(card -> card(out,card,root,false));
|
||||
out.append("</section>");
|
||||
}
|
||||
return finish(out, cards, Set.of("Close"));
|
||||
}
|
||||
|
||||
static String journal(String title, List<MenuDocument.Card> cards, Path root) {
|
||||
StringBuilder out = header(title, "journal");
|
||||
out.append("<main class=\"records\" aria-label=\"Mission records\">");
|
||||
for (var card : cards)
|
||||
if (!JOURNAL_CONTROLS.contains(card.title())) card(out,card,root,true);
|
||||
return finish(out, cards, JOURNAL_CONTROLS);
|
||||
}
|
||||
|
||||
static String travel(String title, String description, List<MenuDocument.Card> cards, Path root) {
|
||||
StringBuilder out = header(title, "travel");
|
||||
out.append("<main class=\"star-map\" aria-label=\"Guild routes\">");
|
||||
if (!description.isBlank()) out.append("<p class=\"terms\">").append(escape(description)).append("</p>");
|
||||
out.append("<section class=\"north-routes\">");
|
||||
var destinationNames=new HashSet<String>();
|
||||
var destinations=cards.stream().filter(card -> card.slot()<45&&destinationNames.add(card.title())).toList();
|
||||
for (var card : destinations.stream().limit(3).toList()) card(out,card,root,false);
|
||||
out.append("</section><p class=\"station\">Spacing Guild</p><section class=\"south-routes\">");
|
||||
for (var card : destinations.stream().skip(3).toList()) card(out,card,root,false);
|
||||
out.append("</section><section class=\"guild-controls\">");
|
||||
for (var card : cards) if(card.slot()>=45) card(out,card,root,false);
|
||||
return finish(out.append("</section>"),cards,Set.of());
|
||||
}
|
||||
|
||||
static String spice(List<MenuDocument.Card> cards, Path root) {
|
||||
StringBuilder out = header("Arrakis · The Spice Trade", "spice");
|
||||
out.append("<main class=\"spice-route\" aria-label=\"Spice buyers\">");
|
||||
var back = Set.of("Back");
|
||||
for (var card : cards) {
|
||||
if (back.contains(card.title())) continue;
|
||||
out.append("<div class=\"spice-").append(card.slot()).append("\">");
|
||||
card(out,card,root,false);
|
||||
out.append("</div>");
|
||||
}
|
||||
return finish(out,cards,back);
|
||||
}
|
||||
|
||||
static String market(String title, List<MenuDocument.Card> cards, Path root) {
|
||||
StringBuilder out = header(title, "market");
|
||||
var footer=Set.of("Back","Previous","Next","Imperial Codex","Collect purchases");
|
||||
out.append("<main class=\"market-hall\"><aside aria-label=\"Market categories\">");
|
||||
for(var card:cards)if(card.slot()<9||card.title().equals("Add held item"))card(out,card,root,false);
|
||||
out.append("</aside><section class=\"market-stock\" aria-label=\"Listings\">");
|
||||
var stock=cards.stream().filter(card->card.slot()>=9&&!footer.contains(card.title())&&!card.title().equals("Add held item")).toList();
|
||||
for(int i=0;i<stock.size();i+=5){
|
||||
out.append("<div class=\"shelf\">");
|
||||
for(var card:stock.subList(i,Math.min(i+5,stock.size())))card(out,card,root,false);
|
||||
out.append("</div>");
|
||||
}
|
||||
return finish(out.append("</section>"),cards,footer);
|
||||
}
|
||||
|
||||
static String house(String title,List<MenuDocument.Card> cards,Path root){
|
||||
StringBuilder out=header(title,"house");
|
||||
var controls=Set.of("Back","Close");
|
||||
out.append("<main class=\"house-map\">");
|
||||
var seals=new HashSet<String>();
|
||||
for(var card:cards){
|
||||
if(controls.contains(card.title())||!seals.add(card.title()))continue;
|
||||
card(out,card,root,false);
|
||||
}
|
||||
return finish(out,cards,controls);
|
||||
}
|
||||
|
||||
static String refit(String title,List<MenuDocument.Card> cards,Path root){
|
||||
StringBuilder out=header("Quartermaster · Refit","refit");
|
||||
var controls=Set.of("Back");
|
||||
out.append("<main class=\"refit-bench\">");
|
||||
for(var card:cards)if(!controls.contains(card.title()))card(out,card,root,false);
|
||||
return finish(out,cards,controls);
|
||||
}
|
||||
|
||||
static String hearth(String title,List<MenuDocument.Card> cards,Path root,MenuDocument.Branding branding){
|
||||
StringBuilder out=header(title,"hearth");
|
||||
var controls=Set.of("Back","Close");
|
||||
out.append("<main class=\"hearth-network\"><section class=\"hearth-identity\">");
|
||||
if(branding.logo().length()<=110000&&branding.logo().matches("[A-Za-z0-9+/]+={0,2}"))
|
||||
out.append("<img class=\"emblem\" alt=\"Organisation emblem\" src=\"data:image/png;base64,").append(branding.logo()).append("\">");
|
||||
if(branding.portrait()>=0&&branding.portrait()<=7)
|
||||
out.append("<img class=\"portrait\" alt=\"\" src=\"art/npc_avatar_").append(branding.portrait()).append(".png\">");
|
||||
if(!branding.mentat().isBlank())out.append("<p>").append(escape(branding.mentat())).append("</p>");
|
||||
var centre=cards.stream().filter(card->card.slot()==4).findFirst();
|
||||
centre.ifPresent(card->card(out,card,root,false));
|
||||
out.append("</section><section class=\"hearth-actions\">");
|
||||
for(var card:cards)if(card.slot()!=4&&!controls.contains(card.title()))card(out,card,root,false);
|
||||
return finish(out.append("</section>"),cards,controls);
|
||||
}
|
||||
|
||||
static String decisions(String title,String description,List<MenuDocument.Card> cards,Path root){
|
||||
StringBuilder out=header("Decisions of Office","decisions");
|
||||
var controls=Set.of("Back","Previous","Next","Close");
|
||||
out.append("<main class=\"decision-ledger\"><h2>").append(escape(title.substring(title.indexOf(" · ")+3))).append("</h2>");
|
||||
if(!description.isBlank())out.append("<p>").append(escape(description)).append("</p>");
|
||||
for(var card:cards)if(!controls.contains(card.title()))card(out,card,root,true);
|
||||
return finish(out,cards,controls);
|
||||
}
|
||||
|
||||
static String standard(String title,String description,List<MenuDocument.Card> cards,Path root){
|
||||
StringBuilder out=header(title,"services");
|
||||
var controls=Set.of("Back","Close","Previous","Next","Back to listing");
|
||||
out.append("<main class=\"service-records\">");
|
||||
if(!description.isBlank())out.append("<p>").append(escape(description).replace("\n","<br>")).append("</p>");
|
||||
for(var card:cards)if(!controls.contains(card.title()))card(out,card,root,true);
|
||||
out.append("</main><footer><button data-slot=\"-3\">Home</button>");
|
||||
for(var card:cards)if(card.action()&&controls.contains(card.title()))
|
||||
out.append("<button data-slot=\"").append(card.slot()).append("\">").append(escape(card.title())).append("</button>");
|
||||
return out.append("</footer></div></body></html>").toString();
|
||||
}
|
||||
|
||||
private static StringBuilder header(String title, String theme) {
|
||||
return new StringBuilder("<!doctype html><html><head><meta charset=\"utf-8\"><style>")
|
||||
.append(CSS).append("</style></head><body class=\"").append(theme)
|
||||
.append("\"><div class=\"frame\"><header><img src=\"art/dunerealms-season-logo-v2.png\" alt=\"DuneRealms\"><h1>")
|
||||
.append(escape(title)).append("</h1></header>");
|
||||
}
|
||||
|
||||
private static void card(StringBuilder out, MenuDocument.Card card, Path root, boolean journal) {
|
||||
String mark = card.action() ? "button" : "article";
|
||||
out.append('<').append(mark).append(" class=\"").append(journal ? "record" : "door").append('"');
|
||||
if (card.action()) out.append(" data-slot=\"").append(card.slot()).append('"');
|
||||
out.append('>');
|
||||
String icon=MenuDocument.icon(card,root);
|
||||
if (!icon.isEmpty()) out.append("<img class=\"icon\" src=\"").append(escape(icon)).append("\" alt=\"\">");
|
||||
out.append("<strong>").append(escape(card.title())).append("</strong>");
|
||||
for (String line : card.lore()) {
|
||||
out.append("<span>").append(escape(line)).append("</span>");
|
||||
var match = PROGRESS.matcher(line);
|
||||
if (journal && match.matches() && Long.parseLong(match.group(2)) > 0) {
|
||||
long percent = Math.min(100,Math.round(100d * Long.parseLong(match.group(1)) / Long.parseLong(match.group(2))));
|
||||
out.append("<div class=\"track\" role=\"progressbar\" aria-valuenow=\"").append(percent)
|
||||
.append("\"><div class=\"progress\" style=\"width:").append(percent).append("%\"></div></div>");
|
||||
}
|
||||
}
|
||||
out.append("</").append(mark).append('>');
|
||||
}
|
||||
|
||||
private static String finish(StringBuilder out, List<MenuDocument.Card> cards, Set<String> controls) {
|
||||
out.append("</main><footer>");
|
||||
for (var card : cards)
|
||||
if (card.action() && controls.contains(card.title()))
|
||||
out.append("<button data-slot=\"").append(card.slot()).append("\">").append(escape(card.title())).append("</button>");
|
||||
return out.append("</footer></div></body></html>").toString();
|
||||
}
|
||||
|
||||
private static final String CSS = """
|
||||
*{box-sizing:border-box}body{margin:0;background:#071b18;color:#f2deb0;font-family:Georgia,serif}
|
||||
.frame{border:5px double #c89d53;min-height:596px;padding:8px;background:#0c2624}
|
||||
header{height:88px;border-bottom:4px double #dfb963;background:linear-gradient(#204942,#102d29);display:flex;align-items:center;padding:0 20px;gap:34px}
|
||||
header img{width:215px;max-height:74px;object-fit:contain}h1{color:#f2c870;font-size:34px;margin:0}
|
||||
main{padding:12px 20px}button{font:inherit;color:inherit}button:hover{border-color:#fff0b2;background:#265a4c}
|
||||
.concourse main{position:relative;background:linear-gradient(#4f322b,#a36138,#55331f);text-align:center}
|
||||
.crest,.doors{display:flex;justify-content:center;gap:16px;margin:10px 0}
|
||||
.door,.record{background:linear-gradient(#234f47,#0d2927);border:2px solid #cda759;box-shadow:inset 0 0 0 2px #0b2724}
|
||||
.door{width:175px;min-height:91px;padding:8px;display:block}
|
||||
.door strong,.record strong{color:#f4d991;font-size:19px;display:block}.door span,.record span{display:block;font:14px Arial;color:#e0e5cb;margin-top:4px}
|
||||
.icon{width:36px;height:36px;object-fit:contain;image-rendering:pixelated}.rescue{position:absolute;right:20px;top:12px}.rescue .door{width:270px;min-height:50px;border-color:#eba85c}
|
||||
.rescue .icon{display:none}
|
||||
.records{background:linear-gradient(#183b36,#0a2825);min-height:385px}
|
||||
.record{display:block;width:100%;min-height:66px;text-align:left;margin:8px 0;padding:10px 14px}.record .icon{float:left;margin:0 12px 0 0}
|
||||
.track{height:9px;margin-top:8px;background:#091d1a;border:1px solid #ac884a}.progress{height:100%;background:#dabb5e}
|
||||
.star-map{background:linear-gradient(#111432,#1d2544,#10172b);text-align:center;min-height:420px}
|
||||
.north-routes,.south-routes,.guild-controls{display:flex;justify-content:center;gap:16px;flex-wrap:wrap}
|
||||
.station{margin:12px auto;padding:8px 22px;width:208px;border:2px dotted #d3a961;color:#f7d278;font-size:22px}
|
||||
.travel .door{border-color:#b89a62;background:linear-gradient(#202f4d,#101b2c)}.travel article{opacity:.65}
|
||||
.guild-controls{margin-top:16px}.guild-controls .door{min-height:50px}.guild-controls .icon{display:none}
|
||||
.spice-route{background:linear-gradient(#883d25,#a7592d,#412317);display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr 1fr;gap:30px;min-height:390px;align-items:center;text-align:center}
|
||||
.spice-route .door{width:100%}.spice-4{grid-column:1;grid-row:1 / 3}.spice-11{grid-column:2;grid-row:1}.spice-15{grid-column:2;grid-row:2}.spice-26{grid-column:3;grid-row:1 / 3}
|
||||
.market-hall{display:flex;gap:18px;background:linear-gradient(#784d25,#392713);min-height:400px}.market-hall aside{width:155px;flex-shrink:0}
|
||||
.market-hall aside .door{width:100%;margin-bottom:8px}.market-stock{flex:1}.shelf{display:flex;gap:8px;padding:7px 5px;border-bottom:4px solid #a8783b}
|
||||
.shelf .door{width:18.8%;min-height:92px;text-align:center}.shelf .door strong{font-size:16px}.shelf .door span{font-size:12px}
|
||||
.house-map{display:flex;justify-content:center;gap:20px;flex-wrap:wrap;align-content:center;min-height:403px;background:linear-gradient(#4a3352,#292941,#131e2b)}
|
||||
.house-map .door{width:220px;min-height:155px}
|
||||
.refit-bench{display:flex;justify-content:center;gap:30px;align-items:center;min-height:390px;background:linear-gradient(#1a4154,#101e2d)}.refit-bench .door{width:300px;min-height:150px}
|
||||
.hearth-network{display:flex;align-items:center;gap:26px;min-height:390px;background:linear-gradient(#154839,#0b2d26)}
|
||||
.hearth-identity{width:29%;text-align:center}.hearth-identity .door{width:100%}
|
||||
.emblem,.portrait{width:78px;height:78px;object-fit:contain}.portrait{margin-left:8px}
|
||||
.hearth-actions{display:flex;flex:1;flex-wrap:wrap;gap:10px}.hearth-actions .door{width:30%}
|
||||
.decision-ledger{background:linear-gradient(#37274e,#19152d);min-height:390px}.decision-ledger .record{border-color:#bb98ce}
|
||||
.service-records{min-height:390px;background:linear-gradient(#20433c,#0a2825)}
|
||||
footer{height:58px;display:flex;align-items:center;gap:10px;padding:0 20px;border-top:2px solid #a78347}
|
||||
footer button{padding:7px 14px;background:#142f2d;border:1px solid #cc9f50}
|
||||
""";
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
private void editPrice(Player p,Draft draft){
|
||||
var s=panel(p,"Exchange · Price");s.description=money(draft.price)+" per item · "+draft.amount+" items\nTotal: "+money(draft.price*draft.amount);s.inventory.setItem(13,icon(Material.GOLD_INGOT,"Price: "+money(draft.price),"Per item · total "+money(draft.price*draft.amount)));
|
||||
long[] steps={1,100,1000,10000};for(int i=0;i<steps.length;i++){long step=steps[i];button(s,27+i,Material.RED_DYE,"− "+money(step),"Decrease the price per item",()->editPrice(p,draft.price(Math.max(1,draft.price-step))));button(s,32+i,Material.LIME_DYE,"+ "+money(step),"Increase the price per item",()->editPrice(p,draft.price(Math.min(100000000,draft.price+step))));}
|
||||
button(s,45,Material.ARROW,"Back to listing","Review the current price before publishing",()->sell(p,draft));button(s,53,Material.NAME_TAG,"Type exact price","Optional private text entry",()->typePrice(p,draft));show(p,s);
|
||||
button(s,45,Material.ARROW,"Back to listing","Review the current price before publishing",()->sell(p,draft));button(s,49,Material.EMERALD,"Use price: "+money(draft.price),"Review the listing before publishing",()->sell(p,draft));button(s,53,Material.NAME_TAG,"Type exact price","Optional private text entry",()->typePrice(p,draft));show(p,s);
|
||||
}
|
||||
private void quantityPresets(Panel s,int available,IntConsumer choose){for(int i=0;i<3;i++){int amount=new int[]{16,32,64}[i];button(s,21+i,Material.CHEST,String.valueOf(amount),"Set quantity · maximum "+available,()->choose.accept(Math.min(amount,available)));}}
|
||||
private void typePrice(Player p,Draft draft){
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -15,7 +15,6 @@ final class NativeMenus {
|
|||
static boolean show(JavaPlugin plugin, Player player, String setting, String title, String description,
|
||||
Inventory inventory, Map<Integer,Runnable> actions, GuiSession gate,
|
||||
DecisionsViewTransport.Style style, MenuDocument.Branding branding) {
|
||||
if (style != DecisionsViewTransport.Style.AUTO) return false;
|
||||
if (!plugin.getConfig().getStringList(setting).contains(player.getUniqueId().toString())) return false;
|
||||
var transport = Bukkit.getServicesManager().load(DecisionsViewTransport.class);
|
||||
if (transport == null) return false;
|
||||
|
|
@ -24,6 +23,14 @@ final class NativeMenus {
|
|||
return show(player, plugin, transport, title, description, cards, actions, gate, style, branding);
|
||||
}
|
||||
|
||||
static boolean showGuild(JavaPlugin plugin, Player player, String title, String description,
|
||||
List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions, GuiSession gate) {
|
||||
if (!plugin.getConfig().getStringList("development.fullscreen-guild-viewers").contains(player.getUniqueId().toString())) return false;
|
||||
var transport = Bukkit.getServicesManager().load(DecisionsViewTransport.class);
|
||||
return transport != null && show(player, plugin, transport, title, description, cards, actions, gate,
|
||||
DecisionsViewTransport.Style.GUILD, null);
|
||||
}
|
||||
|
||||
private static boolean show(Player player, JavaPlugin plugin, DecisionsViewTransport transport, String title,
|
||||
String description, List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions,
|
||||
GuiSession gate, DecisionsViewTransport.Style style, MenuDocument.Branding branding) {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ final class OrganisationMenus implements Listener {
|
|||
}
|
||||
void lore(Player p){
|
||||
var panel=panel(p,"Item lore archive · Preview",false);panel.nativeStyle=DecisionsViewTransport.Style.ITEM_ARCHIVE;panel.nativeSetting="development.fullscreen-codex-viewers";String[] kinds={"MENU","EQUIPMENT","KIT","COMPONENT","TICKET","CASH","RIHLA","DEED","QUEST"};Material[] materials={Material.COMPASS,Material.IRON_SWORD,Material.CHEST,Material.AMETHYST_SHARD,Material.PAPER,Material.GOLD_NUGGET,Material.WRITABLE_BOOK,Material.MAP,Material.BOOK};
|
||||
for(int i=0;i<kinds.length;i++){String kind=kinds[i];Map<String,String> facts=switch(kind){case "EQUIPMENT"->Map.of("Grade","From issued equipment key","House","From House key","Durability","From actual item");case "KIT"->Map.of("Contents","From kit definition","State","Design preview");case "COMPONENT"->Map.of("Recipe","From crafting definition");case "TICKET"->Map.of("Route","From passage key","Departure",":00 / :20 / :40");case "CASH"->Map.of("Value","From bank withdrawal","State","Design preview");case "RIHLA"->Map.of("Recipient","From RIA key","Amount","From transfer record");case "DEED"->Map.of("Organisation","From registered deed","Holder","From current authority");case "QUEST"->Map.of("Objective","From mission key","Progress","From verified events");default->Map.of("Service","DuneRealms","Access","Current JARVIS keys");};try{panel.inventory.setItem(18+i,bridge.lorePreview(kind,materials[i],kind.equals("RIHLA")?"Rihla":kind.replace('_',' '),facts));}catch(Exception unavailable){p.sendMessage("The lore renderer is temporarily unavailable.");return;}}
|
||||
for(int i=0;i<kinds.length;i++){String kind=kinds[i];Map<String,String> facts=switch(kind){case "EQUIPMENT"->Map.of("Grade","From issued equipment key","House","From House key","Durability","From actual item");case "KIT"->Map.of("Contents","From kit definition","State","Design preview");case "COMPONENT"->Map.of("Recipe","From crafting definition");case "TICKET"->Map.of("Route","From passage key","Departure",":00 / :20 / :40");case "CASH"->Map.of("Value","From bank withdrawal","State","Design preview");case "RIHLA"->Map.of("Recipient","From RIA key","Amount","From transfer record");case "DEED"->Map.of("Organisation","From registered deed","Holder","From current authority");case "QUEST"->Map.of("Objective","From mission key","Progress","From verified events");default->Map.of("Service","DuneRealms","Access","Current JARVIS keys");};try{panel.inventory.setItem(18+i,bridge.lorePreview(kind,materials[i],kind.replace('_',' '),facts));}catch(Exception unavailable){p.sendMessage("The lore renderer is temporarily unavailable.");return;}}
|
||||
put(panel,45,"Back","Imperial Codex",Material.ARROW,()->console(p));close(panel,p);show(p,panel);
|
||||
}
|
||||
private void start(Player p,JsonObject data){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class MenuDocumentTest {
|
|||
@Test void compactTradeControlsActDirectlyAndNavigationUsesTheActualBackCallback(){
|
||||
var amount=new MenuDocument.Card(21,"16",List.of(),"chest",1,true,"");var price=new MenuDocument.Card(27,"− 0.01 DM",List.of(),"red_dye",1,true,"");var back=new MenuDocument.Card(45,"Back",List.of(),"arrow",1,true,"");
|
||||
String html=MenuDocument.html("Exchange","","Player",List.of(amount,price,back),-1,Path.of("."));
|
||||
assertTrue(MenuDocument.compactControl(amount));assertTrue(MenuDocument.compactControl(price));assertFalse(MenuDocument.compactControl(back));assertTrue(html.contains("data-slot=\"21\""));assertFalse(html.contains("data-pick=\"21\""));assertTrue(html.contains("data-slot=\"-3\">Home"));assertTrue(html.contains("data-slot=\"45\">Back"));
|
||||
assertTrue(MenuDocument.compactControl(amount));assertTrue(MenuDocument.compactControl(price));assertFalse(MenuDocument.compactControl(back));assertTrue(html.contains("data-slot=\"21\">16</button>"));assertFalse(html.contains("data-pick=\"21\""));assertTrue(html.contains("data-slot=\"-3\">⌂ Home"));assertTrue(html.contains("data-slot=\"45\">← Back"));
|
||||
}
|
||||
@Test void itemNamesAndLoreCannotBecomeHtmlOrCommands(){
|
||||
var card=new MenuDocument.Card(13,"<script>bad</script>",List.of("<button data-console=\"op me\">click</button>"),"../../secret",1,true,"legendary");
|
||||
|
|
@ -25,39 +25,9 @@ class MenuDocumentTest {
|
|||
var row=new MenuDocument.Card(10,"Imperial passage",List.of("Current eligible decision"),"book",1,true,"");
|
||||
var journal=new MenuDocument.Card(49,"Website journal",List.of(),"map",1,true,"");
|
||||
String before=MenuDocument.html("NPC dashboard decision · Emperor","", "Player",List.of(row,journal),-1,Path.of("."));
|
||||
assertTrue(before.contains("Decisions of Office"));
|
||||
assertTrue(before.contains("YOUR DECISIONS"));
|
||||
assertTrue(before.contains("data-slot=\"10\""));
|
||||
assertFalse(before.contains("data-pick=\"10\""));
|
||||
assertTrue(MenuDocument.html("NPC next quest decision · Emperor","", "Player",List.of(journal),-1,Path.of(".")).contains("DECISION RECORDED"));
|
||||
}
|
||||
@Test void suppliedDesignRoutesKeepAuthoritativeSlotsAndReadOnlyCards(){
|
||||
var root=Path.of(".");
|
||||
var rescue=new MenuDocument.Card(8,"Emergency rescue · 1,000 DM",List.of("Teleport to safety and heal"),"book",1,true,"");
|
||||
var house=new MenuDocument.Card(43,"Your House",List.of("Your adviser"),"book",1,true,"");
|
||||
String hub=MenuDocument.html("Imperial Codex","","Player",List.of(rescue,house),-1,root);
|
||||
assertTrue(hub.contains("The Imperial Concourse"));
|
||||
assertFalse(hub.contains("data-pick="));
|
||||
assertFalse(hub.contains("class=\"primary\""));
|
||||
assertTrue(hub.contains("data-slot=\"8\""));
|
||||
assertTrue(hub.contains("data-slot=\"43\""));
|
||||
assertFalse(hub.contains("Rihla ATM"));
|
||||
var route=new MenuDocument.Card(10,"Kaladam",List.of("Guild fare: 250.00 DM"),"book",1,true,"");
|
||||
var locked=new MenuDocument.Card(13,"Locked route",List.of("Unavailable"),"book",1,false,"");
|
||||
String travel=MenuDocument.html("Spacing Guild · Imperial passage","","Player",List.of(route,locked),-1,root);
|
||||
assertTrue(travel.contains("star-map"));
|
||||
assertTrue(travel.contains("250.00 DM"));
|
||||
assertTrue(travel.contains("data-slot=\"10\""));
|
||||
assertFalse(travel.contains("data-slot=\"13\""));
|
||||
var quest=new MenuDocument.Card(0,"Delivered",List.of("active","2 / 5"),"book",1,true,"");
|
||||
String journal=MenuDocument.html("Missions · Personal","","Player",List.of(quest),-1,root);
|
||||
assertTrue(journal.contains("aria-valuenow=\"40\""));
|
||||
assertTrue(journal.contains("data-slot=\"0\""));
|
||||
}
|
||||
@Test void ordinaryMenusNeverAddASecondActionButton(){
|
||||
var action=new MenuDocument.Card(49,"Publish listing",List.of("Move 12 items into the Exchange"),"book",1,true,"");
|
||||
String html=MenuDocument.html("Exchange · Add item","12 items","Player",List.of(action),49,Path.of("."));
|
||||
assertTrue(html.contains("data-slot=\"49\""));
|
||||
assertFalse(html.contains("data-pick=\"49\""));
|
||||
assertFalse(html.contains("class=\"primary\""));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public final class ItemLoreCard {
|
|||
CONSUMABLE("CONSUMABLE",List.of("Class","Consume","Effects","Duration")),
|
||||
TICKET("GUILD PASSAGE",List.of("Route","Departure","Valid until","State")),
|
||||
CASH("DUNEMARK CURRENCY",List.of("Value","Issuer","State")),
|
||||
RIHLA("Rihla transfer",List.of("Recipient","Amount","State")),
|
||||
RIHLA("RIHLA TRANSFER",List.of("Recipient","Amount","State")),
|
||||
DEED("REGISTERED DEED",List.of("Organisation","Office","Holder","Term","State")),
|
||||
QUEST("MISSION INSTRUMENT",List.of("Objective","Progress","Reward","State"));
|
||||
final String label;final List<String> fields;
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff