CScriptCallback.h 2.0 KB

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