refactor: relocate constants in screen stores

This commit is contained in:
2026-01-31 00:52:56 +01:00
parent 742e6363a4
commit 630b399088
13 changed files with 74 additions and 90 deletions

View File

@@ -1,30 +0,0 @@
export const ACHIEVEMENTS_LINE_HEIGHT = 14;
export const ACHIEVEMENTS_HEADER_Y = 20;
export const ACHIEVEMENTS_LIST_START_Y = ACHIEVEMENTS_HEADER_Y + 55;
export const ACHIEVEMENTS_BOTTOM_START_Y = 10;
export const ACHIEVEMENTS_TOP_SCREEN_COUNT = Math.floor(
(LOGICAL_HEIGHT - ACHIEVEMENTS_LIST_START_Y) / ACHIEVEMENTS_LINE_HEIGHT,
);
export const CHECKBOX_SIZE = 7;
export const CHECKBOX_TEXT_GAP = 5;
export const ACHIEVEMENTS_X = 55;
export const drawCheckbox = (
ctx: CanvasRenderingContext2D,
x: number,
y: number,
checked: boolean,
) => {
ctx.fillRect(x, y, CHECKBOX_SIZE, 1);
ctx.fillRect(x, y + CHECKBOX_SIZE - 1, CHECKBOX_SIZE, 1);
ctx.fillRect(x, y + 1, 1, CHECKBOX_SIZE - 2);
ctx.fillRect(x + CHECKBOX_SIZE - 1, y + 1, 1, CHECKBOX_SIZE - 2);
if (checked) {
for (let i = 2; i < CHECKBOX_SIZE - 2; i++) {
ctx.fillRect(x + i, y + i, 1, 1);
ctx.fillRect(x + CHECKBOX_SIZE - 1 - i, y + i, 1, 1);
}
}
};

View File

@@ -1,6 +0,0 @@
export const APP_COLORS = [
["#61829a", "#ba4900", "#fb0018", "#fb8afb"],
["#fb9200", "#f3e300", "#aafb00", "#00fb00"],
["#00a238", "#49db8a", "#30baf3", "#0059f3"],
["#000092", "#8a00d3", "#d300eb", "#fb0092"],
];

View File

@@ -1,2 +0,0 @@
export const sleep = (ms: number) =>
new Promise<void>((resolve) => setTimeout(resolve, ms));

View File

@@ -56,6 +56,28 @@ export const fillTextHCenteredMultiline = (
}
};
export const CHECKBOX_SIZE = 7;
export const CHECKBOX_TEXT_GAP = 5;
export const drawCheckbox = (
ctx: CanvasRenderingContext2D,
x: number,
y: number,
checked: boolean,
) => {
ctx.fillRect(x, y, CHECKBOX_SIZE, 1);
ctx.fillRect(x, y + CHECKBOX_SIZE - 1, CHECKBOX_SIZE, 1);
ctx.fillRect(x, y + 1, 1, CHECKBOX_SIZE - 2);
ctx.fillRect(x + CHECKBOX_SIZE - 1, y + 1, 1, CHECKBOX_SIZE - 2);
if (checked) {
for (let i = 2; i < CHECKBOX_SIZE - 2; i++) {
ctx.fillRect(x + i, y + i, 1, 1);
ctx.fillRect(x + CHECKBOX_SIZE - 1 - i, y + i, 1, 1);
}
}
};
export const fillTextWordWrapped = (
ctx: CanvasRenderingContext2D,
text: string,

View File

@@ -1,7 +0,0 @@
export const LOGICAL_WIDTH = 256;
export const LOGICAL_HEIGHT = 192;
export const SCREEN_SCALE = 2;
export const SCREEN_WIDTH = LOGICAL_WIDTH * SCREEN_SCALE;
export const SCREEN_HEIGHT = LOGICAL_HEIGHT * SCREEN_SCALE;

View File

@@ -1,22 +0,0 @@
export const SETTINGS_MENUS = [
"options",
"clock",
"user",
"touchScreen",
] as const;
export const SETTINGS_SUB_MENUS = [
"optionsLanguage",
"options2048",
"optionsStartUp",
"clockAchievements",
"clockTime",
"clockDate",
"userBirthday",
"userUserName",
"userSnake",
"userColor",
] as const;
export type SettingsMenu = (typeof SETTINGS_MENUS)[number];
export type SettingsSubMenu = (typeof SETTINGS_SUB_MENUS)[number];