Feat: Implement localization for menu headers, sidebars, tooltips, and language selector, and fix compilation errors in Menu.cpp
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <ship/utils/StringHelper.h>
|
||||
#include "Enhancements/custom-message/CustomMessageManager.h"
|
||||
#include "util.h"
|
||||
#include "Localization.h"
|
||||
|
||||
#if not defined(__SWITCH__) && not defined(__WIIU__)
|
||||
#include "Extractor/Extract.h"
|
||||
@@ -809,6 +810,13 @@ void OTRGlobals::Initialize() {
|
||||
|
||||
context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 });
|
||||
|
||||
int32_t lang = CVarGetInteger("gSettings.Menu.Language", 0);
|
||||
if (lang == 1) {
|
||||
LUS::Localization::GetInstance()->LoadLanguage("es_ES");
|
||||
} else {
|
||||
LUS::Localization::GetInstance()->LoadLanguage("en_US");
|
||||
}
|
||||
|
||||
SPDLOG_INFO("Starting Ship of Harkinian version {} (Branch: {} | Commit: {})", (char*)gBuildVersion,
|
||||
(char*)gGitBranch, (char*)gGitCommitHash);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Menu.h"
|
||||
#include "../Localization.h"
|
||||
#include "UIWidgets.hpp"
|
||||
#include "soh/OTRGlobals.h"
|
||||
#include <ship/window/gui/GuiMenuBar.h>
|
||||
@@ -665,7 +666,8 @@ void Menu::DrawElement() {
|
||||
headerWidth += 200.0f;
|
||||
}
|
||||
for (auto& label : menuOrder) {
|
||||
ImVec2 size = ImGui::CalcTextSize(label.c_str());
|
||||
auto& entry = menuEntries.at(label);
|
||||
ImVec2 size = ImGui::CalcTextSize(entry.label.c_str());
|
||||
headerSizes.push_back(size);
|
||||
headerWidth += size.x + style.FramePadding.x * 2 + style.ItemSpacing.x;
|
||||
}
|
||||
@@ -715,7 +717,7 @@ void Menu::DrawElement() {
|
||||
if (headerIndex != label) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
}
|
||||
if (ModernMenuHeaderEntry(entry.label)) {
|
||||
if (ModernMenuHeaderEntry(LUS_LOC(entry.label))) {
|
||||
if (headerSearch) {
|
||||
menuSearch.Clear();
|
||||
}
|
||||
@@ -842,7 +844,7 @@ void Menu::DrawElement() {
|
||||
if (sectionIndex != sidebarLabel) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
}
|
||||
if (ModernMenuSidebarEntry(sidebarLabel)) {
|
||||
if (ModernMenuSidebarEntry(LUS_LOC(sidebarLabel))) {
|
||||
if (headerSearch) {
|
||||
menuSearch.Clear();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SohMenu.h"
|
||||
#include "../Localization.h"
|
||||
#include <ship/window/gui/GuiMenuBar.h>
|
||||
#include <ship/window/gui/GuiElement.h>
|
||||
#include <ship/utils/StringHelper.h>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SohMenu.h"
|
||||
#include "../Localization.h"
|
||||
#include "SohGui.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "SohMenu.h"
|
||||
#include <soh/Enhancements/enhancementTypes.h>
|
||||
#include "../Localization.h"
|
||||
#include <soh/Enhancements/mods.h>
|
||||
#include <soh/Enhancements/game-interactor/GameInteractor.h>
|
||||
#include <soh/OTRGlobals.h>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SohMenu.h"
|
||||
#include "../Localization.h"
|
||||
#include "soh/Enhancements/enhancementTypes.h"
|
||||
#include "soh/Enhancements/randomizer/randomizer.h"
|
||||
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SohMenu.h"
|
||||
#include "../Localization.h"
|
||||
#include "soh/Notification/Notification.h"
|
||||
#include "soh/Enhancements/enhancementTypes.h"
|
||||
#include "SohModals.h"
|
||||
@@ -43,6 +44,11 @@ static const std::map<int32_t, const char*> menuThemeOptions = {
|
||||
{ UIWidgets::Colors::DarkGray, "Dark Gray" },
|
||||
};
|
||||
|
||||
static const std::map<int32_t, const char*> menuLanguageOptions = {
|
||||
{ 0, "English" },
|
||||
{ 1, "Español" },
|
||||
};
|
||||
|
||||
static const std::map<int32_t, const char*> textureFilteringMap = {
|
||||
{ Fast::FILTER_THREE_POINT, "Three-Point" },
|
||||
{ Fast::FILTER_LINEAR, "Linear" },
|
||||
@@ -134,9 +140,25 @@ void SohMenu::AddMenuSettings() {
|
||||
.CVar(CVAR_SETTING("Menu.Theme"))
|
||||
.RaceDisable(false)
|
||||
.Options(ComboboxOptions()
|
||||
.Tooltip("Changes the Theme of the Menu Widgets.")
|
||||
.Tooltip(LUS_LOC("TOOLTIP_MENU_THEME"))
|
||||
.ComboMap(menuThemeOptions)
|
||||
.DefaultIndex(Colors::LightBlue));
|
||||
|
||||
AddWidget(path, "Menu Language", WIDGET_CVAR_COMBOBOX)
|
||||
.CVar("gSettings.Menu.Language")
|
||||
.RaceDisable(false)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
int32_t lang = CVarGetInteger("gSettings.Menu.Language", 0);
|
||||
if (lang == 1) {
|
||||
LUS::Localization::GetInstance()->LoadLanguage("es_ES");
|
||||
} else {
|
||||
LUS::Localization::GetInstance()->LoadLanguage("en_US");
|
||||
}
|
||||
})
|
||||
.Options(ComboboxOptions()
|
||||
.Tooltip(LUS_LOC("TOOLTIP_MENU_LANGUAGE"))
|
||||
.ComboMap(menuLanguageOptions)
|
||||
.DefaultIndex(0));
|
||||
#if not defined(__SWITCH__) and not defined(__WIIU__)
|
||||
AddWidget(path, "Menu Controller Navigation", WIDGET_CVAR_CHECKBOX)
|
||||
.CVar(CVAR_IMGUI_CONTROLLER_NAV)
|
||||
|
||||
Reference in New Issue
Block a user