"save game" in ingame menu( I don't know how a quick "load last saved game" ould work from ingame menu :-/ )

This commit is contained in:
Titus Tscharntke 2012-04-13 23:13:02 +00:00
parent 7f0b439d5d
commit ed201fa5d3
2 changed files with 33 additions and 11 deletions

View File

@ -107,6 +107,8 @@ Game::Game() : ProgramState(NULL) {
exitGamePopupMenuIndex = -1;
joinTeamPopupMenuIndex = -1;
pauseGamePopupMenuIndex = -1;
saveGamePopupMenuIndex = -1;
loadGamePopupMenuIndex = -1;
keyboardSetupPopupMenuIndex = -1;
masterserverMode = false;
currentUIState=NULL;
@ -152,6 +154,8 @@ void Game::resetMembers() {
exitGamePopupMenuIndex = -1;
joinTeamPopupMenuIndex = -1;
pauseGamePopupMenuIndex = -1;
saveGamePopupMenuIndex = -1;
loadGamePopupMenuIndex = -1;
keyboardSetupPopupMenuIndex = -1;
currentUIState = NULL;
@ -1119,11 +1123,18 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) {
joinTeamPopupMenuIndex = menuItems.size()-1;
}
if(allowAdminMenuItems == true) {
if(allowAdminMenuItems == true){
menuItems.push_back(lang.get("PauseResumeGame"));
pauseGamePopupMenuIndex = menuItems.size()-1;
}
pauseGamePopupMenuIndex= menuItems.size() - 1;
if(gameSettings.isNetworkGame() == false){
menuItems.push_back(lang.get("SaveGame"));
saveGamePopupMenuIndex= menuItems.size() - 1;
// menuItems.push_back(lang.get("LoadGame"));
// loadGamePopupMenuIndex= menuItems.size() - 1;
}
}
menuItems.push_back(lang.get("Keyboardsetup"));
keyboardSetupPopupMenuIndex = menuItems.size()-1;
menuItems.push_back(lang.get("Cancel"));
@ -1883,6 +1894,9 @@ void Game::mouseDownLeft(int x, int y) {
}
}
}
else if(result.first == saveGamePopupMenuIndex){
saveGame();
}
}
else if(popupMenuSwitchTeams.mouseClick(x, y)) {
//popupMenuSwitchTeams
@ -2590,14 +2604,7 @@ void Game::keyDown(SDL_KeyboardEvent key) {
}
if(isKeyPressed(configKeys.getSDLKey("SaveGame"),key) == true) {
string file = this->saveGame(GameConstants::saveGameFilePattern);
char szBuf[8096]="";
sprintf(szBuf,lang.get("GameSaved","",true).c_str(),file.c_str());
console.addLine(szBuf);
Config &config= Config::getInstance();
config.setString("LastSavedGame",file);
config.save();
saveGame();
}
}
@ -3584,6 +3591,18 @@ void Game::addNetworkCommandToReplayList(NetworkCommand* networkCommand, int wor
}
}
void Game::saveGame(){
string file = this->saveGame(GameConstants::saveGameFilePattern);
char szBuf[8096]="";
Lang &lang= Lang::getInstance();
sprintf(szBuf,lang.get("GameSaved","",true).c_str(),file.c_str());
console.addLine(szBuf);
Config &config= Config::getInstance();
config.setString("LastSavedGame",file);
config.save();
}
string Game::saveGame(string name) {
Config &config= Config::getInstance();
// auto name file if using saved file pattern string

View File

@ -138,6 +138,8 @@ private:
int exitGamePopupMenuIndex;
int joinTeamPopupMenuIndex;
int pauseGamePopupMenuIndex;
int saveGamePopupMenuIndex;
int loadGamePopupMenuIndex;
int keyboardSetupPopupMenuIndex;
GLuint statelist3dMenu;
ProgramState *currentUIState;
@ -182,6 +184,7 @@ public:
bool getPaused();
void setPaused(bool value, bool forceAllowPauseStateChange=false);
void saveGame();
const int getTotalRenderFps() const {return totalRenderFps;}
void toggleTeamColorMarker();