Move away from browser as a main plataform
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "../renderer/mod.ts";
|
||||
import { GuiScreen } from "../gui/gui_screen.ts";
|
||||
import { credit_sections } from "../gui/credits_screen.ts";
|
||||
import { Button, ListBox, TEXT_SCALE } from "../gui/widgets.ts";
|
||||
import { Button, ListBox, TEXT_SCALE, wrap_text } from "../gui/widgets.ts";
|
||||
|
||||
const MAX_WIDTH = 1200;
|
||||
const MARGIN = 32;
|
||||
@@ -58,23 +58,5 @@ export class TextCreditsScreen extends GuiScreen {
|
||||
|
||||
// every section's heading and text, wrapped at spaces to width pixels
|
||||
function credit_lines(sections: { heading: string; text: string }[], width: number): string[] {
|
||||
const lines: string[] = [];
|
||||
for (const { heading, text } of sections) {
|
||||
lines.push(heading, "");
|
||||
for (const line of text.split("\n")) {
|
||||
let current = "";
|
||||
for (const word of line.split(" ")) {
|
||||
const next = current ? `${current} ${word}` : word;
|
||||
if (current && measure_text(next, TEXT_SCALE) > width) {
|
||||
lines.push(current);
|
||||
current = word;
|
||||
} else {
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
lines.push(current);
|
||||
}
|
||||
lines.push("");
|
||||
}
|
||||
return lines;
|
||||
return sections.flatMap(({ heading, text }) => [heading, "", ...wrap_text(text, width), ""]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user