Skip to content

Commit

Permalink
fix(zq): dmap midi dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosh64 committed Aug 20, 2023
1 parent 833660a commit 01a98d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/dialog/edit_dmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EditDMapDialog::EditDMapDialog(int32_t slot) :
list_strings(GUI::ZCListData::strings()),
list_activesub(GUI::ZCListData::activesubscreens()),
list_passivesub(GUI::ZCListData::passivesubscreens()),
list_midis(GUI::ZCListData::midinames()),
list_midis(GUI::ZCListData::midinames(false, true)),
list_tracks(GUI::ListData::numbers(false, 1, 1)),
list_disableditems(GUI::ZCListData::disableditems(local_dmap.disableditems)),
list_items(GUI::ZCListData::items(false, false)),
Expand Down Expand Up @@ -449,10 +449,10 @@ std::shared_ptr<GUI::Widget> EditDMapDialog::view()
Label(text = "Midi:"),
DropDownList(data = list_midis,
fitParent = true,
selectedValue = local_dmap.midi + 1,
selectedValue = local_dmap.midi,
onSelectFunc = [&](int32_t val)
{
local_dmap.midi = val - 1;
local_dmap.midi = val;
})
),
Frame(title = "Enhanced Music",
Expand Down
12 changes: 10 additions & 2 deletions src/zc_list_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,20 +643,28 @@ GUI::ListData GUI::ZCListData::sfxnames(bool numbered)

return ls;
}
GUI::ListData GUI::ZCListData::midinames(bool numbered)
GUI::ListData GUI::ZCListData::midinames(bool numbered, bool incl_engine)
{
std::map<std::string, int32_t> vals;

GUI::ListData ls;
ls.add("(None)", 0);
auto ofs = 1;
if (incl_engine)
{
ls.add("Overworld", 1);
ls.add("Dungeon", 2);
ls.add("Level 9", 3);
ofs = 4;
}
for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
{
char const* midi_name = customtunes[i].title;
char* name = new char[strlen(midi_name) + 7];
if(numbered)
sprintf(name, "%s (%03d)", midi_name, i+1);
else strcpy(name, midi_name);
ls.add(name, i+1);
ls.add(name, i+ofs);
delete[] name;
}

Expand Down
2 changes: 1 addition & 1 deletion src/zc_list_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace GUI::ZCListData
GUI::ListData lweaptypes();
GUI::ListData weaptypes(bool numbered = false);
GUI::ListData sfxnames(bool numbered = false);
GUI::ListData midinames(bool numbered = false);
GUI::ListData midinames(bool numbered = false, bool incl_engine = false);
GUI::ListData itemdata_script();
GUI::ListData itemsprite_script();
GUI::ListData ffc_script();
Expand Down

0 comments on commit 01a98d5

Please sign in to comment.