AdventureOptions.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * CAdventureOptions.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "AdventureOptions.h"
  12. #include "../CGameInfo.h"
  13. #include "../CPlayerInterface.h"
  14. #include "../PlayerLocalState.h"
  15. #include "../lobby/CCampaignInfoScreen.h"
  16. #include "../lobby/CScenarioInfoScreen.h"
  17. #include "../gui/CGuiHandler.h"
  18. #include "../gui/Shortcut.h"
  19. #include "../widgets/Buttons.h"
  20. #include "../../CCallback.h"
  21. #include "../../lib/StartInfo.h"
  22. AdventureOptions::AdventureOptions()
  23. : CWindowObject(PLAYER_COLORED, "ADVOPTS")
  24. {
  25. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  26. viewWorld = std::make_shared<CButton>(Point(24, 23), "ADVVIEW.DEF", CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_WORLD);
  27. viewWorld->addCallback( [] { LOCPLINT->viewWorldMap(); });
  28. exit = std::make_shared<CButton>(Point(204, 313), "IOK6432.DEF", CButton::tooltip(), std::bind(&AdventureOptions::close, this), EShortcut::GLOBAL_RETURN);
  29. scenInfo = std::make_shared<CButton>(Point(24, 198), "ADVINFO.DEF", CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_SCENARIO);
  30. scenInfo->addCallback(AdventureOptions::showScenarioInfo);
  31. puzzle = std::make_shared<CButton>(Point(24, 81), "ADVPUZ.DEF", CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_PUZZLE);
  32. puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT));
  33. dig = std::make_shared<CButton>(Point(24, 139), "ADVDIG.DEF", CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_DIG_GRAIL);
  34. if(const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero())
  35. dig->addCallback(std::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h));
  36. else
  37. dig->block(true);
  38. }
  39. void AdventureOptions::showScenarioInfo()
  40. {
  41. if(LOCPLINT->cb->getStartInfo()->campState)
  42. {
  43. GH.pushIntT<CCampaignInfoScreen>();
  44. }
  45. else
  46. {
  47. GH.pushIntT<CScenarioInfoScreen>();
  48. }
  49. }