Skip to content

Commit

Permalink
Initial Multi-Language support.
Browse files Browse the repository at this point in the history
Supports English and German now.
  • Loading branch information
SuperSaiyajinStackZ committed May 17, 2020
1 parent d175235 commit ceb0a11
Show file tree
Hide file tree
Showing 19 changed files with 496 additions and 45 deletions.
Binary file modified app/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions include/screens/langSelection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of 3DVier
* Copyright (C) 2020 SuperSaiyajinStackZ
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/

#ifndef _3DVIER_LANGSELECTION_HPP
#define _3DVIER_LANGSELECTION_HPP

#include "common.hpp"
#include "structs.hpp"

#include <vector>

class LangSelection : public Screen
{
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
LangSelection();
private:
int selectedLang = 0;
std::vector<Structs::ButtonPos> langBlocks = {
{37, 32, 20, 20},
{37, 72, 20, 20}
};
};

#endif
50 changes: 50 additions & 0 deletions include/screens/uiSettings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of 3DVier
* Copyright (C) 2020 SuperSaiyajinStackZ
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/

#ifndef _3DVIER_UISETTINGS_HPP
#define _3DVIER_UISETTINGS_HPP

#include "common.hpp"
#include "structs.hpp"

#include <vector>

class UISettings : public Screen
{
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
int Selection = 0;

std::vector<Structs::ButtonPos> mainButtons = {
{90, 40, 140, 40}, // Colors.
{90, 100, 140, 40}, // Language.
{90, 160, 140, 40}, // ?.
};
};

#endif
1 change: 1 addition & 0 deletions include/utils/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "config.hpp"
#include "gfx.hpp"
#include "gui.hpp"
#include "lang.hpp"
#include "msg.hpp"
#include "screenCommon.hpp"

Expand Down
39 changes: 39 additions & 0 deletions include/utils/lang.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of 3DVier
* Copyright (C) 2020 SuperSaiyajinStackZ
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/

#ifndef _3DVIER_LANG_HPP
#define _3DVIER_LANG_HPP

#include "json.hpp"

#include <string>

namespace Lang {
std::string get(const std::string &key);
void load();
}

