Skip to content

Commit cfb498f

Browse files
committed
feat: new subscreen selector options (per-widget and subscreen-wide)
1 parent 95781ce commit cfb498f

File tree

7 files changed

+503
-92
lines changed

7 files changed

+503
-92
lines changed

src/dialog/subscr_macros.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#ifndef ZC_DLG_SUBSCR_MACROS_H
2+
#define ZC_DLG_SUBSCR_MACROS_H
3+
4+
5+
#define NUM_FIELD(var,_min,_max) \
6+
TextField( \
7+
fitParent = true, \
8+
type = GUI::TextField::type::INT_DECIMAL, \
9+
low = _min, high = _max, val = var, \
10+
onValChangedFunc = [=](GUI::TextField::type,std::string_view,int32_t val) \
11+
{ \
12+
var = val; \
13+
})
14+
15+
#define NUM_FIELD_OFFS(var,_min,_max,offs) \
16+
TextField( \
17+
fitParent = true, \
18+
type = GUI::TextField::type::INT_DECIMAL, \
19+
low = _min, high = _max, val = var+offs, \
20+
onValChangedFunc = [=](GUI::TextField::type,std::string_view,int32_t val) \
21+
{ \
22+
var = val-offs; \
23+
})
24+
25+
26+
#define CBOX(var, bit, txt, cspan) \
27+
Checkbox( \
28+
colSpan = cspan, \
29+
text = txt, hAlign = 0.0, \
30+
checked = var & bit, \
31+
onToggleFunc = [=](bool state) \
32+
{ \
33+
SETFLAG(var, bit, state); \
34+
} \
35+
)
36+
37+
#define CBOX_EX(var, bit, txt, ...) \
38+
Checkbox( \
39+
__VA_ARGS__, \
40+
text = txt, \
41+
checked = var & bit, \
42+
onToggleFunc = [=](bool state) \
43+
{ \
44+
SETFLAG(var, bit, state); \
45+
} \
46+
)
47+
48+
#define INFOCBOX(var, bit, txt, info, cspan) \
49+
Row(colSpan = cspan, \
50+
INFOBTN(info), \
51+
CBOX(var,bit,txt,1) \
52+
)
53+
54+
55+
#define DDL(var, lister) \
56+
DropDownList(data = lister, \
57+
fitParent = true, \
58+
selectedValue = var, \
59+
onSelectFunc = [=](int32_t val) \
60+
{ \
61+
var = val; \
62+
} \
63+
)
64+
65+
#define DDL_EX(var, lister, ...) \
66+
DropDownList(data = lister, \
67+
fitParent = true, \
68+
__VA_ARGS__, \
69+
selectedValue = var, \
70+
onSelectFunc = [=](int32_t val) \
71+
{ \
72+
var = val; \
73+
} \
74+
)
75+
76+
77+
#define SELECTOR_GRAPHIC(seltileinfo) \
78+
Rows<3>( \
79+
SelTileSwatch( \
80+
colSpan = 2, \
81+
tile = seltileinfo.tile, \
82+
cset = seltileinfo.cset&0xF, \
83+
showvals = false, \
84+
onSelectFunc = [&](int32_t t, int32_t c, int32_t,int32_t) \
85+
{ \
86+
seltileinfo.tile = t; \
87+
word c2 = (seltileinfo.cset&0xF0); \
88+
seltileinfo.cset = c2|(c&0x0F); \
89+
} \
90+
), \
91+
INFOBTN("Override the tile/cs used by Selectors"), \
92+
Label(text = "Pixel Width:", hAlign = 1.0), \
93+
NUM_FIELD(seltileinfo.sw,0,256), \
94+
INFOBTN("The width, in PIXELS, to draw from tiles. (This divided by 16, rounded up," \
95+
" is the tile width used)"), \
96+
Label(text = "Pixel Height:", hAlign = 1.0), \
97+
NUM_FIELD(seltileinfo.sh,0,256), \
98+
INFOBTN("The height, in PIXELS, to draw from tiles. (This divided by 16, rounded up," \
99+
" is the tile height used)"), \
100+
Label(text = "AFrames:", hAlign = 1.0), \
101+
NUM_FIELD(seltileinfo.frames,0,255), \
102+
INFOBTN("The number of frames in the animation"), \
103+
Label(text = "ASpeed:", hAlign = 1.0), \
104+
NUM_FIELD(seltileinfo.speed,0,255), \
105+
INFOBTN("The speed of the animation"), \
106+
Label(text = "ADelay:", hAlign = 1.0), \
107+
NUM_FIELD(seltileinfo.delay,0,255), \
108+
INFOBTN("The delay time of the animation"), \
109+
Label(text = "Flash CSet:", hAlign = 1.0), \
110+
TextField( \
111+
fitParent = true, \
112+
type = GUI::TextField::type::INT_DECIMAL, \
113+
low = 0, high = 13, val = seltileinfo.cset>>4, \
114+
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) \
115+
{ \
116+
word c2 = seltileinfo.cset&0x0F; \
117+
seltileinfo.cset = c2|(val<<4); \
118+
}), \
119+
INFOBTN("The cset to flash to (set same as the normal cset to not flash)") \
120+
)
121+
122+
#endif
123+

