Game::menu_t Game::Editor::MainMenu(void) { Display & display = Display::Get(); // preload AGG::Cache::PreloadObject(ICN::EDITOR); AGG::Cache::PreloadObject(ICN::BTNEMAIN); AGG::Cache::PreloadObject(ICN::REDBACK); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Display::SetVideoMode(640, 480, Settings::Get().DisplayFlags()); // image background const Sprite &back = AGG::GetICN(ICN::EDITOR, 0); back.Blit(); const Sprite &panel = AGG::GetICN(ICN::REDBACK, 0); panel.Blit(405, 5); LocalEvent & le = LocalEvent::Get(); Button buttonNewMap(455, 45, ICN::BTNEMAIN, 0, 1); Button buttonLoadMap(455, 110, ICN::BTNEMAIN, 2, 3); Button buttonCancelGame(455, 375, ICN::BTNEMAIN, 4, 5); buttonNewMap.Draw(); buttonLoadMap.Draw(); buttonCancelGame.Draw(); cursor.Show(); display.Flip(); // NewMap loop while(le.HandleEvents()) { le.MousePressLeft(buttonNewMap) ? buttonNewMap.PressDraw() : buttonNewMap.ReleaseDraw(); le.MousePressLeft(buttonLoadMap) ? buttonLoadMap.PressDraw() : buttonLoadMap.ReleaseDraw(); le.MousePressLeft(buttonCancelGame) ? buttonCancelGame.PressDraw() : buttonCancelGame.ReleaseDraw(); if(le.MouseClickLeft(buttonNewMap) || HotKeyPress(EVENT_BUTTON_NEWGAME)) return EDITNEWMAP; if(le.MouseClickLeft(buttonLoadMap) || HotKeyPress(EVENT_BUTTON_LOADGAME)) return EDITLOADMAP; if(le.MouseClickLeft(buttonCancelGame) || HotKeyPress(EVENT_DEFAULT_EXIT)) return QUITGAME; // right info if(le.MousePressRight(buttonNewMap)) Dialog::Message(_("New Map"), _("Create a new map, either from scratch or using the random map generator."), Font::BIG); if(le.MousePressRight(buttonLoadMap)) Dialog::Message(_("Load Map"), _("Load an existing map."), Font::BIG); if(le.MousePressRight(buttonCancelGame)) Dialog::Message(_("Quit"), _("Quit out of the map editor."), Font::BIG); } return QUITGAME; }
Game::menu_t Game::NewNetwork(void) { Settings & conf = Settings::Get(); conf.SetGameType(conf.GameType() | Game::TYPE_NETWORK); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Display & display = Display::Get(); //Settings & conf = Settings::Get(); // image background const Sprite &back = AGG::GetICN(ICN::HEROES, 0); const Point top((display.w() - back.w()) / 2, (display.h() - back.h()) / 2); back.Blit(top); const Sprite &panel = AGG::GetICN(ICN::REDBACK, 0); panel.Blit(top.x + 405, top.y + 5); LocalEvent & le = LocalEvent::Get(); Button buttonHost(top.x + 455, top.y + 45, ICN::BTNNET, 0, 1); Button buttonGuest(top.x + 455, top.y + 110, ICN::BTNNET, 2, 3); Button buttonCancelGame(top.x + 455, top.y + 375, ICN::BTNMP, 8, 9); buttonHost.Draw(); buttonGuest.Draw(); buttonCancelGame.Draw(); cursor.Show(); display.Flip(); // newgame loop while(le.HandleEvents()) { le.MousePressLeft(buttonHost) ? buttonHost.PressDraw() : buttonHost.ReleaseDraw(); le.MousePressLeft(buttonGuest) ? buttonGuest.PressDraw() : buttonGuest.ReleaseDraw(); le.MousePressLeft(buttonCancelGame) ? buttonCancelGame.PressDraw() : buttonCancelGame.ReleaseDraw(); if(le.MouseClickLeft(buttonHost) || HotKeyPress(EVENT_BUTTON_HOST)) return NetworkHost(); if(le.MouseClickLeft(buttonGuest) || HotKeyPress(EVENT_BUTTON_GUEST)) return NetworkGuest(); if(HotKeyPress(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(buttonCancelGame)) return MAINMENU; // right info if(le.MousePressRight(buttonHost)) Dialog::Message(_("Host"), _("The host sets up the game options. There can only be one host per network game."), Font::BIG); if(le.MousePressRight(buttonGuest)) Dialog::Message(_("Guest"), _("The guest waits for the host to set up the game, then is automatically added in. There can be multiple guests for TCP/IP games."), Font::BIG); if(le.MousePressRight(buttonCancelGame)) Dialog::Message(_("Cancel"), _("Cancel back to the main menu."), Font::BIG); } return Game::MAINMENU; }
Game::menu_t Game::NewMulti(void) { Settings & conf = Settings::Get(); if(! (conf.GameType(Game::TYPE_BATTLEONLY))) conf.SetGameType(Game::TYPE_STANDARD); if(conf.QVGA()) return PocketPC::NewMulti(); // preload AGG::PreloadObject(ICN::HEROES); AGG::PreloadObject(ICN::BTNHOTST); AGG::PreloadObject(ICN::REDBACK); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Display & display = Display::Get(); // image background const Sprite &back = AGG::GetICN(ICN::HEROES, 0); const Point top((display.w() - back.w()) / 2, (display.h() - back.h()) / 2); back.Blit(top); const Sprite &panel = AGG::GetICN(ICN::REDBACK, 0); panel.Blit(top.x + 405, top.y + 5); LocalEvent & le = LocalEvent::Get(); Button buttonHotSeat(top.x + 455, top.y + 45, ICN::BTNMP, 0, 1); Button buttonNetwork(top.x + 455, top.y + 110, ICN::BTNMP, 2, 3); Button buttonCancelGame(top.x + 455, top.y + 375, ICN::BTNMP, 8, 9); buttonHotSeat.Draw(); buttonCancelGame.Draw(); #ifdef WITH_NET buttonNetwork.Draw(); #else buttonNetwork.SetDisable(true); #endif cursor.Show(); display.Flip(); // newgame loop while(le.HandleEvents()) { le.MousePressLeft(buttonHotSeat) ? buttonHotSeat.PressDraw() : buttonHotSeat.ReleaseDraw(); le.MousePressLeft(buttonCancelGame) ? buttonCancelGame.PressDraw() : buttonCancelGame.ReleaseDraw(); if(le.MouseClickLeft(buttonHotSeat) || HotKeyPress(EVENT_BUTTON_HOTSEAT)) return NEWHOTSEAT; if(HotKeyPress(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(buttonCancelGame)) return MAINMENU; // right info if(le.MousePressRight(buttonHotSeat)) Dialog::Message(_("Hot Seat"), _("Play a Hot Seat game, where 2 to 4 players play around the same computer, switching into the 'Hot Seat' when it is their turn."), Font::BIG); if(le.MousePressRight(buttonCancelGame)) Dialog::Message(_("Cancel"), _("Cancel back to the main menu."), Font::BIG); if(buttonNetwork.isEnable()) { le.MousePressLeft(buttonNetwork) ? buttonNetwork.PressDraw() : buttonNetwork.ReleaseDraw(); if(le.MouseClickLeft(buttonNetwork) || HotKeyPress(EVENT_BUTTON_NETWORK)) return NEWNETWORK; if(le.MousePressRight(buttonNetwork)) Dialog::Message(_("Network"), _("Play a network game, where 2 players use their own computers connected through a LAN (Local Area Network)."), Font::BIG); } } return QUITGAME; }
Game::menu_t Game::NewGame(void) { Mixer::Pause(); AGG::PlayMusic(MUS::MAINMENU); Settings & conf = Settings::Get(); Game::IO::last_name.clear(); if(Settings::Get().QVGA()) return PocketPC::NewGame(); // preload AGG::PreloadObject(ICN::HEROES); AGG::PreloadObject(ICN::BTNNEWGM); AGG::PreloadObject(ICN::REDBACK); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Display & display = Display::Get(); display.Fill(0); // load game settings conf.BinaryLoad(); // image background const Sprite &back = AGG::GetICN(ICN::HEROES, 0); const Point top((display.w() - back.w()) / 2, (display.h() - back.h()) / 2); back.Blit(top); const Sprite &panel = AGG::GetICN(ICN::REDBACK, 0); panel.Blit(top.x + 405, top.y + 5); LocalEvent & le = LocalEvent::Get(); Button buttonStandartGame(top.x + 455, top.y + 45, ICN::BTNNEWGM, 0, 1); Button buttonMultiGame(top.x + 455, top.y + 110, ICN::BTNNEWGM, 4, 5); Button buttonSettings(top.x + 455, top.y + 240, ICN::BTNDCCFG, 4, 5); Button buttonCancelGame(top.x + 455, top.y + 375, ICN::BTNNEWGM, 6, 7); Button buttonBattleGame(top.x + 455, top.y + 175, ICN::BTNBATTLEONLY, 0, 1); //Button buttonCampainGame(top.x + 455, top.y + 110, ICN::BTNNEWGM, 2, 3); //Button buttonMultiGame(top.x + 455, top.y + 175, ICN::BTNNEWGM, 4, 5); //Button buttonSettings(top.x + 455, top.y + 240, ICN::BTNDCCFG, 4, 5); //Button buttonCancelGame(top.x + 455, top.y + 375, ICN::BTNNEWGM, 6, 7); buttonStandartGame.Draw(); //buttonCampainGame.Draw(); buttonMultiGame.Draw(); buttonCancelGame.Draw(); buttonSettings.Draw(); #ifdef BUILD_BATTLEONLY buttonBattleGame.Draw(); #else buttonBattleGame.SetDisable(true); #endif cursor.Show(); display.Flip(); // newgame loop while(le.HandleEvents()) { le.MousePressLeft(buttonStandartGame) ? buttonStandartGame.PressDraw() : buttonStandartGame.ReleaseDraw(); //le.MousePressLeft(buttonCampainGame) ? buttonCampainGame.PressDraw() : buttonCampainGame.ReleaseDraw(); le.MousePressLeft(buttonMultiGame) ? buttonMultiGame.PressDraw() : buttonMultiGame.ReleaseDraw(); le.MousePressLeft(buttonCancelGame) ? buttonCancelGame.PressDraw() : buttonCancelGame.ReleaseDraw(); le.MousePressLeft(buttonSettings) ? buttonSettings.PressDraw() : buttonSettings.ReleaseDraw(); buttonBattleGame.isEnable() && le.MousePressLeft(buttonBattleGame) ? buttonBattleGame.PressDraw() : buttonBattleGame.ReleaseDraw(); if(HotKeyPress(EVENT_BUTTON_STANDARD) || le.MouseClickLeft(buttonStandartGame)) return NEWSTANDARD; //if(HotKeyPress(EVENT_BUTTON_CAMPAIN) || le.MouseClickLeft(buttonCampainGame)) return NEWCAMPAIN; if(HotKeyPress(EVENT_BUTTON_MULTI) || le.MouseClickLeft(buttonMultiGame)) return NEWMULTI; if(HotKeyPress(EVENT_BUTTON_SETTINGS) || le.MouseClickLeft(buttonSettings)){ Dialog::ExtSettings(false); cursor.Show(); display.Flip(); } if(HotKeyPress(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(buttonCancelGame)) return MAINMENU; if(buttonBattleGame.isEnable()) if(HotKeyPress(EVENT_BUTTON_BATTLEONLY) || le.MouseClickLeft(buttonBattleGame)) return NEWBATTLEONLY; // right info if(le.MousePressRight(buttonStandartGame)) Dialog::Message(_("Standard Game"), _("A single player game playing out a single map."), Font::BIG); //if(le.MousePressRight(buttonCampainGame)) Dialog::Message(_("Campaign Game"), _("A single player game playing through a series of maps."), Font::BIG); if(le.MousePressRight(buttonMultiGame)) Dialog::Message(_("Multi-Player Game"), _("A multi-player game, with several human players completing against each other on a single map."), Font::BIG); if(le.MousePressRight(buttonSettings)) Dialog::Message(_("Settings"), _("FHeroes2 game settings."), Font::BIG); if(le.MousePressRight(buttonCancelGame)) Dialog::Message(_("Cancel"), _("Cancel back to the main menu."), Font::BIG); } return QUITGAME; }
Game::menu_t Game::ScenarioInfo(void) { Settings & conf = Settings::Get(); AGG::PlayMusic(MUS::MAINMENU); MapsFileInfoList lists; if(!PrepareMapsFileInfoList(lists, (conf.GameType(Game::TYPE_MULTI)))) { Dialog::Message(_("Warning"), _("No maps available!"), Font::BIG, Dialog::OK); return MAINMENU; } menu_t result = QUITGAME; LocalEvent & le = LocalEvent::Get(); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Display & display = Display::Get(); Point top, pointDifficultyInfo, pointOpponentInfo, pointClassInfo; Rect rectPanel; Button* buttonSelectMaps = NULL; Button* buttonOk = NULL; Button* buttonCancel = NULL; // vector coord difficulty Rects coordDifficulty; coordDifficulty.reserve(5); const Sprite & ngextra = AGG::GetICN(ICN::NGEXTRA, 62); Dialog::FrameBorder* frameborder = NULL; // image background if(conf.QVGA()) { const u16 window_w = 380; const u16 window_h = 224; frameborder = new Dialog::FrameBorder(); frameborder->SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder->Redraw(); rectPanel = frameborder->GetArea(); pointDifficultyInfo = Point(rectPanel.x + 4, rectPanel.y + 24); pointOpponentInfo = Point(rectPanel.x + 4, rectPanel.y + 94); pointClassInfo = Point(rectPanel.x + 4, rectPanel.y + 148); coordDifficulty.push_back(Rect(rectPanel.x + 1, rectPanel.y + 21, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 78, rectPanel.y + 21, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 154, rectPanel.y + 21, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 231, rectPanel.y + 21, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 308, rectPanel.y + 21, ngextra.w(), ngextra.h())); buttonOk = new Button(rectPanel.x + rectPanel.w / 2 - 160, rectPanel.y + rectPanel.h - 30, ICN::NGEXTRA, 66, 67); buttonCancel = new Button(rectPanel.x + rectPanel.w / 2 + 60, rectPanel.y + rectPanel.h - 30, ICN::NGEXTRA, 68, 69); const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0); background.Blit(Rect(0, 0, window_w, window_h), rectPanel); Text text; text.Set(conf.CurrentFileInfo().name, Font::BIG); text.Blit(rectPanel.x + (rectPanel.w - text.w()) / 2, rectPanel.y + 5); } else { const Sprite &panel = AGG::GetICN(ICN::NGHSBKG, 0); const Sprite &back = AGG::GetICN(ICN::HEROES, 0); const Point top((display.w() - back.w()) / 2, (display.h() - back.h()) / 2); rectPanel = Rect(top.x + 204, top.y + 32, panel.w(), panel.h()); pointDifficultyInfo = Point(rectPanel.x + 24, rectPanel.y + 93); pointOpponentInfo = Point(rectPanel.x + 24, rectPanel.y + 202); pointClassInfo = Point(rectPanel.x + 24, rectPanel.y + 282); coordDifficulty.push_back(Rect(rectPanel.x + 21, rectPanel.y + 91, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 98, rectPanel.y + 91, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 174, rectPanel.y + 91, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 251, rectPanel.y + 91, ngextra.w(), ngextra.h())); coordDifficulty.push_back(Rect(rectPanel.x + 328, rectPanel.y + 91, ngextra.w(), ngextra.h())); buttonSelectMaps = new Button(rectPanel.x + 309, rectPanel.y + 45, ICN::NGEXTRA, 64, 65); buttonOk = new Button(rectPanel.x + 31, rectPanel.y + 380, ICN::NGEXTRA, 66, 67); buttonCancel = new Button(rectPanel.x + 287, rectPanel.y + 380, ICN::NGEXTRA, 68, 69); back.Blit(top); } const bool reset_starting_settings = conf.MapsFile().empty() || ! IsFile(conf.MapsFile()); Players & players = conf.GetPlayers(); Interface::PlayersInfo playersInfo(true, !conf.QVGA(), !conf.QVGA()); // set first maps settings if(reset_starting_settings) conf.SetCurrentFileInfo(lists.front()); playersInfo.UpdateInfo(players, pointOpponentInfo, pointClassInfo); RedrawScenarioStaticInfo(rectPanel); RedrawDifficultyInfo(pointDifficultyInfo, !conf.QVGA()); playersInfo.RedrawInfo(); TextSprite* rating = conf.QVGA() ? NULL : new TextSprite(); if(rating) { rating->SetFont(Font::BIG); rating->SetPos(rectPanel.x + 166, rectPanel.y + 383); RedrawRatingInfo(*rating); } SpriteCursor levelCursor(ngextra); switch(conf.GameDifficulty()) { case Difficulty::EASY: levelCursor.Move(coordDifficulty[0]); break; case Difficulty::NORMAL: levelCursor.Move(coordDifficulty[1]); break; case Difficulty::HARD: levelCursor.Move(coordDifficulty[2]); break; case Difficulty::EXPERT: levelCursor.Move(coordDifficulty[3]); break; case Difficulty::IMPOSSIBLE: levelCursor.Move(coordDifficulty[4]); break; } levelCursor.Show(); if(buttonSelectMaps) buttonSelectMaps->Draw(); buttonOk->Draw(); buttonCancel->Draw(); cursor.Show(); display.Flip(); while(le.HandleEvents()) { // press button if(buttonSelectMaps) le.MousePressLeft(*buttonSelectMaps) ? buttonSelectMaps->PressDraw() : buttonSelectMaps->ReleaseDraw(); le.MousePressLeft(*buttonOk) ? buttonOk->PressDraw() : buttonOk->ReleaseDraw(); le.MousePressLeft(*buttonCancel) ? buttonCancel->PressDraw() : buttonCancel->ReleaseDraw(); // click select if(buttonSelectMaps && (Game::HotKeyPress(Game::EVENT_BUTTON_SELECT) || le.MouseClickLeft(*buttonSelectMaps))) { const Maps::FileInfo* fi = Dialog::SelectScenario(lists); if(fi) { conf.SetCurrentFileInfo(*fi); playersInfo.UpdateInfo(players, pointOpponentInfo, pointClassInfo); cursor.Hide(); levelCursor.Hide(); RedrawScenarioStaticInfo(rectPanel); RedrawDifficultyInfo(pointDifficultyInfo, !conf.QVGA()); playersInfo.RedrawInfo(); if(rating) RedrawRatingInfo(*rating); // default difficulty normal levelCursor.Move(coordDifficulty[1]); levelCursor.Show(); conf.SetGameDifficulty(Difficulty::NORMAL); buttonOk->Draw(); buttonCancel->Draw(); } cursor.Show(); display.Flip(); } else // click cancel if(HotKeyPress(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(*buttonCancel)) { result = MAINMENU; break; } else // click ok if(HotKeyPress(EVENT_DEFAULT_READY) || le.MouseClickLeft(*buttonOk)) { DEBUG(DBG_GAME, DBG_INFO, "select maps: " << conf.MapsFile() << \ ", difficulty: " << Difficulty::String(conf.GameDifficulty())); result = STARTGAME; break; } else if(le.MouseClickLeft(rectPanel)) { const s32 index = coordDifficulty.GetIndex(le.GetMouseCursor()); // select difficulty if(0 <= index) { cursor.Hide(); levelCursor.Move(coordDifficulty[index]); conf.SetGameDifficulty(index); if(rating) RedrawRatingInfo(*rating); cursor.Show(); display.Flip(); } else // playersInfo if(playersInfo.QueueEventProcessing()) { cursor.Hide(); RedrawScenarioStaticInfo(rectPanel); levelCursor.Redraw(); RedrawDifficultyInfo(pointDifficultyInfo, !conf.QVGA()); playersInfo.RedrawInfo(); if(rating) RedrawRatingInfo(*rating); buttonOk->Draw(); buttonCancel->Draw(); cursor.Show(); display.Flip(); } } if(le.MousePressRight(rectPanel)) { if(buttonSelectMaps && le.MousePressRight(*buttonSelectMaps)) Dialog::Message(_("Scenario"), _("Click here to select which scenario to play."), Font::BIG); else if(0 <= coordDifficulty.GetIndex(le.GetMouseCursor())) Dialog::Message(_("Game Difficulty"), _("This lets you change the starting difficulty at which you will play. Higher difficulty levels start you of with fewer resources, and at the higher settings, give extra resources to the computer."), Font::BIG); else if(rating && le.MousePressRight(rating->GetRect())) Dialog::Message(_("Difficulty Rating"), _("The difficulty rating reflects a combination of various settings for your game. This number will be applied to your final score."), Font::BIG); else if(le.MousePressRight(*buttonOk)) Dialog::Message(_("OK"), _("Click to accept these settings and start a new game."), Font::BIG); else if(le.MousePressRight(*buttonCancel)) Dialog::Message(_("Cancel"), _("Click to return to the main menu."), Font::BIG); else playersInfo.QueueEventProcessing(); } } cursor.Hide(); if(result == STARTGAME) { players.SetStartGame(); if(conf.ExtGameUseFade()) display.Fade(); Game::ShowLoadMapsText(); // Load maps world.LoadMaps(conf.MapsFile()); } if(frameborder) delete frameborder; if(rating) delete rating; if(buttonSelectMaps) delete buttonSelectMaps; delete buttonOk; delete buttonCancel; return result; }