61 lines
2.2 KiB
C++
61 lines
2.2 KiB
C++
// ModalButtonHelper.h
|
|
#pragma once
|
|
#include "../../lib/input_manager.h"
|
|
#include "../../display/low_level_render.h"
|
|
|
|
class ModalButtonHelper {
|
|
public:
|
|
/**
|
|
* @brief Sets the standard Monopoly virtual button regions
|
|
*/
|
|
static void set_monopoly_regions(InputManager* input_manager, uint16_t width, uint16_t height) {
|
|
if (!input_manager) return;
|
|
|
|
// --- BUTTON CONFIGURATION ---
|
|
// Adjust these variables to move the virtual buttons easily
|
|
int btn_w = 60;
|
|
int btn_h = 60;
|
|
int margin_right = 135; // Positioned for the inner board area (W - 135 = 345)
|
|
int start_y = 80; // Vertical start position
|
|
int spacing = 30; // Gap between buttons
|
|
|
|
int btn_x = width - margin_right;
|
|
int btn_a_y = start_y;
|
|
int btn_b_y = btn_a_y + btn_h + spacing;
|
|
|
|
// Apply regions to input manager
|
|
input_manager->set_virtual_button_regions(
|
|
btn_x, btn_a_y, btn_w, btn_h, // Button A (Top)
|
|
btn_x, btn_b_y, btn_w, btn_h // Button B (Bottom)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @brief Draws virtual A and B buttons at consistent screen locations
|
|
*/
|
|
static void draw_virtual_buttons(LowLevelRenderer* renderer, InputManager* input_manager) {
|
|
if (!renderer || !input_manager) return;
|
|
|
|
int a[4], b[4];
|
|
input_manager->get_virtual_button_regions(a, b);
|
|
|
|
// Save current color
|
|
bool original_color = renderer->get_current_text_color();
|
|
|
|
// Draw Button A (Top)
|
|
renderer->draw_filled_rectangle(a[0], a[1], a[2], a[3], false, 0); // White back
|
|
renderer->draw_rectangle(a[0], a[1], a[2], a[3], true, 2); // Black border
|
|
renderer->set_text_color(true);
|
|
renderer->draw_string_scaled(a[0] + (a[2] - 12) / 2, a[1] + (a[3] - 16) / 2, "A", 2);
|
|
|
|
// Draw Button B (Under A)
|
|
renderer->draw_filled_rectangle(b[0], b[1], b[2], b[3], false, 0); // White back
|
|
renderer->draw_rectangle(b[0], b[1], b[2], b[3], true, 2); // Black border
|
|
renderer->set_text_color(true);
|
|
renderer->draw_string_scaled(b[0] + (b[2] - 12) / 2, b[1] + (b[3] - 16) / 2, "B", 2);
|
|
|
|
// Restore color
|
|
renderer->set_text_color(original_color);
|
|
}
|
|
};
|