AdventureOptions.cpp 2.6 KB

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