Implement a toggle picker for special node fields

This commit is contained in:
2025-02-22 15:49:13 -05:00
committed by Celtic Minstrel
parent 8ac6caa8c5
commit 1d119e1f26
8 changed files with 65 additions and 28 deletions

View File

@@ -32,66 +32,80 @@
<text name='sdf1-lbl' framed='true' top='121' left='22' width='220' height='15'/> <text name='sdf1-lbl' framed='true' top='121' left='22' width='220' height='15'/>
<field name='sdf1' top='120' left='254' width='51' height='16'/> <field name='sdf1' top='120' left='254' width='51' height='16'/>
<button name='sdf1-edit' type='tiny' top='106' left='272'/> <button name='sdf1-edit' type='tiny' top='106' left='272'/>
<led name='sdf1-toggle' top='106' left='272'/>
<text name='sdf2-lbl' framed='true' top='121' left='317' width='176' height='16'/> <text name='sdf2-lbl' framed='true' top='121' left='317' width='176' height='16'/>
<field name='sdf2' top='120' left='510' width='51' height='16'/> <field name='sdf2' top='120' left='510' width='51' height='16'/>
<button name='sdf2-edit' type='tiny' top='106' left='528'/> <button name='sdf2-edit' type='tiny' top='106' left='528'/>
<led name='sdf2-toggle' top='106' left='528'/>
<text size='large' top='141' left='8' width='176' height='16'>Message, Pict:</text> <text size='large' top='141' left='8' width='176' height='16'>Message, Pict:</text>
<text name='msg1-lbl' framed='true' top='164' left='22' width='238' height='15'/> <text name='msg1-lbl' framed='true' top='164' left='22' width='238' height='15'/>
<field name='msg1' top='163' left='270' width='51' height='16'/> <field name='msg1' top='163' left='270' width='51' height='16'/>
<button name='msg1-edit' type='large' top='161' left='329'>Create/Edit</button> <button name='msg1-edit' type='large' top='161' left='329'>Create/Edit</button>
<led name='msg1-toggle' top='167' left='329'/>
<text name='msg2-lbl' framed='true' top='188' left='22' width='238' height='15'/> <text name='msg2-lbl' framed='true' top='188' left='22' width='238' height='15'/>
<field name='msg2' top='187' left='270' width='51' height='16'/> <field name='msg2' top='187' left='270' width='51' height='16'/>
<button name='msg2-edit' type='large' top='185' left='329'>Create/Edit</button> <button name='msg2-edit' type='large' top='185' left='329'>Create/Edit</button>
<led name='msg2-toggle' top='191' left='329'/>
<text name='msg3-lbl' framed='true' top='212' left='22' width='238' height='15'/> <text name='msg3-lbl' framed='true' top='212' left='22' width='238' height='15'/>
<field name='msg3' top='211' left='270' width='51' height='16'/> <field name='msg3' top='211' left='270' width='51' height='16'/>
<button name='msg3-edit' type='large' top='209' left='329'>Create/Edit</button> <button name='msg3-edit' type='large' top='209' left='329'>Create/Edit</button>
<led name='msg3-toggle' top='215' left='329'/>
<text name='pict-lbl' framed='true' top='236' left='22' width='238' height='15'/> <text name='pict-lbl' framed='true' top='236' left='22' width='238' height='15'/>
<field name='pict' top='235' left='270' width='51' height='16'/> <field name='pict' top='235' left='270' width='51' height='16'/>
<button name='pict-edit' type='large' top='233' left='329'>Choose</button> <button name='pict-edit' type='large' top='233' left='329'>Choose</button>
<led name='pict-toggle' top='239' left='329'/>
<text name='pictype-lbl' framed='true' top='260' left='22' width='238' height='15'/> <text name='pictype-lbl' framed='true' top='260' left='22' width='238' height='15'/>
<field name='pictype' top='259' left='270' width='51' height='16'/> <field name='pictype' top='259' left='270' width='51' height='16'/>
<button name='pictype-edit' type='large' top='257' left='329'>Choose</button> <button name='pictype-edit' type='large' top='257' left='329'>Choose</button>
<led name='pictype-toggle' top='263' left='329'/>
<text size='large' top='281' left='8' width='158' height='16'>Extra 1:</text> <text size='large' top='281' left='8' width='158' height='16'>Extra 1:</text>
<text name='x1a-lbl' framed='true' top='302' left='22' width='238' height='15'/> <text name='x1a-lbl' framed='true' top='302' left='22' width='238' height='15'/>
<field name='x1a' top='301' left='270' width='51' height='16'/> <field name='x1a' top='301' left='270' width='51' height='16'/>
<button name='x1a-edit' type='large' top='298' left='330'>Choose</button> <button name='x1a-edit' type='large' top='298' left='330'>Choose</button>
<led name='x1a-toggle' top='304' left='330'/>
<text name='x1b-lbl' framed='true' top='326' left='22' width='238' height='15'/> <text name='x1b-lbl' framed='true' top='326' left='22' width='238' height='15'/>
<field name='x1b' top='325' left='270' width='51' height='16'/> <field name='x1b' top='325' left='270' width='51' height='16'/>
<button name='x1b-edit' type='large' top='322' left='330'>Create/Edit</button> <button name='x1b-edit' type='large' top='322' left='330'>Create/Edit</button>
<led name='x1b-toggle' top='328' left='330'/>
<text name='x1c-lbl' framed='true' top='350' left='22' width='238' height='15'/> <text name='x1c-lbl' framed='true' top='350' left='22' width='238' height='15'/>
<field name='x1c' top='349' left='270' width='51' height='16'/> <field name='x1c' top='349' left='270' width='51' height='16'/>
<button name='x1c-edit' type='large' top='346' left='330'>Create/Edit</button> <button name='x1c-edit' type='large' top='346' left='330'>Create/Edit</button>
<led name='x1c-toggle' top='352' left='330'/>
<text size='large' top='372' left='8' width='158' height='16'>Extra 2:</text> <text size='large' top='372' left='8' width='158' height='16'>Extra 2:</text>
<text name='x2a-lbl' framed='true' top='394' left='22' width='238' height='15'/> <text name='x2a-lbl' framed='true' top='394' left='22' width='238' height='15'/>
<field name='x2a' top='394' left='270' width='51' height='16'/> <field name='x2a' top='394' left='270' width='51' height='16'/>
<button name='x2a-edit' type='large' top='391' left='330'>Choose</button> <button name='x2a-edit' type='large' top='391' left='330'>Choose</button>
<led name='x2a-toggle' top='397' left='330'/>
<text name='x2b-lbl' framed='true' top='419' left='22' width='238' height='15'/> <text name='x2b-lbl' framed='true' top='419' left='22' width='238' height='15'/>
<field name='x2b' top='418' left='270' width='51' height='16'/> <field name='x2b' top='418' left='270' width='51' height='16'/>
<button name='x2b-edit' type='large' top='416' left='330'>Create/Edit</button> <button name='x2b-edit' type='large' top='416' left='330'>Create/Edit</button>
<led name='x2b-toggle' top='422' left='330'/>
<text name='x2c-lbl' framed='true' top='443' left='22' width='238' height='15'/> <text name='x2c-lbl' framed='true' top='443' left='22' width='238' height='15'/>
<field name='x2c' top='442' left='270' width='51' height='16'/> <field name='x2c' top='442' left='270' width='51' height='16'/>
<button name='x2c-edit' type='large' top='440' left='330'>Create/Edit</button> <button name='x2c-edit' type='large' top='440' left='330'>Create/Edit</button>
<led name='x2c-toggle' top='446' left='330'/>
<text size='large' top='471' left='8' width='87' height='16'>Jump To:</text> <text size='large' top='471' left='8' width='87' height='16'>Jump To:</text>
<text name='jump-lbl' framed='true' top='472' left='99' width='182' height='14'/> <text name='jump-lbl' framed='true' top='472' left='99' width='182' height='14'/>
<field name='jump' top='471' left='291' width='52' height='15'/> <field name='jump' top='471' left='291' width='52' height='15'/>
<button name='jump-edit' type='large' top='468' left='349'>Create/Edit</button> <button name='jump-edit' type='large' top='468' left='349'>Create/Edit</button>
<led name='jump-toggle' top='474' left='349'/>
<button name='okay' type='regular' top='494' left='522'>OK</button> <button name='okay' type='regular' top='494' left='522'>OK</button>

