CAdventureOptions.cpp 1.9 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 "CAdventureOptions.h"
  12. #include "CAdvMapInt.h"
  13. #include "../CGameInfo.h"
  14. #include "../CPlayerInterface.h"
  15. #include "../lobby/CCampaignInfoScreen.h"
  16. #include "../lobby/CScenarioInfoScreen.h"
  17. #include "../gui/CGuiHandler.h"
  18. #include "../widgets/Buttons.h"
  19. #include "../../CCallback.h"
  20. #include "../../lib/StartInfo.h"
  21. CAdventureOptions::CAdventureOptions()
  22. : CWindowObject(PLAYER_COLORED, "ADVOPTS")
  23. {
  24. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  25. viewWorld = std::make_shared<CButton>(Point(24, 23), "ADVVIEW.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_v);
  26. viewWorld->addCallback(std::bind(&CPlayerInterface::viewWorldMap, LOCPLINT));
  27. exit = std::make_shared<CButton>(Point(204, 313), "IOK6432.DEF", CButton::tooltip(), std::bind(&CAdventureOptions::close, this), SDLK_RETURN);
  28. exit->assignedKeys.insert(SDLK_ESCAPE);
  29. scenInfo = std::make_shared<CButton>(Point(24, 198), "ADVINFO.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_i);
  30. scenInfo->addCallback(CAdventureOptions::showScenarioInfo);
  31. puzzle = std::make_shared<CButton>(Point(24, 81), "ADVPUZ.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_p);
  32. puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT));
  33. dig = std::make_shared<CButton>(Point(24, 139), "ADVDIG.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_d);
  34. if(const CGHeroInstance *h = adventureInt->curHero())
  35. dig->addCallback(std::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h));
  36. else
  37. dig->block(true);
  38. }
  39. void CAdventureOptions::showScenarioInfo()
  40. {
  41. if(LOCPLINT->cb->getStartInfo()->campState)
  42. {
  43. GH.pushIntT<CCampaignInfoScreen>();
  44. }
  45. else
  46. {
  47. GH.pushIntT<CScenarioInfoScreen>();
  48. }
  49. }