int 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; } int 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()) { frameborder = new Dialog::FrameBorder(Size(380, 224)); 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); 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() || ! System::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); } SpriteMove 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; } 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 && (HotKeyPressEvent(Game::EVENT_BUTTON_SELECT) || le.MouseClickLeft(*buttonSelectMaps))) { levelCursor.Hide(); const Maps::FileInfo* fi = Dialog::SelectScenario(lists); if(fi) { conf.SetCurrentFileInfo(*fi); playersInfo.UpdateInfo(players, pointOpponentInfo, pointClassInfo); cursor.Hide(); RedrawScenarioStaticInfo(rectPanel); RedrawDifficultyInfo(pointDifficultyInfo, !conf.QVGA()); playersInfo.RedrawInfo(); if(rating) RedrawRatingInfo(*rating); // default difficulty normal levelCursor.Move(coordDifficulty[1]); conf.SetGameDifficulty(Difficulty::NORMAL); buttonOk->Draw(); buttonCancel->Draw(); } cursor.Show(); display.Flip(); } else // click cancel if(HotKeyPressEvent(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(*buttonCancel)) { result = MAINMENU; break; } else // click ok if(HotKeyPressEvent(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 std::string lower = StringLower(conf.MapsFile()); if(lower.size() > 3) { std::string ext = lower.substr(lower.size() - 3); if(ext == "mp2" || ext == "mx2") result = world.LoadMapMP2(conf.MapsFile()) ? STARTGAME : MAINMENU; else if(ext == "map") result = world.LoadMapMAP(conf.MapsFile()) ? STARTGAME : MAINMENU; } else { result = MAINMENU; DEBUG(DBG_GAME, DBG_WARN, conf.MapsFile() << ", " << "unknown map format"); } } if(frameborder) delete frameborder; if(rating) delete rating; if(buttonSelectMaps) delete buttonSelectMaps; delete buttonOk; delete buttonCancel; return result; }
void Dialog::SecondarySkillInfo(const std::string &header, const std::string &message, const Skill::Secondary::skill_t skill, const Skill::Level::type_t level, const bool ok_button) { Display & display = Display::Get(); const ICN::icn_t system = Settings::Get().EvilInterface() ? ICN::SYSTEME : ICN::SYSTEM; // preload AGG::PreloadObject(system); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); TextBox box1(header, Font::YELLOW_BIG, BOXAREA_WIDTH); TextBox box2(message, Font::BIG, BOXAREA_WIDTH); const Sprite & border = AGG::GetICN(ICN::SECSKILL, 15); const u8 spacer = Settings::Get().QVGA() ? 5 : 10; Box box(box1.h() + spacer + box2.h() + spacer + border.h(), ok_button); Rect pos = box.GetArea(); if(header.size()) box1.Blit(pos); pos.y += box1.h() + spacer; if(message.size()) box2.Blit(pos); pos.y += box2.h() + spacer; // blit sprite pos.x = box.GetArea().x + (pos.w - border.w()) / 2; display.Blit(border, pos.x, pos.y); const Sprite & sprite = AGG::GetICN(ICN::SECSKILL, Skill::Secondary::GetIndexSprite1(skill)); pos.x = box.GetArea().x + (pos.w - sprite.w()) / 2; display.Blit(sprite, pos.x, pos.y + 3); Text text; // small text text.Set(Skill::Secondary::String(skill), Font::SMALL); pos.x = box.GetArea().x + (pos.w - text.w()) / 2; text.Blit(pos.x, pos.y + 3); text.Set(Skill::Level::String(level)); pos.x = box.GetArea().x + (pos.w - text.w()) / 2; text.Blit(pos.x, pos.y + 55); LocalEvent & le = LocalEvent::Get(); Button *button = NULL; Point pt; if(ok_button) { pt.x = box.GetArea().x + (box.GetArea().w - AGG::GetICN(system, 1).w()) / 2; pt.y = box.GetArea().y + box.GetArea().h - AGG::GetICN(system, 1).h(); button = new Button(pt, system, 1, 2); } if(button) (*button).Draw(); cursor.Show(); display.Flip(); // message loop while(le.HandleEvents()) { if(!ok_button && !le.MousePressRight()) break; if(button) le.MousePressLeft(*button) ? button->PressDraw() : button->ReleaseDraw(); if(button && le.MouseClickLeft(*button)) { break; } if(le.KeyPress(KEY_RETURN) || le.KeyPress(KEY_ESCAPE)) { break; } } cursor.Hide(); if(button) delete button; }
void Dialog::SpellInfo(const std::string &header, const std::string &message, const Spell & spell, bool ok_button) { Display & display = Display::Get(); const int system = Settings::Get().ExtGameEvilInterface() ? ICN::SYSTEME : ICN::SYSTEM; // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); TextBox box1(header, Font::YELLOW_BIG, BOXAREA_WIDTH); TextBox box2(message, Font::BIG, BOXAREA_WIDTH); Text text(spell.GetName(), Font::SMALL); const Sprite & sprite = AGG::GetICN(ICN::SPELLS, spell.IndexSprite()); const int spacer = Settings::Get().QVGA() ? 5 : 10; FrameBox box(box1.h() + spacer + box2.h() + spacer + sprite.h() + 2 + text.h(), ok_button); Rect pos = box.GetArea(); if(header.size()) box1.Blit(pos); pos.y += box1.h() + spacer; if(message.size()) box2.Blit(pos); pos.y += box2.h() + spacer; // blit sprite pos.x = box.GetArea().x + (pos.w - sprite.w()) / 2; sprite.Blit(pos.x, pos.y); // small text pos.x = box.GetArea().x + (pos.w - text.w()) / 2; pos.y = pos.y + sprite.h() + 2; text.Blit(pos); LocalEvent & le = LocalEvent::Get(); Button* button = NULL; Point pt; if(ok_button) { pt.x = box.GetArea().x + (box.GetArea().w - AGG::GetICN(system, 1).w()) / 2; pt.y = box.GetArea().y + box.GetArea().h - AGG::GetICN(system, 1).h(); button = new Button(pt.x, pt.y, system, 1, 2); } if(button) (*button).Draw(); cursor.Show(); display.Flip(); // message loop while(le.HandleEvents()) { if(!ok_button && !le.MousePressRight()) break; if(button) le.MousePressLeft(*button) ? button->PressDraw() : button->ReleaseDraw(); if(button && le.MouseClickLeft(*button)){ break; } if(HotKeyCloseWindow){ break; } } cursor.Hide(); if(button) delete button; }