diff --git a/src/dialog/edit_dmap.cpp b/src/dialog/edit_dmap.cpp index fbfae1f3b1..60bab2e528 100644 --- a/src/dialog/edit_dmap.cpp +++ b/src/dialog/edit_dmap.cpp @@ -5,6 +5,7 @@ #include "zq/zq_class.h" #include "zc_list_data.h" #include "info.h" +#include "subscr.h" #include #include @@ -40,8 +41,9 @@ EditDMapDialog::EditDMapDialog(int32_t slot) : list_types(GUI::ZCListData::dmaptypes()), list_lpals(GUI::ZCListData::lpals()), list_strings(GUI::ZCListData::strings()), - list_activesub(GUI::ZCListData::activesubscreens()), - list_passivesub(GUI::ZCListData::passivesubscreens()), + list_activesub(GUI::ZCListData::subscreens(sstACTIVE, true)), + list_passivesub(GUI::ZCListData::subscreens(sstPASSIVE, true)), + list_overlaysub(GUI::ZCListData::subscreens(sstOVERLAY, true)), list_midis(GUI::ZCListData::midinames()), list_tracks(GUI::ListData::numbers(false, 1, 1)), list_disableditems(GUI::ZCListData::disableditems(local_dmap.disableditems)), @@ -309,7 +311,8 @@ std::shared_ptr EditDMapDialog::view() onValChangedFunc = [&](GUI::TextField::type, std::string_view, int32_t val) { local_dmap.mirrorDMap = val; - }) + }), + INFOBTN("If '> -1', the Mirror will warp you to the specified dmap from this dmap.") ), Row(colSpan = 2, hAlign = 0.0, INFOBTN("Sets the player's continue point to the continue screen when entering this DMap in most circumstances."), @@ -424,24 +427,41 @@ std::shared_ptr EditDMapDialog::view() }) ) ), - Rows<2>( + Rows<3>( framed = true, frameText = "Subscreens", Label(text = "Active:"), DropDownList(data = list_activesub, - fitParent = true, - selectedValue = local_dmap.active_subscreen + 1, + fitParent = true, hAlign = 1.0, + selectedValue = local_dmap.active_subscreen, + disabled = list_activesub.invalid(), onSelectFunc = [&](int32_t val) { - local_dmap.active_subscreen = val - 1; + local_dmap.active_subscreen = val; }), + INFOBTN("The active subscreen to use on this dmap. This is " + " the menu that appears when you press 'Start'."), Label(text = "Passive:"), DropDownList(data = list_passivesub, - fitParent = true, - selectedValue = local_dmap.passive_subscreen + 1, + fitParent = true, hAlign = 1.0, + selectedValue = local_dmap.passive_subscreen, + disabled = list_passivesub.invalid(), onSelectFunc = [&](int32_t val) { - local_dmap.passive_subscreen = val - 1; - }) + local_dmap.passive_subscreen = val; + }), + INFOBTN("The passive subscreen to use on this dmap. This is " + " the menu that draws at the top of the screen."), + Label(text = "Overlay:"), + DropDownList(data = list_overlaysub, + fitParent = true, hAlign = 1.0, + selectedValue = local_dmap.overlay_subscreen, + disabled = list_overlaysub.invalid(), + onSelectFunc = [&](int32_t val) + { + local_dmap.overlay_subscreen = val; + }), + INFOBTN("The overlay subscreen to use on this dmap. This is " + " the menu that draws OVER the entire screen.") ) )), TabRef(name = "Music", Column( @@ -760,9 +780,14 @@ std::shared_ptr EditDMapDialog::view() DMAP_SS_INITD(7) ), Column(padding = 0_px, fitParent = true, - Rows<2>(vAlign = 0.0, + Rows<3>(vAlign = 0.0, SCRIPT_LIST_PROC("Active:", list_dmapscript, local_dmap.active_sub_script, refreshScripts), - SCRIPT_LIST_PROC("Passive:", list_dmapscript, local_dmap.passive_sub_script, refreshScripts) + INFOBTN("If a script is assigned to this slot, it will run when you press 'Start'." + " This script runs INSTEAD of the engine's Active Subscreen opening," + " and all action is frozen including other scripts until this script exits."), + SCRIPT_LIST_PROC("Passive:", list_dmapscript, local_dmap.passive_sub_script, refreshScripts), + INFOBTN("Runs at timings consistent with the engine passive subscreen." + " Useful for drawing custom UI draws.") ), Row(hAlign = 1.0, Label(text = "Script Info:"), @@ -793,8 +818,11 @@ std::shared_ptr EditDMapDialog::view() DMAP_MAP_INITD(7) ), Column(padding = 0_px, fitParent = true, - Rows<2>(vAlign = 0.0, - SCRIPT_LIST_PROC("On Map:", list_dmapscript, local_dmap.onmap_script, refreshScripts) + Rows<3>(vAlign = 0.0, + SCRIPT_LIST_PROC("On Map:", list_dmapscript, local_dmap.onmap_script, refreshScripts), + INFOBTN("If a script is assigned to this slot, it will run when you press 'Map'." + " This script runs INSTEAD of the engine's Map opening," + " and all action is frozen including other scripts until this script exits.") ) ) ) diff --git a/src/dialog/edit_dmap.h b/src/dialog/edit_dmap.h index 9afba775fa..aa972628bc 100644 --- a/src/dialog/edit_dmap.h +++ b/src/dialog/edit_dmap.h @@ -80,7 +80,8 @@ class EditDMapDialog : public GUI::Dialog dmap local_dmap; GUI::ListData list_maps, list_types; - GUI::ListData list_lpals, list_activesub, list_passivesub, list_strings; + GUI::ListData list_activesub, list_passivesub, list_overlaysub, + list_strings, list_lpals; GUI::ListData list_midis, list_tracks; GUI::ListData list_disableditems, list_items; GUI::ListData list_dmapscript; diff --git a/src/gui/list_data.cpp b/src/gui/list_data.cpp index 25d4a36c01..0f42bd134e 100644 --- a/src/gui/list_data.cpp +++ b/src/gui/list_data.cpp @@ -7,14 +7,14 @@ namespace GUI ListData::ListData(size_t numItems, function getString, - function getValue) + function getValue) : _invalid(false) { listItems.reserve(numItems); for(size_t index = 0; index < numItems; ++index) listItems.emplace_back(move(getString(index)), getValue(index)); } -ListData::ListData(::ListData const& jwinldata, int32_t valoffs) +ListData::ListData(::ListData const& jwinldata, int32_t valoffs) : _invalid(false) { int32_t sz; jwinldata.listFunc(-1, &sz); diff --git a/src/gui/list_data.h b/src/gui/list_data.h index eca63fa569..e7a4127cee 100644 --- a/src/gui/list_data.h +++ b/src/gui/list_data.h @@ -44,15 +44,15 @@ struct ListItem class ListData { public: - ListData() {} + ListData() : _invalid(false) {} ListData(const ListData& other) = default; ListData(ListData&& other) = default; - ListData(std::initializer_list listItems): listItems(listItems) + ListData(std::initializer_list listItems) : _invalid(false), listItems(listItems) {} - ListData(std::vector listItems): listItems(std::move(listItems)) + ListData(std::vector listItems) : _invalid(false), listItems(std::move(listItems)) {} - ListData(std::vector strings) + ListData(std::vector strings) : _invalid(false) { for(int i = 0; i < strings.size(); i++) { @@ -83,6 +83,21 @@ class ListData return listItems.size(); } + inline bool empty() const + { + return !listItems.size(); + } + + inline bool invalid() const + { + return _invalid; + } + + inline void setInvalid(bool b) + { + _invalid = b; + } + inline const std::string& getText(size_t index) const { return listItems.at(index).text; @@ -185,6 +200,7 @@ class ListData private: std::vector listItems; + bool _invalid; static const char* jwinWrapper(int32_t index, int32_t* size, void* owner); }; diff --git a/src/zc_list_data.cpp b/src/zc_list_data.cpp index 0fb974833d..b4a139be29 100644 --- a/src/zc_list_data.cpp +++ b/src/zc_list_data.cpp @@ -183,31 +183,6 @@ GUI::ListData GUI::ZCListData::shadow_types() return GUI::ListData(strings); } -static const GUI::ListData aligns -{ - { "Left", 0 }, - { "Center", 1 }, - { "Right", 2 } -}; - -GUI::ListData const& GUI::ZCListData::alignments() -{ - return aligns; -} - -static const GUI::ListData button -{ - { "A", 0 }, - { "B", 1 }, - { "X", 2 }, - { "Y", 3 } -}; - -GUI::ListData const& GUI::ZCListData::buttons() -{ - return button; -} - GUI::ListData GUI::ZCListData::enemies(bool numbered, bool defaultFilter) { map ids; @@ -593,6 +568,61 @@ GUI::ListData GUI::ZCListData::midinames(bool numbered) return ls; } + + +GUI::ListData GUI::ZCListData::lpals() +{ + GUI::ListData ls; + char buf[50]; + for (int q = 0; q < 0x1FF; ++q) + { + sprintf(buf, "%.3X - %s", q, palnames[q]); + ls.add(buf, q + 1); + } + return ls; +} + +GUI::ListData GUI::ZCListData::subscreens(byte type, bool numbered) +{ + std::vector& vec = + (type == sstACTIVE ? subscreens_active + : (type == sstPASSIVE ? subscreens_passive + : subscreens_overlay)); + GUI::ListData ls; + for(int q = 0; q < vec.size(); ++q) + { + if(numbered) + ls.add(fmt::format("{} ({:03})",vec[q].name,q), q); + else ls.add(vec[q].name,q); + } + if(!ls.size()) + { + ls.add("[None Available]",0); + ls.setInvalid(true); + } + return ls; +} + +GUI::ListData GUI::ZCListData::disableditems(byte* disabledarray) +{ + GUI::ListData ls; + for (int q = 0; q < MAXITEMS; ++q) + { + if (disabledarray[q] & 1) + { + char const* itname = item_string[q]; + ls.add(itname, q); + } + } + if (ls.size() == 0) + { + ls.add("", -1); + } + ls.alphabetize(); + return ls; +} + +//SCRIPTS static void load_scriptnames(std::set &names, std::map &vals, std::map scrmap, int32_t count) { @@ -725,6 +755,8 @@ GUI::ListData GUI::ZCListData::generic_script() return ls; } +//CONST& RETURNS + static const GUI::ListData defense_types { { "(None)", 0 }, @@ -874,68 +906,29 @@ GUI::ListData const& GUI::ZCListData::dmaptypes() return dmap_types; } -GUI::ListData GUI::ZCListData::lpals() -{ - GUI::ListData ls; - char buf[50]; - for (int q = 0; q < 0x1FF; ++q) - { - sprintf(buf, "%.3X - %s", q, palnames[q]); - ls.add(buf, q + 1); - } - return ls; -} -GUI::ListData GUI::ZCListData::activesubscreens() +static const GUI::ListData aligns { - GUI::ListData ls; - int32_t i = 0, j = 0; - while (custom_subscreen[j].objects[0].type != ssoNULL) - { - if (custom_subscreen[j].ss_type == sstACTIVE) - { - ls.add(custom_subscreen[j].name, i + 1); - ++i; - } + { "Left", 0 }, + { "Center", 1 }, + { "Right", 2 } +}; - ++j; - } - return ls; +GUI::ListData const& GUI::ZCListData::alignments() +{ + return aligns; } -GUI::ListData GUI::ZCListData::passivesubscreens() +static const GUI::ListData button { - GUI::ListData ls; - int32_t i = 0, j = 0; - while (custom_subscreen[j].objects[0].type != ssoNULL) - { - if (custom_subscreen[j].ss_type == sstPASSIVE) - { - ls.add(custom_subscreen[j].name, i + 1); - ++i; - } - - ++j; - } - return ls; -} + { "A", 0 }, + { "B", 1 }, + { "X", 2 }, + { "Y", 3 } +}; -GUI::ListData GUI::ZCListData::disableditems(byte* disabledarray) +GUI::ListData const& GUI::ZCListData::buttons() { - GUI::ListData ls; - for (int q = 0; q < MAXITEMS; ++q) - { - if (disabledarray[q] & 1) - { - char const* itname = item_string[q]; - ls.add(itname, q); - } - } - if (ls.size() == 0) - { - ls.add("", -1); - } - ls.alphabetize(); - return ls; + return button; } diff --git a/src/zc_list_data.h b/src/zc_list_data.h index de4d94a7e8..aaaf763c58 100644 --- a/src/zc_list_data.h +++ b/src/zc_list_data.h @@ -24,8 +24,7 @@ namespace GUI::ZCListData GUI::ListData sfxnames(bool numbered = false); GUI::ListData midinames(bool numbered = false); GUI::ListData lpals(); - GUI::ListData activesubscreens(); - GUI::ListData passivesubscreens(); + GUI::ListData subscreens(byte type, bool numbered = false); GUI::ListData disableditems(byte* disabledarray); //Scripts GUI::ListData itemdata_script(); diff --git a/src/zq/zq_subscr.cpp b/src/zq/zq_subscr.cpp index 36763a8d6b..5d7c93335c 100644 --- a/src/zq/zq_subscr.cpp +++ b/src/zq/zq_subscr.cpp @@ -2570,36 +2570,6 @@ static DIALOG sstemplatelist_dlg[] = bool show_new_ss=true; -const char *subscreenlist_either(int32_t index, int32_t *list_size, byte type) -{ - std::vector& vec = - (type == sstACTIVE ? subscreens_active - : (type == sstPASSIVE ? subscreens_passive - : subscreens_overlay)); - if(index<0) - { - *list_size = vec.size(); - return NULL; - } - - return vec[index].name.c_str(); -} - -const char *subscreenlist_active(int32_t index, int32_t *list_size) -{ - return subscreenlist_either(index,list_size,sstACTIVE); -} - -const char *subscreenlist_passive(int32_t index, int32_t *list_size) -{ - return subscreenlist_either(index,list_size,sstPASSIVE); -} - -const char *subscreenlist_overlay(int32_t index, int32_t *list_size) -{ - return subscreenlist_either(index,list_size,sstOVERLAY); -} - void call_subscr_listedit_dlg(); int32_t onEditSubscreens() {