CAdventureOptions.cpp 2.0 KB

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