CScriptCallback.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "../global.h"
  3. #include <vector>
  4. class CVCMIServer;
  5. class CGameHandler;
  6. class SComponent;
  7. class CSelectableComponent;
  8. class IChosen;
  9. class CCreatureSet;
  10. class CGHeroInstance;
  11. class CGObjectInstance;
  12. class CGHeroInstance;
  13. class CGTownInstance;
  14. class CGameState;
  15. struct lua_State;
  16. struct MetaString;
  17. struct InfoWindow;
  18. struct ShowInInfobox;
  19. class CScriptCallback
  20. {
  21. CScriptCallback(void);
  22. public:
  23. ~CScriptCallback(void);
  24. CGameHandler *gh;
  25. //get info
  26. static int3 getPos(CGObjectInstance * ob);
  27. int getHeroOwner(int heroID);
  28. int getSelectedHero();
  29. int getDate(int mode=0);
  30. const CGObjectInstance* getObj(int objid);
  31. const CGHeroInstance* getHero(int objid);
  32. const CGTownInstance* getTown(int objid);
  33. //do sth
  34. void setBlockVis(int objid, bool bv);
  35. void setOwner(int objid, ui8 owner);
  36. void setHoverName(int objid, MetaString * name);
  37. void changePrimSkill(int ID, int which, int val, bool abs=false);
  38. void showInfoDialog(InfoWindow *iw);
  39. void showSelDialog(int player, std::string text, std::vector<CSelectableComponent*>*components, IChosen * asker);
  40. void giveResource(int player, int which, int val);
  41. void showCompInfo(ShowInInfobox * comp);
  42. void heroVisitCastle(int obj, int heroID);
  43. void stopHeroVisitCastle(int obj, int heroID);
  44. void giveHeroArtifact(int artid, int hid, int position); //pos==-1 - first free slot in backpack
  45. void startBattle(const CCreatureSet * army1, const CCreatureSet * army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2); //use hero=NULL for no hero
  46. void startBattle(int heroID, CCreatureSet army, int3 tile); //for hero<=>neutral army
  47. //friends
  48. friend class CGameHandler;
  49. };
  50. class CLuaCallback : public CScriptCallback
  51. {
  52. private:
  53. static void registerFuncs(lua_State * L);
  54. static int getPos(lua_State * L);//(CGObjectInstance * object);
  55. static int changePrimSkill(lua_State * L);//(int ID, int which, int val);
  56. static int getGnrlText(lua_State * L);//(int ID, int which, int val);
  57. static int getSelectedHero(lua_State * L);//()
  58. friend class CGameHandler;
  59. };