int main() { nana::gui::form form(nana::gui::API::make_center(400, 300)); nana::gui::listbox listbox(form, nana::rectangle(10, 10, 380, 200)); listbox.append_header(STR("Column 1"), 100); listbox.append_header(STR("Column 2"), 100); listbox.append_header(STR("Column 3"), 100); listbox.append_item(STR("Item 0")); listbox.append_item(STR("Item 1")); listbox.set_item_text(1, 1, STR("subitem")); listbox.set_item_text(1, 2, STR("行1位置2")); listbox.append_categ(STR("Test Category")); listbox.append_item(1, STR("Item 0")); listbox.append_item(1, STR("Item 1")); listbox.append_item(1, STR("Item 2")); listbox.append_item(1, STR("Item 3")); listbox.append_item(1, STR("Item 4")); listbox.append_item(1, STR("Item 5")); listbox.set_item_text(1, 1, 1, STR("索引1位置1")); listbox.set_item_text(1, 3, 2, STR("索引3位置2")); form.show(); nana::gui::exec(); }
Skill::Secondary Dialog::SelectSecondarySkill(void) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> skills(MAXSECONDARYSKILL * 3, 0); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < MAXSECONDARYSKILL * 3; ++ii) skills[ii] = ii; const u16 window_w = 310; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumSecSkill listbox(area); listbox.SetListContent(skills); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } Skill::Secondary skill; if(result == Dialog::OK || listbox.ok) { skill.SetSkill(1 + (listbox.GetCurrent() / 3)); skill.SetLevel(1 + (listbox.GetCurrent() % 3)); } return skill; }
Heroes::heroes_t Dialog::SelectHeroes(Heroes::heroes_t cur) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> heroes(static_cast<int>(Heroes::SANDYSANDY), Heroes::UNKNOWN); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < heroes.size(); ++ii) heroes[ii] = Heroes::ConvertID(ii); const u16 window_w = 240; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumHeroes listbox(area); listbox.SetListContent(heroes); if(cur != Heroes::UNKNOWN) listbox.SetCurrent(static_cast<int>(cur)); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } return result == Dialog::OK || listbox.ok ? Heroes::ConvertID(listbox.GetCurrent()) : Heroes::UNKNOWN; }
Monster Dialog::SelectMonster(u8 id) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> monsters(static_cast<int>(Monster::WATER_ELEMENT), Monster::UNKNOWN); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < monsters.size(); ++ii) monsters[ii] = ii + 1; // skip Monser::UNKNOWN const u16 window_w = 260; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumMonster listbox(area); listbox.SetListContent(monsters); if(id != Monster::UNKNOWN) listbox.SetCurrent(static_cast<int>(id)); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } return result == Dialog::OK || listbox.ok ? Monster(listbox.GetCurrent()) : Monster(Monster::UNKNOWN); }
Spell Dialog::SelectSpell(u8 cur) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> spells(static_cast<int>(Spell::STONE - 1), Spell::NONE); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < spells.size(); ++ii) spells[ii] = ii + 1; const u16 window_w = 340; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumSpell listbox(area); listbox.SetListContent(spells); if(cur != Spell::NONE) listbox.SetCurrent(static_cast<int>(cur)); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } return result == Dialog::OK || listbox.ok ? Spell(listbox.GetCurrent()) : Spell(Spell::NONE); }
int Dialog::SelectHeroes(int cur) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> heroes(static_cast<int>(Heroes::SANDYSANDY), Heroes::UNKNOWN); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < heroes.size(); ++ii) heroes[ii] = ii; Dialog::FrameBorder frameborder(Size(240, 280), AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumHeroes listbox(area); listbox.SetListContent(heroes); if(cur != Heroes::UNKNOWN) listbox.SetCurrent(cur); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); int result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } return result == Dialog::OK || listbox.ok ? listbox.GetCurrent() : Heroes::UNKNOWN; }
void Dialog::ExtSettings(bool readonly) { Display & display = Display::Get(); const Settings & conf = Settings::Get(); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const int window_h = conf.QVGA() ? 224 : 400; Dialog::FrameBorder frameborder(Size(320, window_h)); const Rect & area = frameborder.GetArea(); Text text("FHeroes2 Settings", Font::YELLOW_BIG); text.Blit(area.x + (area.w - text.w()) / 2, area.y + 6); std::vector<u32> states; states.reserve(64); states.push_back(Settings::GAME_SAVE_REWRITE_CONFIRM); states.push_back(Settings::GAME_ALSO_CONFIRM_AUTOSAVE); states.push_back(Settings::GAME_REMEMBER_LAST_FOCUS); states.push_back(Settings::GAME_SHOW_SYSTEM_INFO); states.push_back(Settings::GAME_EVIL_INTERFACE); states.push_back(Settings::GAME_BATTLE_SHOW_GRID); states.push_back(Settings::GAME_BATTLE_SHOW_MOUSE_SHADOW); states.push_back(Settings::GAME_BATTLE_SHOW_MOVE_SHADOW); states.push_back(Settings::GAME_BATTLE_SHOW_DAMAGE); if(! conf.QVGA()) { states.push_back(Settings::GAME_CASTLE_FLASH_BUILDING); states.push_back(Settings::GAME_HIDE_INTERFACE); } if(!conf.PocketPC()) states.push_back(Settings::GAME_DYNAMIC_INTERFACE); states.push_back(Settings::GAME_AUTOSAVE_ON); states.push_back(Settings::GAME_AUTOSAVE_BEGIN_DAY); if(conf.VideoMode().w == 640 && conf.VideoMode().h == 480) states.push_back(Settings::GAME_USE_FADE); #ifdef BUILD_RELEASE states.push_back(Settings::GAME_SHOW_SDL_LOGO); #endif states.push_back(Settings::GAME_CONTINUE_AFTER_VICTORY); states.push_back(Settings::WORLD_SHOW_VISITED_CONTENT); states.push_back(Settings::WORLD_ABANDONED_MINE_RANDOM); states.push_back(Settings::WORLD_SAVE_MONSTER_BATTLE); states.push_back(Settings::WORLD_ALLOW_SET_GUARDIAN); states.push_back(Settings::WORLD_GUARDIAN_TWO_DEFENSE); states.push_back(Settings::WORLD_EXT_OBJECTS_CAPTURED); states.push_back(Settings::WORLD_NOREQ_FOR_ARTIFACTS); states.push_back(Settings::WORLD_SCOUTING_EXTENDED); states.push_back(Settings::WORLD_ARTSPRING_SEPARATELY_VISIT); states.push_back(Settings::WORLD_ARTIFACT_CRYSTAL_BALL); states.push_back(Settings::WORLD_ONLY_FIRST_MONSTER_ATTACK); states.push_back(Settings::WORLD_EYE_EAGLE_AS_SCHOLAR); states.push_back(Settings::WORLD_BAN_WEEKOF); states.push_back(Settings::WORLD_NEW_VERSION_WEEKOF); states.push_back(Settings::WORLD_BAN_PLAGUES); states.push_back(Settings::WORLD_BAN_MONTHOF_MONSTERS); states.push_back(Settings::WORLD_STARTHERO_LOSSCOND4HUMANS); states.push_back(Settings::WORLD_1HERO_HIRED_EVERY_WEEK); states.push_back(Settings::CASTLE_1HERO_HIRED_EVERY_WEEK); states.push_back(Settings::WORLD_DWELLING_ACCUMULATE_UNITS); states.push_back(Settings::WORLD_USE_UNIQUE_ARTIFACTS_ML); states.push_back(Settings::WORLD_USE_UNIQUE_ARTIFACTS_RS); states.push_back(Settings::WORLD_USE_UNIQUE_ARTIFACTS_PS); states.push_back(Settings::WORLD_USE_UNIQUE_ARTIFACTS_SS); states.push_back(Settings::WORLD_DISABLE_BARROW_MOUNDS); states.push_back(Settings::HEROES_BUY_BOOK_FROM_SHRINES); states.push_back(Settings::HEROES_LEARN_SPELLS_WITH_DAY); states.push_back(Settings::HEROES_COST_DEPENDED_FROM_LEVEL); states.push_back(Settings::HEROES_REMEMBER_POINTS_RETREAT); states.push_back(Settings::HEROES_SURRENDERING_GIVE_EXP); states.push_back(Settings::HEROES_RECALCULATE_MOVEMENT); states.push_back(Settings::HEROES_PATROL_ALLOW_PICKUP); states.push_back(Settings::HEROES_AUTO_MOVE_BATTLE_DST); states.push_back(Settings::HEROES_TRANSCRIBING_SCROLLS); states.push_back(Settings::HEROES_ALLOW_BANNED_SECSKILLS); states.push_back(Settings::HEROES_ARENA_ANY_SKILLS); if(! conf.QVGA()) states.push_back(Settings::CASTLE_ALLOW_BUY_FROM_WELL); states.push_back(Settings::CASTLE_ALLOW_GUARDIANS); states.push_back(Settings::CASTLE_MAGEGUILD_POINTS_TURN); states.push_back(Settings::CASTLE_ALLOW_RECRUITS_SPECIAL); states.push_back(Settings::UNIONS_ALLOW_HERO_MEETINGS); states.push_back(Settings::UNIONS_ALLOW_CASTLE_VISITING); states.push_back(Settings::BATTLE_SOFT_WAITING); states.push_back(Settings::BATTLE_OBJECTS_ARCHERS_PENALTY); states.push_back(Settings::BATTLE_MERGE_ARMIES); states.push_back(Settings::BATTLE_ARCHMAGE_RESIST_BAD_SPELL); states.push_back(Settings::BATTLE_MAGIC_TROOP_RESIST); states.push_back(Settings::BATTLE_SKIP_INCREASE_DEFENSE); states.push_back(Settings::BATTLE_REVERSE_WAIT_ORDER); if(conf.PocketPC()) { states.push_back(Settings::POCKETPC_HIDE_CURSOR); states.push_back(Settings::POCKETPC_TAP_MODE); states.push_back(Settings::POCKETPC_LOW_MEMORY); states.push_back(Settings::POCKETPC_DRAG_DROP_SCROLL); #ifdef ANDROID states.push_back(Settings::POCKETPC_LOW_RESOLUTION); #endif } SettingsListBox listbox(area, readonly); const int ah = window_h - 60; listbox.RedrawBackground(area); listbox.SetScrollButtonUp(ICN::DROPLISL, 6, 7, Point(area.x + 295, area.y + 25)); listbox.SetScrollButtonDn(ICN::DROPLISL, 8, 9, Point(area.x + 295, area.y + ah + 5)); listbox.SetScrollSplitter(AGG::GetICN(ICN::DROPLISL, 13), Rect(area.x + 300, area.y + 49, 12, ah - 43)); listbox.SetAreaMaxItems(ah / 40); listbox.SetAreaItems(Rect(area.x + 10, area.y + 30, 290, ah + 5)); listbox.SetListContent(states); listbox.Redraw(); LocalEvent & le = LocalEvent::Get(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); // message loop int result = Dialog::ZERO; while(result == Dialog::ZERO && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } // store if(result == Dialog::OK) { le.SetTapMode(conf.ExtPocketTapMode()); Settings::Get().BinarySave(); } }
Game::menu_t PocketPC::SelectScenario(void) { Settings & conf = Settings::Get(); Cursor & cursor = Cursor::Get(); Display & display = Display::Get(); LocalEvent & le = LocalEvent::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const Sprite &sprite = AGG::GetICN(ICN::HEROES, 0); Rect src_rt((sprite.w() - display.w()) / 2, 0, display.w(), display.h()); sprite.Blit(src_rt, 0, 0); MapsFileInfoList all; if(!PrepareMapsFileInfoList(all, false)) { Dialog::Message(_("Warning"), _("No maps available!"), Font::BIG, Dialog::OK); return Game::MAINMENU; } MapsFileInfoList small; MapsFileInfoList medium; MapsFileInfoList large; MapsFileInfoList xlarge; small.reserve(all.size()); medium.reserve(all.size()); large.reserve(all.size()); xlarge.reserve(all.size()); for(MapsFileInfoList::iterator cur = all.begin(); cur != all.end(); ++ cur) { switch((*cur).size_w) { case Maps::SMALL: small.push_back(*cur); break; case Maps::MEDIUM: medium.push_back(*cur); break; case Maps::LARGE: large.push_back(*cur); break; case Maps::XLARGE: xlarge.push_back(*cur); break; default: continue; } } const u16 window_w = 320; const u16 window_h = 224; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(); const Rect & rt = frameborder.GetArea(); const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0); background.Blit(Rect(0, 0, window_w, window_h), rt); ButtonGroups btnGroups(rt, Dialog::OK|Dialog::CANCEL); Button buttonSelectSmall(rt.x + 7, rt.y + 12, ICN::REQUESTS, 9, 10); Button buttonSelectMedium(rt.x + 69, rt.y + 12, ICN::REQUESTS, 11, 12); Button buttonSelectLarge(rt.x + 131, rt.y + 12, ICN::REQUESTS, 13, 14); Button buttonSelectXLarge(rt.x + 193, rt.y + 12, ICN::REQUESTS, 15, 16); Button buttonSelectAll(rt.x + 255, rt.y + 12, ICN::REQUESTS, 17, 18); if(all.empty()) btnGroups.DisableButton1(true); if(small.empty()) buttonSelectSmall.SetDisable(true); if(medium.empty()) buttonSelectMedium.SetDisable(true); if(large.empty()) buttonSelectLarge.SetDisable(true); if(xlarge.empty()) buttonSelectXLarge.SetDisable(true); ScenarioListBox listbox(rt); listbox.RedrawBackground(rt); listbox.SetScrollButtonUp(ICN::REQUESTS, 5, 6, Point(rt.x + 285, rt.y + 40)); listbox.SetScrollButtonDn(ICN::REQUESTS, 7, 8, Point(rt.x + 285, rt.y + 175)); listbox.SetScrollSplitter(AGG::GetICN(ICN::ESCROLL, 3), Rect(rt.x + 288, rt.y + 58, 12, 114)); listbox.SetAreaMaxItems(8); listbox.SetAreaItems(Rect(rt.x + 17, rt.y + 37, 266, 156)); listbox.SetListContent(all); listbox.Redraw(); btnGroups.Draw(); buttonSelectSmall.Draw(); buttonSelectMedium.Draw(); buttonSelectLarge.Draw(); buttonSelectXLarge.Draw(); buttonSelectAll.Draw(); u16 result = Dialog::ZERO; cursor.Show(); display.Flip(); while(result == Dialog::ZERO && le.HandleEvents()) { le.MousePressLeft(buttonSelectSmall) && buttonSelectSmall.isEnable() ? buttonSelectSmall.PressDraw() : buttonSelectSmall.ReleaseDraw(); le.MousePressLeft(buttonSelectMedium) && buttonSelectMedium.isEnable() ? buttonSelectMedium.PressDraw() : buttonSelectMedium.ReleaseDraw(); le.MousePressLeft(buttonSelectLarge) && buttonSelectLarge.isEnable() ? buttonSelectLarge.PressDraw() : buttonSelectLarge.ReleaseDraw(); le.MousePressLeft(buttonSelectXLarge) && buttonSelectXLarge.isEnable() ? buttonSelectXLarge.PressDraw() : buttonSelectXLarge.ReleaseDraw(); le.MousePressLeft(buttonSelectAll) ? buttonSelectAll.PressDraw() : buttonSelectAll.ReleaseDraw(); result = btnGroups.QueueEventProcessing(); if(((le.MouseClickLeft(buttonSelectSmall) || le.KeyPress(KEY_s)) && buttonSelectSmall.isEnable()) && buttonSelectSmall.isEnable()) { listbox.SetListContent(small); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectMedium) || le.KeyPress(KEY_m)) && buttonSelectMedium.isEnable()) && buttonSelectMedium.isEnable()) { listbox.SetListContent(medium); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectLarge) || le.KeyPress(KEY_l)) && buttonSelectLarge.isEnable()) && buttonSelectLarge.isEnable()) { listbox.SetListContent(large); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectXLarge) || le.KeyPress(KEY_x)) && buttonSelectXLarge.isEnable()) && buttonSelectXLarge.isEnable()) { listbox.SetListContent(xlarge); cursor.Hide(); } else if(le.MouseClickLeft(buttonSelectAll) || le.KeyPress(KEY_a)) { listbox.SetListContent(all); cursor.Hide(); } listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } if(Dialog::OK == result) { conf.SetCurrentFileInfo(listbox.GetCurrent()); conf.SetGameDifficulty(Difficulty::NORMAL); return Game::SCENARIOINFO; } return Game::MAINMENU; }
bool ActionSpellTownPortal(Heroes & hero) { const Kingdom & kingdom = world.GetKingdom(hero.GetColor()); std::vector<s32> castles; Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(KingdomCastles::const_iterator it = kingdom.GetCastles().begin(); it != kingdom.GetCastles().end(); ++it) if(*it && !(*it)->GetHeroes().Guest()) castles.push_back((**it).GetIndex()); if(castles.empty()) { Dialog::Message("", _("No avaialble town. Spell Failed!!!"), Font::BIG, Dialog::OK); return false; } const u16 window_w = 280; const u16 window_h = 200; Dialog::FrameBorder* frameborder = new Dialog::FrameBorder(); frameborder->SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder->Redraw(); const Rect & area = frameborder->GetArea(); const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0); background.Blit(Rect(0, 0, window_w, window_h), area); u16 result = Dialog::ZERO; CastleIndexListBox listbox(area, result); listbox.RedrawBackground(area); listbox.SetScrollButtonUp(ICN::LISTBOX, 3, 4, Point(area.x + 256, area.y + 55)); listbox.SetScrollButtonDn(ICN::LISTBOX, 5, 6, Point(area.x + 256, area.y + 145)); listbox.SetScrollSplitter(AGG::GetICN(ICN::LISTBOX, 10), Rect(area.x + 261, area.y + 78, 14, 64)); listbox.SetAreaMaxItems(5); listbox.SetAreaItems(Rect(area.x + 10, area.y + 60, 250, 100)); listbox.SetListContent(castles); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); while(result == Dialog::ZERO && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } delete frameborder; // store if(result == Dialog::OK) return HeroesTownGate(hero, world.GetCastle(listbox.GetCurrent())); return false; }
const Maps::FileInfo* Dialog::SelectScenario(const MapsFileInfoList & all) { Cursor & cursor = Cursor::Get(); Display & display = Display::Get(); LocalEvent & le = LocalEvent::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const Maps::FileInfo* result = NULL; MapsFileInfoList small; MapsFileInfoList medium; MapsFileInfoList large; MapsFileInfoList xlarge; small.reserve(all.size()); medium.reserve(all.size()); large.reserve(all.size()); xlarge.reserve(all.size()); for(MapsFileInfoList::const_iterator cur = all.begin(); cur != all.end(); ++ cur) { switch((*cur).size_w) { case Maps::SMALL: small.push_back(*cur); break; case Maps::MEDIUM: medium.push_back(*cur); break; case Maps::LARGE: large.push_back(*cur); break; case Maps::XLARGE: xlarge.push_back(*cur); break; default: continue; } } const Sprite & panel = AGG::GetICN(ICN::REQSBKG, 0); Background back((display.w() - panel.w()) / 2, (display.h() - panel.h()) / 2, panel.w(), panel.h()); back.Save(); const Rect & rt = back.GetRect(); const Rect countPlayers(rt.x + 45, rt.y + 55, 20, 175); const Rect sizeMaps(rt.x + 62, rt.y + 55, 20, 175); const Rect victoryConds(rt.x + 267, rt.y + 55, 20, 175); const Rect lossConds(rt.x + 287, rt.y + 55, 20, 175); const Rect curCountPlayer(rt.x + 66, rt.y + 264, 18, 18); const Rect curMapSize(rt.x + 85, rt.y + 264, 18, 18); const Rect curMapName(rt.x + 107, rt.y + 264, 166, 18); const Rect curVictoryCond(rt.x + 277, rt.y + 264, 18, 18); const Rect curLossCond(rt.x + 295, rt.y + 264, 18, 18); const Rect curDifficulty(rt.x + 220, rt.y + 292, 114, 20); const Rect curDescription(rt.x + 42, rt.y + 316, 292, 90); Button buttonOk(rt.x + 140, rt.y + 410, ICN::REQUESTS, 1, 2); Button buttonSelectSmall(rt.x + 37, rt.y + 22, ICN::REQUESTS, 9, 10); Button buttonSelectMedium(rt.x + 99, rt.y + 22, ICN::REQUESTS, 11, 12); Button buttonSelectLarge(rt.x + 161, rt.y + 22, ICN::REQUESTS, 13, 14); Button buttonSelectXLarge(rt.x + 223, rt.y + 22, ICN::REQUESTS, 15, 16); Button buttonSelectAll(rt.x + 285, rt.y + 22, ICN::REQUESTS, 17, 18); if(small.empty()) buttonSelectSmall.SetDisable(true); if(medium.empty()) buttonSelectMedium.SetDisable(true); if(large.empty()) buttonSelectLarge.SetDisable(true); if(xlarge.empty()) buttonSelectXLarge.SetDisable(true); ScenarioListBox listbox(rt); listbox.RedrawBackground(rt); listbox.SetScrollButtonUp(ICN::REQUESTS, 5, 6, Point(rt.x + 327, rt.y + 55)); listbox.SetScrollButtonDn(ICN::REQUESTS, 7, 8, Point(rt.x + 327, rt.y + 217)); listbox.SetScrollSplitter(AGG::GetICN(ICN::ESCROLL, 3), Rect(rt.x + 330, rt.y + 73, 12, 141)); listbox.SetAreaMaxItems(9); listbox.SetAreaItems(Rect(rt.x + 55, rt.y + 55, 270, 175)); listbox.SetListContent(const_cast<MapsFileInfoList &>(all)); listbox.Redraw(); buttonOk.Draw(); buttonSelectSmall.Draw(); buttonSelectMedium.Draw(); buttonSelectLarge.Draw(); buttonSelectXLarge.Draw(); buttonSelectAll.Draw(); cursor.Show(); display.Flip(); while(le.HandleEvents()) { if(buttonOk.isEnable()) le.MousePressLeft(buttonOk) ? buttonOk.PressDraw() : buttonOk.ReleaseDraw(); le.MousePressLeft(buttonSelectSmall) && buttonSelectSmall.isEnable() ? buttonSelectSmall.PressDraw() : buttonSelectSmall.ReleaseDraw(); le.MousePressLeft(buttonSelectMedium) && buttonSelectMedium.isEnable() ? buttonSelectMedium.PressDraw() : buttonSelectMedium.ReleaseDraw(); le.MousePressLeft(buttonSelectLarge) && buttonSelectLarge.isEnable() ? buttonSelectLarge.PressDraw() : buttonSelectLarge.ReleaseDraw(); le.MousePressLeft(buttonSelectXLarge) && buttonSelectXLarge.isEnable() ? buttonSelectXLarge.PressDraw() : buttonSelectXLarge.ReleaseDraw(); le.MousePressLeft(buttonSelectAll) ? buttonSelectAll.PressDraw() : buttonSelectAll.ReleaseDraw(); if((buttonOk.isEnable() && le.MouseClickLeft(buttonOk)) || Game::HotKeyPress(Game::EVENT_DEFAULT_READY) || listbox.selectOk) { MapsFileInfoList::const_iterator it = std::find(all.begin(), all.end(), listbox.GetCurrent()); result = it != all.end() ? &(*it) : NULL; break; } else if(Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT)) { result = NULL; break; } else if(((le.MouseClickLeft(buttonSelectSmall) || le.KeyPress(KEY_s)) && buttonSelectSmall.isEnable()) && buttonSelectSmall.isEnable()) { listbox.SetListContent(small); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectMedium) || le.KeyPress(KEY_m)) && buttonSelectMedium.isEnable()) && buttonSelectMedium.isEnable()) { listbox.SetListContent(medium); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectLarge) || le.KeyPress(KEY_l)) && buttonSelectLarge.isEnable()) && buttonSelectLarge.isEnable()) { listbox.SetListContent(large); cursor.Hide(); } else if(((le.MouseClickLeft(buttonSelectXLarge) || le.KeyPress(KEY_x)) && buttonSelectXLarge.isEnable()) && buttonSelectXLarge.isEnable()) { listbox.SetListContent(xlarge); cursor.Hide(); } else if(le.MouseClickLeft(buttonSelectAll) || le.KeyPress(KEY_a)) { listbox.SetListContent(const_cast<MapsFileInfoList &>(all)); cursor.Hide(); } listbox.QueueEventProcessing(); // right info if(le.MousePressRight(buttonSelectSmall)) Dialog::Message(_("Small Maps"), _("View only maps of size small (36x36)."), Font::BIG); else if(le.MousePressRight(buttonSelectMedium)) Dialog::Message(_("Medium Maps"), _("View only maps of size medium (72x72)."), Font::BIG); else if(le.MousePressRight(buttonSelectLarge)) Dialog::Message(_("Large Maps"), _("View only maps of size large (108x108)."), Font::BIG); else if(le.MousePressRight(buttonSelectXLarge)) Dialog::Message(_("Extra Large Maps"), _("View only maps of size extra large (144x144)."), Font::BIG); else if(le.MousePressRight(buttonSelectAll)) Dialog::Message(_("All Maps"), _("View all maps, regardless of size."), Font::BIG); else if(le.MousePressRight(countPlayers) || le.MousePressRight(curCountPlayer)) Dialog::Message(_("Players Icon"), _("Indicates how many players total are in the EditScenario. Any positions not occupied by humans will be occupied by computer players."), Font::BIG); else if(le.MousePressRight(sizeMaps) || le.MousePressRight(curMapSize)) Dialog::Message(_("Size Icon"), _("Indicates whether the maps is small (36x36), medium (72x72), large (108x108), or extra large (144x144)."), Font::BIG); else if(le.MousePressRight(curMapName)) Dialog::Message(_("Selected Name"), _("The name of the currently selected map."), Font::BIG); else if(le.MousePressRight(victoryConds)) { const Maps::FileInfo* item = listbox.GetFromPosition(le.GetMouseCursor()); if(item) VictoryConditionInfo(*item); } else if(le.MousePressRight(lossConds)) { const Maps::FileInfo* item = listbox.GetFromPosition(le.GetMouseCursor()); if(item) LossConditionInfo(*item); } else if(le.MousePressRight(curVictoryCond)) VictoryConditionInfo(listbox.GetCurrent()); else if(le.MousePressRight(curLossCond)) LossConditionInfo(listbox.GetCurrent()); else if(le.MousePressRight(curDifficulty)) Dialog::Message(_("Selected Map Difficulty"), _("The map difficulty of the currently selected map. The map difficulty is determined by the EditScenario designer. More difficult maps might include more or stronger enemies, fewer resources, or other special conditions making things tougher for the human player."), Font::BIG); else if(le.MousePressRight(curDescription)) Dialog::Message(_("Selected Description"), _("The description of the currently selected map."), Font::BIG); else if(le.MousePressRight(buttonOk)) Dialog::Message(_("OK"), _("Accept the choice made."), Font::BIG); if(!cursor.isVisible()) { listbox.Redraw(); buttonOk.Draw(); buttonSelectSmall.Draw(); buttonSelectMedium.Draw(); buttonSelectLarge.Draw(); buttonSelectXLarge.Draw(); buttonSelectAll.Draw(); cursor.Show(); display.Flip(); } } cursor.Hide(); back.Restore(); return result; }