mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-07 02:40:30 -05:00
improve cvar usage in AudioEditor (#2523)
Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
parent
95fe6b492b
commit
23d2e4a2cc
@ -196,7 +196,7 @@ void AudioCollection::AddToCollection(char* otrPath, uint16_t seqNum) {
|
|||||||
}
|
}
|
||||||
SequenceInfo info = {seqNum,
|
SequenceInfo info = {seqNum,
|
||||||
sequenceName,
|
sequenceName,
|
||||||
StringHelper::Replace(StringHelper::Replace(sequenceName, " ", "_"), "~", "-"),
|
StringHelper::Replace(StringHelper::Replace(StringHelper::Replace(sequenceName, " ", "_"), "~", "-"),".", ""),
|
||||||
type};
|
type};
|
||||||
sequenceMap.emplace(seqNum, info);
|
sequenceMap.emplace(seqNum, info);
|
||||||
}
|
}
|
||||||
@ -206,7 +206,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
|
// for Hyrule Field instead. Otherwise, leave it alone, so that without any sfx editor modifications we will
|
||||||
// play the normal track as usual.
|
// play the normal track as usual.
|
||||||
if (seqId == NA_BGM_FIELD_MORNING) {
|
if (seqId == NA_BGM_FIELD_MORNING) {
|
||||||
if (CVarGetInteger("gSfxEditor_NA_BGM_FIELD_LOGIC", NA_BGM_FIELD_LOGIC) != NA_BGM_FIELD_LOGIC) {
|
if (CVarGetInteger("gAudioEditor.ReplacedSequences.NA_BGM_FIELD_LOGIC", NA_BGM_FIELD_LOGIC) != NA_BGM_FIELD_LOGIC) {
|
||||||
seqId = NA_BGM_FIELD_LOGIC;
|
seqId = NA_BGM_FIELD_LOGIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ uint16_t AudioCollection::GetReplacementSequence(uint16_t seqId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto& sequenceInfo = sequenceMap.at(seqId);
|
const auto& sequenceInfo = sequenceMap.at(seqId);
|
||||||
const std::string cvarKey = "gSfxEditor_" + sequenceInfo.sfxKey;
|
const std::string cvarKey = "gAudioEditor.ReplacedSequences." + sequenceInfo.sfxKey;
|
||||||
int replacementSeq = CVarGetInteger(cvarKey.c_str(), seqId);
|
int replacementSeq = CVarGetInteger(cvarKey.c_str(), seqId);
|
||||||
if (!sequenceMap.contains(replacementSeq)) {
|
if (!sequenceMap.contains(replacementSeq)) {
|
||||||
replacementSeq = seqId;
|
replacementSeq = seqId;
|
||||||
@ -225,7 +225,7 @@ uint16_t AudioCollection::GetReplacementSequence(uint16_t seqId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) {
|
void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) {
|
||||||
const std::string cvarKey = "gExcludeSfx_" + seqInfo->sfxKey;
|
const std::string cvarKey = "gAudioEditor.Excluded." + seqInfo->sfxKey;
|
||||||
excludedSequences.insert(seqInfo);
|
excludedSequences.insert(seqInfo);
|
||||||
includedSequences.erase(seqInfo);
|
includedSequences.erase(seqInfo);
|
||||||
CVarSetInteger(cvarKey.c_str(), 1);
|
CVarSetInteger(cvarKey.c_str(), 1);
|
||||||
@ -233,7 +233,7 @@ void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) {
|
void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) {
|
||||||
const std::string cvarKey = "gExcludeSfx_" + seqInfo->sfxKey;
|
const std::string cvarKey = "gAudioEditor.Excluded." + seqInfo->sfxKey;
|
||||||
includedSequences.insert(seqInfo);
|
includedSequences.insert(seqInfo);
|
||||||
excludedSequences.erase(seqInfo);
|
excludedSequences.erase(seqInfo);
|
||||||
CVarClear(cvarKey.c_str());
|
CVarClear(cvarKey.c_str());
|
||||||
@ -244,7 +244,7 @@ void AudioCollection::InitializeShufflePool() {
|
|||||||
if (shufflePoolInitialized) return;
|
if (shufflePoolInitialized) return;
|
||||||
|
|
||||||
for (auto& [seqId, seqInfo] : sequenceMap) {
|
for (auto& [seqId, seqInfo] : sequenceMap) {
|
||||||
const std::string cvarKey = "gExcludeSfx_" + seqInfo.sfxKey;
|
const std::string cvarKey = "gAudioEditor.Excluded." + seqInfo.sfxKey;
|
||||||
if (CVarGetInteger(cvarKey.c_str(), 0)) {
|
if (CVarGetInteger(cvarKey.c_str(), 0)) {
|
||||||
excludedSequences.insert(&seqInfo);
|
excludedSequences.insert(&seqInfo);
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +92,7 @@ void RandomizeGroup(SeqType type) {
|
|||||||
}
|
}
|
||||||
Shuffle(values);
|
Shuffle(values);
|
||||||
for (const auto& [seqId, seqData] : AudioCollection::Instance->GetAllSequences()) {
|
for (const auto& [seqId, seqData] : AudioCollection::Instance->GetAllSequences()) {
|
||||||
const std::string cvarKey = "gSfxEditor_" + seqData.sfxKey;
|
const std::string cvarKey = "gAudioEditor.ReplacedSequences." + seqData.sfxKey;
|
||||||
if (seqData.category & type) {
|
if (seqData.category & type) {
|
||||||
// Only save authentic sequence CVars
|
// Only save authentic sequence CVars
|
||||||
if (((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && seqData.sequenceId >= MAX_AUTHENTIC_SEQID) {
|
if (((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && seqData.sequenceId >= MAX_AUTHENTIC_SEQID) {
|
||||||
@ -112,28 +112,28 @@ void ResetGroup(const std::map<u16, SequenceInfo>& map, SeqType type) {
|
|||||||
if (seqData.category == SEQ_FANFARE && defaultValue >= MAX_AUTHENTIC_SEQID) {
|
if (seqData.category == SEQ_FANFARE && defaultValue >= MAX_AUTHENTIC_SEQID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const std::string cvarKey = "gSfxEditor_" + seqData.sfxKey;
|
const std::string cvarKey = "gAudioEditor.ReplacedSequences." + seqData.sfxKey;
|
||||||
CVarSetInteger(cvarKey.c_str(), defaultValue);
|
CVarSetInteger(cvarKey.c_str(), defaultValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPreviewButton(uint16_t sequenceId, std::string sfxKey, SeqType sequenceType) {
|
void DrawPreviewButton(uint16_t sequenceId, std::string sfxKey, SeqType sequenceType) {
|
||||||
const std::string cvarKey = "gSfxEditor_" + sfxKey;
|
const std::string cvarKey = "gAudioEditor.ReplacedSequences." + sfxKey;
|
||||||
const std::string hiddenKey = "##" + cvarKey;
|
const std::string hiddenKey = "##" + cvarKey;
|
||||||
const std::string stopButton = " Stop " + hiddenKey;
|
const std::string stopButton = " Stop " + hiddenKey;
|
||||||
const std::string previewButton = "Preview" + hiddenKey;
|
const std::string previewButton = "Preview" + hiddenKey;
|
||||||
|
|
||||||
if (CVarGetInteger("gSfxEditor_playing", 0) == sequenceId) {
|
if (CVarGetInteger("gAudioEditor.Playing", 0) == sequenceId) {
|
||||||
if (ImGui::Button(stopButton.c_str())) {
|
if (ImGui::Button(stopButton.c_str())) {
|
||||||
func_800F5C2C();
|
func_800F5C2C();
|
||||||
CVarSetInteger("gSfxEditor_playing", 0);
|
CVarSetInteger("gAudioEditor.Playing", 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::Button(previewButton.c_str())) {
|
if (ImGui::Button(previewButton.c_str())) {
|
||||||
if (CVarGetInteger("gSfxEditor_playing", 0) != 0) {
|
if (CVarGetInteger("gAudioEditor.Playing", 0) != 0) {
|
||||||
func_800F5C2C();
|
func_800F5C2C();
|
||||||
CVarSetInteger("gSfxEditor_playing", 0);
|
CVarSetInteger("gAudioEditor.Playing", 0);
|
||||||
} else {
|
} else {
|
||||||
if (sequenceType == SEQ_SFX) {
|
if (sequenceType == SEQ_SFX) {
|
||||||
Audio_PlaySoundGeneral(sequenceId, &pos, 4, &freqScale, &freqScale, &reverbAdd);
|
Audio_PlaySoundGeneral(sequenceId, &pos, 4, &freqScale, &freqScale, &reverbAdd);
|
||||||
@ -143,7 +143,7 @@ void DrawPreviewButton(uint16_t sequenceId, std::string sfxKey, SeqType sequence
|
|||||||
} else {
|
} else {
|
||||||
// TODO: Cant do both here, so have to click preview button twice
|
// TODO: Cant do both here, so have to click preview button twice
|
||||||
PreviewSequence(sequenceId);
|
PreviewSequence(sequenceId);
|
||||||
CVarSetInteger("gSfxEditor_playing", sequenceId);
|
CVarSetInteger("gAudioEditor.Playing", sequenceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string cvarKey = "gSfxEditor_" + seqData.sfxKey;
|
const std::string cvarKey = "gAudioEditor.ReplacedSequences." + seqData.sfxKey;
|
||||||
const std::string hiddenKey = "##" + cvarKey;
|
const std::string hiddenKey = "##" + cvarKey;
|
||||||
const std::string resetButton = "Reset" + hiddenKey;
|
const std::string resetButton = "Reset" + hiddenKey;
|
||||||
const std::string randomizeButton = "Randomize" + hiddenKey;
|
const std::string randomizeButton = "Randomize" + hiddenKey;
|
||||||
@ -308,7 +308,7 @@ void DrawTypeChip(SeqType type) {
|
|||||||
|
|
||||||
void DrawSfxEditor(bool& open) {
|
void DrawSfxEditor(bool& open) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
CVarSetInteger("gSfxEditor", 0);
|
CVarSetInteger("gAudioEditor.WindowOpen", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ void DrawSfxEditor(bool& open) {
|
|||||||
|
|
||||||
void InitAudioEditor() {
|
void InitAudioEditor() {
|
||||||
//Draw the bar in the menu.
|
//Draw the bar in the menu.
|
||||||
SohImGui::AddWindow("Enhancements", "SFX Editor", DrawSfxEditor);
|
SohImGui::AddWindow("Enhancements", "Audio Editor", DrawSfxEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SeqType> allTypes = { SEQ_BGM_WORLD, SEQ_BGM_EVENT, SEQ_BGM_BATTLE, SEQ_OCARINA, SEQ_FANFARE, SEQ_INSTRUMENT, SEQ_SFX };
|
std::vector<SeqType> allTypes = { SEQ_BGM_WORLD, SEQ_BGM_EVENT, SEQ_BGM_BATTLE, SEQ_OCARINA, SEQ_FANFARE, SEQ_INSTRUMENT, SEQ_SFX };
|
||||||
|
@ -842,12 +842,12 @@ namespace GameMenuBar {
|
|||||||
SohImGui::RequestCvarSaveOnNextTick();
|
SohImGui::RequestCvarSaveOnNextTick();
|
||||||
SohImGui::EnableWindow("Cosmetics Editor", CVarGetInteger("gCosmeticsEditorEnabled", 0));
|
SohImGui::EnableWindow("Cosmetics Editor", CVarGetInteger("gCosmeticsEditorEnabled", 0));
|
||||||
}
|
}
|
||||||
if (ImGui::Button(GetWindowButtonText("Audio Editor", CVarGetInteger("gSfxEditor", 0)).c_str(), ImVec2(-1.0f, 0.0f)))
|
if (ImGui::Button(GetWindowButtonText("Audio Editor", CVarGetInteger("gAudioEditor.WindowOpen", 0)).c_str(), ImVec2(-1.0f, 0.0f)))
|
||||||
{
|
{
|
||||||
bool currentValue = CVarGetInteger("gSfxEditor", 0);
|
bool currentValue = CVarGetInteger("gAudioEditor.WindowOpen", 0);
|
||||||
CVarSetInteger("gSfxEditor", !currentValue);
|
CVarSetInteger("gAudioEditor.WindowOpen", !currentValue);
|
||||||
SohImGui::RequestCvarSaveOnNextTick();
|
SohImGui::RequestCvarSaveOnNextTick();
|
||||||
SohImGui::EnableWindow("SFX Editor", CVarGetInteger("gSfxEditor", 0));
|
SohImGui::EnableWindow("Audio Editor", CVarGetInteger("gAudioEditor.WindowOpen", 0));
|
||||||
}
|
}
|
||||||
if (ImGui::Button(GetWindowButtonText("Gameplay Stats", CVarGetInteger("gGameplayStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) {
|
if (ImGui::Button(GetWindowButtonText("Gameplay Stats", CVarGetInteger("gGameplayStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) {
|
||||||
bool currentValue = CVarGetInteger("gGameplayStatsEnabled", 0);
|
bool currentValue = CVarGetInteger("gGameplayStatsEnabled", 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user