diff --git a/.forgejo/workflows/compact-menus.yml b/.forgejo/workflows/compact-menus.yml new file mode 100644 index 00000000..24817da8 --- /dev/null +++ b/.forgejo/workflows/compact-menus.yml @@ -0,0 +1,44 @@ +name: Compact DuneMenus Build +on: + workflow_dispatch: + push: + branches: ['feat/dunemenus-compact-*'] + +jobs: + compact-menus: + 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: Verify the DuneMenus-only transition + shell: bash + run: | + set -euo pipefail + gradle --no-daemon -p DuneMenus test jar + python3 tools/test_plugin_fleet_install.py -v + python3 tools/plugin_compact_menus.py DuneMenus/build/libs/DuneMenus.jar + mkdir compact-menus-artifacts + cp DuneMenus/build/libs/DuneMenus.jar compact-menus-artifacts/ + printf '%s\n' "$(git rev-parse HEAD)" > compact-menus-artifacts/SOURCE_COMMIT + python3 tools/write-plugin-manifest.py compact-menus-artifacts "$GITHUB_SHA" + cp tools/{install-plugin-fleet,plugin_compact_menus,plugin_menu_pack,plugin_backend_abi,plugin_fleet_rollback,plugin_pack_properties,plugin_pillager_abi}.py compact-menus-artifacts/ + (cd compact-menus-artifacts && sha256sum -- *.jar *.json *.py SOURCE_COMMIT > SHA256SUMS) + - uses: actions/upload-artifact@v3 + with: + name: DuneRealms-Compact-Menus + path: compact-menus-artifacts/ + if-no-files-found: error diff --git a/DuneMenus/build.gradle.kts b/DuneMenus/build.gradle.kts index 518b52d8..803cbb1b 100644 --- a/DuneMenus/build.gradle.kts +++ b/DuneMenus/build.gradle.kts @@ -1,7 +1,7 @@ import java.security.MessageDigest plugins { java } group = "com.dunerealms" -version = "2.0.8-navigator1" +version = "2.0.9-compact1" repositories { mavenCentral() maven("https://repo.papermc.io/repository/maven-public/") diff --git a/DuneMenus/src/main/java/com/dunerealms/menus/SuppliedDocument.java b/DuneMenus/src/main/java/com/dunerealms/menus/SuppliedDocument.java index 5245ea52..3aee1992 100644 --- a/DuneMenus/src/main/java/com/dunerealms/menus/SuppliedDocument.java +++ b/DuneMenus/src/main/java/com/dunerealms/menus/SuppliedDocument.java @@ -33,11 +33,27 @@ final class SuppliedDocument { Card focused=null;for(Card c:cards)if(c.slot()==selected){focused=c;break;} if(focused!=null){b.append("

").append(escape(focused.title())).append("

");for(String line:focused.lore())b.append("

").append(escape(line)).append("

");b.append("
");} b.append("
");int index=0; - int summaryLimit=layout.equals("constellation")?1:2; + int summaryLimit=id.equals("exchange")?2:1; for(Card c:cards){b.append(c.enabled()?"":"");} - b.append("
");for(String line:info)b.append("

").append(escape(line)).append("

");return b.append("
").toString(); + b.append("
");for(String line:info)b.append("

").append(escape(line)).append("

");return b.append("
").toString(); } private static final String CSS=""" .locked.card,.constellation .locked.card{color:#c0c4c8;background:#262c30;border-color:#72777a}.locked.card p{color:#c0c4c8}.constellation .locked.card{height:84px} .rihla-brand{height:62px;overflow:hidden;background:#faf6ed;border:1px solid #b59349}.rihla-logo{display:block;width:146px;height:auto;align-self:flex-start}.cash-controls{display:flex;justify-content:space-between;position:relative;z-index:3;padding:10px 0}.cash-action{border:1px solid #c6a154;background:#123b2d;padding:12px 24px;font-size:16px}.cash-action[data-slot='24']{order:2;background:#3f5a26}.cash-action[data-slot='36']{order:1}.receipt .facts{background:#102a24;border:1px solid #b59349;padding:18px;margin:12px auto;max-width:650px}.receipt .facts p{font-size:14px;line-height:1.6} *{box-sizing:border-box}body{margin:0;padding:12px;background:#03100f;color:#f1e7cd;font-family:Georgia,serif;font-size:13px}button{font-family:Georgia,serif;color:#f4df9d;cursor:pointer}.frame{min-height:570px;border:2px solid #b69149;outline:1px solid #645334;outline-offset:5px;background:#081e1b;position:relative;overflow:hidden}header{height:78px;border-bottom:2px solid #ae8943;background:linear-gradient(90deg,#102f29,#041512);display:flex;align-items:center;padding:8px 22px;gap:22px}.brand{display:flex;align-items:center;gap:8px;color:#d6ad58;font-size:38px;border-right:1px solid #7c683b;padding-right:20px}.brand span{font-size:16px;line-height:17px;letter-spacing:3px}.heading{flex:1}small{font-size:10px;letter-spacing:3px;color:#ad985f}h1{font-size:26px;margin:5px 0 0;color:#eed995;letter-spacing:1px}.close{width:31px;height:31px;border:1px solid #a58b4d;background:#112922;font-size:24px}.scene{position:relative;min-height:411px;padding:0 28px;overflow:hidden;background:linear-gradient(#162d30,#53665a 58%,#a88c52)}.quote{text-align:center;font-style:italic;position:relative;z-index:1;padding:12px 0 8px;margin:0;color:#f4e7bf}.dune{position:absolute;left:-12%;width:125%;height:180px;border-radius:55% 70% 0 0;pointer-events:none}.rear{bottom:0;background:#b4955a;transform:rotate(-8deg)}.front{bottom:-90px;background:#635a38;transform:rotate(9deg)}.moon{position:absolute;right:15%;top:23px;background:#e4dbb6;border-radius:50%;width:45px;height:45px;opacity:.55}main{position:relative;z-index:2}.doors,.bank{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;padding:12px 0 35px}.card{background:linear-gradient(135deg,#173e35,#0c201d);border:1px solid #b59349;box-shadow:inset 0 0 0 3px #0a231f,0 3px 8px #071713;padding:9px;height:140px;position:relative;display:block;text-align:left;width:16.875%;overflow:hidden}.card>div{width:100%;min-width:0}.card .emblem{display:block;width:38px;height:38px;line-height:32px;margin:0 auto 4px;padding:2px;border:1px solid #8b784c;background:#09251f;box-shadow:inset 0 0 0 2px #143a30;text-align:center}.market-tools{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;position:relative;z-index:2;padding:8px 0}.market-tool{display:flex;align-items:center;gap:6px;border:1px solid #8b784c;background:#12352c;padding:6px 10px;font-size:11px}.tool-icon{display:block;width:24px;height:24px;line-height:24px;text-align:center}.tool-icon .item-icon{width:24px;height:24px}.detail-link{position:absolute;right:10px;top:10px;font-size:10px;padding:4px 6px;border:1px solid #8b784c;background:#163a30;color:#e4cd91}.detail-link:hover{background:#315c45}.item-icon{width:32px;height:32px;object-fit:contain;image-rendering:pixelated}.brand-logo{width:158px;height:58px;object-fit:contain}.brand{width:180px;flex-shrink:0;padding-right:0;justify-content:center}.card h2{line-height:1.2}.card p{line-height:1.25;white-space:normal;overflow-wrap:break-word}.item-details{border:1px solid #786338;background:#102a24;margin-top:12px;padding:16px}.item-details p{overflow-wrap:break-word}.card h2{overflow-wrap:break-word;white-space:normal}.card:hover{background:linear-gradient(135deg,#315c45,#183c32);border-color:#f3d784}.emblem{font-size:26px;color:var(--accent);width:35px;flex-shrink:0;text-align:center}h2{font-size:14px;margin:0 0 6px}p{margin:2px 0;font-size:10px;line-height:1.35;color:#d1d3bc}.back{position:absolute;bottom:2px;left:0;background:#12372c;border:1px solid #ad8c48;padding:7px 12px;display:flex;align-items:center;gap:8px}.pager{border:1px solid #ad8c48;background:#12372c;padding:10px;display:flex;gap:8px;align-items:center}.back .emblem,.pager .emblem{font-size:17px;width:22px;height:22px;line-height:18px;border:0;padding:0;margin:0;box-shadow:none;background:transparent}.back .item-icon,.pager .item-icon{width:20px;height:20px}.back h2{margin:0;font-size:12px}.back p{display:none}.hub .card{width:16.5%;min-height:89px}.hub .emblem{font-size:26px}.journal{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;padding:8px 0 45px}.journal .card{width:30%;height:140px;min-height:68px;padding:9px}.journal .card p{display:block;margin:2px 0}.council{display:flex;flex-wrap:wrap;gap:16px;justify-content:center;padding:20px 8% 44px}.council .card{width:34.5%;height:140px;min-height:115px;border-top:3px solid var(--accent)}.bank .card{width:22.5%;min-height:100px}.travel .scene{background:radial-gradient(ellipse at center,#123a40,#061317)}.travel .dune,.travel .moon{display:none}.constellation{height:350px;position:relative}.constellation .card{position:absolute;width:173px;height:72px;min-height:68px;border-color:#74aeb6;background:linear-gradient(135deg,#173e43,#091c23)}.constellation .card .emblem{display:none}.constellation .n0{top:0;left:36%}.constellation .n1{top:98px;left:0}.constellation .n2{top:98px;right:0}.constellation .n3{top:225px;left:12%}.constellation .n4{top:225px;right:12%}.constellation .back{bottom:0}.guild{position:absolute;top:168px;left:44%;font-size:52px;color:#c4dcdf;text-align:center}.guild span{display:block;font-size:11px;letter-spacing:2px}.orbit{position:absolute;border:1px solid #467b84;width:62%;height:170px;top:130px;left:19%;border-radius:50%;transform:rotate(24deg)}.orbit.two{transform:rotate(-24deg)}footer{height:76px;padding:9px 22px;background:#0b211c;border-top:1px solid #a88b47;display:flex;align-items:center;gap:22px}.facts{position:relative;padding:12px 0 24px;z-index:2}.facts p{font-size:11px;color:#c0c9b2}.seal{font-size:10px;letter-spacing:2px;color:#bda464}.war .scene{background:linear-gradient(#2e2424,#182c26)}.spice .scene{background:linear-gradient(#715232,#bc9251)}.politics .scene{background:linear-gradient(#2f2444,#132c27)} + /* Compact, centred layout at 75% of the canvas, rounded edges and a Dune palette. Later rules override the base styles above. */ + body{padding:10px 0;font-family:"Noto Sans","DejaVu Sans","Segoe UI",sans-serif;background:radial-gradient(ellipse at 50% 0,#0d2c30,#03100f 72%)} + .frame{width:75%;margin:0 auto;min-height:520px;border-radius:14px;outline-offset:4px;box-shadow:0 0 0 1px #3a2f18,0 10px 30px #02080a} + h1,h2,small,.seal{font-family:"Palatino Linotype","Book Antiqua","Noto Serif",Georgia,serif} + header{height:64px;padding:6px 18px;gap:16px;border-radius:12px 12px 0 0;border-bottom:2px solid #c9a24d;background:linear-gradient(90deg,#14382f,#06201b 60%,#0b2a3a)} + h1{font-size:22px;margin:3px 0 0}.brand{width:150px}.brand-logo{width:132px;height:48px}.close{border-radius:8px} + .scene{min-height:360px} + .card{width:18.5%;height:138px;padding:8px;border-radius:10px;box-shadow:inset 0 0 0 2px #0a231f,inset 0 0 14px #0f4a52,0 3px 8px #071713} + .card:hover{box-shadow:inset 0 0 0 2px #0a231f,inset 0 0 16px #c98a2c,0 3px 10px #071713} + .card .emblem{width:40px;height:40px;border-radius:8px;text-shadow:0 0 6px var(--accent)} + .hub .card{width:18.5%}.journal .card{width:31%;height:138px}.council .card{height:138px}.bank .card{width:24%}.constellation .card{border-radius:12px} + h2{font-size:13px}.item-icon{width:32px;height:32px} + .market-tool,.back,.pager,.cash-action,.detail-link{border-radius:8px}.item-details,.facts,.receipt .facts{border-radius:10px} + footer{height:52px;padding:6px 18px;border-radius:0 0 12px 12px;gap:18px;background:linear-gradient(90deg,#0b211c,#0a2330)} + .detail-link{right:6px;top:6px;font-size:9px;padding:2px 5px;opacity:.85} + .motto{color:#e0a64e} """; } diff --git a/DuneMenus/src/test/java/com/dunerealms/menus/SuppliedDocumentTest.java b/DuneMenus/src/test/java/com/dunerealms/menus/SuppliedDocumentTest.java index 38583ba6..ad23a60a 100644 --- a/DuneMenus/src/test/java/com/dunerealms/menus/SuppliedDocumentTest.java +++ b/DuneMenus/src/test/java/com/dunerealms/menus/SuppliedDocumentTest.java @@ -58,4 +58,29 @@ class SuppliedDocumentTest { var sell=new Card(49,"Sell item",List.of("List the item in your main hand"),"hopper");var mine=new Card(7,"My listings",List.of("Manage existing listings"),"chest");var item=new Card(13,"Real item",List.of("100 DM"),"iron_sword"); String html=SuppliedDocument.html("exchange","Buy","",List.of(sell,mine,item),List.of());assertTrue(html.contains("class='market-tool' data-slot='49'"));assertTrue(html.contains("class='market-tool' data-slot='7'"));assertTrue(html.contains("class='card n0' data-slot='13'"));assertEquals(1,html.split("data-slot='49'",-1).length-1); } + + @Test void everyFamilyHasOnlyLocalAssetsAndRealActions(){ + var allowedSrc=java.util.regex.Pattern.compile("(art/(logo|rihla)\\.png|pack/assets/[a-z0-9_/.-]+\\.png)"); + for(String id:List.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","deposit","redeem","receipt","transfer")){ + var cards=new java.util.ArrayList();var images=new java.util.HashMap(); + for(int n=0;n<6;n++){cards.add(new Card(n,"Entry "+n,List.of("Line "+n),"compass",n!=2));images.put(n,"pack/assets/dunerealms/textures/item/x"+n+".png");} + cards.add(new Card(45,"Back",List.of(),"arrow")); + String html=SuppliedDocument.html(id,id,"sub",cards,List.of("info"),images); + assertFalse(html.matches("(?is).*(href\\s*=|https?:|javascript:|();var m=java.util.regex.Pattern.compile("data-slot='(\\d+)'").matcher(html.replaceAll("(?s)","")); + while(m.find())slots.add(m.group(1)); + assertEquals(slots.size(),new java.util.HashSet<>(slots).size(),id+" duplicate action slot"); + assertFalse(slots.contains("2"),id+" locked card has an action"); + for(String slot:slots){int value=Integer.parseInt(slot);int real=value>=1000?value-1000:value;assertTrue(cards.stream().anyMatch(c->c.slot()==real&&c.enabled()),id+" unknown or locked slot "+slot);} + } + } + @Test void bundledArtFilesExist(){ + for(String f:List.of("menu-art/art/logo.png","menu-art/art/rihla.png"))assertNotNull(getClass().getClassLoader().getResource(f),f); + } + @Test void menuIsCentredAtThreeQuartersOfTheCanvas(){ + String html=SuppliedDocument.html("hub","Hub","",List.of(),List.of()); + assertTrue(html.contains(".frame{width:75%;margin:0 auto"));assertTrue(html.contains("THE SPICE MUST FLOW")); + } } diff --git a/tools/install-plugin-fleet.py b/tools/install-plugin-fleet.py index 4e0e81d1..db800d92 100644 --- a/tools/install-plugin-fleet.py +++ b/tools/install-plugin-fleet.py @@ -75,8 +75,9 @@ def verify_dunechest_fleet_target(sid, root, unit, incoming, installed): def plan(artifacts, inventory, expected_source): mode=inventory.get('mode') - if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa'}: + if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa','compact-menus'}: raise ValueError('An explicit supported rollout mode is required') + compact_menus=mode=='compact-menus' jerboa=mode=='arrakis-jerboa' raw_spice=mode=='arrakis-raw-spice' pillager=mode=='pillager-preserve-economy' @@ -91,6 +92,10 @@ def plan(artifacts, inventory, expected_source): allowed_names = {'DuneEss', 'DuneRealms', 'DuneCore', 'DuneLobby', 'DuneNPC', 'DunerealmsGUI', 'DuneTerrain', 'JarvisTranslator', 'DuneMenus'} if dunechest: allowed_names={'DuneChest'} + if compact_menus: + allowed_names={'DuneMenus'} + if inventory.get('menuPack') is not None: + raise ValueError('Compact menus require retaining the current resource pack') if jerboa: allowed_names={'DuneTerrain'} if raw_spice: @@ -160,11 +165,16 @@ def plan(artifacts, inventory, expected_source): raise ValueError('Server private prerequisites must be explicitly provided and reviewed') chosen = [files[name] for name in selected] + [prerequisites[key] for key in selected_prerequisites] wanted = {entry['name'].casefold() for entry in chosen} - uses_menu='dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa)) + uses_menu=not compact_menus and ('dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa))) if menu and menu.get('unified') and not (crysknife or dunechest or jerboa) and 'dunerealmsgui' not in wanted: raise ValueError('Unified pack rollout must select its matching DunerealmsGUI adapter') if not (pillager or crysknife or navigator or dunechest or raw_spice or jerboa) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}: raise ValueError('GUI rollout must retain working Ess/JARVIS/Core/Terrain binaries') + if compact_menus: + expected_root = Path('/opt/dunerealms/lobby') if sid == 'lobby' else Path('/opt/dunerealms/servers') / sid + if (sid not in DUNECHEST_PLANETS | {'lobby'} or root != expected_root or unit != f'dune-{sid}.service' + or wanted != {'dunemenus'} or selected_prerequisites): + raise ValueError('Compact menus may only replace DuneMenus on a reviewed server') if jerboa and (sid != 'arrakis' or root != ARRAKIS_ROOT or unit != 'dune-arrakis.service' or wanted != {'duneterrain'} or selected_prerequisites): raise ValueError('Jerboa rollout may only replace Terrain on Arrakis') @@ -325,6 +335,17 @@ def plan(artifacts, inventory, expected_source): replaced={entry['filename'] for entry in previous} retained=[{'filename':path.name,'sha256':digest(path),'metadata':metadata(path)} for path in sorted(plugins.glob('*.jar')) if path.name not in replaced] + if compact_menus: + from plugin_compact_menus import BASELINE_SHA256, verify_jar + installed = existing_paths.get('dunemenus') + if installed is None or digest(installed) not in {BASELINE_SHA256, chosen[0]['sha256']}: + raise ValueError('Compact menus require the reviewed installed DuneMenus') + if not {'dunerealmsgui', 'jarvistranslator', 'mcgui'}.issubset(existing_paths): + raise ValueError('Compact menus require the retained GUI, JARVIS and MCGUI runtimes') + verify_jar(chosen[0]['source']) + replaced = {entry['filename'] for entry in previous} + retained = [{'filename': path.name, 'sha256': digest(path), 'metadata': metadata(path)} + for path in sorted(plugins.glob('*.jar')) if path.name not in replaced] if jerboa: from plugin_arrakis_jerboa import BASELINE_SHA256, verify_terrain installed = existing_paths.get('duneterrain') diff --git a/tools/navigator-transition.json b/tools/navigator-transition.json index 272608b2..d24e3656 100644 --- a/tools/navigator-transition.json +++ b/tools/navigator-transition.json @@ -10,7 +10,7 @@ }, "modules": { "DuneMenus": { - "version": "2.0.8-navigator1", + "version": "2.0.9-compact1", "changedClasses": [ "com/dunerealms/menus/CanvasProvider.class", "com/dunerealms/menus/Card.class", diff --git a/tools/plugin_compact_menus.py b/tools/plugin_compact_menus.py new file mode 100644 index 00000000..88863c66 --- /dev/null +++ b/tools/plugin_compact_menus.py @@ -0,0 +1,30 @@ +from pathlib import Path +import hashlib +import zipfile + +BASELINE_SHA256 = '1b8bbfe5ff34341e54267bca2fb87aabc780e483b5ea015870dd517b99af8871' +OVERLAY = 'com/dunerealms/menus/SuppliedDocument.class' +RETAINED_TREE = 'b8ed957242f45c034250cb482a23f91af7affe11167e5a7e9d070360d57f85df' +DESCRIPTOR_SHA256 = '209c7f8da76a2788ce40de9e83fbca9e4370c665cf5d9803b5ea31d812f1894b' + + +def verify_jar(path): + if any(len(pin) != 64 for pin in (BASELINE_SHA256, RETAINED_TREE, DESCRIPTOR_SHA256)): + raise ValueError('Expected complete SHA-256 pins') + with zipfile.ZipFile(path) as jar: + names = [name for name in jar.namelist() if not name.endswith('/')] + if len(set(names)) != len(names): + raise ValueError('Duplicate DuneMenus archive entry') + if b'THE SPICE MUST FLOW' not in jar.read(OVERLAY): + raise ValueError('Compact menu markup is missing') + if hashlib.sha256(jar.read('plugin.yml')).hexdigest() != DESCRIPTOR_SHA256: + raise ValueError('DuneMenus descriptor differs outside the reviewed version') + rows = [name + '\0' + hashlib.sha256(jar.read(name)).hexdigest() + for name in sorted(names) if name not in {OVERLAY, 'plugin.yml'}] + if hashlib.sha256('\n'.join(rows).encode()).hexdigest() != RETAINED_TREE: + raise ValueError('DuneMenus changed outside the reviewed compact UI and version') + + +if __name__ == '__main__': + import sys + verify_jar(Path(sys.argv[1]))