Implement a mechanism for a special node picker to affect two fields
Use it for the MSG_PAIR picker and the PIC_NONE picker.
This commit is contained in:
@@ -762,7 +762,7 @@ node_builder_t& node_builder_t::sdf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
node_builder_t& node_builder_t::msg() {
|
node_builder_t& node_builder_t::msg() {
|
||||||
return msg1(eSpecPicker::MSG_PAIR).msg2(eSpecPicker::NONE);
|
return field_pair(eSpecField::MSG1, eSpecField::MSG2, eSpecPicker::MSG_PAIR);
|
||||||
};
|
};
|
||||||
|
|
||||||
node_builder_t& node_builder_t::rect() {
|
node_builder_t& node_builder_t::rect() {
|
||||||
@@ -772,7 +772,7 @@ node_builder_t& node_builder_t::rect() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
node_builder_t& node_builder_t::pic() {
|
node_builder_t& node_builder_t::pic() {
|
||||||
return pict(eSpecPicker::PICTURE).ptyp(STRT_PICT);
|
return field_pair(eSpecField::PICT, eSpecField::PTYP, eSpecPicker::PICTURE).ptyp(STRT_PICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_builder_t& node_builder_t::sdf1(node_function_t picker) {
|
node_builder_t& node_builder_t::sdf1(node_function_t picker) {
|
||||||
@@ -838,8 +838,9 @@ node_builder_t& node_builder_t::field(eSpecField field, node_function_t picker)
|
|||||||
}
|
}
|
||||||
|
|
||||||
node_builder_t& node_builder_t::field_pair(eSpecField main, eSpecField extra, node_function_t picker) {
|
node_builder_t& node_builder_t::field_pair(eSpecField main, eSpecField extra, node_function_t picker) {
|
||||||
// Not implemented yet, so just assign the picker to the main field and NONE to the extra field.
|
field(main, picker).field(extra, eSpecPicker::NONE);
|
||||||
return field(main, picker).field(extra, eSpecPicker::NONE);
|
(node.*fields().map[main]).continuation = extra;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_builder_t& node_builder_t::sdf(eSpecField a, eSpecField b) {
|
node_builder_t& node_builder_t::sdf(eSpecField a, eSpecField b) {
|
||||||
|
@@ -160,7 +160,7 @@ enum class eSpecPicker {
|
|||||||
POINTER,
|
POINTER,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class eSpecField { SDF1, SDF2, MSG1, MSG2, MSG3, PICT, PTYP, EX1A, EX1B, EX1C, EX2A, EX2B, EX2C, JUMP };
|
enum class eSpecField { NONE, SDF1, SDF2, MSG1, MSG2, MSG3, PICT, PTYP, EX1A, EX1B, EX1C, EX2A, EX2B, EX2C, JUMP };
|
||||||
|
|
||||||
struct node_function_t {
|
struct node_function_t {
|
||||||
eSpecPicker button = eSpecPicker::NONE;
|
eSpecPicker button = eSpecPicker::NONE;
|
||||||
@@ -172,6 +172,7 @@ struct node_function_t {
|
|||||||
};
|
};
|
||||||
bool augmented = false; // only for eSpecPicker::FIELD and eSpecPicker::STRING with certain string types
|
bool augmented = false; // only for eSpecPicker::FIELD and eSpecPicker::STRING with certain string types
|
||||||
int adjust = 0; // only for eSpecPicker::STRING
|
int adjust = 0; // only for eSpecPicker::STRING
|
||||||
|
eSpecField continuation = eSpecField::NONE;
|
||||||
std::string label() const;
|
std::string label() const;
|
||||||
std::string help() const; // maybe we don't need this though? I guess it would be for a hypothetical help button next to each field to give addition info on how that one field works.
|
std::string help() const; // maybe we don't need this though? I guess it would be for a hypothetical help button next to each field to give addition info on how that one field works.
|
||||||
node_function_t();
|
node_function_t();
|
||||||
|
@@ -855,18 +855,44 @@ static node_function_t get_field_function(const cSpecial& spec, const std::strin
|
|||||||
return node_function_t();
|
return node_function_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string get_control_for_field(eSpecField field) {
|
||||||
|
switch(field) {
|
||||||
|
case eSpecField::SDF1: return "sdf1";
|
||||||
|
case eSpecField::SDF2: return "sdf2";
|
||||||
|
case eSpecField::MSG1: return "msg1";
|
||||||
|
case eSpecField::MSG2: return "msg2";
|
||||||
|
case eSpecField::MSG3: return "msg3";
|
||||||
|
case eSpecField::PICT: return "pict";
|
||||||
|
case eSpecField::PTYP: return "pictype";
|
||||||
|
case eSpecField::EX1A: return "x1a";
|
||||||
|
case eSpecField::EX1B: return "x1b";
|
||||||
|
case eSpecField::EX1C: return "x1c";
|
||||||
|
case eSpecField::EX2A: return "x2a";
|
||||||
|
case eSpecField::EX2B: return "x2b";
|
||||||
|
case eSpecField::EX2C: return "x2c";
|
||||||
|
case eSpecField::JUMP: return "jump";
|
||||||
|
case eSpecField::NONE: break;
|
||||||
|
}
|
||||||
|
return "num";
|
||||||
|
}
|
||||||
|
|
||||||
static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& edit_stack) {
|
static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& edit_stack) {
|
||||||
std::string field = item_hit.substr(0, item_hit.find_first_of('-'));
|
std::string field = item_hit.substr(0, item_hit.find_first_of('-'));
|
||||||
const cSpecial& spec = edit_stack.top().node;
|
const cSpecial& spec = edit_stack.top().node;
|
||||||
node_function_t fcn = get_field_function(spec, field);
|
node_function_t fcn = get_field_function(spec, field);
|
||||||
short val = me[field].getTextAsNum(), store;
|
short val = me[field].getTextAsNum(), store;
|
||||||
switch(fcn.button) {
|
switch(fcn.button) {
|
||||||
case eSpecPicker::MSG_PAIR:
|
case eSpecPicker::MSG_PAIR: {
|
||||||
store = me["msg2"].getTextAsNum();
|
if(fcn.continuation == eSpecField::NONE) {
|
||||||
|
store = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto otherField = get_control_for_field(fcn.continuation);
|
||||||
|
store = me[otherField].getTextAsNum();
|
||||||
edit_spec_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &val, &store, &me);
|
edit_spec_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &val, &store, &me);
|
||||||
me["msg2"].setTextToNum(store);
|
me[otherField].setTextToNum(store);
|
||||||
store = val;
|
store = val;
|
||||||
break;
|
} break;
|
||||||
case eSpecPicker::MSG_SINGLE:
|
case eSpecPicker::MSG_SINGLE:
|
||||||
edit_spec_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &val, nullptr, &me);
|
edit_spec_text(fcn.force_global ? STRS_SCEN : eStrMode(edit_stack.top().mode), &val, nullptr, &me);
|
||||||
store = val;
|
store = val;
|
||||||
@@ -958,9 +984,10 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t&
|
|||||||
case eSpecPicker::PICTURE: {
|
case eSpecPicker::PICTURE: {
|
||||||
ePicType type = fcn.pic_type;
|
ePicType type = fcn.pic_type;
|
||||||
if(type == PIC_NONE) {
|
if(type == PIC_NONE) {
|
||||||
short pictype = me["pictype"].getTextAsNum();
|
auto otherField = get_control_for_field(fcn.continuation);
|
||||||
|
short pictype = me[otherField].getTextAsNum();
|
||||||
if(pictype < 0) {
|
if(pictype < 0) {
|
||||||
me["pictype"].setTextToNum(PIC_DLOG);
|
me[otherField].setTextToNum(PIC_DLOG);
|
||||||
type = PIC_DLOG;
|
type = PIC_DLOG;
|
||||||
} else type = ePicType(pictype);
|
} else type = ePicType(pictype);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user