Integrate thematic sprites and improve Monopoly UI
This commit is contained in:
@@ -22,6 +22,8 @@ extern "C" {
|
||||
#include "BoardModalGame.h"
|
||||
#include "ChanceModalGame.h"
|
||||
#include "CommunityChestModalGame.h"
|
||||
#include "TurnModalGame.h"
|
||||
#include "sprites.h"
|
||||
#include "MonopolyBoardRenderer.h"
|
||||
|
||||
|
||||
@@ -50,6 +52,7 @@ void MonopolyGame::init() {
|
||||
shuffle_chance_deck();
|
||||
shuffle_community_deck();
|
||||
if (active_modal) { delete active_modal; active_modal = nullptr; }
|
||||
active_modal = new TurnModalGame(width, height, renderer, gui, input_manager, &players[current_player_idx]);
|
||||
// TODO: Reset all board state, property ownership, etc.
|
||||
}
|
||||
|
||||
@@ -105,6 +108,7 @@ bool MonopolyGame::update(const InputEvent& event) {
|
||||
BoardModalGame* board_modal = (active_modal->get_type() == Game::Type::MONOPOLY_BOARD) ? static_cast<BoardModalGame*>(active_modal) : nullptr;
|
||||
ChanceModalGame* chance_modal = (active_modal->get_type() == Game::Type::MONOPOLY_CHANCE) ? static_cast<ChanceModalGame*>(active_modal) : nullptr;
|
||||
CommunityChestModalGame* community_modal = (active_modal->get_type() == Game::Type::MONOPOLY_COMMUNITY_CHEST) ? static_cast<CommunityChestModalGame*>(active_modal) : nullptr;
|
||||
TurnModalGame* turn_modal = (active_modal->get_type() == Game::Type::MONOPOLY_TURN) ? static_cast<TurnModalGame*>(active_modal) : nullptr;
|
||||
|
||||
if (dice_modal && dice_modal->is_dismissed()) {
|
||||
delete active_modal;
|
||||
@@ -128,7 +132,7 @@ bool MonopolyGame::update(const InputEvent& event) {
|
||||
if (is_owned) break;
|
||||
}
|
||||
bool can_afford = (p->balance >= MONOPOLY_BOARD[modal_property_index].cost);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, &MONOPOLY_BOARD[modal_property_index], is_owned, owner_name, owner_id, can_afford, players, players_count);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, &MONOPOLY_BOARD[modal_property_index], is_owned, owner_name, owner_id, can_afford, players, players_count, current_player_idx);
|
||||
modal_property_index = -1;
|
||||
} else if (last_drawn_chance_idx >= 0) {
|
||||
active_modal = new ChanceModalGame(width, height, renderer, gui, input_manager, &CHANCE_DECK[last_drawn_chance_idx], players, players_count, p->position);
|
||||
@@ -219,7 +223,7 @@ bool MonopolyGame::update(const InputEvent& event) {
|
||||
}
|
||||
}
|
||||
bool can_afford = (p->balance >= landed->cost);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, landed, is_owned, owner_name, owner_id, can_afford, players, players_count);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, landed, is_owned, owner_name, owner_id, can_afford, players, players_count, current_player_idx);
|
||||
}
|
||||
}
|
||||
return needs_redraw;
|
||||
@@ -283,7 +287,7 @@ bool MonopolyGame::update(const InputEvent& event) {
|
||||
}
|
||||
}
|
||||
bool can_afford = (p->balance >= landed->cost);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, landed, is_owned, owner_name, owner_id, can_afford, players, players_count);
|
||||
active_modal = new PropertyModalGame(width, height, renderer, gui, input_manager, landed, is_owned, owner_name, owner_id, can_afford, players, players_count, current_player_idx);
|
||||
}
|
||||
}
|
||||
return needs_redraw;
|
||||
@@ -360,6 +364,10 @@ bool MonopolyGame::update(const InputEvent& event) {
|
||||
delete active_modal;
|
||||
active_modal = nullptr;
|
||||
needs_redraw = true;
|
||||
} else if (turn_modal && turn_modal->is_dismissed()) {
|
||||
delete active_modal;
|
||||
active_modal = nullptr;
|
||||
needs_redraw = true;
|
||||
}
|
||||
return needs_redraw;
|
||||
}
|
||||
@@ -445,6 +453,7 @@ roll_dice_logic:
|
||||
} else {
|
||||
current_player_idx = (current_player_idx + 1) % players_count;
|
||||
has_rolled = false; double_rolls = 0; just_sent_to_jail = false; selected_action = 0;
|
||||
active_modal = new TurnModalGame(width, height, renderer, gui, input_manager, &players[current_player_idx]);
|
||||
needs_redraw = true;
|
||||
}
|
||||
break;
|
||||
@@ -475,22 +484,50 @@ void MonopolyGame::draw() {
|
||||
int ix = cw + 2, iy = ch + 2;
|
||||
int iw = width - 2 * cw - 4, ih = height - 2 * ch - 4;
|
||||
|
||||
// Stats Window in center
|
||||
// --- Inner Dashboard UI ---
|
||||
// Window Border
|
||||
renderer->draw_rectangle(ix, iy, iw, ih, true, 2);
|
||||
renderer->draw_rectangle(ix + 3, iy + 3, iw - 6, ih - 6, true, 1);
|
||||
|
||||
// Header Title Bar (Player Name)
|
||||
char buf[128];
|
||||
renderer->draw_string_scaled(ix + 70, iy + 180, "Monopoly", 3);
|
||||
renderer->draw_filled_rectangle(ix + 4, iy + 4, iw - 8, 35, true, 1);
|
||||
renderer->set_text_color(false); // White text
|
||||
snprintf(buf, sizeof(buf), "%s'S TURN", p->name);
|
||||
renderer->draw_string_scaled(ix + (iw - (int)strlen(buf) * 12) / 2, iy + 12, buf, 2);
|
||||
renderer->set_text_color(true);
|
||||
|
||||
renderer->draw_string_scaled(ix + (iw - 8 * 18) / 2, iy + ih - 35, "Monopoly", 3);
|
||||
|
||||
int content_y = iy + 0;
|
||||
snprintf(buf, sizeof(buf), "%s", p->name);
|
||||
renderer->draw_string_scaled(ix + 5, content_y, buf, 3);
|
||||
content_y += 40;
|
||||
int content_y = iy + 50;
|
||||
|
||||
snprintf(buf, sizeof(buf), "BAL: $%d", p->balance);
|
||||
renderer->draw_string_scaled(ix + 5, content_y, buf, 2);
|
||||
snprintf(buf, sizeof(buf), "BALANCE: $%d", p->balance);
|
||||
renderer->draw_string_scaled(ix + 10, content_y, buf, 2);
|
||||
content_y += 25;
|
||||
|
||||
snprintf(buf, sizeof(buf), "TILE: %s", tile->name);
|
||||
renderer->draw_string_scaled(ix + 10, content_y, buf, 1);
|
||||
content_y += 20;
|
||||
|
||||
snprintf(buf, sizeof(buf), "POS: %s", tile->name);
|
||||
renderer->draw_string_scaled(ix + 5, content_y, buf, 2);
|
||||
content_y += 20;
|
||||
// Draw special tile sprite
|
||||
const unsigned char* sprite = nullptr;
|
||||
if (tile->type == TILE_COMMUNITY_CHEST) sprite = epd_bitmap_CommunityChest;
|
||||
else if (tile->type == TILE_CHANCE) sprite = epd_bitmap_Chance;
|
||||
else if (tile->type == TILE_FREE_PARKING) sprite = epd_bitmap_FreeParking;
|
||||
else if (tile->type == TILE_GO_TO_JAIL) sprite = epd_bitmap_GoToJail;
|
||||
else if (tile->type == TILE_UTILITY) {
|
||||
if (strstr(tile->name, "Electric")) sprite = epd_bitmap_ElectricCompany;
|
||||
else if (strstr(tile->name, "Water")) sprite = epd_bitmap_WaterWorks;
|
||||
}
|
||||
|
||||
if (sprite) {
|
||||
// Draw at bottom right of dashboard
|
||||
renderer->draw_bitmap(sprite, ix + iw - 105, iy + ih - 105, 100, 100, true);
|
||||
}
|
||||
|
||||
// Separator line
|
||||
renderer->draw_line(ix + 10, content_y, ix + iw - 10, content_y, true);
|
||||
content_y += 15;
|
||||
// Draw action menu
|
||||
const char* actions[3];
|
||||
int menu_count = 0;
|
||||
@@ -504,7 +541,7 @@ void MonopolyGame::draw() {
|
||||
|
||||
for (int i = 0; i < menu_count; ++i) {
|
||||
snprintf(buf, sizeof(buf), "%s%s", (i == selected_action) ? "> " : " ", actions[i]);
|
||||
renderer->draw_string_scaled(ix + 5, content_y, buf, 2);
|
||||
content_y += 20;
|
||||
renderer->draw_string_scaled(ix + 15, content_y, buf, 2);
|
||||
content_y += 25;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user