2008-07-30 20:51:19 +03:00
# pragma once
# include "../global.h"
# include <vector>
2008-09-12 11:51:46 +03:00
# include <set>
2008-08-22 15:21:09 +03:00
# include "../client/FunctionList.h"
2008-07-30 20:51:19 +03:00
class CVCMIServer ;
class CGameHandler ;
class SComponent ;
class CSelectableComponent ;
class IChosen ;
class CCreatureSet ;
class CGHeroInstance ;
class CGObjectInstance ;
class CGHeroInstance ;
class CGTownInstance ;
class CGameState ;
struct lua_State ;
struct MetaString ;
2008-07-31 00:27:15 +03:00
struct InfoWindow ;
2008-08-04 18:56:36 +03:00
struct ShowInInfobox ;
2008-08-13 03:44:31 +03:00
struct SelectionDialog ;
2008-08-22 15:21:09 +03:00
struct YesNoDialog ;
2008-09-12 11:51:46 +03:00
struct BattleResult ;
2008-07-30 20:51:19 +03:00
class CScriptCallback
{
CScriptCallback ( void ) ;
public :
~ CScriptCallback ( void ) ;
CGameHandler * gh ;
//get info
static int3 getPos ( CGObjectInstance * ob ) ;
2008-08-26 00:14:00 +03:00
int getOwner ( int heroID ) ;
2008-08-22 15:21:09 +03:00
int getResource ( int player , int which ) ;
2008-07-30 20:51:19 +03:00
int getSelectedHero ( ) ;
int getDate ( int mode = 0 ) ;
const CGObjectInstance * getObj ( int objid ) ;
const CGHeroInstance * getHero ( int objid ) ;
const CGTownInstance * getTown ( int objid ) ;
//do sth
2008-09-12 11:51:46 +03:00
void changeSpells ( int hid , bool give , const std : : set < ui32 > & spells ) ;
2008-08-13 07:41:11 +03:00
void removeObject ( int objid ) ;
2008-07-30 20:51:19 +03:00
void setBlockVis ( int objid , bool bv ) ;
void setOwner ( int objid , ui8 owner ) ;
void setHoverName ( int objid , MetaString * name ) ;
2008-08-04 18:56:36 +03:00
void changePrimSkill ( int ID , int which , int val , bool abs = false ) ;
2008-07-31 00:27:15 +03:00
void showInfoDialog ( InfoWindow * iw ) ;
2008-08-22 15:21:09 +03:00
void showYesNoDialog ( YesNoDialog * iw , const CFunctionList < void ( ui32 ) > & callback ) ;
void showSelectionDialog ( SelectionDialog * iw , const CFunctionList < void ( ui32 ) > & callback ) ; //returns question id
2008-07-30 20:51:19 +03:00
void giveResource ( int player , int which , int val ) ;
2008-08-04 18:56:36 +03:00
void showCompInfo ( ShowInInfobox * comp ) ;
2008-07-30 20:51:19 +03:00
void heroVisitCastle ( int obj , int heroID ) ;
void stopHeroVisitCastle ( int obj , int heroID ) ;
2008-09-29 00:01:49 +03:00
void giveHeroArtifact ( int artid , int hid , int position ) ; //pos==-1 - first free slot in backpack; pos==-2 - default if available or backpack
2008-09-12 11:51:46 +03:00
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
void startBattle ( int heroID , CCreatureSet army , int3 tile , boost : : function < void ( BattleResult * ) > cb ) ; //for hero<=>neutral army
2008-09-20 21:30:37 +03:00
void setAmount ( int objid , ui32 val ) ;
2008-09-23 13:58:54 +03:00
void moveHero ( int hid , int3 pos , bool instant ) ;
2008-07-30 20:51:19 +03:00
//friends
friend class CGameHandler ;
} ;
class CLuaCallback : public CScriptCallback
{
private :
static void registerFuncs ( lua_State * L ) ;
static int getPos ( lua_State * L ) ; //(CGObjectInstance * object);
static int changePrimSkill ( lua_State * L ) ; //(int ID, int which, int val);
static int getGnrlText ( lua_State * L ) ; //(int ID, int which, int val);
static int getSelectedHero ( lua_State * L ) ; //()
friend class CGameHandler ;
} ;