Fixed a bunch of random little bugs everywhere.
This commit is contained in:
parent
f946d46936
commit
6b3ce5eb3d
9 changed files with 64 additions and 38 deletions
21
gui.cpp
21
gui.cpp
|
@ -168,6 +168,10 @@ void GUI::handle_world_events() {
|
|||
}
|
||||
}
|
||||
|
||||
void GUI::shutdown() {
|
||||
$renderer.close();
|
||||
}
|
||||
|
||||
bool GUI::handle_ui_events() {
|
||||
using KB = sf::Keyboard;
|
||||
using MOUSE = sf::Mouse;
|
||||
|
@ -179,8 +183,7 @@ bool GUI::handle_ui_events() {
|
|||
|
||||
while($renderer.poll_event(event)) {
|
||||
if(event.type == sf::Event::Closed) {
|
||||
// BUG: This should call a GUI::shutdown so I can do saves and stuff.
|
||||
$renderer.close();
|
||||
shutdown();
|
||||
} else if(event.type == sf::Event::KeyPressed) {
|
||||
|
||||
if(KB::isKeyPressed(KB::Left)) {
|
||||
|
@ -207,14 +210,12 @@ bool GUI::handle_ui_events() {
|
|||
$status_ui.$component->OnEvent(Event::Return);
|
||||
}
|
||||
} else if(MOUSE::isButtonPressed(MOUSE::Left)) {
|
||||
sf::Vector2i pos = MOUSE::getPosition($renderer.$window);
|
||||
Mouse mev;
|
||||
mev.button = Mouse::Button::Left,
|
||||
// BUG: renderer should have a function that handles mouse coordinates
|
||||
// BUG: optionally maybe have it in panel? Seems to work though.
|
||||
mev.x=pos.x / $renderer.$ui_bounds.width;
|
||||
mev.y=pos.y / $renderer.$ui_bounds.height;
|
||||
// BUG: maybe also handle mouse motion events?
|
||||
Point pos = $renderer.mouse_position();
|
||||
Mouse mev{
|
||||
.button=Mouse::Button::Left,
|
||||
.x=int(pos.x), .y=int(pos.y)
|
||||
};
|
||||
|
||||
$status_ui.$component->OnEvent(Event::Mouse("", mev));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue