Shrink the House selection cards #51

Merged
unimatrix merged 1 commit from feat/dunemenus-compact-house-20261202 into main 2026-12-02 07:18:27 +01:00
6 changed files with 52 additions and 6 deletions

View file

@ -1,7 +1,7 @@
import java.security.MessageDigest
plugins { java }
group = "com.dunerealms"
version = "2.0.9-compact1"
version = "2.0.10-housecompact1"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")

View file

@ -16,6 +16,7 @@ final class SuppliedDocument {
static String html(String id,String title,String subtitle,List<Card> cards,List<String> info,Map<Integer,String> images,int selected){
boolean rihla=Set.of("atm","withdraw","deposit","redeem","receipt").contains(id);
String layout=switch(id){case "travel"->"constellation";case "clan","company","house","politics"->"council";case "missions","war"->"journal";case "bank","atm","withdraw","deposit","redeem","receipt","transfer"->"bank";default->"doors";};
if(id.equals("house")&&(title.equals("Choose your House")||title.equals("Your House")))layout+=" house-choices";
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset='UTF-8'><style>").append(CSS).append("</style></head><body style='--accent:").append(accent(id)).append("'><div class='frame ").append(escape(id)).append("'><header><div class='brand'><img class='brand-logo' src='art/logo.png'></div><div class='heading'><small>THE IMPERIAL CONCOURSE</small><h1>").append(escape(title)).append("</h1></div><button class='close' data-slot='-1'>×</button></header><div class='scene'><div class='moon'></div><div class='dune rear'></div><div class='dune front'></div><p class='quote'>").append(escape(subtitle)).append("</p>");
if(layout.equals("constellation"))b.append("<div class='orbit one'></div><div class='orbit two'></div><div class='guild'>✷<span>SPACING GUILD</span></div>");
if(id.equals("exchange")){b.append("<nav class='market-tools'>");for(Card c:cards)if(marketTool(c))b.append("<button class='market-tool' data-slot='").append(c.slot()).append("'><span class='tool-icon'>").append(image(c,images)).append("</span><span>").append(escape(c.title())).append("</span></button>");b.append("</nav>");cards=cards.stream().filter(c->!marketTool(c)).toList();}
@ -50,6 +51,10 @@ final class SuppliedDocument {
.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}
.house-choices .card{width:26%;height:105px;min-height:105px}
.house-choices .card .emblem{width:32px;height:32px;line-height:26px}
.house-choices .card .item-icon{width:26px;height:26px}
.house-choices .card h2{font-size: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)}

View file

@ -41,6 +41,7 @@ public class RendererVerification {
System.out.println(id+": parser clean; "+cards.size()+" action hitboxes; maxScroll="+frame.maxScroll()+"; render-and-hitbox-ms="+((System.nanoTime()-started)/1_000_000));
}
verifyNavigators(dir,loader);
verifyHouseChoices(dir,loader);
var actualIcon=Path.of("../network/resource-pack/central/overlay/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Path iconTarget=dir.resolve("pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Files.createDirectories(iconTarget.getParent());Files.copy(actualIcon,iconTarget,StandardCopyOption.REPLACE_EXISTING);
for(String name:List.of("item/iron_sword","block/cobblestone")){Path target=dir.resolve("pack/assets/minecraft/textures/"+name+".png");Files.createDirectories(target.getParent());Files.copy(Path.of("../network/resource-pack/vanilla-art/overlay/assets/minecraft/textures/"+name+".png"),target,StandardCopyOption.REPLACE_EXISTING);}
var listing=new Card(13,"\uE400§6Paul's chopper",List.of("LEGENDARY | MK XIV","Used by Paul himself.","Efficiency VIII","Fortune IV","Mending I","Unbreaking IV","Seller: J.A.R.V.I.S. HQ","1 available · 500.00 DM each"),"netherite_axe");
@ -50,6 +51,38 @@ public class RendererVerification {
System.out.println("PASS: "+checked+" direct action hitboxes across15 menu families.");
}
private static void verifyHouseChoices(Path dir,Page.Loader loader)throws Exception{
List<Card> cards=List.of(new Card(10,"Aerdrecht",List.of("Click to select this House"),"paper"),
new Card(13,"Harkveen",List.of("Click to select this House"),"paper"),
new Card(16,"Korenholt",List.of("Click to select this House"),"paper"),
new Card(29,"Vlierdam",List.of("Click to select this House"),"paper"),
new Card(33,"Imperial House with a longer name",List.of("Selected · confirm below"),"paper"));
String html=SuppliedDocument.html("house","Choose your House","",cards,List.of());
var page=Page.of(html,dir.resolve("house-choices.html"),loader);
var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
if(!page.problems.isEmpty())throw new AssertionError(page.problems.toString());
var rendered=page.document.select("main > button");
if(rendered.size()!=5)throw new AssertionError("Expected five House actions");
double firstRow=frame.boundsOf(rendered.first()).getMinY();
int onFirstRow=0;
for(var element:rendered){
var box=frame.boundsOf(element);
if(box==null||box.isEmpty())throw new AssertionError("Missing House card");
if(Math.abs(box.getMinY()-firstRow)<1)onFirstRow++;
var hit=frame.elementAt(box.getCenterX(),box.getCenterY());
if(hit==null||hit.closest("[data-slot]")!=element)throw new AssertionError("House action not reachable");
for(var text:element.select("h2,p")){
var bounds=frame.boundsOf(text);
if(bounds!=null&&(bounds.getMinX()<box.getMinX()-1||bounds.getMaxX()>box.getMaxX()+1
||bounds.getMinY()<box.getMinY()-1||bounds.getMaxY()>box.getMaxY()+1))
throw new AssertionError("House text outside card: "+bounds+" vs "+box);
}
}
if(onFirstRow!=3)throw new AssertionError("Expected three 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");
}
private static void verifyNavigators(Path dir,Page.Loader loader)throws Exception{
List<Card> guild=List.of(
new Card(4,"Arrakduin",List.of("Fare: 125.00 DM"),"compass"),

View file

@ -44,6 +44,13 @@ class SuppliedDocumentTest {
assertEquals("card",SuppliedDocument.kind(new Card(45,"Your House",List.of(),"arrow")));
for(String line:SuppliedDocument.lines("Personal level, Reputation and active quests with a verylongunbrokenwordthatmustalsofit",24))assertTrue(line.length()<=24);
}
@Test void houseChoiceDensityDoesNotCarryOverToAdvisersOrOtherCouncilMenus(){
var cards=List.of(new Card(10,"Aerdrecht",List.of("Click to select this House"),"paper"));
for(String title:List.of("Choose your House","Your House"))
assertTrue(SuppliedDocument.html("house",title,"",cards,List.of()).contains("<main class='council house-choices'>"));
assertTrue(SuppliedDocument.html("house","Your House adviser · Stilgar","",cards,List.of()).contains("<main class='council'>"));
assertTrue(SuppliedDocument.html("company","Your Company","",cards,List.of()).contains("<main class='council'>"));
}
@Test void localArtworkPathsAreEscapedAndNeverRemoteOrTraversable(){
var card=new Card(13,"Axe",List.of(),"netherite_axe");assertTrue(SuppliedDocument.image(card,java.util.Map.of(13,"pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png")).contains("<img"));
assertFalse(SuppliedDocument.image(card,java.util.Map.of(13,"https://evil/image.png")).contains("<img"));assertFalse(SuppliedDocument.image(card,java.util.Map.of(13,"pack/assets/../secret.png")).contains("<img"));

View file

@ -10,7 +10,7 @@
},
"modules": {
"DuneMenus": {
"version": "2.0.9-compact1",
"version": "2.0.10-housecompact1",
"changedClasses": [
"com/dunerealms/menus/CanvasProvider.class",
"com/dunerealms/menus/Card.class",

View file

@ -2,10 +2,10 @@ from pathlib import Path
import hashlib
import zipfile
BASELINE_SHA256 = '1b8bbfe5ff34341e54267bca2fb87aabc780e483b5ea015870dd517b99af8871'
BASELINE_SHA256 = '4585825d0ac6cc70b0c95988cf4e8eb0f378e473d33a10b0a98c4b75fee51a8d'
OVERLAY = 'com/dunerealms/menus/SuppliedDocument.class'
RETAINED_TREE = 'b8ed957242f45c034250cb482a23f91af7affe11167e5a7e9d070360d57f85df'
DESCRIPTOR_SHA256 = '209c7f8da76a2788ce40de9e83fbca9e4370c665cf5d9803b5ea31d812f1894b'
DESCRIPTOR_SHA256 = '0fb38d824e501a45cefee7f04d8b3034c3d735ee9833a48207d58b193717e70f'
def verify_jar(path):
@ -15,8 +15,9 @@ def verify_jar(path):
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')
markup = jar.read(OVERLAY)
if b'THE SPICE MUST FLOW' not in markup or b'house-choices' not in markup:
raise ValueError('Compact menu or House-choice 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()