aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test-client/locale.ts19
-rw-r--r--test-client/main.ts4
-rw-r--r--test-client/tiles.ts6
3 files changed, 25 insertions, 4 deletions
diff --git a/test-client/locale.ts b/test-client/locale.ts
index 61d083b4..59f77eac 100644
--- a/test-client/locale.ts
+++ b/test-client/locale.ts
@@ -1,6 +1,14 @@
+const LANGUAGES = [
+ "ar", "de", "en", "es", "eu",
+ "fi", "fr", "he", "ja", "nl",
+ "pl", "pt", "to", "tr",
+ "zh_Hans", "zh_Hant",
+]
+
let TR: { [key: string]: string } = {}
-export async function init_locale(lang: string) {
+export async function init_locale(lang?: string) {
+ if (!lang) return await init_locale(select_language())
const res = await fetch(`/locale/${encodeURIComponent(lang)}.json`, { headers: { "Accept": "application/json" } })
if (!res.ok) throw new Error("language pack download failed");
TR = await res.json()
@@ -12,3 +20,12 @@ export function tr(key: string, ...args: string[]): string {
s = s.replace(/%(s|i)/ig, () => args.shift() ?? "[not provided]")
return s
}
+
+function select_language(): string {
+ const plang = (new URLSearchParams(globalThis.location.hash.substring(1))).get("lang")
+ if (plang) return plang
+ const navlang = navigator.language.split("-")[0] ?? "en"
+ if (LANGUAGES.includes(navlang)) return navlang
+ console.warn("fallback language selected");
+ return "en"
+}
diff --git a/test-client/main.ts b/test-client/main.ts
index 9ec4ac5e..4313ab96 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -37,7 +37,7 @@ export let ctx: CanvasRenderingContext2D;
export let canvas: HTMLCanvasElement;
let ws: WebSocket;
document.addEventListener("DOMContentLoaded", async () => {
- await init_locale(navigator.language.split("-")[0] ?? "en")
+ await init_locale()
const ws_uri = window.location.protocol.endsWith("s:")
? `wss://${window.location.host}/`
: `ws://${window.location.hostname}:27032/`
@@ -283,7 +283,7 @@ function keyboard(ev: KeyboardEvent, down: boolean) {
if (down && ev.code == "Numpad2") send({ player: my_id, type: "communicate", message: { text: "/start senior" } })
if (down && ev.code == "Numpad3") send({ player: my_id, type: "communicate", message: { text: "/start sophomore" } })
if (down && ev.code == "Numpad4") send({ player: my_id, type: "communicate", message: { text: "/start debug" } })
- if (down && ev.code == "Numpad5") send({ player: my_id, type: "communicate", message: { text: "/start bus" } })
+ if (down && ev.code == "Numpad5") send({ player: my_id, type: "communicate", message: { text: "/start 5star" } })
if (down && ev.code == "Numpad8") send({ player: my_id, type: "communicate", message: { text: "/start-tutorial plate:seared-patty,sliced-bun" } })
if (down && ev.code == "Numpad9") send({ player: my_id, type: "communicate", message: { text: "/start-tutorial plate:bun" } })
if (down && ev.code == "Numpad0") send({ player: my_id, type: "communicate", message: { text: "/end" } })
diff --git a/test-client/tiles.ts b/test-client/tiles.ts
index 17d150ea..86203cb7 100644
--- a/test-client/tiles.ts
+++ b/test-client/tiles.ts
@@ -113,7 +113,7 @@ const iref = (name: ItemName): Component => c => draw_item_sprite(c, name)
const tref = (name: TileName): Component => c => TILES[name].forEach(f => f(c))
export type ItemName = string
-export type TileName = "sink" | "conveyor" | "book" | "tomato-crate" | "steak-crate" | "flour-crate" | "leek-crate" | "rice-crate" | "fish-crate" | "coconut-crate" | "strawberry-crate" | "oven" | "cuttingboard" | "stove" | "freezer" | "trash" | "grass" | "tree" | "wall" | "chair" | "floor" | "door" | "counter" | "wall-window" | "table" | "counter-window" | "path" | "lamp" | "street"
+export type TileName = "sink" | "conveyor" | "book" | "lettuce-crate" | "cheese-crate" | "tomato-crate" | "steak-crate" | "flour-crate" | "leek-crate" | "rice-crate" | "fish-crate" | "coconut-crate" | "strawberry-crate" | "oven" | "cuttingboard" | "stove" | "freezer" | "trash" | "grass" | "tree" | "wall" | "chair" | "floor" | "door" | "counter" | "wall-window" | "table" | "counter-window" | "path" | "lamp" | "street"
const ITEMS: { [key in ItemName]: (c: string[]) => Component } = {
"bun": () => circle(0.3, "#853e20"),
@@ -145,6 +145,8 @@ const ITEMS: { [key in ItemName]: (c: string[]) => Component } = {
"sliced-tomato": () => circle(0.3, "#d16363", "#d63838", 0.08),
"lettuce": () => circle(0.3, "#64a30b"),
"sliced-lettuce": () => circle(0.3, "#a0da4f", "#64a30b", 0.08),
+ "cheese": () => circle(0.3, "#b3b615"),
+ "sliced-cheese": () => rect(0.25, "#dcdf29", "#b3b615", 0.05),
"dirty-plate": () => circle(0.4, "#947a6f", "#d3a187", 0.02),
"mochi-dough": () => circle(0.3, "rgb(172, 162, 151)"),
"rice-flour": () => iref("rice"),
@@ -186,6 +188,8 @@ const TILES: { [key in TileName]: Component[] } = {
"flour-crate": crate("flour"),
"steak-crate": crate("steak"),
"tomato-crate": crate("tomato"),
+ "lettuce-crate": crate("lettuce"),
+ "cheese-crate": crate("cheese"),
"leek-crate": crate("leek"),
"rice-crate": crate("rice"),
"fish-crate": crate("fish"),