forked from unimatrix/web
Display official organisation emblems and political Mentats
This commit is contained in:
parent
d6a009979f
commit
297eafe2b4
1 changed files with 123 additions and 16 deletions
|
|
@ -5,6 +5,7 @@ import java.util.regex.*;
|
|||
|
||||
/** Market-shaped presentation. All dynamic content is text; actions live in the server session. */
|
||||
final class MenuDocument {
|
||||
record Branding(String logo,String mentat,int portrait){}
|
||||
record Card(int slot,String title,List<String> lore,String material,int amount,boolean action,String quality){}
|
||||
static boolean compactControl(Card c){return c.action&&(Set.of("16","32","64").contains(c.title)||c.title.matches("[+−] (?:[0-9].*|Quantity)"));}
|
||||
static String clean(String text){return text==null?"":text.replaceAll("[\\p{Co}\\p{Cc}&&[^\\n]]","").replaceAll("(?i)§[0-9a-fk-orx]","").trim();}
|
||||
|
|
@ -19,11 +20,14 @@ final class MenuDocument {
|
|||
}
|
||||
static String fact(Card c){for(String line:c.lore){Matcher m=Pattern.compile("[0-9][0-9,.]*\\s*DM").matcher(line);if(m.find())return m.group();}for(String line:c.lore)if(line.matches("(?i).*(progress|claimed|in progress|XP|complete).*"))return line.length()>35?line.substring(0,32)+"…":line;return c.amount>1?"× "+c.amount:c.action?"View →":"Details";}
|
||||
static String html(String title,String description,String player,List<Card> cards,int selected,Path root){
|
||||
return html(title,description,player,cards,selected,root,null);
|
||||
}
|
||||
static String html(String title,String description,String player,List<Card> cards,int selected,Path root,Branding branding){
|
||||
if(title.equals("War Muster Room"))return warMusterRoom(description,player,cards,root);
|
||||
if(title.startsWith("NPC dashboard · ")||title.startsWith("NPC turn-in · ")||title.startsWith("NPC next quest · ")||title.startsWith("NPC dashboard decision · ")||title.startsWith("NPC turn-in decision · ")||title.startsWith("NPC next quest decision · "))return roleplay(title,description,cards,selected,root);
|
||||
int back=cards.stream().filter(c->c.action&&(c.title.equalsIgnoreCase("Back")||c.title.toLowerCase(Locale.ROOT).startsWith("back to "))).mapToInt(Card::slot).findFirst().orElse(-3);
|
||||
List<Card> controls=cards.stream().filter(MenuDocument::compactControl).toList();cards=cards.stream().filter(c->!compactControl(c)).toList();
|
||||
String theme=theme(title,cards);
|
||||
String theme=branding==null?theme(title,cards):"organisation";
|
||||
Card detail=cards.stream().filter(c->c.slot==selected).findFirst().orElse(cards.isEmpty()?null:cards.get(0));
|
||||
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset=\"utf-8\"><title>DuneRealms</title><style>").append(CSS).append(CONTROL_CSS).append(THEME_CSS).append("</style></head><body class=\"").append(theme).append("\"><div class=\"awning\"></div><header><img class=\"logo\" src=\"art/dunerealms-season-logo-v2.png\"><div class=\"heading\"><small>CHOAM · IMPERIAL SERVICES</small><h1>").append(escape(title)).append("</h1></div><span class=\"viewer\">").append(escape(player)).append("</span><nav class=\"menu-nav\"><button data-slot=\"-3\">⌂ Home</button><button data-slot=\"").append(back).append("\">← Back</button></nav><button class=\"close\" data-slot=\"-1\">×</button></header><main><aside class=\"").append(detail!=null&&detail.material.equals("light_blue_dye")?"ingame":"").append("\">");
|
||||
if(detail!=null){String image=icon(detail,root);b.append("<div class=\"stage\">");if(!image.isBlank())b.append("<img src=\"").append(image).append("\">");else b.append("<span>◇</span>");b.append("</div><h2>").append(escape(detail.title)).append("</h2>");
|
||||
|
|
@ -32,6 +36,19 @@ final class MenuDocument {
|
|||
if(detail.action&&!theme.equals("house")&&!theme.equals("organisation"))b.append("<button class=\"primary\" data-slot=\"").append(detail.slot).append("\">").append(escape(detail.title)).append(" →</button>");
|
||||
}else b.append("<h2>Your realm awaits</h2><p>No entries are available in this selection.</p>");
|
||||
b.append("</aside><section class=\"shelves\">");
|
||||
if(branding!=null&&(!branding.logo.isEmpty()||!branding.mentat.isEmpty())){
|
||||
b.append("<div class=\"organisation-identity\">");
|
||||
if(branding.logo.length()<=110000&&branding.logo.matches("[A-Za-z0-9+/]+={0,2}")){
|
||||
b.append("<img alt=\"Organisation emblem\" src=\"data:image/png;base64,").append(branding.logo).append("\">");
|
||||
}
|
||||
if(!branding.mentat.isEmpty()){
|
||||
if(branding.portrait>=0&&branding.portrait<=7){
|
||||
b.append("<img alt=\"\" src=\"art/npc_avatar_").append(branding.portrait).append(".png\">");
|
||||
}
|
||||
b.append("<div>Mentat<h2>").append(escape(branding.mentat)).append("</h2></div>");
|
||||
}
|
||||
b.append("</div>");
|
||||
}
|
||||
if(!clean(description).isBlank())b.append("<p class=\"intro\">").append(escape(description).replace("\n","<br>")).append("</p>");
|
||||
if(!controls.isEmpty()){b.append("<div class=\"quick-controls\">");for(Card c:controls)b.append("<button data-slot=\"").append(c.slot).append("\">").append(escape(c.title)).append("</button>");b.append("</div>");}
|
||||
for(int i=0;i<cards.size();i+=4){b.append("<div class=\"shelf\"><div class=\"goods\">");for(Card c:cards.subList(i,Math.min(i+4,cards.size()))){
|
||||
|
|
@ -107,6 +124,8 @@ final class MenuDocument {
|
|||
.spice .slot{padding:10px;background:#3d271c;border:1px solid #aa6545}
|
||||
.spice .cubby{background:#2e1c15;border-color:#aa6545}
|
||||
.organisation{--accent:#9ee3d7;--edge:#578f8e;--glow:#7dcab832;background:linear-gradient(160deg,#152d34,#0b2025)}
|
||||
.organisation-identity{display:flex;align-items:center;gap:18px;padding:10px 18px;margin-bottom:12px;border:1px solid #578f8e;background:#152d34}
|
||||
.organisation-identity img{width:88px;height:88px;object-fit:contain}
|
||||
.organisation .awning{height:8px;background:#578f8e;border:0}
|
||||
.organisation main{display:block}.organisation aside{display:none}.organisation .goods{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||
.organisation .slot{flex-direction:row;text-align:left;gap:15px;padding:18px;background:#1a3840;border:1px solid #578f8e}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff