game[junk bag]: some "basic" works on interface and help dialogs.

This commit is contained in:
ALONSO Laurent
2022-01-25 10:08:45 +01:00
committed by Celtic Minstrel
parent a343ad9b9f
commit dcb82a5789
10 changed files with 150 additions and 29 deletions

View File

@@ -39,11 +39,12 @@
#include "render_shapes.hpp"
#include "enum_map.hpp"
rectangle item_screen_button_rects[9] = {
{125,10,141,28},{125,40,141,58},{125,68,141,86},{125,98,141,116},{125,126,141,144},{125,156,141,174},
{126,176,141,211},
{126,213,141,248},
{127,251,140,267}
rectangle item_screen_button_rects[10] = {
{125,9,141,27},{125,37,141,55},{125,64,141,82},{125,92,141,110},{125,119,141,137},{125,147,141,165}, // pc
{126,190,141,222}, // special
{126,221,141,254}, // quest
{127,254,140,270}, // help
{125,174,141,189} // junk bag
};
rectangle medium_buttons[4] = {
{383,190,401,225}, {402, 190, 420, 225},
@@ -61,7 +62,7 @@ rectangle startup_top;
enum_map(eItemButton, bool) item_area_button_active[8];
enum_map(ePlayerButton, bool) pc_area_button_active[6];
short item_bottom_button_active[9] = {0,0,0,0,0, 0,1,1,1};
bool item_bottom_button_active[10] = {false,false,false,false,false, false,true,true,true,false};
rectangle pc_help_button;
@@ -190,19 +191,6 @@ void init_screen_locs() {
item_buttons[i][j].offset(0,13 * i);
}
/* for(short i = 0; i < 8; i++) {
item_screen_button_rects[i] = bottom_base;
OffsetRect(&item_screen_button_rects[i],10 + i * 29,126);
}
item_screen_button_rects[6].left = 176;
item_screen_button_rects[6].right = 211;
item_screen_button_rects[7].left = 213;
item_screen_button_rects[7].right = 248;
item_screen_button_rects[8].top = 127;
item_screen_button_rects[8].bottom = 140;
item_screen_button_rects[8].left = 251;
item_screen_button_rects[8].right = 267; */
// name, hp, sp, info, trade
pc_buttons[0][PCBTN_NAME].top = 18;
pc_buttons[0][PCBTN_NAME].bottom = pc_buttons[0][PCBTN_NAME].top + 12;
@@ -1354,7 +1342,7 @@ bool handle_action(const sf::Event& event) {
point_in_area.x -= item_win_ul.x;
point_in_area.y -= item_win_ul.y;
for(int i = 0; i < 9; i++)
for(int i = 0; i < 10; i++)
if(item_bottom_button_active[i] > 0 && point_in_area.in(item_screen_button_rects[i])) {
rectangle button_rect = item_screen_button_rects[i];
button_rect.offset(item_win_ul);
@@ -1369,6 +1357,9 @@ bool handle_action(const sf::Event& event) {
case 8: // help
cChoiceDlog("help-inventory").show();
break;
case 9:
set_stat_window(ITEM_WIN_JUNK);
break;
default:
handle_switch_pc_items(i, need_redraw);
break;

View File

@@ -629,10 +629,14 @@ bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short
sout << "item" << i << "-info";
itemDialog[sout.str()].attachClickHandler(handler);
}
if (univ.party.show_junk_bag)
if (univ.party.show_junk_bag) {
itemDialog["junk"].show();
else
itemDialog["help-junk"].show();
}
else {
itemDialog["junk"].hide();
itemDialog["help-junk"].hide();
}
put_item_graphics(itemDialog, first_item, pc_getting, itemRefs);
void (*give_help)(short,short,cDialog&) = ::give_help;

View File

@@ -74,10 +74,10 @@ extern enum_map(eItemButton, rectangle) item_buttons[8];
extern enum_map(ePlayerButton, rectangle) pc_buttons[6];
extern enum_map(eItemButton, bool) item_area_button_active[8];
extern enum_map(ePlayerButton, bool) pc_area_button_active[6];
extern rectangle item_screen_button_rects[9];
extern rectangle item_screen_button_rects[10];
extern std::vector<int> spec_item_array;
// combat globals
extern short item_bottom_button_active[9];
extern bool item_bottom_button_active[10];
extern cUniverse univ;
extern short shop_identify_cost;
extern short store_selling_values[8];
@@ -543,7 +543,7 @@ void place_item_button(short button_position,short which_slot,eItemButton button
void place_item_bottom_buttons() {
rectangle pc_from_rect = {0,0,36,28},but_from_rect = {30,60,46,78},to_rect;
rectangle spec_from_rect = {0,60,15,95}, job_from_rect = {15,60,30,95}, help_from_rect = {46,60,59,76};
rectangle spec_from_rect = {0,60,15,95}, job_from_rect = {15,60,30,95}, help_from_rect = {46,60,59,76}, bag_from_rect = {60,60,78,78};
// TODO: What about when the buttons are pressed?
TextStyle style;
style.lineHeight = 10;
@@ -576,6 +576,18 @@ void place_item_bottom_buttons() {
rect_draw_some_item(invenbtn_gworld, job_from_rect, item_stats_gworld, to_rect, sf::BlendAlpha);
to_rect = item_screen_button_rects[8];
rect_draw_some_item(invenbtn_gworld, help_from_rect, item_stats_gworld, to_rect, sf::BlendAlpha);
if (univ.party.show_junk_bag) {
to_rect = item_screen_button_rects[9];
item_bottom_button_active[9] = true;
rect_draw_some_item(invenbtn_gworld, bag_from_rect, item_stats_gworld, to_rect, sf::BlendAlpha);
to_rect.inset(2,2);
std::string numeral = "7";
short width = string_length(numeral, style);
to_rect.offset(-width - 5, 0);
win_draw_string(item_stats_gworld, to_rect, numeral, eTextMode::LEFT_TOP, style);
}
else
item_bottom_button_active[9] = false;
}
void set_stat_window_for_pc(int pc) {