src/dialog/subscr_props.cpp

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "gui/common.h"
1111
#include "base/misctypes.h"
1212
#include "subscr_transition.h"
13+
#include "subscr_macros.h"
1314

1415
extern script_data *genericscripts[NUMSCRIPTSGENERIC];
1516
extern ZCSubscreen subscr_edit;
@@ -74,26 +75,6 @@ static const GUI::ListData list_pgmode
7475
{ "Target", PGGOTO_TRG },
7576
};
7677

77-
#define NUM_FIELD(var,_min,_max) \
78-
TextField( \
79-
fitParent = true, \
80-
type = GUI::TextField::type::INT_DECIMAL, \
81-
low = _min, high = _max, val = var, \
82-
onValChangedFunc = [=](GUI::TextField::type,std::string_view,int32_t val) \
83-
{ \
84-
var = val; \
85-
})
86-
87-
#define NUM_FIELD_OFFS(var,_min,_max,offs) \
88-
TextField( \
89-
fitParent = true, \
90-
type = GUI::TextField::type::INT_DECIMAL, \
91-
low = _min, high = _max, val = var+offs, \
92-
onValChangedFunc = [=](GUI::TextField::type,std::string_view,int32_t val) \
93-
{ \
94-
var = val-offs; \
95-
})
96-
9778
#define MISC_COLOR_SEL(var, txt, num) \
9879
Frame( \
9980
title = txt, \
@@ -122,43 +103,6 @@ Frame( \
122103
}) \
123104
)
124105

125-
#define CBOX(var, bit, txt, cspan) \
126-
Checkbox( \
127-
colSpan = cspan, \
128-
text = txt, hAlign = 0.0, \
129-
checked = var & bit, \
130-
onToggleFunc = [=](bool state) \
131-
{ \
132-
SETFLAG(var, bit, state); \
133-
} \
134-
)
135-
136-
#define CBOX_EX(var, bit, txt, ...) \
137-
Checkbox( \
138-
__VA_ARGS__, \
139-
text = txt, \
140-
checked = var & bit, \
141-
onToggleFunc = [=](bool state) \
142-
{ \
143-
SETFLAG(var, bit, state); \
144-
} \
145-
)
146-
147-
#define INFOCBOX(var, bit, txt, info, cspan) \
148-
Row(colSpan = cspan, \
149-
INFOBTN(info), \
150-
CBOX(var,bit,txt,1) \
151-
)
152-
153-
#define DDL(var, lister) \
154-
DropDownList(data = lister, \
155-
fitParent = true, \
156-
selectedValue = var, \
157-
onSelectFunc = [=](int32_t val) \
158-
{ \
159-
var = val; \
160-
} \
161-
)
162106
#define DDL_FONT(var) \
163107
DropDownList(data = list_font, \
164108
fitParent = true, \
@@ -169,16 +113,6 @@ DropDownList(data = list_font, \
169113
if(fonttf) fonttf->setFont(get_zc_font(val)); \
170114
} \
171115
)
172-
#define DDL_EX(var, lister, ...) \
173-
DropDownList(data = lister, \
174-
fitParent = true, \
175-
__VA_ARGS__, \
176-
selectedValue = var, \
177-
onSelectFunc = [=](int32_t val) \
178-
{ \
179-
var = val; \
180-
} \
181-
)
182116

