mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-26 03:12:18 -05:00
Fixes crash during randomization of individual sound effects. (#2203)
* Fixes randomization of individual sound effects. * Re-adds the mistakenly removed const specifier. * Implements new randomization syntax that actually fixes the crash. * Increases default width of sfx editor menu. The default width was cutting off a lot of the text in the dropdowns due to the added Randomize button.
This commit is contained in:
parent
4999df5395
commit
56ac27b8f4
@ -297,19 +297,17 @@ void Draw_SfxTab(const std::string& tabId, const std::map<u16, std::tuple<std::s
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushItemWidth(-FLT_MIN);
|
ImGui::PushItemWidth(-FLT_MIN);
|
||||||
if (ImGui::Button(randomizeButton.c_str())) {
|
if (ImGui::Button(randomizeButton.c_str())) {
|
||||||
bool valid = false;
|
while (true) {
|
||||||
uint32_t value;
|
auto it = map.begin();
|
||||||
while (!valid) {
|
std::advance(it, rand() % map.size());
|
||||||
value = Random(2, map.size());
|
const auto& [value, seqData] = *it;
|
||||||
if (map.contains(value)) {
|
const auto& [name, sfxKey, seqType] = seqData;
|
||||||
auto [name, sfxKey, seqType] = map.at(value);
|
if (seqType & type) {
|
||||||
if (seqType & type) {
|
CVar_SetS32(cvarKey.c_str(), value);
|
||||||
valid = true;
|
SohImGui::RequestCvarSaveOnNextTick();
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CVar_SetS32(cvarKey.c_str(), value);
|
|
||||||
SohImGui::RequestCvarSaveOnNextTick();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
@ -355,7 +353,7 @@ void DrawSfxEditor(bool& open) {
|
|||||||
CVar_SetS32("gSfxEditor", 0);
|
CVar_SetS32("gSfxEditor", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImGui::SetNextWindowSize(ImVec2(465, 630), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(900, 630), ImGuiCond_FirstUseEver);
|
||||||
if (!ImGui::Begin("SFX Editor", &open)) {
|
if (!ImGui::Begin("SFX Editor", &open)) {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user