View File

@@ -448,7 +448,7 @@ Second part of message
Unused Unused
Unused Unused
Unused Unused
If 1, just store ID in SDF and leave PC in party Just store ID in SDF and leave PC in party?
extra 1b extra 1b
extra 1c extra 1c
extra 2a extra 2a

View File

@@ -196,7 +196,7 @@ Unused
0 - allow, 1 - prevent 0 - allow, 1 - prevent
Unused Unused
Unused Unused
0 - don't force, 1 - force if blocked Force allow if blocked?
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -245,7 +245,7 @@ Unused
Unused Unused
Unused Unused
Which sound Which sound
0 - wait for sound to finish, 1 - don't wait Continue without waiting for sound to finish?
Unused Unused
Unused Unused
Unused Unused
@@ -264,7 +264,7 @@ Unused
Horse to set (0 .. 29) Horse to set (0 .. 29)
Unused Unused
Unused Unused
0 - not property, 1 - becomes property Owned by party?
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -281,7 +281,7 @@ Unused
Boat to set (0 .. 29) Boat to set (0 .. 29)
Unused Unused
Unused Unused
0 - not property, 1 - becomes property Owned by party?
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -298,7 +298,7 @@ Unused
Town to show/hide Town to show/hide
Unused Unused
Unused Unused
0 - town hidden, 1 - town visible Town visible?
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -650,7 +650,7 @@ Unused
Unused Unused
Unused Unused
Unused Unused
If 1, put a space before it Put a space before it?
Unused Unused
String to append String to append
Unused Unused
@@ -667,7 +667,7 @@ Unused
Unused Unused
Unused Unused
Unused Unused
If 1, put a space before it Put a space before it?
Unused Unused
Number to append Number to append
Unused Unused
@@ -684,7 +684,7 @@ Unused
Unused Unused
Unused Unused
Unused Unused
If 1, put a space before it Put a space before it?
Unused Unused
Monster type, or 0 to used selected PC Monster type, or 0 to used selected PC
Unused Unused
@@ -701,10 +701,10 @@ Unused
Unused Unused
Unused Unused
Unused Unused
If 1, put a space before it Put a space before it?
Unused Unused
Item type Item type
0 - unidentified, 1 - full identified name Use identified name?
Unused Unused
Unused Unused
Unused Unused
@@ -718,7 +718,7 @@ Unused
Unused Unused
Unused Unused
Unused Unused
If 1, put a space before it Put a space before it?
Unused Unused
Terrain type Terrain type
Unused Unused

