From 82a7b0000f2646ae11c4b21b850c95b3a1df8df0 Mon Sep 17 00:00:00 2001 From: EmilyV99 Date: Sun, 20 Aug 2023 03:19:28 -0400 Subject: [PATCH] feat: Add 'Overlay Subscreens' These subscreens draw over the screen at all times, both during play and the active subscreen. As usual, widgets can have the 'Display' settings on widgets to change their visibility while the active subscreen is up, down, and scrolling. This can be used for various things like displaying your current keys over the corner of the game screen. --- modules/zquest/ZQuestGUI.txt | 1 + resources/docs/ZScript_Additions.txt | 3 + src/base/dmap.h | 1 + src/base/zdefs.h | 2 +- src/dialog/subscr_lists_edit.cpp | 148 +++ src/dialog/subscr_lists_edit.h | 35 + src/dialog/subscr_props.cpp | 11 +- src/gui/list.cpp | 1 + src/jwin.cpp | 40 +- src/new_subscr.cpp | 14 +- src/new_subscr.h | 6 +- src/parser/ByteCode.cpp | 2 +- src/parser/ByteCode.h | 2 +- src/parser/symbols/DMapDataSymbols.cpp | 2 + src/qst.cpp | 89 +- src/subscr.cpp | 50 +- src/subscr.h | 5 +- src/zc/ffscript.cpp | 22 +- src/zc/ffscript.h | 2 +- src/zc/zc_subscr.cpp | 26 +- src/zc/zelda.cpp | 2 +- src/zq/ffasm.cpp | 2 +- src/zq/zq_class.cpp | 31 +- src/zq/zq_subscr.cpp | 1345 ++++++++++++------------ webdocs/zsdocs_main.json | 4 +- 25 files changed, 1035 insertions(+), 811 deletions(-) create mode 100644 src/dialog/subscr_lists_edit.cpp create mode 100644 src/dialog/subscr_lists_edit.h diff --git a/modules/zquest/ZQuestGUI.txt b/modules/zquest/ZQuestGUI.txt index 2615b759e1..95c1308972 100644 --- a/modules/zquest/ZQuestGUI.txt +++ b/modules/zquest/ZQuestGUI.txt @@ -43,6 +43,7 @@ src/dialog/about.cpp src/dialog/subscr_props.cpp src/dialog/subscr_settings.cpp src/dialog/subscr_transition.cpp +src/dialog/subscr_lists_edit.cpp src/dialog/room.cpp src/dialog/foodlg.cpp src/dialog/quest_rules.cpp diff --git a/resources/docs/ZScript_Additions.txt b/resources/docs/ZScript_Additions.txt index a45212896f..2e81ce78cc 100644 --- a/resources/docs/ZScript_Additions.txt +++ b/resources/docs/ZScript_Additions.txt @@ -6515,6 +6515,9 @@ int ActiveSubscreen; int PassiveSubscreen; * The passive subscreen ID. + +int OverlaySubscreen; + * The overlay subscreen ID. int Grid[8]; * The rooms displayed either when the player has the map item, diff --git a/src/base/dmap.h b/src/base/dmap.h index c0f794a705..2d4564f042 100644 --- a/src/base/dmap.h +++ b/src/base/dmap.h @@ -38,6 +38,7 @@ struct dmap byte tmusictrack; byte active_subscreen; byte passive_subscreen; + byte overlay_subscreen; // int32_t emusic; //byte padding; //204 diff --git a/src/base/zdefs.h b/src/base/zdefs.h index 45c5fabd0b..99bd5d95d5 100644 --- a/src/base/zdefs.h +++ b/src/base/zdefs.h @@ -232,7 +232,7 @@ enum {ENC_METHOD_192B104=0, ENC_METHOD_192B105, ENC_METHOD_192B185, ENC_METHOD_2 #define V_COMBOS 42 #define V_CSETS 5 //palette data #define V_MAPS 28 -#define V_DMAPS 18 +#define V_DMAPS 19 #define V_DOORS 1 #define V_ITEMS 57 #define V_WEAPONS 8 diff --git a/src/dialog/subscr_lists_edit.cpp b/src/dialog/subscr_lists_edit.cpp new file mode 100644 index 0000000000..81886eb272 --- /dev/null +++ b/src/dialog/subscr_lists_edit.cpp @@ -0,0 +1,148 @@ +#include "subscr_lists_edit.h" +#include +#include "alert.h" +#include +#include +#include +#include "new_subscr.h" +#include "zq/zq_subscr.h" +#include "zc_list_data.h" +#include "gui/use_size.h" +#include "gui/common.h" + +extern ZCSubscreen subscr_edit; +extern DIALOG *subscreen_dlg; + +void delete_subscreen(size_t ind, byte ty); +void do_edit_subscr(size_t ind, byte ty); + +static std::vector* subscr_vecs[sstMAX]; +static const std::string _titles[sstMAX] = {"Active","Passive","Overlay"}; +static const std::string _infos[sstMAX] = { + "The subscreen that actively opens when you press 'Start'", + "The subscreen visible at the top of the screen normally, which moves down when the active opens.", + "Like the passive, but visible across the whole screen and does NOT move down for the active opening." + }; + +void call_subscr_listedit_dlg() +{ + SubscrListEditDialog().show(); +} + +static size_t editsub_tabptr = 0; +std::shared_ptr SubscrListEditDialog::view() +{ + using namespace GUI::Builder; + using namespace GUI::Props; + + std::shared_ptr g; + window = Window( + title = "Edit Subscreens", + onClose = message::DONE, + Column( + g = TabPanel(ptr = &editsub_tabptr), + Rows<2>( + Button( + text = "Done", + topPadding = 0.5_em, + minwidth = 90_px, + onClick = message::DONE, + focused = true) + ) + ) + ); + + subscr_vecs[0] = &subscreens_active; + subscr_vecs[1] = &subscreens_passive; + subscr_vecs[2] = &subscreens_overlay; + for(int q = 0; q < sstMAX; ++q) + { + auto* vec = subscr_vecs[q]; + subscr_lists[q] = GUI::ListData(vec->size(), + [&,vec](size_t ind) + { + return fmt::format("{} ({:03d})",(*vec)[ind].name,ind); + }, + [&](size_t ind){return int32_t(ind);}); + subscr_lists[q].add(fmt::format("",_titles[q]),vec->size()); + message edit_msg = message(int(message::EDIT0)+q), + del_msg = message(int(message::DEL0)+q); + g->add(TabRef(name = _titles[q], + Column( + INFOBTN_EX(_infos[q], maxheight = 1.5_em), + List(data = subscr_lists[q], + selectedValue = sel_inds[q], + onDClick = edit_msg, + onSelectFunc = [&,q](int32_t val) + { + sel_inds[q] = val; + }), + Row( + Button( + text = "Edit", + minwidth = 90_px, hAlign = 1.0, + onClick = edit_msg), + Button( + text = "Delete", + minwidth = 90_px, hAlign = 0.0, + onClick = del_msg) + ) + ) + )); + } + + return window; +} + +bool SubscrListEditDialog::handleMessage(const GUI::DialogMessage& msg) +{ + bool refresh = false; + switch(msg.message) + { + case message::REFR_INFO: + break; + case message::EDIT0: + case message::EDIT1: + case message::EDIT2: + { + size_t cur_type = int(msg.message)-int(message::EDIT0); + do_edit_subscr(sel_inds[cur_type],cur_type); + refresh = true; + break; + } + case message::DEL0: + case message::DEL1: + case message::DEL2: + { + size_t cur_type = int(msg.message)-int(message::DEL0); + auto& vec = *subscr_vecs[cur_type]; + if(sel_inds[cur_type] >= vec.size()) + return false; + bool run = false; + AlertDialog(fmt::format("Delete {} Subscreen?",_titles[cur_type]), + fmt::format("Are you sure you want to delete {} Subscreen {} '{}'?" + " This cannot be undone!", _titles[cur_type], sel_inds[cur_type], + vec[sel_inds[cur_type]].name), + [&](bool ret,bool) + { + run = ret; + }).show(); + if(run) + delete_subscreen(sel_inds[cur_type],cur_type); + refresh = true; + break; + } + case message::REFRESH: + refresh = true; + break; + case message::DONE: + return true; + } + if(refresh) + { + rerun_dlg = true; + return true; + } + return false; +} + diff --git a/src/dialog/subscr_lists_edit.h b/src/dialog/subscr_lists_edit.h new file mode 100644 index 0000000000..c31feeecbf --- /dev/null +++ b/src/dialog/subscr_lists_edit.h @@ -0,0 +1,35 @@ +#ifndef ZC_DIALOG_SUBSCR_LISTS_EDIT_H +#define ZC_DIALOG_SUBSCR_LISTS_EDIT_H + +#include +#include +#include +#include +#include +#include +#include "subscr.h" + +void call_subscr_listedit_dlg(); + +class SubscrListEditDialog: public GUI::Dialog +{ +public: + enum class message + { + REFR_INFO, REFRESH, DONE, EDIT0, EDIT1, EDIT2, DEL0, DEL1, DEL2 + }; + + SubscrListEditDialog() = default; + + std::shared_ptr view() override; + bool handleMessage(const GUI::DialogMessage& msg); +protected: + std::shared_ptr window; + + GUI::ListData subscr_lists[sstMAX]; + size_t sel_inds[sstMAX]; + + void refr_info(); +}; + +#endif diff --git a/src/dialog/subscr_props.cpp b/src/dialog/subscr_props.cpp index f1f7a5eb2b..676059d42f 100644 --- a/src/dialog/subscr_props.cpp +++ b/src/dialog/subscr_props.cpp @@ -356,8 +356,9 @@ std::shared_ptr SubscrPropDialog::view() std::shared_ptr g1; loc_grid = Column( Row( - Column( - Label(text = "Display:"), + Rows<2>( + Label(text = "Display:", colSpan = 2), + INFOBTN("Draws while the active subscreen is UP (closed)"), Checkbox( text = "Active Up", hAlign = 0.0, checked = local_subref->posflags & sspUP, @@ -366,6 +367,7 @@ std::shared_ptr SubscrPropDialog::view() SETFLAG(local_subref->posflags,sspUP,state); } ), + INFOBTN("Draws while the active subscreen is DOWN (open)"), Checkbox( text = "Active Down", hAlign = 0.0, checked = local_subref->posflags & sspDOWN, @@ -374,6 +376,7 @@ std::shared_ptr SubscrPropDialog::view() SETFLAG(local_subref->posflags,sspDOWN,state); } ), + INFOBTN("Draws while the active subscreen is SCROLLING (opening/closing)"), Checkbox( text = "Active Scrolling", hAlign = 0.0, checked = local_subref->posflags & sspSCROLLING, @@ -893,10 +896,10 @@ std::shared_ptr SubscrPropDialog::view() INFOBTN("If >1, displays multiple gauge pieces height-wise."), // Label(text = "HSpace:", hAlign = 1.0), - gauge_gw[g++] = NUM_FIELD(w->hspace, 0, 255), + gauge_gw[g++] = NUM_FIELD(w->hspace, -128, 127), INFOBTN("Extra space between gauge pieces width-wise."), Label(text = "VSpace:", hAlign = 1.0), - gauge_gw[g++] = NUM_FIELD(w->vspace, 0, 255), + gauge_gw[g++] = NUM_FIELD(w->vspace, -128, 127), INFOBTN("Extra space between gauge pieces height-wise."), // Label(text = "Grid XOffset:", hAlign = 1.0), diff --git a/src/gui/list.cpp b/src/gui/list.cpp index 2ebadbb9d1..aac50bfa55 100644 --- a/src/gui/list.cpp +++ b/src/gui/list.cpp @@ -70,6 +70,7 @@ int32_t List::getSelectedValue() const void List::setIndex() { + if (!listData || !listData->size()) return; // Find a valid selection. We'll take the first thing with a matching // value. If nothing matches exactly, take the one that's closest to // the selected value. diff --git a/src/jwin.cpp b/src/jwin.cpp index 3143a8c3e9..7ebbb5244b 100644 --- a/src/jwin.cpp +++ b/src/jwin.cpp @@ -9284,33 +9284,49 @@ int32_t new_tab_proc(int32_t msg, DIALOG *d, int32_t c) -int32_t jwin_hline_proc(int32_t msg, DIALOG *d, int32_t c) +int32_t jwin_hline_proc(int32_t msg, DIALOG *d, int32_t) { - //these are here to bypass compiler warnings about unused arguments - c=c; - ASSERT(d); if(msg==MSG_DRAW) { - _allegro_hline(screen, d->x, d->y, d->x+d->w-1, scheme[jcMEDDARK]); - _allegro_hline(screen, d->x, d->y+1, d->x+d->w-1, scheme[jcLIGHT]); + if(d->w < 1) return D_O_K; + for(int q = 0; q <= d->d1; ++q) + { + if(d->d2&1) + { + _allegro_hline(screen, d->x, d->y+q, d->x+d->w-1, d->fg); + } + else + { + _allegro_hline(screen, d->x, d->y-q, d->x+d->w-1, scheme[jcMEDDARK]); + _allegro_hline(screen, d->x, d->y+1+q, d->x+d->w-1, scheme[jcLIGHT]); + } + } } return D_O_K; } -int32_t jwin_vline_proc(int32_t msg, DIALOG *d, int32_t c) +int32_t jwin_vline_proc(int32_t msg, DIALOG *d, int32_t) { - //these are here to bypass compiler warnings about unused arguments - c=c; - ASSERT(d); if(msg==MSG_DRAW) { - _allegro_vline(screen, d->x, d->y, d->y+d->h-1, scheme[jcMEDDARK]); - _allegro_vline(screen, d->x+1, d->y, d->y+d->h-1, scheme[jcLIGHT]); + if(d->h < 1) return D_O_K; + for(int q = 0; q <= d->d1; ++q) + { + if(d->d2&1) + { + _allegro_vline(screen, d->x+q, d->y, d->y+d->h-1, d->fg); + } + else + { + _allegro_vline(screen, d->x+q, d->y, d->y+d->h-1, scheme[jcMEDDARK]); + _allegro_vline(screen, d->x+1-q, d->y, d->y+d->h-1, scheme[jcLIGHT]); + } + } } return D_O_K; diff --git a/src/new_subscr.cpp b/src/new_subscr.cpp index 989aff2151..f7cd43128f 100644 --- a/src/new_subscr.cpp +++ b/src/new_subscr.cpp @@ -3906,7 +3906,7 @@ int32_t SW_MiscGaugePiece::read(PACKFILE *f, word s_version) { if(auto ret = SW_GaugePiece::read(f, s_version)) return ret; - if(!p_getc(&counter, f)) + if(!p_igetw(&counter, f)) return qe_invalid; if(!p_igetw(&per_container,f)) return qe_invalid; @@ -3916,7 +3916,7 @@ int32_t SW_MiscGaugePiece::write(PACKFILE *f) const { if(auto ret = SW_GaugePiece::write(f)) return ret; - if(!p_putc(counter, f)) + if(!p_iputw(counter, f)) new_return(1); if(!p_iputw(per_container,f)) new_return(1); @@ -4880,8 +4880,8 @@ int32_t ZCSubscreen::read(PACKFILE *f, word s_version) return qe_invalid; if(!p_igetl(&flags,f)) new_return(1); - bool passive = sub_type == sstPASSIVE; - if(!passive) + bool active = sub_type == sstACTIVE; + if(active) { for(int q = 0; q < 4; ++q) if(!p_igetw(&def_btns[q],f)) @@ -4924,8 +4924,8 @@ int32_t ZCSubscreen::write(PACKFILE *f) const new_return(1); if(!p_iputl(flags,f)) new_return(1); - bool passive = sub_type == sstPASSIVE; - if(!passive) + bool active = sub_type == sstACTIVE; + if(active) { for(int q = 0; q < 4; ++q) if(!p_iputw(def_btns[q],f)) @@ -4948,7 +4948,7 @@ int32_t ZCSubscreen::write(PACKFILE *f) const } } byte pagecnt = zc_min(MAX_SUBSCR_PAGES,pages.size()); - if(pagecnt && passive) + if(pagecnt && !active) pagecnt = 1; if(!p_putc(pagecnt,f)) new_return(1); diff --git a/src/new_subscr.h b/src/new_subscr.h index c1e995517b..e8d73f87fd 100644 --- a/src/new_subscr.h +++ b/src/new_subscr.h @@ -778,8 +778,8 @@ struct SW_GaugePiece : public SubscrWidget { SubscrMTInfo mts[4]; word frames = 1, speed = 1, delay, container; - byte gauge_wid, gauge_hei; - byte hspace, vspace, unit_per_frame; + byte gauge_wid, gauge_hei, unit_per_frame; + int8_t hspace, vspace; int16_t grid_xoff, grid_yoff; word anim_val; int16_t inf_item = -1; @@ -845,7 +845,7 @@ struct SW_MagicGaugePiece : public SW_GaugePiece struct SW_MiscGaugePiece : public SW_GaugePiece { - byte counter; + int16_t counter; word per_container = 1; SW_MiscGaugePiece() = default; diff --git a/src/parser/ByteCode.cpp b/src/parser/ByteCode.cpp index f60fa0349d..d18b005fbe 100644 --- a/src/parser/ByteCode.cpp +++ b/src/parser/ByteCode.cpp @@ -2010,7 +2010,7 @@ string ZScript::VarToString(int32_t ID) case SCREENLENSHIDES: return "SCREENLENSHIDES"; case GAMETRIGGROUPS: return "GAMETRIGGROUPS"; case GAMEOVERRIDEITEMS: return "GAMEOVERRIDEITEMS"; - case RESRVD_VAR_EMILY44: return "RESRVD_VAR_EMILY44"; + case DMAPDATASUBSCRO: return "DMAPDATASUBSCRO"; case RESRVD_VAR_EMILY45: return "RESRVD_VAR_EMILY45"; case RESRVD_VAR_EMILY46: return "RESRVD_VAR_EMILY46"; case RESRVD_VAR_EMILY47: return "RESRVD_VAR_EMILY47"; diff --git a/src/parser/ByteCode.h b/src/parser/ByteCode.h index 6d8a8b0356..f1b9f5a1fc 100644 --- a/src/parser/ByteCode.h +++ b/src/parser/ByteCode.h @@ -1549,7 +1549,7 @@ #define SCREENLENSHIDES 1462 #define GAMETRIGGROUPS 1463 #define GAMEOVERRIDEITEMS 1464 -#define RESRVD_VAR_EMILY44 1465 +#define DMAPDATASUBSCRO 1465 #define RESRVD_VAR_EMILY45 1466 #define RESRVD_VAR_EMILY46 1467 #define RESRVD_VAR_EMILY47 1468 diff --git a/src/parser/symbols/DMapDataSymbols.cpp b/src/parser/symbols/DMapDataSymbols.cpp index 6de81ca081..578dbec955 100644 --- a/src/parser/symbols/DMapDataSymbols.cpp +++ b/src/parser/symbols/DMapDataSymbols.cpp @@ -39,6 +39,8 @@ static AccessorTable DMapDataTable[] = { "setActiveSubscreen", 0, ZTID_VOID, DMAPDATASUBSCRA, 0, { ZTID_DMAPDATA, ZTID_FLOAT },{} }, { "getPassiveSubscreen", 0, ZTID_FLOAT, DMAPDATASUBSCRP, 0, { ZTID_DMAPDATA },{} }, { "setPassiveSubscreen", 0, ZTID_VOID, DMAPDATASUBSCRP, 0, { ZTID_DMAPDATA, ZTID_FLOAT },{} }, + { "getOverlaySubscreen", 0, ZTID_FLOAT, DMAPDATASUBSCRO, 0, { ZTID_DMAPDATA },{} }, + { "setOverlaySubscreen", 0, ZTID_VOID, DMAPDATASUBSCRO, 0, { ZTID_DMAPDATA, ZTID_FLOAT },{} }, { "getGrid[]", 0, ZTID_FLOAT, DMAPDATAGRID, 0, { ZTID_DMAPDATA, ZTID_FLOAT },{} }, { "setGrid[]", 0, ZTID_VOID, DMAPDATAGRID, 0, { ZTID_DMAPDATA, ZTID_FLOAT, ZTID_FLOAT },{} }, { "getMiniMapTile[]", 0, ZTID_FLOAT, DMAPDATAMINIMAPTILE, 0, { ZTID_DMAPDATA, ZTID_FLOAT },{} }, diff --git a/src/qst.cpp b/src/qst.cpp index 8663321cc8..910685c47c 100644 --- a/src/qst.cpp +++ b/src/qst.cpp @@ -5259,7 +5259,11 @@ int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap tempDMap.tmusic_xfade_in = 0; tempDMap.tmusic_xfade_out = 0; } - + + if(s_version >= 19) + if(!p_getc(&tempDMap.overlay_subscreen, f)) + return qe_invalid; + memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap)); } @@ -11276,7 +11280,9 @@ int32_t readherosprites(PACKFILE *f, zquestheader *Header) int32_t read_old_subscreens(PACKFILE *f, word s_version) { - new_subscreen.clear(); + subscreens_active.clear(); + subscreens_passive.clear(); + subscreens_overlay.clear(); for(int32_t i=0; i=ssdtMAX) @@ -11893,31 +11924,31 @@ int32_t setupsubscreens() case ssdtBSZELDAENHANCED: case ssdtBSZELDACOMPLETE: { - new_subscreen[0].load_old(default_subscreen_active[tempsubscreen][0]); - new_subscreen[0].sub_type=sstACTIVE; - new_subscreen[0].name = "Active Subscreen (Triforce)"; - new_subscreen[1].load_old(default_subscreen_active[tempsubscreen][1]); - new_subscreen[1].sub_type=sstACTIVE; - new_subscreen[1].name = "Active Subscreen (Dungeon Map)"; - new_subscreen[2].load_old(default_subscreen_passive[tempsubscreen][0]); - new_subscreen[2].sub_type=sstPASSIVE; - new_subscreen[2].name = "Passive Subscreen (Magic)"; - new_subscreen[3].load_old(default_subscreen_passive[tempsubscreen][1]); - new_subscreen[3].sub_type=sstPASSIVE; - new_subscreen[3].name = "Passive Subscreen (No Magic)"; + subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]); + subscreens_active[0].sub_type=sstACTIVE; + subscreens_active[0].name = "Active Subscreen (Triforce)"; + subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]); + subscreens_active[1].sub_type=sstACTIVE; + subscreens_active[1].name = "Active Subscreen (Dungeon Map)"; + subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]); + subscreens_passive[0].sub_type=sstPASSIVE; + subscreens_passive[0].name = "Passive Subscreen (Magic)"; + subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]); + subscreens_passive[1].sub_type=sstPASSIVE; + subscreens_passive[1].name = "Passive Subscreen (No Magic)"; break; } case ssdtZ3: { - new_subscreen[0].load_old(z3_active_a); - new_subscreen[0].sub_type=sstACTIVE; - new_subscreen[1].load_old(z3_active_ab); - new_subscreen[1].sub_type=sstACTIVE; - new_subscreen[2].load_old(z3_passive_a); - new_subscreen[2].sub_type=sstPASSIVE; - new_subscreen[3].load_old(z3_passive_ab); - new_subscreen[3].sub_type=sstPASSIVE; + subscreens_active[0].load_old(z3_active_a); + subscreens_active[0].sub_type=sstACTIVE; + subscreens_active[1].load_old(z3_active_ab); + subscreens_active[1].sub_type=sstACTIVE; + subscreens_passive[0].load_old(z3_passive_a); + subscreens_passive[0].sub_type=sstPASSIVE; + subscreens_passive[1].load_old(z3_passive_ab); + subscreens_passive[1].sub_type=sstPASSIVE; break; } } diff --git a/src/subscr.cpp b/src/subscr.cpp index 23852cbf05..49f4738e9a 100644 --- a/src/subscr.cpp +++ b/src/subscr.cpp @@ -34,10 +34,10 @@ extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations; extern HeroClass Hero; extern FFScript FFCore; -ZCSubscreen *new_subscreen_active; -ZCSubscreen *new_subscreen_passive; +ZCSubscreen *new_subscreen_active = nullptr, *new_subscreen_passive = nullptr, + *new_subscreen_overlay = nullptr; -std::vector new_subscreen; +std::vector subscreens_active, subscreens_passive, subscreens_overlay; static const int32_t notscrolling = sspUP | sspDOWN; static const int32_t pos = notscrolling | sspSCROLLING; @@ -3143,6 +3143,12 @@ void put_passive_subscr(BITMAP *dest,int32_t x,int32_t y,bool showtime,int32_t p show_custom_subscreen(subscr, new_subscreen_passive, 0, 0, showtime, pos2); destroy_bitmap(subscr); + if(new_subscreen_overlay) + { + subscr = create_sub_bitmap(dest,x,0,256,224); + show_custom_subscreen(subscr, new_subscreen_overlay, 0, 0, showtime, pos2); + destroy_bitmap(subscr); + } } /* @@ -3505,34 +3511,17 @@ void update_subscreens(int32_t dmap) { if(dmap<0) dmap=get_currdmap(); - - int32_t index=DMaps[dmap].active_subscreen; - - int32_t i=-1, j=0; - - while(j < new_subscreen.size() && i!=index) - { - if(new_subscreen[j].sub_type==sstACTIVE) - ++i; - - ++j; - } - - auto next_active = &new_subscreen[j-1]; - - index=DMaps[dmap].passive_subscreen; - - i=-1, j=0; - - while(j < new_subscreen.size() && i!=index) - { - if(new_subscreen[j].sub_type==sstPASSIVE) - ++i; - - ++j; - } - auto next_passive = &new_subscreen[j-1]; + ZCSubscreen *next_active = nullptr, *next_passive = nullptr, *next_overlay = nullptr; + int indx = DMaps[dmap].active_subscreen; + if(unsigned(indx) < subscreens_active.size()) + next_active = &subscreens_active[indx]; + indx = DMaps[dmap].passive_subscreen; + if(unsigned(indx) < subscreens_passive.size()) + next_passive = &subscreens_passive[indx]; + indx = DMaps[dmap].overlay_subscreen; + if(unsigned(indx) < subscreens_overlay.size()) + next_overlay = &subscreens_overlay[indx]; if(get_qr(qr_OLD_SUBSCR) && new_subscreen_active) { @@ -3542,6 +3531,7 @@ void update_subscreens(int32_t dmap) new_subscreen_passive = next_passive; new_subscreen_active = next_active; + new_subscreen_overlay = next_overlay; } void sso_bounding_box(BITMAP *bmp, SubscrWidget* widg, int32_t color) diff --git a/src/subscr.h b/src/subscr.h index 41cf1d766a..03b31444c8 100644 --- a/src/subscr.h +++ b/src/subscr.h @@ -45,7 +45,7 @@ INLINE void putdot(BITMAP *dest,int32_t x,int32_t y,int32_t c) // subscreen default types enum { ssdtOLD, ssdtNEWSUBSCR, ssdtREV2, ssdtBSZELDA, ssdtBSZELDAMODIFIED, ssdtBSZELDAENHANCED, ssdtBSZELDACOMPLETE, ssdtZ3, ssdtMAX }; -enum { sstACTIVE, sstPASSIVE, sstMAX }; +enum { sstACTIVE, sstPASSIVE, sstOVERLAY, sstMAX }; enum { sssFULLPUSH, sssFULLSLIDEDOWN, sssMAX }; @@ -95,9 +95,10 @@ extern subscreen_object z3_active_a[80]; extern subscreen_object z3_passive_a[66]; extern subscreen_object z3_active_ab[82]; extern subscreen_object z3_passive_ab[75]; -extern std::vector new_subscreen; +extern std::vector subscreens_active, subscreens_passive, subscreens_overlay; extern ZCSubscreen *new_subscreen_active; extern ZCSubscreen *new_subscreen_passive; +extern ZCSubscreen *new_subscreen_overlay; const byte tripiece[2][8][3] = { diff --git a/src/zc/ffscript.cpp b/src/zc/ffscript.cpp index 5c6bea28db..7ae3c5a51c 100644 --- a/src/zc/ffscript.cpp +++ b/src/zc/ffscript.cpp @@ -11109,14 +11109,18 @@ int32_t get_register(const int32_t arg) { ret = ((byte)DMaps[ri->dmapsref].tmusictrack) * 10000; break; } - case DMAPDATASUBSCRA: //byte, active subscreen + case DMAPDATASUBSCRA: { ret = ((byte)DMaps[ri->dmapsref].active_subscreen) * 10000; break; } - case DMAPDATASUBSCRP: //byte, passive subscreen + case DMAPDATASUBSCRP: { ret = ((byte)DMaps[ri->dmapsref].passive_subscreen) * 10000; break; } + case DMAPDATASUBSCRO: + { + ret = ((byte)DMaps[ri->dmapsref].overlay_subscreen) * 10000; break; + } case DMAPDATADISABLEDITEMS: //byte[MAXITEMS] { int32_t indx = ri->d[rINDEX] / 10000; @@ -21614,7 +21618,7 @@ void set_register(int32_t arg, int32_t value) { DMaps[ri->dmapsref].tmusictrack= ((byte)(value / 10000)); break; } - case DMAPDATASUBSCRA: //byte, active subscreen + case DMAPDATASUBSCRA: { bool changed = DMaps[ri->dmapsref].active_subscreen != ((byte)(value / 10000)); DMaps[ri->dmapsref].active_subscreen= ((byte)(value / 10000)); @@ -21622,7 +21626,7 @@ void set_register(int32_t arg, int32_t value) update_subscreens(); break; } - case DMAPDATASUBSCRP: //byte, passive subscreen + case DMAPDATASUBSCRP: { bool changed = DMaps[ri->dmapsref].passive_subscreen != ((byte)(value / 10000)); DMaps[ri->dmapsref].passive_subscreen= ((byte)(value / 10000)); @@ -21630,6 +21634,14 @@ void set_register(int32_t arg, int32_t value) update_subscreens(); break; } + case DMAPDATASUBSCRO: + { + bool changed = DMaps[ri->dmapsref].overlay_subscreen != ((byte)(value / 10000)); + DMaps[ri->dmapsref].overlay_subscreen = ((byte)(value / 10000)); + if(changed&&ri->dmapsref==currdmap) + update_subscreens(); + break; + } case DMAPDATADISABLEDITEMS: //byte[MAXITEMS] { int32_t indx = ri->d[rINDEX] / 10000; @@ -42968,7 +42980,7 @@ script_variable ZASMVars[]= { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0}, { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0}, { "GAMEOVERRIDEITEMS", GAMEOVERRIDEITEMS, 0, 0}, - { "RESRVD_VAR_EMILY44", RESRVD_VAR_EMILY44, 0, 0}, + { "DMAPDATASUBSCRO", DMAPDATASUBSCRO, 0, 0}, { "RESRVD_VAR_EMILY45", RESRVD_VAR_EMILY45, 0, 0}, { "RESRVD_VAR_EMILY46", RESRVD_VAR_EMILY46, 0, 0}, { "RESRVD_VAR_EMILY47", RESRVD_VAR_EMILY47, 0, 0}, diff --git a/src/zc/ffscript.h b/src/zc/ffscript.h index 51c935ce31..258490ecd9 100644 --- a/src/zc/ffscript.h +++ b/src/zc/ffscript.h @@ -4909,7 +4909,7 @@ enum ASM_DEFINE #define SCREENLENSHIDES 0x14EC #define GAMETRIGGROUPS 0x14ED #define GAMEOVERRIDEITEMS 0x14EE -#define RESRVD_VAR_EMILY44 0x14EF +#define DMAPDATASUBSCRO 0x14EF #define RESRVD_VAR_EMILY45 0x14F0 #define RESRVD_VAR_EMILY46 0x14F1 #define RESRVD_VAR_EMILY47 0x14F2 diff --git a/src/zc/zc_subscr.cpp b/src/zc/zc_subscr.cpp index ea5a2760b8..bde88ce6a5 100644 --- a/src/zc/zc_subscr.cpp +++ b/src/zc/zc_subscr.cpp @@ -38,6 +38,19 @@ void put_active_subscr(int32_t y, int32_t pos) show_custom_subscreen(framebuf, new_subscreen_active, 0, 6-y, game->should_show_time(), pos); } +void draw_subscrs(BITMAP* dest, int x, int y, bool showtime, int pos) +{ + if(get_qr(qr_OLD_SUBSCR)) + { + put_passive_subscr(dest,x,176-2-y,showtime,pos); + put_active_subscr(y,pos); + } + else + { + put_active_subscr(y,pos); + put_passive_subscr(dest,x,176-2-y,showtime,pos); + } +} void dosubscr() { PALETTE temppal; @@ -120,10 +133,7 @@ void dosubscr() blit(scrollbuf,framebuf,256,0,0,176-2-y+passive_subscreen_height,256,y); } - //throw the passive subscreen onto the screen - put_passive_subscr(framebuf,0,176-2-y,showtime,sspSCROLLING); - //put the active subscreen above the passive subscreen - put_active_subscr(y,sspSCROLLING); + draw_subscrs(framebuf,0,y,showtime,sspSCROLLING); advanceframe(false); @@ -411,8 +421,7 @@ void dosubscr() //else nothing to do; the playing field has scrolled off the screen //draw the passive and active subscreen - put_passive_subscr(framebuf,0,176-2-miny,showtime,sspDOWN); - put_active_subscr(miny,sspDOWN); + draw_subscrs(framebuf,0,miny,showtime,sspDOWN); advanceframe(false); if (replay_version_check(11)) @@ -450,10 +459,7 @@ void dosubscr() blit(scrollbuf,framebuf,256,0,0,176-2-y+passive_subscreen_height,256,y); } - //throw the passive subscreen onto the screen - put_passive_subscr(framebuf,0,176-2-y,showtime,sspSCROLLING); - //put the active subscreen above the passive subscreen - put_active_subscr(y,sspSCROLLING); + draw_subscrs(framebuf,0,y,showtime,sspSCROLLING); advanceframe(false); if(Quit) diff --git a/src/zc/zelda.cpp b/src/zc/zelda.cpp index 51557a2a09..4c008eb2cd 100644 --- a/src/zc/zelda.cpp +++ b/src/zc/zelda.cpp @@ -1988,7 +1988,7 @@ int32_t init_game() timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP); timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL); previous_DMap = currdmap = warpscr = worldscr=game->get_continue_dmap(); - new_subscreen_active = new_subscreen_passive = nullptr; + new_subscreen_active = new_subscreen_passive = new_subscreen_overlay = nullptr; init_dmap(); if(game->get_continue_scrn() >= 0x80) diff --git a/src/zq/ffasm.cpp b/src/zq/ffasm.cpp index a2f7eb373e..1854e836f9 100644 --- a/src/zq/ffasm.cpp +++ b/src/zq/ffasm.cpp @@ -2656,7 +2656,7 @@ script_variable variable_list[]= { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0}, { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0}, { "GAMEOVERRIDEITEMS", GAMEOVERRIDEITEMS, 0, 0}, - { "RESRVD_VAR_EMILY44", RESRVD_VAR_EMILY44, 0, 0}, + { "DMAPDATASUBSCRO", DMAPDATASUBSCRO, 0, 0}, { "RESRVD_VAR_EMILY45", RESRVD_VAR_EMILY45, 0, 0}, { "RESRVD_VAR_EMILY46", RESRVD_VAR_EMILY46, 0, 0}, { "RESRVD_VAR_EMILY47", RESRVD_VAR_EMILY47, 0, 0}, diff --git a/src/zq/zq_class.cpp b/src/zq/zq_class.cpp index a684cb6ed9..e10b56648a 100644 --- a/src/zq/zq_class.cpp +++ b/src/zq/zq_class.cpp @@ -8018,7 +8018,9 @@ int32_t writedmaps(PACKFILE *f, word version, word build, word start_dmap, word { new_return(45); } - } + if(!p_putc(DMaps[i].overlay_subscreen, f)) + new_return(46); + } if(writecycle==0) { @@ -12264,13 +12266,36 @@ int32_t writesubscreens(PACKFILE *f, zquestheader *Header) writesize=0; - byte sz = new_subscreen.size(); + byte sz = subscreens_active.size(); if(!p_putc(sz,f)) new_return(5); + for(int32_t i=0; i1) - { - bool singular = subscr_edit.pages.size()==2; - std::string pgs = singular ? "page 2" : fmt::format("pages 2-{}",subscr_edit.pages.size()); - AlertDialog(fmt::format("Delete Page{}",singular?"":"s"), - fmt::format("Are you sure you want to delete {} by" - " switching to a passive subscreen?", pgs), - [&](bool ret,bool) - { - run = ret; - }).show(); - } - if(!run) return D_O_K; - - if(subscr_edit.sub_type == sstPASSIVE) - { - subscr_edit.sub_type = sstACTIVE; - subscreen_dlg[3].h=172*2-4; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - else - { - subscr_edit.sub_type = sstPASSIVE; - subscreen_dlg[3].h=116; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - while(subscr_edit.pages.size() > 1) - subscr_edit.delete_page(1); - } - update_subscr_dlg(false); - return D_REDRAW; -} - - const char *color_str[16] = { - "Black", "Blue", "Green", "Cyan", "Red", "Magenta", "Brown", "Light Gray", - "Dark Gray", "Light Blue", "Light Green", "Light Cyan", "Light Red", "Light Magenta", "Yellow", "White" + "Black", "Blue", "Green", "Cyan", "Red", "Magenta", "Brown", "Light Gray", + "Dark Gray", "Light Blue", "Light Green", "Light Cyan", "Light Red", "Light Magenta", "Yellow", "White" }; const char *colorlist(int32_t index, int32_t *list_size) { - if(index<0) - { - *list_size = 16; - return NULL; - } - - return color_str[index]; + if(index<0) + { + *list_size = 16; + return NULL; + } + + return color_str[index]; } static ListData color_list(colorlist, &font); static DIALOG grid_dlg[] = { - // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) - { jwin_win_proc, 0, 0, 158, 120, vc(0), vc(11), 0, D_EXIT, 0, 0, (void *) "Edit Grid Properties", NULL, NULL }, - { jwin_button_proc, 18, 95, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, - { jwin_button_proc, 81, 95, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, - { jwin_text_proc, 6, 29, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "X Size:", NULL, NULL }, - { jwin_edit_proc, 42, 25, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, - // 5 - { jwin_text_proc, 6, 49, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Y Size:", NULL, NULL }, - { jwin_edit_proc, 42, 45, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, - { jwin_text_proc, 78, 29, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "X Offset:", NULL, NULL }, - { jwin_edit_proc, 126, 25, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, - { jwin_text_proc, 78, 49, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Y Offset:", NULL, NULL }, - // 10 - { jwin_edit_proc, 126, 45, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, - { jwin_text_proc, 6, 69, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Color:", NULL, NULL }, - { jwin_droplist_proc, 36, 65, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, - { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } + // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) + { jwin_win_proc, 0, 0, 158, 120, vc(0), vc(11), 0, D_EXIT, 0, 0, (void *) "Edit Grid Properties", NULL, NULL }, + { jwin_button_proc, 18, 95, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, + { jwin_button_proc, 81, 95, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, + { jwin_text_proc, 6, 29, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "X Size:", NULL, NULL }, + { jwin_edit_proc, 42, 25, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, + // 5 + { jwin_text_proc, 6, 49, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Y Size:", NULL, NULL }, + { jwin_edit_proc, 42, 45, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, + { jwin_text_proc, 78, 29, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "X Offset:", NULL, NULL }, + { jwin_edit_proc, 126, 25, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, + { jwin_text_proc, 78, 49, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Y Offset:", NULL, NULL }, + // 10 + { jwin_edit_proc, 126, 45, 26, 16, 0, 0, 0, 0, 3, 0, NULL, NULL, NULL }, + { jwin_text_proc, 6, 69, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Color:", NULL, NULL }, + { jwin_droplist_proc, 36, 65, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, + { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, + { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; static DIALOG sel_options_dlg[] = { - // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) - { jwin_win_proc, 0, 0, 225, 120, vc(0), vc(11), 0, D_EXIT, 0, 0, (void *) "Selection Options", NULL, NULL }, - { jwin_button_proc, 51, 95, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, - { jwin_button_proc, 114, 95, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, - { jwin_frame_proc, 6, 28, 213, 51, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, FR_ETCHED, 0, NULL, NULL, NULL }, - { jwin_text_proc, 10, 25, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) " Selection Outlines ", NULL, NULL }, - // 5 - { jwin_text_proc, 14, 41, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Primary Color:", NULL, NULL }, - { jwin_droplist_proc, 94, 37, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, - { jwin_text_proc, 14, 61, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Secondary Color:", NULL, NULL }, - { jwin_droplist_proc, 94, 57, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, - { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } + // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) + { jwin_win_proc, 0, 0, 225, 120, vc(0), vc(11), 0, D_EXIT, 0, 0, (void *) "Selection Options", NULL, NULL }, + { jwin_button_proc, 51, 95, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, + { jwin_button_proc, 114, 95, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, + { jwin_frame_proc, 6, 28, 213, 51, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, FR_ETCHED, 0, NULL, NULL, NULL }, + { jwin_text_proc, 10, 25, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) " Selection Outlines ", NULL, NULL }, + // 5 + { jwin_text_proc, 14, 41, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Primary Color:", NULL, NULL }, + { jwin_droplist_proc, 94, 37, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, + { jwin_text_proc, 14, 61, 186, 16, 0, 0, 0, 0, 0, 0, (void *) "Secondary Color:", NULL, NULL }, + { jwin_droplist_proc, 94, 57, 116, 16, 0, 0, 0, 0, 0, 0, (void *) &color_list, NULL, NULL }, + { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, + { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; SubscrWidget* create_new_widget_of(int32_t type, int x, int y) @@ -1432,14 +1406,14 @@ SubscrWidget* create_new_widget_of(int32_t type, int x, int y) SubscrWidget* create_new_widget(int x, int y) { SubscrWidgListerDialog().show(); //pick an index! - + return create_new_widget_of(lister_sel_val, x, y); } int32_t onNewSubscreenObject() { create_new_widget(); - return D_O_K; + return D_O_K; } @@ -1572,15 +1546,15 @@ void grid_snap_objects(bool *selection, int32_t snap_type) typedef struct dist_obj { - int32_t index; - int32_t l; - int32_t t; - int32_t w; - int32_t h; - int32_t r; - int32_t b; - int32_t c; - int32_t m; + int32_t index; + int32_t l; + int32_t t; + int32_t w; + int32_t h; + int32_t r; + int32_t b; + int32_t c; + int32_t m; } dist_obj; void distribute_objects(bool *, int32_t distribute_type) @@ -1732,144 +1706,144 @@ void distribute_objects(bool *, int32_t distribute_type) int32_t onReverseArrangement() { auto& pg = subscr_edit.cur_page(); - int32_t i=0; - int32_t j=pg.contents.size()-1; - subscreen_object tempsso; - - sso_selection[curr_widg]=true; - - while(true) - { - while(i=0 && !sso_selection[j]) - j--; - - if(i>=j) - { - sso_selection[curr_widg]=false; - return D_O_K; - } - - if(curr_widg==i) - curr_widg=j; - else if(curr_widg==j) - curr_widg=i; + int32_t i=0; + int32_t j=pg.contents.size()-1; + subscreen_object tempsso; + + sso_selection[curr_widg]=true; + + while(true) + { + while(i=0 && !sso_selection[j]) + j--; + + if(i>=j) + { + sso_selection[curr_widg]=false; + return D_O_K; + } + + if(curr_widg==i) + curr_widg=j; + else if(curr_widg==j) + curr_widg=i; zc_swap(pg.contents[i],pg.contents[j]); - - i++; - j--; - } + + i++; + j--; + } } int32_t onAlignLeft() { - align_objects(sso_selection, ssoaLEFT); - return D_O_K; + align_objects(sso_selection, ssoaLEFT); + return D_O_K; } int32_t onAlignCenter() { - align_objects(sso_selection, ssoaCENTER); - return D_O_K; + align_objects(sso_selection, ssoaCENTER); + return D_O_K; } int32_t onAlignRight() { - align_objects(sso_selection, ssoaRIGHT); - return D_O_K; + align_objects(sso_selection, ssoaRIGHT); + return D_O_K; } int32_t onAlignTop() { - align_objects(sso_selection, ssoaTOP); - return D_O_K; + align_objects(sso_selection, ssoaTOP); + return D_O_K; } int32_t onAlignMiddle() { - align_objects(sso_selection, ssoaMIDDLE); - return D_O_K; + align_objects(sso_selection, ssoaMIDDLE); + return D_O_K; } int32_t onAlignBottom() { - align_objects(sso_selection, ssoaBOTTOM); - return D_O_K; + align_objects(sso_selection, ssoaBOTTOM); + return D_O_K; } int32_t onDistributeLeft() { - distribute_objects(sso_selection, ssodLEFT); - return D_O_K; + distribute_objects(sso_selection, ssodLEFT); + return D_O_K; } int32_t onDistributeCenter() { - distribute_objects(sso_selection, ssodCENTER); - return D_O_K; + distribute_objects(sso_selection, ssodCENTER); + return D_O_K; } int32_t onDistributeRight() { - distribute_objects(sso_selection, ssodRIGHT); - return D_O_K; + distribute_objects(sso_selection, ssodRIGHT); + return D_O_K; } int32_t onDistributeTop() { - distribute_objects(sso_selection, ssodTOP); - return D_O_K; + distribute_objects(sso_selection, ssodTOP); + return D_O_K; } int32_t onDistributeMiddle() { - distribute_objects(sso_selection, ssodMIDDLE); - return D_O_K; + distribute_objects(sso_selection, ssodMIDDLE); + return D_O_K; } int32_t onDistributeBottom() { - distribute_objects(sso_selection, ssodBOTTOM); - return D_O_K; + distribute_objects(sso_selection, ssodBOTTOM); + return D_O_K; } int32_t onGridSnapLeft() { - grid_snap_objects(sso_selection, ssosLEFT); - return D_O_K; + grid_snap_objects(sso_selection, ssosLEFT); + return D_O_K; } int32_t onGridSnapCenter() { - grid_snap_objects(sso_selection, ssosCENTER); - return D_O_K; + grid_snap_objects(sso_selection, ssosCENTER); + return D_O_K; } int32_t onGridSnapRight() { - grid_snap_objects(sso_selection, ssosRIGHT); - return D_O_K; + grid_snap_objects(sso_selection, ssosRIGHT); + return D_O_K; } int32_t onGridSnapTop() { - grid_snap_objects(sso_selection, ssosTOP); - return D_O_K; + grid_snap_objects(sso_selection, ssosTOP); + return D_O_K; } int32_t onGridSnapMiddle() { - grid_snap_objects(sso_selection, ssosMIDDLE); - return D_O_K; + grid_snap_objects(sso_selection, ssosMIDDLE); + return D_O_K; } int32_t onGridSnapBottom() { - grid_snap_objects(sso_selection, ssosBOTTOM); - return D_O_K; + grid_snap_objects(sso_selection, ssosBOTTOM); + return D_O_K; } static int32_t onToggleInvis() @@ -1884,21 +1858,21 @@ static int32_t onToggleShowUnowned() zq_ignore_item_ownership = !zq_ignore_item_ownership; SETFLAG(ss_view_menu[4].flags, D_SELECTED, zq_ignore_item_ownership); zc_set_config("editsubscr","show_all_items",zq_ignore_item_ownership?1:0); - return D_O_K; + return D_O_K; } static int32_t onToggleMaxCtr() { zq_view_fullctr = !zq_view_fullctr; SETFLAG(ss_view_menu[6].flags, D_SELECTED, zq_view_fullctr); zc_set_config("editsubscr","show_full_counters",zq_view_fullctr?1:0); - return D_O_K; + return D_O_K; } static int32_t onToggleMaxMaxCtr() { zq_view_maxctr = !zq_view_maxctr; SETFLAG(ss_view_menu[7].flags, D_SELECTED, zq_view_maxctr); zc_set_config("editsubscr","show_maxed_maxcounters",zq_view_maxctr?1:0); - return D_O_K; + return D_O_K; } static int32_t onToggleNoInf() { @@ -1907,7 +1881,7 @@ static int32_t onToggleNoInf() zq_view_noinf = !zq_view_noinf; SETFLAG(ss_view_menu[8].flags, D_SELECTED, zq_view_noinf); zc_set_config("editsubscr","show_no_infinites",zq_view_noinf?1:0); - return D_O_K; + return D_O_K; } static int32_t onToggleAllInf() { @@ -1916,110 +1890,110 @@ static int32_t onToggleAllInf() zq_view_allinf = !zq_view_allinf; SETFLAG(ss_view_menu[9].flags, D_SELECTED, zq_view_allinf); zc_set_config("editsubscr","show_all_infinites",zq_view_allinf?1:0); - return D_O_K; + return D_O_K; } static int32_t onToggleConfDelete() { subscr_confirm_delete = !subscr_confirm_delete; SETFLAG(ss_settings_menu[3].flags, D_SELECTED, subscr_confirm_delete); zc_set_config("editsubscr","confirm_delete",subscr_confirm_delete?1:0); - return D_O_K; + return D_O_K; } static int32_t onEditGrid() { - grid_dlg[0].dp2=get_zc_font(font_lfont); - char xsize[11]; - char ysize[11]; - char xoffset[4]; - char yoffset[4]; - sprintf(xsize, "%d", zc_max(zinit.ss_grid_x,1)); - sprintf(ysize, "%d", zc_max(zinit.ss_grid_y,1)); - sprintf(xoffset, "%d", zinit.ss_grid_xofs); - sprintf(yoffset, "%d", zinit.ss_grid_yofs); - grid_dlg[4].dp=xsize; - grid_dlg[6].dp=ysize; - grid_dlg[8].dp=xoffset; - grid_dlg[10].dp=yoffset; - grid_dlg[12].d1=zinit.ss_grid_color; - - large_dialog(grid_dlg); - - int32_t ret = zc_popup_dialog(grid_dlg,2); - - if(ret==1) - { - zinit.ss_grid_x=zc_max(atoi(xsize),1); - zinit.ss_grid_xofs=atoi(xoffset); - zinit.ss_grid_y=zc_max(atoi(ysize),1); - zinit.ss_grid_yofs=atoi(yoffset); - zinit.ss_grid_color=grid_dlg[12].d1; - } - - return D_O_K; + grid_dlg[0].dp2=get_zc_font(font_lfont); + char xsize[11]; + char ysize[11]; + char xoffset[4]; + char yoffset[4]; + sprintf(xsize, "%d", zc_max(zinit.ss_grid_x,1)); + sprintf(ysize, "%d", zc_max(zinit.ss_grid_y,1)); + sprintf(xoffset, "%d", zinit.ss_grid_xofs); + sprintf(yoffset, "%d", zinit.ss_grid_yofs); + grid_dlg[4].dp=xsize; + grid_dlg[6].dp=ysize; + grid_dlg[8].dp=xoffset; + grid_dlg[10].dp=yoffset; + grid_dlg[12].d1=zinit.ss_grid_color; + + large_dialog(grid_dlg); + + int32_t ret = zc_popup_dialog(grid_dlg,2); + + if(ret==1) + { + zinit.ss_grid_x=zc_max(atoi(xsize),1); + zinit.ss_grid_xofs=atoi(xoffset); + zinit.ss_grid_y=zc_max(atoi(ysize),1); + zinit.ss_grid_yofs=atoi(yoffset); + zinit.ss_grid_color=grid_dlg[12].d1; + } + + return D_O_K; } static int32_t onShowHideGrid() { - bool show=!(zinit.ss_flags&ssflagSHOWGRID); - zinit.ss_flags&=~ssflagSHOWGRID; - zinit.ss_flags|=(show?ssflagSHOWGRID:0); - ss_view_menu[1].flags=zinit.ss_flags&ssflagSHOWGRID?D_SELECTED:0; - return D_O_K; + bool show=!(zinit.ss_flags&ssflagSHOWGRID); + zinit.ss_flags&=~ssflagSHOWGRID; + zinit.ss_flags|=(show?ssflagSHOWGRID:0); + ss_view_menu[1].flags=zinit.ss_flags&ssflagSHOWGRID?D_SELECTED:0; + return D_O_K; } int32_t onSelectionOptions() { - sel_options_dlg[0].dp2=get_zc_font(font_lfont); - sel_options_dlg[6].d1=zinit.ss_bbox_1_color; - sel_options_dlg[8].d1=zinit.ss_bbox_2_color; - - large_dialog(sel_options_dlg); - - int32_t ret = zc_popup_dialog(sel_options_dlg,2); - - if(ret==1) - { - zinit.ss_bbox_1_color=sel_options_dlg[6].d1; - zinit.ss_bbox_2_color=sel_options_dlg[8].d1; - } - - return D_O_K; + sel_options_dlg[0].dp2=get_zc_font(font_lfont); + sel_options_dlg[6].d1=zinit.ss_bbox_1_color; + sel_options_dlg[8].d1=zinit.ss_bbox_2_color; + + large_dialog(sel_options_dlg); + + int32_t ret = zc_popup_dialog(sel_options_dlg,2); + + if(ret==1) + { + zinit.ss_bbox_1_color=sel_options_dlg[6].d1; + zinit.ss_bbox_2_color=sel_options_dlg[8].d1; + } + + return D_O_K; } void update_up_dn_btns() { - if(curr_widg<1) - { - subscreen_dlg[10].flags|=D_DISABLED; - } - else - { - subscreen_dlg[10].flags&=~D_DISABLED; - } - - if(curr_widg>=subscr_edit.cur_page().contents.size()-1) - { - subscreen_dlg[9].flags|=D_DISABLED; - } - else - { - subscreen_dlg[9].flags&=~D_DISABLED; - } - - subscreen_dlg[9].flags|=D_DIRTY; - subscreen_dlg[10].flags|=D_DIRTY; + if(curr_widg<1) + { + subscreen_dlg[11].flags|=D_DISABLED; + } + else + { + subscreen_dlg[11].flags&=~D_DISABLED; + } + + if(curr_widg>=subscr_edit.cur_page().contents.size()-1) + { + subscreen_dlg[10].flags|=D_DISABLED; + } + else + { + subscreen_dlg[10].flags&=~D_DISABLED; + } + + subscreen_dlg[10].flags|=D_DIRTY; + subscreen_dlg[11].flags|=D_DIRTY; } int32_t onSSCtrlPgUp() { - return onBringForward(); + return onBringForward(); } int32_t onSSCtrlPgDn() { - return onSendBackward(); + return onSendBackward(); } static bool send_backwd() @@ -2071,7 +2045,7 @@ int32_t onBringToFront() update_sso_name(); } update_up_dn_btns(); - return D_O_K; + return D_O_K; } int32_t onSendToBack() @@ -2082,118 +2056,118 @@ int32_t onSendToBack() update_sso_name(); } update_up_dn_btns(); - return D_O_K; + return D_O_K; } int32_t onSSPgDn() { - if(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]) - { - return onSSCtrlPgDn(); - } - else - { - --curr_widg; - - if(curr_widg<0) - { - curr_widg=subscr_edit.cur_page().contents.size()-1; - } - - update_sso_name(); - update_up_dn_btns(); - } - - return D_O_K; + if(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]) + { + return onSSCtrlPgDn(); + } + else + { + --curr_widg; + + if(curr_widg<0) + { + curr_widg=subscr_edit.cur_page().contents.size()-1; + } + + update_sso_name(); + update_up_dn_btns(); + } + + return D_O_K; } int32_t onSSPgUp() { - if(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]) - { - return onSSCtrlPgUp(); - } - else - { - if(!subscr_edit.cur_page().contents.empty()) - { - ++curr_widg; - - if(curr_widg>=subscr_edit.cur_page().contents.size()) - { - curr_widg=0; - } - } - - update_sso_name(); - update_up_dn_btns(); - } - - return D_O_K; + if(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]) + { + return onSSCtrlPgUp(); + } + else + { + if(!subscr_edit.cur_page().contents.empty()) + { + ++curr_widg; + + if(curr_widg>=subscr_edit.cur_page().contents.size()) + { + curr_widg=0; + } + } + + update_sso_name(); + update_up_dn_btns(); + } + + return D_O_K; } int32_t d_ssup_btn_proc(int32_t msg,DIALOG *d,int32_t c) { - switch(msg) - { - case MSG_CLICK: - { - jwin_iconbutton_proc(msg, d, c); - return onSSCtrlPgUp(); - } - break; - } - - return jwin_iconbutton_proc(msg, d, c); + switch(msg) + { + case MSG_CLICK: + { + jwin_iconbutton_proc(msg, d, c); + return onSSCtrlPgUp(); + } + break; + } + + return jwin_iconbutton_proc(msg, d, c); } int32_t d_ssdn_btn_proc(int32_t msg,DIALOG *d,int32_t c) { - switch(msg) - { - case MSG_CLICK: - { - jwin_iconbutton_proc(msg, d, c); - return onSSCtrlPgDn(); - } - break; - } - - return jwin_iconbutton_proc(msg, d, c); + switch(msg) + { + case MSG_CLICK: + { + jwin_iconbutton_proc(msg, d, c); + return onSSCtrlPgDn(); + } + break; + } + + return jwin_iconbutton_proc(msg, d, c); } int32_t d_sslt_btn_proc(int32_t msg,DIALOG *d,int32_t c) { - switch(msg) - { - case MSG_CLICK: - { - jwin_iconbutton_proc(msg, d, c); - onSSPgDn(); - return D_O_K; - } - break; - } - - return jwin_iconbutton_proc(msg, d, c); + switch(msg) + { + case MSG_CLICK: + { + jwin_iconbutton_proc(msg, d, c); + onSSPgDn(); + return D_O_K; + } + break; + } + + return jwin_iconbutton_proc(msg, d, c); } int32_t d_ssrt_btn_proc(int32_t msg,DIALOG *d,int32_t c) { - switch(msg) - { - case MSG_CLICK: - { - jwin_iconbutton_proc(msg, d, c); - onSSPgUp(); - return D_O_K; - } - break; - } - - return jwin_iconbutton_proc(msg, d, c); + switch(msg) + { + case MSG_CLICK: + { + jwin_iconbutton_proc(msg, d, c); + onSSPgUp(); + return D_O_K; + } + break; + } + + return jwin_iconbutton_proc(msg, d, c); } -int dlg_fontheight(DIALOG const& d) +int dlg_fh(DIALOG const& d) { if(d.dp2) return text_height((FONT*)d.dp2); @@ -2208,8 +2182,9 @@ int dlg_fontlen(DIALOG const& d,char const* ptr = nullptr) } void update_subscr_dlg(bool start) { + auto const& subty = subscr_edit.sub_type; if(start) - { + { subscreen_dlg[0].dp2=get_zc_font(font_lfont); refresh_subscr_items(); curr_widg=0; @@ -2227,54 +2202,40 @@ void update_subscr_dlg(bool start) ss_view_menu[3].flags=zinit.ss_flags&ssflagSHOWINVIS?D_SELECTED:0; ss_view_menu[1].flags=zinit.ss_flags&ssflagSHOWGRID?D_SELECTED:0; - subscreen_dlg[4].dp=(void *)&subscr_edit; - subscreen_dlg[5].fg=jwin_pal[jcBOX]; - subscreen_dlg[5].bg=jwin_pal[jcBOX]; + subscreen_dlg[5].dp=(void *)&subscr_edit; + subscreen_dlg[6].fg=jwin_pal[jcBOX]; + subscreen_dlg[6].bg=jwin_pal[jcBOX]; strncpy(subscr_namebuf,subscr_edit.name.c_str(),63); - subscreen_dlg[6].dp=(void *)str_oname; - subscreen_dlg[55].dp=(void *)str_cpyname; - subscreen_dlg[8].dp=(void *)subscr_namebuf; - if(propCopyWidg) - { - delete propCopyWidg; - propCopyWidg = nullptr; - copied_page = -1; - } + subscreen_dlg[7].dp=(void *)str_oname; + subscreen_dlg[56].dp=(void *)str_cpyname; + subscreen_dlg[9].dp=(void *)subscr_namebuf; + copied_page = -1; update_sso_name(); - subscreen_dlg[10].flags|=D_DISABLED; + subscreen_dlg[11].flags|=D_DISABLED; - if(subscr_edit.sub_type==sstPASSIVE) + if(subscr_edit.sub_type==sstACTIVE) { - subscreen_dlg[21].flags|=D_DISABLED; - subscreen_dlg[22].flags|=D_DISABLED; - subscreen_dlg[23].flags|=D_DISABLED; - subscreen_dlg[24].flags|=D_DISABLED; - } - else - { - subscreen_dlg[21].flags&=~D_DISABLED; subscreen_dlg[22].flags&=~D_DISABLED; subscreen_dlg[23].flags&=~D_DISABLED; subscreen_dlg[24].flags&=~D_DISABLED; + subscreen_dlg[25].flags&=~D_DISABLED; + } + else + { + subscreen_dlg[22].flags|=D_DISABLED; + subscreen_dlg[23].flags|=D_DISABLED; + subscreen_dlg[24].flags|=D_DISABLED; + subscreen_dlg[25].flags|=D_DISABLED; } subscr_edit.cur_page().move_legacy(SEL_VERIFY_RIGHT); - bool enlarge = subscreen_dlg[0].d1==0; - - if(enlarge) + if(!subscreen_dlg[0].d1) { large_dialog(subscreen_dlg,2); - subscreen_dlg[4].y-=32; - subscreen_dlg[3].y-=31; - subscreen_dlg[3].x+=1; - - if(subscr_edit.sub_type == sstPASSIVE) - subscreen_dlg[3].h=60*2-4; - else if(subscr_edit.sub_type == sstACTIVE) - subscreen_dlg[3].h=172*2-4; - - subscreen_dlg[4].h=subscreen_dlg[3].h-4; + subscreen_dlg[5].y-=32; + subscreen_dlg[4].y-=31; + subscreen_dlg[4].x+=1; } //Some fancier stuff for the subscreen update @@ -2288,19 +2249,42 @@ void update_subscr_dlg(bool start) subscreen_dlg[q].dp2 = (void*)get_custom_font(CFONT_GUI); } } - subscreen_dlg[0].h = 474 + 2 + dlg_fontheight(subscreen_dlg[6]) + dlg_fontheight(subscreen_dlg[55]); - subscreen_dlg[8].y = subscreen_dlg[0].y + subscreen_dlg[0].h - 6 - subscreen_dlg[8].h; - subscreen_dlg[8].x = subscreen_dlg[7].x + dlg_fontlen(subscreen_dlg[7]) + 2; - subscreen_dlg[7].y = subscreen_dlg[8].y + (subscreen_dlg[8].h/2) - - dlg_fontheight(subscreen_dlg[7])/2; - subscreen_dlg[6].y = subscreen_dlg[8].y - 2 - dlg_fontheight(subscreen_dlg[6]); - subscreen_dlg[55].y = subscreen_dlg[6].y-dlg_fontheight(subscreen_dlg[55]); + int hei, winhei = 476 + dlg_fh(subscreen_dlg[7]) + dlg_fh(subscreen_dlg[56]); + switch(subty) + { + default: + case sstACTIVE: + strcpy(subscr_titlebuf,"Active Subscreen Editor"); + hei = 168; + break; + case sstPASSIVE: + strcpy(subscr_titlebuf,"Passive Subscreen Editor"); + hei = 56; + winhei -= 40; + break; + case sstOVERLAY: + strcpy(subscr_titlebuf,"Overlay Subscreen Editor"); + hei = 224; + winhei += 56; + break; + } + subscreen_dlg[0].h = winhei; + jwin_center_dialog(subscreen_dlg); + subscreen_dlg[5].h=hei*2; + subscreen_dlg[4].h=subscreen_dlg[5].h+4; + subscreen_dlg[9].y = subscreen_dlg[0].y + subscreen_dlg[0].h - 6 - subscreen_dlg[9].h; + subscreen_dlg[9].x = subscreen_dlg[8].x + dlg_fontlen(subscreen_dlg[8]) + 2; + subscreen_dlg[8].y = subscreen_dlg[9].y + (subscreen_dlg[9].h/2) + - dlg_fh(subscreen_dlg[8])/2; + subscreen_dlg[7].y = subscreen_dlg[9].y - 2 - dlg_fh(subscreen_dlg[7]); + subscreen_dlg[56].y = subscreen_dlg[7].y-dlg_fh(subscreen_dlg[56]); { //complex maths- line up strings by their first ':' - subscreen_dlg[55].x = subscreen_dlg[6].x = subscreen_dlg[8].x; - DIALOG* dlgs[] = {&subscreen_dlg[6],&subscreen_dlg[55]}; + subscreen_dlg[56].x = subscreen_dlg[7].x = subscreen_dlg[9].x; + DIALOG* dlgs[] = {&subscreen_dlg[7],&subscreen_dlg[56]}; char tmpstr[512] = {0}; int maxlen=0; int lens[2]; + int found = 0; for(int ind = 0; ind < 2; ++ind) { char const* str = (char const*)dlgs[ind]->dp; @@ -2310,6 +2294,7 @@ void update_subscr_dlg(bool start) if(tmpstr[q] == ':') { tmpstr[q+1] = 0; + ++found; break; } } @@ -2318,46 +2303,57 @@ void update_subscr_dlg(bool start) if(len > maxlen) maxlen = len; } - for(int ind = 0; ind < 2; ++ind) + if(found == 2) { - dlgs[ind]->x += maxlen-lens[ind]; + for(int ind = 0; ind < 2; ++ind) + dlgs[ind]->x += maxlen-lens[ind]; } } - subscreen_dlg[49].y = subscreen_dlg[48].y = subscreen_dlg[47].y = - subscreen_dlg[46].y = subscreen_dlg[45].y = - subscreen_dlg[3].y+168*2+2; - subscreen_dlg[45].y += (subscreen_dlg[46].h-dlg_fontheight(subscreen_dlg[45]))/2; + subscreen_dlg[50].y = subscreen_dlg[49].y = subscreen_dlg[48].y = + subscreen_dlg[47].y = subscreen_dlg[46].y = + subscreen_dlg[4].y+168*2+2; + subscreen_dlg[46].y += (subscreen_dlg[47].h-dlg_fh(subscreen_dlg[46]))/2; - subscreen_dlg[50].y = subscreen_dlg[51].y = subscreen_dlg[52].y = - subscreen_dlg[53].y = subscreen_dlg[54].y = - subscreen_dlg[49].y+subscreen_dlg[49].h; + subscreen_dlg[51].y = subscreen_dlg[52].y = subscreen_dlg[53].y = + subscreen_dlg[54].y = subscreen_dlg[55].y = + subscreen_dlg[50].y+subscreen_dlg[50].h; subscreen_dlg[1].y = subscreen_dlg[2].y = - subscreen_dlg[8].y+subscreen_dlg[8].h-subscreen_dlg[1].h; - subscreen_dlg[2].x = subscreen_dlg[12].x+subscreen_dlg[12].w-subscreen_dlg[2].w; + subscreen_dlg[9].y+subscreen_dlg[9].h-subscreen_dlg[1].h; + subscreen_dlg[2].x = subscreen_dlg[13].x+subscreen_dlg[13].w-subscreen_dlg[2].w; subscreen_dlg[1].x = subscreen_dlg[2].x-subscreen_dlg[1].w; - subscreen_dlg[8].w = subscreen_dlg[1].x-subscreen_dlg[8].x-2; + subscreen_dlg[9].w = subscreen_dlg[1].x-subscreen_dlg[9].x-2; + + subscreen_dlg[3].x = subscreen_dlg[0].x+2; + subscreen_dlg[3].y = subscreen_dlg[5].y+(56*2); + subscreen_dlg[3].d1 = 3; + subscreen_dlg[3].fg = vc(15); + if(subty == sstOVERLAY) + { + subscreen_dlg[3].w = subscreen_dlg[5].w+2*(subscreen_dlg[5].x-subscreen_dlg[0].x-2); + } + else subscreen_dlg[3].w = 0; } } - bool nopages = subscr_edit.sub_type==sstPASSIVE; - for(int q = 45; q <= 54; ++q) + bool nopages = subty!=sstACTIVE; + for(int q = 46; q <= 55; ++q) SETFLAG(subscreen_dlg[q].flags,D_HIDDEN,nopages); if(!nopages) { sprintf(pgbuf, "Pg %d/%zd", subscr_edit.curpage+1,subscr_edit.pages.size()); - SETFLAG(subscreen_dlg[46].flags,D_DISABLED,subscr_edit.curpage<1); - SETFLAG(subscreen_dlg[47].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); - SETFLAG(subscreen_dlg[49].flags,D_DISABLED,subscr_edit.pages.size()>=MAX_SUBSCR_PAGES); - SETFLAG(subscreen_dlg[50].flags,D_DISABLED,subscr_edit.curpage<1); - SETFLAG(subscreen_dlg[52].flags,D_DISABLED,subscr_edit.curpage<1); - SETFLAG(subscreen_dlg[51].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); - SETFLAG(subscreen_dlg[53].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); - int tw = 8+dlg_fontlen(subscreen_dlg[45]); - subscreen_dlg[50].x = subscreen_dlg[46].x = subscreen_dlg[45].x-(tw/2)-subscreen_dlg[46].w; - subscreen_dlg[51].x = subscreen_dlg[47].x = subscreen_dlg[45].x+(tw/2); - subscreen_dlg[52].x = subscreen_dlg[48].x = subscreen_dlg[46].x - subscreen_dlg[48].w; - subscreen_dlg[53].x = subscreen_dlg[49].x = subscreen_dlg[47].x + subscreen_dlg[47].w; - subscreen_dlg[54].x = subscreen_dlg[45].x - subscreen_dlg[54].w/2; + SETFLAG(subscreen_dlg[47].flags,D_DISABLED,subscr_edit.curpage<1); + SETFLAG(subscreen_dlg[48].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); + SETFLAG(subscreen_dlg[50].flags,D_DISABLED,subscr_edit.pages.size()>=MAX_SUBSCR_PAGES); + SETFLAG(subscreen_dlg[51].flags,D_DISABLED,subscr_edit.curpage<1); + SETFLAG(subscreen_dlg[53].flags,D_DISABLED,subscr_edit.curpage<1); + SETFLAG(subscreen_dlg[52].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); + SETFLAG(subscreen_dlg[54].flags,D_DISABLED,subscr_edit.curpage>=subscr_edit.pages.size()-1); + int tw = 8+dlg_fontlen(subscreen_dlg[46]); + subscreen_dlg[51].x = subscreen_dlg[47].x = subscreen_dlg[46].x-(tw/2)-subscreen_dlg[47].w; + subscreen_dlg[52].x = subscreen_dlg[48].x = subscreen_dlg[46].x+(tw/2); + subscreen_dlg[53].x = subscreen_dlg[49].x = subscreen_dlg[47].x - subscreen_dlg[49].w; + subscreen_dlg[54].x = subscreen_dlg[50].x = subscreen_dlg[48].x + subscreen_dlg[48].w; + subscreen_dlg[55].x = subscreen_dlg[46].x - subscreen_dlg[55].w/2; } // Disable pastes if no copies bool nocopies = (!propCopyWidg || propCopyWidg->getType()==widgNULL); @@ -2392,27 +2388,27 @@ bool edit_subscreen() { switch(ret) { - case 46: // Page Left + case 47: // Page Left if(subscr_edit.curpage > 0) --subscr_edit.curpage; break; - case 50: // Page Start + case 51: // Page Start subscr_edit.curpage = 0; break; - case 47: // Page Right + case 48: // Page Right if(subscr_edit.curpage < subscr_edit.pages.size()-1) ++subscr_edit.curpage; break; - case 51: // Page End + case 52: // Page End subscr_edit.curpage = subscr_edit.pages.size()-1; break; - case 52: // Swap Left + case 53: // Swap Left subscr_edit.swap_pages(subscr_edit.curpage,subscr_edit.curpage-1); break; - case 53: // Swap Right + case 54: // Swap Right subscr_edit.swap_pages(subscr_edit.curpage,subscr_edit.curpage+1); break; - case 48: // Del Page + case 49: // Del Page { auto count = subscr_edit.cur_page().contents.size(); bool del = !count; @@ -2431,7 +2427,7 @@ bool edit_subscreen() subscr_edit.delete_page(subscr_edit.curpage); break; } - case 49: // New Page + case 50: // New Page subscr_edit.add_page(subscr_edit.curpage+1); break; } @@ -2456,86 +2452,86 @@ bool edit_subscreen() const char *allsubscrtype_str[30] = { - "Original (Top, Triforce)", "Original (Top, Map)", - "New Subscreen (Top, Triforce)", "New Subscreen (Top, Map)", - "Revision 2 (Top, Triforce)", "Revision 2 (Top, Map)", - "BS Zelda Original (Top, Triforce)", "BS Zelda Original (Top, Map)", - "BS Zelda Modified (Top, Triforce)", "BS Zelda Modified (Top, Map)", - "BS Zelda Enhanced (Top, Triforce)", "BS Zelda Enhanced (Top, Map)", - "BS Zelda Complete (Top, Triforce)", "BS Zelda Complete (Top, Map)", - "Zelda 3 (Top)", - "Original (Bottom, Magic)", "Original (Bottom, No Magic)", - "New Subscreen (Bottom, Magic)", "New Subscreen (Bottom, No Magic)", - "Revision 2 (Bottom, Magic)", "Revision 2 (Bottom, No Magic)", - "BS Zelda Original (Bottom, Magic)", "BS Zelda Original (Bottom, No Magic)", - "BS Zelda Modified (Bottom, Magic)", "BS Zelda Modified (Bottom, No Magic)", - "BS Zelda Enhanced (Bottom, Magic)", "BS Zelda Enhanced (Bottom, No Magic)", - "BS Zelda Complete (Bottom, Magic)", "BS Zelda Complete (Bottom, No Magic)", - "Zelda 3 (Bottom)" + "Original (Top, Triforce)", "Original (Top, Map)", + "New Subscreen (Top, Triforce)", "New Subscreen (Top, Map)", + "Revision 2 (Top, Triforce)", "Revision 2 (Top, Map)", + "BS Zelda Original (Top, Triforce)", "BS Zelda Original (Top, Map)", + "BS Zelda Modified (Top, Triforce)", "BS Zelda Modified (Top, Map)", + "BS Zelda Enhanced (Top, Triforce)", "BS Zelda Enhanced (Top, Map)", + "BS Zelda Complete (Top, Triforce)", "BS Zelda Complete (Top, Map)", + "Zelda 3 (Top)", + "Original (Bottom, Magic)", "Original (Bottom, No Magic)", + "New Subscreen (Bottom, Magic)", "New Subscreen (Bottom, No Magic)", + "Revision 2 (Bottom, Magic)", "Revision 2 (Bottom, No Magic)", + "BS Zelda Original (Bottom, Magic)", "BS Zelda Original (Bottom, No Magic)", + "BS Zelda Modified (Bottom, Magic)", "BS Zelda Modified (Bottom, No Magic)", + "BS Zelda Enhanced (Bottom, Magic)", "BS Zelda Enhanced (Bottom, No Magic)", + "BS Zelda Complete (Bottom, Magic)", "BS Zelda Complete (Bottom, No Magic)", + "Zelda 3 (Bottom)" }; const char *activesubscrtype_str[16] = { - "Blank", - "Original (Top, Triforce)", "Original (Top, Map)", - "New Subscreen (Top, Triforce)", "New Subscreen (Top, Map)", - "Revision 2 (Top, Triforce)", "Revision 2 (Top, Map)", - "BS Zelda Original (Top, Triforce)", "BS Zelda Original (Top, Map)", - "BS Zelda Modified (Top, Triforce)", "BS Zelda Modified (Top, Map)", - "BS Zelda Enhanced (Top, Triforce)", "BS Zelda Enhanced (Top, Map)", - "BS Zelda Complete (Top, Triforce)", "BS Zelda Complete (Top, Map)", - "Zelda 3 (Top)" + "Blank", + "Original (Top, Triforce)", "Original (Top, Map)", + "New Subscreen (Top, Triforce)", "New Subscreen (Top, Map)", + "Revision 2 (Top, Triforce)", "Revision 2 (Top, Map)", + "BS Zelda Original (Top, Triforce)", "BS Zelda Original (Top, Map)", + "BS Zelda Modified (Top, Triforce)", "BS Zelda Modified (Top, Map)", + "BS Zelda Enhanced (Top, Triforce)", "BS Zelda Enhanced (Top, Map)", + "BS Zelda Complete (Top, Triforce)", "BS Zelda Complete (Top, Map)", + "Zelda 3 (Top)" }; const char *activelist(int32_t index, int32_t *list_size) { - if(index<0) - { - *list_size = 16; - return NULL; - } - - return activesubscrtype_str[index]; + if(index<0) + { + *list_size = 16; + return NULL; + } + + return activesubscrtype_str[index]; } const char *passivesubscrtype_str[16] = { - "Blank", - "Original (Bottom, Magic)", "Original (Bottom, No Magic)", - "New Subscreen (Bottom, Magic)", "New Subscreen (Bottom, No Magic)", - "Revision 2 (Bottom, Magic)", "Revision 2 (Bottom, No Magic)", - "BS Zelda Original (Bottom, Magic)", "BS Zelda Original (Bottom, No Magic)", - "BS Zelda Modified (Bottom, Magic)", "BS Zelda Modified (Bottom, No Magic)", - "BS Zelda Enhanced (Bottom, Magic)", "BS Zelda Enhanced (Bottom, No Magic)", - "BS Zelda Complete (Bottom, Magic)", "BS Zelda Complete (Bottom, No Magic)", - "Zelda 3 (Bottom)" + "Blank", + "Original (Bottom, Magic)", "Original (Bottom, No Magic)", + "New Subscreen (Bottom, Magic)", "New Subscreen (Bottom, No Magic)", + "Revision 2 (Bottom, Magic)", "Revision 2 (Bottom, No Magic)", + "BS Zelda Original (Bottom, Magic)", "BS Zelda Original (Bottom, No Magic)", + "BS Zelda Modified (Bottom, Magic)", "BS Zelda Modified (Bottom, No Magic)", + "BS Zelda Enhanced (Bottom, Magic)", "BS Zelda Enhanced (Bottom, No Magic)", + "BS Zelda Complete (Bottom, Magic)", "BS Zelda Complete (Bottom, No Magic)", + "Zelda 3 (Bottom)" }; const char *passivelist(int32_t index, int32_t *list_size) { - if(index<0) - { - *list_size = 16; - return NULL; - } - - return passivesubscrtype_str[index]; + if(index<0) + { + *list_size = 16; + return NULL; + } + + return passivesubscrtype_str[index]; } const char *activepassive_str[sstMAX] = { - "Active", "Passive" + "Active", "Passive" }; const char *activepassivelist(int32_t index, int32_t *list_size) { - if(index<0) - { - *list_size = sstMAX; - return NULL; - } - - return activepassive_str[index]; + if(index<0) + { + *list_size = sstMAX; + return NULL; + } + + return activepassive_str[index]; } static ListData passive_list(passivelist, &font); @@ -2543,240 +2539,174 @@ static ListData active_list(activelist, &font); int32_t sstype_drop_proc(int32_t msg,DIALOG *d,int32_t c) { - int32_t tempd1=d->d1; - int32_t ret=jwin_droplist_proc(msg,d,c); - - if(tempd1!=d->d1) - { - (d+1)->dp=(d->d1)?(void*)&passive_list:(void*)&active_list; - object_message(d+1,MSG_START,0); - (d+1)->flags|=D_DIRTY; - } - - return ret; + int32_t tempd1=d->d1; + int32_t ret=jwin_droplist_proc(msg,d,c); + + if(tempd1!=d->d1) + { + (d+1)->dp=(d->d1)?(void*)&passive_list:(void*)&active_list; + object_message(d+1,MSG_START,0); + (d+1)->flags|=D_DIRTY; + } + + return ret; } static ListData activepassive_list(activepassivelist, &font); static DIALOG sstemplatelist_dlg[] = { - // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) - { jwin_win_proc, 0, 0, 265, 87, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "New Subscreen", NULL, NULL }, - { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, - { jwin_text_proc, 4, 28, 8, 8, 0, 0, 0, 0, 0, 0, (void *) "Type:", NULL, NULL }, - { jwin_text_proc, 4, 46, 8, 8, 0, 0, 0, 0, 0, 0, (void *) "Template:", NULL, NULL }, - { sstype_drop_proc, 33, 24, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &activepassive_list, NULL, NULL }, - { jwin_droplist_proc, 50, 42, 211, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &active_list, NULL, NULL }, - { jwin_button_proc, 61, 62, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, - { jwin_button_proc, 142, 62, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } + // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) + { jwin_win_proc, 0, 0, 265, 87, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "New Subscreen", NULL, NULL }, + { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, + { jwin_text_proc, 4, 28, 8, 8, 0, 0, 0, 0, 0, 0, (void *) "Type:", NULL, NULL }, + { jwin_text_proc, 4, 46, 8, 8, 0, 0, 0, 0, 0, 0, (void *) "Template:", NULL, NULL }, + { sstype_drop_proc, 33, 24, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &activepassive_list, NULL, NULL }, + { jwin_droplist_proc, 50, 42, 211, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &active_list, NULL, NULL }, + { jwin_button_proc, 61, 62, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, + { jwin_button_proc, 142, 62, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, + { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; bool show_new_ss=true; -const char *subscreenlist(int32_t index, int32_t *list_size) -{ - if(index<0) - { - *list_size = new_subscreen.size()+(show_new_ss?1:0); - return NULL; - } - if(show_new_ss && index == new_subscreen.size()) - return ""; - if(unsigned(index) < new_subscreen.size()) - return new_subscreen[index].name.c_str(); - return ""; -} - const char *subscreenlist_either(int32_t index, int32_t *list_size, byte type) { - if(index<0) - { - int32_t i=0, j=0; - - while(j < new_subscreen.size()) - { - if(new_subscreen[j].sub_type==type) - ++i; - - ++j; - } - - *list_size = i; - return NULL; - } - - int32_t i=-1, j=0; - - while(j < new_subscreen.size() && i!=index) + std::vector& vec = + (type == sstACTIVE ? subscreens_active + : (type == sstPASSIVE ? subscreens_passive + : subscreens_overlay)); + if(index<0) { - if(new_subscreen[j].sub_type==type) - ++i; - - ++j; + *list_size = vec.size(); + return NULL; } - - return new_subscreen[j-1].name.c_str(); + + return vec[index].name.c_str(); } -const char *subscreenlist_a(int32_t index, int32_t *list_size) +const char *subscreenlist_active(int32_t index, int32_t *list_size) { - return subscreenlist_either(index,list_size,sstACTIVE); + return subscreenlist_either(index,list_size,sstACTIVE); } -const char *subscreenlist_b(int32_t index, int32_t *list_size) +const char *subscreenlist_passive(int32_t index, int32_t *list_size) { - return subscreenlist_either(index,list_size,sstPASSIVE); + return subscreenlist_either(index,list_size,sstPASSIVE); } -static ListData subscreen_list(subscreenlist, &font); - -DIALOG sslist_dlg[] = +const char *subscreenlist_overlay(int32_t index, int32_t *list_size) { - // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) - { jwin_win_proc, 0, 0, 234, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Subscreen", NULL, NULL }, - { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, - { jwin_abclist_proc, 12, 24, 211, 95, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &subscreen_list, NULL, NULL }, - { jwin_button_proc, 12, 123, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL }, - { jwin_button_proc, 85, 123, 61, 21, vc(14), vc(1), KEY_DEL, D_EXIT, 0, 0, (void *) "Delete", NULL, NULL }, - { jwin_button_proc, 158, 123, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } -}; + return subscreenlist_either(index,list_size,sstOVERLAY); +} +void call_subscr_listedit_dlg(); int32_t onEditSubscreens() { - int32_t ret=-1; - sslist_dlg[0].dp2=get_zc_font(font_lfont); - sstemplatelist_dlg[0].dp2=get_zc_font(font_lfont); - - large_dialog(sslist_dlg); - - while(ret!=0&&ret!=5) - { - ret=zc_popup_dialog(sslist_dlg,2); - - auto ind = sslist_dlg[2].d1; - if(ret==4) - { - int32_t confirm = jwin_alert("Confirm Delete", "You are about to delete the selected subscreen!", "Are you sure?", NULL, "OK", "Cancel", KEY_ENTER, KEY_ESC, get_zc_font(font_lfont)); - - if(confirm==1) - { - delete_subscreen(ind); - saved=false; - } - } - else if(ret==2 || ret ==3) - { - if(ind < new_subscreen.size()) - subscr_edit = new_subscreen[ind]; - else subscr_edit.clear(); - if(subscr_edit.sub_type==sstPASSIVE) - { - subscreen_dlg[3].h=116; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - else - { - subscr_edit.sub_type = sstACTIVE; - subscreen_dlg[3].h=340; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - - bool edit_it=true; - - if(subscr_edit.pages.empty()) - { - large_dialog(sstemplatelist_dlg); - - ret=zc_popup_dialog(sstemplatelist_dlg,4); - - if(ret==6) - { - if(sstemplatelist_dlg[5].d1<15) - { - if(sstemplatelist_dlg[5].d1 != 0) - { - subscreen_object *tempsub; - - if(sstemplatelist_dlg[4].d1==0) - { - tempsub = default_subscreen_active[(sstemplatelist_dlg[5].d1-1)/2][(sstemplatelist_dlg[5].d1-1)&1]; - } - else - { - tempsub = default_subscreen_passive[(sstemplatelist_dlg[5].d1-1)/2][(sstemplatelist_dlg[5].d1-1)&1]; - } - subscr_edit.load_old(tempsub); - } - - if(sstemplatelist_dlg[4].d1==0) - { - subscr_edit.sub_type=sstACTIVE; - subscr_edit.name = activesubscrtype_str[sstemplatelist_dlg[5].d1]; - subscreen_dlg[3].h=172*2; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - else - { - subscr_edit.sub_type=sstPASSIVE; - subscr_edit.name = passivesubscrtype_str[sstemplatelist_dlg[5].d1]; - subscreen_dlg[3].h=120; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - } - else //Z3 - { - subscreen_object *tempsub; - - if(sstemplatelist_dlg[4].d1==0) - { - tempsub = z3_active_a; - } - else - { - tempsub = z3_passive_a; - } - subscr_edit.load_old(tempsub); - - if(sstemplatelist_dlg[4].d1==0) - { - subscr_edit.sub_type=sstACTIVE; - subscr_edit.name = activesubscrtype_str[sstemplatelist_dlg[5].d1]; - subscreen_dlg[3].h=344; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - - } - else - { - subscr_edit.sub_type=sstPASSIVE; - subscr_edit.name = passivesubscrtype_str[sstemplatelist_dlg[5].d1]; - subscreen_dlg[3].h=120; - subscreen_dlg[4].h=subscreen_dlg[3].h-4; - } - } - } - else - { - edit_it=false; - } - } - if(subscr_edit.pages.empty()) - subscr_edit.pages.emplace_back(); - - if(edit_it && edit_subscreen()) + call_subscr_listedit_dlg(); + return D_O_K; +} + +void do_edit_subscr(size_t ind, byte ty) +{ + std::vector& vec = + (ty == sstACTIVE ? subscreens_active + : (ty == sstPASSIVE ? subscreens_passive + : subscreens_overlay)); + + if(ind < vec.size()) + subscr_edit = vec[ind]; + else subscr_edit.clear(); + subscr_edit.sub_type = ty; + + bool edit_it=true; + + /* No templates for now... not sure how to handle these + if(subscr_edit.pages.empty()) + { + large_dialog(sstemplatelist_dlg); + + auto ret=zc_popup_dialog(sstemplatelist_dlg,4); + + if(ret==6) + { + if(sstemplatelist_dlg[5].d1<15) { - if(ind < new_subscreen.size()) - new_subscreen[ind] = subscr_edit; - else new_subscreen.push_back(subscr_edit); + if(sstemplatelist_dlg[5].d1 != 0) + { + subscreen_object *tempsub; + + if(sstemplatelist_dlg[4].d1==0) + { + tempsub = default_subscreen_active[(sstemplatelist_dlg[5].d1-1)/2][(sstemplatelist_dlg[5].d1-1)&1]; + } + else + { + tempsub = default_subscreen_passive[(sstemplatelist_dlg[5].d1-1)/2][(sstemplatelist_dlg[5].d1-1)&1]; + } + subscr_edit.load_old(tempsub); + } + + if(sstemplatelist_dlg[4].d1==0) + { + subscr_edit.sub_type=sstACTIVE; + subscr_edit.name = activesubscrtype_str[sstemplatelist_dlg[5].d1]; + subscreen_dlg[4].h=172*2; + subscreen_dlg[5].h=subscreen_dlg[4].h-4; + } + else + { + subscr_edit.sub_type=sstPASSIVE; + subscr_edit.name = passivesubscrtype_str[sstemplatelist_dlg[5].d1]; + subscreen_dlg[4].h=120; + subscreen_dlg[5].h=subscreen_dlg[4].h-4; + } } - } - } - - position_mouse_z(0); - return D_O_K; + else //Z3 + { + subscreen_object *tempsub; + + if(sstemplatelist_dlg[4].d1==0) + { + tempsub = z3_active_a; + } + else + { + tempsub = z3_passive_a; + } + subscr_edit.load_old(tempsub); + + if(sstemplatelist_dlg[4].d1==0) + { + subscr_edit.sub_type=sstACTIVE; + subscr_edit.name = activesubscrtype_str[sstemplatelist_dlg[5].d1]; + subscreen_dlg[4].h=344; + subscreen_dlg[5].h=subscreen_dlg[4].h-4; + + } + else + { + subscr_edit.sub_type=sstPASSIVE; + subscr_edit.name = passivesubscrtype_str[sstemplatelist_dlg[5].d1]; + subscreen_dlg[4].h=120; + subscreen_dlg[5].h=subscreen_dlg[4].h-4; + } + } + } + else + { + edit_it=false; + } + }*/ + if(subscr_edit.pages.empty()) + subscr_edit.pages.emplace_back(); + if(edit_it && edit_subscreen()) + { + if(ind < vec.size()) + vec[ind] = subscr_edit; + else vec.push_back(subscr_edit); + } } - void update_sso_name() { auto* w = subscr_edit.cur_page().get_widget(curr_widg); @@ -2798,43 +2728,62 @@ void center_zq_subscreen_dialogs() { jwin_center_dialog(grid_dlg); jwin_center_dialog(sel_options_dlg); - jwin_center_dialog(sslist_dlg); jwin_center_dialog(sstemplatelist_dlg); jwin_center_dialog(subscreen_dlg); } -void delete_subscreen(int32_t subscreenidx) +void delete_subscreen(size_t ind, byte ty) { - if(subscreenidx >= new_subscreen.size()) + std::vector* vec = nullptr; + switch(ty) + { + case sstACTIVE: + vec = &subscreens_active; + break; + case sstPASSIVE: + vec = &subscreens_passive; + break; + case sstOVERLAY: + vec = &subscreens_overlay; + break; + } + if(!vec || ind >= vec->size()) return; - int32_t i = 0; - int32_t active_ind = 0, passive_ind = 0; - for(auto it = new_subscreen.begin(); it != new_subscreen.end(); ++it) + int count = 0; + bool del = false; + for(auto it = vec->begin(); it != vec->end(); ++it) { - if(i++ == subscreenidx) + if(count++ == ind) { - if(it->sub_type == sstACTIVE) passive_ind = -1; - else active_ind = -1; - i = -1; - new_subscreen.erase(it); + --count; + del = true; + vec->erase(it); break; } - if(it->sub_type == sstACTIVE) ++active_ind; - else ++passive_ind; } - if(i != -1) active_ind = passive_ind = -1; //no deletion + if(!del) return; //nothing deleted? //fix dmaps int32_t dmap_count=count_dmaps(); for(int32_t i=0; i -1 && DMaps[i].active_subscreen > active_ind) - DMaps[i].active_subscreen--; - - if(passive_ind > -1 && DMaps[i].passive_subscreen > passive_ind) - DMaps[i].passive_subscreen--; + switch(ty) + { + case sstACTIVE: + if(DMaps[i].active_subscreen > count) + --DMaps[i].active_subscreen; + break; + case sstPASSIVE: + if(DMaps[i].passive_subscreen > count) + --DMaps[i].passive_subscreen; + break; + case sstOVERLAY: + if(DMaps[i].overlay_subscreen > count) + --DMaps[i].overlay_subscreen; + break; + } } } + diff --git a/webdocs/zsdocs_main.json b/webdocs/zsdocs_main.json index fce0c1fe16..bc10820705 100644 --- a/webdocs/zsdocs_main.json +++ b/webdocs/zsdocs_main.json @@ -701,8 +701,8 @@ "val": "$0$6" }, { - "name": "Subscreens ;; dmapdata::ActiveSubscreen / dmapdata::PassiveSubscreen / dmapdata::ASubScript / dmapdata::PSubScript / dmapdata::SubInitD", - "val": "

