diff --git a/data/de/page_data.json b/data/de/page_data.json new file mode 100644 index 0000000..6c6d36e --- /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": "abbrechen", + "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 0000000..4cfc03a Binary files /dev/null and b/img/top_bar.png differ 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;