183117
#define GAUGE_MINITILE(ind,txt,vMTInfo,vModflag,bit) \
184118
Frame(fitParent = true, Column(fitParent = true, \
@@ -796,8 +730,7 @@ std::shared_ptr<GUI::Widget> SubscrPropDialog::view()
796730
onSelectFunc = [=](int32_t val)
797731
{
798732
w->iid = val;
799-
ddl->setDisabled(val > -1);
800-
labels[0]->setDisabled(val > -1);
733+
updateAttr();
801734
}
802735
),
803736
INFOBTN("The specified item ID will be tied to this item slot (OVERRIDES 'Item Class' if set)"),
@@ -1630,6 +1563,52 @@ std::shared_ptr<GUI::Widget> SubscrPropDialog::view()
16301563
)
16311564
)
16321565
),
1566+
TabRef(name = "Selector",
1567+
selframes[2] = Frame(title = "Selector Customization",
1568+
info = "Customize the selector cursor",
1569+
fitParent = true,
1570+
Column(
1571+
Rows<2>(
1572+
CBOX_EX(local_subref->genflags,SUBSCRFLAG_SELOVERRIDE,"Override Selector",
1573+
_EX_RBOX,onToggle = message::REFR_SELECTABLE),
1574+
INFOBTN("Change the selector while over this widget")
1575+
),
1576+
selgs[3] = Row(
1577+
Frame(title = "Dimensions", fitParent = true,
1578+
Rows<3>(
1579+
Label(text = "Selector X", hAlign = 1.0),
1580+
NUM_FIELD(local_subref->selector_override.x,0,255),
1581+
INFOBTN("The top-left of the selector will be forced to this X"),
1582+
Label(text = "Selector Y", hAlign = 1.0),
1583+
NUM_FIELD(local_subref->selector_override.y,0,255),
1584+
INFOBTN("The top-left of the selector will be forced to this Y"),
1585+
Label(text = "Selector Width", hAlign = 1.0),
1586+
NUM_FIELD(local_subref->selector_override.w,0,256),
1587+
INFOBTN("The selector will be forced to this width"),
1588+
Label(text = "Selector Height", hAlign = 1.0),
1589+
NUM_FIELD(local_subref->selector_override.h,0,256),
1590+
INFOBTN("The selector will be forced to this height")
1591+
)),
1592+
Frame(title = "Selector 1 Graphic", fitParent = true,
1593+
info = "Override the Tile, CSet, and Width/Height used by selectors"
1594+
" with 'Use Selector 2' unchecked."
1595+
"\nWidth/Height are given in pixels, and that pixel size will be"
1596+
" used as the source size of the draw. These sizes rounded up to the"
1597+
" next full tile will be the tile width/height of the draw.",
1598+
SELECTOR_GRAPHIC(local_subref->selector_override.tileinfo[0])
1599+
),
1600+
Frame(title = "Selector 2 Graphic", fitParent = true,
1601+
info = "Override the Tile, CSet, and Width/Height used by selectors"
1602+
" with 'Use Selector 2' checked."
1603+
"\nWidth/Height are given in pixels, and that pixel size will be"
1604+
" used as the source size of the draw. These sizes rounded up to the"
1605+
" next full tile will be the tile width/height of the draw.",
1606+
SELECTOR_GRAPHIC(local_subref->selector_override.tileinfo[1])
1607+
)
1608+
)
1609+
)
1610+
)
1611+
),
16331612
seltabs[0] = TabRef(name = "Script",
16341613
Frame(title = "Generic Frozen Script",
16351614
info = "Run a Generic Frozen Script when a button is pressed."
@@ -1684,6 +1663,7 @@ std::shared_ptr<GUI::Widget> SubscrPropDialog::view()
16841663
)
16851664
);
16861665
updateSelectable();
1666+
updateAttr();
16871667
refr_info();
16881668
return window;
16891669
}
@@ -1692,13 +1672,16 @@ void SubscrPropDialog::updateSelectable()
16921672
{
16931673
bool seldis = !(local_subref->genflags & SUBSCRFLAG_SELECTABLE);
16941674
bool scrdis = seldis || !local_subref->generic_script;
1675+
bool selovdis = seldis || !(local_subref->genflags & SUBSCRFLAG_SELOVERRIDE);
16951676
bool pgdis = seldis || !local_subref->pg_mode;
16961677
selgs[0]->setDisabled(seldis);
16971678
selframes[0]->setDisabled(seldis);
16981679
selframes[1]->setDisabled(seldis);
1680+
selframes[2]->setDisabled(seldis);
16991681
seltabs[0]->setDisabled(seldis);
17001682
selgs[1]->setDisabled(scrdis);
17011683
selgs[2]->setDisabled(scrdis);
1684+
selgs[3]->setDisabled(selovdis);
17021685
seltfs[0]->setDisabled(pgdis || local_subref->pg_mode != PGGOTO_TRG);
17031686
selbtns[0]->setDisabled(pgdis);
17041687

@@ -1716,6 +1699,19 @@ void SubscrPropDialog::updateSelectable()
17161699
geninitd_btn[q]->setDisabled(local_gen_meta.initd_help[q].empty());
17171700
}
17181701
}
1702+
void SubscrPropDialog::updateAttr()
1703+
{
1704+
switch(local_subref->getType())
1705+
{
1706+
case widgITEMSLOT:
1707+
{
1708+
SW_ItemSlot* w = dynamic_cast<SW_ItemSlot*>(local_subref);
1709+
ddl->setDisabled(w->iid > -1);
1710+
labels[0]->setDisabled(w->iid > -1);
1711+
break;
1712+
}
1713+
}
1714+
}
17191715
void SubscrPropDialog::updateColors()
17201716
{
17211717
switch(local_subref->getType())
@@ -1787,6 +1783,9 @@ bool SubscrPropDialog::handleMessage(const GUI::DialogMessage<message>& msg)
17871783
{
17881784
switch(msg.message)
17891785
{
1786+
case message::REFR_SELECTABLE:
1787+
updateSelectable();
1788+
break;
17901789
case message::REFR_INFO:
17911790
refr_info();
17921791
break;

src/dialog/subscr_props.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SubscrPropDialog: public GUI::Dialog<SubscrPropDialog>
2424
public:
2525
enum class message
2626
{
27-
REFR_INFO, OK, CANCEL
27+
REFR_INFO, OK, CANCEL, REFR_SELECTABLE
2828
};
2929

3030
SubscrPropDialog(SubscrWidget* widg, int32_t obj_ind);
@@ -44,8 +44,8 @@ class SubscrPropDialog: public GUI::Dialog<SubscrPropDialog>
4444
std::shared_ptr<GUI::TextField> tfs[3];
4545
std::shared_ptr<GUI::Checkbox> cbs[4];
4646

47-
std::shared_ptr<GUI::Grid> selgs[3];
48-
std::shared_ptr<GUI::Frame> selframes[2];
47+
std::shared_ptr<GUI::Grid> selgs[4];
48+
std::shared_ptr<GUI::Frame> selframes[3];
4949
std::shared_ptr<GUI::TabRef> seltabs[1];
5050
std::shared_ptr<GUI::TextField> seltfs[1];
5151
std::shared_ptr<GUI::Button> selbtns[1];
@@ -70,6 +70,7 @@ class SubscrPropDialog: public GUI::Dialog<SubscrPropDialog>
7070
list_costinds;
7171

7272
void updateSelectable();
73+
void updateAttr();
7374
void updateColors();
7475
void update_wh();
7576
void refr_info();

0 commit comments

Comments
 (0)