View File

@@ -128,7 +128,7 @@ Unused
If party has this much gold ... If party has this much gold ...
Call this special ... Call this special ...
Unused Unused
If 1, take gold Take gold?
Unused Unused
Unused Unused
Otherwise call this special Otherwise call this special
@@ -145,7 +145,7 @@ Unused
If party has this much food ... If party has this much food ...
Call this special ... Call this special ...
Unused Unused
If 1, take food Take food?
Unused Unused
Unused Unused
Otherwise call this special Otherwise call this special
@@ -164,7 +164,7 @@ Y coordinate of space
Unused Unused
If item of this class on space ... If item of this class on space ...
Call this special ... Call this special ...
If 1, take item Take item?
Otherwise call this special Otherwise call this special
-------------------- --------------------
@@ -179,7 +179,7 @@ Unused
If has item of this special class ... If has item of this special class ...
Call this special ... Call this special ...
Unused Unused
If 1, take item Take item?
Unused Unused
Unused Unused
Otherwise call this special Otherwise call this special
@@ -196,7 +196,7 @@ Unused
If has equipped item of this special ... If has equipped item of this special ...
Call this special ... Call this special ...
Unused Unused
If 1, take item Take item?
Unused Unused
Unused Unused
Otherwise call this special Otherwise call this special
@@ -329,7 +329,7 @@ Unused
Unused Unused
Unused Unused
Unused Unused
1 - include dead characters, otherwise no Include dead characters?
If party size sufficient, call this special ... If party size sufficient, call this special ...
Unused Unused
0 - Exact size, 1 - Minimum size 0 - Exact size, 1 - Minimum size
@@ -449,7 +449,7 @@ Unused
Unused Unused
Unused Unused
Which context (0 .. 24) Which context (0 .. 24)
0 - can enter, 1 - no enter Prevent entry?
If context matches, call this special ... If context matches, call this special ...
Unused Unused
Unused Unused

