Integrate thematic sprites and improve Monopoly UI

This commit is contained in:
Adolfo Reyna
2026-02-02 23:14:14 -05:00
parent 3bdbfb1811
commit eb86c3fc0e
8 changed files with 722 additions and 79 deletions

View File

@@ -41,34 +41,84 @@ public:
int ix = cw + 5, iy = ch + 5;
int iw = width - 2 * cw - 10, ih = height - 2 * ch - 10;
// Window Background
// Window Background (Double Border)
renderer->draw_filled_rectangle(ix, iy, iw, ih, false, 0);
renderer->draw_rectangle(ix, iy, iw, ih, true, 1);
renderer->draw_rectangle(ix, iy, iw, ih, true, 2);
renderer->draw_rectangle(ix + 3, iy + 3, iw - 6, ih - 6, true, 1);
// Title
renderer->draw_string_scaled(ix + (iw - 144) / 2, iy + 5, "== BOARD ==", 2);
// Header Title Bar
renderer->draw_filled_rectangle(ix + 4, iy + 4, iw - 8, 30, true, 1);
renderer->set_text_color(false);
renderer->draw_string_scaled(ix + (iw - 12 * 12) / 2, iy + 10, "BOARD STATUS", 2);
renderer->set_text_color(true);
// 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;
}
// Calculate wealth for all players to find the leader
int leader_idx = 0;
int max_wealth = -1;
int p_wealth[MAX_PLAYERS];
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 + 45;
for (int i = 0; i < players_count; ++i) {
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;
int total = players[i].balance;
for (int j = 0; j < players[i].property_count; ++j) {
total += MONOPOLY_BOARD[players[i].properties_owned[j]].cost;
}
p_wealth[i] = total;
if (total > max_wealth) {
max_wealth = total;
leader_idx = i;
}
}
renderer->draw_string_scaled(ix + (iw - 120) / 2, iy + ih - 15, "PRESS B TO EXIT", 1);
// --- Current Player Section (Observer) ---
Player& curr = players[observer_idx];
char buf[128];
int stats_y = iy + 45;
// Name with token
snprintf(buf, sizeof(buf), "[%c] %s", (curr.token ? curr.token[0] : 'P'), curr.name);
renderer->draw_string_scaled(ix + 12, stats_y, buf, 2);
stats_y += 20;
// Split Balance and Total Wealth into two lines
snprintf(buf, sizeof(buf), "CASH: $%d", curr.balance);
renderer->draw_string_scaled(ix + 15, stats_y, buf, 2);
stats_y += 20;
snprintf(buf, sizeof(buf), "TOTAL: $%d", p_wealth[observer_idx]);
renderer->draw_string_scaled(ix + 15, stats_y, buf, 2);
stats_y += 25;
// Separator Line
renderer->draw_line(ix + 10, stats_y, ix + iw - 10, stats_y, true);
stats_y += 10;
// --- Standings Header ---
renderer->draw_string_scaled(ix + 10, stats_y, "STANDINGS:", 1);
stats_y += 15;
for (int i = 0; i < players_count; ++i) {
bool is_leader = (i == leader_idx);
bool is_observer = (i == observer_idx);
// Format: *[T] Name $Wealth
if (is_leader) {
snprintf(buf, sizeof(buf), "*%c:%-6s $%d", (players[i].token ? players[i].token[0] : 'P'), players[i].name, p_wealth[i]);
} else {
snprintf(buf, sizeof(buf), " %c:%-6s $%d", (players[i].token ? players[i].token[0] : 'P'), players[i].name, p_wealth[i]);
}
if (is_observer) {
renderer->draw_filled_rectangle(ix + 8, stats_y - 2, iw - 16, 12, true, 1);
renderer->set_text_color(false);
}
renderer->draw_string_scaled(ix + 12, stats_y, buf, 1);
if (is_observer) renderer->set_text_color(true);
stats_y += 13;
}
renderer->draw_string_scaled(ix + (iw - 12 * 6) / 2, iy + ih - 15, "PRESS BUTTON", 1);
}
public: