Build reproducible GUI renderer verification and safe fleet installer
This commit is contained in:
parent
794a96b5f8
commit
72a11f0870
1 changed files with 407 additions and 3 deletions
|
|
@ -0,0 +1,26 @@
|
|||
package com.dunerealms.menus;
|
||||
import java.nio.file.*;import java.util.*;import java.awt.geom.*;import javax.imageio.ImageIO;import ai.resourcepack.ui.html.*;import ai.resourcepack.ui.html.css.Selector;
|
||||
public class RendererVerification {
|
||||
public static void main(String[]args)throws Exception{
|
||||
Path dir=Path.of(args[0]);Files.createDirectories(dir);var loader=new Page.Loader(false,dir.resolve("engine-cache"));int checked=0;
|
||||
for(String id:List.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","transfer")){
|
||||
List<Card> cards=new ArrayList<>();int count=id.equals("exchange")?28:id.equals("travel")?5:8;
|
||||
for(int n=0;n<count;n++)cards.add(new Card(n,(n==0?"Imperial Postbank":"Entry "+(n+1)),List.of("Verified service detail","Amount: 100.00 DM"),id.equals("travel")?"compass":"emerald"));
|
||||
cards.add(new Card(45,"Back",List.of(),"arrow"));
|
||||
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);
|
||||
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);
|
||||
if(bounds==null||bounds.getWidth()<=0||bounds.getHeight()<=0)throw new AssertionError(id+" invisible slot "+card.slot());
|
||||
double scroll=Math.max(0,Math.min(frame.maxScroll(),bounds.getCenterY()-260));var visible=HtmlRenderer.render(page,1536,896,1.5,scroll,Selector.State.NONE);
|
||||
var at=visible.elementAt(bounds.getCenterX(),bounds.getCenterY()-scroll);var button=at==null?null:at.closest("[data-slot]");
|
||||
if(button==null||!button.attr("data-slot").equals(""+card.slot()))throw new AssertionError(id+" hit slot "+card.slot()+" at "+bounds+" scroll="+scroll+" got="+button);
|
||||
checked++;
|
||||
}
|
||||
System.out.println(id+": parser clean; "+cards.size()+" action hitboxes; maxScroll="+frame.maxScroll());
|
||||
}
|
||||
System.out.println("PASS: "+checked+" direct action hitboxes across15 menu families.");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff