Several small fixes/tweaks

- Fix drop/give/use buttons not appearing in inventory
- Fix wrong item variety being shown in the item info dialog
- Enable the code path where clicking an item while in "use space" mode uses the item
- Introduce constants for the special item pages
This commit is contained in:
2015-01-26 02:49:38 -05:00
parent 188e50b36c
commit 644d1cbda8
5 changed files with 42 additions and 21 deletions

View File

@@ -662,7 +662,6 @@ static void handle_switch_pc_items(short which_pc, bool& need_redraw) {
add_string_to_buf("Set active: Finish what you're doing first.");
else {
if(!is_combat()) {
// TODO: Maybe allow this in combat, as per the above TODO note?
if(univ.party[which_pc].main_status != eMainStatus::ALIVE && (overall_mode != MODE_SHOPPING || active_shop.getType() != eShopType::ALCHEMY))
add_string_to_buf("Set active: PC must be here & active.");
else {
@@ -693,10 +692,17 @@ static void handle_equip_item(short item_hit, bool& need_redraw) {
equip_item(stat_window, item_hit);
take_ap(1);
need_redraw = true;
}
} else if(stat_screen_mode > MODE_SHOP) {
// TODO: For some reason, the game didn't do anything at all in this case.
// I'm not sure why; maybe it intended to forward to the sell button?
} else add_string_to_buf("Equip: Finish what you're doing first.");
}
static void handle_use_item(short item_hit, bool& did_something, bool& need_redraw) {
if(!prime_time()) {
add_string_to_buf("Use item: Finish what you're doing first.");
return;
}
use_item(stat_window, item_hit);
if(overall_mode != MODE_TOWN_TARGET && overall_mode != MODE_SPELL_TARGET)
did_something = true;
@@ -705,6 +711,10 @@ static void handle_use_item(short item_hit, bool& did_something, bool& need_redr
}
static void handle_give_item(short item_hit, bool& did_something, bool& need_redraw) {
if(!prime_time()) {
add_string_to_buf("Give item: Finish what you're doing first.");
return;
}
give_thing(stat_window, item_hit);
did_something = true;
need_redraw = true;
@@ -712,7 +722,9 @@ static void handle_give_item(short item_hit, bool& did_something, bool& need_red
}
static void handle_drop_item(short item_hit, bool& need_redraw) {
if(is_out())
if(!prime_time())
add_string_to_buf("Drop item: Finish what you're doing first.");
else if(is_out())
drop_item(stat_window,item_hit,univ.party.p_loc);
else {
add_string_to_buf("Drop item: Click where to drop item.");
@@ -752,6 +764,9 @@ static void handle_item_shop_action(short item_hit) {
univ.party[stat_window].items[item_hit].enchant_weapon(ench,store_selling_values[i]);
}
break;
case MODE_INVEN: case MODE_SHOP:
// The button doesn't even exist, so just do nothing.
break;
}
}
@@ -1297,10 +1312,11 @@ bool handle_action(sf::Event event) {
switch(i) {
case 6: // special screen
give_help(50,0);
set_stat_window(6);
set_stat_window(ITEM_WIN_SPECIAL);
break;
case 7:
// TODO: Jobs! Or maybe quests!
//set_stat_window(ITEM_WIN_QUESTS);
break;
case 8: // help
cChoiceDlog("help-inventory").show();
@@ -1310,7 +1326,7 @@ bool handle_action(sf::Event event) {
break;
}
}
if(stat_window < 7) {
if(stat_window <= ITEM_WIN_QUESTS) {
for(int i = 0; i < 8; i++)
for(int j = 0; j < 6; j++)
if(item_area_button_active[i][j] && point_in_area.in(item_buttons[i][j])) {
@@ -1320,9 +1336,7 @@ bool handle_action(sf::Event event) {
item_buttons[i][j].offset(-ITEM_WIN_UL_X,-ITEM_WIN_UL_Y);
item_hit = item_sbar->getPosition() + i;
if(!prime_time() && j < 4 && (j > 0 || stat_screen_mode < 2))
add_string_to_buf("Item action: Finish what you're doing first.");
else switch(j) {
switch(j) {
case 0: // equip
handle_equip_item(item_hit, need_redraw);
break;
@@ -1333,14 +1347,16 @@ bool handle_action(sf::Event event) {
handle_give_item(item_hit, did_something, need_redraw);
break;
case 3: // drop
if(stat_window == 6) {
if(stat_window == ITEM_WIN_SPECIAL) {
use_spec_item(spec_item_array[item_hit]);
need_redraw = true;
} else handle_drop_item(item_hit, need_redraw);
break;
case 4: // info
if(stat_window == 6)
if(stat_window == ITEM_WIN_SPECIAL)
put_spec_item_info(spec_item_array[item_hit]);
else if(stat_window == ITEM_WIN_QUESTS)
; // TODO: Implement quests view
else display_pc_item(stat_window, item_hit,univ.party[stat_window].items[item_hit],0);
break;
case 5: // sell? That this codes was reached indicates that the item was sellable

View File

@@ -190,6 +190,10 @@ enum eTrapType {
#define PCBTN_INFO 3
#define PCBTN_TRADE 4
// Item window modes (non-PC)
#define ITEM_WIN_SPECIAL 6
#define ITEM_WIN_QUESTS 7
//Spell select
#define SPELL_SELECT_NONE 0
#define SPELL_SELECT_ACTIVE 1

View File

@@ -197,7 +197,7 @@ static void put_item_info(cDialog& me,const cItem& s_i) {
if(s_i.magic && s_i.ident)
magic.setState(led_red);
else magic.setState(led_off);
me["type"].setText(get_str("item-types-display", int(s_i.variety)));
me["type"].setText(get_str("item-types-display", int(s_i.variety) + 1));
// Clear fields
me["val"].setText("");

View File

@@ -2424,8 +2424,8 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
else {
univ.party.spec_items[spec.ex1a] = spec.ex1b == 0;
}
if(stat_window == 6)
set_stat_window(6);
if(stat_window == ITEM_WIN_SPECIAL)
set_stat_window(ITEM_WIN_SPECIAL);
*redraw = 1;
break;
case eSpecType::ONCE_NULL:
@@ -2493,8 +2493,8 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
ASB("You get a special item.");
univ.party.spec_items[spec.m3] = true;
*redraw = true;
if(stat_window == 6)
set_stat_window(6);
if(stat_window == ITEM_WIN_SPECIAL)
set_stat_window(ITEM_WIN_SPECIAL);
}
if(spec.ex2b >= 0) *next_spec = spec.ex2b;
}

View File

@@ -233,7 +233,7 @@ void put_item_screen(short screen_num,short suppress_buttons) {
TextStyle style;
style.lineHeight = 10;
switch(screen_num) {
case 6: // On special items page
case ITEM_WIN_SPECIAL:
style.font = FONT_BOLD;
style.colour = sf::Color::White;
win_draw_string(item_stats_gworld,upper_frame_rect,"Special items:",eTextMode::WRAP,style);
@@ -251,7 +251,8 @@ void put_item_screen(short screen_num,short suppress_buttons) {
}
}
break;
case 7: // On jobs page
case ITEM_WIN_QUESTS:
// TODO: Implement quest list
break;
default: // on an items page
@@ -314,7 +315,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 == MODE_SHOP) &&
if((stat_screen_mode == MODE_INVEN) &&
((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);
@@ -493,11 +494,11 @@ void set_stat_window(short new_stat) {
short i,array_pos = 0;
stat_window = new_stat;
if(stat_window < 6 && univ.party[stat_window].main_status != eMainStatus::ALIVE)
if(stat_window < ITEM_WIN_SPECIAL && univ.party[stat_window].main_status != eMainStatus::ALIVE)
stat_window = first_active_pc();
item_sbar->setPageSize(8);
switch(stat_window) {
case 6:
case ITEM_WIN_SPECIAL:
for(i = 0; i < 60; i++)
spec_item_array[i] = -1;
for(i = 0; i < 50; i++) ////
@@ -508,7 +509,7 @@ void set_stat_window(short new_stat) {
array_pos = max(0,array_pos - 8);
item_sbar->setMaximum(array_pos);
break;
case 7:
case ITEM_WIN_QUESTS:
item_sbar->setMaximum(2);
item_sbar->setPageSize(2);
break;