Example #1
0
static void OnQuickStartButton()
{
  SetGameMode(AMJU_MODE_NONE);
  static PlayerInfoManager* pim = ThePlayerInfoManager::Instance();
  PlayerInfo* pi = pim->GetPI();
  Assert(pi);
  std::string email = pi->PIGetString(PI_KEY("email"));
  TheGSLoginWaiting::Instance()->SetEmail(email);
  TheGame::Instance()->SetCurrentState(TheGSLoginWaiting::Instance());
}
Example #2
0
void GSTitle::OnActive()
{
  static bool first = true;
  if (first)
  {
    first = false;

    TheAvatarManager::Instance()->Load();

    // Set default keyboard layout
    KbSetLayout(KB_LAYOUT_REGULAR);

    TheGSOptions::Instance()->LoadFromConfig();
  }

  // Kill off any dummy player object
  TheGame::Instance()->ClearGameObjects();

#ifdef SHOW_FRAME_TIME
  Font* font = (Font*)TheResourceManager::Instance()->GetRes("font2d/arial-font.font");
  TheGame::Instance()->SetFrameTimeFont(font);
#endif

  GSGui::OnActive();

  if (!m_titleImage.OpenAndLoad("title-bgimage.txt"))
  {
std::cout << "Failed to load GUI title bg image!\n";
    Assert(0);
  }

  m_gui = LoadGui("gui-title.txt");
  Assert(m_gui);

  GuiButton* start = (GuiButton*)GetElementByName(m_gui, "start-button");
  start->SetCommand(Amju::OnStartButton);
  start->SetHasFocus(true); 

  GuiButton* options = (GuiButton*)GetElementByName(m_gui, "options-button");
  options->SetCommand(Amju::OnOptionsButton);

  GuiButton* quick = (GuiButton*)GetElementByName(m_gui, "quick-start-button");
  static PlayerInfoManager* pim = ThePlayerInfoManager::Instance();
  if (pim->GetNumPlayerNames() > 0)
  {
    quick->SetVisible(true);
    quick->SetCommand(Amju::OnQuickStartButton);
    quick->SetHasFocus(true);

    // Change button text to player name
    Strings names = pim->GetPlayerNames();
    Assert(!names.empty());
    pim->SetCurrentPlayer(names[0]);
    PlayerInfo* pi = pim->GetPI();
    Assert(pi);
    std::string playername = pi->PIGetString(PI_KEY("playername"));
    quick->SetText(playername);
  }
  else
  {
    quick->SetVisible(false);
  }

  GuiButton* quit = (GuiButton*)GetElementByName(m_gui, "quit-button");
  quit->SetCommand(Amju::OnQuitButton);
  quit->SetIsCancelButton(true);

#ifdef SHOW_VERSION
  GuiText* ver = (GuiText*)GetElementByName(m_gui, "version");
  std::string s = "v." + ToString(VersionMajor) + "." + ToString(VersionMinor);
#ifdef _DEBUG
  s += " DEBUG";
#endif
  ver->SetText(s);
#endif

  //CreateText("my game");

#ifdef PLAY_MUSIC
  TheSoundManager::Instance()->PlaySong(ROConfig()->GetValue("music-title", "Sound/hammers.it"));
#endif
}