-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b03a0d0
commit 202a400
Showing
11 changed files
with
213 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "yaml"] | ||
path = yaml | ||
url = https://github.com/jbeder/yaml-cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#pragma once | ||
|
||
#include "utils.h" | ||
#include <yaml-cpp/yaml.h> | ||
|
||
class Locale | ||
{ | ||
|
||
private: | ||
std::string langCode; | ||
std::fstream file; | ||
YAML::Node node; | ||
|
||
void loadFile() { | ||
std::string path = "locale/" + langCode + ".yml"; | ||
file.open(path, std::ios::in); | ||
if (!file.is_open()) { | ||
logger::error("Failed to open file: ", path, ". Defaulting to en.yml"); | ||
file.open("locale/en.yml", std::ios::in); | ||
if (!file.is_open()) { | ||
logger::error("Failed to open file: locale/en.yml"); | ||
system("pause"); | ||
exit(1); | ||
} | ||
} | ||
} | ||
|
||
public: | ||
Locale(std::string langCode) | ||
{ | ||
this->langCode = langCode; | ||
|
||
loadFile(); | ||
|
||
try { | ||
node = YAML::Load(file); | ||
} | ||
catch (const std::runtime_error& re) | ||
{ | ||
logger::error("Runtime error when loading lang file: ", re.what()); | ||
system("pause"); | ||
exit(1); | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
logger::error("Error occurred: ", ex.what()); | ||
system("pause"); | ||
exit(1); | ||
} | ||
catch (...) | ||
{ | ||
logger::error("Unknown failure occurred. Possible memory corruption"); | ||
system("pause"); | ||
exit(1); | ||
} | ||
} | ||
|
||
std::string get(const std::string& key, std::string default_value = "Unknown string") { | ||
try { | ||
return node[key].as<std::string>(); | ||
} | ||
catch (const std::runtime_error& re) | ||
{ | ||
logger::error("Runtime error when getting string: ", re.what()); | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
logger::error("Error occurred when getting string: ", ex.what()); | ||
} | ||
catch (...) | ||
{ | ||
logger::error("Unknown failure occurred when getting string. Possible memory corruption"); | ||
} | ||
return default_value; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
inline std::string getSystemLang() { | ||
LCID lcid = GetThreadLocale(); | ||
wchar_t name[LOCALE_NAME_MAX_LENGTH]; | ||
wchar_t parentLocateName[LOCALE_NAME_MAX_LENGTH]; | ||
LCIDToLocaleName(lcid, name, LOCALE_NAME_MAX_LENGTH, 0); | ||
GetLocaleInfoEx(name, LOCALE_SPARENT, parentLocateName, LOCALE_NAME_MAX_LENGTH); | ||
|
||
std::wstring langCode = std::wstring(parentLocateName); | ||
return std::string(langCode.begin(), langCode.end()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
created_libs_folder: "Created \"libs\" directory, please place DLLs in that directory and try again." | ||
no_dlls_found: "No DLLs found in \"libs\" directory, please place DLLs in that directory and try again." | ||
found_one: "Found one DLL: " | ||
found_multiple: "Found more than 1 DLL, please select one:\n" | ||
input_index: "Enter DLL index: " | ||
loading_dll: "Loading DLL: " | ||
found_process_id: "Process found with ID: " | ||
dll_unloaded: "DLL unloaded successfully, do you want to load it again?" | ||
dll_not_unloaded: "DLL not unloaded, exiting..." | ||
dll_loaded: "DLL loaded successfully!" | ||
|
||
fail_game_not_found: "Game not found, please check that the game is running and try again." | ||
fail_process_id: "Failed to get process ID" | ||
fail_admin: "Please run this program as administrator and try again." | ||
fail_open_process: "Failed to open process" | ||
fail_already_loaded: "That DLL is already loaded in the process. Do you want to unload it?" | ||
fail_unload: "Failed to unload DLL" | ||
fail_malloc: "Failed to allocate memory in the process" | ||
fail_write_memory: "Failed to write memory in the process" | ||
fail_create_thread: "Failed to create remote thread in the process" | ||
fail_thread_wait: "Failed to wait for remote thread in the process" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
created_libs_folder: "Se ha creado el directorio \"libs\", por favor coloque los DLLs en ese directorio y vuelva a intentarlo." | ||
no_dlls_found: "No se encontraron DLLs en el directorio \"libs\", por favor coloque los DLLs en ese directorio y vuelva a intentarlo." | ||
found_one: "Se encontró un DLL: " | ||
found_multiple: "Se encontraron más de 1 DLL, por favor seleccione uno:\n" | ||
input_index: "Ingrese el índice del DLL: " | ||
loading_dll: "Cargando DLL: " | ||
found_process_id: "Proceso encontrado con ID: " | ||
dll_unloaded: "DLL descargado con éxito, ¿quieres volver a cargarlo?" | ||
dll_not_unloaded: "DLL no descargado, saliendo..." | ||
dll_loaded: "DLL cargado con éxito!" | ||
|
||
fail_game_not_found: "Juego no encontrado, por favor verifique que el juego se esté ejecutando y vuelva a intentarlo." | ||
fail_process_id: "No se pudo obtener el ID del proceso" | ||
fail_admin: "Por favor, ejecute este programa como administrador y vuelva a intentarlo." | ||
fail_open_process: "No se pudo abrir el proceso" | ||
fail_already_loaded: "Ese DLL ya está cargado en el proceso. ¿Quieres descargarlo?" | ||
fail_unload: "No se pudo descargar DLL" | ||
fail_malloc: "No se pudo asignar memoria en el proceso" | ||
fail_write_memory: "No se pudo escribir en la memoria del proceso" | ||
fail_create_thread: "No se pudo crear un hilo remoto en el proceso" | ||
fail_thread_wait: "No se pudo esperar el hilo remoto en el proceso" |