lang: convertits els fitxers de text a json
This commit is contained in:
@@ -169,10 +169,10 @@ void Credits::fillTextTexture()
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
const std::array<std::string, 10> TEXTS = {
|
||||
lang::getText(121),
|
||||
lang::getText(122),
|
||||
lang::getText(123),
|
||||
lang::getText(124),
|
||||
lang::getText("CREDITS_121"),
|
||||
lang::getText("CREDITS_122"),
|
||||
lang::getText("CREDITS_123"),
|
||||
lang::getText("CREDITS_124"),
|
||||
"JAILDESIGNER",
|
||||
"JAILDOCTOR (INTRO)",
|
||||
"ERIC MATYAS (SOUNDIMAGE.ORG)",
|
||||
|
||||
@@ -28,7 +28,7 @@ void DefineButtons::render()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
text_->writeCentered(x_, y_ - 10, lang::getText(100) + std::to_string(options.controllers.at(index_controller_).player_id));
|
||||
text_->writeCentered(x_, y_ - 10, lang::getText("DEFINE_BUTTONS_100") + std::to_string(options.controllers.at(index_controller_).player_id));
|
||||
text_->writeCentered(x_, y_, controller_names_.at(index_controller_));
|
||||
text_->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
|
||||
}
|
||||
@@ -135,9 +135,9 @@ bool DefineButtons::checkButtonNotInUse(SDL_GamepadButton button)
|
||||
void DefineButtons::clearButtons()
|
||||
{
|
||||
buttons_.clear();
|
||||
buttons_.emplace_back(lang::getText(95), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText(96), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText(97), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText(98), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText(99), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText("DEFINE_BUTTONS_95"), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText("DEFINE_BUTTONS_96"), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText("DEFINE_BUTTONS_97"), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText("DEFINE_BUTTONS_98"), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(lang::getText("DEFINE_BUTTONS_99"), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
}
|
||||
@@ -460,9 +460,9 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP);
|
||||
|
||||
// Textos
|
||||
Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/en_UK.txt", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/es_ES.json", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/en_UK.json", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/ba_BA.json", AssetType::LANG);
|
||||
|
||||
// Si falta algun fichero, sale del programa
|
||||
if (!Asset::get()->check())
|
||||
@@ -692,20 +692,20 @@ std::string Director::getLangFile(lang::Code code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case lang::Code::ba_BA:
|
||||
return Asset::get()->get("ba_BA.txt");
|
||||
case lang::Code::VALENCIAN:
|
||||
return Asset::get()->get("ba_BA.json");
|
||||
break;
|
||||
case lang::Code::es_ES:
|
||||
return Asset::get()->get("es_ES.txt");
|
||||
case lang::Code::SPANISH:
|
||||
return Asset::get()->get("es_ES.json");
|
||||
break;
|
||||
case lang::Code::en_UK:
|
||||
return Asset::get()->get("en_UK.txt");
|
||||
case lang::Code::ENGLISH:
|
||||
return Asset::get()->get("en_UK.json");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Asset::get()->get("en_UK.txt");
|
||||
return Asset::get()->get("en_UK.json");
|
||||
}
|
||||
|
||||
#ifdef ARCADE
|
||||
|
||||
@@ -276,7 +276,7 @@ void Game::updateStage()
|
||||
else
|
||||
{
|
||||
auto text = Resource::get()->getText("04b_25_2x");
|
||||
const std::string caption = std::to_string(10 - Stage::number) + lang::getText(38);
|
||||
const std::string caption = std::to_string(10 - Stage::number) + lang::getText("GAME_TEXT_38");
|
||||
createMessage(paths, text->writeToTexture(caption, 1, -4));
|
||||
}
|
||||
}
|
||||
@@ -1727,12 +1727,12 @@ void Game::initPlayers(int player_id)
|
||||
const int y = param.game.play_area.rect.h - 30;
|
||||
players_.emplace_back(std::make_unique<Player>(1, param.game.play_area.first_quarter_x - 15, y, demo_.enabled, param.game.play_area.rect, player_textures_[0], player_animations_));
|
||||
players_.back()->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||
players_.back()->setName(lang::getText(53));
|
||||
players_.back()->setName(lang::getText("SCOREBOARD_53"));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
|
||||
players_.emplace_back(std::make_unique<Player>(2, param.game.play_area.third_quarter_x - 15, y, demo_.enabled, param.game.play_area.rect, player_textures_[1], player_animations_));
|
||||
players_.back()->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||
players_.back()->setName(lang::getText(54));
|
||||
players_.back()->setName(lang::getText("SCOREBOARD_53"));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
|
||||
// Activa el jugador que coincide con el "player_id"
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace globalInputs
|
||||
{
|
||||
// Si la notificación de salir no está activa, muestra la notificación
|
||||
#ifdef ARCADE
|
||||
const int INDEX = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
|
||||
Notifier::get()->show({lang::getText(INDEX), std::string()}, -1, CODE);
|
||||
const std::string TEXT = code == section::Options::QUIT_WITH_CONTROLLER ? lang::getText("NOTIFICATIONS_116") : lang::getText("NOTIFICATIONS_94");
|
||||
Notifier::get()->show(TEXT, std::string()}, -1, CODE);
|
||||
#else
|
||||
Notifier::get()->show({lang::getText(94), std::string()}, -1, CODE);
|
||||
Notifier::get()->show({lang::getText("NOTIFICATIONS_94"), std::string()}, -1, CODE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,11 @@ namespace globalInputs
|
||||
if (Notifier::get()->checkCode(CODE))
|
||||
{
|
||||
section::name = section::Name::INIT;
|
||||
Notifier::get()->show({lang::getText(111)});
|
||||
Notifier::get()->show({lang::getText("HELP_111")});
|
||||
}
|
||||
else
|
||||
{
|
||||
Notifier::get()->show({lang::getText(125), std::string()}, -1, CODE);
|
||||
Notifier::get()->show({lang::getText("NOTIFICATIONS_125"), std::string()}, -1, CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,21 +65,21 @@ namespace globalInputs
|
||||
void toggleIntegerScale()
|
||||
{
|
||||
Screen::get()->toggleIntegerScale();
|
||||
Notifier::get()->show({lang::getText(134) + " " + boolToOnOff(options.video.integer_scale)});
|
||||
Notifier::get()->show({lang::getText("MISC_134") + " " + boolToOnOff(options.video.integer_scale)});
|
||||
}
|
||||
|
||||
// Activa / desactiva el vsync
|
||||
void toggleVSync()
|
||||
{
|
||||
Screen::get()->toggleVSync();
|
||||
Notifier::get()->show({lang::getText(136) + " " + boolToOnOff(options.video.v_sync)});
|
||||
Notifier::get()->show({lang::getText("MISC_136") + " " + boolToOnOff(options.video.v_sync)});
|
||||
}
|
||||
|
||||
// Activa o desactiva los shaders
|
||||
void toggleShaders()
|
||||
{
|
||||
Screen::get()->toggleShaders();
|
||||
Notifier::get()->show({lang::getText(135) + " " + boolToOnOff(options.video.shaders)});
|
||||
Notifier::get()->show({lang::getText("MISC_135") + " " + boolToOnOff(options.video.shaders)});
|
||||
}
|
||||
|
||||
// Obtiene una fichero a partir de un lang::Code
|
||||
@@ -87,14 +87,14 @@ namespace globalInputs
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case lang::Code::ba_BA:
|
||||
return Asset::get()->get("ba_BA.txt");
|
||||
case lang::Code::VALENCIAN:
|
||||
return Asset::get()->get("ba_BA.json");
|
||||
break;
|
||||
case lang::Code::es_ES:
|
||||
return Asset::get()->get("es_ES.txt");
|
||||
case lang::Code::SPANISH:
|
||||
return Asset::get()->get("es_ES.json");
|
||||
break;
|
||||
default:
|
||||
return Asset::get()->get("en_UK.txt");
|
||||
return Asset::get()->get("en_UK.json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,10 +104,10 @@ namespace globalInputs
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case lang::Code::ba_BA:
|
||||
case lang::Code::VALENCIAN:
|
||||
return " \"ba_BA\"";
|
||||
break;
|
||||
case lang::Code::es_ES:
|
||||
case lang::Code::SPANISH:
|
||||
return " \"es_ES\"";
|
||||
break;
|
||||
default:
|
||||
@@ -126,12 +126,12 @@ namespace globalInputs
|
||||
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
|
||||
section::name = section::Name::INIT;
|
||||
section::options = section::Options::RELOAD;
|
||||
Notifier::get()->show({lang::getText(127) + getLangName(options.game.language)});
|
||||
Notifier::get()->show({lang::getText("NOTIFICATIONS_127") + getLangName(options.game.language)});
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto NEXT = lang::getNextLangCode(options.game.language);
|
||||
Notifier::get()->show({lang::getText(126) + getLangName(NEXT), std::string()}, -1, CODE);
|
||||
Notifier::get()->show({lang::getText("NOTIFICATIONS_126") + getLangName(NEXT), std::string()}, -1, CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace globalInputs
|
||||
void toggleFireMode()
|
||||
{
|
||||
options.game.autofire = !options.game.autofire;
|
||||
Notifier::get()->show({lang::getText(130) + " " + boolToOnOff(options.game.autofire)});
|
||||
Notifier::get()->show({lang::getText("MISC_130") + " " + boolToOnOff(options.game.autofire)});
|
||||
}
|
||||
|
||||
// Salta una sección del juego
|
||||
@@ -271,7 +271,7 @@ namespace globalInputs
|
||||
if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||
{
|
||||
Screen::get()->toggleFullscreen();
|
||||
const std::string MODE = options.video.fullscreen ? lang::getText(133) : lang::getText(132);
|
||||
const std::string MODE = options.video.fullscreen ? lang::getText("MISC_133") : lang::getText("MISC_132");
|
||||
Notifier::get()->show({MODE});
|
||||
return;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ namespace globalInputs
|
||||
{
|
||||
if (Screen::get()->decWindowZoom())
|
||||
{
|
||||
Notifier::get()->show({lang::getText(131) + " x" + std::to_string(options.window.size)});
|
||||
Notifier::get()->show({lang::getText("MISC_131") + " x" + std::to_string(options.window.size)});
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace globalInputs
|
||||
{
|
||||
if (Screen::get()->incWindowZoom())
|
||||
{
|
||||
Notifier::get()->show({lang::getText(131) + " x" + std::to_string(options.window.size)});
|
||||
Notifier::get()->show({lang::getText("MISC_131") + " x" + std::to_string(options.window.size)});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void HiScoreTable::createSprites()
|
||||
const int first_line = (param.game.height - size) / 2;
|
||||
|
||||
// Crea el sprite para el texto de cabecera
|
||||
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, lang::getText(42), -2, background_fade_color_.getInverse().lighten(25)));
|
||||
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, lang::getText("HIGHSCORE_TABLE_42"), -2, background_fade_color_.getInverse().lighten(25)));
|
||||
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line);
|
||||
|
||||
// Crea los sprites para las entradas en la tabla de puntuaciones
|
||||
|
||||
@@ -139,38 +139,45 @@ void Instructions::fillTexture()
|
||||
|
||||
// Calcula cual es el texto más largo de las descripciones de los items
|
||||
int lenght = 0;
|
||||
for (int i = 17; i <= 21; ++i)
|
||||
const std::array<std::string, 5> ITEM_DESCRIPTIONS = {
|
||||
lang::getText("INSTRUCTIONS_17"),
|
||||
lang::getText("INSTRUCTIONS_18"),
|
||||
lang::getText("INSTRUCTIONS_19"),
|
||||
lang::getText("INSTRUCTIONS_20"),
|
||||
lang::getText("INSTRUCTIONS_21")
|
||||
};
|
||||
for (const auto& desc : ITEM_DESCRIPTIONS)
|
||||
{
|
||||
const int l = text_->lenght(lang::getText(i));
|
||||
const int l = text_->lenght(desc);
|
||||
lenght = l > lenght ? l : lenght;
|
||||
}
|
||||
const int anchor_item = (param.game.width - (lenght + desp_x)) / 2;
|
||||
const int ANCHOR_ITEM = (param.game.width - (lenght + desp_x)) / 2;
|
||||
|
||||
// Escribe el texto de las instrucciones
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, lang::getText(11), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, lang::getText("INSTRUCTIONS_11"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
|
||||
const int anchor1 = first_line + space_post_header;
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, lang::getText(12), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, lang::getText(13), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, lang::getText(14), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, lang::getText(15), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, lang::getText("INSTRUCTIONS_12"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, lang::getText("INSTRUCTIONS_13"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, lang::getText("INSTRUCTIONS_14"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, lang::getText("INSTRUCTIONS_15"), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
|
||||
// Escribe el texto de los objetos y sus puntos
|
||||
const int anchor2 = anchor1 + space_pre_header + space_new_paragraph + space_between_lines * 3;
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, lang::getText(16), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, lang::getText("INSTRUCTIONS_16"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
|
||||
const int anchor3 = anchor2 + space_post_header;
|
||||
text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 0, lang::getText(17), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 1, lang::getText(18), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 2, lang::getText(19), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 3, lang::getText(20), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 4, lang::getText(21), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 0, lang::getText("INSTRUCTIONS_17"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 1, lang::getText("INSTRUCTIONS_18"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 2, lang::getText("INSTRUCTIONS_19"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 3, lang::getText("INSTRUCTIONS_20"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 4, lang::getText("INSTRUCTIONS_21"), SHADOW_TEXT_COLOR);
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
|
||||
// Da valor a la variable
|
||||
sprite_pos_.x = anchor_item;
|
||||
sprite_pos_.x = ANCHOR_ITEM;
|
||||
sprite_pos_.y = anchor3 - ((param.game.item_size - text_->getCharacterSize()) / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -396,39 +396,39 @@ void Intro::initTexts()
|
||||
}
|
||||
|
||||
// Un dia qualsevol de l'any 2000
|
||||
texts_.at(0)->setCaption(lang::getText(27));
|
||||
texts_.at(0)->setCaption(lang::getText("INTRO_27"));
|
||||
texts_.at(0)->setSpeed(8);
|
||||
|
||||
// Tot esta tranquil a la UPV
|
||||
texts_.at(1)->setCaption(lang::getText(28));
|
||||
texts_.at(1)->setCaption(lang::getText("INTRO_28"));
|
||||
texts_.at(1)->setSpeed(8);
|
||||
|
||||
// Fins que un desaprensiu...
|
||||
texts_.at(2)->setCaption(lang::getText(29));
|
||||
texts_.at(2)->setCaption(lang::getText("INTRO_29"));
|
||||
texts_.at(2)->setSpeed(12);
|
||||
|
||||
// HEY! ME ANE A FERME UN CORTAET...
|
||||
texts_.at(3)->setCaption(lang::getText(30));
|
||||
texts_.at(3)->setCaption(lang::getText("INTRO_30"));
|
||||
texts_.at(3)->setSpeed(8);
|
||||
|
||||
// UAAAAAAAAAAAAA!!!
|
||||
texts_.at(4)->setCaption(lang::getText(31));
|
||||
texts_.at(4)->setCaption(lang::getText("INTRO_31"));
|
||||
texts_.at(4)->setSpeed(1);
|
||||
|
||||
// Espera un moment...
|
||||
texts_.at(5)->setCaption(lang::getText(32));
|
||||
texts_.at(5)->setCaption(lang::getText("INTRO_32"));
|
||||
texts_.at(5)->setSpeed(16);
|
||||
|
||||
// Si resulta que no tinc solt!
|
||||
texts_.at(6)->setCaption(lang::getText(33));
|
||||
texts_.at(6)->setCaption(lang::getText("INTRO_33"));
|
||||
texts_.at(6)->setSpeed(2);
|
||||
|
||||
// MERDA DE MAQUINA!
|
||||
texts_.at(7)->setCaption(lang::getText(34));
|
||||
texts_.at(7)->setCaption(lang::getText("INTRO_34"));
|
||||
texts_.at(7)->setSpeed(3);
|
||||
|
||||
// Blop... blop... blop...
|
||||
texts_.at(8)->setCaption(lang::getText(35));
|
||||
texts_.at(8)->setCaption(lang::getText("INTRO_35"));
|
||||
texts_.at(8)->setSpeed(20);
|
||||
|
||||
for (auto &text : texts_)
|
||||
|
||||
25526
source/json.hpp
Normal file
25526
source/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,57 @@
|
||||
#include "lang.h"
|
||||
#include <fstream> // Para basic_ifstream, basic_istream, ifstream
|
||||
#include <vector> // Para vector
|
||||
#include <fstream>
|
||||
#include <unordered_map>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace lang
|
||||
{
|
||||
std::vector<std::string> texts; // Vector con los textos
|
||||
std::unordered_map<std::string, std::string> texts;
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
bool loadFromFile(const std::string &file_path)
|
||||
{
|
||||
texts.clear();
|
||||
|
||||
bool success = false;
|
||||
|
||||
std::ifstream rfile(file_path);
|
||||
if (rfile.is_open() && rfile.good())
|
||||
{
|
||||
success = true;
|
||||
std::string line;
|
||||
if (!rfile.is_open())
|
||||
return false;
|
||||
|
||||
// Lee el resto de datos del fichero
|
||||
while (std::getline(rfile, line))
|
||||
try
|
||||
{
|
||||
json j;
|
||||
rfile >> j;
|
||||
|
||||
for (auto &el : j.items())
|
||||
{
|
||||
// Almacena solo las lineas que no empiezan por # o no esten vacias
|
||||
const bool TEST1 = line.substr(0, 1) != "#";
|
||||
const bool TEST2 = !line.empty();
|
||||
if (TEST1 && TEST2)
|
||||
{
|
||||
texts.push_back(line);
|
||||
}
|
||||
};
|
||||
texts[el.key()] = el.value();
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
// Puedes loguear el error si quieres
|
||||
return false;
|
||||
}
|
||||
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Obtiene la cadena de texto del indice
|
||||
std::string getText(int index)
|
||||
// Obtiene el texto por clave
|
||||
std::string getText(const std::string &key)
|
||||
{
|
||||
return texts.at(index);
|
||||
auto it = texts.find(key);
|
||||
if (it != texts.end())
|
||||
return it->second;
|
||||
else
|
||||
return "[missing text: " + key + "]";
|
||||
}
|
||||
|
||||
// Obtiene el codigo del idioma del siguiente idioma
|
||||
// Obtiene el código del siguiente idioma disponible
|
||||
Code getNextLangCode(Code lang)
|
||||
{
|
||||
auto index = static_cast<int>(lang);
|
||||
index = (index + 1) % 3;
|
||||
return static_cast<Code>(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <string> // Para std::string
|
||||
#include <string>
|
||||
|
||||
namespace lang
|
||||
{
|
||||
// --- Códigos de idioma soportados ---
|
||||
enum class Code : int
|
||||
{
|
||||
es_ES = 0, // Español
|
||||
ba_BA = 1, // Bable/Asturiano
|
||||
en_UK = 2, // Inglés (Reino Unido)
|
||||
SPANISH = 0,
|
||||
VALENCIAN = 1,
|
||||
ENGLISH = 2
|
||||
};
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
// Carga los textos desde el fichero JSON especificado
|
||||
bool loadFromFile(const std::string &file_path);
|
||||
|
||||
// Obtiene la cadena de texto correspondiente al índice
|
||||
std::string getText(int index);
|
||||
// Obtiene un texto a partir de una clave
|
||||
std::string getText(const std::string &key);
|
||||
|
||||
// Obtiene el código del siguiente idioma disponible
|
||||
// Obtiene el código del siguiente idioma (circular)
|
||||
Code getNextLangCode(Code lang);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void initOptions()
|
||||
|
||||
// Opciones de juego
|
||||
options.game.difficulty = GameDifficulty::NORMAL;
|
||||
options.game.language = lang::Code::ba_BA;
|
||||
options.game.language = lang::Code::VALENCIAN;
|
||||
options.game.autofire = true;
|
||||
options.game.clear_last_hi_score_entries();
|
||||
|
||||
@@ -92,11 +92,11 @@ bool loadOptionsFile(std::string file_path)
|
||||
}
|
||||
|
||||
// Normaliza los valores
|
||||
if (options.game.language != lang::Code::en_UK &&
|
||||
options.game.language != lang::Code::ba_BA &&
|
||||
options.game.language != lang::Code::es_ES)
|
||||
if (options.game.language != lang::Code::ENGLISH &&
|
||||
options.game.language != lang::Code::VALENCIAN &&
|
||||
options.game.language != lang::Code::SPANISH)
|
||||
{
|
||||
options.game.language = lang::Code::en_UK;
|
||||
options.game.language = lang::Code::ENGLISH;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
@@ -282,10 +282,10 @@ void Resource::createTextures()
|
||||
{"game_text_1000_points", "1.000"},
|
||||
{"game_text_2500_points", "2.500"},
|
||||
{"game_text_5000_points", "5.000"},
|
||||
{"game_text_powerup", lang::getText(117)},
|
||||
{"game_text_one_hit", lang::getText(118)},
|
||||
{"game_text_stop", lang::getText(119)},
|
||||
{"game_text_1000000_points", lang::getText(76)}};
|
||||
{"game_text_powerup", lang::getText("GAME_TEXT_117")},
|
||||
{"game_text_one_hit", lang::getText("GAME_TEXT_118")},
|
||||
{"game_text_stop", lang::getText("GAME_TEXT_119")},
|
||||
{"game_text_1000000_points", lang::getText("GAMEPLAY_76")}};
|
||||
|
||||
auto text = getText("04b_25");
|
||||
for (const auto &s : strings)
|
||||
@@ -297,9 +297,9 @@ void Resource::createTextures()
|
||||
// Tamaño doble
|
||||
std::vector<NameAndText> strings2X = {
|
||||
{"game_text_100000_points", "100.000"},
|
||||
{"game_text_get_ready", lang::getText(75)},
|
||||
{"game_text_last_stage", lang::getText(79)},
|
||||
{"game_text_congratulations", lang::getText(50)},
|
||||
{"game_text_get_ready", lang::getText("GAMEPLAY_75")},
|
||||
{"game_text_last_stage", lang::getText("GAME_TEXT_79")},
|
||||
{"game_text_congratulations", lang::getText("GAME_COMPLETION_TEXT_50")},
|
||||
{"game_text_game_over", "Game Over"}};
|
||||
|
||||
auto text2 = getText("04b_25_2x");
|
||||
|
||||
@@ -177,7 +177,7 @@ void Scoreboard::fillPanelTextures()
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
|
||||
// MULT
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(55));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("SCOREBOARD_55"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, "x" + std::to_string(mult_[i]).substr(0, 3));
|
||||
break;
|
||||
}
|
||||
@@ -185,13 +185,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::DEMO:
|
||||
{
|
||||
// DEMO MODE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(101));
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("SCOREBOARD_101"));
|
||||
|
||||
// PRESS START TO PLAY
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(103));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(104));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("SCOREBOARD_103"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("SCOREBOARD_104"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -199,13 +199,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::WAITING:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("SCOREBOARD_102"));
|
||||
|
||||
// PRESS START TO PLAY
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(103));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(104));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("SCOREBOARD_103"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("SCOREBOARD_104"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -213,13 +213,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::GAME_OVER:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("SCOREBOARD_102"));
|
||||
|
||||
// PLEASE WAIT
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(114));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(115));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("SCOREBOARD_114"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText("SCOREBOARD_115"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::STAGE_INFO:
|
||||
{
|
||||
// STAGE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, lang::getText(57) + std::to_string(stage_));
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, lang::getText("SCOREBOARD_57") + std::to_string(stage_));
|
||||
|
||||
// POWERMETER
|
||||
power_meter_sprite_->setSpriteClip(0, 0, 40, 7);
|
||||
@@ -236,7 +236,7 @@ void Scoreboard::fillPanelTextures()
|
||||
power_meter_sprite_->render();
|
||||
|
||||
// HI-SCORE
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(56));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("SCOREBOARD_56"));
|
||||
const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_));
|
||||
break;
|
||||
@@ -249,7 +249,7 @@ void Scoreboard::fillPanelTextures()
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
|
||||
// CONTINUE
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(105));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("SCOREBOARD_105"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, std::to_string(continue_counter_[i]));
|
||||
break;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ void Scoreboard::fillPanelTextures()
|
||||
|
||||
// ENTER NAME
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("SCOREBOARD_106"));
|
||||
SDL_FRect rect = {enter_name_pos_.x, enter_name_pos_.y, 5.0f, 7.0f};
|
||||
|
||||
// Recorre todos los slots de letras del nombre
|
||||
@@ -298,7 +298,7 @@ void Scoreboard::fillPanelTextures()
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
|
||||
// NAME
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText("SCOREBOARD_106"));
|
||||
/* TEXTO CENTRADO */
|
||||
// text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
|
||||
|
||||
@@ -309,12 +309,12 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::GAME_COMPLETED:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText("SCOREBOARD_102"));
|
||||
|
||||
// SCORE
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(120));
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText("SCOREBOARD_120"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, updateScoreText(score_[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void Title::render()
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
||||
{
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, NO_COLOR, 1, shadow);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText("TITLE_23"), 1, NO_COLOR, 1, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ void Title::render()
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 10 > 4 && !define_buttons_->isEnabled())
|
||||
{
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, NO_COLOR, 1, shadow);
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText("TITLE_23"), 1, NO_COLOR, 1, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ void Title::swapControllers()
|
||||
void Title::swapKeyboard()
|
||||
{
|
||||
swapOptionsKeyboard();
|
||||
std::string text = lang::getText(100) + std::to_string(getPlayerWhoUsesKeyboard()) + ": " + lang::getText(69);
|
||||
std::string text = lang::getText("DEFINE_BUTTONS_100") + std::to_string(getPlayerWhoUsesKeyboard()) + ": " + lang::getText("MENU_OPTIONS_69");
|
||||
Notifier::get()->show({text});
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void Title::showControllers()
|
||||
const size_t index = player_controller_index.at(i);
|
||||
if (options.controllers.at(index).plugged)
|
||||
{
|
||||
text.at(i) = lang::getText(100) + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
|
||||
text.at(i) = lang::getText("DEFINE_BUTTONS_100") + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ std::string boolToString(bool value)
|
||||
// Convierte un valor booleano en una cadena "on" o "off"
|
||||
std::string boolToOnOff(bool value)
|
||||
{
|
||||
return value ? lang::getText(128) : lang::getText(129);
|
||||
return value ? lang::getText("MISC_128") : lang::getText("MISC_129");
|
||||
}
|
||||
|
||||
// Convierte una cadena a minusculas
|
||||
|
||||
Reference in New Issue
Block a user