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(); 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("",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"); } }