CGameInterface.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * CGameInterface.h, 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. #pragma once
  11. #include "CBattleGameInterface.h"
  12. #include "IGameEventsReceiver.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class BattleStateInfoForRetreat;
  15. struct ObjectPosInfo;
  16. class CCallback;
  17. class CCommanderInstance;
  18. using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
  19. /// Central class for managing human player / AI interface logic
  20. class DLL_LINKAGE CGameInterface : public CBattleGameInterface, public IGameEventsReceiver
  21. {
  22. public:
  23. virtual ~CGameInterface() = default;
  24. virtual void initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB){};
  25. virtual void yourTurn(QueryID askID){}; //called AFTER playerStartsTurn(player)
  26. //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
  27. virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)=0;
  28. virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)=0;
  29. // Show a dialog, player must take decision. If selection then he has to choose between one of given components,
  30. // if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called
  31. // with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
  32. virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel, bool safeToAutoaccept) = 0;
  33. // all stacks operations between these objects become allowed, interface has to call onEnd when done
  34. virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) = 0;
  35. virtual void showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) = 0;
  36. virtual void showMapObjectSelectDialog(QueryID askID, const Component & icon, const MetaString & title, const MetaString & description, const std::vector<ObjectInstanceID> & objects) = 0;
  37. virtual void finish(){}; //if for some reason we want to end
  38. virtual void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions, bool showTerrain){};
  39. virtual std::optional<BattleAction> makeSurrenderRetreatDecision(const BattleID & battleID, const BattleStateInfoForRetreat & battleState) = 0;
  40. /// Invalidates and destroys all paths for all heroes
  41. virtual void invalidatePaths(){};
  42. };
  43. VCMI_LIB_NAMESPACE_END