Skip to content

Commit

Permalink
Cleaned up some function names in MenuManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Aug 8, 2014
1 parent 3370e84 commit a5e3e67
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/control/keyboard_manager.cpp
Expand Up @@ -76,7 +76,7 @@ KeyboardManager::process_key_event(const SDL_KeyboardEvent& event)
// if console is open: send key there
process_console_key_event(event);
}
else if (MenuManager::instance().current())
else if (MenuManager::instance().is_active())
{
// if menu mode: send key there
process_menu_key_event(event);
Expand Down
14 changes: 7 additions & 7 deletions src/gui/menu.cpp
Expand Up @@ -69,10 +69,10 @@ Menu::~Menu()
{
MenuManager::instance().m_all_menus.remove(this);

if (MenuManager::instance().current() == this)
if (MenuManager::instance().m_current == this)
MenuManager::instance().m_current = nullptr;

if (MenuManager::instance().get_previous() == this)
if (MenuManager::instance().m_previous == this)
MenuManager::instance().m_previous = nullptr;
}

Expand Down Expand Up @@ -630,13 +630,13 @@ Menu::draw(DrawingContext& context)
{
if (close)
{
menu_width = (MenuManager::instance().current()->get_width() * (1.0f - effect_progress));
menu_height = (MenuManager::instance().current()->get_height() * (1.0f - effect_progress));
menu_width *= 1.0f - effect_progress;
menu_height *= 1.0f - effect_progress;
}
else if (MenuManager::instance().get_previous())
else if (MenuManager::instance().m_previous)
{
menu_width = (menu_width * effect_progress) + (MenuManager::instance().get_previous()->get_width() * (1.0f - effect_progress));
menu_height = (menu_height * effect_progress) + (MenuManager::instance().get_previous()->get_height() * (1.0f - effect_progress));
menu_width = (menu_width * effect_progress) + (MenuManager::instance().m_previous->get_width() * (1.0f - effect_progress));
menu_height = (menu_height * effect_progress) + (MenuManager::instance().m_previous->get_height() * (1.0f - effect_progress));
//std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
}
else
Expand Down
10 changes: 5 additions & 5 deletions src/gui/menu_manager.hpp
Expand Up @@ -52,15 +52,15 @@ class MenuManager

void recalc_pos();

Menu* get_previous()
/** Return the current active menu or NULL if none is active */
Menu* current() const
{
return m_previous;
return m_current;
}

/** Return the current active menu or NULL if none is active */
Menu* current()
bool is_active() const
{
return m_current;
return m_current != nullptr;
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/game_session.cpp
Expand Up @@ -436,7 +436,7 @@ GameSession::update(float elapsed_time)
}

// Unpause the game if the menu has been closed
if (game_pause && !MenuManager::instance().current()) {
if (game_pause && !MenuManager::instance().is_active()) {
g_screen_manager->set_speed(speed_before_pause);
game_pause = false;
}
Expand Down
16 changes: 8 additions & 8 deletions src/supertux/screen_manager.cpp
Expand Up @@ -139,8 +139,8 @@ ScreenManager::draw(DrawingContext& context)
static int frame_count = 0;

current_screen->draw(context);
if(MenuManager::instance().current() != NULL)
MenuManager::instance().current()->draw(context);
if(m_menu_manager->current() != NULL)
m_menu_manager->current()->draw(context);
if(screen_fade.get() != NULL)
screen_fade->draw(context);
Console::instance->draw(context);
Expand Down Expand Up @@ -175,8 +175,8 @@ ScreenManager::update_gamelogic(float elapsed_time)
scripting::update_debugger();
scripting::TimeScheduler::instance->update(game_time);
current_screen->update(elapsed_time);
if (MenuManager::instance().current() != NULL)
MenuManager::instance().current()->update();
if (m_menu_manager->current() != NULL)
m_menu_manager->current()->update();
if(screen_fade.get() != NULL)
screen_fade->update(elapsed_time);
Console::instance->update(elapsed_time);
Expand All @@ -191,8 +191,8 @@ ScreenManager::process_events()
{
g_input_manager->process_event(event);

if(MenuManager::instance().current() != NULL)
MenuManager::instance().current()->event(event);
if(m_menu_manager->current() != NULL)
m_menu_manager->current()->event(event);

switch(event.type)
{
Expand All @@ -206,7 +206,7 @@ ScreenManager::process_events()
case SDL_WINDOWEVENT_RESIZED:
Renderer::instance()->resize(event.window.data1,
event.window.data2);
MenuManager::instance().recalc_pos();
m_menu_manager->recalc_pos();
break;
}
break;
Expand All @@ -220,7 +220,7 @@ ScreenManager::process_events()
{
g_config->use_fullscreen = !g_config->use_fullscreen;
Renderer::instance()->apply_config();
MenuManager::instance().recalc_pos();
m_menu_manager->recalc_pos();
}
else if (event.key.keysym.sym == SDLK_PRINTSCREEN ||
event.key.keysym.sym == SDLK_F12)
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/title_screen.cpp
Expand Up @@ -167,7 +167,7 @@ TitleScreen::update(float elapsed_time)

// reopen menu if user closed it (so that the app doesn't close when user
// accidently hit ESC)
if(MenuManager::instance().current() == 0 && g_screen_manager->has_no_pending_fadeout())
if(!MenuManager::instance().is_active() && g_screen_manager->has_no_pending_fadeout())
{
MenuManager::instance().set_current(main_menu.get());
}
Expand Down
2 changes: 1 addition & 1 deletion src/worldmap/worldmap.cpp
Expand Up @@ -406,7 +406,7 @@ void
WorldMap::on_escape_press()
{
// Show or hide the menu
if(!MenuManager::instance().current()) {
if(!MenuManager::instance().is_active()) {
MenuManager::instance().set_current(worldmap_menu.get());
tux->set_direction(D_NONE); // stop tux movement when menu is called
} else {
Expand Down

0 comments on commit a5e3e67

Please sign in to comment.