Skip to content

Commit fb2dc65

Browse files
MalkierianKiritoDv
authored andcommitted
Add CVar for Better Level Select language.
Convert CVars to macro use in BetterLevelSelect.cpp. Add mGhostshipMenu as an extern to GhosthipGui.hpp.
1 parent 4a3ef6c commit fb2dc65

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/port/mods/BetterLevelSelect.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "BetterLevelSelect.h"
22

33
#include "sm64.h"
4+
#include "port/ui/cvar_prefixes.h"
45
#include "game/area.h"
56
#include "audio/external.h"
67
#include "game/game_init.h"
@@ -244,7 +245,7 @@ s32 BetterLevelSelect_UpdateMenu(s16 arg, s32 b) {
244245
return 1;
245246
}
246247

247-
if(arg != LVL_INTRO_LEVEL_SELECT || CVarGetInteger("gDeveloperTools.BetterLevelSelect", 1) == 0){
248+
if(arg != LVL_INTRO_LEVEL_SELECT || CVarGetInteger(CVAR_DEVELOPER_TOOLS("BetterLevelSelect"), 1) == 0){
248249
return lvl_intro_update(arg, b);
249250
}
250251

@@ -397,10 +398,11 @@ s32 BetterLevelSelect_UpdateMenu(s16 arg, s32 b) {
397398
}
398399

399400
Gfx* BetterLevelSelect_DrawMenu(s32 state, struct GraphNode *node, UNUSED void *context) {
400-
if(state != 1 || CVarGetInteger("gDeveloperTools.BetterLevelSelect", 1) != 1) {
401+
if (state != 1 || CVarGetInteger(CVAR_DEVELOPER_TOOLS("BetterLevelSelect"), 1) != 1) {
401402
return NULL;
402403
}
403404

405+
int language = CVarGetInteger(CVAR_DEVELOPER_TOOLS("BLSLanguage"), ROM_JP);
404406
int32_t count = ARRAY_COUNT(entries);
405407
GfxPrint printer;
406408
Gfx* head = &self.pool[0];
@@ -430,10 +432,10 @@ Gfx* BetterLevelSelect_DrawMenu(s32 state, struct GraphNode *node, UNUSED void *
430432
GfxPrint_SetColor(&printer, 175, 175, 175, 255);
431433
}
432434

433-
GfxPrint_Printf(&printer, "%3d %s", idx, ROM_JP ? entry.japaneseName : entry.englishName);
435+
GfxPrint_Printf(&printer, "%3d %s", idx, language ? entry.japaneseName : entry.englishName);
434436
}
435437

436-
std::vector<const char*> acts = ROM_JP ? entries[self.currentLevelIndex].actsJp : entries[self.currentLevelIndex].actsEn;
438+
std::vector<const char*> acts = language ? entries[self.currentLevelIndex].actsJp : entries[self.currentLevelIndex].actsEn;
437439

438440
if(!acts.empty()) {
439441
GfxPrint_SetPos(&printer, 2, 25);
@@ -497,7 +499,7 @@ static void Init() {
497499
return;
498500
}
499501

500-
if(CVarGetInteger("gDeveloperTools.BetterLevelSelect", 1) == 0){
502+
if(CVarGetInteger(CVAR_DEVELOPER_TOOLS("BetterLevelSelect"), 1) == 0){
501503
*ev->geoLayoutAddr = (void*) intro_geo_000414;
502504
} else {
503505
*ev->geoLayoutAddr = (void*) BetterLevelSelect_GeoWrapper;

src/port/ui/GhostshipGui.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <spdlog/spdlog.h>
44
#include <imgui.h>
55
#include <imgui_internal.h>
6-
#include "UIWidgets.hpp"
76

87
#ifdef __APPLE__
98
#include <fast/backends/gfx_metal.h>
@@ -14,7 +13,6 @@
1413
#endif
1514

1615
#include "Notification.h"
17-
#include "GhostshipMenu.h"
1816
#include "GhostshipInputEditorWindow.h"
1917
#include "SaveEditor.h"
2018

src/port/ui/GhostshipGui.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
#include "UIWidgets.hpp"
44
#include "InputViewer.h"
55
#include "GhostshipModals.h"
6+
#include "GhostshipMenu.h"
67

78
namespace GhostshipGui {
89
void SetupHooks();
910
void SetupGuiElements();
1011
void Draw();
1112
void Destroy();
1213
UIWidgets::Colors GetMenuThemeColor();
14+
extern std::shared_ptr<GhostshipMenu> mGhostshipMenu;
1315
} // namespace GhostshipGui
1416

1517
#define THEME_COLOR GhostshipGui::GetMenuThemeColor()

src/port/ui/GhostshipMenuDevTools.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ static const std::unordered_map<int32_t, const char*> debugInfoPages = {
1818
{ DEBUG_PAGE_EFFECTINFO, "Effect" }, { DEBUG_PAGE_ENEMYINFO, "Enemy" },
1919
};
2020

21+
static const std::unordered_map<int32_t, const char*> language = {
22+
{ 0, "English" }, { 1, "Japanese" },
23+
};
24+
2125
#ifdef _DEBUG
2226
DebugLogOption defaultLogLevel = DEBUG_LOG_TRACE;
2327
#else
@@ -67,6 +71,14 @@ void GhostshipMenu::AddMenuDevTools() {
6771
})
6872
.PreFunc(
6973
[](WidgetInfo& info) { info.options->Disabled(!CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugMode"), 0)); });
74+
AddWidget(path, "Level Select Language", WIDGET_CVAR_COMBOBOX)
75+
.CVar(CVAR_DEVELOPER_TOOLS("BLSLanguage"))
76+
.Options(ComboboxOptions()
77+
.Tooltip("Language used in Better Level Select")
78+
.ComboMap(language))
79+
.PreFunc(
80+
[](WidgetInfo& info) { info.options->Disabled(!CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugMode"), 0) ||
81+
!CVarGetInteger(CVAR_DEVELOPER_TOOLS("BetterLevelSelect"), 0)); });
7082
AddWidget(path, "Draw Debug Info", WIDGET_CVAR_CHECKBOX)
7183
.CVar(CVAR_DEVELOPER_TOOLS("DrawDebugInfo"))
7284
.Options(CheckboxOptions().Tooltip("Draws Debug Related Information"));

0 commit comments

Comments
 (0)