Redesign the Mission Journal as a parchment ledger

This commit is contained in:
unimatrixgit 2026-11-28 14:25:28 +01:00
commit 7215f9aab2
2 changed files with 151 additions and 9 deletions

View file

@ -34,6 +34,10 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
private static final int COLS = 11, ROWS = 9;
private static final int STANDARD_PAGE = 4, THREE_COLUMN_PAGE = 6;
private static final int LAST_ROW = 5, LAST_CARD_HEIGHT = 64;
private static final int JOURNAL_WIDTH = 384;
private static final int JOURNAL_TEXT_WIDTH = 304;
private static final Font JOURNAL_TITLE = new Font(Font.SERIF, Font.BOLD, 24);
private static final Font JOURNAL_TEXT = new Font(Font.SANS_SERIF, Font.PLAIN, 16);
private static final Font CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 17);
private static final Font CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
private static final int FULL_CARD_LORE_LINES = 5;
@ -70,7 +74,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
final IntConsumer select;
final Runnable dismiss;
final List<Entity> entities = new ArrayList<>();
final Map<Integer, Tile> buttons = new HashMap<>();
final Map<Integer, List<Tile>> buttons = new HashMap<>();
Integer focus;
volatile Page page;
int mountId;
@ -211,6 +215,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 (usesReadingPane(document.style())) return archivePage(document, index);
if (document.style() == Style.JOURNAL) return journalPage(document, index);
var cards = document.cards();
int capacity = capacity(document.style());
if (cards.size() <= capacity) return new Page(0, document.style(), cards);
@ -224,6 +229,23 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
return new Page(index, document.style(), List.copyOf(visible));
}
private static Page journalPage(Document document, int index) {
var back = document.cards().stream()
.filter(card -> card.actionable() && card.title().equals("Back")).findFirst().orElse(null);
var entries = document.cards().stream().filter(card -> card != back).toList();
int start = index * 2;
int end = Math.min(start + 2, entries.size());
int count = Math.max(1, (entries.size() + 1) / 2);
var blank = new Card(EMPTY, "", List.of(), false);
var visible = new ArrayList<>(entries.subList(start, end));
while (visible.size() < 2) visible.add(blank);
var label = List.of("Page " + (index + 1) + " / " + count);
visible.add(new Card(PREVIOUS, "Previous", label, index > 0));
visible.add(back == null ? blank : back);
visible.add(new Card(NEXT, "Next", label, end < entries.size()));
return new Page(index, document.style(), List.copyOf(visible));
}
private static Page archivePage(Document document, int index) {
var entries = document.cards().stream().filter(card -> isReadingEntry(document.style(), card)).toList();
var actions = document.cards().stream().filter(card -> !isReadingEntry(document.style(), card)).toList();
@ -294,12 +316,15 @@ 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 && !usesReadingPane(scene.page.style)))) continue;
if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && !usesReadingPane(scene.page.style) && scene.page.style != Style.JOURNAL))) 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);
var tile = new Tile(map, image, card == null || !card.actionable() ? image : focused(image, row == LAST_ROW ? LAST_CARD_HEIGHT : 122));
if (card != null && card.actionable()) scene.buttons.put(card.slot(), tile);
boolean journalRow = scene.page.style == Style.JOURNAL && row < LAST_ROW;
var tile = new Tile(map, image, card == null || !card.actionable() ? image :
journalRow ? focusedJournalRow(image, col) : focused(image, row == LAST_ROW ? LAST_CARD_HEIGHT : 122));
if (card != null && card.actionable())
scene.buttons.computeIfAbsent(card.slot(), ignored -> new ArrayList<>()).add(tile);
pixels(scene, tile, false);
}
}
@ -365,6 +390,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.JOURNAL) return page.cards.get(row == LAST_ROW ? col - 2 : row - 3);
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);
@ -385,7 +411,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
private void focus(Scene scene, Integer slot) {
if (scene.closed || Objects.equals(scene.focus, slot)) return;
scene.focus = slot;
scene.buttons.forEach((action, tile) -> pixels(scene, tile, action.equals(slot)));
scene.buttons.forEach((action, tiles) -> tiles.forEach(tile -> pixels(scene, tile, action.equals(slot))));
}
private void select(Scene scene, Integer slot) {
@ -481,6 +507,10 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
draw.setColor(palette.background);
draw.fillRect(0, 0, image.getWidth(), image.getHeight());
draw.setColor(palette.accent);
if (scene.document.style() == Style.JOURNAL) {
drawJournal(draw, scene.document, scene.page, palette);
return image;
}
draw.setStroke(new BasicStroke(7));
draw.drawRect(445, 335, 518, 374);
@ -516,6 +546,117 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
return image;
}
private static boolean fitsJournal(java.awt.Graphics2D draw, Document document) {
draw.setFont(JOURNAL_TITLE);
if (!wrap(draw, document.title(), 323, 1).complete()) return false;
for (Card card : document.cards()) {
var title = journalRowTitle(draw, card);
if (!title.complete()) return false;
draw.setFont(JOURNAL_TEXT);
if (!wrapLore(draw, card.lore(), JOURNAL_TEXT_WIDTH, 5 - title.lines().size()).complete()) return false;
}
return true;
}
private static Wrapped journalRowTitle(java.awt.Graphics2D draw, Card card) {
draw.setFont(JOURNAL_TITLE);
var title = wrap(draw, card.title(), JOURNAL_TEXT_WIDTH, 2);
if (title.complete()) return title;
draw.setFont(JOURNAL_TITLE.deriveFont(19f));
return wrap(draw, card.title(), JOURNAL_TEXT_WIDTH, 2);
}
private void drawJournal(java.awt.Graphics2D draw, Document document, Page page, Palette palette) {
var ink = new Color(34, 43, 39);
var binding = new Color(25, 58, 51);
var brass = new Color(199, 152, 72);
draw.setColor(new Color(12, 28, 27));
draw.fillRoundRect(478, 330, 452, 386, 16, 16);
draw.setColor(brass);
draw.drawRoundRect(485, 337, 438, 372, 12, 12);
draw.setColor(binding);
draw.fillRoundRect(490, 342, 428, 362, 10, 10);
draw.setColor(brass);
draw.fillRect(510, 379, JOURNAL_WIDTH + 4, 2);
drawResource(draw, "/mcgui/dunerealms-season-logo-v2.png", 506, 349, 62, 24);
draw.setColor(palette.accent);
draw.setFont(JOURNAL_TITLE);
draw.drawString(document.title(), 578, 370);
for (int row = 3; row < LAST_ROW; row++) {
Card card = cardAt(page, row, 5);
if (card == null || card.slot() == EMPTY) continue;
int y = row * 128;
draw.setColor(new Color(15, 36, 32));
draw.fillRoundRect(514, y + 8, JOURNAL_WIDTH - 2, 116, 12, 12);
draw.setColor(card.actionable() ? palette.tile : new Color(188, 177, 149));
draw.fillRoundRect(512, y + 4, JOURNAL_WIDTH, 116, 12, 12);
draw.setColor(brass);
draw.drawRoundRect(515, y + 7, JOURNAL_WIDTH - 7, 109, 9, 9);
draw.drawLine(530, y + 14, 530, y + 110);
draw.setColor(ink);
var title = journalRowTitle(draw, card).lines();
int titleHeight = draw.getFontMetrics().getHeight();
int textY = y + 31;
for (String line : title) {
draw.drawString(line, 543, textY);
textY += titleHeight;
}
if (card.actionable()) {
draw.setColor(binding);
draw.fillOval(856, y + 45, 28, 28);
draw.setColor(palette.accent);
draw.setStroke(new BasicStroke(2));
draw.drawLine(864, y + 59, 876, y + 59);
draw.drawLine(871, y + 54, 876, y + 59);
draw.drawLine(871, y + 64, 876, y + 59);
draw.setStroke(new BasicStroke(1));
}
draw.setColor(ink);
draw.setFont(JOURNAL_TEXT);
int baseline = textY - 8;
for (String line : wrapLore(draw, card.lore(), JOURNAL_TEXT_WIDTH, 5 - title.size()).lines()) {
draw.drawString(line, 543, baseline);
baseline += draw.getFontMetrics().getHeight();
}
}
for (int col = 4; col <= 6; col++) {
Card navigation = cardAt(page, LAST_ROW, col);
if (!navigation.actionable()) continue;
int x = col * 128;
draw.setColor(new Color(37, 78, 64));
draw.fillRoundRect(x + 4, 648, 120, 48, 8, 8);
draw.setColor(brass);
draw.drawRoundRect(x + 4, 648, 119, 47, 8, 8);
draw.setColor(palette.accent);
draw.setFont(CARD_TITLE);
String label = navigation.title();
draw.drawString(label, x + (128 - draw.getFontMetrics().stringWidth(label)) / 2, col == 5 ? 669 : 678);
}
String label = cardAt(page, LAST_ROW, 4).lore().getFirst();
draw.setColor(palette.accent);
draw.setFont(JOURNAL_TEXT.deriveFont(13f));
draw.drawString(label, 704 - draw.getFontMetrics().stringWidth(label) / 2,
cardAt(page, LAST_ROW, 5).actionable() ? 687 : 678);
}
private static BufferedImage focusedJournalRow(BufferedImage normal, int column) {
var image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB);
var draw = image.createGraphics();
try {
draw.drawImage(normal, 0, 0, null);
draw.setColor(new Color(249, 218, 155));
draw.fillRect(0, 4, 128, 3);
draw.fillRect(0, 121, 128, 3);
if (column == 4) draw.fillRect(0, 4, 3, 120);
if (column == 6) draw.fillRect(125, 4, 3, 120);
} finally {
draw.dispose();
}
return image;
}
private record Palette(Color background, Color tile, Color accent) {}
private static Palette palette(Scene scene) {
@ -528,7 +669,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
case CODEX, ITEM_ARCHIVE -> new Palette(new Color(40, 33, 24), new Color(90, 63, 37), new Color(246, 221, 158));
case GUILD -> new Palette(new Color(14, 28, 47), new Color(28, 58, 83), new Color(188, 224, 249));
case SPICE -> new Palette(new Color(54, 25, 16), new Color(105, 54, 33), new Color(255, 214, 133));
case JOURNAL -> new Palette(new Color(30, 40, 31), new Color(61, 80, 51), new Color(235, 212, 154));
case JOURNAL -> new Palette(new Color(18, 33, 30), new Color(239, 221, 177), new Color(255, 226, 159));
case HOUSE -> new Palette(new Color(34, 26, 39), new Color(72, 52, 79), new Color(244, 211, 152));
case AUTO -> scene.roleplay == null
? new Palette(new Color(25, 40, 46), new Color(52, 93, 107), new Color(237, 199, 105))
@ -539,6 +680,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
private static boolean fitsStyled(Document document) {
var graphics = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics();
try {
if (document.style() == Style.JOURNAL) return fitsJournal(graphics, document);
setHeadingFont(graphics, document.style(), styledTitle(document));
if (!wrap(graphics, styledTitle(document), 500, 1).complete) return false;
if (document.style() == Style.EXCHANGE_CHECKOUT) {
@ -603,7 +745,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, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> true;
case CODEX, ITEM_ARCHIVE, GUILD, SPICE, ORGANISATION, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> true;
default -> false;
};
}
@ -742,7 +884,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
}
}
case SPICE -> drawSceneArt(draw, "npc_world_arrakis", 650, 422, 108, 162);
case JOURNAL, CODEX -> {
case CODEX -> {
drawResource(draw, "/mcgui/dunerealms-season-logo-v2.png", 650, 449, 108, 96);
draw.setColor(palette.accent);
draw.drawLine(650, 446, 758, 446);

View file

@ -183,7 +183,7 @@ final class OrganisationMenus implements Listener {
});
}
private void warStatus(Player p,Runnable back){
var screen=panel(p,"War report",false);screen.nativeStyle=DecisionsViewTransport.Style.JOURNAL;screen.nativeSetting="development.fullscreen-organisation-viewers";JsonObject result;
var screen=panel(p,"War report",false);screen.nativeStyle=DecisionsViewTransport.Style.ORGANISATION;screen.nativeSetting="development.fullscreen-organisation-viewers";JsonObject result;
try{result=bridge.warReport(p.getUniqueId());}catch(Exception unavailable){p.sendMessage("War reports are temporarily unavailable.");return;}
var campaigns=result.getAsJsonArray("campaigns");
if(campaigns==null||campaigns.isEmpty())put(screen,22,"No active deployment","No current roster lease.\nArrange wars through your Clan or POL control panel.",Material.MAP,()->warStatus(p,back));