Rearrange the basic_buttons array to avoid the extra indirection step

- All buttons from the array that were strictly related to UI have been removed.
- Some new buttons have been added. The duplicate Leave button has been removed.
This commit is contained in:
2015-10-04 21:11:16 -04:00
parent f8deb48edb
commit cae5fc3140
8 changed files with 52 additions and 141 deletions

View File

@@ -618,7 +618,7 @@ the Jump To node.
<dt>Stuff done 1, Stuff done 2:</dt><dd>As usual.</dd>
<dt>Mess1, Mess2:</dt><dd>Standard usage.</dd></dd>
<dt>Type 55: Display Dialog (Dialog pic)</dt><dd>This very important special node displays
<dt>Type 55: Display Dialog</dt><dd>This very important special node displays
a dialog box with up to six text messages and a dialog picture (which you choose) in the
upper left. The lower right hand corner can have 1 to 3 buttons. The player must press a
button, at which point another special node will be called. You choose a special node to
@@ -656,7 +656,7 @@ want the text of a book to come up when the party looks at a certain bookshelf,
probably want the same text to keep coming up when the look at the bookshelf later
on.</dd></dd>
<dt>Type 58: Give Item (Dialog pic)</dt><dd>Displays a dialog box with up to six text
<dt>Type 58: Give Item Dialog</dt><dd>Displays a dialog box with up to six text
messages and a dialog picture (which you choose) in the upper left. At the lower right
hand corner are two buttons: Take and Leave. If take is pressed, the party is given an
item (if the item can be carried). If the item is taken, the Stuff Done flag is set to

View File

@@ -615,7 +615,7 @@ short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicTy
std::string item_hit = customDialog.show();
for(int i = 0; i < 3; i++) {
auto& btn = basic_buttons[available_btns[buttons[i]]];
auto& btn = basic_buttons[buttons[i]];
if(item_hit == btn.label)
return i + 1;
}

View File

