Refactor mode integer for select_pc (see calref#699)
This commit is contained in:
@@ -864,7 +864,7 @@ void handle_bash_pick(location destination, bool& did_something, bool& need_redr
|
||||
else if(!is_unlockable(destination))
|
||||
add_string_to_buf(" Wrong terrain type.");
|
||||
else {
|
||||
short pc = select_pc(0, isBash ? "Who will bash?" : "Who will pick the lock?");
|
||||
short pc = select_pc(eSelectPC::ONLY_LIVING, isBash ? "Who will bash?" : "Who will pick the lock?");
|
||||
if(pc == 6) {
|
||||
add_string_to_buf(" Cancelled.");
|
||||
overall_mode = MODE_TOWN;
|
||||
@@ -1904,12 +1904,12 @@ void handle_menu_spell(eSpell spell_picked) {
|
||||
store_mage = spell_picked;
|
||||
else store_priest = spell_picked;
|
||||
if(spell_type == eSkill::MAGE_SPELLS && (*spell_picked).need_select != SELECT_NO) {
|
||||
if((store_spell_target = select_pc((*spell_picked).need_select == SELECT_ANY ? 1 : 0,"Cast spell on who?")) == 6)
|
||||
if((store_spell_target = select_pc((*spell_picked).need_select == SELECT_ANY ? eSelectPC::ANY : eSelectPC::ONLY_LIVING,"Cast spell on who?")) == 6)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(spell_type == eSkill::PRIEST_SPELLS && (*spell_picked).need_select != SELECT_NO)
|
||||
if((store_spell_target = select_pc((*spell_picked).need_select == SELECT_ANY ? 1 : 0,"Cast spell on who?")) == 6)
|
||||
if((store_spell_target = select_pc((*spell_picked).need_select == SELECT_ANY ? eSelectPC::ANY : eSelectPC::ONLY_LIVING,"Cast spell on who?")) == 6)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2149,7 +2149,7 @@ void debug_kill_party() {
|
||||
size_t choice = cStringChoice({"Dead", "Dust", "Stone"}, "Kill how?").show(-1);
|
||||
if(choice == -1) return;
|
||||
eMainStatus death_type = static_cast<eMainStatus>(static_cast<size_t>(eMainStatus::DEAD) + choice);
|
||||
short pc = select_pc(0, "Kill who?", true);
|
||||
short pc = select_pc(eSelectPC::ONLY_LIVING, "Kill who?", true);
|
||||
if(pc == 6) return;
|
||||
for(int i = 0; i < 6; ++i){
|
||||
if(i == pc || (univ.party[i].is_alive() && pc == 7)) {
|
||||
@@ -2177,7 +2177,7 @@ void debug_hurt_party() {
|
||||
record_action("debug_hurt_party", "");
|
||||
}
|
||||
|
||||
short pc = select_pc(0, "Hurt who?", true);
|
||||
short pc = select_pc(eSelectPC::ONLY_LIVING, "Hurt who?", true);
|
||||
if(pc == 6) return;
|
||||
for(int i = 0; i < 6; ++i){
|
||||
if(i == pc || (univ.party[i].is_alive() && pc == 7)) {
|
||||
@@ -2216,7 +2216,7 @@ void debug_give_status() {
|
||||
}
|
||||
}
|
||||
|
||||
short pc = select_pc(0, "Give status to who?", true);
|
||||
short pc = select_pc(eSelectPC::ONLY_LIVING, "Give status to who?", true);
|
||||
if(pc == 6) return;
|
||||
for(int i = 0; i < 6; ++i){
|
||||
if(i == pc || (univ.party[i].is_alive() && pc == 7)) {
|
||||
@@ -3445,7 +3445,7 @@ void handle_drop_pc() {
|
||||
}else if(is_combat()){
|
||||
add_string_to_buf("Delete PC: Not in combat.");
|
||||
}else{
|
||||
int choice = select_pc(1,"Delete who?");
|
||||
int choice = select_pc(eSelectPC::ANY,"Delete who?");
|
||||
if(choice < 6) {
|
||||
std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show();
|
||||
if(confirm == "no"){
|
||||
@@ -4122,7 +4122,7 @@ void handle_new_pc_graphic() {
|
||||
if(recording){
|
||||
record_action("handle_new_pc_graphic", "");
|
||||
}
|
||||
short choice = select_pc(1,"New graphic for who?");
|
||||
short choice = select_pc(eSelectPC::ANY,"New graphic for who?");
|
||||
if(choice < 6)
|
||||
pick_pc_graphic(choice,1,nullptr);
|
||||
draw_terrain();
|
||||
@@ -4132,7 +4132,7 @@ void handle_rename_pc() {
|
||||
if(recording){
|
||||
record_action("handle_rename_pc", "");
|
||||
}
|
||||
short choice = select_pc(1,"Rename who?");
|
||||
short choice = select_pc(eSelectPC::ANY,"Rename who?");
|
||||
if(choice < 6)
|
||||
pick_pc_name(choice,nullptr);
|
||||
put_pc_screen();
|
||||
|
@@ -4585,7 +4585,6 @@ void combat_immed_mage_cast(short current_pc, eSpell spell_num, bool freebie) {
|
||||
break;
|
||||
|
||||
case eSpell::HASTE_MINOR: case eSpell::HASTE: case eSpell::STRENGTH: case eSpell::ENVENOM: case eSpell::RESIST_MAGIC:
|
||||
// target = select_pc(11,0);
|
||||
target = store_spell_target;
|
||||
if(target < 6) {
|
||||
cPlayer& target_pc = univ.party[target];
|
||||
|
@@ -936,7 +936,7 @@ void handle_talk_node(int which_talk_entry) {
|
||||
save_talk_str2 = "";
|
||||
break;
|
||||
case eTalkNode::TRAINING:
|
||||
if((get_pc = select_pc(0,"Train who?")) < 6) {
|
||||
if((get_pc = select_pc(eSelectPC::ONLY_LIVING,"Train who?")) < 6) {
|
||||
can_save_talk = false;
|
||||
spend_xp(get_pc,1, nullptr);
|
||||
}
|
||||
|
@@ -190,7 +190,7 @@ void give_thing(short pc_num, short item_num) {
|
||||
add_string_to_buf("Give: Item is cursed.");
|
||||
else {
|
||||
item_store = univ.party[pc_num].items[item_num];
|
||||
who_to = select_pc(3,"Give item to who?");
|
||||
who_to = select_pc(eSelectPC::ONLY_LIVING_WITH_ITEM_SLOT,"Give item to who?");
|
||||
if((overall_mode == MODE_COMBAT) && !adjacent(univ.party[pc_num].combat_pos,univ.party[who_to].combat_pos)) {
|
||||
add_string_to_buf("Give: Must be adjacent.");
|
||||
who_to = 6;
|
||||
@@ -921,9 +921,7 @@ static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod)
|
||||
return true;
|
||||
}
|
||||
|
||||
// mode determines which PCs can be picked
|
||||
// 0 - only living pcs, 1 - any pc, 2 - only dead pcs, 3 - only living pcs with inventory space
|
||||
short select_pc(short mode, std::string title, bool allow_choose_all) {
|
||||
short select_pc(eSelectPC mode, std::string title, bool allow_choose_all) {
|
||||
short item_hit;
|
||||
|
||||
set_cursor(sword_curs);
|
||||
@@ -941,18 +939,21 @@ short select_pc(short mode, std::string title, bool allow_choose_all) {
|
||||
if(univ.party[i].main_status == eMainStatus::ABSENT || univ.party[i].main_status == eMainStatus::FLED)
|
||||
can_pick = false;
|
||||
else switch(mode) {
|
||||
case 3:
|
||||
case eSelectPC::ONLY_LIVING_WITH_ITEM_SLOT:
|
||||
if(!univ.party[i].has_space())
|
||||
can_pick = false;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 0:
|
||||
case eSelectPC::ONLY_LIVING:
|
||||
if(univ.party[i].main_status != eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
break;
|
||||
case 2:
|
||||
case eSelectPC::ONLY_DEAD:
|
||||
if(univ.party[i].main_status == eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
break;
|
||||
// Suppress a compiler warning:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!can_pick) {
|
||||
selectPc["pick" + n].hide();
|
||||
|
@@ -41,5 +41,11 @@ std::string get_text_response(std::string prompt = "", pic_num_t pic = 16);
|
||||
// Specify cancel_value to show a cancel button, which will return the given value (for example, -1)
|
||||
short get_num_response(short min, short max, std::string prompt, std::vector<std::string> choice_names = {}, boost::optional<short> cancel_value = boost::none);
|
||||
|
||||
enum class eSelectPC {
|
||||
ONLY_LIVING,
|
||||
ANY,
|
||||
ONLY_DEAD,
|
||||
ONLY_LIVING_WITH_ITEM_SLOT
|
||||
};
|
||||
// Prompt the player to choose a party member. Returns 0-5 for a pc, 6 for cancel, or 7 for all.
|
||||
short select_pc(short mode, std::string title="", bool allow_choose_all = false);
|
||||
short select_pc(eSelectPC mode, std::string title="", bool allow_choose_all = false);
|
||||
|
@@ -993,7 +993,6 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
case eSpell::HEAL_MINOR: case eSpell::HEAL: case eSpell::HEAL_MAJOR:
|
||||
case eSpell::POISON_WEAKEN: case eSpell::POISON_CURE: case eSpell::DISEASE_CURE:
|
||||
case eSpell::RESTORE_MIND: case eSpell::CLEANSE: case eSpell::AWAKEN: case eSpell::PARALYSIS_CURE:
|
||||
// target = select_pc(11,0);
|
||||
target = store_spell_target;
|
||||
if(target < 6) {
|
||||
if(!freebie)
|
||||
@@ -2120,7 +2119,7 @@ void do_alchemy() {
|
||||
short r1;
|
||||
short pc_num;
|
||||
|
||||
pc_num = select_pc(0);
|
||||
pc_num = select_pc(eSelectPC::ONLY_LIVING);
|
||||
if(pc_num == 6)
|
||||
return;
|
||||
|
||||
|
@@ -481,7 +481,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
can_enter = false;
|
||||
if(choice == "leave")
|
||||
break;
|
||||
if((door_pc = select_pc(0)) < 6) {
|
||||
if((door_pc = select_pc(eSelectPC::ONLY_LIVING)) < 6) {
|
||||
if(choice == "pick")
|
||||
pick_lock(where_check,door_pc);
|
||||
else bash_door(where_check,door_pc);
|
||||
@@ -1115,8 +1115,8 @@ void use_item(short pc,short item) {
|
||||
}
|
||||
switch((*spell).need_select) {
|
||||
case SELECT_NO: break;
|
||||
case SELECT_ACTIVE: store_spell_target = select_pc(0); break;
|
||||
case SELECT_ANY: store_spell_target = select_pc(1); break;
|
||||
case SELECT_ACTIVE: store_spell_target = select_pc(eSelectPC::ONLY_LIVING); break;
|
||||
case SELECT_ANY: store_spell_target = select_pc(eSelectPC::ANY); break;
|
||||
}
|
||||
if(overall_mode == MODE_COMBAT) {
|
||||
bool priest = (*spell).is_priest();
|
||||
@@ -2649,7 +2649,7 @@ void oneshot_spec(const runtime_state& ctx) {
|
||||
*ctx.ret_a = 1;
|
||||
} else {
|
||||
if(!is_combat()) {
|
||||
dlg_res = select_pc(0,"Trap! Who will disarm?");
|
||||
dlg_res = select_pc(eSelectPC::ONLY_LIVING,"Trap! Who will disarm?");
|
||||
if(dlg_res == 6){
|
||||
*ctx.ret_a = 1;
|
||||
set_sd = false;
|
||||
@@ -2699,22 +2699,22 @@ void affect_spec(const runtime_state& ctx) {
|
||||
if(spec.ex1a == 2)
|
||||
ctx.cur_target = &univ.party;
|
||||
else if(spec.ex1a == 1) {
|
||||
i = select_pc(0);
|
||||
i = select_pc(eSelectPC::ONLY_LIVING);
|
||||
if(i != 6)
|
||||
ctx.cur_target = &univ.party[i];
|
||||
}
|
||||
else if(spec.ex1a == 0) {
|
||||
i = select_pc(1);
|
||||
i = select_pc(eSelectPC::ANY);
|
||||
if(i != 6)
|
||||
ctx.cur_target = &univ.party[i];
|
||||
}
|
||||
else if(spec.ex1a == 3) {
|
||||
i = select_pc(2);
|
||||
i = select_pc(eSelectPC::ONLY_DEAD);
|
||||
if(i != 6)
|
||||
ctx.cur_target = &univ.party[i];
|
||||
}
|
||||
else if(spec.ex1a == 4) {
|
||||
i = select_pc(3);
|
||||
i = select_pc(eSelectPC::ONLY_LIVING_WITH_ITEM_SLOT);
|
||||
if(i != 6)
|
||||
ctx.cur_target = &univ.party[i];
|
||||
}
|
||||
@@ -4086,7 +4086,7 @@ void townmode_spec(const runtime_state& ctx) {
|
||||
check_mess = false;
|
||||
break;
|
||||
}
|
||||
r1 = select_pc(0,"Which character goes?");
|
||||
r1 = select_pc(eSelectPC::ONLY_LIVING,"Which character goes?");
|
||||
if(ctx.which_mode == eSpecCtx::OUT_MOVE || ctx.which_mode == eSpecCtx::TOWN_MOVE || ctx.which_mode == eSpecCtx::COMBAT_MOVE)
|
||||
*ctx.ret_a = 1;
|
||||
if(r1 != 6) {
|
||||
|
Reference in New Issue
Block a user