CScriptCallback.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "../global.h"
  3. #include <vector>
  4. #include "../client/FunctionList.h"
  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. struct YesNoDialog;
  22. class CScriptCallback
  23. {
  24. CScriptCallback(void);
  25. public:
  26. ~CScriptCallback(void);
  27. CGameHandler *gh;
  28. //get info
  29. static int3 getPos(CGObjectInstance * ob);
  30. int getHeroOwner(int heroID);
  31. int getResource(int player, int which);
  32. int getSelectedHero();
  33. int getDate(int mode=0);
  34. const CGObjectInstance* getObj(int objid);
  35. const CGHeroInstance* getHero(int objid);
  36. const CGTownInstance* getTown(int objid);
  37. //do sth
  38. void removeObject(int objid);
  39. void setBlockVis(int objid, bool bv);
  40. void setOwner(int objid, ui8 owner);
  41. void setHoverName(int objid, MetaString * name);
  42. void changePrimSkill(int ID, int which, int val, bool abs=false);
  43. void showInfoDialog(InfoWindow *iw);
  44. void showYesNoDialog(YesNoDialog *iw, const CFunctionList<void(ui32)> &callback);
  45. void showSelectionDialog(SelectionDialog *iw, const CFunctionList<void(ui32)> &callback); //returns question id
  46. void giveResource(int player, int which, int val);
  47. void showCompInfo(ShowInInfobox * comp);
  48. void heroVisitCastle(int obj, int heroID);
  49. void stopHeroVisitCastle(int obj, int heroID);
  50. void giveHeroArtifact(int artid, int hid, int position); //pos==-1 - first free slot in backpack
  51. void startBattle(const CCreatureSet * army1, const CCreatureSet * army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2); //use hero=NULL for no hero
  52. void startBattle(int heroID, CCreatureSet army, int3 tile); //for hero<=>neutral army
  53. //friends
  54. friend class CGameHandler;
  55. };
  56. class CLuaCallback : public CScriptCallback
  57. {
  58. private:
  59. static void registerFuncs(lua_State * L);
  60. static int getPos(lua_State * L);//(CGObjectInstance * object);
  61. static int changePrimSkill(lua_State * L);//(int ID, int which, int val);
  62. static int getGnrlText(lua_State * L);//(int ID, int which, int val);
  63. static int getSelectedHero(lua_State * L);//()
  64. friend class CGameHandler;
  65. };