A little clean up while I think about how to do this....

main
Zed A. Shaw 6 days ago
parent d36c42038d
commit 88d362d6a5
  1. 27
      gui.cpp

@ -165,43 +165,44 @@ void GUI::handle_world_events() {
}
bool GUI::handle_ui_events() {
using KB = sf::Keyboard;
using MOUSE = sf::Mouse;
bool event_happened = false;
sf::Event event;
auto player = $world.get_the<Player>();
int map_font_size = $renderer.font_size();
auto& player_motion = $world.get<Motion>(player.entity);
while($renderer.poll_event(event)) {
if(event.type == sf::Event::Closed) {
$renderer.close();
} else if(event.type == sf::Event::KeyPressed) {
// ZED: Uh we can just do this...?
auto& player_motion = $world.get<Motion>(player.entity);
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
if(KB::isKeyPressed(KB::Left)) {
player_motion.dx = -1;
event_happened = true;
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
} else if(KB::isKeyPressed(KB::Right)) {
player_motion.dx = 1;
event_happened = true;
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
} else if(KB::isKeyPressed(KB::Up)) {
player_motion.dy = -1;
event_happened = true;
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
} else if(KB::isKeyPressed(KB::Down)) {
player_motion.dy = 1;
event_happened = true;
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Equal)) {
} else if(KB::isKeyPressed(KB::Equal)) {
resize_map(map_font_size + 10);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Hyphen)) {
} else if(KB::isKeyPressed(KB::Hyphen)) {
resize_map(map_font_size - 10);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
} else if(KB::isKeyPressed(KB::S)) {
save_world();
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Tab)) {
} else if(KB::isKeyPressed(KB::Tab)) {
$status_ui.$component->OnEvent(Event::Tab);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Enter)) {
} else if(KB::isKeyPressed(KB::Enter)) {
$status_ui.$component->OnEvent(Event::Return);
}
} else if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
sf::Vector2i pos = sf::Mouse::getPosition($renderer.$window);
} else if(MOUSE::isButtonPressed(MOUSE::Left)) {
sf::Vector2i pos = MOUSE::getPosition($renderer.$window);
Mouse mev;
mev.button = Mouse::Button::Left,
mev.x=pos.x / $renderer.$ui_bounds.width; // this needs to be in...panel coordinates?

Loading…
Cancel
Save