Windows build

This commit is contained in:
2026-11-22 19:49:50 -03:00
parent ed6f5fe0df
commit cbd662dc2a
12 changed files with 625 additions and 16 deletions
+7 -5
View File
@@ -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 = "";
+3 -3
View File
@@ -69,7 +69,7 @@ function ask<T extends string | boolean>(question: (id: number) => ClientMessage
return new Promise((resolve) => asking.set(id, resolve as (answer: string | boolean) => void));
}
function native_platform(page: URL, stored: Record<string, string>): Platform {
function native_platform(page: URL, stored: Record<string, string>, credits: string | undefined): Platform {
const storage = new Map(Object.entries(stored));
return {
page,
@@ -104,7 +104,7 @@ function native_platform(page: URL, stored: Record<string, string>): Platform {
const title = `Join ${address.base.host}?`;
return ask((id) => ({ type: "ask", id, title, text, yes: "Join", no: "Cancel" }));
},
credits_screen: (on_back) => new TextCreditsScreen(on_back),
credits_screen: (on_back) => new TextCreditsScreen(on_back, credits),
read_clipboard: () => ask((id) => ({ type: "read_clipboard", id })),
write_clipboard(text) {
post({ type: "write_clipboard", text });
@@ -133,7 +133,7 @@ function native_platform(page: URL, stored: Record<string, string>): Platform {
}
async function start(message: Extract<WindowMessage, { type: "start" }>) {
set_platform(native_platform(new URL(message.page), message.storage));
set_platform(native_platform(new URL(message.page), message.storage, message.credits));
const { surface: handles, width, height } = message;
const surface = new Deno.UnsafeWindowSurface({
system: handles.system,
+3
View File
@@ -22,6 +22,9 @@ export type WindowMessage =
storage: Record<string, string>;
// whether the window can play sound, see desktop/openal.ts
audio: boolean;
// the credits of the libraries the app comes with, see desktop/libraries.ts. an app older than its client
// (updated from the site) doesn't send them
credits?: string;
}
// in pixels, what's drawn to is this big now
| { type: "resize"; width: number; height: number }