Compact Dune menu cards and repair service navigation
This commit is contained in:
parent
31dbf92e9c
commit
b4dd9e42c3
17 changed files with 488 additions and 32 deletions
52
.forgejo/workflows/compact-menu-links.yml
Normal file
52
.forgejo/workflows/compact-menu-links.yml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
name: Compact Dune Menu Overlay
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/compact-menu-links-*']
|
||||
|
||||
jobs:
|
||||
compact-menu-links:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test menu routes and package only scoped UI classes
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
for module in DuneRealmsGUI DuneMenus DuneLobby; do
|
||||
gradle --no-daemon -p "$module" test jar
|
||||
done
|
||||
mkdir compact-menu-links
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_menu_polish import CLASSES
|
||||
from plugin_wild_update import read_archive, write_archive
|
||||
for module, jar in {"gui":"DuneRealmsGUI/build/libs/DunerealmsGUI.jar", "menus":"DuneMenus/build/libs/DuneMenus.jar", "lobby":"DuneLobby/build/libs/DuneRealms-Lobby.jar"}.items():
|
||||
source = read_archive(Path(jar).read_bytes())
|
||||
entries = list(CLASSES[module])
|
||||
if module in ("gui", "menus"): entries.append("com/dunerealms/" + module + "/MenuPolish.class")
|
||||
Path("compact-menu-links/" + module + ".zip").write_bytes(write_archive({e:source[e] for e in entries}))
|
||||
PY
|
||||
cp tools/{plugin_menu_polish.py,plugin_wild_update.py,CompactMenuMerge.java} compact-menu-links/
|
||||
printf '%s\n' "$GITHUB_SHA" > compact-menu-links/SOURCE_COMMIT
|
||||
(cd compact-menu-links && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Compact-Menu-Links
|
||||
path: compact-menu-links
|
||||
if-no-files-found: error
|
||||
|
|
@ -180,7 +180,7 @@ public final class DuneLobby extends JavaPlugin implements Listener, CommandExec
|
|||
e.getPlayer().sendMessage("The Spacing Guild menu is unavailable.");
|
||||
}
|
||||
}
|
||||
case "exchange" -> { if(Bukkit.getPluginCommand("dune")!=null) e.getPlayer().performCommand("dune exchange"); else e.getPlayer().sendMessage(ChatColor.GOLD+"Koopkring market integration requires DuneCore on this backend."); }
|
||||
case "exchange" -> { if(!e.getPlayer().performCommand("dunerealmsgui:exchange")) e.getPlayer().sendMessage("The Exchange service is temporarily unavailable."); }
|
||||
case "water","spice" -> trade(e.getPlayer(),role);
|
||||
}
|
||||
}
|
||||
|
|
@ -207,29 +207,11 @@ public final class DuneLobby extends JavaPlugin implements Listener, CommandExec
|
|||
|
||||
}
|
||||
}
|
||||
private void departure(Player player,String planet) {
|
||||
TravelMenu menu=new TravelMenu(planet); ItemStack confirm=new ItemStack(Material.LIME_CONCRETE); ItemMeta meta=confirm.getItemMeta();
|
||||
meta.setDisplayName("Confirm departure: "+planet); meta.setLore(List.of("DuneEss fares and access rules apply when installed.")); confirm.setItemMeta(meta);
|
||||
menu.inventory.setItem(4,confirm);
|
||||
com.example.dunegui.NativeMenus.show(this,player,"Guild departure",List.of(
|
||||
new com.example.dunegui.NativeMenus.Choice("Confirm departure: "+planet,"DuneEss fares and access rules apply.",()->depart(player,planet)),
|
||||
new com.example.dunegui.NativeMenus.Choice("Cancel","",player::closeInventory)));
|
||||
}
|
||||
private void departure(Player player,String planet) { depart(player,planet); }
|
||||
private void depart(Player player,String planet) {
|
||||
long now=System.currentTimeMillis(); if(now-travelCooldown.getOrDefault(player.getUniqueId(),0L)<5000) return;
|
||||
travelCooldown.put(player.getUniqueId(),now);
|
||||
Bukkit.getScheduler().runTask(this,()-> {
|
||||
player.closeInventory();
|
||||
if(Bukkit.getPluginCommand("duneess")!=null) { player.performCommand("duneess travel "+planet); return; }
|
||||
World target=Bukkit.getWorld(planet);
|
||||
if(target!=null) { player.teleport(target.getSpawnLocation()); return; }
|
||||
String server=getConfig().getString("servers."+planet,"");
|
||||
if(server.isBlank()) { player.sendMessage("No destination configured."); return; }
|
||||
try {
|
||||
ByteArrayOutputStream bytes=new ByteArrayOutputStream(); DataOutputStream out=new DataOutputStream(bytes); out.writeUTF("Connect"); out.writeUTF(server);
|
||||
player.sendPluginMessage(this,"BungeeCord",bytes.toByteArray()); player.sendMessage("Guild departure requested. If you remain here, the destination or proxy is unavailable.");
|
||||
} catch(IOException ex) { player.sendMessage("Guild departure could not be requested."); }
|
||||
});
|
||||
// Boarding remains with the authenticated current Guild quote and confirmation flow.
|
||||
if (!player.performCommand("dunerealmsgui:guildtravel"))
|
||||
player.sendMessage("The Spacing Guild menu is temporarily unavailable.");
|
||||
}
|
||||
@EventHandler public void drag(InventoryDragEvent e) { if(e.getView().getTopInventory().getHolder() instanceof TravelMenu) e.setCancelled(true); }
|
||||
@EventHandler public void quit(PlayerQuitEvent e) { travelCooldown.remove(e.getPlayer().getUniqueId()); }
|
||||
|
|
|
|||
87
DuneMenus/docs/menu-audit-20261205.json
Normal file
87
DuneMenus/docs/menu-audit-20261205.json
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"scope": "Current six Paper backends; source routes and saved Citizens records; no production payments or quest claims executed",
|
||||
"menuFamilies": [
|
||||
"hub",
|
||||
"travel",
|
||||
"exchange",
|
||||
"clan",
|
||||
"company",
|
||||
"missions",
|
||||
"spice",
|
||||
"war",
|
||||
"politics",
|
||||
"house",
|
||||
"equipment",
|
||||
"bank",
|
||||
"atm",
|
||||
"withdraw",
|
||||
"transfer"
|
||||
],
|
||||
"nativeServiceRoutes": [
|
||||
"hub",
|
||||
"travel",
|
||||
"exchange",
|
||||
"clan",
|
||||
"company",
|
||||
"missions",
|
||||
"spice",
|
||||
"war",
|
||||
"politics",
|
||||
"lore",
|
||||
"cookbook",
|
||||
"mentat",
|
||||
"house",
|
||||
"equipment"
|
||||
],
|
||||
"repairs": [
|
||||
"Explicit current Exchange Broker command",
|
||||
"Departure pads open current authenticated Guild menu without legacy direct teleport fallback",
|
||||
"Guild return menu gains Back to Imperial Codex",
|
||||
"Empty NPC mission views link to the current mission journal",
|
||||
"Cookbook command offered in completion and explicit Codex route",
|
||||
"Permission refusal produces feedback instead of a silent menu"
|
||||
],
|
||||
"guild": {
|
||||
"primaryWorldsWithSavedNavigator": [
|
||||
"arrakis",
|
||||
"caladan",
|
||||
"giedi_prime",
|
||||
"kaitain",
|
||||
"sigma_draconis_iv"
|
||||
],
|
||||
"lobby": "Guild Navigator Liaison",
|
||||
"enabledOnAllSix": true,
|
||||
"otherDimensions": "Guild command and marked-NPC handler are world independent; outside guild_lobby the menu presents the existing central return operation. No new NPC spawned or travel authority bypassed."
|
||||
},
|
||||
"npcPurposeReview": {
|
||||
"savedRecords": 45,
|
||||
"snapshotCaution": "Disk registry snapshot is not a fresh connected-client or spawned-entity census.",
|
||||
"legacyCopies": {
|
||||
"lobby_arrakis": {
|
||||
"unmappedQuestRoles": [
|
||||
"esmar_tuek",
|
||||
"stilgar",
|
||||
"shadout_mapes",
|
||||
"chani",
|
||||
"liet_kynes",
|
||||
"alia_atreides",
|
||||
"war_marshal"
|
||||
],
|
||||
"ambientSmugglerCopies": 3
|
||||
},
|
||||
"lobby_base": {
|
||||
"quartermasterCopy": 1
|
||||
}
|
||||
},
|
||||
"clarity": "Water and spice sellers in Guild Lobby barter explicitly non-redeemable samples; they are not the Arrakis Melange buyers. Dynamic Home Block NPC retains its organisation service. Fixed Esmar starts contracts, Staban receives deliveries. No NPC records removed."
|
||||
},
|
||||
"notClaimed": "Full live client coverage across every faction, permission, quest state, Java and Bedrock remains a separate player validation; fixtures do not spend money, advance quests, or transfer live players.",
|
||||
"localValidation": {
|
||||
"unitTests": 252,
|
||||
"failed": 0,
|
||||
"renderedControls": 334,
|
||||
"renderer": "Exact installed MCGUI 0.8.6",
|
||||
"standardCardWidthAndHeightRatio": 0.75,
|
||||
"retainedVariants": "Lobby and planet GUI/Menu classes assembled without unrelated archive changes; method-level audit excludes only explicit target methods."
|
||||
}
|
||||
}
|
||||
|
|
@ -112,12 +112,14 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
|
|||
|
||||
public void openMenu(Player player, String menu) {
|
||||
if (player.hasPermission("dunemenus.use")) create(menu, player, null).open();
|
||||
else player.sendMessage("You do not have permission to open this menu.");
|
||||
}
|
||||
|
||||
public void presentService(Player player, String section, String title, String description,
|
||||
org.bukkit.inventory.Inventory inventory, Map<Integer, Runnable> actions) {
|
||||
if (player.hasPermission("dunemenus.use"))
|
||||
new ServiceMenu(this, player, section, title, description, inventory, actions).open();
|
||||
else player.sendMessage("You do not have permission to open this menu.");
|
||||
}
|
||||
|
||||
void organisationServices(Player player,String kind,String id) {
|
||||
|
|
@ -229,7 +231,7 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
|
|||
@Override
|
||||
public List<String> onTabComplete(CommandSender s, Command c, String l, String[] a) {
|
||||
if (a.length != 1) return List.of();
|
||||
return java.util.stream.Stream.concat(IDS.stream(), java.util.stream.Stream.of("reload"))
|
||||
return java.util.stream.Stream.concat(IDS.stream(), java.util.stream.Stream.of("reload", "cookbook"))
|
||||
.filter(x -> x.startsWith(a[0].toLowerCase())).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
38
DuneMenus/src/main/java/com/dunerealms/menus/MenuPolish.java
Normal file
38
DuneMenus/src/main/java/com/dunerealms/menus/MenuPolish.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package com.dunerealms.menus;
|
||||
|
||||
/** Presentation only: original slot identifiers and callbacks remain unchanged. */
|
||||
final class MenuPolish {
|
||||
private MenuPolish() {}
|
||||
static String apply(String html) {
|
||||
if (html.contains("/* compact-dune-cards */")) return html;
|
||||
return html.replace("</style>", "/* compact-dune-cards */" + CSS + "</style>");
|
||||
}
|
||||
private static final String CSS = """
|
||||
|
||||
/* Compact service cards: 75% of their previous dimensions; retain the Dune palette. */
|
||||
.card{width:13.875%;height:103.5px;padding:5px;border-radius:8px;box-shadow:inset 0 0 0 1px #0a231f,0 2px 6px #071713}
|
||||
.card:hover{box-shadow:inset 0 0 0 1px #0a231f,0 2px 8px #071713}
|
||||
.hub .card{width:13.875%;min-height:66.75px}.journal .card{width:23.25%;height:103.5px;min-height:51px;padding:6px}
|
||||
.council .card{width:25.875%;height:103.5px;min-height:86.25px}.bank .card{width:18%;min-height:75px}
|
||||
.card .emblem{width:24px;height:24px;line-height:20px;padding:1px;margin:0 auto 2px;border-radius:6px;box-shadow:none;text-shadow:none}
|
||||
.card .item-icon{width:20px;height:20px}.card h2{font-size:11.5px;line-height:1.15;height:26.45px;overflow:hidden;margin:0 0 2px}.card p{font-size:9.5px;line-height:1.2;max-height:22.8px;overflow:hidden;margin:1px 0}.card p:last-child{max-height:11.4px}.locked.card{height:auto}.locked.card p{max-height:none}
|
||||
.house-choices .card{width:19.5%;height:78.75px;min-height:78.75px}.house-choices .card h2{font-size:11px}
|
||||
.house-choices .card .emblem{width:24px;height:24px;line-height:20px}.house-choices .card .item-icon{width:20px;height:20px}
|
||||
.constellation{height:auto;min-height:262.5px;display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;align-content:flex-start;padding:12px 0 36px}
|
||||
.constellation .card{position:relative;top:auto;left:auto;right:auto;width:129.75px;height:54px;min-height:54px;padding:6px;border-radius:8px}
|
||||
.constellation .locked.card{height:auto;min-height:63px}.constellation .back{position:absolute;bottom:0;left:0}
|
||||
.detail-link{right:4px;top:4px;font-size:9px;padding:2px 4px;border-radius:5px}
|
||||
.goods{width:75%;margin:0 auto;gap:12px}.travel .goods{gap:18px}.community .goods{gap:15px}.quest .goods{gap:7.5px}.hub .goods{max-width:637.5px;width:75%}
|
||||
.slot{min-height:93px;padding:8.25px 5px 7.5px;border-width:2px;border-radius:8px;box-shadow:inset 0 0 0 1px #081d1b,0 2px 5px #091d17}
|
||||
.slot:hover,.slot.selected{box-shadow:inset 0 0 0 1px #081d1b,0 2px 7px #091d17}
|
||||
.hub .slot{min-height:99px}.slot strong,.hub .slot strong{font-size:12px;line-height:1.2;overflow-wrap:break-word}
|
||||
.slot .cubby,.travel .cubby{width:36px;height:36px;border-radius:7px}.slot .cubby img{width:30px;height:30px}
|
||||
.travel .slot{min-height:108.75px}.quest .slot{min-height:57.75px;padding:5px 11.25px;grid-template-columns:42.75px 1fr;column-gap:9.75px}
|
||||
.quest .slot strong{font-size:15px}.quest .slot .cubby{width:36px;height:36px}.slot .tag{font-size:10px;margin-top:4.5px}.slot .cubby{margin-bottom:5.25px}.quest .slot .cubby{margin:0}
|
||||
.mission{width:72%;min-height:27px;padding:5px 11px;font-size:12px;border-width:1px;border-radius:6px}
|
||||
.mission span{font-size:11px}.primary{width:60%;min-height:32.25px;padding:5px 11px;font-size:15px;border-width:1px;border-radius:6px}
|
||||
.secondary{width:54%;min-height:24.75px;padding:4.5px 11px;font-size:11.25px;border-width:1px;border-radius:6px}
|
||||
.slots{width:75%;margin:0 auto;gap:5.25px}.member{min-height:35.25px;border-radius:6px;font-size:11px}.member .number{width:17.25px;padding:4.5px 0;font-size:9px}
|
||||
@media(max-width:600px){.goods,.hub .goods{width:100%}.slot strong,.hub .slot strong{font-size:12px}}
|
||||
""";
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -27,6 +27,15 @@ public class RendererVerification {
|
|||
String html=SuppliedDocument.html(id,"DuneRealms · "+id,"Service information",cards,List.of("Read-only account and permission details"));
|
||||
Path file=dir.resolve(id+"-matrix.html");Files.writeString(file,html);var page=Page.of(html,file,loader);var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
|
||||
if(!page.problems.isEmpty())throw new AssertionError(id+" parser problems "+page.problems);
|
||||
int marker=html.indexOf("/* compact-dune-cards */"),styleEnd=html.indexOf("</style>",marker);
|
||||
String baseline=html.substring(0,marker)+html.substring(styleEnd);
|
||||
var oldPage=Page.of(baseline,dir.resolve(id+"-before.html"),loader);
|
||||
var oldFrame=HtmlRenderer.render(oldPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
var oldBox=oldFrame.boundsOf(oldPage.document.selectFirst("main .card"));
|
||||
var newBox=frame.boundsOf(page.document.selectFirst("main .card"));
|
||||
if(Math.abs(newBox.getWidth()/oldBox.getWidth()-.75)>.002 || Math.abs(newBox.getHeight()/oldBox.getHeight()-.75)>.002)
|
||||
throw new AssertionError(id+" card size must be 75%: "+oldBox+" -> "+newBox);
|
||||
|
||||
ImageIO.write(frame.image(),"png",dir.resolve(id+"-matrix-engine.png").toFile());
|
||||
for(Card card:cards){
|
||||
var element=page.document.selectFirst("[data-slot='"+card.slot()+"']");var bounds=frame.boundsOf(element);
|
||||
|
|
@ -78,9 +87,10 @@ public class RendererVerification {
|
|||
throw new AssertionError("House text outside card: "+bounds+" vs "+box);
|
||||
}
|
||||
}
|
||||
if(onFirstRow!=3)throw new AssertionError("Expected three House cards across, got "+onFirstRow);
|
||||
int expectedColumns=page.document.selectFirst("main").hasClass("house-choices")?4:3;
|
||||
if(onFirstRow!=expectedColumns)throw new AssertionError("Expected "+expectedColumns+" compact House cards across, got "+onFirstRow);
|
||||
ImageIO.write(frame.image(),"png",dir.resolve("house-choices-engine.png").toFile());
|
||||
System.out.println("House selector: five original actions, three columns, contained text");
|
||||
System.out.println("House selector: five original actions, variant-preserving compact columns, contained text");
|
||||
}
|
||||
|
||||
private static void verifyNavigators(Path dir,Page.Loader loader)throws Exception{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import java.security.MessageDigest
|
||||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.41-house1"
|
||||
|
|
@ -18,3 +19,28 @@ sourceSets.main { java.srcDirs("../citizens-common/src/main/java", "../pack-sess
|
|||
tasks.processResources {
|
||||
from(rootProject.file("../network/content-assets/cookbook/spice-crafting.json"))
|
||||
}
|
||||
|
||||
val mcguiRuntime = providers.gradleProperty("mcguiRuntime")
|
||||
val rendererRuntimeFiles = mcguiRuntime.map { files(it) }.getOrElse(files())
|
||||
val rendererTest by sourceSets.creating {
|
||||
compileClasspath += sourceSets.main.get().output + rendererRuntimeFiles
|
||||
runtimeClasspath += sourceSets.main.get().output + rendererRuntimeFiles
|
||||
}
|
||||
val verifyRendererRuntime by tasks.registering {
|
||||
doLast {
|
||||
require(mcguiRuntime.isPresent) { "Supply -PmcguiRuntime=<existing MCGUI-0.8.6.jar>" }
|
||||
val jar = file(mcguiRuntime.get())
|
||||
require(jar.isFile) { "MCGUI runtime file not found" }
|
||||
val hash = MessageDigest.getInstance("SHA-256").digest(jar.readBytes()).joinToString("") { "%02x".format(it) }
|
||||
require(hash == "69a454291cc27c36cdbc680bfbde245a90a3913de53cc1591c502a5a49124300") { "MCGUI runtime differs from reviewed test input" }
|
||||
logger.lifecycle("Renderer verification: MCGUI0.8.6 SHA-256 {}", hash)
|
||||
}
|
||||
}
|
||||
tasks.named(rendererTest.compileJavaTaskName) { dependsOn(verifyRendererRuntime) }
|
||||
tasks.register<JavaExec>("verifyMenuRenderer") {
|
||||
dependsOn(rendererTest.classesTaskName)
|
||||
classpath = rendererTest.runtimeClasspath
|
||||
mainClass.set("com.dunerealms.gui.CompactRendererVerification")
|
||||
jvmArgs("-Djava.awt.headless=true")
|
||||
args(providers.gradleProperty("rendererOutput").getOrElse(layout.buildDirectory.dir("renderer-verification").get().asFile.absolutePath))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
panel.inventory=Bukkit.createInventory(panel,54,Component.text(title,NamedTextColor.GOLD));
|
||||
panel.inventory.setItem(22,icon(player,"Return to Guild Lobby",detail,"drgui_transparent",Material.COMPASS));
|
||||
panel.actions.put(22,returnToLobby);
|
||||
button(panel,player,45,"Back","Imperial Codex",Material.ARROW,()->organisations.console(player));
|
||||
if(MCGUIMenus.show(player,title,detail,panel.inventory,panel.actions,panel.gate))return;
|
||||
player.openInventory(panel.inventory);
|
||||
expire(panel);
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ final class MenuDocument {
|
|||
String image=icon(c,root);b.append("<button ").append(c.action?"data-slot":"data-pick").append("=\"").append(c.slot).append("\" class=\"slot ").append(c==detail?"selected":"").append(c.material.equals("light_blue_dye")?" ingame":"").append("\"><span class=\"cubby\">");if(!image.isBlank())b.append("<img src=\"").append(image).append("\">");else b.append("<span class=\"sigil\">◇</span>");
|
||||
b.append("</span><strong>").append(escape(c.title)).append("</strong><span class=\"tag\">").append(escape(fact(c))).append("</span></button>");
|
||||
}b.append("</div>");
|
||||
b.append("</section></main><footer><span>J.A.R.V.I.S. · Your realm, connected</span><span>Click an action · Scroll for more · Sneak to close</span></footer></body></html>");return b.toString();
|
||||
b.append("</section></main><footer><span>J.A.R.V.I.S. · Your realm, connected</span><span>Click an action · Scroll for more · Sneak to close</span></footer></body></html>");return MenuPolish.apply(b.toString());
|
||||
}
|
||||
static String warMusterRoom(String description,String player,List<Card> cards,Path root){
|
||||
Map<Integer,Card> positions=new HashMap<>();for(Card card:cards)positions.put(card.slot,card);Card own=cards.stream().filter(c->c.lore.stream().anyMatch(l->l.equals("Your team"))).findFirst().orElse(null);String side=own!=null&&own.title.startsWith("Red")?"red":"blue";
|
||||
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset=\"utf-8\"><style>").append(WAR_CSS).append("</style></head><body><div class=\"war-frame\"><header><img src=\"art/logo.png\"><div><small>J.A.R.V.I.S. · CLAN WAR</small><h1>WAR MUSTER ROOM</h1></div><span>").append(escape(player)).append("</span><button class=\"close\" data-slot=\"-1\">×</button></header><p class=\"brief\">").append(escape(description).replace("\n"," · ")).append("</p><main><section class=\"roster ").append(side).append("\"><h2>").append(escape(own==null?"YOUR TEAM":own.title)).append("</h2><div class=\"slots\">");
|
||||
int[] slots={19,20,21,22,28,29,30,31};for(int i=0;i<slots.length;i++){Card card=positions.get(slots[i]);if(card==null)continue;String tag=card.action?"button":"div";b.append('<').append(tag).append(" class=\"member ").append(card.title.startsWith("Empty slot")?"empty":"").append("\"");if(card.action)b.append(" data-slot=\"").append(card.slot).append("\"");b.append("><span class=\"number\">").append(i+1).append("</span><span class=\"name\">").append(escape(card.title)).append("</span><span class=\"select\">").append(card.action?"▾":"◇").append("</span></").append(tag).append('>');}b.append("</div></section><section class=\"status\"><h2>PROVINCE & ROSTER STATUS</h2><div class=\"provinces\">");
|
||||
for(int slot:new int[]{2,6}){Card c=positions.get(slot);if(c==null)continue;String color=c.title.startsWith("Red")?"red":"blue";b.append("<article class=\"province ").append(color).append("\"><span class=\"flag\">⚑</span><strong>").append(escape(c.title)).append("</strong>");for(String lore:c.lore)b.append("<p>").append(escape(lore)).append("</p>");b.append("</article>");}b.append("</div>");Card key=positions.get(34);if(key!=null){b.append("<div class=\"key\"><h3>TEAM ROSTER KEY</h3>");for(String line:key.lore)b.append("<p>").append(escape(line)).append("</p>");b.append("</div>");}b.append("</section></main><footer>");for(int slot:new int[]{45,47,49,51}){Card c=positions.get(slot);if(c==null)continue;b.append("<button class=\"").append(slot==49?"save ":slot==51?"launch ":"").append(c.action?"":"disabled").append("\"");if(c.action)b.append(" data-slot=\"").append(c.slot).append("\"");b.append('>').append(escape(c.title)).append("</button>");}b.append("</footer><p class=\"notice\">Auto-launch 15 minutes after scheduled start · Sneak to close</p></div></body></html>");return b.toString();
|
||||
for(int slot:new int[]{2,6}){Card c=positions.get(slot);if(c==null)continue;String color=c.title.startsWith("Red")?"red":"blue";b.append("<article class=\"province ").append(color).append("\"><span class=\"flag\">⚑</span><strong>").append(escape(c.title)).append("</strong>");for(String lore:c.lore)b.append("<p>").append(escape(lore)).append("</p>");b.append("</article>");}b.append("</div>");Card key=positions.get(34);if(key!=null){b.append("<div class=\"key\"><h3>TEAM ROSTER KEY</h3>");for(String line:key.lore)b.append("<p>").append(escape(line)).append("</p>");b.append("</div>");}b.append("</section></main><footer>");for(int slot:new int[]{45,47,49,51}){Card c=positions.get(slot);if(c==null)continue;b.append("<button class=\"").append(slot==49?"save ":slot==51?"launch ":"").append(c.action?"":"disabled").append("\"");if(c.action)b.append(" data-slot=\"").append(c.slot).append("\"");b.append('>').append(escape(c.title)).append("</button>");}b.append("</footer><p class=\"notice\">Auto-launch 15 minutes after scheduled start · Sneak to close</p></div></body></html>");return MenuPolish.apply(b.toString());
|
||||
}
|
||||
private static final String WAR_CSS="""
|
||||
*{box-sizing:border-box}body{margin:0;padding:14px;background:linear-gradient(145deg,#142f25,#081e19);color:#f5e7bd;font-family:Minecraft,monospace;font-size:13px}.war-frame{border:3px solid #d3a84c;border-radius:12px;padding:12px 18px 9px;background:linear-gradient(150deg,#244735,#10291f);box-shadow:inset 0 0 0 2px #604d22,0 8px 22px #0009}header{display:flex;align-items:center;gap:16px;height:62px;border-bottom:2px solid #bf9746;padding-bottom:5px}header img{width:150px;height:54px;object-fit:contain}header div{flex:1}header small{color:#c9a958;font-size:10px;letter-spacing:2px}h1{margin:3px 0;font-size:24px;color:#f2d58b}header span{color:#c8d8be;font-size:10px}.close{width:33px;height:32px}.brief{font-size:10px;color:#e6ca85;line-height:1.4;margin:7px 0 10px}main{display:grid;grid-template-columns:1fr 1fr;gap:14px}.roster,.status{border:2px solid #c49c40;border-radius:7px;padding:8px;background:#0b221b}h2{font-size:15px;letter-spacing:1px;margin:0 0 7px;padding:6px;text-align:center;color:#fff0c6;border-bottom:1px solid #bc9848}.roster.blue h2{background:#234e82}.roster.red h2{background:#713a36}.slots{display:grid;grid-template-columns:1fr 1fr;gap:7px}.member{display:flex;align-items:center;gap:7px;min-height:47px;padding:4px;border:1px solid #c5a259;border-radius:4px;background:linear-gradient(90deg,#193d2c,#123025);color:#efdfb5;text-align:left;font:12px Minecraft,monospace}.member:hover{background:#42664c}.number{background:#24485f;border:1px solid #c6a253;border-radius:3px;width:23px;text-align:center;padding:6px 0}.red .number{background:#7c3535}.name{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.member.empty{color:#9bafaa}.select{color:#dfb85f}.provinces{display:grid;grid-template-columns:1fr 1fr;gap:7px}.province{padding:8px;border:1px solid #c5a259;border-radius:5px;background:#213e35;min-height:105px}.province.blue{background:linear-gradient(145deg,#25567c,#162f43)}.province.red{background:linear-gradient(145deg,#884846,#442c2b)}.province strong{font-size:12px;color:#ffe7a1;display:block;margin-bottom:4px}.flag{float:right;color:#e2bd62;font-size:24px}.province p,.key p{font-size:10px;margin:3px 0;color:#e5dbc1;line-height:1.4}.key{margin-top:9px;border:1px solid #bb9144;padding:7px;border-radius:4px;background:#132f24}.key h3{margin:0 0 4px;font-size:12px;color:#f3cf7b}.key p:first-of-type{font-size:14px;color:#fff0b4;overflow-wrap:break-word}footer{display:flex;gap:10px;justify-content:center;margin-top:10px}button{font:12px Minecraft,monospace;padding:9px 14px;color:#fbe5aa;border:2px solid #c7a353;background:#183b2b;border-radius:5px}button[data-slot]:hover{background:#42664c}.save{background:linear-gradient(140deg,#f2d18b,#b58a39);color:#28230c;min-width:150px}.launch{min-width:145px;background:#543e20}.disabled{background:#394744;color:#a6b1ab;border-color:#65736b}.notice{text-align:center;color:#c8b77b;font-size:10px;margin:6px 0 0}
|
||||
|
|
@ -73,7 +73,7 @@ final class MenuDocument {
|
|||
if(dashboard&&pick!=null)b.append("<button class=\"primary\" data-slot=\"").append(pick.slot).append("\">SELECT ").append(decision?"DECISION":"MISSION").append("</button>");
|
||||
if(dashboard&&pick==null&&cards.stream().anyMatch(c->c.action&&c.slot>=9&&c.slot<45))b.append("<p class=\"hint\">Select an entry to continue.</p>");
|
||||
for(Card c:cards){if(!c.action||dashboard&&c.slot>=9&&c.slot<45)continue;String action=c.title.equals("Claim verified reward")?"CLAIM & CONTINUE":c.title;boolean primary=c.slot==31||c.title.equals("Accept")||c.title.equals("Confirm and execute");b.append("<button class=\"").append(primary?"primary":"secondary").append("\" data-slot=\"").append(c.slot).append("\">").append(escape(action)).append("</button>");}
|
||||
return b.append("</section><footer>SHIFT TO CLOSE</footer></div></body></html>").toString();
|
||||
return MenuPolish.apply(b.append("</section><footer>SHIFT TO CLOSE</footer></div></body></html>").toString());
|
||||
}
|
||||
private static final String ROLEPLAY_CSS="""
|
||||
*{box-sizing:border-box}body{margin:0;color:#f8edcf;background:#061c13;font-family:'Source Serif 4',Georgia,serif}.frame{position:relative;min-height:597px;width:100%;display:grid;grid-template-columns:30% 70%;background-image:url('art/quest-dialogue-frame.png');background-size:100% 100%;background-repeat:no-repeat;padding:18px 22px 42px}.portrait{position:relative;padding:17px 27px 122px 17px;display:flex;align-items:center;justify-content:center;min-height:500px}.avatar{width:100%;height:auto;max-height:370px;object-fit:contain;image-rendering:pixelated}.nameplate{position:absolute;bottom:10px;left:18px;right:36px;text-align:center}.nameplate h2{font-size:25px;line-height:1.08;margin:0;color:#f6e2a8}.nameplate p{font-style:italic;font-size:14px;color:#e5cb8f;margin:8px 4px}.content{padding:0 40px 30px 33px;min-width:0;text-align:center}header{display:flex;align-items:center;justify-content:center;gap:16px;color:#cfa94c}h1{margin:0 0 7px;color:#fff2cd;font-size:32px;letter-spacing:1px;line-height:1.1}.dialogue-art{width:80%;max-height:140px;object-fit:cover;border:1px solid #b59b58;margin:8px auto}.dialogue{font-size:17px;color:#f2dfb1;font-style:italic;margin:7px auto 12px;line-height:1.3;max-width:95%}.summary,.record{border:2px solid #bc9f52;border-radius:6px;padding:8px 14px;margin:9px auto;background:#05251bd9;max-width:96%}.bar{height:15px;border:1px solid #d9ba68;background:#09291d;margin:5px 20px}.bar div{height:100%;background:linear-gradient(#ffe17c,#c69a32)}.summary p,.record p{margin:4px 0;line-height:1.25;font-size:14px}.record h3{margin:2px 0 6px;font-size:20px;color:#f1d293}.paths{color:#f5e0a5;font-size:20px;letter-spacing:1px;margin:12px 0 6px}.mission,.primary,.secondary{background:linear-gradient(#113a29,#08281d);border:2px solid #c0a150;color:#f9ecc6;min-height:36px;padding:7px 15px;border-radius:7px;font:600 16px 'Source Serif 4',Georgia,serif;display:block;width:96%;margin:7px auto;box-shadow:inset 0 1px 0 #f5e0a450}.mission{text-align:left;display:flex;justify-content:space-between;gap:12px}.mission span{font-size:13px;color:#e8d09b}.mission.selected span{color:#3a2c0b}.mission.selected,.primary{background:linear-gradient(#ffe082,#c99a2d);color:#1b1a0b;border:2px solid #fff1b3;box-shadow:0 0 10px #e0ad4b66,inset 0 1px 0 #fff0b9}.primary{font-size:20px;font-weight:700;width:80%;text-transform:uppercase;min-height:43px}.secondary{width:72%;font-size:15px;min-height:33px}.mission:hover,.secondary:hover{border-color:#fff0b9}.hint{color:#cbb47d;font-style:italic;font-size:13px}footer{position:absolute;bottom:13px;left:32%;right:3%;text-align:center;font-size:13px;letter-spacing:3px;color:#f5dd98;font-weight:700}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.dunerealms.gui;
|
||||
|
||||
/** Presentation only: original slot identifiers and callbacks remain unchanged. */
|
||||
final class MenuPolish {
|
||||
private MenuPolish() {}
|
||||
static String apply(String html) {
|
||||
if (html.contains("/* compact-dune-cards */")) return html;
|
||||
return html.replace("</style>", "/* compact-dune-cards */" + CSS + "</style>");
|
||||
}
|
||||
private static final String CSS = """
|
||||
|
||||
/* Compact service cards: 75% of their previous dimensions; retain the Dune palette. */
|
||||
.card{width:13.875%;height:103.5px;padding:5px;border-radius:8px;box-shadow:inset 0 0 0 1px #0a231f,0 2px 6px #071713}
|
||||
.card:hover{box-shadow:inset 0 0 0 1px #0a231f,0 2px 8px #071713}
|
||||
.hub .card{width:13.875%;min-height:66.75px}.journal .card{width:23.25%;height:103.5px;min-height:51px;padding:6px}
|
||||
.council .card{width:25.875%;height:103.5px;min-height:86.25px}.bank .card{width:18%;min-height:75px}
|
||||
.card .emblem{width:24px;height:24px;line-height:20px;padding:1px;margin:0 auto 2px;border-radius:6px;box-shadow:none;text-shadow:none}
|
||||
.card .item-icon{width:20px;height:20px}.card h2{font-size:11.5px;line-height:1.15;height:26.45px;overflow:hidden;margin:0 0 2px}.card p{font-size:9.5px;line-height:1.2;max-height:22.8px;overflow:hidden;margin:1px 0}.card p:last-child{max-height:11.4px}.locked.card{height:auto}.locked.card p{max-height:none}
|
||||
.house-choices .card{width:19.5%;height:78.75px;min-height:78.75px}.house-choices .card h2{font-size:11px}
|
||||
.house-choices .card .emblem{width:24px;height:24px;line-height:20px}.house-choices .card .item-icon{width:20px;height:20px}
|
||||
.constellation{height:auto;min-height:262.5px;display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;align-content:flex-start;padding:12px 0 36px}
|
||||
.constellation .card{position:relative;top:auto;left:auto;right:auto;width:129.75px;height:54px;min-height:54px;padding:6px;border-radius:8px}
|
||||
.constellation .locked.card{height:auto;min-height:63px}.constellation .back{position:absolute;bottom:0;left:0}
|
||||
.detail-link{right:4px;top:4px;font-size:9px;padding:2px 4px;border-radius:5px}
|
||||
.goods{width:75%;margin:0 auto;gap:12px}.travel .goods{gap:18px}.community .goods{gap:15px}.quest .goods{gap:7.5px}.hub .goods{max-width:637.5px;width:75%}
|
||||
.slot{min-height:93px;padding:8.25px 5px 7.5px;border-width:2px;border-radius:8px;box-shadow:inset 0 0 0 1px #081d1b,0 2px 5px #091d17}
|
||||
.slot:hover,.slot.selected{box-shadow:inset 0 0 0 1px #081d1b,0 2px 7px #091d17}
|
||||
.hub .slot{min-height:99px}.slot strong,.hub .slot strong{font-size:12px;line-height:1.2;overflow-wrap:break-word}
|
||||
.slot .cubby,.travel .cubby{width:36px;height:36px;border-radius:7px}.slot .cubby img{width:30px;height:30px}
|
||||
.travel .slot{min-height:108.75px}.quest .slot{min-height:57.75px;padding:5px 11.25px;grid-template-columns:42.75px 1fr;column-gap:9.75px}
|
||||
.quest .slot strong{font-size:15px}.quest .slot .cubby{width:36px;height:36px}.slot .tag{font-size:10px;margin-top:4.5px}.slot .cubby{margin-bottom:5.25px}.quest .slot .cubby{margin:0}
|
||||
.mission{width:72%;min-height:27px;padding:5px 11px;font-size:12px;border-width:1px;border-radius:6px}
|
||||
.mission span{font-size:11px}.primary{width:60%;min-height:32.25px;padding:5px 11px;font-size:15px;border-width:1px;border-radius:6px}
|
||||
.secondary{width:54%;min-height:24.75px;padding:4.5px 11px;font-size:11.25px;border-width:1px;border-radius:6px}
|
||||
.slots{width:75%;margin:0 auto;gap:5.25px}.member{min-height:35.25px;border-radius:6px;font-size:11px}.member .number{width:17.25px;padding:4.5px 0;font-size:9px}
|
||||
@media(max-width:600px){.goods,.hub .goods{width:100%}.slot strong,.hub .slot strong{font-size:12px}}
|
||||
""";
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ final class QuestMenus implements Listener {
|
|||
if(selected!=null){var row=available.stream().filter(q->selected.equals(text(q,"id",""))).findFirst().orElse(null);if(row!=null){roleSelected(p,data,role,row);return;}}
|
||||
var screen=panel(p,"NPC dashboard · "+role.name());screen.description="";roleAvatar(screen,data,role);int active=0,ready=0,claimed=0;for(var e:data.getAsJsonArray("quests")){var q=e.getAsJsonObject();if(!roleAllowed(data,role,q))continue;if(text(q,"state","").equals("claimed"))claimed++;else if(yes(q,"canClaim"))ready++;else if(text(q,"state","").equals("active"))active++;}String stats=active+" active · "+ready+" ready · "+claimed+" claimed";if(data.has("npcSummary")&&data.get("npcSummary").isJsonObject()){var rep=data.getAsJsonObject("npcSummary");stats+="\nReputation "+text(rep,"xp","—")+" / "+text(rep,"nextXP","—");if(rep.has("percent")&&!rep.get("percent").isJsonNull())stats+="\nProgress: "+Math.max(0,Math.min(100,rep.get("percent").getAsInt()))+"%";}put(screen,5,"Mission overview",stats,Material.PAPER,null);var summary=screen.inventory.getItem(5);var meta=summary.getItemMeta();meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","menu_art"),org.bukkit.persistence.PersistentDataType.STRING,"npc_summary");summary.setItemMeta(meta);screen.inventory.setItem(5,summary);var ordered=new ArrayList<JsonObject>(available);ordered.sort(Comparator.comparingInt(q->Set.of("active","completed").contains(text(q,"state",""))?0:1));
|
||||
int slot=9;for(var q:ordered){if(slot>=45)break;String status=Set.of("active","completed").contains(text(q,"state",""))?"Progress: "+text(q,"progress","0")+" / "+text(q,"target","1"):"Eligible to accept";put(screen,slot++,text(q,"title","Mission"),status+"\n"+text(q,"id","")+" · "+text(q,"objective",""),Material.WRITABLE_BOOK,()->roleSelected(p,data,role,q));}
|
||||
if(ordered.isEmpty())put(screen,13,"No eligible missions","Read the website journal for the full record.",Material.MAP,null);
|
||||
if(ordered.isEmpty())put(screen,13,"Open your mission journal","No missions are available from this contact right now.\nBrowse your other story arcs and current objectives.",Material.MAP,()->open(p));
|
||||
if(role.key().equals("esmar_tuek")){
|
||||
put(screen,47,"Smuggler Navigator","Review personal passage to another world.",Material.COMPASS,()->smugglerMenu(p,data,role));
|
||||
if(role.world().equals("arrakis"))put(screen,48,"Smuggling contracts","Start a delivery with Esmar Tuek",Material.CHEST,()->p.performCommand("dunenpc smuggle contract"));
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ final class SuppliedMenus {
|
|||
private SuppliedMenus(){}
|
||||
static boolean open(Player p,String id){return call("openMenu",new Class<?>[]{Player.class,String.class},p,id);}
|
||||
static boolean command(Player p,String command,String[] args){
|
||||
String id=switch(command){case "exchange","spice","clan","company","house","mentat"->command;case "polgui"->"politics";case "warmuster"->"war";case "guildtravel"->args.length==0?"travel":null;case "drgui"->args.length==0?"hub":args.length==1?switch(args[0].toLowerCase(Locale.ROOT)){case "quests"->"missions";case "hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","mentat"->args[0].toLowerCase(Locale.ROOT);default->null;}:null;default->null;};
|
||||
String id=route(command,args);
|
||||
return id!=null&&open(p,id);
|
||||
}
|
||||
static String route(String command,String[] args){
|
||||
return switch(command){case "exchange","spice","clan","company","house","mentat"->command;case "polgui"->"politics";case "warmuster"->"war";case "guildtravel"->args.length==0?"travel":null;case "drgui"->args.length==0?"hub":args.length==1?switch(args[0].toLowerCase(Locale.ROOT)){case "quests"->"missions";case "hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","cookbook","mentat"->args[0].toLowerCase(Locale.ROOT);default->null;}:null;default->null;};
|
||||
}
|
||||
static boolean service(Player p,String title,String description,Inventory inventory,Map<Integer,Runnable> actions,GuiSession supplied){
|
||||
GuiSession gate=supplied==null?new GuiSession(p.getUniqueId()):supplied;
|
||||
Map<Integer,Runnable> guarded=new HashMap<>();actions.forEach((slot,action)->guarded.put(slot,()->{if(gate.claim(p.getUniqueId()))action.run();}));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.nio.file.*;import java.util.*;import javax.imageio.ImageIO;
|
||||
import ai.resourcepack.ui.html.*;import ai.resourcepack.ui.html.css.Selector;
|
||||
public class CompactRendererVerification {
|
||||
public static void main(String[] args)throws Exception{
|
||||
Path out=Path.of(args[0]);Files.createDirectories(out);var loader=new Page.Loader(false,out.resolve("cache"));int checked=0;
|
||||
Files.createDirectories(out.resolve("art"));
|
||||
for(Path source:List.of(Path.of("../DuneMenus/src/main/resources/menu-art/art"),Path.of("src/main/resources/mcgui-npc-avatars")))
|
||||
try(var paths=Files.list(source)){for(Path file:paths.filter(Files::isRegularFile).toList())Files.copy(file,out.resolve("art").resolve(file.getFileName()),StandardCopyOption.REPLACE_EXISTING);}
|
||||
var cards=new ArrayList<MenuDocument.Card>();
|
||||
for(int n=0;n<12;n++)cards.add(new MenuDocument.Card(n,"Service "+n,List.of("Authoritative service detail","100.00 DM"),"book",1,true,""));
|
||||
cards.add(new MenuDocument.Card(45,"Back",List.of(),"arrow",1,true,""));
|
||||
for(String title:List.of("Imperial Codex","Equipment","Spacing Guild","Mission journal","Clan","Company","Political offices","Exchange","Rihla ATM","NPC dashboard · Adviser","NPC turn-in · Adviser","War Muster Room")){
|
||||
var rows=cards;
|
||||
if(title.equals("War Muster Room")){
|
||||
rows=new ArrayList<>();rows.add(new MenuDocument.Card(2,"Blue · Own",List.of("Your team"),"blue_banner",1,false,""));
|
||||
rows.add(new MenuDocument.Card(6,"Red · Opponent",List.of("Read only"),"red_banner",1,false,""));
|
||||
for(int slot:new int[]{19,20,21,22,28,29,30,31})rows.add(new MenuDocument.Card(slot,"Member",List.of(),"player_head",1,true,""));
|
||||
for(int slot:new int[]{45,47,49})rows.add(new MenuDocument.Card(slot,"Action",List.of(),"arrow",1,true,""));
|
||||
}
|
||||
String html=MenuDocument.html(title,"Current verified services","Fixture",rows,-1,out);
|
||||
var page=Page.of(html,out.resolve(title.hashCode()+".html"),loader);var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
|
||||
if(!page.problems.isEmpty())throw new AssertionError(title+page.problems.toString());
|
||||
if(page.document.selectFirst(".slot")!=null){
|
||||
int marker=html.indexOf("/* compact-dune-cards */"),end=html.indexOf("</style>",marker);
|
||||
var oldPage=Page.of(html.substring(0,marker)+html.substring(end),out.resolve("before-"+title.hashCode()+".html"),loader);
|
||||
var oldFrame=HtmlRenderer.render(oldPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
var before=oldFrame.boundsOf(oldPage.document.selectFirst(".slot"));var after=frame.boundsOf(page.document.selectFirst(".slot"));
|
||||
if(Math.abs(after.getWidth()/before.getWidth()-.75)>.002 || Math.abs(after.getHeight()/before.getHeight()-.75)>.002)throw new AssertionError(title+" expected 75% card dimensions "+before+" -> "+after);
|
||||
System.out.println(title+" scale width="+after.getWidth()/before.getWidth()+" height="+after.getHeight()/before.getHeight());
|
||||
}
|
||||
var controls=page.document.select("[data-slot],[data-pick]");if(controls.isEmpty())throw new AssertionError(title+" no controls");
|
||||
for(var element:controls){var box=frame.boundsOf(element);if(box==null||box.isEmpty())throw new AssertionError(title+" hidden control");
|
||||
double scroll=Math.max(0,Math.min(frame.maxScroll(),box.getCenterY()-260));
|
||||
var visible=HtmlRenderer.render(page,1536,896,1.5,scroll,Selector.State.NONE);var hit=visible.elementAt(box.getCenterX(),box.getCenterY()-scroll);
|
||||
if(hit==null || hit.closest("[data-slot],[data-pick]")!=element)throw new AssertionError(title+" unreachable "+element+" box="+box);
|
||||
checked++;
|
||||
}
|
||||
ImageIO.write(frame.image(),"png",out.resolve(title.hashCode()+".png").toFile());
|
||||
System.out.println(title+": "+controls.size()+" controls reachable");
|
||||
}
|
||||
System.out.println("PASS "+checked+" native/fallback UI controls");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class MenuEntryRoutesTest {
|
||||
@Test void everyCodexServiceHasAnExplicitEntryIncludingCookbook(){
|
||||
for(String id:Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","cookbook","mentat"))
|
||||
assertEquals(id,SuppliedMenus.route("drgui",new String[]{id}),id);
|
||||
assertEquals("missions",SuppliedMenus.route("drgui",new String[]{"quests"}));
|
||||
}
|
||||
@Test void guildEntryDoesNotDependOnAWorldAndTargetedCancellationRemainsNative(){
|
||||
assertEquals("travel",SuppliedMenus.route("guildtravel",new String[]{}));
|
||||
assertNull(SuppliedMenus.route("guildtravel",new String[]{"cancel"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"previewitem","id","1"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"movenpc","stilgar"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"unknown"}));
|
||||
}
|
||||
}
|
||||
101
tools/CompactMenuMerge.java
Normal file
101
tools/CompactMenuMerge.java
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Handle;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
class CompactMenuMerge {
|
||||
private static final String GUI = "com/dunerealms/gui/";
|
||||
private static final Map<String, Set<String>> TARGETS = Map.of(
|
||||
GUI + "DuneGUI", Set.of("guildReturnMenu"),
|
||||
GUI + "QuestMenus", Set.of("roleJournal"),
|
||||
GUI + "SuppliedMenus", Set.of("command", "route"),
|
||||
"com/dunerealms/menus/DuneMenusPlugin", Set.of("openMenu", "presentService", "onTabComplete"),
|
||||
"com/example/dunelobby/DuneLobby", Set.of("entityInteract", "departure", "depart"));
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 3) throw new IllegalArgumentException("Expected retained, donor and output classes");
|
||||
var retainedReader = new ClassReader(Files.readAllBytes(Path.of(args[0])));
|
||||
var retained = parse(retainedReader);
|
||||
var donor = parse(new ClassReader(Files.readAllBytes(Path.of(args[1]))));
|
||||
if (retained.name.equals("com/dunerealms/gui/MenuDocument") || retained.name.equals("com/dunerealms/menus/SuppliedDocument")) {
|
||||
int expected = retained.name.endsWith("/MenuDocument") ? 6 : 7;
|
||||
int changed = 0;
|
||||
for (var method : retained.methods) {
|
||||
if (!method.name.equals("html") || org.objectweb.asm.Type.getArgumentTypes(method.desc).length != expected) continue;
|
||||
for (var instruction : method.instructions.toArray()) {
|
||||
if (instruction instanceof org.objectweb.asm.tree.MethodInsnNode call && call.owner.endsWith("/MenuPolish"))
|
||||
throw new IllegalArgumentException("Style already installed");
|
||||
if (instruction.getOpcode() == org.objectweb.asm.Opcodes.ARETURN)
|
||||
method.instructions.insertBefore(instruction, new org.objectweb.asm.tree.MethodInsnNode(
|
||||
org.objectweb.asm.Opcodes.INVOKESTATIC, retained.name.substring(0,retained.name.lastIndexOf('/')+1)+"MenuPolish",
|
||||
"apply", "(Ljava/lang/String;)Ljava/lang/String;", false));
|
||||
}
|
||||
changed++;
|
||||
}
|
||||
if (changed != 1) throw new IllegalArgumentException("Unexpected document overloads");
|
||||
var writer = new ClassWriter(retainedReader, 0); retained.accept(writer);
|
||||
Files.write(Path.of(args[2]), writer.toByteArray()); return;
|
||||
}
|
||||
var targets = TARGETS.get(retained.name);
|
||||
if (targets == null || !retained.name.equals(donor.name)) throw new IllegalArgumentException("Unexpected overlay class");
|
||||
var additions = new LinkedHashMap<String, MethodNode>();
|
||||
var renamed = new HashMap<String, String>();
|
||||
for (String target : targets.stream().sorted().toList()) {
|
||||
var method = donor.methods.stream().filter(m -> m.name.equals(target)).toList();
|
||||
if (method.size() != 1) throw new IllegalArgumentException("Expected one donor method " + target);
|
||||
prepare(donor, method.getFirst(), additions, renamed);
|
||||
}
|
||||
for (var entry : additions.entrySet()) {
|
||||
var method = entry.getValue();
|
||||
if (!targets.contains(method.name) &&
|
||||
retained.methods.stream().anyMatch(old -> old.name.equals(method.name) && old.desc.equals(method.desc))) {
|
||||
throw new IllegalArgumentException("Unexpected existing helper " + method.name);
|
||||
}
|
||||
retained.methods.removeIf(old -> old.name.equals(method.name) && old.desc.equals(method.desc));
|
||||
retained.methods.add(method);
|
||||
}
|
||||
var writer = new ClassWriter(retainedReader, 0);
|
||||
retained.accept(writer);
|
||||
Files.write(Path.of(args[2]), writer.toByteArray());
|
||||
}
|
||||
|
||||
private static void prepare(ClassNode donor, MethodNode method, Map<String, MethodNode> copies,
|
||||
Map<String, String> renamed) {
|
||||
String key = method.name + method.desc;
|
||||
if (copies.putIfAbsent(key, method) != null) return;
|
||||
for (var instruction : method.instructions) {
|
||||
if (!(instruction instanceof InvokeDynamicInsnNode dynamic)) continue;
|
||||
for (int i = 0; i < dynamic.bsmArgs.length; i++) {
|
||||
if (!(dynamic.bsmArgs[i] instanceof Handle handle) || !handle.getOwner().equals(donor.name) ||
|
||||
!handle.getName().startsWith("lambda$")) continue;
|
||||
String original = handle.getName() + handle.getDesc();
|
||||
String replacement = renamed.get(original);
|
||||
if (replacement == null) {
|
||||
var helper = donor.methods.stream().filter(m -> m.name.equals(handle.getName()) &&
|
||||
m.desc.equals(handle.getDesc())).findFirst().orElseThrow();
|
||||
replacement = "compactMenu$" + handle.getName();
|
||||
renamed.put(original, replacement);
|
||||
helper.name = replacement;
|
||||
prepare(donor, helper, copies, renamed);
|
||||
}
|
||||
dynamic.bsmArgs[i] = new Handle(handle.getTag(), handle.getOwner(), replacement,
|
||||
handle.getDesc(), handle.isInterface());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ClassNode parse(ClassReader reader) {
|
||||
var node = new ClassNode();
|
||||
reader.accept(node, 0);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
54
tools/plugin_menu_polish.py
Normal file
54
tools/plugin_menu_polish.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
"""Assemble reviewed compact-menu methods onto the installed plugin variants."""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from plugin_wild_update import digest, read_archive, write_archive
|
||||
|
||||
CLASSES = {
|
||||
"gui": ("com/dunerealms/gui/MenuDocument.class", "com/dunerealms/gui/DuneGUI.class", "com/dunerealms/gui/QuestMenus.class", "com/dunerealms/gui/SuppliedMenus.class"),
|
||||
"menus": ("com/dunerealms/menus/SuppliedDocument.class", "com/dunerealms/menus/DuneMenusPlugin.class"),
|
||||
"lobby": ("com/example/dunelobby/DuneLobby.class",),
|
||||
}
|
||||
|
||||
|
||||
|
||||
def assemble(module, baseline, baseline_sha, donor, donor_sha, output, classpath):
|
||||
baseline_bytes = baseline.read_bytes()
|
||||
donor_bytes = donor.read_bytes()
|
||||
if digest(baseline_bytes) != baseline_sha or digest(donor_bytes) != donor_sha:
|
||||
raise ValueError("Unexpected baseline or donor checksum")
|
||||
retained = read_archive(baseline_bytes)
|
||||
compiled = read_archive(donor_bytes)
|
||||
java_home = os.environ.get("JAVA_HOME")
|
||||
executable = "java.exe" if os.name == "nt" else "java"
|
||||
java = str(Path(java_home) / "bin" / executable) if java_home else executable
|
||||
helper = Path(__file__).with_name("CompactMenuMerge.java")
|
||||
with TemporaryDirectory() as temporary:
|
||||
temp = Path(temporary)
|
||||
for index, entry in enumerate(CLASSES[module]):
|
||||
old, new, merged = (temp / f"{index}-{name}.class" for name in ("retained", "donor", "merged"))
|
||||
old.write_bytes(retained[entry])
|
||||
new.write_bytes(compiled[entry])
|
||||
subprocess.run([java, "--class-path", classpath, str(helper), str(old), str(new), str(merged)], check=True)
|
||||
retained[entry] = merged.read_bytes()
|
||||
if module in ("gui", "menus"):
|
||||
entry = "com/dunerealms/" + module + "/MenuPolish.class"
|
||||
if entry in retained: raise ValueError("Menu styling already installed")
|
||||
retained[entry] = compiled[entry]
|
||||
with output.open("xb") as candidate:
|
||||
candidate.write(write_archive(retained))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("module", choices=CLASSES)
|
||||
parser.add_argument("baseline", type=Path)
|
||||
parser.add_argument("baseline_sha")
|
||||
parser.add_argument("donor", type=Path)
|
||||
parser.add_argument("donor_sha")
|
||||
parser.add_argument("output", type=Path)
|
||||
parser.add_argument("classpath", help="ASM core and tree JARs")
|
||||
assemble(**vars(parser.parse_args()))
|
||||
Loading…
Reference in a new issue

Staff