View File

@@ -88,7 +88,7 @@ Stuff Done Flag Part A
Stuff Done Flag Part B Stuff Done Flag Part B
Number of first message in dialog Number of first message in dialog
Unused Unused
1 - add 'Leave'/'OK' button, else no Add 'Leave'/'OK' button?
Picture number Picture number
Picture type Picture type
Label of 2nd button (-1 - no button) Label of 2nd button (-1 - no button)

View File

@@ -37,7 +37,7 @@ X of space to move to
Y of space to move to Y of space to move to
First part of message First part of message
Second part of message Second part of message
Set to 1 to place in container, if present Place in container, if present?
0 - entire rectangle, 1 - just borders 0 - entire rectangle, 1 - just borders
Unused Unused
Top of rectangle Top of rectangle

View File

@@ -77,7 +77,7 @@ Unused
X coordinate of space X coordinate of space
Y coordinate of space Y coordinate of space
Unused Unused
0 - Just move, 1 - Teleport Play teleport animation?
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -197,7 +197,7 @@ X coordinate of space to place
Y coordinate of space to place Y coordinate of space to place
Unused Unused
Number of creature to place Number of creature to place
1 - force placement Force placement?
Unused Unused
Special to Jump To Special to Jump To
@@ -350,7 +350,7 @@ X coordinate to place at
Y coordinate to place at Y coordinate to place at
Unused Unused
Number of town to place party in Number of town to place party in
If 1, always change level. Skip dialog and always change level?
Trigger Limitations Trigger Limitations
Special to Call in New Town Special to Call in New Town
@@ -384,7 +384,7 @@ X coordinate to place at
Y coordinate to place at Y coordinate to place at
Unused Unused
Item to place Item to place
Set to 1 to place in container, if present Place in container, if present?
Unused Unused
Special to Jump To Special to Jump To
@@ -417,7 +417,7 @@ Unused
Sound to play (10 = teleport) Sound to play (10 = teleport)
Unused Unused
Unused Unused
If 1, don't change location 0 - return to split point, 1 - don't change location
Unused Unused
Unused Unused
Special to Jump To Special to Jump To
@@ -520,8 +520,8 @@ Which spell pattern? (0 - single space)
Max range? (ignored outside combat mode) Max range? (ignored outside combat mode)
Max targets? (>1 only in combat) Max targets? (>1 only in combat)
Special Called if Targeting Fails Special Called if Targeting Fails
if 1, allow obstructed spaces Allow obstructed spaces?
if 1, allow targeting in antimagic fields Allow targeting in antimagic fields?
Special to Call for Each Target Special to Call for Each Target
-------------------- --------------------

View File

