CScriptCallback.h 2.6 KB

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