Integrate thematic sprites and improve Monopoly UI
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "monopoly_board.h"
|
||||
#include "player.h"
|
||||
#include "MonopolyBoardRenderer.h"
|
||||
#include "sprites.h"
|
||||
|
||||
class PropertyModalGame : public Game {
|
||||
const BoardTile* property;
|
||||
@@ -20,10 +21,11 @@ class PropertyModalGame : public Game {
|
||||
bool rent_requested;
|
||||
Player* players;
|
||||
int players_count;
|
||||
int observer_idx;
|
||||
|
||||
public:
|
||||
PropertyModalGame(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager, const BoardTile* prop, bool owned, const char* owner, int o_id, bool affordable, Player* p_list = nullptr, int p_count = 0)
|
||||
: Game(width, height, renderer, gui, input_manager), property(prop), dismissed(false), is_owned(owned), owner_name(owner), owner_id(o_id), can_afford(affordable), selected_choice(0), buy_requested(false), rent_requested(false), players(p_list), players_count(p_count) {
|
||||
PropertyModalGame(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager, const BoardTile* prop, bool owned, const char* owner, int o_id, bool affordable, Player* p_list = nullptr, int p_count = 0, int obs_idx = -1)
|
||||
: Game(width, height, renderer, gui, input_manager), property(prop), dismissed(false), is_owned(owned), owner_name(owner), owner_id(o_id), can_afford(affordable), selected_choice(0), buy_requested(false), rent_requested(false), players(p_list), players_count(p_count), observer_idx(obs_idx) {
|
||||
if (is_owned || !can_afford) selected_choice = 1;
|
||||
}
|
||||
void init() override { dismissed = false; buy_requested = false; rent_requested = false; selected_choice = 0; }
|
||||
@@ -70,7 +72,8 @@ public:
|
||||
if (players && players_count > 0) {
|
||||
int property_idx = -1;
|
||||
for(int i=0; i<40; i++) if(&MONOPOLY_BOARD[i] == property) property_idx = i;
|
||||
MonopolyBoardRenderer::draw_board_perimeter(renderer, width, height, players, players_count, property_idx);
|
||||
// Keep observer_idx to show player's own properties on perimeter
|
||||
MonopolyBoardRenderer::draw_board_perimeter(renderer, width, height, players, players_count, property_idx, observer_idx);
|
||||
}
|
||||
|
||||
// Window background (White box)
|
||||
@@ -83,17 +86,17 @@ public:
|
||||
renderer->set_text_color(false); // White text
|
||||
snprintf(buf, sizeof(buf), "%s", property->name);
|
||||
renderer->draw_string_scaled(win_x + (win_w - (int)strlen(buf) * 12) / 2, win_y + 10, buf, 2);
|
||||
renderer->set_text_color(true);
|
||||
|
||||
// Subtitle (Type)
|
||||
const char* type_str = "PROPERTY";
|
||||
if (property->type == TILE_RAILROAD) type_str = "RAILROAD";
|
||||
else if (property->type == TILE_UTILITY) type_str = "UTILITY";
|
||||
snprintf(buf, sizeof(buf), "%s", type_str);
|
||||
renderer->draw_string_scaled(win_x + (win_w - (int)strlen(buf) * 12) / 2, win_y + 45, buf, 2);
|
||||
renderer->draw_string_scaled(win_w - (int)strlen(buf) * 6 + 20, win_y + 30, buf, 1);
|
||||
renderer->set_text_color(true);
|
||||
|
||||
// Info box center
|
||||
int info_y = win_y + 75;
|
||||
int info_y = win_y + 45;
|
||||
// Price
|
||||
snprintf(buf, sizeof(buf), "PRICE: $%d", property->cost);
|
||||
renderer->draw_string_scaled(win_x + 20, info_y, buf, 2);
|
||||
@@ -118,6 +121,16 @@ public:
|
||||
}
|
||||
renderer->draw_string_scaled(win_x + 20, info_y, buf, 2);
|
||||
|
||||
// Draw special utility sprite if applicable
|
||||
const unsigned char* sprite = nullptr;
|
||||
if (property->type == TILE_UTILITY) {
|
||||
if (strstr(property->name, "Electric")) sprite = epd_bitmap_ElectricCompany;
|
||||
else if (strstr(property->name, "Water")) sprite = epd_bitmap_WaterWorks;
|
||||
}
|
||||
if (sprite) {
|
||||
renderer->draw_bitmap(sprite, win_x + win_w - 105, win_y + win_h - 105, 100, 100, true);
|
||||
}
|
||||
|
||||
// Action Buttons
|
||||
int btn_y = win_y + win_h - 85;
|
||||
int btn_w = win_w - 40;
|
||||
@@ -170,12 +183,10 @@ public:
|
||||
renderer->draw_string_scaled(win_x + 25, btn_y + 10, buf, 2);
|
||||
renderer->set_text_color(true);
|
||||
|
||||
// Helpful hint
|
||||
renderer->draw_string_scaled(win_x + 20, win_y + win_h - 20, "A:Next B:Sel", 1);
|
||||
} else {
|
||||
renderer->draw_filled_rectangle(win_x + 20, btn_y, btn_w, btn_h, true, 1);
|
||||
renderer->set_text_color(false);
|
||||
renderer->draw_string_scaled(win_x + (win_w - 7 * 12) / 2, btn_y + 10, ">B PASS", 2);
|
||||
renderer->draw_string_scaled(win_x + (win_w - 7 * 12) / 2, btn_y + 10, ">PASS", 2);
|
||||
renderer->set_text_color(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user