improve board view with visual cues of the properties owned
This commit is contained in:
@@ -12,10 +12,11 @@ class BoardModalGame : public Game {
|
||||
bool dismissed;
|
||||
Player* players;
|
||||
int players_count;
|
||||
int observer_idx;
|
||||
|
||||
public:
|
||||
BoardModalGame(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager, Player* p, int count)
|
||||
: Game(width, height, renderer, gui, input_manager), dismissed(false), players(p), players_count(count) {}
|
||||
BoardModalGame(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager, Player* p, int count, int current_idx)
|
||||
: Game(width, height, renderer, gui, input_manager), dismissed(false), players(p), players_count(count), observer_idx(current_idx) {}
|
||||
|
||||
void init() override { dismissed = false; }
|
||||
Type get_type() const override { return Type::MONOPOLY_BOARD; }
|
||||
@@ -32,9 +33,7 @@ public:
|
||||
void draw() override {
|
||||
renderer->clear_buffer();
|
||||
|
||||
MonopolyBoardRenderer::draw_board_perimeter(renderer, width, height, players, players_count, players[0].position /* Just for example, or -1 */);
|
||||
// We'll pass -1 for the general board view to keep it clean
|
||||
MonopolyBoardRenderer::draw_board_perimeter(renderer, width, height, players, players_count, -1);
|
||||
MonopolyBoardRenderer::draw_board_perimeter(renderer, width, height, players, players_count, -1, observer_idx);
|
||||
|
||||
// --- Inner UI ---
|
||||
int cw = width / 7;
|
||||
@@ -42,15 +41,30 @@ public:
|
||||
int ix = cw + 5, iy = ch + 5;
|
||||
int iw = width - 2 * cw - 10, ih = height - 2 * ch - 10;
|
||||
|
||||
// Window Background
|
||||
renderer->draw_filled_rectangle(ix, iy, iw, ih, false, 0);
|
||||
renderer->draw_rectangle(ix, iy, iw, ih, true, 1);
|
||||
|
||||
// Title
|
||||
renderer->draw_string_scaled(ix + (iw - 144) / 2, iy + 10, "== BOARD ==", 2);
|
||||
renderer->draw_string_scaled(ix + (iw - 144) / 2, iy + 5, "== BOARD ==", 2);
|
||||
|
||||
// Stats for current player
|
||||
Player& curr = players[observer_idx];
|
||||
int total_wealth = curr.balance;
|
||||
for (int i = 0; i < curr.property_count; ++i) {
|
||||
total_wealth += MONOPOLY_BOARD[curr.properties_owned[i]].cost;
|
||||
}
|
||||
|
||||
char wealth_buf[64];
|
||||
snprintf(wealth_buf, sizeof(wealth_buf), "%s: Bal:$%d Wealth:$%d", curr.name, curr.balance, total_wealth);
|
||||
renderer->draw_string_scaled(ix + 10, iy + 30, wealth_buf, 1);
|
||||
|
||||
// Legend for players
|
||||
int ly = iy + 40;
|
||||
int ly = iy + 45;
|
||||
for (int i = 0; i < players_count; ++i) {
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%c:%s($%d)", (players[i].token ? players[i].token[0] : 'P'), players[i].name, players[i].balance);
|
||||
renderer->draw_string_scaled(ix + 10, ly, buf, 1);
|
||||
char buf[128];
|
||||
snprintf(buf, sizeof(buf), "%c:%s $%d", (players[i].token ? players[i].token[0] : 'P'), players[i].name, players[i].balance);
|
||||
renderer->draw_string_scaled(ix + 5, ly, buf, 1);
|
||||
ly += 12;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user