@@ -171,6 +171,12 @@ void cSpecial::append(legacy::special_node_type& old){
if(old.type == 55) type = eSpecType::ONCE_DIALOG;
else if(old.type == 58) type = eSpecType::ONCE_GIVE_ITEM_DIALOG;
else type = eSpecType::TOWN_PORTAL;
if(type == eSpecType::TOWN_PORTAL) break;
// Duplicate Leave button
if(old.ex1a == 20)
ex1a = 9;
if(old.ex2a == 20)
ex2a = 9;
break;
case 57: case 60: // Large dialogs with monster graphics
if(pic >= 400 && pic < 1000)
@@ -181,6 +187,11 @@ void cSpecial::append(legacy::special_node_type& old){
m2 = -1;
if(old.type == 57) type = eSpecType::ONCE_DIALOG;
else if(old.type == 60) type = eSpecType::ONCE_GIVE_ITEM_DIALOG;
// Duplicate Leave button
if(old.ex1a == 20)
ex1a = 9;
if(old.ex2a == 20)
ex2a = 9;
break;
case 56: case 59: case 188: // Large dialogs with terrain graphics
pictype = PIC_TER;
@@ -189,6 +200,12 @@ void cSpecial::append(legacy::special_node_type& old){
if(old.type == 56) type = eSpecType::ONCE_DIALOG;
else if(old.type == 59) type = eSpecType::ONCE_GIVE_ITEM_DIALOG;
else type = eSpecType::TOWN_LEVER;
if(type == eSpecType::TOWN_LEVER) break;
// Duplicate Leave button
if(old.ex1a == 20)
ex1a = 9;
if(old.ex2a == 20)
ex2a = 9;
break;
case 190: // Large stairway dialog
type = eSpecType::TOWN_STAIR;

View File

@@ -9,29 +9,18 @@
/// @file
/// Preset button specifications for cThreeChoice
/// The buttons available to special nodes; consists of indices into the basic_buttons array.
size_t available_btns[53] = {
0, 63, 64, 65, 1, 4, 5, 8, 128,9,
10, 11, 12, 13, 14, 15, 16, 17, 29, 51,
60, 61, 62, 66, 69, 70, 71, 72, 73, 74,
79, 80, 83, 86, 87, 88, 91, 92, 93, 99,
100,101,102,104,129,130,131,132,133,134,
135,136,137
};
/// A list of preset button types. Many of these are unused.
bbtt basic_buttons[] = {
{BTN_DONE, " ", {false,key_enter,mod_none}}, // Formerly DLG_BTN_REG with "Done " as the string
/// A list of preset button types.
bbtt basic_buttons[71] = {
{BTN_DONE, " ", {false,key_enter,mod_none}, "Done"},
{BTN_REG, "OK", {false,key_enter,mod_none}},
{BTN_REG, "Yes", {false,'y',mod_none}},
{BTN_REG, "No", {false,'n',mod_none}},
{BTN_REG, "Ask", {false,0,mod_none}},
{BTN_LEFT, " ", {true,key_left,mod_none}},
{BTN_RIGHT, " ", {true,key_right,mod_none}},
{BTN_REG, "Keep", {false,'k',mod_none}},
{BTN_REG, "Cancel", {true,key_esc,mod_none}},
{BTN_SM, "+", {false,0,mod_none}},
{BTN_SM, "-", {false,0,mod_none}},
{BTN_REG, "Buy", {false,0,mod_none}},
{BTN_REG, "Enter", {false,0,mod_none}},
{BTN_REG, "Leave", {false,key_enter,mod_none}},
//10
{BTN_REG, "Get", {false,'g',mod_none}},
{BTN_REG, "1", {false,'1',mod_none}},
{BTN_REG, "2", {false,'2',mod_none}},
@@ -40,130 +29,33 @@ bbtt basic_buttons[] = {
{BTN_REG, "5", {false,'5',mod_none}},
{BTN_REG, "6", {false,'6',mod_none}},
{BTN_REG, "Cast", {false,0,mod_none}},
{BTN_TINY, " ", {false,0,mod_none}},
{BTN_TINY, " ", {false,0,mod_none}},
//20
{BTN_TINY, " ", {false,0,mod_none}},
{BTN_TINY, " ", {false,0,mod_none}},
{BTN_TINY, " ", {false,0,mod_none}},
{BTN_REG, "Buy", {false,0,mod_none}},
{BTN_REG, "Sell", {false,0,mod_none}},
{BTN_LG, "Other Spells", {false,' ',mod_none}},
{BTN_REG, "Buy x10", {false,0,mod_none}},
{BTN_UP, " ", {true,key_up,mod_none}},
{BTN_DOWN, " ", {true,key_down,mod_none}},
{BTN_REG, "Save", {false,0,mod_none}},
//30
{BTN_REG, "Race", {false,0,mod_none}},
{BTN_TALL, "Train", {false,0,mod_none}},
{BTN_REG, "Items", {false,0,mod_none}},
{BTN_REG, "Spells", {false,0,mod_none}},
{BTN_LG, "Heal Party", {false,0,mod_none}},
{BTN_SM, "1", {false,'1',mod_none}},
{BTN_SM, "2", {false,'2',mod_none}},
{BTN_SM, "3", {false,'3',mod_none}},
{BTN_SM, "4", {false,'4',mod_none}},
{BTN_SM, "5", {false,'5',mod_none}},
//40
{BTN_SM, "6", {false,'6',mod_none}},
{BTN_SM, "7", {false,'7',mod_none}},
{BTN_SM, "8", {false,'8',mod_none}},
{BTN_SM, "9", {false,'9',mod_none}},
{BTN_SM, "10", {false,'a',mod_none}},
{BTN_SM, "11", {false,'b',mod_none}},
{BTN_SM, "12", {false,'c',mod_none}},
{BTN_SM, "13", {false,'d',mod_none}},
{BTN_SM, "14", {false,'e',mod_none}},
{BTN_SM, "15", {false,'f',mod_none}},
//50
{BTN_SM, "16", {false,'g',mod_none}},
{BTN_REG, "Take", {false,0,mod_none}},
{BTN_REG, "Create", {false,0,mod_none}},
{BTN_REG, "Delete", {false,0,mod_none}},
{BTN_LG, "Race/Special", {false,0,mod_none}},
{BTN_REG, "Skill", {false,0,mod_none}},
{BTN_REG, "Name", {false,0,mod_none}},
{BTN_REG, "Graphic", {false,0,mod_none}},
{BTN_LG, "Bash Door", {false,0,mod_none}},
{BTN_LG, "Pick Lock", {false,0,mod_none}},
//60
{BTN_REG, "Leave", {false,key_enter,mod_none}}, // dupe
{BTN_REG, "Stay", {false,key_enter,mod_none}},
{BTN_REG, "Steal", {false,0,mod_none}},
{BTN_REG, "Attack", {false,0,mod_none}},
{BTN_REG, "OK", {false,key_enter,mod_none}},
{BTN_REG, "Yes", {false,'y',mod_none}},
{BTN_REG, "No", {false,'n',mod_none}},
{BTN_LG, "Step In", {false,0,mod_none}},
{BTN_HELP, " ", {false,'?',mod_none}},
{BTN_REG, "Record", {false,'r',mod_none}},
{BTN_REG, "Climb", {false,0,mod_none}},
//70
{BTN_REG, "Flee", {false,0,mod_none}},
{BTN_REG, "Onward", {false,0,mod_none}},
{BTN_REG, "Answer", {false,0,mod_none}},
{BTN_REG, "Drink", {false,0,mod_none}},
{BTN_LG, "Approach", {false,0,mod_none}},
{BTN_LG, "Mage Spells", {false,0,mod_none}},
{BTN_LG, "Priest Spells", {false,0,mod_none}},
{BTN_LG, "Advantages", {false,0,mod_none}},
{BTN_LG, "New Game", {false,0,mod_none}},
{BTN_REG, "Land", {false,0,mod_none}},
//80
{BTN_REG, "Under", {false,0,mod_none}},
{BTN_REG, "Restore", {false,0,mod_none}},
{BTN_REG, "Restart", {false,0,mod_none}},
{BTN_REG, "Quit", {false,0,mod_none}},
{BTN_LG, "Save First", {false,0,mod_none}},
{BTN_LG, "Just Quit", {false,0,mod_none}},
{BTN_REG, "Rest", {false,0,mod_none}},
{BTN_REG, "Read", {false,0,mod_none}},
{BTN_REG, "Pull", {false,0,mod_none}},
{BTN_LG, "Alchemy", {false,0,mod_none}},
//90
{BTN_SM, "17", {false,'g',mod_none}},
{BTN_REG, "Push", {false,0,mod_none}},
{BTN_REG, "Pray", {false,0,mod_none}},
{BTN_REG, "Wait", {false,0,mod_none}},
{BTN_PUSH, "", {false,0,mod_none}},
{BTN_TRAIT, "", {false,0,mod_none}},
{BTN_TALL, "Delete", {false,0,mod_none}},
{BTN_TALL, "Graphic", {false,0,mod_none}},
{BTN_TALL, "Create", {false,0,mod_none}},
{BTN_REG, "Give", {false,0,mod_none}},
//100
{BTN_REG, "Destroy", {false,0,mod_none}},
{BTN_REG, "Pay", {false,0,mod_none}},
{BTN_REG, "Free", {false,0,mod_none}},
{BTN_LG, "Next Tip", {false,0,mod_none}},
{BTN_REG, "Touch", {false,0,mod_none}},
{BTN_LG, "Select Icon", {false,0,mod_none}},
{BTN_LG, "Create/Edit", {false,0,mod_none}},
{BTN_LG, "Clear Special", {false,0,mod_none}},
{BTN_LG, "Edit Abilities", {false,0,mod_none}},
{BTN_REG, "Choose", {false,0,mod_none}},
//110
{BTN_LG, "Go Back", {false,0,mod_none}},
{BTN_LG, "Create New", {false,0,mod_none}},
{BTN_LG, "General", {false,0,mod_none}},
{BTN_LG, "One Shots", {false,0,mod_none}},
{BTN_LG, "Affect PCs", {false,0,mod_none}},
{BTN_LG, "If-Thens", {false,0,mod_none}},
{BTN_LG, "Town Specs", {false,0,mod_none}},
{BTN_LG, "Out Specs", {false,0,mod_none}},
{BTN_LG, "Advanced", {false,0,mod_none}},
{BTN_LG, "Weapon Abil", {false,0,mod_none}},
//120
{BTN_LG, "General Abil.", {false,0,mod_none}},
{BTN_LG, "NonSpell Use", {false,0,mod_none}},
{BTN_LG, "Spell Usable", {false,0,mod_none}},
{BTN_LG, "Reagents", {false,0,mod_none}},
{BTN_LG, "Missiles", {false,0,mod_none}},
{BTN_LG, "Abilities", {false,0,mod_none}},
{BTN_LG, "Pick Picture", {false,0,mod_none}},
{BTN_LG, "Animated", {false,0,mod_none}},
{BTN_REG, "Enter", {false,0,mod_none}},
{BTN_REG, "Burn", {false,0,mod_none}},
//130
{BTN_REG, "Insert", {false,0,mod_none}},
{BTN_REG, "Remove", {false,0,mod_none}},
{BTN_REG, "Accept", {false,0,mod_none}},
@@ -172,20 +64,22 @@ bbtt basic_buttons[] = {
{BTN_REG, "Close", {false,0,mod_none}},
{BTN_REG, "Sit", {false,0,mod_none}},
{BTN_REG, "Stand", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
//140
{BTN_SM, "18", {false,0,mod_none}},
{BTN_SM, "19", {false,0,mod_none}},
{BTN_SM, "20", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}}, // invisible button; text was "Invisible!"
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
{BTN_SM, "", {false,0,mod_none}},
//150
{BTN_LG, "Open File", {false,0,mod_none}},
{BTN_SM, " ", {false,0,mod_none}},
{BTN_LEFT, " ", {true,key_left,mod_none}, "Left Arrow"},
{BTN_RIGHT, " ", {true,key_right,mod_none}, "Right Arrow"},
{BTN_UP, " ", {true,key_up,mod_none}, "Up Arrow"},
{BTN_DOWN, " ", {true,key_down,mod_none}, "Down Arrow"},
{BTN_REG, "Sell", {false,0,mod_none}},
{BTN_REG, "Identify", {false,0,mod_none}},
{BTN_REG, "Enchant", {false,0,mod_none}},
{BTN_REG, "Train", {false,0,mod_none}},
{BTN_LG, "Heal Party", {false,0,mod_none}},
{BTN_LG, "Bash Door", {false,0,mod_none}},
{BTN_LG, "Pick Lock", {false,0,mod_none}},
{BTN_REG, "Record", {false,'r',mod_none}},
{BTN_REG, "Climb", {false,0,mod_none}},
{BTN_REG, "Restore", {false,0,mod_none}},
{BTN_REG, "Restart", {false,0,mod_none}},
{BTN_REG, "Create", {false,0,mod_none}},
{BTN_REG, "Choose", {false,0,mod_none}},
{BTN_LG, "Go Back", {false,0,mod_none}},
};

View File

@@ -343,7 +343,7 @@ cThreeChoice::cThreeChoice
int i = 0;
for(short j : buttons) {
if(j < 0) buttonDefs[i++] = null_btn;
else buttonDefs[i++] = basic_buttons[available_btns[j]];
else buttonDefs[i++] = basic_buttons[j];
}
init_buttons(buttonDefs[0], buttonDefs[1], buttonDefs[2]);
init_pict(pic);

View File

@@ -103,6 +103,7 @@ struct bbtt {
eBtnType type; ///< The type of the preset button.
std::string label; ///< The preset button's label, if any.
cKey defaultKey; ///< The preset button's default key shortcut, if any.
std::string name; ///< (optional) A more descriptive name for the button.
};
/// Represents a preset button for use with cThreeChoice.
@@ -110,8 +111,7 @@ typedef boost::optional<bbtt> cBasicButtonType;
namespace {cBasicButtonType null_btn = boost::none;}
#ifndef BTNS_DEFINED
extern bbtt basic_buttons[];
extern size_t available_btns[53];
extern bbtt basic_buttons[71];
#endif
/// A choice dialog with several strings and up to three buttons.

View File

@@ -221,7 +221,7 @@ bool pick_string(std::string from_file, cDialog& parent, std::string result_fld,
static bool show_help(std::string from_file, cDialog& parent, pic_num_t pic){
StringRsrc strings = *ResMgr::get<StringRsrc>(from_file);
cThreeChoice help(strings,basic_buttons[63],pic,PIC_DLOG,&parent);
cThreeChoice help(strings,basic_buttons[1],pic,PIC_DLOG,&parent);
help.show();
return true;
}

View File

@@ -354,8 +354,8 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, std
strings = *ResMgr::get<StringRsrc>("shop-specials");
break;
case STRT_BUTTON:
for(int btn : available_btns) {
strings.push_back(basic_buttons[btn].label);
for(auto btn : basic_buttons) {
strings.push_back(btn.name.empty() ? btn.label : btn.name);
}
break;
case STRT_CMP: