renombrades extensions .h a .hpp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "lang.h"
|
||||
#include "lang.hpp"
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <exception> // Para exception
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "difficulty.h" // Para Difficulty
|
||||
#include "external/json.hpp" // Para basic_json, iteration_proxy_value, oper...
|
||||
#include "options.h" // Para SettingsOpt...
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "difficulty.hpp" // Para Difficulty
|
||||
#include "external/json.hpp" // Para basic_json, iteration_proxy_value, oper...
|
||||
#include "options.hpp" // Para SettingsOpt...
|
||||
#include "resource_helper.hpp" // Para ResourceHelper
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -25,7 +25,7 @@ std::vector<Language> languages = {
|
||||
{Code::ENGLISH, "Ingles", "en_UK.json"}};
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
auto loadFromFile(const std::string &file_path) -> bool {
|
||||
auto loadFromFile(const std::string& file_path) -> bool {
|
||||
texts.clear();
|
||||
|
||||
// Intentar cargar desde ResourceHelper primero
|
||||
@@ -47,10 +47,10 @@ auto loadFromFile(const std::string &file_path) -> bool {
|
||||
rfile >> j;
|
||||
}
|
||||
|
||||
for (const auto &el : j.items()) {
|
||||
for (const auto& el : j.items()) {
|
||||
texts[el.key()] = el.value();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
} catch (const std::exception& e) {
|
||||
// Puedes loguear el error si quieres
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ auto loadFromFile(const std::string &file_path) -> bool {
|
||||
}
|
||||
|
||||
// Obtiene el texto por clave
|
||||
auto getText(const std::string &key) -> std::string {
|
||||
auto getText(const std::string& key) -> std::string {
|
||||
auto it = texts.find(key);
|
||||
if (it != texts.end()) {
|
||||
return it->second;
|
||||
@@ -80,7 +80,7 @@ auto getNextLangCode(Code lang) -> Code {
|
||||
|
||||
// Obtiene un idioma del vector de idiomas a partir de un código
|
||||
auto getLanguage(Code code) -> Language {
|
||||
for (const auto &lang : languages) {
|
||||
for (const auto& lang : languages) {
|
||||
if (lang.code == code) {
|
||||
return lang;
|
||||
}
|
||||
@@ -90,8 +90,8 @@ auto getLanguage(Code code) -> Language {
|
||||
}
|
||||
|
||||
// Devuelve el código de un idioma a partir de un nombre
|
||||
auto getCodeFromName(const std::string &name) -> Code {
|
||||
for (const auto &lang : languages) {
|
||||
auto getCodeFromName(const std::string& name) -> Code {
|
||||
for (const auto& lang : languages) {
|
||||
if (lang.name == name) {
|
||||
return lang.code;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ auto getCodeFromName(const std::string &name) -> Code {
|
||||
|
||||
// Devuelve el nombre de un idioma a partir de un código
|
||||
auto getNameFromCode(Code code) -> std::string {
|
||||
for (const auto &lang : languages) {
|
||||
for (const auto& lang : languages) {
|
||||
if (lang.code == code) {
|
||||
return lang.name;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ auto getNameFromCode(Code code) -> std::string {
|
||||
|
||||
// Actualiza los nombres de los idiomas
|
||||
void updateLanguageNames() {
|
||||
for (auto &lang : languages) {
|
||||
for (auto& lang : languages) {
|
||||
switch (lang.code) {
|
||||
case Code::SPANISH:
|
||||
lang.name = Lang::getText("[SERVICE_MENU] LANG_ES");
|
||||
@@ -134,10 +134,10 @@ void updateLanguageNames() {
|
||||
// Actualiza los nombres de las dificultades
|
||||
void updateDifficultyNames() {
|
||||
// 1. Pide una referencia MODIFICABLE a la lista de dificultades
|
||||
auto &difficulties = Difficulty::getDifficulties();
|
||||
auto& difficulties = Difficulty::getDifficulties();
|
||||
|
||||
// 2. Recorre la lista
|
||||
for (auto &difficulty_info : difficulties) {
|
||||
for (auto& difficulty_info : difficulties) {
|
||||
// 3. Para cada dificultad, usa su código para obtener el texto traducido y actualizar su nombre
|
||||
switch (difficulty_info.code) {
|
||||
case Difficulty::Code::EASY:
|
||||
@@ -155,7 +155,7 @@ void updateDifficultyNames() {
|
||||
|
||||
// Obtiene una fichero a partir de un lang::Code
|
||||
auto getLanguageFileName(Lang::Code code) -> std::string {
|
||||
for (const auto &lang : languages) {
|
||||
for (const auto& lang : languages) {
|
||||
if (lang.code == code) {
|
||||
return Asset::get()->get(lang.file_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user