Finish strictifying special node type enum (forgot the scenario editor)

This commit is contained in:
2014-12-07 17:50:21 -05:00
parent 46c3c69bd9
commit 0d7ad2c718
4 changed files with 267 additions and 111 deletions

View File

@@ -83,3 +83,194 @@ std::istream& operator >> (std::istream& in, eSpecType& e) {
e = eSpecType::ERROR;
return in;
}
// This is sort of a workaround for VS2013 not supporting C99 designated initializers in C++.
namespace node_types {
using np_populator = std::function<void(node_properties_t)>;
template<typename T> struct np_populator_builder {
T node_properties_t::*const prop;
np_populator_builder(T node_properties_t::* p) : prop(p) {}
void setVal(node_properties_t props, T val) const {
(props.*prop) = val;
}
template<typename T2> np_populator operator= (T2 val) const {
return std::bind(&np_populator_builder<T>::setVal, this, std::placeholders::_1, val);
}
};
namespace keys {
template<typename T> using npb = const np_populator_builder<T>;
using npt = node_properties_t;
// Needs to be one of these for every member variable in node_properties_t.
npb<bool> ex1a_ch(&npt::ex1a_choose), ex1b_ch(&npt::ex1b_choose), ex1c_ch(&npt::ex1c_choose);
npb<bool> ex2a_ch(&npt::ex1a_choose), ex2b_ch(&npt::ex2b_choose), ex2c_ch(&npt::ex2c_choose);
npb<short> sdf_lbl(&npt::sdf_label), msg_lbl(&npt::sdf_label);
npb<short> pic_lbl(&npt::sdf_label), jmp_lbl(&npt::sdf_label);
}
}
node_properties_t::node_properties_t(std::initializer_list<node_types::np_populator> vals) {
for(node_types::np_populator val : vals) val(*this);
}
using namespace node_types::keys;
// This is the database of information on the special nodes, used by the scenario editor to decide how to set up the edit node dialog.
// Keys ending in _ch indicate whether a "Choose" or "Create/Edit" button should be present, and must be a boolean.
// (Whether it's a Choose or Create/Edit button depends on the field.)
// Keys ending in _lbl indicate the set of labels applied to that set of fields, and are also used to determine the effect of the buttons.
// The extra fields curently have their label associations hard-coded rather than listed here.
const std::map<eSpecType, node_properties_t> allNodeProps = {
{eSpecType::NONE, {}},
{eSpecType::SET_SDF, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::INC_SDF, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::DISPLAY_MSG, {msg_lbl = 1}},
{eSpecType::SECRET_PASSAGE, {msg_lbl = 1}},
{eSpecType::DISPLAY_SM_MSG, {msg_lbl = 1}},
{eSpecType::FLIP_SDF, {sdf_lbl = 1,msg_lbl = 1}},
// TODO: XXX_BLOCK were here and had jmp_lbl = 1; what to do about that?
{eSpecType::CANT_ENTER, {msg_lbl = 1}},
{eSpecType::CHANGE_TIME, {msg_lbl = 1}},
{eSpecType::SCEN_TIMER_START, {ex1b_ch = true}},
{eSpecType::PLAY_SOUND, {}},
{eSpecType::CHANGE_HORSE_OWNER, {}},
{eSpecType::CHANGE_BOAT_OWNER, {}},
{eSpecType::SET_TOWN_VISIBILITY, {msg_lbl = 1}},
{eSpecType::MAJOR_EVENT_OCCURRED, {msg_lbl = 1}},
{eSpecType::FORCED_GIVE, {ex1a_ch = true,ex2b_ch = true,msg_lbl = 1}},
{eSpecType::BUY_ITEMS_OF_TYPE, {ex1b_ch = true,msg_lbl = 1}},
{eSpecType::CALL_GLOBAL, {}},
{eSpecType::SET_SDF_ROW, {sdf_lbl = 1}},
{eSpecType::COPY_SDF, {sdf_lbl = 1}},
// TODO: Sanctify was here, and had ex1b_ch = true; what to do about that?
{eSpecType::REST, {msg_lbl = 1}},
{eSpecType::WANDERING_WILL_FIGHT, {}},
{eSpecType::END_SCENARIO, {}},
{eSpecType::ONCE_GIVE_ITEM, {ex1a_ch = true,ex2b_ch = true,sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::ONCE_GIVE_SPEC_ITEM, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::ONCE_NULL, {sdf_lbl = 1}},
{eSpecType::ONCE_SET_SDF, {sdf_lbl = 1}},
{eSpecType::ONCE_DISPLAY_MSG, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::ONCE_DIALOG, {ex1a_ch = true,ex2a_ch = true,ex1b_ch = true,ex2b_ch = true,
sdf_lbl = 1,msg_lbl = 4,pic_lbl = 1,jmp_lbl = 4}},
{eSpecType::ONCE_DIALOG_TERRAIN, {ex1a_ch = true,ex2a_ch = true,ex1b_ch = true,ex2b_ch = true,
sdf_lbl = 1,msg_lbl = 4,pic_lbl = 2,jmp_lbl = 4}},
{eSpecType::ONCE_DIALOG_MONSTER, {ex1a_ch = true,ex2a_ch = true,ex1b_ch = true,ex2b_ch = true,
sdf_lbl = 1,msg_lbl = 4,pic_lbl = 3,jmp_lbl = 4}},
{eSpecType::ONCE_GIVE_ITEM_DIALOG, {ex1a_ch = true,ex2b_ch = true,sdf_lbl = 1,msg_lbl = 5,pic_lbl = 1}},
{eSpecType::ONCE_GIVE_ITEM_TERRAIN, {ex1a_ch = true,ex2b_ch = true,sdf_lbl = 1,msg_lbl = 5,pic_lbl = 2}},
{eSpecType::ONCE_GIVE_ITEM_MONSTER, {ex1a_ch = true,ex2b_ch = true,sdf_lbl = 1,msg_lbl = 5,pic_lbl = 3}},
{eSpecType::ONCE_OUT_ENCOUNTER, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::ONCE_TOWN_ENCOUNTER, {sdf_lbl = 1,msg_lbl = 1}},
{eSpecType::ONCE_TRAP, {sdf_lbl = 1,msg_lbl = 1,jmp_lbl = 2}},
{eSpecType::SELECT_PC, {ex1b_ch = true,msg_lbl = 1}},
{eSpecType::DAMAGE, {msg_lbl = 1}},
{eSpecType::AFFECT_HP, {msg_lbl = 1}},
{eSpecType::AFFECT_SP, {msg_lbl = 1}},
{eSpecType::AFFECT_XP, {msg_lbl = 1}},
{eSpecType::AFFECT_SKILL_PTS, {msg_lbl = 1}},
{eSpecType::AFFECT_DEADNESS, {msg_lbl = 1}},
{eSpecType::AFFECT_POISON, {msg_lbl = 1}},
{eSpecType::AFFECT_SPEED, {msg_lbl = 1}},
{eSpecType::AFFECT_INVULN, {msg_lbl = 1}},
{eSpecType::AFFECT_MAGIC_RES, {msg_lbl = 1}},
{eSpecType::AFFECT_WEBS, {msg_lbl = 1}},
{eSpecType::AFFECT_DISEASE, {msg_lbl = 1}},
{eSpecType::AFFECT_SANCTUARY, {msg_lbl = 1}},
{eSpecType::AFFECT_CURSE_BLESS, {msg_lbl = 1}},
{eSpecType::AFFECT_DUMBFOUND, {msg_lbl = 1}},
{eSpecType::AFFECT_SLEEP, {msg_lbl = 1}},
{eSpecType::AFFECT_PARALYSIS, {msg_lbl = 1}},
{eSpecType::AFFECT_STAT, {msg_lbl = 1,pic_lbl = 4}},
{eSpecType::AFFECT_MAGE_SPELL, {msg_lbl = 1}},
{eSpecType::AFFECT_PRIEST_SPELL, {msg_lbl = 1}},
{eSpecType::AFFECT_GOLD, {msg_lbl = 1}},
{eSpecType::AFFECT_FOOD, {msg_lbl = 1}},
{eSpecType::AFFECT_ALCHEMY, {msg_lbl = 1}},
{eSpecType::AFFECT_STEALTH, {msg_lbl = 1}},
{eSpecType::AFFECT_FIREWALK, {msg_lbl = 1}},
{eSpecType::AFFECT_FLIGHT, {msg_lbl = 1}},
{eSpecType::IF_SDF, {ex1b_ch = true,ex2b_ch = true,sdf_lbl = 1,jmp_lbl = 3}},
{eSpecType::IF_TOWN_NUM, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_RANDOM, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAVE_SPECIAL_ITEM, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_SDF_COMPARE, {ex2b_ch = true,sdf_lbl = 1,jmp_lbl = 3}},
{eSpecType::IF_TOWN_TER_TYPE, {ex2a_ch = true,ex2b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_OUT_TER_TYPE, {ex2a_ch = true,ex2b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_GOLD, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_FOOD, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_ITEM_CLASS_ON_SPACE, {ex2b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAVE_ITEM_CLASS, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_EQUIP_ITEM_CLASS, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_GOLD_AND_TAKE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_FOOD_AND_TAKE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_ITEM_CLASS_ON_SPACE_AND_TAKE, {ex2b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAVE_ITEM_CLASS_AND_TAKE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_EQUIP_ITEM_CLASS_AND_TAKE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_DAY_REACHED, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_BARRELS, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_CRATES, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_EVENT_OCCURRED, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_CAVE_LORE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_HAS_WOODSMAN, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_ENOUGH_MAGE_LORE, {ex1b_ch = true,jmp_lbl = 3}},
{eSpecType::IF_TEXT_RESPONSE, {ex1b_ch = true,ex2b_ch = true,pic_lbl = 5,jmp_lbl = 3}},
{eSpecType::IF_SDF_EQ, {ex1b_ch = true,sdf_lbl = 1,jmp_lbl = 3}},
{eSpecType::IF_CONTEXT, {}},
{eSpecType::MAKE_TOWN_HOSTILE, {msg_lbl = 1}},
{eSpecType::TOWN_CHANGE_TER, {ex2a_ch = true,msg_lbl = 1}},
{eSpecType::TOWN_SWAP_TER, {ex2a_ch = true,msg_lbl = 1}},
{eSpecType::TOWN_TRANS_TER, {msg_lbl = 1}},
{eSpecType::TOWN_MOVE_PARTY, {msg_lbl = 1}},
{eSpecType::TOWN_HIT_SPACE, {msg_lbl = 1}},
{eSpecType::TOWN_EXPLODE_SPACE, {msg_lbl = 1,pic_lbl = 6}},
{eSpecType::TOWN_LOCK_SPACE, {msg_lbl = 1}},
{eSpecType::TOWN_UNLOCK_SPACE, {msg_lbl = 1}},
{eSpecType::TOWN_SFX_BURST, {msg_lbl = 1}},
{eSpecType::TOWN_CREATE_WANDERING, {msg_lbl = 1}},
{eSpecType::TOWN_PLACE_MONST, {ex2a_ch = true,msg_lbl = 1}},
{eSpecType::TOWN_DESTROY_MONST, {ex1a_ch = true,msg_lbl = 1}},
{eSpecType::TOWN_NUKE_MONSTS, {msg_lbl = 1}},
{eSpecType::TOWN_GENERIC_LEVER, {ex1b_ch = true}},
{eSpecType::TOWN_GENERIC_PORTAL, {}},
{eSpecType::TOWN_GENERIC_BUTTON, {ex1b_ch = true}},
{eSpecType::TOWN_GENERIC_STAIR, {}},
{eSpecType::TOWN_LEVER, {ex1b_ch = true,msg_lbl = 2,pic_lbl = 2}},
{eSpecType::TOWN_PORTAL, {msg_lbl = 2,pic_lbl = 1}},
{eSpecType::TOWN_STAIR, {msg_lbl = 2}},
{eSpecType::TOWN_RELOCATE, {msg_lbl = 1}},
{eSpecType::TOWN_PLACE_ITEM, {ex2a_ch = true,msg_lbl = 1}},
{eSpecType::TOWN_SPLIT_PARTY, {msg_lbl = 1}},
{eSpecType::TOWN_REUNITE_PARTY, {msg_lbl = 1}},
{eSpecType::TOWN_TIMER_START, {ex1b_ch = true,msg_lbl = 1}},
{eSpecType::RECT_PLACE_FIRE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_FORCE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_ICE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_BLADE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_SCLOUD, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_SLEEP, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_QUICKFIRE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_FIRE_BARR, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_FORCE_BARR, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_CLEANSE, {sdf_lbl = 2,msg_lbl = 1}},
{eSpecType::RECT_PLACE_SFX, {sdf_lbl = 7,msg_lbl = 1}},
{eSpecType::RECT_PLACE_OBJECT, {sdf_lbl = 8,msg_lbl = 1}},
{eSpecType::RECT_MOVE_ITEMS, {sdf_lbl = 4,msg_lbl = 1}},
{eSpecType::RECT_DESTROY_ITEMS, {msg_lbl = 1}},
{eSpecType::RECT_CHANGE_TER, {sdf_lbl = 5,msg_lbl = 1}},
{eSpecType::RECT_SWAP_TER, {sdf_lbl = 6,msg_lbl = 1}},
// TODO: Is it correct for some RECT specials to not have sdf_lbl = something?
{eSpecType::RECT_TRANS_TER, {msg_lbl = 1}},
{eSpecType::RECT_LOCK, {msg_lbl = 1}},
{eSpecType::RECT_UNLOCK, {msg_lbl = 1}},
{eSpecType::OUT_MAKE_WANDER, {}},
{eSpecType::OUT_CHANGE_TER, {ex2a_ch = true,msg_lbl = 1}},
{eSpecType::OUT_PLACE_ENCOUNTER, {msg_lbl = 1}},
{eSpecType::OUT_MOVE_PARTY, {msg_lbl = 1}},
{eSpecType::OUT_STORE, {ex1a_ch = true,msg_lbl = 3}},
};
const node_properties_t& operator* (eSpecType t) {
node_properties_t p = allNodeProps.at(t);
return p;
}

View File

@@ -46,7 +46,15 @@ struct pending_special_type {
long long trigger_time;
};
struct node_properties_t {
bool ex1a_choose, ex1b_choose, ex1c_choose, ex2a_choose, ex2b_choose, ex2c_choose;
short sdf_label, msg_label, pic_label, jmp_label;
node_properties_t() {}
node_properties_t(std::initializer_list<std::function<void(node_properties_t)>>);
};
std::ostream& operator << (std::ostream& out, eSpecType& e);
std::istream& operator >> (std::istream& in, eSpecType& e);
const node_properties_t& operator* (eSpecType t);
#endif

View File

@@ -3348,17 +3348,17 @@ void start_special_editing(short mode,short just_redo_text) {
for (i = 0; i < num_specs[mode]; i++) {
switch (mode) {
case 0:
s2 = get_str("special-node-names",scenario.scen_specials[i].type + 1);
s2 = get_str("special-node-names",int(scenario.scen_specials[i].type) + 1);
sprintf((char *) str,"%d - %-30.30s",i,s2.c_str());
set_rb(i,4000 + i,(char *) str,0);
break;
case 1:
s2 = get_str("special-node-names",current_terrain.specials[i].type + 1);
s2 = get_str("special-node-names",int(current_terrain.specials[i].type) + 1);
sprintf((char *) str,"%d - %-30.30s",i,s2.c_str());
set_rb(i,5000 + i,(char *) str,0);
break;
case 2:
s2 = get_str("special-node-names",town->specials[i].type + 1);
s2 = get_str("special-node-names",int(town->specials[i].type) + 1);
sprintf((char *) str,"%d - %-30.30s",i,s2.c_str());
set_rb(i,6000 + i,(char *) str,0);
break;

View File

@@ -31,68 +31,6 @@ std::stack<short> last_node;
cSpecial store_spec_node;
short num_specs[3] = {256,60,100};
std::set<short> ex1a_choose = {19,50,55,56,57,58,59,60,182,229,-1,-1};
std::set<short> ex2a_choose = {55,56,57,-1,-1, -1,135,136,171,172, 181,192,226,-1,-1, -1,-1,-1};
std::set<short> ex1b_choose = {
13, 20, 55, 56, 57, 24, -1, -1, 80, 130,
131,132,133,137,138,140,141,142,143,145,
146,147,148,149,150,151,152,153,154,184,
188,195,186,-1, -1, -1, -1, -1, -1, 155
};
std::set<short> ex2b_choose = {
19, 50, 55, 56, 57, 58, 59, 60, 130,134,
135,136,139,144,154,-1, -1, -1, -1, -1
};
// These are maps from special node type to indices
// Those that map to index 0 are omitted, because if a key doesn't exist when fetched, it defaults to 0.
// TODO: Actually use the special node enum type here
std::map<short,short> edit_spec_stuff_done_mess = {
{1,1}, {2,1}, {6,1}, {22,3}, {23,1},
{50,1}, {51,1}, {52,1}, {53,1}, {54,1},
{55,1}, {56,1}, {57,1}, {58,1}, {59,1},
{60,1}, {61,1}, {62,1}, {63,1},
{130,1}, {134,1}, {155,1},
{200,2}, {201,2}, {202,2}, {203,2}, {204,2},
{205,2}, {206,2}, {207,2}, {208,2}, {209,2},
{210,7}, {211,8}, {212,4}, {214,5}, {215,6},
};
std::map<short,short> edit_spec_mess_mess = {
{1,1}, {2,1}, {3,1}, {5,1}, {6,1},
{11,1}, {12,1}, {17,1}, {18,1}, {19,1},
{20,1}, {25,1},
{50,1}, {51,1}, {54,1}, {55,4}, {56,4}, {57,4}, {58,5}, {59,5}, {60,5},
{61,1}, {62,1}, {63,1},
{80,1}, {81,1}, {82,1}, {83,1}, {84,1},
{85,1}, {86,1}, {87,1}, {88,1}, {89,1},
{90,1}, {91,1}, {92,1}, {93,1}, {94,1},
{95,1}, {96,1}, {97,1}, {98,1}, {99,1},
{100,1}, {101,1}, {102,1}, {103,1}, {104,1},
{105,1}, {106,1},
{170,1}, {171,1}, {172,1}, {173,1}, {174,1},
{175,1}, {176,1}, {177,1}, {178,1}, {179,1},
{180,1}, {181,1}, {182,1}, {183,1}, {188,2}, {189,2},
{190,2}, {191,1}, {192,1}, {193,1}, {194,1}, {195,1},
{200,1}, {201,1}, {202,1}, {203,1}, {204,1},
{205,1}, {206,1}, {207,1}, {208,1}, {209,1},
{210,1}, {211,1}, {212,1}, {213,1}, {214,1},
{215,1}, {216,1}, {217,1}, {218,1},
{226,1}, {227,1}, {228,1}, {229,3},
};
std::map<short,short> edit_pict_mess = {
{55,1}, {56,2}, {57,3}, {58,1}, {59,2}, {60,3},
{98,4}, {154,5}, {176,6}, {188,2}, {189,1},
};
std::map<short,short> edit_jumpto_mess = {
{7,1}, {8,1}, {9,1}, {10,1},
{55,4}, {56,4}, {57,4}, {63,2},
{130,3}, {131,3}, {132,3}, {133,3}, {134,3},
{135,3}, {136,3}, {137,3}, {138,3}, {139,3},
{140,3}, {141,3}, {142,3}, {143,3}, {144,3},
{145,3}, {146,3}, {147,3}, {148,3}, {149,3},
{150,3}, {151,3}, {152,3}, {153,3}, {154,3},
};
std::vector<pic_num_t> field_pics = {2,3,5,6,7,8,9,10,11,12,13,14,15,16,24,25,26,27,28,29,30,31};
std::vector<pic_num_t> boom_pics = {0,1,2,3,4,8,16,24,32};
std::vector<pic_num_t> lgdlog_pics = {0,72};
@@ -329,7 +267,7 @@ static bool save_spec_enc(cDialog& me, short which_mode, short which_node) {
store_spec_node.ex2b = me["x2b"].getTextAsNum();
store_spec_node.jumpto = me["jump"].getTextAsNum();
if (edit_spec_stuff_done_mess[store_spec_node.type] == 1) {
if((*store_spec_node.type).sdf_label == 1) {
if (cre(store_spec_node.sd1,-1,299,"The first part of a Stuff Done flag must be from 0 to 299 (or -1 if the Stuff Done flag is ignored.",
"",&me) > 0) return false;
if (cre(store_spec_node.sd2,-1,9,"The second part of a Stuff Done flag must be from 0 to 9 (or -1 if the Stuff Done flag is ignored.",
@@ -349,7 +287,7 @@ static void put_spec_enc_in_dlog(cDialog& me, short which_node) {
std::string str;
me["num"].setTextToNum(which_node);
str = get_str("special-node-names",store_spec_node.type + 1);
str = get_str("special-node-names",int(store_spec_node.type) + 1);
me["type"].setText(str);
if(last_node.empty())
@@ -358,7 +296,7 @@ static void put_spec_enc_in_dlog(cDialog& me, short which_node) {
me["sdf1"].setTextToNum(store_spec_node.sd1);
me["sdf2"].setTextToNum(store_spec_node.sd2);
switch (edit_spec_stuff_done_mess[store_spec_node.type]) {
switch((*store_spec_node.type).sdf_label) {
case 0:
me["sdf1-lbl"].setText("Unused.");
me["sdf2-lbl"].setText("Unused.");
@@ -399,7 +337,7 @@ static void put_spec_enc_in_dlog(cDialog& me, short which_node) {
me["msg1"].setTextToNum(store_spec_node.m1);
me["msg2"].setTextToNum(store_spec_node.m2);
switch (edit_spec_mess_mess[store_spec_node.type]) {
switch((*store_spec_node.type).msg_label) {
case 0:
me["msg1-lbl"].setText("Unused.");
me["msg2-lbl"].setText("Unused.");
@@ -439,7 +377,7 @@ static void put_spec_enc_in_dlog(cDialog& me, short which_node) {
}
me["pict"].setTextToNum(store_spec_node.pic);
switch (edit_pict_mess[store_spec_node.type]) {
switch((*store_spec_node.type).pic_label) {
case 0:
me["pict-lbl"].setText("Unused.");
me["pict-edit"].hide();
@@ -471,35 +409,35 @@ static void put_spec_enc_in_dlog(cDialog& me, short which_node) {
}
me["x1a"].setTextToNum(store_spec_node.ex1a);
str = get_str("special-x1a",store_spec_node.type + 1);
str = get_str("special-x1a",int(store_spec_node.type) + 1);
me["x1a-lbl"].setText(str);
if(ex1a_choose.count(store_spec_node.type) == 1)
if((*store_spec_node.type).ex1a_choose == 1)
me["x1a-edit"].show();
else me["x1a-edit"].hide();
me["x1b"].setTextToNum(store_spec_node.ex1b);
str = get_str("special-x1b",store_spec_node.type + 1);
str = get_str("special-x1b",int(store_spec_node.type) + 1);
me["x1b-lbl"].setText(str);
if(ex1b_choose.count(store_spec_node.type) == 1)
if((*store_spec_node.type).ex1b_choose == 1)
me["x1b-edit"].show();
else me["x1b-edit"].hide();
me["x2a"].setTextToNum(store_spec_node.ex2a);
str = get_str("special-x2a",store_spec_node.type + 1);
str = get_str("special-x2a",int(store_spec_node.type) + 1);
me["x2a-lbl"].setText(str);
if(ex2a_choose.count(store_spec_node.type) == 1)
if((*store_spec_node.type).ex2a_choose == 1)
me["x2a-edit"].show();
else me["x2a-edit"].hide();
me["x2b"].setTextToNum(store_spec_node.ex2b);
str = get_str("special-x2b",store_spec_node.type + 1);
str = get_str("special-x2b",int(store_spec_node.type) + 1);
me["x2b-lbl"].setText(str);
if(ex2b_choose.count(store_spec_node.type) == 1)
if((*store_spec_node.type).ex2b_choose == 1)
me["x2b-edit"].show();
else me["x2b-edit"].hide();
me["jump"].setTextToNum(store_spec_node.jumpto);
switch (edit_jumpto_mess[store_spec_node.type]) {
switch ((*store_spec_node.type).jmp_label) {
case 0:
me["jump-lbl"].setText("Special to Jump To");
break;
@@ -551,9 +489,9 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
spec = -1;
//CDSN(822,8,-1)
// TODO: Generalize this situation of a node jumping to a scenario node
if((item_hit == "x1b-edit") && (store_spec_node.type == 13))
if(item_hit == "x1b-edit" && store_spec_node.type == eSpecType::SCEN_TIMER_START)
spec = get_fresh_spec(0);
else if((item_hit == "jump-edit") && (store_spec_node.type == 21))
else if(item_hit == "jump-edit" && store_spec_node.type == eSpecType::CALL_GLOBAL)
spec = get_fresh_spec(0);
else spec = get_fresh_spec(which_mode);
if (spec < 0) {
@@ -578,24 +516,30 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
}
if(!save_spec_enc(me, which_mode, which_node))
return true;
if((item_hit == "x1b-edit") && (store_spec_node.type == 13))
if(item_hit == "x1b-edit" && store_spec_node.type == eSpecType::SCEN_TIMER_START)
node_to_change_to = spec;
else if((item_hit == "jump-edit") && (store_spec_node.type == 21))
else if(item_hit == "jump-edit" && store_spec_node.type == eSpecType::CALL_GLOBAL)
node_to_change_to = spec;
else node_to_change_to = which_mode * 1000 + spec;
last_node.push(which_mode * 1000 + which_node);
} else if(item_hit == "x1a-edit") {
switch (store_spec_node.type) {
case 19: case 50: case 58: case 59: case 60:
case eSpecType::FORCED_GIVE:
case eSpecType::ONCE_GIVE_ITEM:
case eSpecType::ONCE_GIVE_ITEM_DIALOG:
case eSpecType::ONCE_GIVE_ITEM_TERRAIN:
case eSpecType::ONCE_GIVE_ITEM_MONSTER:
i = choose_text(STRT_ITEM,store_spec_node.ex1a,&me,"Give which item?");
break;
case 229:
case eSpecType::OUT_STORE:
i = choose_text(STRT_ITEM,store_spec_node.ex1a,&me,"First item in store?");
break;
case 55: case 56: case 57:
case eSpecType::ONCE_DIALOG:
case eSpecType::ONCE_DIALOG_TERRAIN:
case eSpecType::ONCE_DIALOG_MONSTER:
i = choose_text(STRT_BUTTON,store_spec_node.ex1a,&me,"Which button label?");
break;
case 182:
case eSpecType::TOWN_DESTROY_MONST:
i = choose_text(STRT_MONST,store_spec_node.ex1a,&me,"Choose Which Monster:");
break;
}
@@ -603,16 +547,28 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
me["x1a"].setTextToNum(store_spec_node.ex1a);
} else if(item_hit == "x2a-edit") {
switch (store_spec_node.type) {
case 19: case 50: case 192: case 229:
case eSpecType::FORCED_GIVE:
case eSpecType::ONCE_GIVE_ITEM:
case eSpecType::TOWN_PLACE_ITEM:
case eSpecType::OUT_STORE: // TODO: This isn't right - it should be "number of items" or some such
i = choose_text(STRT_ITEM,store_spec_node.ex2a,&me,"Give which item?");
break;
case 55: case 56: case 57: case 58: case 59: case 60:
case eSpecType::ONCE_DIALOG:
case eSpecType::ONCE_DIALOG_TERRAIN:
case eSpecType::ONCE_DIALOG_MONSTER:
case eSpecType::ONCE_GIVE_ITEM_DIALOG:
case eSpecType::ONCE_GIVE_ITEM_TERRAIN:
case eSpecType::ONCE_GIVE_ITEM_MONSTER:
i = choose_text(STRT_BUTTON,store_spec_node.ex2a,&me,"Which button label?");
break;
case 181:
case eSpecType::TOWN_PLACE_MONST:
i = choose_text(STRT_MONST,store_spec_node.ex2a,&me,"Choose Which Monster:");
break;
case 135: case 136: case 171: case 172: case 226:
case eSpecType::IF_TOWN_TER_TYPE:
case eSpecType::IF_OUT_TER_TYPE:
case eSpecType::TOWN_CHANGE_TER:
case eSpecType::TOWN_SWAP_TER:
case eSpecType::OUT_CHANGE_TER:
i = choose_text(STRT_TER,store_spec_node.ex2a,&me,"Which Terrain?");
break;
}
@@ -621,14 +577,14 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
} else if(item_hit == "msg2-edit") { // TODO: What about msg1-edit?
if(save_spec_enc(me, which_mode, which_node))
return true;
if ((edit_spec_mess_mess[store_spec_node.type] == 2) ||
(edit_spec_mess_mess[store_spec_node.type] == 4) ||
(edit_spec_mess_mess[store_spec_node.type] == 5)) {
if (((*store_spec_node.type).msg_label == 2) ||
((*store_spec_node.type).msg_label == 4) ||
((*store_spec_node.type).msg_label == 5)) {
edit_dialog_text(which_mode,&store_spec_node.m1,&me);
put_spec_enc_in_dlog(me, which_node);
}
else if ((edit_spec_mess_mess[store_spec_node.type] == 1) ||
(edit_spec_mess_mess[store_spec_node.type] == 3)) {
else if (((*store_spec_node.type).msg_label == 1) ||
((*store_spec_node.type).msg_label == 3)) {
edit_spec_text(which_mode,&store_spec_node.m1,
&store_spec_node.m2,&me);
put_spec_enc_in_dlog(me, which_node);
@@ -637,7 +593,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
if(save_spec_enc(me, which_mode, which_node))
return true;
i = -1;
switch (edit_pict_mess[store_spec_node.type]) {
switch ((*store_spec_node.type).pic_label) {
case 1:
i = choose_graphic(store_spec_node.pic,PIC_DLOG,&me);
break;
@@ -655,48 +611,49 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short&
} else if(item_hit == "general") {
if(save_spec_enc(me, which_mode, which_node) == true)
return true;
i = choose_text_res("special-node-names",1,28,store_spec_node.type + 1,&me,"Choose General Use Special:");
// TODO: I wonder if this can all be achieved without casts... if not, at least check getNodeCategory to ensure validity.
i = choose_text_res("special-node-names",1,28,int(store_spec_node.type) + 1,&me,"Choose General Use Special:");
if (i >= 0) {
store_spec_node.type = i - 1;
store_spec_node.type = eSpecType(i - 1);
}
put_spec_enc_in_dlog(me, which_node);
} else if(item_hit == "oneshot") {
if(save_spec_enc(me, which_mode, which_node))
return true;
i = choose_text_res("special-node-names",51,64,store_spec_node.type + 1,&me,"Choose One-Shot Special:");
i = choose_text_res("special-node-names",51,64,int(store_spec_node.type) + 1,&me,"Choose One-Shot Special:");
if (i >= 0) {
store_spec_node.type = i - 1;
store_spec_node.type = eSpecType(i - 1);
store_spec_node.sd1 = -1;
store_spec_node.sd2 = -1;
if ((store_spec_node.type >= 55) && (store_spec_node.type <= 57))
if(store_spec_node.type == eSpecType::ONCE_DIALOG || store_spec_node.type == eSpecType::ONCE_DIALOG_TERRAIN || store_spec_node.type == eSpecType::ONCE_DIALOG_MONSTER)
store_spec_node.m2 = 1;
}
put_spec_enc_in_dlog(me, which_node);
} else if(item_hit == "affectpc") {
if(save_spec_enc(me, which_mode, which_node))
return true;
i = choose_text_res("special-node-names",81,107,store_spec_node.type + 1,&me,"Choose Affect Party Special:");
if (i >= 0) store_spec_node.type = i - 1;
i = choose_text_res("special-node-names",81,107,int(store_spec_node.type) + 1,&me,"Choose Affect Party Special:");
if (i >= 0) store_spec_node.type = eSpecType(i - 1);
put_spec_enc_in_dlog(me, which_node);
} else if(item_hit == "ifthen") {
if(save_spec_enc(me, which_mode, which_node))
return true;
i = choose_text_res("special-node-names",131,156,store_spec_node.type + 1,&me,"Choose If-Then Special:");
i = choose_text_res("special-node-names",131,156,int(store_spec_node.type) + 1,&me,"Choose If-Then Special:");
if (i >= 0) {
store_spec_node.type = i - 1;
store_spec_node.type = eSpecType(i - 1);
}
put_spec_enc_in_dlog(me, which_node);
} else if(item_hit == "town") {
if(save_spec_enc(me, which_mode, which_node))
return true;
i = choose_text_res("special-node-names",171,219,store_spec_node.type + 1,&me,"Choose Town Special:");
if (i >= 0) store_spec_node.type = i - 1;
i = choose_text_res("special-node-names",171,219,int(store_spec_node.type) + 1,&me,"Choose Town Special:");
if (i >= 0) store_spec_node.type = eSpecType(i - 1);
put_spec_enc_in_dlog(me, which_node);
} else if(item_hit == "out") {
if(save_spec_enc(me, which_mode, which_node))
return true;
i = choose_text_res("special-node-names",226,230,store_spec_node.type + 1,&me,"Choose Outdoor Special:");
if (i >= 0) store_spec_node.type = i - 1;
i = choose_text_res("special-node-names",226,230,int(store_spec_node.type) + 1,&me,"Choose Outdoor Special:");
if (i >= 0) store_spec_node.type = eSpecType(i - 1);
put_spec_enc_in_dlog(me, which_node);
}
/*if ((item_hit >= 37) && (item_hit <= 42)) {
@@ -762,7 +719,7 @@ short get_fresh_spec(short which_mode) {
store_node = current_terrain.specials[i];
if (which_mode == 2)
store_node = town->specials[i];
if ((store_node.type == 0) && (store_node.jumpto == -1) && (store_node.pic == -1))
if(store_node.type == eSpecType::NONE && store_node.jumpto == -1 && store_node.pic == -1)
return i;
}