diff --git a/src/dialog/subscr_props.cpp b/src/dialog/subscr_props.cpp index 47c34f7eef..406bbe65b0 100644 --- a/src/dialog/subscr_props.cpp +++ b/src/dialog/subscr_props.cpp @@ -31,7 +31,8 @@ SubscrPropDialog::SubscrPropDialog(SubscrWidget* widg, int32_t obj_ind) : list_counters(GUI::ZCListData::ss_counters(true)), //All counters list_counters2(GUI::ZCListData::ss_counters(true,true)), //All counters, no (None) list_itemclass(GUI::ZCListData::itemclass(true)), - list_genscr(GUI::ZCListData::generic_script()) + list_genscr(GUI::ZCListData::generic_script()), + list_sfx(GUI::ZCListData::sfxnames(true)) { byte pg = subscr_edit.curpage, ind = index; start_default_btnslot = 0; @@ -63,6 +64,13 @@ static const GUI::ListData wrapping_type_list { "Character", 0 }, { "Word", 1 } }; +static const GUI::ListData list_pgmode +{ + { "None", PGGOTO_NONE }, + { "Next", PGGOTO_NEXT }, + { "Prev", PGGOTO_PREV }, + { "Target", PGGOTO_TRG }, +}; #define NUM_FIELD(var,_min,_max) \ TextField( \ @@ -299,6 +307,7 @@ std::shared_ptr SubscrPropDialog::GEN_INITD(int ind) } static size_t sprop_tabs[widgMAX] = {0}; +static size_t sprop_tab_sel = 0; static char tbuf[1025] = {0}; std::shared_ptr SubscrPropDialog::view() { @@ -731,7 +740,12 @@ std::shared_ptr SubscrPropDialog::view() " heart piece display, or bow name on bow&arrow) will not be added for this widget."), CBOX_EX(w->flags,SUBSCR_CURITM_IGNR_SP_DISPLAY,"Ignore Special Display",_EX_RBOX), INFOBTN("If checked, special display properties (like the hardcoded map, compass, boss key" - " displays and changing heart pieces into the heart piece display) will not occur for this widget.") + " displays and changing heart pieces into the heart piece display) will not occur for this widget."), + // + DummyWidget(), + CBOX_EX(w->flags,SUBSCR_CURITM_NO_INTER_WO_ITEM,"No Interact Without Item",_EX_RBOX), + INFOBTN("If checked, effects using buttons such as changing pages or running frozen generic scripts" + " on this widget will not trigger unless there is a valid item displayed.") ); break; } @@ -1425,44 +1439,110 @@ std::shared_ptr SubscrPropDialog::view() for(auto& ref : extra_grids) tpan->add(TabRef(name = ref.first, ref.second)); } - tpan->add(TabRef(name = "Selection", Rows<2>( - Frame(title = "Cursor Selectable", info = "If the subscreen cursor can select this" - " widget, and the selectable position information for selecting it.", - fitParent = true, - Column(padding = 0_px, - Checkbox( - text = "Is Selectable", - checked = local_subref->genflags & SUBSCRFLAG_SELECTABLE, - onToggleFunc = [&](bool state) - { - SETFLAG(local_subref->genflags, SUBSCRFLAG_SELECTABLE, state); - updateSelectable(); - }), - selgs[0] = Rows<3>( - Label(text = "Position:", hAlign = 1.0), - NUM_FIELD(local_subref->pos, 0, 254), - INFOBTN("The unique position ID of this slot. Setting this to a number" - " that is already in use on this page may cause buggy behavior."), - Label(text = "Up Select:", hAlign = 1.0), - NUM_FIELD(local_subref->pos_up, 0, 254), - INFOBTN("The unique position ID to move to when pressing 'Up'"), - Label(text = "Down Select:", hAlign = 1.0), - NUM_FIELD(local_subref->pos_down, 0, 254), - INFOBTN("The unique position ID to move to when pressing 'Down'"), - Label(text = "Left Select:", hAlign = 1.0), - NUM_FIELD(local_subref->pos_left, 0, 254), - INFOBTN("The unique position ID to move to when pressing 'Left' / 'L' quickswap"), - Label(text = "Right Select:", hAlign = 1.0), - NUM_FIELD(local_subref->pos_right, 0, 254), - INFOBTN("The unique position ID to move to when pressing 'Right' / 'R' quickswap") - ) + tpan->add(TabRef(name = "Selection", + TabPanel(ptr = &sprop_tab_sel, + TabRef(name = "Basic", + Rows<2>( + Frame(title = "Cursor Selectable", info = "If the subscreen cursor can select this" + " widget, and the selectable position information for selecting it.", + fitParent = true, + Column(padding = 0_px, + Checkbox( + text = "Is Selectable", + checked = local_subref->genflags & SUBSCRFLAG_SELECTABLE, + onToggleFunc = [&](bool state) + { + SETFLAG(local_subref->genflags, SUBSCRFLAG_SELECTABLE, state); + updateSelectable(); + }), + selgs[0] = Rows<3>( + Label(text = "Position:", hAlign = 1.0), + NUM_FIELD(local_subref->pos, 0, 254), + INFOBTN("The unique position ID of this slot. Setting this to a number" + " that is already in use on this page may cause buggy behavior."), + Label(text = "Up Select:", hAlign = 1.0), + NUM_FIELD(local_subref->pos_up, 0, 254), + INFOBTN("The unique position ID to move to when pressing 'Up'"), + Label(text = "Down Select:", hAlign = 1.0), + NUM_FIELD(local_subref->pos_down, 0, 254), + INFOBTN("The unique position ID to move to when pressing 'Down'"), + Label(text = "Left Select:", hAlign = 1.0), + NUM_FIELD(local_subref->pos_left, 0, 254), + INFOBTN("The unique position ID to move to when pressing 'Left' / 'L' quickswap"), + Label(text = "Right Select:", hAlign = 1.0), + NUM_FIELD(local_subref->pos_right, 0, 254), + INFOBTN("The unique position ID to move to when pressing 'Right' / 'R' quickswap") + ) + ) + ), + selframes[0] = Frame(title = "Page Change", + info = "Change the current subscreen page when a button is pressed.", + fitParent = true, + Column( + Rows<3>( + Label(text = "Mode:",hAlign = 1.0), + DropDownList(data = list_pgmode, + fitParent = true, selectedValue = local_subref->pg_mode, + onSelectFunc = [&](int32_t val) + { + local_subref->pg_mode = val; + updateSelectable(); + }), + INFOBTN("Which mode to use for page swapping." + "\nPrev/Next move to the previous or next page." + "\nTarget moves to a specific page number." + "\nNone disables page swapping altogether."), + // + Label(text = "Target:",hAlign = 1.0), + seltfs[0] = TextField( + fitParent = true, + type = GUI::TextField::type::INT_DECIMAL, + low = 0, high = MAX_SUBSCR_PAGES, val = local_subref->pg_targ, + onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) + { + local_subref->pg_targ = val; + }), + INFOBTN("The target page for 'Target' mode." + " If set to an invalid page, no page change occurs."), + // + Label(text = "Transition SFX:"), + selddls[0] = DropDownList(data = list_sfx, + fitParent = true, maxwidth = 200_px, + selectedValue = local_subref->pg_trans.tr_sfx, + onSelectFunc = [&](int32_t val) + { + local_subref->pg_trans.tr_sfx = val; + } + ), + INFOBTN("SFX to play when changing pages"), + // + DummyWidget(), + CBOX(local_subref->genflags,SUBSCRFLAG_PGGOTO_NOWRAP,"No Wrap",1), + INFOBTN("If checked, trying to page left from page 0 or" + " right from the final page will do nothing.") + ), + INTBTN_PANEL2(local_subref->pg_btns,"Page Button:") + ) + ), + selframes[1] = Frame(title = "Selection Text", + info = "If not blank, use this text for 'Selection Text' widgets.", + fitParent = true, colSpan = 2, + TextField( + type = GUI::TextField::type::TEXT, + maxLength = 255, + text = local_subref->override_text, + onValChangedFunc = [&](GUI::TextField::type,std::string_view text,int32_t) + { + local_subref->override_text = text; + }) + ) ) ), - selframes[0] = Frame(title = "Generic Frozen Script", - info = "Run a Generic Frozen Script when a button is pressed." - "\nThe script will run before any other effects that occur from" - " pressing the button (such as equipping an item to a button).", - fitParent = true, + seltabs[0] = TabRef(name = "Script", + Frame(title = "Generic Frozen Script", + info = "Run a Generic Frozen Script when a button is pressed." + "\nThe script will run before any other effects that occur from" + " pressing the button (such as equipping an item to a button).", Row( selgs[1] = Column(padding = 0_px, GEN_INITD(0), @@ -1487,19 +1567,8 @@ std::shared_ptr SubscrPropDialog::view() selgs[2] = INTBTN_PANEL2(local_subref->gen_script_btns,"Run Button:") ) ) - ), - selframes[1] = Frame(title = "Selection Text", - info = "If not blank, use this text for 'Selection Text' widgets.", - fitParent = true, colSpan = 2, - TextField( - type = GUI::TextField::type::TEXT, - maxLength = 255, - text = local_subref->override_text, - onValChangedFunc = [&](GUI::TextField::type,std::string_view text,int32_t) - { - local_subref->override_text = text; - }) ) + ) ))); window = Window( title = titlebuf, @@ -1530,11 +1599,17 @@ std::shared_ptr SubscrPropDialog::view() void SubscrPropDialog::updateSelectable() { bool seldis = !(local_subref->genflags & SUBSCRFLAG_SELECTABLE); + bool scrdis = seldis || !local_subref->generic_script; + bool pgdis = seldis || !local_subref->pg_mode; selgs[0]->setDisabled(seldis); selframes[0]->setDisabled(seldis); selframes[1]->setDisabled(seldis); - selgs[1]->setDisabled(seldis || !local_subref->generic_script); - selgs[2]->setDisabled(seldis || !local_subref->generic_script); + seltabs[0]->setDisabled(seldis); + selgs[1]->setDisabled(scrdis); + selgs[2]->setDisabled(scrdis); + seltfs[0]->setDisabled(pgdis || local_subref->pg_mode != PGGOTO_TRG); + selddls[0]->setDisabled(pgdis); + if(local_subref->generic_script) local_gen_meta = genericscripts[local_subref->generic_script]->meta; diff --git a/src/dialog/subscr_props.h b/src/dialog/subscr_props.h index 7641e1abb1..d37c35cf6b 100644 --- a/src/dialog/subscr_props.h +++ b/src/dialog/subscr_props.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,9 @@ class SubscrPropDialog: public GUI::Dialog std::shared_ptr selgs[3]; std::shared_ptr selframes[2]; + std::shared_ptr seltabs[1]; + std::shared_ptr seltfs[1]; + std::shared_ptr selddls[1]; std::shared_ptr geninitd_lbl[8]; std::shared_ptr geninitd_btn[8]; @@ -62,7 +66,7 @@ class SubscrPropDialog: public GUI::Dialog zasm_meta local_gen_meta; GUI::ListData list_font, list_shadtype, list_aligns, list_buttons, list_items, - list_counters, list_counters2, list_itemclass, list_genscr; + list_counters, list_counters2, list_itemclass, list_genscr, list_sfx; void updateSelectable(); void updateColors(); diff --git a/src/new_subscr.cpp b/src/new_subscr.cpp index 90bd2ab8df..ff0b5183a9 100644 --- a/src/new_subscr.cpp +++ b/src/new_subscr.cpp @@ -52,7 +52,7 @@ static ZCSubscreen* subscr_anim = nullptr; int subscr_override_clkoffsets[MAXITEMS]; bool subscr_itemless = false, subscr_pg_animating = false; int btnitem_clks[4] = {0}; -int btnitem_ids[4] = {0}; +int btnitem_ids[4] = {-1,-1,-1,-1}; void refresh_subscr_buttonitems() { @@ -788,6 +788,18 @@ bool SubscrWidget::copy_prop(SubscrWidget const* src, bool all) for(int q = 0; q < 8; ++q) generic_initd[q] = src->generic_initd[q]; type = src->type; + pg_btns = src->pg_btns; + pg_mode = src->pg_mode; + if(!pg_mode || !pg_btns) + { + pg_mode = pg_btns = pg_targ = 0; + pg_trans.clear(); + } + else + { + pg_targ = src->pg_targ; + pg_trans = src->pg_trans; + } } return true; } @@ -834,6 +846,17 @@ int32_t SubscrWidget::read(PACKFILE *f, word s_version) if(!p_igetl(&generic_initd[q],f)) return qe_invalid; } + if(!p_getc(&pg_mode,f)) + return qe_invalid; + if(pg_mode) + { + if(!p_getc(&pg_btns,f)) + return qe_invalid; + if(!p_getc(&pg_targ,f)) + return qe_invalid; + if(auto ret = pg_trans.read(f, s_version)) + return ret; + } } return 0; } @@ -881,9 +904,25 @@ int32_t SubscrWidget::write(PACKFILE *f) const if(!p_iputl(generic_initd[q],f)) new_return(1); } + if(!p_putc(pg_mode,f)) + new_return(1); + if(pg_mode) + { + if(!p_putc(pg_btns,f)) + new_return(1); + if(!p_putc(pg_targ,f)) + new_return(1); + if(auto ret = pg_trans.write(f)) + return ret; + } } return 0; } +void SubscrWidget::check_btns(byte btnflgs, ZCSubscreen& parent) const +{ + if(pg_mode && (btnflgs&pg_btns)) + parent.page_change(pg_mode, pg_targ, pg_trans, genflags&SUBSCRFLAG_PGGOTO_NOWRAP); +} void SubscrWidget::replay_rand_compat(byte pos) const { if((compat_flags & SUBSCRCOMPAT_FONT_RAND) && (posflags&pos) && replay_version_check(0,19)) @@ -4686,24 +4725,28 @@ int32_t ZCSubscreen::read(PACKFILE *f, word s_version) return qe_invalid; if(!p_getc(&sub_type,f)) return qe_invalid; - for(int q = 0; q < 4; ++q) - if(!p_igetw(&def_btns[q],f)) - return qe_invalid; - if(!p_getc(&btn_left,f)) - new_return(1); - if(!p_getc(&btn_right,f)) - new_return(1); - if(auto ret = page_transition.read(f, s_version)) - return ret; if(!p_igetl(&flags,f)) new_return(1); - if(!p_igetw(&script,f)) - return qe_invalid; - if(script) + bool passive = sub_type == sstPASSIVE; + if(!passive) { - for(int q = 0; q < 8; ++q) - if(!p_igetl(&initd[q],f)) + for(int q = 0; q < 4; ++q) + if(!p_igetw(&def_btns[q],f)) return qe_invalid; + if(!p_getc(&btn_left,f)) + new_return(1); + if(!p_getc(&btn_right,f)) + new_return(1); + if(auto ret = page_transition.read(f, s_version)) + return ret; + if(!p_igetw(&script,f)) + return qe_invalid; + if(script) + { + for(int q = 0; q < 8; ++q) + if(!p_igetl(&initd[q],f)) + return qe_invalid; + } } byte pagecnt; if(!p_getc(&pagecnt,f)) @@ -4724,26 +4767,32 @@ int32_t ZCSubscreen::write(PACKFILE *f) const new_return(1); if(!p_putc(sub_type,f)) new_return(1); - for(int q = 0; q < 4; ++q) - if(!p_iputw(def_btns[q],f)) - new_return(1); - if(!p_putc(btn_left,f)) - new_return(1); - if(!p_putc(btn_right,f)) - new_return(1); - if(auto ret = page_transition.write(f)) - return ret; if(!p_iputl(flags,f)) new_return(1); - if(!p_iputw(script,f)) - new_return(1); - if(script) + bool passive = sub_type == sstPASSIVE; + if(!passive) { - for(int q = 0; q < 8; ++q) - if(!p_iputl(initd[q],f)) + for(int q = 0; q < 4; ++q) + if(!p_iputw(def_btns[q],f)) new_return(1); + if(!p_putc(btn_left,f)) + new_return(1); + if(!p_putc(btn_right,f)) + new_return(1); + if(auto ret = page_transition.write(f)) + return ret; + if(!p_iputw(script,f)) + new_return(1); + if(script) + { + for(int q = 0; q < 8; ++q) + if(!p_iputl(initd[q],f)) + new_return(1); + } } - byte pagecnt = zc_min(255,pages.size()); + byte pagecnt = zc_min(MAX_SUBSCR_PAGES,pages.size()); + if(pagecnt && passive) + pagecnt = 1; if(!p_putc(pagecnt,f)) new_return(1); for(byte q = 0; q < pagecnt; ++q) @@ -4753,26 +4802,54 @@ int32_t ZCSubscreen::write(PACKFILE *f) const return 0; } -void ZCSubscreen::check_btns(byte btnflgs) +bool ZCSubscreen::wrap_pg(int& pg, bool nowrap) { - int pg = curpage; - if(btn_right&btnflgs) - ++pg; - else if(btn_left&btnflgs) - --pg; - else return; if(pg < 0) { - if(flags&SUBFLAG_NOPAGEWRAP) - return; + if(nowrap) + return false; pg = pages.size()-1; } else if(pg >= pages.size()) { - if(flags&SUBFLAG_NOPAGEWRAP) - return; + if(nowrap) + return false; pg = 0; } + return true; +} +void ZCSubscreen::check_btns(byte btnflgs) +{ + int pg = curpage; + if(btn_right&btnflgs) + ++pg; + else if(btn_left&btnflgs) + --pg; + else return; + if(!wrap_pg(pg,flags&SUBFLAG_NOPAGEWRAP)) + return; subscrpg_animate(curpage,pg,page_transition,*this); } +void ZCSubscreen::page_change(byte mode, byte targ, SubscrTransition const& trans, bool nowrap) +{ + int pg = curpage; + switch(mode) + { + case PGGOTO_NEXT: + ++pg; + break; + case PGGOTO_PREV: + --pg; + break; + case PGGOTO_TRG: + if(targ < pages.size()) + pg = targ; + break; + } + if(pg == curpage) + return; + if(!wrap_pg(pg,nowrap)) + return; + subscrpg_animate(curpage,pg,trans,*this); +} diff --git a/src/new_subscr.h b/src/new_subscr.h index 5b683d2c00..3e9caf5587 100644 --- a/src/new_subscr.h +++ b/src/new_subscr.h @@ -126,7 +126,7 @@ enum //old subscreen object types ssoMAX, ssoTEMPOLD }; -enum +enum //new subscreen object types { widgNULL, widgFRAME, widgTEXT, widgLINE, widgRECT, widgTIME, widgMMETER, widgLMETER, widgBTNITM, widgCOUNTER, @@ -189,42 +189,51 @@ enum //subscreen text alignment sstaLEFT, sstaCENTER, sstaRIGHT }; -#define SUBSCRFLAG_SELECTABLE 0x00000001 - -#define SUBSCRFLAG_SPEC_01 0x00000001 -#define SUBSCRFLAG_SPEC_02 0x00000002 -#define SUBSCRFLAG_SPEC_03 0x00000004 -#define SUBSCRFLAG_SPEC_04 0x00000008 -#define SUBSCRFLAG_SPEC_05 0x00000010 -#define SUBSCRFLAG_SPEC_06 0x00000020 -#define SUBSCRFLAG_SPEC_07 0x00000040 -#define SUBSCRFLAG_SPEC_08 0x00000080 -#define SUBSCRFLAG_SPEC_09 0x00000100 -#define SUBSCRFLAG_SPEC_10 0x00000200 -#define SUBSCRFLAG_SPEC_11 0x00000400 -#define SUBSCRFLAG_SPEC_12 0x00000800 -#define SUBSCRFLAG_SPEC_13 0x00001000 -#define SUBSCRFLAG_SPEC_14 0x00002000 -#define SUBSCRFLAG_SPEC_15 0x00004000 -#define SUBSCRFLAG_SPEC_16 0x00008000 -#define SUBSCRFLAG_SPEC_17 0x00010000 -#define SUBSCRFLAG_SPEC_18 0x00020000 -#define SUBSCRFLAG_SPEC_19 0x00040000 -#define SUBSCRFLAG_SPEC_20 0x00080000 -#define SUBSCRFLAG_SPEC_21 0x00100000 -#define SUBSCRFLAG_SPEC_22 0x00200000 -#define SUBSCRFLAG_SPEC_23 0x00400000 -#define SUBSCRFLAG_SPEC_24 0x00800000 -#define SUBSCRFLAG_SPEC_25 0x01000000 -#define SUBSCRFLAG_SPEC_26 0x02000000 -#define SUBSCRFLAG_SPEC_27 0x04000000 -#define SUBSCRFLAG_SPEC_28 0x08000000 -#define SUBSCRFLAG_SPEC_29 0x10000000 -#define SUBSCRFLAG_SPEC_30 0x20000000 -#define SUBSCRFLAG_SPEC_31 0x40000000 -#define SUBSCRFLAG_SPEC_32 0x80000000 - -#define SUBSCRCOMPAT_FONT_RAND 0x01 +enum //PGGOTO modes +{ + PGGOTO_NONE, + PGGOTO_NEXT, + PGGOTO_PREV, + PGGOTO_TRG +}; + +#define SUBSCRFLAG_SELECTABLE 0x00000001 +#define SUBSCRFLAG_PGGOTO_NOWRAP 0x00000002 + +#define SUBSCRFLAG_SPEC_01 0x00000001 +#define SUBSCRFLAG_SPEC_02 0x00000002 +#define SUBSCRFLAG_SPEC_03 0x00000004 +#define SUBSCRFLAG_SPEC_04 0x00000008 +#define SUBSCRFLAG_SPEC_05 0x00000010 +#define SUBSCRFLAG_SPEC_06 0x00000020 +#define SUBSCRFLAG_SPEC_07 0x00000040 +#define SUBSCRFLAG_SPEC_08 0x00000080 +#define SUBSCRFLAG_SPEC_09 0x00000100 +#define SUBSCRFLAG_SPEC_10 0x00000200 +#define SUBSCRFLAG_SPEC_11 0x00000400 +#define SUBSCRFLAG_SPEC_12 0x00000800 +#define SUBSCRFLAG_SPEC_13 0x00001000 +#define SUBSCRFLAG_SPEC_14 0x00002000 +#define SUBSCRFLAG_SPEC_15 0x00004000 +#define SUBSCRFLAG_SPEC_16 0x00008000 +#define SUBSCRFLAG_SPEC_17 0x00010000 +#define SUBSCRFLAG_SPEC_18 0x00020000 +#define SUBSCRFLAG_SPEC_19 0x00040000 +#define SUBSCRFLAG_SPEC_20 0x00080000 +#define SUBSCRFLAG_SPEC_21 0x00100000 +#define SUBSCRFLAG_SPEC_22 0x00200000 +#define SUBSCRFLAG_SPEC_23 0x00400000 +#define SUBSCRFLAG_SPEC_24 0x00800000 +#define SUBSCRFLAG_SPEC_25 0x01000000 +#define SUBSCRFLAG_SPEC_26 0x02000000 +#define SUBSCRFLAG_SPEC_27 0x04000000 +#define SUBSCRFLAG_SPEC_28 0x08000000 +#define SUBSCRFLAG_SPEC_29 0x10000000 +#define SUBSCRFLAG_SPEC_30 0x20000000 +#define SUBSCRFLAG_SPEC_31 0x40000000 +#define SUBSCRFLAG_SPEC_32 0x80000000 + +#define SUBSCRCOMPAT_FONT_RAND 0x01 struct SubscrWidget { byte posflags; @@ -248,6 +257,9 @@ struct SubscrWidget int32_t generic_initd[8]; byte gen_script_btns; + byte pg_btns, pg_mode, pg_targ; + SubscrTransition pg_trans; + SubscrWidget() = default; SubscrWidget(byte ty); SubscrWidget(subscreen_object const& old); @@ -268,6 +280,8 @@ struct SubscrWidget virtual bool copy_prop(SubscrWidget const* src, bool all = false); virtual int32_t write(PACKFILE *f) const; + void check_btns(byte btnflgs, ZCSubscreen& parent) const; + void replay_rand_compat(byte pos) const; static SubscrWidget* fromOld(subscreen_object const& old); static SubscrWidget* readWidg(PACKFILE* f, word s_version); @@ -596,6 +610,7 @@ struct SW_Clear : public SubscrWidget #define SUBSCR_CURITM_NONEQP SUBSCRFLAG_SPEC_02 #define SUBSCR_CURITM_IGNR_SP_SELTEXT SUBSCRFLAG_SPEC_03 #define SUBSCR_CURITM_IGNR_SP_DISPLAY SUBSCRFLAG_SPEC_04 +#define SUBSCR_CURITM_NO_INTER_WO_ITEM SUBSCRFLAG_SPEC_05 struct SW_ItemSlot : public SubscrWidget { int32_t iclass, iid = -1; @@ -879,6 +894,7 @@ struct SW_SelectedText : public SubscrWidget virtual int32_t read(PACKFILE *f, word s_version) override; }; + #define MAX_SUBSCR_PAGES 254 struct SubscrPage { @@ -921,12 +937,12 @@ struct ZCSubscreen std::vector pages; byte curpage, sub_type; std::string name; + dword flags; word def_btns[4]={255,255,255,255}; byte btn_left, btn_right; SubscrTransition page_transition; - dword flags; //!TODO Subscreen Scripts word script; @@ -948,6 +964,9 @@ struct ZCSubscreen int32_t write(PACKFILE *f) const; void check_btns(byte btnflgs); + void page_change(byte mode, byte targ, SubscrTransition const& trans, bool nowrap); +private: + bool wrap_pg(int& pg, bool nowrap); }; #endif diff --git a/src/zc/zc_subscr.cpp b/src/zc/zc_subscr.cpp index 85592abdf1..67ddcad4f4 100644 --- a/src/zc/zc_subscr.cpp +++ b/src/zc/zc_subscr.cpp @@ -139,6 +139,7 @@ void dosubscr() do { + auto pgnum = new_subscreen_active->curpage; auto& pg = new_subscreen_active->cur_page(); if (replay_version_check(0, 11)) load_control_state(); @@ -183,6 +184,10 @@ void dosubscr() } } } + + if(pos!=pg.cursor_pos) + sfx(QMisc.miscsfx[sfxSUBSCR_CURSOR_MOVE]); + //Assign items to buttons bool can_equip = true; @@ -190,181 +195,188 @@ void dosubscr() if(widg) { - if(widg->generic_script && (btn_press&widg->gen_script_btns)) - { - FFCore.runGenericFrozenEngine(widg->generic_script, widg->generic_initd); - } - bool can_equip = true; - if(widg->getType() == widgITEMSLOT && (widg->flags & SUBSCR_CURITM_NONEQP)) - can_equip = false; + bool can_interact = true; + if(widg->getType() == widgITEMSLOT + && (widg->flags & SUBSCR_CURITM_NO_INTER_WO_ITEM) + && widg->getDisplayItem() < 0) + can_interact = false; - if(can_equip) + if(can_interact) { - auto eqwpn = widg->getItemVal(); - if(eqwpn > -1) + if(widg->generic_script && (btn_press&widg->gen_script_btns)) + FFCore.runGenericFrozenEngine(widg->generic_script, widg->generic_initd); + bool can_equip = true; + if(widg->getType() == widgITEMSLOT && (widg->flags & SUBSCR_CURITM_NONEQP)) + can_equip = false; + + if(can_equip) { - if(b_only || (btn_press&INT_BTN_B)) + auto eqwpn = widg->getItemVal(); + if(eqwpn > -1) { - if(noverify && !b_only && eqwpn == Bwpn) - { - Bwpn = -1; - game->forced_bwpn = -1; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - - game->bwpn = 255; - directItemB = -1; - } - else + if(b_only || (btn_press&INT_BTN_B)) { - if(use_a && eqwpn == Awpn) + if(noverify && !b_only && eqwpn == Bwpn) { - Awpn = Bwpn; - game->awpn = game->bwpn; - directItemA = directItemB; + Bwpn = -1; + game->forced_bwpn = -1; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + + game->bwpn = 255; + directItemB = -1; } - else if(use_x && eqwpn == Xwpn) + else { - Xwpn = Bwpn; - game->xwpn = game->bwpn; - directItemX = directItemB; + if(use_a && eqwpn == Awpn) + { + Awpn = Bwpn; + game->awpn = game->bwpn; + directItemA = directItemB; + } + else if(use_x && eqwpn == Xwpn) + { + Xwpn = Bwpn; + game->xwpn = game->bwpn; + directItemX = directItemB; + } + else if(use_y && eqwpn == Ywpn) + { + Ywpn = Bwpn; + game->ywpn = game->bwpn; + directItemY = directItemB; + } + + Bwpn = eqwpn; + game->forced_bwpn = -1; //clear forced if the item is selected using the actual subscreen + if(!b_only) sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + game->bwpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; + directItemB = eqwpn; } - else if(use_y && eqwpn == Ywpn) - { - Ywpn = Bwpn; - game->ywpn = game->bwpn; - directItemY = directItemB; - } - - Bwpn = eqwpn; - game->forced_bwpn = -1; //clear forced if the item is selected using the actual subscreen - if(!b_only) sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - game->bwpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; - directItemB = eqwpn; } - } - else if(use_a && (btn_press&INT_BTN_A)) - { - if(noverify && eqwpn == Awpn) + else if(use_a && (btn_press&INT_BTN_A)) { - Awpn = -1; - game->forced_awpn = -1; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - - game->awpn = 255; - directItemA = -1; - } - else - { - if(eqwpn == Bwpn) - { - Bwpn = Awpn; - game->bwpn = game->awpn; - directItemB = directItemA; - } - else if(use_x && eqwpn == Xwpn) + if(noverify && eqwpn == Awpn) { - Xwpn = Awpn; - game->xwpn = game->awpn; - directItemX = directItemA; + Awpn = -1; + game->forced_awpn = -1; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + + game->awpn = 255; + directItemA = -1; } - else if(use_y && eqwpn == Ywpn) + else { - Ywpn = Awpn; - game->ywpn = game->awpn; - directItemY = directItemA; + if(eqwpn == Bwpn) + { + Bwpn = Awpn; + game->bwpn = game->awpn; + directItemB = directItemA; + } + else if(use_x && eqwpn == Xwpn) + { + Xwpn = Awpn; + game->xwpn = game->awpn; + directItemX = directItemA; + } + else if(use_y && eqwpn == Ywpn) + { + Ywpn = Awpn; + game->ywpn = game->awpn; + directItemY = directItemA; + } + + Awpn = eqwpn; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + game->awpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; + game->forced_awpn = -1; //clear forced if the item is selected using the actual subscreen + directItemA = eqwpn; } - - Awpn = eqwpn; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - game->awpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; - game->forced_awpn = -1; //clear forced if the item is selected using the actual subscreen - directItemA = eqwpn; - } - } - else if(use_x && (btn_press&INT_BTN_EX1)) - { - if(noverify && eqwpn == Xwpn) - { - Xwpn = -1; - game->forced_xwpn = -1; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - - game->xwpn = 255; - directItemX = -1; } - else + else if(use_x && (btn_press&INT_BTN_EX1)) { - if(eqwpn == Bwpn) - { - Bwpn = Xwpn; - game->bwpn = game->xwpn; - directItemB = directItemX; - } - else if(use_a && eqwpn == Awpn) + if(noverify && eqwpn == Xwpn) { - Awpn = Xwpn; - game->awpn = game->xwpn; - directItemA = directItemX; + Xwpn = -1; + game->forced_xwpn = -1; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + + game->xwpn = 255; + directItemX = -1; } - else if(use_y && eqwpn == Ywpn) + else { - Ywpn = Xwpn; - game->ywpn = game->xwpn; - directItemY = directItemX; + if(eqwpn == Bwpn) + { + Bwpn = Xwpn; + game->bwpn = game->xwpn; + directItemB = directItemX; + } + else if(use_a && eqwpn == Awpn) + { + Awpn = Xwpn; + game->awpn = game->xwpn; + directItemA = directItemX; + } + else if(use_y && eqwpn == Ywpn) + { + Ywpn = Xwpn; + game->ywpn = game->xwpn; + directItemY = directItemX; + } + + Xwpn = eqwpn; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + game->xwpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; + game->forced_xwpn = -1; //clear forced if the item is selected using the actual subscreen + directItemX = eqwpn; } - - Xwpn = eqwpn; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - game->xwpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; - game->forced_xwpn = -1; //clear forced if the item is selected using the actual subscreen - directItemX = eqwpn; } - } - else if(use_y && (btn_press&INT_BTN_EX2)) - { - if(noverify && eqwpn == Ywpn) - { - Ywpn = -1; - game->forced_ywpn = -1; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - - game->ywpn = 255; - directItemY = -1; - } - else + else if(use_y && (btn_press&INT_BTN_EX2)) { - if(eqwpn == Bwpn) + if(noverify && eqwpn == Ywpn) { - Bwpn = Ywpn; - game->bwpn = game->ywpn; - directItemB = directItemY; + Ywpn = -1; + game->forced_ywpn = -1; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + + game->ywpn = 255; + directItemY = -1; } - else if(use_a && eqwpn == Awpn) + else { - Awpn = Ywpn; - game->awpn = game->ywpn; - directItemA = directItemY; + if(eqwpn == Bwpn) + { + Bwpn = Ywpn; + game->bwpn = game->ywpn; + directItemB = directItemY; + } + else if(use_a && eqwpn == Awpn) + { + Awpn = Ywpn; + game->awpn = game->ywpn; + directItemA = directItemY; + } + else if(use_x && eqwpn == Xwpn) + { + Xwpn = Ywpn; + game->xwpn = game->ywpn; + directItemX = directItemY; + } + + Ywpn = eqwpn; + sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); + game->ywpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; + game->forced_ywpn = -1; //clear forced if the item is selected using the actual subscreen + directItemY = eqwpn; } - else if(use_x && eqwpn == Xwpn) - { - Xwpn = Ywpn; - game->xwpn = game->ywpn; - directItemX = directItemY; - } - - Ywpn = eqwpn; - sfx(QMisc.miscsfx[sfxSUBSCR_ITEM_ASSIGN]); - game->ywpn = ((pg.cursor_pos)<<8) | new_subscreen_active->curpage; - game->forced_ywpn = -1; //clear forced if the item is selected using the actual subscreen - directItemY = eqwpn; } } } + widg->check_btns(btn_press,*new_subscreen_active); } } - new_subscreen_active->check_btns(btn_press); - if(pos!=pg.cursor_pos) - sfx(QMisc.miscsfx[sfxSUBSCR_CURSOR_MOVE]); + if(new_subscreen_active->curpage == pgnum) + new_subscreen_active->check_btns(btn_press); } do_dcounters(); diff --git a/src/zq/zq_subscr.cpp b/src/zq/zq_subscr.cpp index 1e41e4653c..feeca35652 100644 --- a/src/zq/zq_subscr.cpp +++ b/src/zq/zq_subscr.cpp @@ -356,6 +356,7 @@ int32_t d_subscreen_proc(int32_t msg,DIALOG *d,int32_t) case MSG_DRAW: { ++subscr_item_clk; + animate_subscr_buttonitems(); BITMAP *buf = create_bitmap_ex(8,256,hei); if(buf) @@ -1755,8 +1756,7 @@ void distribute_objects(bool *, int32_t distribute_type) int32_t onBringToFront() { - while (curr_subscreen_object >= 0 && - curr_subscreen_object < subscr_edit.cur_page().contents.size()-1) + while(curr_subscreen_object 0 && - curr_subscreen_object < subscr_edit.cur_page().contents.size()) + while(curr_subscreen_object>0) { onSendBackward(); } @@ -1780,6 +1779,7 @@ 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_subscreen_object]=true; @@ -2063,7 +2063,7 @@ int32_t onSSCtrlPgDn() int32_t onSendBackward() { auto& pg = subscr_edit.cur_page(); - if(curr_subscreen_object > 0 && curr_subscreen_object 0 && curr_subscreen_object