forked from unimatrix/web
Render opt-in equipment, decision detail and war muster views
This commit is contained in:
parent
4c6b947ab3
commit
f3686fb5e4
1 changed files with 68 additions and 36 deletions
|
|
@ -41,8 +41,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
private static final Font CHECKOUT_TERMS = new Font(Font.SANS_SERIF, Font.BOLD, 15);
|
||||
private static final Font COMPACT_CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
private static final Font COMPACT_CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
|
||||
private static final Font GUILD_TERMS = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
|
||||
private static final int GUILD_TERMS_WIDTH = 108, GUILD_TERMS_LINES = 16;
|
||||
private static final Font SIDEBAR_TERMS = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
|
||||
private static final int SIDEBAR_TERMS_WIDTH = 108, SIDEBAR_TERMS_LINES = 16;
|
||||
private static final Font ARCHIVE_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
|
||||
private static final int ARCHIVE_COLUMN_LINES = 7;
|
||||
private static final int ARCHIVE_COLUMN_WIDTH = 177;
|
||||
|
|
@ -210,7 +210,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static Page page(Document document, int index) {
|
||||
if (document.style() == Style.EXCHANGE_CHECKOUT) return checkoutPage(document, index);
|
||||
if (document.style() == Style.ITEM_ARCHIVE) return archivePage(document, index);
|
||||
if (usesReadingPane(document.style())) return archivePage(document, index);
|
||||
var cards = document.cards();
|
||||
int capacity = capacity(document.style());
|
||||
if (cards.size() <= capacity) return new Page(0, document.style(), cards);
|
||||
|
|
@ -225,12 +225,15 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
}
|
||||
|
||||
private static Page archivePage(Document document, int index) {
|
||||
var entries = document.cards().stream().filter(card -> !card.actionable()).toList();
|
||||
var actions = document.cards().stream().filter(Card::actionable).toList();
|
||||
var entries = document.cards().stream().filter(card -> isReadingEntry(document.style(), card)).toList();
|
||||
var actions = document.cards().stream().filter(card -> !isReadingEntry(document.style(), card)).toList();
|
||||
var entry = entries.get(index);
|
||||
var visible = new ArrayList<Card>();
|
||||
var blank = new Card(EMPTY, "", List.of(), false);
|
||||
visible.add(entries.get(index)); // The reading pane is drawn separately from the interactive tiles.
|
||||
visible.add(entry); // The reading pane is drawn separately from the interactive tiles.
|
||||
visible.add(blank);
|
||||
if (document.style() == Style.WORKSHOP)
|
||||
visible.add(entry.actionable() ? new Card(entry.slot(), entry.title(), List.of(), true, entry.material()) : blank);
|
||||
visible.addAll(actions);
|
||||
while (visible.size() < STANDARD_PAGE) visible.add(blank);
|
||||
if (entries.size() > 1) {
|
||||
|
|
@ -271,7 +274,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
scene.focus = null;
|
||||
for (int row = 0; row < ROWS; row++) {
|
||||
for (int col = 0; col < COLS; col++) {
|
||||
if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && scene.page.style != Style.ITEM_ARCHIVE))) continue;
|
||||
if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && !usesReadingPane(scene.page.style)))) continue;
|
||||
var map = new MapId(FIRST_SCENE_MAP + row * COLS + col);
|
||||
var image = art.getSubimage(col * 128, row * 128, 128, 128);
|
||||
var card = cardAt(scene.page, row, col);
|
||||
|
|
@ -342,7 +345,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static Card cardAt(Page page, int row, int col) {
|
||||
if (row < 3 || row > LAST_ROW || col < 4 || col > 6) return null;
|
||||
if (page.style == Style.ITEM_ARCHIVE && row == 3) return null;
|
||||
if (usesReadingPane(page.style) && row == 3) return null;
|
||||
if (col == 5 && (capacity(page.style) == STANDARD_PAGE || row == LAST_ROW)) return null;
|
||||
int cap = capacity(page.style);
|
||||
int index = row == LAST_ROW ? cap + (col == 4 ? 0 : 1) :
|
||||
|
|
@ -449,7 +452,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
int headlineWidth = draw.getFontMetrics().stringWidth(heading);
|
||||
draw.drawString(heading, (image.getWidth() - headlineWidth) / 2, 372);
|
||||
if (scene.roleplay != null) drawRoleplay(draw, scene);
|
||||
else if (scene.document.style() == Style.ITEM_ARCHIVE) drawArchive(draw, scene, palette);
|
||||
else if (usesReadingPane(scene.document.style())) drawArchive(draw, scene, palette);
|
||||
else if (scene.document.style() != Style.AUTO) drawStyledIdentity(draw, scene, palette);
|
||||
for (int row = 3; row <= LAST_ROW; row++) for (int col = 4; col <= 6; col++) {
|
||||
Card card = cardAt(scene.page, row, col);
|
||||
|
|
@ -479,6 +482,9 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static Palette palette(Scene scene) {
|
||||
return switch (scene.document.style()) {
|
||||
case WAR_MUSTER -> new Palette(new Color(38, 24, 28), new Color(78, 44, 53), new Color(245, 204, 177));
|
||||
case WORKSHOP -> new Palette(new Color(29, 37, 42), new Color(54, 73, 84), new Color(235, 219, 177));
|
||||
case DECISION_DETAIL -> new Palette(new Color(21, 33, 41), new Color(47, 69, 81), new Color(236, 203, 129));
|
||||
case ORGANISATION -> new Palette(new Color(16, 31, 37), new Color(29, 75, 79), new Color(142, 228, 211));
|
||||
case EXCHANGE, EXCHANGE_CHECKOUT -> new Palette(new Color(42, 28, 18), new Color(91, 62, 36), new Color(245, 208, 139));
|
||||
case CODEX, ITEM_ARCHIVE -> new Palette(new Color(40, 33, 24), new Color(90, 63, 37), new Color(246, 221, 158));
|
||||
|
|
@ -504,24 +510,28 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
var terms = checkoutTerms(graphics, document.description());
|
||||
if (terms.isEmpty() || terms.size() > 9) return false;
|
||||
}
|
||||
if (document.style() == Style.GUILD) {
|
||||
graphics.setFont(GUILD_TERMS);
|
||||
var terms = guildTerms(graphics, document);
|
||||
if (document.style() == Style.GUILD || document.style() == Style.WAR_MUSTER) {
|
||||
graphics.setFont(SIDEBAR_TERMS);
|
||||
var terms = sidebarTerms(graphics, document);
|
||||
if (terms.lines().isEmpty() || !terms.complete()) return false;
|
||||
}
|
||||
if (document.style() == Style.ITEM_ARCHIVE) {
|
||||
long actionCount = document.cards().stream().filter(Card::actionable).count();
|
||||
if (actionCount < 1 || actionCount > 2 || actionCount == document.cards().size()) return false;
|
||||
if (usesReadingPane(document.style())) {
|
||||
long navigationCount = document.cards().stream().filter(card -> !isReadingEntry(document.style(), card)).count();
|
||||
int maximumNavigation = document.style() == Style.WORKSHOP ? 1 : 2;
|
||||
if (navigationCount > maximumNavigation || navigationCount == document.cards().size()) return false;
|
||||
if (document.style() == Style.ITEM_ARCHIVE && navigationCount == 0) return false;
|
||||
}
|
||||
graphics.setFont(CARD_TITLE);
|
||||
if (document.identity() != null && !wrap(graphics, document.identity().mentat(), 112, 2).complete) return false;
|
||||
for (Card card : document.cards()) {
|
||||
boolean seal = document.style() == Style.HOUSE && nativeArt(card.material()) != null;
|
||||
graphics.setFont(CARD_TITLE);
|
||||
if (document.style() == Style.ITEM_ARCHIVE && !card.actionable()) {
|
||||
if (usesReadingPane(document.style()) && isReadingEntry(document.style(), card)) {
|
||||
if (!wrap(graphics, card.title(), 368, 1).complete) return false;
|
||||
graphics.setFont(ARCHIVE_LORE);
|
||||
if (!archiveLore(graphics, card).complete) return false;
|
||||
if (document.style() == Style.WORKSHOP && card.actionable() &&
|
||||
!fitsFullCardTitle(graphics, document.style(), card)) return false;
|
||||
continue;
|
||||
}
|
||||
if (usesFullCardLore(document.style())) {
|
||||
|
|
@ -542,7 +552,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static void setHeadingFont(java.awt.Graphics2D draw, Style style, String title) {
|
||||
int size = switch (style) {
|
||||
case ITEM_ARCHIVE, GUILD, ORGANISATION -> 28;
|
||||
case ITEM_ARCHIVE, GUILD, ORGANISATION, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> 28;
|
||||
default -> 38;
|
||||
};
|
||||
draw.setFont(new Font(Font.SANS_SERIF, Font.BOLD, size));
|
||||
|
|
@ -555,7 +565,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static boolean usesFullCardLore(Style style) {
|
||||
return switch (style) {
|
||||
case JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE, ORGANISATION -> true;
|
||||
case JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE, ORGANISATION, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
|
@ -571,11 +581,20 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
}
|
||||
|
||||
private static boolean compactCardLore(Style style) {
|
||||
return style == Style.SPICE || style == Style.ORGANISATION;
|
||||
return style == Style.SPICE || style == Style.ORGANISATION || style == Style.WORKSHOP || style == Style.DECISION_DETAIL || style == Style.WAR_MUSTER;
|
||||
}
|
||||
|
||||
private static Wrapped guildTerms(java.awt.Graphics2D draw, Document document) {
|
||||
return wrapLore(draw, document.description().lines().toList(), GUILD_TERMS_WIDTH, GUILD_TERMS_LINES);
|
||||
private static boolean usesReadingPane(Style style) {
|
||||
return style == Style.ITEM_ARCHIVE || style == Style.WORKSHOP;
|
||||
}
|
||||
|
||||
private static boolean isReadingEntry(Style style, Card card) {
|
||||
if (style == Style.ITEM_ARCHIVE) return !card.actionable();
|
||||
return !card.actionable() || (!card.title().equals("Back") && !card.title().equals("Close"));
|
||||
}
|
||||
|
||||
private static Wrapped sidebarTerms(java.awt.Graphics2D draw, Document document) {
|
||||
return wrapLore(draw, document.description().lines().toList(), SIDEBAR_TERMS_WIDTH, SIDEBAR_TERMS_LINES);
|
||||
}
|
||||
|
||||
private static Wrapped archiveLore(java.awt.Graphics2D draw, Card card) {
|
||||
|
|
@ -664,11 +683,11 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
draw.setColor(palette.background.darker());
|
||||
draw.fillRect(644, 389, 120, 232);
|
||||
switch (document.style()) {
|
||||
case GUILD -> {
|
||||
case GUILD, WAR_MUSTER -> {
|
||||
draw.setColor(palette.accent);
|
||||
draw.setFont(GUILD_TERMS);
|
||||
draw.setFont(SIDEBAR_TERMS);
|
||||
int y = 406;
|
||||
for (String line : guildTerms(draw, document).lines()) {
|
||||
for (String line : sidebarTerms(draw, document).lines()) {
|
||||
draw.drawString(line, 649, y);
|
||||
y += draw.getFontMetrics().getHeight();
|
||||
}
|
||||
|
|
@ -790,6 +809,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
String heading = switch (title[0]) {
|
||||
case "NPC dashboard" -> "YOUR MISSIONS";
|
||||
case "NPC next quest" -> "YOUR NEXT MISSION";
|
||||
case "NPC turn-in decision" -> "POLITICAL DECISION";
|
||||
case "NPC next quest decision" -> "DECISION RECORDED";
|
||||
case "NPC turn-in" -> document.cards().stream().anyMatch(card ->
|
||||
card.actionable() && (card.title().equals("Claim verified reward") || card.title().equals("Next quest")))
|
||||
? "MISSION COMPLETE" : "MISSION TURN-IN";
|
||||
|
|
@ -824,7 +845,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
try {
|
||||
graphics.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
|
||||
if (!wrap(graphics, roleplay.contact, 112, 2).complete) return false;
|
||||
if (!fitsCards(graphics, document, roleplay)) return false;
|
||||
if (document.style() == Style.AUTO && !fitsCards(graphics, document, roleplay)) return false;
|
||||
graphics.setFont(CARD_LORE);
|
||||
String summary = roleplay.summary == null ? document.description() : String.join(" ", roleplay.summary.lore());
|
||||
return wrap(graphics, summary, 112, 6).complete;
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff