AdventureOptions.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "../../lib/texts/CGeneralTextHandler.h"
  24. AdventureOptions::AdventureOptions()
  25. : CWindowObject(PLAYER_COLORED, ImagePath::builtin("ADVOPTS"))
  26. {
  27. OBJECT_CONSTRUCTION;
  28. viewWorld = std::make_shared<CButton>(Point(24, 23), AnimationPath::builtin("ADVVIEW.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_WORLD);
  29. viewWorld->addCallback([] { LOCPLINT->viewWorldMap(); });
  30. puzzle = std::make_shared<CButton>(Point(24, 81), AnimationPath::builtin("ADVPUZ.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_PUZZLE);
  31. puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT));
  32. dig = std::make_shared<CButton>(Point(24, 139), AnimationPath::builtin("ADVDIG.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_DIG_GRAIL);
  33. if(const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero())
  34. dig->addCallback(std::bind(&CPlayerInterface::tryDigging, LOCPLINT, h));
  35. else
  36. dig->block(true);
  37. scenInfo = std::make_shared<CButton>(Point(24, 198), AnimationPath::builtin("ADVINFO.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_VIEW_SCENARIO);
  38. scenInfo->addCallback(AdventureOptions::showScenarioInfo);
  39. replay = std::make_shared<CButton>(Point(24, 257), AnimationPath::builtin("ADVTURN.DEF"), CButton::tooltip(), [&](){ close(); }, EShortcut::ADVENTURE_REPLAY_TURN);
  40. replay->addCallback([]{ LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.replayOpponentTurnNotImplemented")); });
  41. exit = std::make_shared<CButton>(Point(203, 313), AnimationPath::builtin("IOK6432.DEF"), CButton::tooltip(), std::bind(&AdventureOptions::close, this), EShortcut::GLOBAL_RETURN);
  42. }
  43. void AdventureOptions::showScenarioInfo()
  44. {
  45. if(LOCPLINT->cb->getStartInfo()->campState)
  46. {
  47. GH.windows().createAndPushWindow<CCampaignInfoScreen>();
  48. }
  49. else
  50. {
  51. GH.windows().createAndPushWindow<CScenarioInfoScreen>();
  52. }
  53. }