mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-22 09:22: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::PushItemWidth(-FLT_MIN);
|
||||
if (ImGui::Button(randomizeButton.c_str())) {
|
||||
bool valid = false;
|
||||
uint32_t value;
|
||||
while (!valid) {
|
||||
value = Random(2, map.size());
|
||||
if (map.contains(value)) {
|
||||
auto [name, sfxKey, seqType] = map.at(value);
|
||||
while (true) {
|
||||
auto it = map.begin();
|
||||
std::advance(it, rand() % map.size());
|
||||
const auto& [value, seqData] = *it;
|
||||
const auto& [name, sfxKey, seqType] = seqData;
|
||||
if (seqType & type) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
CVar_SetS32(cvarKey.c_str(), value);
|
||||
SohImGui::RequestCvarSaveOnNextTick();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
@ -355,7 +353,7 @@ void DrawSfxEditor(bool& open) {
|
||||
CVar_SetS32("gSfxEditor", 0);
|
||||
return;
|
||||
}
|
||||
ImGui::SetNextWindowSize(ImVec2(465, 630), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(900, 630), ImGuiCond_FirstUseEver);
|
||||
if (!ImGui::Begin("SFX Editor", &open)) {
|
||||
ImGui::End();
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user