diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index 72f84b560..25cfcce45 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -243,6 +243,9 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro luaScript.registerFunction(networkShowMessageForFaction, "networkShowMessageForFaction"); luaScript.registerFunction(networkShowMessageForTeam, "networkShowMessageForTeam"); + luaScript.registerFunction(networkSetCameraPositionForFaction, "networkSetCameraPositionForFaction"); + luaScript.registerFunction(networkSetCameraPositionForTeam, "networkSetCameraPositionForTeam"); + luaScript.registerFunction(showMessage, "showMessage"); luaScript.registerFunction(setDisplayText, "setDisplayText"); luaScript.registerFunction(addConsoleText, "addConsoleText"); @@ -827,6 +830,26 @@ void ScriptManager::networkShowMessageForTeam(const string &text, const string & onMessageBoxOk(false); } +void ScriptManager::networkSetCameraPositionForFaction(int factionIndex, const Vec2i &pos) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + ScriptManager_STREFLOP_Wrapper streflopWrapper; + + if(factionIndex == this->world->getThisFactionIndex()) { + gameCamera->centerXZ(pos.x, pos.y); + } +} + +void ScriptManager::networkSetCameraPositionForTeam(int teamIndex, const Vec2i &pos) { + if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + ScriptManager_STREFLOP_Wrapper streflopWrapper; + + if(teamIndex == this->world->getThisTeamIndex()) { + gameCamera->centerXZ(pos.x, pos.y); + } +} + void ScriptManager::showMessage(const string &text, const string &header){ ScriptManager_STREFLOP_Wrapper streflopWrapper; @@ -1600,6 +1623,19 @@ int ScriptManager::networkShowMessageForTeam(LuaHandle* luaHandle){ return luaArguments.getReturnCount(); } +int ScriptManager::networkSetCameraPositionForFaction(LuaHandle* luaHandle){ + LuaArguments luaArguments(luaHandle); + thisScriptManager->networkSetCameraPositionForFaction(luaArguments.getInt(-2), luaArguments.getVec2i(-1)); + return luaArguments.getReturnCount(); +} + +int ScriptManager::networkSetCameraPositionForTeam(LuaHandle* luaHandle){ + LuaArguments luaArguments(luaHandle); + thisScriptManager->networkSetCameraPositionForTeam(luaArguments.getInt(-2), luaArguments.getVec2i(-1)); + return luaArguments.getReturnCount(); +} + + int ScriptManager::setDisplayText(LuaHandle* luaHandle){ LuaArguments luaArguments(luaHandle); thisScriptManager->setDisplayText(luaArguments.getString(-1)); diff --git a/source/glest_game/game/script_manager.h b/source/glest_game/game/script_manager.h index 0f5980736..7fc1e06fb 100644 --- a/source/glest_game/game/script_manager.h +++ b/source/glest_game/game/script_manager.h @@ -241,6 +241,9 @@ private: void networkShowMessageForFaction(const string &text, const string &header,int factionIndex); void networkShowMessageForTeam(const string &text, const string &header,int teamIndex); + void networkSetCameraPositionForFaction(int factionIndex, const Vec2i &pos); + void networkSetCameraPositionForTeam(int teamIndex, const Vec2i &pos); + void showMessage(const string &text, const string &header); void clearDisplayText(); void setDisplayText(const string &text); @@ -363,6 +366,9 @@ private: static int networkShowMessageForFaction(LuaHandle* luaHandle); static int networkShowMessageForTeam(LuaHandle* luaHandle); + static int networkSetCameraPositionForFaction(LuaHandle* luaHandle); + static int networkSetCameraPositionForTeam(LuaHandle* luaHandle); + static int showMessage(LuaHandle* luaHandle); static int setDisplayText(LuaHandle* luaHandle); static int addConsoleText(LuaHandle* luaHandle);