CScriptCallback.h 2.1 KB

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