#endif
40 changes: 40 additions & 0 deletions romfs/lang/de/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"A_CONTINUE": "Drücke \uE000 zum fortfahren.",
"BAR_COLOR": "Balkenfarbe",
"BG_COLOR": "Hintergrundfarbe",
"BUTTON_COLOR": "Schaltflächenfarbe",
"CHAR_SELECT": "Navigiere mit dem Steuerkreuz. Drücke \uE000 zum auswählen.",
"COLOR_SETTINGS": "Farbeinstellungen",
"CURRENT_VERSION": "Aktuelle Version: ",
"CREDITS": "Credits",
"DEVELOPED_BY": "Entwickelt von: SuperSaiyajinStackZ.",
"ENTER_BLUE_RGB": "Gebe die Blaue RGB an.",
"ENTER_GREEN_RGB": "Gebe die Grüne RGB an.",
"ENTER_RED_RGB": "Gebe die Rote RGB an.",
"ENTER_WIN_AMOUNT": "Gebe die Anzahl an Siegen ein.",
"GAME_ALL_USED": "Alle Slots sind benutzt... Starte das Spiel neu...",
"GAME_EXIT": "Möchtest du dieses Spiel verlassen?",
"GAME_INSTR": "Drücke \uE000 um eine Position auszuwählen.\nBenutze das Steuerkreuz um zu navigieren.\nDrücke START um das Spiel zu verlassen.",
"GAME_RESULT": "%s hat das Spiel gewonnen!\nErgebnis: %s: %i | %s: %i.",
"GAME_WIN_ROUND": "%s hat diese Runde gewonnen!\nBenötigte Siege zum gewinnen: %i.",
"LANGUAGE": "Sprache",
"MAINMENU": "Hauptmenü",
"NEW_GAME": "Neues Spiel",
"NO": "Nein",
"NOT_IMPLEMENTED_YET": "Das ist noch nicht implementiert!",
"OK": "OK",
"P1CHIP_COLOR": "Spieler 1 Chipfarbe",
"P2CHIP_COLOR": "Spieler 2 Chipfarbe",
"PLAYER1_CHAR": "Spieler 1: Wähle deinen Avatar aus!",
"PLAYER2_CHAR": "Spieler 2: Wähle deinen Avatar aus!",
"PLAYER1_NAME": "Spieler 1: Gebe deinen Namen ein!",
"PLAYER2_NAME": "Spieler 2: Gebe deinen Namen ein!",
"RASTER_COLOR": "Gitterfarbe",
"SELECT_LANG": "Wähle die aktuelle Sprache.",
"SELECTOR_COLOR": "Selektorfarbe",
"TEXT_COLOR": "Textfarbe",
"UI_SETTINGS": "UI Einstellungen",
"WINS": "Siege:",
"WINS_TO_WIN": "Benötigte Siege zum Gewinn:",
"YES": "Ja"
}
40 changes: 40 additions & 0 deletions romfs/lang/en/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"A_CONTINUE": "Press \uE000 to continue.",
"BAR_COLOR": "Bar Color",
"BG_COLOR": "Background Color",
"BUTTON_COLOR": "Button Color",
"CHAR_SELECT": "Navigate with the D-Pad. Press \uE000 to select.",
"COLOR_SETTINGS": "Color Settings",
"CURRENT_VERSION": "Current Version: ",
"CREDITS": "Credits",
"DEVELOPED_BY": "Developed by: SuperSaiyajinStackZ.",
"ENTER_BLUE_RGB": "Enter the Blue RGB.",
"ENTER_GREEN_RGB": "Enter the Green RGB.",
"ENTER_RED_RGB": "Enter the Red RGB.",
"ENTER_WIN_AMOUNT": "Enter the amount of wins.",
"GAME_ALL_USED": "All Slots are used. Restarting the game...",
"GAME_EXIT": "Do you like to exit this game?",
"GAME_INSTR": "Press \uE000 to select a position.\nUse the D-Pad to navigate.\nPress START to exit.",
"GAME_RESULT": "%s wins this game!\nResult: %s: %i | %s: %i.",
"GAME_WIN_ROUND": "%s wins this round!\nNeeded wins to win: %i.",
"LANGUAGE": "Language",
"MAINMENU": "MainMenu",
"NEW_GAME": "New Game",
"NO": "No",
"NOT_IMPLEMENTED_YET": "This is not implemented yet!",
"OK": "OK",
"P1CHIP_COLOR": "Player 1 Chip Color",
"P2CHIP_COLOR": "Player 2 Chip Color",
"PLAYER1_CHAR": "Player 1: Select your avatar!",
"PLAYER2_CHAR": "Player 2: Select your avatar aus!",
"PLAYER1_NAME": "Player 1: Enter your name!",
"PLAYER2_NAME": "Player 2: Enter your name!",
"RASTER_COLOR": "Raster Color",
"SELECT_LANG": "Choose the current language.",
"SELECTOR_COLOR": "Selector Color",
"TEXT_COLOR": "Text Color",
"UI_SETTINGS": "UI Settings",
"WINS": "Wins:",
"WINS_TO_WIN": "Needed wins to win:",
"YES": "Yes"
}
13 changes: 7 additions & 6 deletions source/gui/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ bool Msg::promptMsg2(std::string promptMsg)
// Draw Bottom Screen part.
Gui::Draw_Rect(10, 100, 140, 40, config->buttonColor());
Gui::Draw_Rect(170, 100, 140, 40, config->buttonColor());
Gui::DrawStringCentered(-150+70, 105, 0.8f, config->textColor(),"Yes", 140);
Gui::DrawStringCentered(150-70, 105, 0.8f, config->textColor(), "No", 140);
Gui::DrawStringCentered(-150+70, 105, 0.8f, config->textColor(), Lang::get("YES"), 140);
Gui::DrawStringCentered(150-70, 105, 0.8f, config->textColor(), Lang::get("NO"), 140);
GFX::DrawButtonSelector(promptBtn[selection].x, promptBtn[selection].y);
C3D_FrameEnd(0);

Expand Down Expand Up @@ -136,10 +136,10 @@ void Msg::DisplayWaitMsg(std::string waitMsg, ...)
GFX::DrawTop();
Gui::Draw_Rect(0, 80, 400, 80, config->barColor());
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.8f, waitMsg))/2, 0.8f, config->textColor(), waitMsg, 390, 70);
Gui::DrawStringCentered(0, 214, 0.8f, config->textColor(), "Press \uE000 to continue.", 390);
Gui::DrawStringCentered(0, 214, 0.8f, config->textColor(), Lang::get("A_CONTINUE"), 390);
GFX::DrawBottom();
Gui::Draw_Rect(100, 100, 140, 40, config->buttonColor());
Gui::DrawStringCentered(-60+70, 105, 0.8f, config->textColor(), "OK", 140);
Gui::DrawStringCentered(-60+70, 105, 0.8f, config->textColor(), Lang::get("OK"), 140);
C3D_FrameEnd(0);

while(1)
Expand All @@ -160,7 +160,8 @@ void Msg::HelperBox(std::string Msg) {
int textBoxHeight = Gui::GetStringHeight(0.6f, Msg) + 5;

Gui::Draw_Rect(40, 211 - textBoxHeight, 320, textBoxHeight, config->barColor());
Gui::Draw_Rect(44, 215 - textBoxHeight, 312, textBoxHeight - 8, config->bgColor());
Gui::Draw_Rect(40, 211 - textBoxHeight, 320, textBoxHeight, C2D_Color32(0, 0, 0, 190));
Gui::Draw_Rect(44, 215 - textBoxHeight, 312, textBoxHeight - 8, config->barColor());
Gui::DrawStringCentered(0, 215 - textBoxHeight-2, 0.6, config->textColor(), Msg, 305, Gui::GetStringHeight(0.6f, Msg));
Gui::ScreenDraw(Bottom);
Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, 190));
Expand All @@ -180,5 +181,5 @@ void Msg::DisplayMsg(std::string Message) {
}

