CGameInterface.h 2.8 KB

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