Skip to content

Commit

Permalink
CVar Macro Cleanup (HarbourMasters#4062)
Browse files Browse the repository at this point in the history
* Standardized CVar macros to have `CVAR_` at the front instead of the end.
Removed excluded and replaced sequence macros.

* Missed a few developer CVars outside of `SohMenuBar.cpp`

* 1 more.
  • Loading branch information
Malkierian authored Apr 21, 2024
1 parent e2622af commit 33aef87
Show file tree
Hide file tree
Showing 55 changed files with 1,291 additions and 1,293 deletions.
12 changes: 6 additions & 6 deletions soh/soh/Enhancements/audio/AudioCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ AudioCollection::AudioCollection() {
}

std::string AudioCollection::GetCvarKey(std::string sfxKey) {
auto prefix = AUDIO_CVAR("ReplacedSequences.");
auto prefix = CVAR_AUDIO("ReplacedSequences.");
return prefix + sfxKey + ".value";
}

std::string AudioCollection::GetCvarLockKey(std::string sfxKey) {
auto prefix = std::string(AUDIO_CVAR("ReplacedSequences."));
auto prefix = std::string(CVAR_AUDIO("ReplacedSequences."));
return prefix + sfxKey + ".locked";
}

Expand Down Expand Up @@ -365,7 +365,7 @@ uint16_t AudioCollection::GetReplacementSequence(uint16_t seqId) {
// for Hyrule Field instead. Otherwise, leave it alone, so that without any sfx editor modifications we will
// play the normal track as usual.
if (seqId == NA_BGM_FIELD_MORNING) {
if (CVarGetInteger(AUDIO_CVAR("ReplacedSequences.NA_BGM_FIELD_LOGIC.value"), NA_BGM_FIELD_LOGIC) != NA_BGM_FIELD_LOGIC) {
if (CVarGetInteger(CVAR_AUDIO("ReplacedSequences.NA_BGM_FIELD_LOGIC.value"), NA_BGM_FIELD_LOGIC) != NA_BGM_FIELD_LOGIC) {
seqId = NA_BGM_FIELD_LOGIC;
}
}
Expand All @@ -384,15 +384,15 @@ uint16_t AudioCollection::GetReplacementSequence(uint16_t seqId) {
}

void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) {
const std::string cvarKey = std::string(AUDIO_CVAR("Excluded.")) + seqInfo->sfxKey;
const std::string cvarKey = std::string(CVAR_AUDIO("Excluded.")) + seqInfo->sfxKey;
excludedSequences.insert(seqInfo);
includedSequences.erase(seqInfo);
CVarSetInteger(cvarKey.c_str(), 1);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}

void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) {
const std::string cvarKey = std::string(AUDIO_CVAR("Excluded.")) + seqInfo->sfxKey;
const std::string cvarKey = std::string(CVAR_AUDIO("Excluded.")) + seqInfo->sfxKey;
includedSequences.insert(seqInfo);
excludedSequences.erase(seqInfo);
CVarClear(cvarKey.c_str());
Expand All @@ -404,7 +404,7 @@ void AudioCollection::InitializeShufflePool() {

for (auto& [seqId, seqInfo] : sequenceMap) {
if (!seqInfo.canBeUsedAsReplacement) continue;
const std::string cvarKey = std::string(AUDIO_CVAR("Excluded.")) + seqInfo.sfxKey;
const std::string cvarKey = std::string(CVAR_AUDIO("Excluded.")) + seqInfo.sfxKey;
if (CVarGetInteger(cvarKey.c_str(), 0)) {
excludedSequences.insert(&seqInfo);
} else {
Expand Down
28 changes: 14 additions & 14 deletions soh/soh/Enhancements/audio/AudioEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ void DrawPreviewButton(uint16_t sequenceId, std::string sfxKey, SeqType sequence
const std::string stopButton = ICON_FA_STOP + hiddenKey;
const std::string previewButton = ICON_FA_PLAY + hiddenKey;

if (CVarGetInteger(AUDIO_CVAR("Playing"), 0) == sequenceId) {
if (CVarGetInteger(CVAR_AUDIO("Playing"), 0) == sequenceId) {
if (ImGui::Button(stopButton.c_str())) {
func_800F5C2C();
CVarSetInteger(AUDIO_CVAR("Playing"), 0);
CVarSetInteger(CVAR_AUDIO("Playing"), 0);
}
UIWidgets::Tooltip("Stop Preview");
} else {
if (ImGui::Button(previewButton.c_str())) {
if (CVarGetInteger(AUDIO_CVAR("Playing"), 0) != 0) {
if (CVarGetInteger(CVAR_AUDIO("Playing"), 0) != 0) {
func_800F5C2C();
CVarSetInteger(AUDIO_CVAR("Playing"), 0);
CVarSetInteger(CVAR_AUDIO("Playing"), 0);
} else {
if (sequenceType == SEQ_SFX || sequenceType == SEQ_VOICE) {
Audio_PlaySoundGeneral(sequenceId, &pos, 4, &freqScale, &freqScale, &reverbAdd);
Expand All @@ -183,7 +183,7 @@ void DrawPreviewButton(uint16_t sequenceId, std::string sfxKey, SeqType sequence
} else {
// TODO: Cant do both here, so have to click preview button twice
PreviewSequence(sequenceId);
CVarSetInteger(AUDIO_CVAR("Playing"), sequenceId);
CVarSetInteger(CVAR_AUDIO("Playing"), sequenceId);
}
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ void DrawTypeChip(SeqType type) {

void AudioEditorRegisterOnSceneInitHook() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int16_t sceneNum) {
if (CVarGetInteger(AUDIO_CVAR("RandomizeAllOnNewScene"), 0)) {
if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnNewScene"), 0)) {
AudioEditor_RandomizeAll();
}
});
Expand Down Expand Up @@ -492,47 +492,47 @@ void AudioEditor::DrawElement() {
ImGui::TableNextColumn();
if (ImGui::BeginChild("SfxOptions", ImVec2(0, -8))) {
ImGui::PushItemWidth(-FLT_MIN);
UIWidgets::EnhancementCheckbox("Disable Enemy Proximity Music", AUDIO_CVAR("EnemyBGMDisable"));
UIWidgets::EnhancementCheckbox("Disable Enemy Proximity Music", CVAR_AUDIO("EnemyBGMDisable"));
UIWidgets::InsertHelpHoverText(
"Disables the music change when getting close to enemies. Useful for hearing "
"your custom music for each scene more often.");
UIWidgets::EnhancementCheckbox("Disable Leading Music in Lost Woods", AUDIO_CVAR("LostWoodsConsistentVolume"));
UIWidgets::EnhancementCheckbox("Disable Leading Music in Lost Woods", CVAR_AUDIO("LostWoodsConsistentVolume"));
UIWidgets::InsertHelpHoverText(
"Disables the volume shifting in the Lost Woods. Useful for hearing "
"your custom music in the Lost Woods if you don't need the navigation assitance "
"the volume changing provides. If toggling this while in the Lost Woods, reload "
"the area for the effect to kick in."
);
UIWidgets::EnhancementCheckbox("Display Sequence Name on Overlay", AUDIO_CVAR("SeqNameOverlay"));
UIWidgets::EnhancementCheckbox("Display Sequence Name on Overlay", CVAR_AUDIO("SeqNameOverlay"));
UIWidgets::InsertHelpHoverText(
"Displays the name of the current sequence in the corner of the screen whenever a new sequence "
"is loaded to the main sequence player (does not apply to fanfares or enemy BGM)."
);
ImGui::SameLine();
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
UIWidgets::EnhancementSliderInt("Overlay Duration: %d seconds", "##SeqNameOverlayDuration",
AUDIO_CVAR("SeqNameOverlayDuration"), 1, 10, "", 5);
CVAR_AUDIO("SeqNameOverlayDuration"), 1, 10, "", 5);
ImGui::PopItemWidth();
ImGui::NewLine();
ImGui::PopItemWidth();
UIWidgets::EnhancementSliderFloat("Link's voice pitch multiplier: %.1f %%", "##linkVoiceFreqMultiplier",
AUDIO_CVAR("LinkVoiceFreqMultiplier"), 0.4, 2.5, "", 1.0, true, true);
CVAR_AUDIO("LinkVoiceFreqMultiplier"), 0.4, 2.5, "", 1.0, true, true);
ImGui::SameLine();
const std::string resetButton = "Reset##linkVoiceFreqMultiplier";
if (ImGui::Button(resetButton.c_str())) {
CVarSetFloat(AUDIO_CVAR("LinkVoiceFreqMultiplier"), 1.0f);
CVarSetFloat(CVAR_AUDIO("LinkVoiceFreqMultiplier"), 1.0f);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}

ImGui::NewLine();
UIWidgets::EnhancementCheckbox("Randomize All Music and Sound Effects on New Scene", AUDIO_CVAR("RandomizeAllOnNewScene"));
UIWidgets::EnhancementCheckbox("Randomize All Music and Sound Effects on New Scene", CVAR_AUDIO("RandomizeAllOnNewScene"));
UIWidgets::Tooltip("Enables randomizing all unlocked music and sound effects when you enter a new scene.");

ImGui::NewLine();
ImGui::PushItemWidth(-FLT_MIN);
UIWidgets::PaddedSeparator();
UIWidgets::PaddedText("The following options are experimental and may cause music\nto sound odd or have other undesireable effects.");
UIWidgets::EnhancementCheckbox("Lower Octaves of Unplayable High Notes", AUDIO_CVAR("ExperimentalOctaveDrop"));
UIWidgets::EnhancementCheckbox("Lower Octaves of Unplayable High Notes", CVAR_AUDIO("ExperimentalOctaveDrop"));
UIWidgets::InsertHelpHoverText("Some custom sequences may have notes that are too high for the game's audio "
"engine to play. Enabling this checkbox will cause these notes to drop a "
"couple of octaves so they can still harmonize with the other notes of the "
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/controls/InputViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex
}

void InputViewer::DrawElement() {
if (CVarGetInteger(WINDOW_CVAR("InputViewer"), 0)) {
if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) {
static bool sButtonTexturesLoaded = false;
if (!sButtonTexturesLoaded) {
LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage(
Expand Down
6 changes: 3 additions & 3 deletions soh/soh/Enhancements/controls/SohInputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ void SohInputEditorWindow::DrawMiscControlPanel() {
UIWidgets::Tooltip("Allows the cursor on the pause menu to be over any slot. Sometimes required in rando to select "
"certain items.");
UIWidgets::Spacer(0);
ImGui::BeginDisabled(CVarGetInteger(SETTING_CVAR("DisableChanges"), 0));
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0));
UIWidgets::PaddedEnhancementCheckbox("Enable speed modifiers", "gEnableWalkModify", true, false);
UIWidgets::Tooltip("Hold the assigned button to change the maximum walking or swimming speed");
if (CVarGetInteger("gEnableWalkModify", 0)) {
Expand Down Expand Up @@ -1839,7 +1839,7 @@ void SohInputEditorWindow::DrawLinkTab() {
}

void SohInputEditorWindow::DrawIvanTab() {
if (CVarGetInteger("gDebugEnabled", 0)) {
if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0)) {
DrawDebugPortTab(1, "Ivan (P2)");
return;
}
Expand Down Expand Up @@ -2246,7 +2246,7 @@ void SohInputEditorWindow::DrawElement() {
ImGui::BeginTabBar("##ControllerConfigPortTabs");
DrawLinkTab();
DrawIvanTab();
if (CVarGetInteger("gDebugEnabled", 0)) {
if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0)) {
DrawDebugPortTab(2);
DrawDebugPortTab(3);
}
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ void Reset_Option_Double(const char* Button_Title, const char* name) {
}
}
void DrawSillyTab() {
ImGui::BeginDisabled(CVarGetInteger(SETTING_CVAR("DisableChanges"), 0));
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0));
if (CVarGetInteger("gLetItSnow", 0)) {
if (UIWidgets::EnhancementCheckbox("Let It Snow", "gLetItSnow")) {
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void GameInteractor::EnableRemoteInteractor() {
return;
}

if (SDLNet_ResolveHost(&remoteIP, CVarGetString(REMOTE_CVAR("IP"), "127.0.0.1"), CVarGetInteger(REMOTE_CVAR("Port"), 43384)) == -1) {
if (SDLNet_ResolveHost(&remoteIP, CVarGetString(CVAR_REMOTE("IP"), "127.0.0.1"), CVarGetInteger(CVAR_REMOTE("Port"), 43384)) == -1) {
SPDLOG_ERROR("[GameInteractor] SDLNet_ResolveHost: {}", SDLNet_GetError());
}

Expand Down
26 changes: 13 additions & 13 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ReloadSceneTogglingLinkAge() {
void RegisterInfiniteMoney() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger(CHEAT_CVAR("InfiniteMoney"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("InfiniteMoney"), 0) != 0) {
if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) {
gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET);
}
Expand All @@ -77,7 +77,7 @@ void RegisterInfiniteMoney() {
void RegisterInfiniteHealth() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger(CHEAT_CVAR("InfiniteHealth"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("InfiniteHealth"), 0) != 0) {
if (gSaveContext.health < gSaveContext.healthCapacity) {
gSaveContext.health = gSaveContext.healthCapacity;
}
Expand All @@ -88,7 +88,7 @@ void RegisterInfiniteHealth() {
void RegisterInfiniteAmmo() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger(CHEAT_CVAR("InfiniteAmmo"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("InfiniteAmmo"), 0) != 0) {
// Deku Sticks
if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) {
AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS);
Expand Down Expand Up @@ -125,7 +125,7 @@ void RegisterInfiniteAmmo() {
void RegisterInfiniteMagic() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger(CHEAT_CVAR("InfiniteMagic"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("InfiniteMagic"), 0) != 0) {
if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) {
gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30;
}
Expand All @@ -136,7 +136,7 @@ void RegisterInfiniteMagic() {
void RegisterInfiniteNayrusLove() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger(CHEAT_CVAR("InfiniteNayru"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("InfiniteNayru"), 0) != 0) {
gSaveContext.nayrusLoveTimer = 0x44B;
}
});
Expand All @@ -146,7 +146,7 @@ void RegisterMoonJumpOnL() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;

if (CVarGetInteger(CHEAT_CVAR("MoonJumpOnL"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("MoonJumpOnL"), 0) != 0) {
Player* player = GET_PLAYER(gPlayState);

if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) {
Expand All @@ -161,7 +161,7 @@ void RegisterInfiniteISG() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;

if (CVarGetInteger(CHEAT_CVAR("EasyISG"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("EasyISG"), 0) != 0) {
Player* player = GET_PLAYER(gPlayState);
player->meleeWeaponState = 1;
}
Expand All @@ -173,7 +173,7 @@ void RegisterEzQPA() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;

if (CVarGetInteger(CHEAT_CVAR("EasyQPA"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("EasyQPA"), 0) != 0) {
Player* player = GET_PLAYER(gPlayState);
player->meleeWeaponQuads[0].info.toucher.dmgFlags = 0x16171617;
player->meleeWeaponQuads[1].info.toucher.dmgFlags = 0x16171617;
Expand All @@ -185,7 +185,7 @@ void RegisterUnrestrictedItems() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded(true)) return;

if (CVarGetInteger(CHEAT_CVAR("NoRestrictItems"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("NoRestrictItems"), 0) != 0) {
u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
memset(&gPlayState->interfaceCtx.restrictions, 0, sizeof(gPlayState->interfaceCtx.restrictions));
gPlayState->interfaceCtx.restrictions.sunsSong = sunsBackup;
Expand All @@ -195,7 +195,7 @@ void RegisterUnrestrictedItems() {

void RegisterFreezeTime() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (CVarGetInteger(CHEAT_CVAR("FreezeTime"), 0) != 0) {
if (CVarGetInteger(CVAR_CHEAT("FreezeTime"), 0) != 0) {
if (CVarGetInteger("gPrevTime", -1) == -1) {
CVarSetInteger("gPrevTime", gSaveContext.dayTime);
}
Expand All @@ -214,7 +214,7 @@ void RegisterSwitchAge() {
static bool warped = false;

if (!GameInteractor::IsSaveLoaded(true)) {
CVarClear(GENERAL_CVAR("SwitchAge"));
CVarClear(CVAR_GENERAL("SwitchAge"));
warped = false;
return;
}
Expand All @@ -224,7 +224,7 @@ void RegisterSwitchAge() {
static RoomContext* roomCtx;
static s32 roomNum;

if (CVarGetInteger(GENERAL_CVAR("SwitchAge"), 0) && !warped) {
if (CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) && !warped) {
playerPos = GET_PLAYER(gPlayState)->actor.world.pos;
playerYaw = GET_PLAYER(gPlayState)->actor.shape.rot.y;
roomCtx = &gPlayState->roomCtx;
Expand All @@ -243,7 +243,7 @@ void RegisterSwitchAge() {
func_80097534(gPlayState, roomCtx); // load map for new room (unloading the previous room)
}
warped = false;
CVarClear(GENERAL_CVAR("SwitchAge"));
CVarClear(CVAR_GENERAL("SwitchAge"));
}
});
}
Expand Down
Loading

0 comments on commit 33aef87

Please sign in to comment.