Create enum for stat screen mode

This commit is contained in:
2015-01-21 13:53:29 -05:00
parent 53677398de
commit fb607f83c1
7 changed files with 43 additions and 29 deletions

View File

@@ -101,7 +101,8 @@ extern bool talk_end_forced;
extern short which_combat_type,num_targets_left;
extern location center;
extern short current_pc;
extern short combat_active_pc,stat_screen_mode;
extern short combat_active_pc;
extern eStatMode stat_screen_mode;
extern bool map_visible,diff_depth_ok;
extern sf::RenderWindow mini_map;
@@ -716,7 +717,7 @@ static void handle_drop_item(short item_hit, bool& need_redraw) {
static void handle_item_shop_action(short item_hit) {
long i = item_hit - item_sbar->getPosition();
switch(stat_screen_mode) {
case 2: // identify item
case MODE_IDENTIFY:
if(!take_gold(shop_identify_cost,false))
ASB("Identify: You don't have the gold.");
else {
@@ -726,14 +727,14 @@ static void handle_item_shop_action(short item_hit) {
univ.party[stat_window].combine_things();
}
break;
case 3: case 4: case 5: // various selling
case MODE_SELL_WEAP: case MODE_SELL_ARMOR: case MODE_SELL_ANY:
play_sound(-39);
univ.party.gold += store_selling_values[i];
ASB("You sell your item.");
univ.party[stat_window].take_item(item_hit);
put_item_screen(stat_window,1);
break;
case 6: // enchant item
case MODE_ENCHANT:
if(!take_gold(store_selling_values[i],false))
ASB("Enchant: You don't have the gold.");
else {

View File

@@ -80,6 +80,16 @@ enum eGameMode {
MODE_CUTSCENE = 51, // for future use
};
enum eStatMode {
MODE_INVEN = 0,
MODE_SHOP = 1,
MODE_IDENTIFY = 2,
MODE_SELL_WEAP = 3,
MODE_SELL_ARMOR = 4,
MODE_SELL_ANY = 5,
MODE_ENCHANT = 6,
};
#ifndef DIR_ARRAY_DEF
extern signed char dir_x_dif[9];
extern signed char dir_y_dif[9];

View File

@@ -41,7 +41,8 @@ extern bool play_sounds,give_intro_hint,show_startup_splash,changed_display_mode
extern sf::RenderWindow mainPtr;
extern rectangle d_rects[80];
extern short d_rect_index[80];
extern short display_mode,stat_screen_mode,current_pc;
extern short display_mode,current_pc;
extern eStatMode stat_screen_mode;
extern long register_flag;
extern long ed_flag,ed_key;
extern bool save_maps,give_delays;
@@ -124,7 +125,7 @@ void start_shop_mode(eShopType shop_type,short shop_min,short shop_max,short cos
store_pre_shop_mode = overall_mode;
overall_mode = MODE_SHOPPING;
stat_screen_mode = 1;
stat_screen_mode = MODE_SHOP;
set_up_shop_array(shop_type, shop_min, std::max(shop_min, shop_max));
put_background();
@@ -164,7 +165,7 @@ void end_shop_mode() {
center = univ.town.p_loc;
update_explored(center);
}
stat_screen_mode = 0;
stat_screen_mode = MODE_INVEN;
put_item_screen(stat_window,0);
put_pc_screen();
// TODO: I suspect REFRESH_NONE will suffice here
@@ -448,7 +449,7 @@ void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short st
store_pre_talk_mode = overall_mode;
overall_mode = MODE_TALKING;
talk_end_forced = false;
stat_screen_mode = 1;
stat_screen_mode = MODE_SHOP;
current_talk_node = TALK_LOOK;
// Bring up and place first strings.
@@ -472,7 +473,7 @@ void end_talk_mode() {
center = univ.town.p_loc;
update_explored(center);
}
stat_screen_mode = 0;
stat_screen_mode = MODE_INVEN;
put_item_screen(stat_window,0);
put_pc_screen();
// TODO: I suspect REFRESH_NONE will suffice here
@@ -686,25 +687,25 @@ void handle_talk_event(location p) {
break;
case eTalkNode::SELL_WEAPONS:
strnum1 = -1;
stat_screen_mode = 3;
stat_screen_mode = MODE_SELL_WEAP;
put_item_screen(stat_window,1);
give_help(42,43);
break;
case eTalkNode::SELL_ARMOR:
strnum1 = -1;
stat_screen_mode = 4;
stat_screen_mode = MODE_SELL_ARMOR;
put_item_screen(stat_window,1);
give_help(42,43);
break;
case eTalkNode::SELL_ITEMS:
strnum1 = -1;
stat_screen_mode = 5;
stat_screen_mode = MODE_SELL_ANY;
put_item_screen(stat_window,1);
give_help(42,43);
break;
case eTalkNode::IDENTIFY: case eTalkNode::ENCHANT:
strnum1 = -1;
stat_screen_mode = (ttype == eTalkNode::IDENTIFY) ? 2 : 6;
stat_screen_mode = (ttype == eTalkNode::IDENTIFY) ? MODE_IDENTIFY : MODE_ENCHANT;
shop_identify_cost = a;
put_item_screen(stat_window,1);
give_help(ttype == eTalkNode::IDENTIFY ? 44 : 45,0);

View File

@@ -24,7 +24,7 @@
#define DONE_BUTTON_ITEM 1
extern short stat_screen_mode;
extern eStatMode stat_screen_mode;
extern bool give_delays;
extern eGameMode overall_mode;
extern bool play_sounds,sys_7_avail,save_maps,party_in_memory,in_scen_debug,ghost_mode;
@@ -112,7 +112,7 @@ void finish_load_party(){
end_startup();
overall_mode = town_restore ? MODE_TOWN : MODE_OUTDOORS;
stat_screen_mode = 0;
stat_screen_mode = MODE_INVEN;
build_outdoors();
erase_out_specials();

View File

@@ -80,8 +80,8 @@ location ul = {28,10};
short display_mode = 0; // 0 - center 1- ul 2 - ur 3 - dl 4 - dr 5 - small win
long stored_key;
short pixel_depth,old_depth = 8;
// TODO: Enumify stat_screen_mode
short current_ground = 0,stat_screen_mode = 0;
short current_ground = 0;
eStatMode stat_screen_mode;
short anim_step = -1;
// Spell casting globals

View File

@@ -60,7 +60,8 @@ extern sf::RenderWindow mainPtr;
extern bool spell_forced,save_maps,suppress_stat_screen,boom_anim_active;
extern eSpell store_mage, store_priest;
extern short store_mage_lev, store_priest_lev;
extern short store_spell_target,pc_casting,stat_screen_mode;
extern short store_spell_target,pc_casting;
extern eStatMode stat_screen_mode;
extern effect_pat_type null_pat,single,t,square,radius2,radius3,small_square,open_square;
extern effect_pat_type current_pat;
extern short current_spell_range;
@@ -261,7 +262,7 @@ void put_party_in_scen(std::string scen_name) {
// graphics wise
end_startup();
stat_screen_mode = 0;
stat_screen_mode = MODE_INVEN;
build_outdoors();
erase_out_specials();

View File

@@ -34,7 +34,8 @@ rectangle item_buttons_from[7] = {
eGameMode store_mode;
extern short had_text_freeze,stat_screen_mode;
extern short had_text_freeze;
extern eStatMode stat_screen_mode;
// graphics globals
extern rectangle status_panel_rect,status_panel_title_rect;
@@ -292,7 +293,7 @@ void put_item_screen(short screen_num,short suppress_buttons) {
sout << univ.party[pc].items[i_num].full_name << ' ';
// TODO: Why are bashing weapons excluded from this?
if(univ.party[pc].items[i_num].charges > 0 && univ.party[pc].items[i_num].weap_type != eSkill::BASHING_WEAPONS
&& (stat_screen_mode <= 1))
&& (stat_screen_mode == MODE_INVEN || stat_screen_mode == MODE_SHOP))
sout << '(' << int(univ.party[pc].items[i_num].charges) << ')';
}
dest_rect.left -= 2;
@@ -302,7 +303,7 @@ void put_item_screen(short screen_num,short suppress_buttons) {
// this is kludgy, awkwark, and has redundant code. Done this way to
// make go faster, and I got lazy.
if((stat_screen_mode == 0) &&
if((stat_screen_mode == MODE_SHOP) &&
((is_town()) || (is_out()) || ((is_combat()) && (pc == current_pc)))) { // place give and drop and use
place_item_button(0,i,0,univ.party[pc].items[i_num].graphic_num); // item_graphic
if(abil_chart[univ.party[pc].items[i_num].ability]) // place use if can
@@ -312,7 +313,7 @@ void put_item_screen(short screen_num,short suppress_buttons) {
else {
place_item_button(0,i,0,univ.party[pc].items[i_num].graphic_num); // item_graphic
place_item_button(3,i,4,0); // info button
if((stat_screen_mode == 0) &&
if((stat_screen_mode == MODE_SHOP) &&
((is_town()) || (is_out()) || ((is_combat()) && (pc == current_pc)))) { // place give and drop and use
place_item_button(1,i,2,0);
place_item_button(2,i,3,0);
@@ -320,7 +321,7 @@ void put_item_screen(short screen_num,short suppress_buttons) {
place_item_button(0,i,1,0);
}
}
if(stat_screen_mode > 1) {
if(stat_screen_mode != MODE_INVEN && stat_screen_mode != MODE_SHOP) {
place_buy_button(i,pc,i_num);
}
@@ -352,14 +353,14 @@ void place_buy_button(short position,short pc_num,short item_num) {
val_to_place = val_to_place / 2;
switch(stat_screen_mode) {
case 2:
case MODE_IDENTIFY:
if(!univ.party[pc_num].items[item_num].ident) {
item_area_button_active[position][5] = true;
source_rect = button_sources[0];
val_to_place = shop_identify_cost;
}
break;
case 3: // sell weapons
case MODE_SELL_WEAP:
if(isWeaponType(univ.party[pc_num].items[item_num].variety) &&
(!univ.party[pc_num].equip[item_num]) &&
(univ.party[pc_num].items[item_num].ident) && (val_to_place > 0) &&
@@ -368,7 +369,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
source_rect = button_sources[1];
}
break;
case 4: // sell armor
case MODE_SELL_ARMOR:
if(isArmourType(univ.party[pc_num].items[item_num].variety) &&
(!univ.party[pc_num].equip[item_num]) &&
(univ.party[pc_num].items[item_num].ident) && (val_to_place > 0) &&
@@ -377,7 +378,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
source_rect = button_sources[1];
}
break;
case 5: // sell any
case MODE_SELL_ANY:
if((val_to_place > 0) && (univ.party[pc_num].items[item_num].ident) &&
(!univ.party[pc_num].equip[item_num]) &&
(!univ.party[pc_num].items[item_num].unsellable)) {
@@ -385,7 +386,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
source_rect = button_sources[1];
}
break;
case 6: // augment weapons
case MODE_ENCHANT:
if((univ.party[pc_num].items[item_num].variety == eItemType::ONE_HANDED || univ.party[pc_num].items[item_num].variety == eItemType::TWO_HANDED) &&
(univ.party[pc_num].items[item_num].ident) &&
univ.party[pc_num].items[item_num].ability == eItemAbil::NONE &&