void Msg::NotImplementedYet(void) {
Msg::DisplayWaitMsg("This is not implemented yet!");
Msg::DisplayWaitMsg(Lang::get("NOT_IMPLEMENTED_YET"));
}
1 change: 1 addition & 0 deletions source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Result Init::Initialize() {
mkdir("sdmc:/3ds", 0777); // For DSP dump
mkdir("sdmc:/3ds/3DVier", 0777); // main Path.
config = std::make_unique<Config>();
Lang::load();
Gui::loadSheet("romfs:/gfx/chars.t3x", characters);
Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites);
osSetSpeedupEnable(true); // Enable speed-up for New 3DS users.
Expand Down
24 changes: 12 additions & 12 deletions source/screens/colorChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ColorChanger::DrawPreview(void) const {

void ColorChanger::Draw(void) const {
GFX::DrawTop();
Gui::DrawStringCentered(0, 0, 0.9f, config->textColor(), "3DVier - UI Settings", 320);
Gui::DrawStringCentered(0, 0, 0.9f, config->textColor(), "3DVier - " + Lang::get("COLOR_SETTINGS"), 320);
DrawPreview();
GFX::DrawBottom();

Expand All @@ -58,42 +58,42 @@ void ColorChanger::Draw(void) const {
Gui::Draw_Rect(buttons[2].x, buttons[2].y, 95, 41, C2D_Color32(0, 0, 255, 255));

if (colorMode == 0) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Selector Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("SELECTOR_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->selectorColor(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->selectorColor(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->selectorColor(), 0).c_str(), 400);
} else if (colorMode == 1) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Button Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("BUTTON_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->buttonColor(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->buttonColor(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->buttonColor(), 0).c_str(), 400);
} else if (colorMode == 2) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Bar Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("BAR_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->barColor(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->barColor(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->barColor(), 0).c_str(), 400);
} else if (colorMode == 3) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "BG Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("BG_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->bgColor(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->bgColor(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->bgColor(), 0).c_str(), 400);
} else if (colorMode == 4) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Text Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("TEXT_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->textColor(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->textColor(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->textColor(), 0).c_str(), 400);
} else if (colorMode == 5) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Player 1 Chip Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("P1CHIP_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p1Chip(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p1Chip(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p1Chip(), 0).c_str(), 400);
} else if (colorMode == 6) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Player 2 Chip Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("P2CHIP_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p2Chip(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p2Chip(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->p2Chip(), 0).c_str(), 400);
} else if (colorMode == 7) {
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, "Raster Color", 320);
Gui::DrawStringCentered(0, 60, 0.7f, WHITE, Lang::get("RASTER_COLOR"), 320);
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(config->raster(), 2).c_str(), 400);
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(config->raster(), 1).c_str(), 400);
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(config->raster(), 0).c_str(), 400);
Expand All @@ -120,7 +120,7 @@ void ColorChanger::Logic(u32 hDown, u32 hHeld, touchPosition touch) {

if (hDown & KEY_TOUCH) {
if (touching(touch, buttons[0])) {
int temp = Keyboard::getUint(255, "Enter the Red RGB.");
int temp = Keyboard::getUint(255, Lang::get("ENTER_RED_RGB"));
if(temp != -1) {
red = temp;
if (colorMode == 0) {
Expand All @@ -142,7 +142,7 @@ void ColorChanger::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
}
}
} else if (touching(touch, buttons[1])) {
int temp = Keyboard::getUint(255, "Enter the Green RGB.");
int temp = Keyboard::getUint(255, Lang::get("ENTER_GREEN_RGB"));
if(temp != -1) {
green = temp;
if (colorMode == 0) {
Expand All @@ -164,7 +164,7 @@ void ColorChanger::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
}
}
} else if (touching(touch, buttons[2])) {
int temp = Keyboard::getUint(255, "Enter the Blue RGB.");
int temp = Keyboard::getUint(255, Lang::get("ENTER_BLUE_RGB"));
if(temp != -1) {
blue = temp;
if (colorMode == 0) {
Expand Down
6 changes: 3 additions & 3 deletions source/screens/credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button);

void Credits::Draw(void) const {
GFX::DrawTop();
Gui::DrawStringCentered(0, 0, 0.9f, config->textColor(), "3DVier - Credits", 400);
Gui::DrawStringCentered(0, 30, 0.7f, config->textColor(), "Developed by SuperSaiyajinStackZ.", 390);
Gui::DrawStringCentered(0, 0, 0.9f, config->textColor(), "3DVier - " + Lang::get("CREDITS"), 400);
Gui::DrawStringCentered(0, 30, 0.7f, config->textColor(), Lang::get("DEVELOPED_BY"), 390);
GFX::DrawSprite(sprites_stackZ_idx, 2, 80);
GFX::DrawSprite(sprites_universal_core_idx, 190, 105);
std::string currentVersion = "Current Version: ";
std::string currentVersion = Lang::get("CURRENT_VERSION");
currentVersion += V_STRING;
Gui::DrawString(395-Gui::GetStringWidth(0.70f, currentVersion), 217, 0.70f, config->textColor(), currentVersion, 400);
GFX::DrawBottom();
Expand Down
Loading

0 comments on commit ceb0a11

Please sign in to comment.