feat: screen manager

This commit is contained in:
2025-12-13 18:28:53 +01:00
parent 33f918995b
commit 92f5c83e36
5 changed files with 118 additions and 21 deletions

View File

@@ -0,0 +1,25 @@
import type { Screen, ScreenContext } from "../screen";
import { HomeScreen } from "./home-screen";
export class ContactScreen implements Screen {
renderTop(ctx: CanvasRenderingContext2D) {
ctx.fillStyle = "#ffffff";
ctx.font = "10px NDS10";
ctx.textBaseline = "top";
ctx.fillText("CONTACT", 1, 1);
}
renderBottom(ctx: CanvasRenderingContext2D) {
ctx.fillStyle = "#ffffff";
ctx.font = "10px NDS10";
ctx.textAlign = "left";
ctx.textBaseline = "bottom";
ctx.fillText("< Back", 1, 191);
}
handleTouch(x: number, y: number, context: ScreenContext): void {
if (x >= 0 && x <= 51 && y >= 178 && y <= 192) {
context.navigate(new HomeScreen());
}
}
}

View File

@@ -0,0 +1,25 @@
import type { Screen, ScreenContext } from "../screen";
import { ContactScreen } from "./contact-screen";
export class HomeScreen implements Screen {
renderTop(ctx: CanvasRenderingContext2D) {
ctx.fillStyle = "#ffffff";
ctx.font = "10px NDS10";
ctx.textBaseline = "top";
ctx.fillText("HOME", 1, 1);
}
renderBottom(ctx: CanvasRenderingContext2D) {
ctx.fillStyle = "#ffffff";
ctx.font = "10px NDS10";
ctx.textAlign = "right";
ctx.textBaseline = "bottom";
ctx.fillText("Contact >", 255, 191);
}
handleTouch(x: number, y: number, context: ScreenContext): void {
if (x >= 205 && x <= 256 && y >= 178 && y <= 192) {
context.navigate(new ContactScreen());
}
}
}