Example #1
0
bool AppWarmux::CheckInactive(SDL_Event& evnt)
{
#ifdef MAEMO
  Osso::Process();
#endif

#ifdef HAVE_HANDHELD
#  define CHECK_STATE(e) e.type==SDL_ACTIVEEVENT
#else
#  define CHECK_STATE(e) e.type==SDL_ACTIVEEVENT && e.active.state&SDL_APPACTIVE
#endif

  if (CHECK_STATE(evnt) && evnt.active.gain == 0) {
    PAUSE_LOG("Pause: entering, state=%X\n", evnt.active.state);
    JukeBox::GetInstance()->CloseDevice();
    GameTime::GetInstance()->SetWaitingForUser(true);

    Action a(Action::ACTION_ANNOUNCE_PAUSE);
    Network::GetInstance()->SendActionToAll(a);

    while (SDL_WaitEvent(&evnt)) {
#ifdef MAEMO
      Osso::Process();
#endif
      if (evnt.type == SDL_QUIT) AppWarmux::EmergencyExit();
      if (evnt.type == SDL_ACTIVEEVENT && evnt.active.gain == 1) {
        PAUSE_LOG("Active: state=%X\n", evnt.active.state);
        if ((!menu || choice != MainMenu::NONE) && GameIsRunning()) {
          PAUSE_LOG("Pause: menu=%p\n", menu);
          choice = MainMenu::NONE;
          bool exit = false;
          // There shouldn't be any other menu set, right?
          menu = new PauseMenu(exit);
          menu->Run();
          delete menu;
          menu = NULL;
          if (exit)
            Game::GetInstance()->UserAsksForEnd();
        }

        JukeBox::GetInstance()->OpenDevice();
        JukeBox::GetInstance()->NextMusic();
        GameTime::GetInstance()->SetWaitingForUser(false);

        break;
      }

      PAUSE_LOG("Dropping event %u\n", evnt.type);
    }
    return true;
  }
  return false;
}
Example #2
0
// the loop routine runs over and over again forever:
void loop()
{
	if (GameIsRunning())
	{
		WaitForGameToExit();
		PrintLonelyText();
	}
	else
	{
		DoLonelyModeLoop();
	}
}
Example #3
0
void AppWarmux::DisplayError(const std::string &msg)
{
  std::cerr << msg << std::endl;

  if (GameIsRunning()) {
    if (Game::GetCurrentMenu()) {
      Game::GetCurrentMenu()->DisplayError(msg);
    }
    // nothing to do
  } else if (singleton->GetCurrentMenu()) {
    singleton->GetCurrentMenu()->DisplayError(msg);
  }
}
Example #4
0
void AppWarmux::ReceiveMsgCallback(const std::string& msg, const Color& color, bool in_game)
{
  if (Replay::GetConstInstance()->IsPlaying() && in_game) {
    Game::GetInstance()->chatsession.NewMessage(msg, color);
  } else if (GameIsRunning()) {
    if (Game::GetCurrentMenu() && !in_game) {
      // Drop message, we should be paused anyway
    } else {
      // Add message to chat session in Game
      Game::GetInstance()->chatsession.NewMessage(msg, color);
    }
  } else if (GetCurrentMenu()) {
    GetCurrentMenu()->ReceiveMsgCallback(msg, color);
  }
}
Example #5
0
void AppWarmux::RefreshDisplay()
{
  if (GameIsRunning()) {
    if (Game::GetCurrentMenu()) {
      Game::GetCurrentMenu()->RedrawMenu();
      return;
    } else {
      GetWorld().DrawSky(true);
      GetWorld().Draw(true);
    }
  }
  else if (GetCurrentMenu()) {
    GetCurrentMenu()->RedrawMenu();
  }
}