Fix emulator compilation and crash, and implement Monopoly payment modal
This commit is contained in:
@@ -8,11 +8,11 @@ CXXFLAGS = -std=c++17 -Wall
|
||||
# Paths for Homebrew on macOS (Silicon/M1/M2/M3)
|
||||
ifeq ($(OS), Darwin)
|
||||
SFML_DIR = $(shell brew --prefix sfml@2)
|
||||
INCLUDES = -I. -I$(SFML_DIR)/include -I../display -I../fonts -I../games
|
||||
INCLUDES = -I. -I.. -I$(SFML_DIR)/include -I../display -I../fonts -I../games
|
||||
LIBS = -L$(SFML_DIR)/lib -lsfml-graphics -lsfml-window -lsfml-system
|
||||
else
|
||||
# Standard Linux paths
|
||||
INCLUDES = -I. -I../display -I../fonts -I../games
|
||||
INCLUDES = -I. -I.. -I../display -I../fonts -I../games
|
||||
LIBS = -lsfml-graphics -lsfml-window -lsfml-system
|
||||
endif
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,56 @@
|
||||
#pragma once
|
||||
#ifndef INPUT_MANAGER_H
|
||||
#define INPUT_MANAGER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "input_event.h"
|
||||
|
||||
// Minimal stub for emulator build
|
||||
class InputManager {
|
||||
public:
|
||||
bool has_buttons() const { return false; }
|
||||
bool has_touch() const { return false; }
|
||||
|
||||
void get_virtual_button_regions(int* a_rect, int* b_rect) const {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
a_rect[i] = v_button_a[i];
|
||||
b_rect[i] = v_button_b[i];
|
||||
}
|
||||
}
|
||||
void set_virtual_button_regions(int ax, int ay, int aw, int ah, int bx, int by, int bw, int bh) {
|
||||
v_button_a[0] = ax; v_button_a[1] = ay; v_button_a[2] = aw; v_button_a[3] = ah;
|
||||
v_button_b[0] = bx; v_button_b[1] = by; v_button_b[2] = bw; v_button_b[3] = bh;
|
||||
v_buttons_active = true;
|
||||
}
|
||||
void clear_virtual_button_regions() {
|
||||
v_buttons_active = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
v_button_a[i] = 0;
|
||||
v_button_b[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool check_virtual_buttons(int16_t x, int16_t y, InputType& out_type) const {
|
||||
if (!v_buttons_active) return false;
|
||||
|
||||
if (x >= v_button_a[0] && x <= v_button_a[0] + v_button_a[2] &&
|
||||
y >= v_button_a[1] && y <= v_button_a[1] + v_button_a[3]) {
|
||||
out_type = INPUT_BUTTON_0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x >= v_button_b[0] && x <= v_button_b[0] + v_button_b[2] &&
|
||||
y >= v_button_b[1] && y <= v_button_b[1] + v_button_b[3]) {
|
||||
out_type = INPUT_BUTTON_1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
int v_button_a[4] = {0, 0, 0, 0};
|
||||
int v_button_b[4] = {0, 0, 0, 0};
|
||||
bool v_buttons_active = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -64,6 +64,12 @@ int main() {
|
||||
event.x = sfEvent.mouseButton.x;
|
||||
event.y = sfEvent.mouseButton.y;
|
||||
event.valid = true;
|
||||
|
||||
// Check for virtual buttons
|
||||
InputType virtual_type;
|
||||
if (input_manager.check_virtual_buttons(event.x, event.y, virtual_type)) {
|
||||
event.type = virtual_type;
|
||||
}
|
||||
} else if (sfEvent.type == sf::Event::KeyPressed) {
|
||||
if (sfEvent.key.code == sf::Keyboard::Space) {
|
||||
event.type = INPUT_BUTTON_0;
|
||||
|
||||
Reference in New Issue
Block a user