Skip to content

Commit

Permalink
feat: Overlay Subscreen settable in dmap editor
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Aug 20, 2023
1 parent 82a7b00 commit e7b77da
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 134 deletions.
58 changes: 43 additions & 15 deletions src/dialog/edit_dmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "zq/zq_class.h"
#include "zc_list_data.h"
#include "info.h"
#include "subscr.h"
#include <fmt/format.h>
#include <base/qrs.h>

Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -309,7 +311,8 @@ std::shared_ptr<GUI::Widget> 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."),
Expand Down Expand Up @@ -424,24 +427,41 @@ std::shared_ptr<GUI::Widget> 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(
Expand Down Expand Up @@ -760,9 +780,14 @@ std::shared_ptr<GUI::Widget> 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:"),
Expand Down Expand Up @@ -793,8 +818,11 @@ std::shared_ptr<GUI::Widget> 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.")
)
)
)
Expand Down
3 changes: 2 additions & 1 deletion src/dialog/edit_dmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class EditDMapDialog : public GUI::Dialog<EditDMapDialog>
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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/list_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace GUI

ListData::ListData(size_t numItems,
function<string(size_t)> getString,
function<int32_t(size_t)> getValue)
function<int32_t(size_t)> 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);
Expand Down
24 changes: 20 additions & 4 deletions src/gui/list_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ListItem> listItems): listItems(listItems)
ListData(std::initializer_list<ListItem> listItems) : _invalid(false), listItems(listItems)
{}

ListData(std::vector<ListItem> listItems): listItems(std::move(listItems))
ListData(std::vector<ListItem> listItems) : _invalid(false), listItems(std::move(listItems))
{}
ListData(std::vector<std::string> strings)
ListData(std::vector<std::string> strings) : _invalid(false)
{
for(int i = 0; i < strings.size(); i++)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -185,6 +200,7 @@ class ListData

private:
std::vector<ListItem> listItems;
bool _invalid;

static const char* jwinWrapper(int32_t index, int32_t* size, void* owner);
};
Expand Down
153 changes: 73 additions & 80 deletions src/zc_list_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, int32_t> ids;
Expand Down Expand Up @@ -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<ZCSubscreen>& 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<std::string> &names, std::map<std::string, int32_t> &vals,
std::map<int32_t, script_slot_data> scrmap, int32_t count)
{
Expand Down Expand Up @@ -725,6 +755,8 @@ GUI::ListData GUI::ZCListData::generic_script()
return ls;
}

//CONST& RETURNS

static const GUI::ListData defense_types
{
{ "(None)", 0 },
Expand Down Expand Up @@ -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;
}

3 changes: 1 addition & 2 deletions src/zc_list_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit e7b77da

Please sign in to comment.