@@ -555,19 +555,28 @@ static void setup_node_field(cDialog& me, std::string field, short value, const
me[field].setTextToNum(value); me[field].setTextToNum(value);
bool is_sdf = field.substr(0,3) == "sdf"; bool is_sdf = field.substr(0,3) == "sdf";
std::string button = field + "-edit"; std::string button = field + "-edit";
std::string toggle = field + "-toggle";
switch(fcn.button) { switch(fcn.button) {
case eSpecPicker::NONE: case eSpecPicker::NONE:
me[button].hide(); me[button].hide();
me[toggle].hide();
break; break;
case eSpecPicker::MSG_PAIR: case eSpecPicker::MSG_SINGLE: case eSpecPicker::MSG_PAIR: case eSpecPicker::MSG_SINGLE:
case eSpecPicker::MSG_SEQUENCE: case eSpecPicker::NODE: case eSpecPicker::MSG_SEQUENCE: case eSpecPicker::NODE:
me[button].show(); me[button].show();
me[toggle].hide();
if(is_sdf) break; if(is_sdf) break;
me[button].setText("Create/Edit"); me[button].setText("Create/Edit");
dynamic_cast<cButton&>(me[button]).setBtnType(BTN_LG); dynamic_cast<cButton&>(me[button]).setBtnType(BTN_LG);
break; break;
case eSpecPicker::TOGGLE:
me[button].hide();
me[toggle].show();
dynamic_cast<cLed&>(me[toggle]).setState(value > 0 ? eLedState::led_red : eLedState::led_off);
break;
default: default:
me[button].show(); me[button].show();
me[toggle].hide();
if(is_sdf) break; if(is_sdf) break;
me[button].setText("Choose"); me[button].setText("Choose");
dynamic_cast<cButton&>(me[button]).setBtnType(BTN_REG); dynamic_cast<cButton&>(me[button]).setBtnType(BTN_REG);
@@ -866,6 +875,17 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t&
store = val; store = val;
edit_dialog_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &store, &me); edit_dialog_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &store, &me);
break; break;
case eSpecPicker::TOGGLE: {
// TODO: We should also add a focus handler so that manually changing the field value updates the toggle...
cLed& toggle = dynamic_cast<cLed&>(me[item_hit]);
if(val > 0) {
store = 0;
toggle.setState(eLedState::led_off);
} else {
store = 1;
toggle.setState(eLedState::led_red);
}
} break;
case eSpecPicker::NODE: { case eSpecPicker::NODE: {
short mode = fcn.force_global ? 0 : edit_stack.top().mode; short mode = fcn.force_global ? 0 : edit_stack.top().mode;
store = val < 0 ? get_fresh_spec(mode) : val; store = val < 0 ? get_fresh_spec(mode) : val;
@@ -1000,6 +1020,9 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) {
"msg1-edit", "msg2-edit", "msg3-edit", "pict-edit", "pictype-edit", "jump-edit", "msg1-edit", "msg2-edit", "msg3-edit", "pict-edit", "pictype-edit", "jump-edit",
"x1a-edit", "x1b-edit", "x1c-edit", "x2a-edit", "x2b-edit", "x2c-edit", "x1a-edit", "x1b-edit", "x1c-edit", "x2a-edit", "x2b-edit", "x2c-edit",
"sdf1-edit", "sdf2-edit", "sdf1-edit", "sdf2-edit",
"msg1-toggle", "msg2-toggle", "msg3-toggle", "pict-toggle", "pictype-toggle", "jump-toggle",
"x1a-toggle", "x1b-toggle", "x1c-toggle", "x2a-toggle", "x2b-toggle", "x2c-toggle",
"sdf1-toggle", "sdf2-toggle",
}); });
special["cancel"].attachClickHandler(std::bind(discard_spec_enc, _1, std::ref(edit_stack))); special["cancel"].attachClickHandler(std::bind(discard_spec_enc, _1, std::ref(edit_stack)));
special["node-help"].attachClickHandler([&edit_stack](cDialog& me, std::string item_hit, eKeyMod mods) { special["node-help"].attachClickHandler([&edit_stack](cDialog& me, std::string item_hit, eKeyMod mods) {