Did a full code review to identify things to fix and either fixed them or noted BUG where I should come back.

This commit is contained in:
Zed A. Shaw 2024-12-04 21:43:59 -05:00
parent ae43dad499
commit 9abb39a3bf
14 changed files with 72 additions and 35 deletions

10
gui.cpp
View file

@ -179,6 +179,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();
} else if(event.type == sf::Event::KeyPressed) {
@ -209,8 +210,11 @@ bool GUI::handle_ui_events() {
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?
// 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?
$status_ui.$component->OnEvent(Event::Mouse("", mev));
}
}
@ -230,8 +234,8 @@ void GUI::run_systems() {
void GUI::shake() {
for(int i = 0; i < 10; ++i) {
int x = Random::uniform<int>(-20,20);
int y = Random::uniform<int>(-20,20);
int x = Random::uniform<int>(-10,10);
int y = Random::uniform<int>(-10,10);
// add x/y back to draw screen
$renderer.draw($map_view, x, y);
$renderer.display();