Windows build
This commit is contained in:
@@ -15,16 +15,18 @@ const BUTTON_HEIGHT = 48;
|
||||
const TEXT_PADDING = 24;
|
||||
|
||||
// the credits in the desktop app, drawn in the window with the markdown as it's written, since there's no browser to
|
||||
// show it as a page
|
||||
// show it as a page. after them, the credits of the libraries the app comes with (see desktop/libraries.ts)
|
||||
export class TextCreditsScreen extends GuiScreen {
|
||||
#list = new ListBox(0, 0, () => {});
|
||||
#back: Button;
|
||||
#sections: { heading: string; text: string }[];
|
||||
// what the lines were wrapped for
|
||||
#wrapped_width = 0;
|
||||
|
||||
constructor(on_back: () => void) {
|
||||
constructor(on_back: () => void, libraries: string | undefined) {
|
||||
super();
|
||||
this.#back = new Button("Back", BUTTON_WIDTH, BUTTON_HEIGHT, on_back);
|
||||
this.#sections = [...credit_sections(), ...(libraries ? [{ heading: "Libraries", text: libraries }] : [])];
|
||||
}
|
||||
|
||||
on_tick(_delta: number): void {
|
||||
@@ -35,7 +37,7 @@ export class TextCreditsScreen extends GuiScreen {
|
||||
list.y = TOP;
|
||||
if (list.width !== this.#wrapped_width) {
|
||||
this.#wrapped_width = list.width;
|
||||
list.rows = credit_lines(list.width - TEXT_PADDING).map((text) => ({ text }));
|
||||
list.rows = credit_lines(this.#sections, list.width - TEXT_PADDING).map((text) => ({ text }));
|
||||
}
|
||||
this.#back.x = (canvas.width - BUTTON_WIDTH) / 2;
|
||||
this.#back.y = list.y + list.height + MARGIN;
|
||||
@@ -55,9 +57,9 @@ export class TextCreditsScreen extends GuiScreen {
|
||||
}
|
||||
|
||||
// every section's heading and text, wrapped at spaces to width pixels
|
||||
function credit_lines(width: number): string[] {
|
||||
function credit_lines(sections: { heading: string; text: string }[], width: number): string[] {
|
||||
const lines: string[] = [];
|
||||
for (const { heading, text } of credit_sections()) {
|
||||
for (const { heading, text } of sections) {
|
||||
lines.push(heading, "");
|
||||
for (const line of text.split("\n")) {
|
||||
let current = "";
|
||||
|
||||
Reference in New Issue
Block a user