Skip to content

Commit

Permalink
[InterfaceState] Now updates parent. This fixes a problem where clien…
Browse files Browse the repository at this point in the history
…t froze the game when in pause menu or chat.
  • Loading branch information
Unarelith committed Feb 25, 2020
1 parent 7a28b8b commit 27fb5e9
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 17 deletions.
2 changes: 0 additions & 2 deletions client/include/states/ChatState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class ChatState : public InterfaceState {

void onEvent(const SDL_Event &event) override;

void update() override;

private:
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;

Expand Down
2 changes: 2 additions & 0 deletions client/include/states/InterfaceState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class InterfaceState : public gk::ApplicationState {
void setup();
void onEvent(const SDL_Event &event) override;

void update() override;

void prepareDraw(gk::RenderTarget &target, gk::RenderStates &states) const;

bool m_drawBackground = true;
Expand Down
2 changes: 0 additions & 2 deletions client/include/states/PauseMenuState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class PauseMenuState : public InterfaceState {

void onEvent(const SDL_Event &event) override;

void update() override;

private:
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;

Expand Down
2 changes: 0 additions & 2 deletions client/include/states/SettingsMenuState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class SettingsMenuState : public InterfaceState {

void onEvent(const SDL_Event &event) override;

void update() override;

private:
void doneButtonAction();

Expand Down
3 changes: 0 additions & 3 deletions client/source/states/ChatState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ void ChatState::onEvent(const SDL_Event &event) {
}
}

void ChatState::update() {
}

void ChatState::draw(gk::RenderTarget &target, gk::RenderStates states) const {
if (m_parent)
target.draw(*m_parent, states);
Expand Down
5 changes: 5 additions & 0 deletions client/source/states/InterfaceState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void InterfaceState::onEvent(const SDL_Event &event) {
}
}

void InterfaceState::update() {
if (m_parent)
m_parent->update();
}

void InterfaceState::prepareDraw(gk::RenderTarget &target, gk::RenderStates &states) const {
states.transform *= getTransform();
states.shader = &m_shader;
Expand Down
3 changes: 1 addition & 2 deletions client/source/states/LuaGUIState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ void LuaGUIState::onEvent(const SDL_Event &event) {
}

void LuaGUIState::update() {
if (m_parent)
m_parent->update();
InterfaceState::update();

for (auto &it : m_widgets)
it->update();
Expand Down
3 changes: 0 additions & 3 deletions client/source/states/PauseMenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ void PauseMenuState::onEvent(const SDL_Event &event) {
}
}

void PauseMenuState::update() {
}

void PauseMenuState::draw(gk::RenderTarget &target, gk::RenderStates states) const {
if (m_parent)
target.draw(*m_parent, states);
Expand Down
3 changes: 0 additions & 3 deletions client/source/states/SettingsMenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ void SettingsMenuState::onEvent(const SDL_Event &event) {
}
}

void SettingsMenuState::update() {
}

void SettingsMenuState::doneButtonAction() {
if (m_state != MenuState::Main) {
m_state = MenuState::Main;
Expand Down

0 comments on commit 27fb5e9

Please sign in to comment.