CScriptCallback.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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
  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. //friends
  58. friend class CGameHandler;
  59. };
  60. class CLuaCallback : public CScriptCallback
  61. {
  62. private:
  63. static void registerFuncs(lua_State * L);
  64. static int getPos(lua_State * L);//(CGObjectInstance * object);
  65. static int changePrimSkill(lua_State * L);//(int ID, int which, int val);
  66. static int getGnrlText(lua_State * L);//(int ID, int which, int val);
  67. static int getSelectedHero(lua_State * L);//()
  68. friend class CGameHandler;
  69. };