From d7b225fa244e19bb93bc202d9e804bc80111f96c Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 18 Jun 2025 12:49:54 -0500 Subject: [PATCH] Show custom sounds without names in picker. fix #761 --- src/scenedit/scen.keydlgs.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index 210a2fa5..bbf7bed5 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -1039,9 +1039,25 @@ static short choose_boom_type(short cur, cDialog* parent) { } snd_num_t choose_sound(short cur, cDialog* parent, std::string title) { + extern fs::path tempDir; + extern std::string scenario_temp_dir_name; + if(cur < 0) cur = 0; StringList snd_names = *ResMgr::strings.get("sound-names"); std::copy(scenario.snd_names.begin(), scenario.snd_names.end(), std::back_inserter(snd_names)); + + if(fs::is_directory(tempDir/scenario_temp_dir_name/"sounds")) { + for(fs::directory_iterator iter(tempDir/scenario_temp_dir_name/"sounds"); iter != fs::directory_iterator(); iter++) { + std::string fname = iter->path().filename().string(); + int num = std::stoi(fname.substr(3)); + if(snd_names.size() <= num){ + snd_names.resize(num + 1); + } + if(snd_names[num].empty()) + snd_names[num] = fname + " (unnamed)"; + } + } + cStringChoice snd_dlg(snd_names, title, parent); snd_dlg.attachSelectHandler([](cStringChoice&, int n) { force_play_sound(-n);