bugfix load setup
This commit is contained in:
parent
cc9c001736
commit
476c398c0c
|
@ -334,6 +334,7 @@ public:
|
|||
|
||||
void pushBackItem(string item, string translated_item="");
|
||||
void clearItems();
|
||||
vector<string> & getItems() {return items;}
|
||||
void setItems(const vector<string> &items, const vector<string> translated_items=vector<string>());
|
||||
void setSelectedItemIndex(int index, bool errorOnMissing=true);
|
||||
void setSelectedItem(string item, bool errorOnMissing=true);
|
||||
|
@ -399,6 +400,7 @@ public:
|
|||
void clearItems();
|
||||
|
||||
GraphicButton* createButton(string item);
|
||||
vector<string> & getItems() {return items;}
|
||||
void setItems(const vector<string> &items, const vector<string> translated_items=vector<string>());
|
||||
void setSelectedItemIndex(int index, bool errorOnMissing=true);
|
||||
void setSelectedItem(string item, bool errorOnMissing=true);
|
||||
|
|
|
@ -475,7 +475,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
labelInfo.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
|
||||
labelWaitingForPlayers.registerGraphicComponent(containerName,"labelInfo");
|
||||
labelWaitingForPlayers.init(30, 100);
|
||||
labelWaitingForPlayers.init(0, networkHeadPos-25);
|
||||
labelWaitingForPlayers.setText("");
|
||||
labelWaitingForPlayers.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelWaitingForPlayers.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
|
@ -1946,8 +1946,8 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||
setupName=replaceAll(setupName,"\\","_");
|
||||
}
|
||||
if( setupName!= lang.getString(LAST_SETUP_STRING)) {
|
||||
string filename=setupName+".mgg";
|
||||
saveGameSettings(SETUPS_DIR+filename);
|
||||
string filename=SETUPS_DIR+setupName+".mgg";
|
||||
saveGameSettings(filename);
|
||||
console.addLine("--> " +filename);
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
|
@ -1961,8 +1961,11 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||
if( setupName== lang.getString(LAST_SETUP_STRING)){
|
||||
fileNameToLoad=HEADLESS_SAVED_SETUP_FILENAME;
|
||||
}
|
||||
if(loadGameSettings(fileNameToLoad))
|
||||
console.addLine("<-- " +setupName+".mgg");
|
||||
if(loadGameSettings(fileNameToLoad)){
|
||||
console.addLine("<-- " +fileNameToLoad);
|
||||
needToBroadcastServerSettings=true;
|
||||
broadcastServerSettingsDelayTimer=time(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( buttonDeleteSetup.mouseClick(x, y)){
|
||||
|
@ -5442,14 +5445,30 @@ bool MenuStateConnectedGame::loadGameSettings(const std::string &fileName) {
|
|||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
||||
bool result=CoreData::getInstance().loadGameSettingsFromFile(fileName,&gameSettings);
|
||||
if(result==false)
|
||||
if(result==false){
|
||||
console.addLine("Cannot load '"+fileName+"'");
|
||||
return false;
|
||||
}
|
||||
if(gameSettings.getMap() == "") {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
copyToGameSettings(&gameSettings);
|
||||
}
|
||||
|
||||
vector<string> mapsV=formattedPlayerSortedMaps[0];
|
||||
if(std::find(mapsV.begin(), mapsV.end(), gameSettings.getMap()) == mapsV.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', map unknown ("+gameSettings.getMap()+")");
|
||||
return false;// map unknown
|
||||
}
|
||||
if(std::find(tilesetFiles.begin(), tilesetFiles.end(), gameSettings.getTileset()) == tilesetFiles.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', tileset unknown ("+gameSettings.getTileset()+")");
|
||||
return false;// tileset unknown
|
||||
}
|
||||
if(std::find(techTreeFiles.begin(), techTreeFiles.end(), gameSettings.getTech()) == techTreeFiles.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', techtree unknown ("+gameSettings.getTech()+")");
|
||||
return false;// techtree unknown
|
||||
}
|
||||
|
||||
setupUIFromGameSettings(&gameSettings, false);
|
||||
|
||||
needToBroadcastServerSettings=true;
|
||||
|
|
|
@ -1264,8 +1264,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
setupName=replaceAll(setupName,"\\","_");
|
||||
}
|
||||
if( setupName!= lang.getString(LAST_SETUP_STRING)) {
|
||||
string filename=setupName+".mgg";
|
||||
saveGameSettings(SETUPS_DIR+filename);
|
||||
string filename=SETUPS_DIR+setupName+".mgg";
|
||||
saveGameSettings(filename);
|
||||
console.addLine("--> " +filename);
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
|
@ -1280,7 +1280,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
fileNameToLoad=SAVED_SETUP_FILENAME;
|
||||
}
|
||||
if(loadGameSettings(fileNameToLoad))
|
||||
console.addLine("<-- " +setupName+".mgg");
|
||||
console.addLine("<-- " +fileNameToLoad);
|
||||
}
|
||||
}
|
||||
else if ( buttonDeleteSetup.mouseClick(x, y)){
|
||||
|
@ -4136,6 +4136,21 @@ bool MenuStateCustomGame::loadGameSettingsFromFile(GameSettings *gameSettings,st
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> mapsV=formattedPlayerSortedMaps[0];
|
||||
if(std::find(mapsV.begin(), mapsV.end(), gameSettings->getMap()) == mapsV.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', map unknown ("+gameSettings->getMap()+")");
|
||||
return false;// map unknown
|
||||
}
|
||||
if(std::find(tilesetFiles.begin(), tilesetFiles.end(), gameSettings->getTileset()) == tilesetFiles.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', tileset unknown ("+gameSettings->getTileset()+")");
|
||||
return false;// tileset unknown
|
||||
}
|
||||
if(std::find(techTreeFiles.begin(), techTreeFiles.end(), gameSettings->getTech()) == techTreeFiles.end()) {
|
||||
console.addLine("Cannot load '"+fileName+"', techtree unknown ("+gameSettings->getTech()+")");
|
||||
return false;// techtree unknown
|
||||
}
|
||||
|
||||
setupUIFromGameSettings(*gameSettings);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
|
|
Loading…
Reference in New Issue