int ActiveSubscreen;

\nWhich engine active subscreen to use on this dmap.\n\n

int PassiveSubscreen;

\nWhich engine passive subscreen to use on this dmap.\n\n

int ASubScript;

\nWhich dmapdata script to use as a replacement for the engine active subscreen (0 for none).\n\n

int PSubScript;

\nWhich dmapdata script to run for passive subscreen draws.\n\n

untyped SubInitD[8];

\nThe 8 InitD values shared by the Active and Passive Subscreen Scripts." + "name": "Subscreens ;; dmapdata::ActiveSubscreen / dmapdata::PassiveSubscreen / dmapdata::OverlaySubscreen / dmapdata::ASubScript / dmapdata::PSubScript / dmapdata::SubInitD", + "val": "

int ActiveSubscreen;

\nWhich engine active subscreen to use on this dmap.\n\n

int PassiveSubscreen;

\nWhich engine passive subscreen to use on this dmap.\n\n

int OverlaySubscreen;

\nWhich engine overlay subscreen to use on this dmap.\n\n

int ASubScript;

\nWhich dmapdata script to use as a replacement for the engine active subscreen (0 for none).\n\n

int PSubScript;

\nWhich dmapdata script to run for passive subscreen draws.\n\n

untyped SubInitD[8];

\nThe 8 InitD values shared by the Active and Passive Subscreen Scripts." }, { "name": "Map Script ;; dmapdata::MapScript / dmapdata::MapInitD",