From 38a1356e27c6c22077ba25fca2894de17745e84f Mon Sep 17 00:00:00 2001 From: DevFlamur Date: Sat, 3 Dec 2022 01:05:28 +0100 Subject: [PATCH 1/2] Started adding languages and flipped top bar image --- data/de/page_data.json | 225 ++++++++++++++++++++++++++++++++ data/{ => en}/page_data.json | 64 +++++++++ data/it/page_data.json | 225 ++++++++++++++++++++++++++++++++ img/{bar.png => bottom_bar.png} | Bin img/top_bar.png | Bin 0 -> 539 bytes js/page.js | 11 +- js/page_types/choice.js | 6 +- js/page_types/info.js | 6 +- js/sketch.js | 3 +- 9 files changed, 530 insertions(+), 10 deletions(-) create mode 100644 data/de/page_data.json rename data/{ => en}/page_data.json (72%) create mode 100644 data/it/page_data.json rename img/{bar.png => bottom_bar.png} (100%) create mode 100644 img/top_bar.png diff --git a/data/de/page_data.json b/data/de/page_data.json new file mode 100644 index 0000000..13cfd6c --- /dev/null +++ b/data/de/page_data.json @@ -0,0 +1,225 @@ +{ + "start": "main_menu", + "end": "", + "default": { + "name": "default", + "type": "no-type", + "showInput": true, + "data": { + "title": "Startseite", + "action": { + "type": "goToStart" + }, + "content": { + "textIndent": 0, + "font": { + "name": "CodeGon Mono", + "file": "fonts/codegon-mono.ttf", + "size": 7 + } + } + } + }, + "pages": [ + { + "name": "main_menu", + "type": "choice", + "showInput": true, + "data": { + "title": "The Oregon Trail", + "choices": [ + { + "text": "Befahre die Spur", + "action": { + "type": "changePage", + "newPageName": "occupation" + } + }, + { + "text": "Mehr uber die Spur", + "action": { + "type": "changePage", + "newPageName": "about_game" + } + }, + { + "text": ["sehe Oregon Top Ten an"], + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Ton ausschalten", + "action": { + "type": "toggleSetting", + "setting": "sound", + "secondAction": { + "type": "changeText", + "texts": ["Ton ausschalten", "Ton anschalten"], + "current": 0 + } + } + }, + { + "text": "Testseite aufmachen", + "action": { + "type": "changePage", + "newPageName": "test" + } + }, + { + "text": "Sprache aendern", + "action": { + "type": "changePage", + "newPageName": "language" + } + } + ], + "prompt": "Was ist deine Wahl?", + "img": "img/title.png", + "content": { + "textIndent": 5 + } + } + }, + { + "name": "occupation", + "type": "choice", + "showInput": true, + "data": { + "title": ["Viele Arten von Menschen haben das gemacht", "Reise nach Oregon."], + "choices": [ + { + "text": "Sei ein Banker aus Boston", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Seien Sie ein Zimmermann aus Ohio", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Sei ein Bauer aus Illinois", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": ["Finden Sie die Unterschiede heraus", "zwischen diesen Entscheidungen"], + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Kehren Sie zurück", + "action": { + "type": "changePage", + "newPageName": "main_menu" + } + } + ], + "prompt": "Was ist deine Wahl?", + "img": "", + "content": { + "textIndent": 2 + } + } + }, + { + "name": "about_game", + "type": "info", + "showInput": false, + "data": { + "title": "Der Oregon-Trail", + "prompt": "Drücke die LEERTASTE um fortzufahren", + "text": [ + "Versuchen Sie, eine Reise", + "mit einem Planwagen über 2000", + "Meilen von Ebenen, Flüssen und", + "Bergen zu unternehmen. Versuchen!", + "plains, will you slosh your", + "Werden Sie Ihre Ochsen in der Ebene", + "durch schlammige und wassergefüllte Furchen", + "schwappen oder durch sechs Zoll", + "tiefen Staub stapfen?" + ], + "action": { + "type": "changePage", + "newPageName": "main_menu" + }, + "img": "img/title.png", + "content": { + "textIndent": 2 + } + } + }, + { + "name": "test" + }, + { + "name" : "language", + "type": "choice", + "showInput": true, + "data": { + "title": ["Wählen Sie Ihre Anzeigesprache"], + "choices": [ + { + "text": "Englisch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Deutsch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Italienisch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Tschechisch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Neue Sprache hinzufuegen", + "action": { + "type": "changePage", + "newPageName": "test" + } + }, + { + "text": "beenden", + "action": { + "type": "changePage", + "newPageName": "main_menu" + } + } + ], + "prompt": "Was ist deine Wahl?", + "img": "", + "content": { + "textIndent": 2 + } + } + } + ] +} diff --git a/data/page_data.json b/data/en/page_data.json similarity index 72% rename from data/page_data.json rename to data/en/page_data.json index 84d87a1..ec54644 100644 --- a/data/page_data.json +++ b/data/en/page_data.json @@ -67,6 +67,13 @@ "type": "changePage", "newPageName": "test" } + }, + { + "text": "Change Language", + "action": { + "type": "changePage", + "newPageName": "language" + } } ], "prompt": "What is your choice?", @@ -156,6 +163,63 @@ }, { "name": "test" + }, + { + "name" : "language", + "type": "choice", + "showInput": true, + "data": { + "title": ["Choose your display language"], + "choices": [ + { + "text": "English", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Deutsch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Italiano", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Czech", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Add new Language", + "action": { + "type": "changePage", + "newPageName": "test" + } + }, + { + "text": "Cancel", + "action": { + "type": "changePage", + "newPageName": "main_menu" + } + } + ], + "prompt": "What is your choice?", + "img": "", + "content": { + "textIndent": 2 + } + } } ] } diff --git a/data/it/page_data.json b/data/it/page_data.json new file mode 100644 index 0000000..93bc6bd --- /dev/null +++ b/data/it/page_data.json @@ -0,0 +1,225 @@ +{ + "start": "main_menu", + "end": "", + "default": { + "name": "default", + "type": "no-type", + "showInput": true, + "data": { + "title": "Default Page", + "action": { + "type": "goToStart" + }, + "content": { + "textIndent": 0, + "font": { + "name": "CodeGon Mono", + "file": "fonts/codegon-mono.ttf", + "size": 7 + } + } + } + }, + "pages": [ + { + "name": "main_menu", + "type": "choice", + "showInput": true, + "data": { + "title": "The Oregon Trail", + "choices": [ + { + "text": "(italian) Travel the trail", + "action": { + "type": "changePage", + "newPageName": "occupation" + } + }, + { + "text": "Learn about the trail", + "action": { + "type": "changePage", + "newPageName": "about_game" + } + }, + { + "text": "See the Oregon Top Ten", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Turn sound off", + "action": { + "type": "toggleSetting", + "setting": "sound", + "secondAction": { + "type": "changeText", + "texts": ["Turn sound off", "Turn sound on"], + "current": 0 + } + } + }, + { + "text": "Open the test page", + "action": { + "type": "changePage", + "newPageName": "test" + } + }, + { + "text": "Change Language", + "action": { + "type": "changePage", + "newPageName": "language" + } + } + ], + "prompt": "What is your choice?", + "img": "img/title.png", + "content": { + "textIndent": 5 + } + } + }, + { + "name": "occupation", + "type": "choice", + "showInput": true, + "data": { + "title": ["Many kinds of people made the", "trip to Oregon."], + "choices": [ + { + "text": "Be a banker from Boston", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Be a carpenter from Ohio", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Be a farmer from Illinois", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": ["Find out the differences", "between theese choices"], + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Return back", + "action": { + "type": "changePage", + "newPageName": "main_menu" + } + } + ], + "prompt": "What is your choice?", + "img": "", + "content": { + "textIndent": 2 + } + } + }, + { + "name": "about_game", + "type": "info", + "showInput": false, + "data": { + "title": "The Oregon Trail", + "prompt": "Press SPACE BAR to continue", + "text": [ + "Try taking a journey by", + "covered wagon across 2000", + "miles of plains, rivers, and", + "mountains. Try! On the", + "plains, will you slosh your", + "oxen through mud and", + "water-filled ruts or will you", + "plod through dust six inches", + "deep?" + ], + "action": { + "type": "changePage", + "newPageName": "main_menu" + }, + "img": "img/title.png", + "content": { + "textIndent": 2 + } + } + }, + { + "name": "test" + }, + { + "name" : "language", + "type": "choice", + "showInput": true, + "data": { + "title": ["Choose your display language"], + "choices": [ + { + "text": "English", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Deutsch", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Italiano", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Czech", + "action": { + "type": "changePage", + "newPageName": "" + } + }, + { + "text": "Add new Language", + "action": { + "type": "changePage", + "newPageName": "test" + } + }, + { + "text": "Cancel", + "action": { + "type": "changePage", + "newPageName": "main_menu" + } + } + ], + "prompt": "What is your choice?", + "img": "", + "content": { + "textIndent": 2 + } + } + } + ] +} diff --git a/img/bar.png b/img/bottom_bar.png similarity index 100% rename from img/bar.png rename to img/bottom_bar.png diff --git a/img/top_bar.png b/img/top_bar.png new file mode 100644 index 0000000000000000000000000000000000000000..4cfc03ac3e12ca9a3f3baffc936aee7cd7216bef GIT binary patch literal 539 zcmV+$0_6RPP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10jNnt zK~#90?cGaG!!Q6v(G)RdjjW9|vH%!Vm7r4Urg8jvIcJE}5LBDQw%4Jb>fQ@d2rDUzZlnTw>;{)6%IsiZ{MF%KaD=d49Ov%>c zD?GqGMF#+grRZ=9wF<+%)Phi};MCruqwriA&+t4&2LOnr=n$#(b5~|xVYezcB`Jj` zWjrW6Bv5n!fLMwS5z<$ny$iwKLQ?y=IIYfStMu`g`ty-Z(E$KrDLPEa3iDW_6q8nk zhi%M1W}@f-0I}YCp8(L`CySMQ0nEA&evlLQA2LOmQP0_JJfcjotk*yVzqs?}{kZhJcaEcB95Np`y=!~-B z8ubqK>^#R~F14SGOkd{T*jzvVQ*;1;Si|hm>2(J>${i;F)KI#vwYuJpvWG{}0RUok z+oMzaGhTZD&dr{Ixp=?k;{D3j`uf>=JSjQ=K&)Z^>S`}5kaP3jtjA`4j>UZ8ueAB8 d=l}q*egV_6;MyCPT7&=q002ovPDHLkV1iUG^(_DZ literal 0 HcmV?d00001 diff --git a/js/page.js b/js/page.js index fcbef81..4eb3068 100644 --- a/js/page.js +++ b/js/page.js @@ -15,7 +15,8 @@ class Page { const descent = textDescent(); this.textHeight = ascent + descent; - this.bar = loadImage('img/bar.png'); + this.topBar = loadImage('img/top_bar.png'); + this.bottomBar = loadImage('img/bottom_bar.png'); } // --- LOADING --- @@ -153,8 +154,12 @@ class Page { this.renderPosition.y += h; } - renderBar() { - this.renderImg(this.bar); + renderBottomBar() { + this.renderImg(this.bottomBar); + } + + renderTopBar() { + this.renderImg(this.topBar); } renderStart() { diff --git a/js/page_types/choice.js b/js/page_types/choice.js index 912d709..52c2528 100644 --- a/js/page_types/choice.js +++ b/js/page_types/choice.js @@ -26,10 +26,10 @@ class Choice extends Page { if (this.img) { this.renderImg(this.img); - this.renderBar(); + this.renderTopBar(); this.newLine(); } else { - this.renderBar(); + this.renderTopBar(); this.newLine(); this.renderText(0, this.title); this.newLine(); @@ -43,7 +43,7 @@ class Choice extends Page { this.updateCursor(); this.newLine(); - this.renderBar(); + this.renderBottomBar(); } changeText(changeData) { diff --git a/js/page_types/info.js b/js/page_types/info.js index 3c6642d..21f42fa 100644 --- a/js/page_types/info.js +++ b/js/page_types/info.js @@ -19,10 +19,10 @@ class Info extends Page { if (this.img) { this.renderImg(this.img); - this.renderBar(); + this.renderTopBar(); this.newLine(); } else { - this.renderBar(); + this.renderTopBar(); this.newLine(); this.renderText(0, this.title); this.newLine(); @@ -31,7 +31,7 @@ class Info extends Page { this.newLine(); this.renderText(0, this.text); this.newLine(); - this.renderBar(); + this.renderBottomBar(); this.newLine(); this.renderText(3, this.prompt); diff --git a/js/sketch.js b/js/sketch.js index 4faf7be..bbb4b06 100644 --- a/js/sketch.js +++ b/js/sketch.js @@ -4,13 +4,14 @@ p5.disableFriendlyErrors = true; const SETTINGS = { sound: true, scale: 2, + language: 'en' }; let data; let stateManager; function preload() { - data = loadJSON('data/page_data.json'); + data = loadJSON('data/' + SETTINGS.language + '/page_data.json'); } let pageManager; From 887979172b82df2d97e76d0c1830127866e0cc32 Mon Sep 17 00:00:00 2001 From: rampage64 Date: Sat, 3 Dec 2022 01:14:20 +0100 Subject: [PATCH 2/2] changed text --- data/de/page_data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/de/page_data.json b/data/de/page_data.json index 13cfd6c..6c6d36e 100644 --- a/data/de/page_data.json +++ b/data/de/page_data.json @@ -207,7 +207,7 @@ } }, { - "text": "beenden", + "text": "abbrechen", "action": { "type": "changePage", "newPageName": "main_menu"