- added new LUA method togglePauseGame
This commit is contained in:
parent
82e31d670b
commit
4b085691df
|
@ -1279,7 +1279,6 @@ void Game::keyDown(char key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
|
||||||
|
|
||||||
//send key to the chat manager
|
//send key to the chat manager
|
||||||
chatManager.keyDown(key);
|
chatManager.keyDown(key);
|
||||||
|
@ -1352,16 +1351,8 @@ void Game::keyDown(char key) {
|
||||||
}
|
}
|
||||||
//pause
|
//pause
|
||||||
else if(key == configKeys.getCharKey("PauseGame")) {
|
else if(key == configKeys.getCharKey("PauseGame")) {
|
||||||
if(speedChangesAllowed){
|
//printf("Toggle pause paused = %d\n",paused);
|
||||||
if(paused){
|
setPaused(!paused);
|
||||||
console.addLine(lang.get("GameResumed"));
|
|
||||||
paused= false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
console.addLine(lang.get("GamePaused"));
|
|
||||||
paused= true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//switch display color
|
//switch display color
|
||||||
else if(key == configKeys.getCharKey("ChangeFontColor")) {
|
else if(key == configKeys.getCharKey("ChangeFontColor")) {
|
||||||
|
@ -1369,12 +1360,14 @@ void Game::keyDown(char key) {
|
||||||
}
|
}
|
||||||
//increment speed
|
//increment speed
|
||||||
else if(key == configKeys.getCharKey("GameSpeedIncrease")) {
|
else if(key == configKeys.getCharKey("GameSpeedIncrease")) {
|
||||||
|
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||||
if(speedChangesAllowed){
|
if(speedChangesAllowed){
|
||||||
incSpeed();
|
incSpeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//decrement speed
|
//decrement speed
|
||||||
else if(key == configKeys.getCharKey("GameSpeedDecrease")) {
|
else if(key == configKeys.getCharKey("GameSpeedDecrease")) {
|
||||||
|
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||||
if(speedChangesAllowed){
|
if(speedChangesAllowed){
|
||||||
decSpeed();
|
decSpeed();
|
||||||
}
|
}
|
||||||
|
@ -1993,6 +1986,23 @@ void Game::decSpeed() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::setPaused(bool value) {
|
||||||
|
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||||
|
//printf("Toggle pause value = %d, speedChangesAllowed = %d\n",value,speedChangesAllowed);
|
||||||
|
|
||||||
|
if(speedChangesAllowed) {
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
if(value == false) {
|
||||||
|
console.addLine(lang.get("GameResumed"));
|
||||||
|
paused= false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.addLine(lang.get("GamePaused"));
|
||||||
|
paused= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Game::getUpdateLoops() {
|
int Game::getUpdateLoops() {
|
||||||
if(paused) {
|
if(paused) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -133,6 +133,8 @@ public:
|
||||||
World *getWorld() {return &world;}
|
World *getWorld() {return &world;}
|
||||||
const World *getWorld() const {return &world;}
|
const World *getWorld() const {return &world;}
|
||||||
|
|
||||||
|
bool getPaused() const { return paused;}
|
||||||
|
void setPaused(bool value);
|
||||||
const int getTotalRenderFps() const {return totalRenderFps;}
|
const int getTotalRenderFps() const {return totalRenderFps;}
|
||||||
//init
|
//init
|
||||||
virtual void load(LoadGameItem loadTypes);
|
virtual void load(LoadGameItem loadTypes);
|
||||||
|
|
|
@ -89,6 +89,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
|
||||||
luaScript.registerFunction(playStreamingSound, "playStreamingSound");
|
luaScript.registerFunction(playStreamingSound, "playStreamingSound");
|
||||||
luaScript.registerFunction(stopStreamingSound, "stopStreamingSound");
|
luaScript.registerFunction(stopStreamingSound, "stopStreamingSound");
|
||||||
luaScript.registerFunction(stopAllSound, "stopAllSound");
|
luaScript.registerFunction(stopAllSound, "stopAllSound");
|
||||||
|
luaScript.registerFunction(togglePauseGame, "togglePauseGame");
|
||||||
luaScript.registerFunction(giveResource, "giveResource");
|
luaScript.registerFunction(giveResource, "giveResource");
|
||||||
luaScript.registerFunction(givePositionCommand, "givePositionCommand");
|
luaScript.registerFunction(givePositionCommand, "givePositionCommand");
|
||||||
luaScript.registerFunction(giveProductionCommand, "giveProductionCommand");
|
luaScript.registerFunction(giveProductionCommand, "giveProductionCommand");
|
||||||
|
@ -456,6 +457,12 @@ void ScriptManager::stopAllSound() {
|
||||||
world->stopAllSound();
|
world->stopAllSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptManager::togglePauseGame(int pauseStatus) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] pauseStatus = %d\n",__FILE__,__FUNCTION__,__LINE__,pauseStatus);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
world->togglePauseGame((pauseStatus != 0));
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptManager::morphToUnit(int unitId,const string &morphName, int ignoreRequirements) {
|
void ScriptManager::morphToUnit(int unitId,const string &morphName, int ignoreRequirements) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] forceUpgradesIfRequired = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),ignoreRequirements);
|
SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] forceUpgradesIfRequired = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),ignoreRequirements);
|
||||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
@ -909,6 +916,12 @@ int ScriptManager::stopAllSound(LuaHandle* luaHandle) {
|
||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::togglePauseGame(LuaHandle* luaHandle) {
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] value = %d\n",__FILE__,__FUNCTION__,__LINE__,luaArguments.getInt(-1));
|
||||||
|
thisScriptManager->togglePauseGame(luaArguments.getInt(-1));
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
int ScriptManager::giveResource(LuaHandle* luaHandle){
|
int ScriptManager::giveResource(LuaHandle* luaHandle){
|
||||||
LuaArguments luaArguments(luaHandle);
|
LuaArguments luaArguments(luaHandle);
|
||||||
thisScriptManager->giveResource(luaArguments.getString(-3), luaArguments.getInt(-2), luaArguments.getInt(-1));
|
thisScriptManager->giveResource(luaArguments.getString(-3), luaArguments.getInt(-2), luaArguments.getInt(-1));
|
||||||
|
|
|
@ -185,6 +185,7 @@ private:
|
||||||
void playStreamingSound(const string &playSound);
|
void playStreamingSound(const string &playSound);
|
||||||
void stopStreamingSound(const string &playSound);
|
void stopStreamingSound(const string &playSound);
|
||||||
void stopAllSound();
|
void stopAllSound();
|
||||||
|
void togglePauseGame(int pauseStatus);
|
||||||
|
|
||||||
void giveResource(const string &resourceName, int factionIndex, int amount);
|
void giveResource(const string &resourceName, int factionIndex, int amount);
|
||||||
void givePositionCommand(int unitId, const string &producedName, const Vec2i &pos);
|
void givePositionCommand(int unitId, const string &producedName, const Vec2i &pos);
|
||||||
|
@ -250,6 +251,7 @@ private:
|
||||||
static int playStreamingSound(LuaHandle* luaHandle);
|
static int playStreamingSound(LuaHandle* luaHandle);
|
||||||
static int stopStreamingSound(LuaHandle* luaHandle);
|
static int stopStreamingSound(LuaHandle* luaHandle);
|
||||||
static int stopAllSound(LuaHandle* luaHandle);
|
static int stopAllSound(LuaHandle* luaHandle);
|
||||||
|
static int togglePauseGame(LuaHandle* luaHandle);
|
||||||
|
|
||||||
static int giveResource(LuaHandle* luaHandle);
|
static int giveResource(LuaHandle* luaHandle);
|
||||||
static int givePositionCommand(LuaHandle* luaHandle);
|
static int givePositionCommand(LuaHandle* luaHandle);
|
||||||
|
|
|
@ -935,6 +935,10 @@ void World::moveToUnit(int unitId, int destUnitId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::togglePauseGame(bool pauseStatus) {
|
||||||
|
game->setPaused(pauseStatus);
|
||||||
|
}
|
||||||
|
|
||||||
void World::giveUpgradeCommand(int unitId, const string &upgradeName) {
|
void World::giveUpgradeCommand(int unitId, const string &upgradeName) {
|
||||||
Unit *unit= findUnitById(unitId);
|
Unit *unit= findUnitById(unitId);
|
||||||
if(unit != NULL) {
|
if(unit != NULL) {
|
||||||
|
|
|
@ -202,6 +202,7 @@ public:
|
||||||
void stopStreamingSound(const string &playSound);
|
void stopStreamingSound(const string &playSound);
|
||||||
void stopAllSound();
|
void stopAllSound();
|
||||||
void moveToUnit(int unitId, int destUnitId);
|
void moveToUnit(int unitId, int destUnitId);
|
||||||
|
void togglePauseGame(bool pauseStatus);
|
||||||
|
|
||||||
void giveResource(const string &resourceName, int factionIndex, int amount);
|
void giveResource(const string &resourceName, int factionIndex, int amount);
|
||||||
int getResourceAmount(const string &resourceName, int factionIndex);
|
int getResourceAmount(const string &resourceName, int factionIndex);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user