|
|
|
@ -212,13 +212,22 @@ namespace gui { |
|
|
|
|
fmt::println("END: received event after done: {}", int(ev)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FSM::keyboard() { |
|
|
|
|
while(const auto keyev = $window.pollEvent()) { |
|
|
|
|
if(keyev->is<sf::Event::Closed>()) { |
|
|
|
|
void FSM::keyboard_mouse() { |
|
|
|
|
while(const auto ev = $window.pollEvent()) { |
|
|
|
|
if(ev->is<sf::Event::Closed>()) { |
|
|
|
|
event(Event::QUIT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(const auto* key = keyev->getIf<sf::Event::KeyPressed>()) { |
|
|
|
|
if(const auto* mouse = ev->getIf<sf::Event::MouseButtonPressed>()) { |
|
|
|
|
if(mouse->button == sf::Mouse::Button::Left) { |
|
|
|
|
sf::Vector2f pos = $window.mapPixelToCoords(mouse->position); |
|
|
|
|
$combat_ui.$gui.mouse(pos.x, pos.y); |
|
|
|
|
$status_ui.$gui.mouse(pos.x, pos.y); |
|
|
|
|
$main_ui.mouse(pos.x, pos.y); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(const auto* key = ev->getIf<sf::Event::KeyPressed>()) { |
|
|
|
|
using KEY = sf::Keyboard::Scan; |
|
|
|
|
switch(key->scancode) { |
|
|
|
|
case KEY::W: |
|
|
|
@ -279,15 +288,6 @@ namespace gui { |
|
|
|
|
$window.display(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FSM::mouse() { |
|
|
|
|
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { |
|
|
|
|
sf::Vector2f pos = $window.mapPixelToCoords(sf::Mouse::getPosition($window)); |
|
|
|
|
$combat_ui.$gui.mouse(pos.x, pos.y); |
|
|
|
|
$status_ui.$gui.mouse(pos.x, pos.y); |
|
|
|
|
$main_ui.mouse(pos.x, pos.y); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FSM::run_systems() { |
|
|
|
|
System::enemy_pathing($level); |
|
|
|
|
System::collision($level); |
|
|
|
|