AdventureOptions.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/WindowHandler.h"
  19. #include "../gui/Shortcut.h"
  20. #include "../widgets/Buttons.h"
  21. #include "../../CCallback.h"
  22. #include "../../lib/StartInfo.h"
  23. AdventureOptions::AdventureOptions()
  24. : CWindowObject(PLAYER_COLORED, ImagePath::builtin("ADVOPTS"))
  25. {
  26. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  27. viewWorld = std::make_shared<CButton>(Point(24, 23), AnimationPath::builtin("ADVVIEW.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_WORLD);
  28. viewWorld->addCallback( [] { LOCPLINT->viewWorldMap(); });
  29. exit = std::make_shared<CButton>(Point(204, 313), AnimationPath::builtin("IOK6432.DEF"), CButton::tooltip(), std::bind(&AdventureOptions::close, this), EShortcut::GLOBAL_RETURN);
  30. scenInfo = std::make_shared<CButton>(Point(24, 198), AnimationPath::builtin("ADVINFO.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_SCENARIO);
  31. scenInfo->addCallback(AdventureOptions::showScenarioInfo);
  32. puzzle = std::make_shared<CButton>(Point(24, 81), AnimationPath::builtin("ADVPUZ.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_PUZZLE);
  33. puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT));
  34. dig = std::make_shared<CButton>(Point(24, 139), AnimationPath::builtin("ADVDIG.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_DIG_GRAIL);
  35. if(const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero())
  36. dig->addCallback(std::bind(&CPlayerInterface::tryDigging, LOCPLINT, h));
  37. else
  38. dig->block(true);
  39. }
  40. void AdventureOptions::showScenarioInfo()
  41. {
  42. if(LOCPLINT->cb->getStartInfo()->campState)
  43. {
  44. GH.windows().createAndPushWindow<CCampaignInfoScreen>();
  45. }
  46. else
  47. {
  48. GH.windows().createAndPushWindow<CScenarioInfoScreen>();
  49. }
  50. }