load/save setups in menu state connected
This commit is contained in:
parent
22d22e275b
commit
cc9c001736
|
@ -3149,6 +3149,10 @@ void Renderer::renderLabel(GraphicLabel *label) {
|
|||
return;
|
||||
}
|
||||
|
||||
if( label->getVisible()==false){
|
||||
return;
|
||||
}
|
||||
|
||||
if(label->getEditable() && label->getMaxEditRenderWidth()>0)
|
||||
{
|
||||
int x= label->getX();
|
||||
|
|
|
@ -45,7 +45,9 @@ static const double REPROMPT_DOWNLOAD_SECONDS = 7;
|
|||
//static const string ITEM_MISSING = "***missing***";
|
||||
// above replaced with Lang::getInstance().getString("DataMissing","",true)
|
||||
const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 2;
|
||||
static const char *HEADLESS_SAVED_GAME_FILENAME = "lastHeadlessGameSettings.mgg";
|
||||
static const char *HEADLESS_SAVED_SETUP_FILENAME = "lastHeadlessGameSettings.mgg";
|
||||
static const char *LAST_SETUP_STRING="LastSetup";
|
||||
static const char *SETUPS_DIR="setups/";
|
||||
|
||||
const int mapPreviewTexture_X = 5;
|
||||
const int mapPreviewTexture_Y = 260;
|
||||
|
@ -301,6 +303,39 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
|
||||
listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount());
|
||||
|
||||
// Save Setup
|
||||
currY=mapHeadPos-100;
|
||||
currX=xoffset+325;
|
||||
|
||||
comboBoxLoadSetup.registerGraphicComponent(containerName,"comboBoxLoadSetup");
|
||||
comboBoxLoadSetup.init(currX, currY, 220);
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
|
||||
currY = currY - labelOffset;
|
||||
|
||||
buttonDeleteSetup.registerGraphicComponent(containerName,"buttonDeleteSetup");
|
||||
buttonDeleteSetup.init(currX, currY, 110);
|
||||
buttonDeleteSetup.setText(lang.getString("Delete"));
|
||||
buttonLoadSetup.registerGraphicComponent(containerName,"buttonLoadSetup");
|
||||
buttonLoadSetup.init(currX+110, currY, 110);
|
||||
buttonLoadSetup.setText(lang.getString("Load"));
|
||||
|
||||
currY = currY - labelOffset;
|
||||
|
||||
labelSaveSetupName.registerGraphicComponent(containerName,"labelSaveSetupName");
|
||||
labelSaveSetupName.init(currX,currY, 110);
|
||||
labelSaveSetupName.setText("");
|
||||
labelSaveSetupName.setEditable(true);
|
||||
labelSaveSetupName.setMaxEditWidth(16);
|
||||
labelSaveSetupName.setMaxEditRenderWidth(labelSaveSetupName.getW());
|
||||
labelSaveSetupName.setBackgroundColor(Vec4f(230,230,230,0.4));
|
||||
labelSaveSetupName.setRenderBackground(true);
|
||||
|
||||
buttonSaveSetup.registerGraphicComponent(containerName,"buttonSaveSetup");
|
||||
buttonSaveSetup.init(currX+110, currY, 110);
|
||||
buttonSaveSetup.setText(lang.getString("Save"));
|
||||
|
||||
|
||||
// Toy Block
|
||||
currY=mapHeadPos;
|
||||
|
@ -1787,7 +1822,7 @@ void MenuStateConnectedGame::broadCastGameSettingsToHeadlessServer(bool forceNow
|
|||
}
|
||||
|
||||
if(validDisplayedGamesettings){
|
||||
loadGameSettings(&displayedGamesettings);
|
||||
copyToGameSettings(&displayedGamesettings);
|
||||
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("broadcast settings:\n%s\n",displayedGamesettings.toString().c_str());
|
||||
|
@ -1833,6 +1868,8 @@ void MenuStateConnectedGame::updateResourceMultiplier(const int index) {
|
|||
void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButton,string advanceToItemStartingWith) {
|
||||
|
||||
try {
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
int oldListBoxMapfilterIndex=listBoxMapFilter.getSelectedItemIndex();
|
||||
if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
@ -1869,11 +1906,74 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||
needToBroadcastServerSettings=true;
|
||||
broadcastServerSettingsDelayTimer=time(NULL);
|
||||
}
|
||||
else if(comboBoxMap.isDropDownShowing()){
|
||||
//do nothing
|
||||
}
|
||||
else if(comboBoxLoadSetup.mouseClick(x,y)){
|
||||
}
|
||||
else if(comboBoxLoadSetup.isDropDownShowing()){
|
||||
//do nothing
|
||||
}
|
||||
else if(listBoxFogOfWar.mouseClick(x, y)) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
needToBroadcastServerSettings=true;
|
||||
broadcastServerSettingsDelayTimer=time(NULL);
|
||||
}
|
||||
else if(labelSaveSetupName.mouseClick(x, y) ){
|
||||
setActiveInputLabel(&labelSaveSetupName);
|
||||
}
|
||||
else if ( buttonSaveSetup.mouseClick(x, y)){
|
||||
GameSettings gameSettings;
|
||||
copyToGameSettings(&gameSettings);
|
||||
int humanSlots=0;
|
||||
for( int i=0; i<gameSettings.getFactionCount();i++){
|
||||
switch (gameSettings.getFactionControl(i)) {
|
||||
case ctNetwork:
|
||||
case ctHuman:
|
||||
case ctNetworkUnassigned:
|
||||
humanSlots++;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
string setupName=intToStr(humanSlots)+"_"+gameSettings.getMap();
|
||||
labelSaveSetupName.setText(trim(labelSaveSetupName.getText()));
|
||||
if(labelSaveSetupName.getText()!=""){
|
||||
setupName=labelSaveSetupName.getText();
|
||||
setupName=replaceAll(setupName,"/","_");
|
||||
setupName=replaceAll(setupName,"\\","_");
|
||||
}
|
||||
if( setupName!= lang.getString(LAST_SETUP_STRING)) {
|
||||
string filename=setupName+".mgg";
|
||||
saveGameSettings(SETUPS_DIR+filename);
|
||||
console.addLine("--> " +filename);
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
comboBoxLoadSetup.setSelectedItem(setupName);
|
||||
}
|
||||
}
|
||||
else if ( buttonLoadSetup.mouseClick(x, y)){
|
||||
string setupName=comboBoxLoadSetup.getSelectedItem();
|
||||
if( setupName!=""){
|
||||
string fileNameToLoad=SETUPS_DIR+setupName+".mgg";
|
||||
if( setupName== lang.getString(LAST_SETUP_STRING)){
|
||||
fileNameToLoad=HEADLESS_SAVED_SETUP_FILENAME;
|
||||
}
|
||||
if(loadGameSettings(fileNameToLoad))
|
||||
console.addLine("<-- " +setupName+".mgg");
|
||||
}
|
||||
}
|
||||
else if ( buttonDeleteSetup.mouseClick(x, y)){
|
||||
string setupName=comboBoxLoadSetup.getSelectedItem();
|
||||
if( setupName!=""&& setupName!= lang.getString(LAST_SETUP_STRING)) {
|
||||
removeFile(savedSetupsDir+setupName+".mgg");
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
console.addLine("X " +setupName+".mgg");
|
||||
}
|
||||
}
|
||||
else if(checkBoxAllowObservers.mouseClick(x, y)) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
needToBroadcastServerSettings=true;
|
||||
|
@ -2012,10 +2112,10 @@ void MenuStateConnectedGame::PlayNow(bool saveGame) {
|
|||
ClientInterface *clientInterface = networkManager.getClientInterface();
|
||||
|
||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
if(saveGame == true) {
|
||||
CoreData::getInstance().saveGameSettingsToFile(HEADLESS_SAVED_GAME_FILENAME,&gameSettings,true);
|
||||
CoreData::getInstance().saveGameSettingsToFile(HEADLESS_SAVED_SETUP_FILENAME,&gameSettings,true);
|
||||
}
|
||||
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
|
@ -2162,7 +2262,7 @@ void MenuStateConnectedGame::reloadFactions(bool keepExistingSelectedItem, strin
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
void MenuStateConnectedGame::copyToGameSettings(GameSettings *gameSettings) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
int factionCount= 0;
|
||||
|
@ -2559,6 +2659,16 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||
}
|
||||
|
||||
comboBoxMap.mouseMove(x, y);
|
||||
comboBoxLoadSetup.mouseMove(x, y);
|
||||
if (comboBoxLoadSetup.isDropDownShowing()) {
|
||||
if (ms->get(mbLeft)) {
|
||||
comboBoxLoadSetup.mouseDown(x, y);
|
||||
}
|
||||
}
|
||||
buttonSaveSetup.mouseMove(x, y);
|
||||
buttonLoadSetup.mouseMove(x, y);
|
||||
buttonDeleteSetup.mouseMove(x, y);
|
||||
|
||||
listBoxFogOfWar.mouseMove(x, y);
|
||||
checkBoxAllowObservers.mouseMove(x, y);
|
||||
listBoxTileset.mouseMove(x, y);
|
||||
|
@ -2826,6 +2936,11 @@ void MenuStateConnectedGame::render() {
|
|||
renderer.renderButton(&buttonPlayNow);
|
||||
renderer.renderButton(&buttonRestoreLastSettings);
|
||||
|
||||
renderer.renderLabel(&labelSaveSetupName);
|
||||
renderer.renderButton(&buttonSaveSetup);
|
||||
renderer.renderButton(&buttonLoadSetup);
|
||||
renderer.renderButton(&buttonDeleteSetup);
|
||||
|
||||
renderer.renderCheckBox(&checkBoxScenario);
|
||||
renderer.renderLabel(&labelScenario);
|
||||
if(checkBoxScenario.getValue() == true) {
|
||||
|
@ -2882,6 +2997,7 @@ void MenuStateConnectedGame::render() {
|
|||
safeMutexFTPProgress.ReleaseLock();
|
||||
|
||||
renderer.renderComboBox(&comboBoxMap);
|
||||
renderer.renderComboBox(&comboBoxLoadSetup);
|
||||
|
||||
if(mainMessageBox.getEnabled()) {
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
|
@ -2974,7 +3090,11 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
checkBoxAllowNativeLanguageTechtree.setEditable(isHeadlessAdmin());
|
||||
checkBoxAllowNativeLanguageTechtree.setEnabled(isHeadlessAdmin());
|
||||
|
||||
buttonSaveSetup.setVisible(isHeadlessAdmin());
|
||||
labelSaveSetupName.setVisible(isHeadlessAdmin());
|
||||
buttonLoadSetup.setVisible(isHeadlessAdmin());
|
||||
buttonDeleteSetup.setVisible(isHeadlessAdmin());
|
||||
comboBoxLoadSetup.setVisible(isHeadlessAdmin());
|
||||
comboBoxMap.setEditable(isHeadlessAdmin());
|
||||
listBoxMapFilter.setEditable(isHeadlessAdmin());
|
||||
buttonPlayNow.setVisible(isHeadlessAdmin() ||
|
||||
|
@ -3576,7 +3696,7 @@ void MenuStateConnectedGame::update() {
|
|||
//printf("Menu got new settings thisfactionindex = %d startlocation: %d control = %d\n",displayedGamesettings.getThisFactionIndex(),clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()),displayedGamesettings.getFactionControl(clientInterface->getGameSettings()->getThisFactionIndex()));
|
||||
if ( difftime((long int)time(NULL),noReceiveTimer) < 3 || difftime((long int)time(NULL),broadcastServerSettingsDelayTimer) < HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS){
|
||||
// copy my current settings in UI to displayedSettings;
|
||||
loadGameSettings(&displayedGamesettings);
|
||||
copyToGameSettings(&displayedGamesettings);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
@ -3688,7 +3808,7 @@ void MenuStateConnectedGame::update() {
|
|||
//printf("Loading saved game file [%s]\n",saveGameFile.c_str());
|
||||
|
||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
@ -5312,15 +5432,22 @@ void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings
|
|||
}
|
||||
|
||||
void MenuStateConnectedGame::RestoreLastGameSettings() {
|
||||
loadGameSettings(HEADLESS_SAVED_SETUP_FILENAME);
|
||||
}
|
||||
|
||||
|
||||
bool MenuStateConnectedGame::loadGameSettings(const std::string &fileName) {
|
||||
// Ensure we have set the gamesettings at least once
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
||||
CoreData::getInstance().loadGameSettingsFromFile(HEADLESS_SAVED_GAME_FILENAME,&gameSettings);
|
||||
bool result=CoreData::getInstance().loadGameSettingsFromFile(fileName,&gameSettings);
|
||||
if(result==false)
|
||||
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__);
|
||||
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
}
|
||||
|
||||
setupUIFromGameSettings(&gameSettings, false);
|
||||
|
@ -5328,7 +5455,34 @@ void MenuStateConnectedGame::RestoreLastGameSettings() {
|
|||
needToBroadcastServerSettings=true;
|
||||
broadcastServerSettingsDelayTimer=time(NULL);
|
||||
noReceiveTimer=time(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::saveGameSettings(std::string fileName) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
GameSettings gameSettings;
|
||||
copyToGameSettings(&gameSettings);
|
||||
CoreData::getInstance().saveGameSettingsToFile(fileName, &gameSettings,true);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::loadSavedSetupNames() {
|
||||
Config &config = Config::getInstance();
|
||||
Lang &lang= Lang::getInstance();
|
||||
vector<string> paths;
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
string saveSetupDir ;
|
||||
saveSetupDir = userData +"setups";
|
||||
paths.push_back(saveSetupDir);
|
||||
savedSetupFilenames.clear();
|
||||
findAll(paths, "*.mgg", savedSetupFilenames, true, false, true);
|
||||
sort(savedSetupFilenames.begin(),savedSetupFilenames.end());
|
||||
savedSetupFilenames.insert(savedSetupFilenames.begin(),1,lang.getString(LAST_SETUP_STRING));
|
||||
}
|
||||
|
||||
int MenuStateConnectedGame::setupMapList(string scenario) {
|
||||
|
|
|
@ -98,6 +98,14 @@ private:
|
|||
GraphicLabel labelAllowObservers;
|
||||
GraphicCheckBox checkBoxAllowObservers;
|
||||
|
||||
GraphicButton buttonSaveSetup;
|
||||
GraphicLabel labelSaveSetupName;
|
||||
GraphicButton buttonLoadSetup;
|
||||
GraphicButton buttonDeleteSetup;
|
||||
GraphicComboBox comboBoxLoadSetup;
|
||||
string savedSetupsDir;
|
||||
vector<string> savedSetupFilenames;
|
||||
|
||||
GraphicLabel labelAllowNativeLanguageTechtree;
|
||||
GraphicCheckBox checkBoxAllowNativeLanguageTechtree;
|
||||
|
||||
|
@ -180,8 +188,6 @@ private:
|
|||
|
||||
std::map<string,uint32> mapCRCUpdateList;
|
||||
|
||||
|
||||
|
||||
string getMissingMapFromFTPServer;
|
||||
bool getMissingMapFromFTPServerInProgress;
|
||||
time_t getMissingMapFromFTPServerLastPrompted;
|
||||
|
@ -223,7 +229,6 @@ private:
|
|||
GraphicLabel labelFallbackCpuMultiplier;
|
||||
GraphicListBox listBoxFallbackCpuMultiplier;
|
||||
|
||||
|
||||
GraphicButton buttonPlayNow;
|
||||
|
||||
GraphicCheckBox checkBoxScenario;
|
||||
|
@ -300,17 +305,20 @@ private:
|
|||
void switchToNextMapGroup(const int direction);
|
||||
void switchToMapGroup(int filterIndex);
|
||||
string getCurrentMapFile();
|
||||
void loadGameSettings(GameSettings *gameSettings);
|
||||
void copyToGameSettings(GameSettings *gameSettings);
|
||||
void reloadFactions(bool keepExistingSelectedItem,string scenario);
|
||||
void PlayNow(bool saveGame);
|
||||
bool isHeadlessAdmin();
|
||||
void broadCastGameSettingsToHeadlessServer(bool forceNow);
|
||||
void updateResourceMultiplier(const int index);
|
||||
|
||||
void saveGameSettings(std::string fileName);
|
||||
bool loadGameSettings(const std::string &fileName);
|
||||
void RestoreLastGameSettings();
|
||||
void setupUIFromGameSettings(GameSettings *gameSettings, bool errorOnMissingData);
|
||||
|
||||
int setupMapList(string scenario);
|
||||
void loadSavedSetupNames();
|
||||
int setupTechList(string scenario, bool forceLoad=false);
|
||||
void setupTilesetList(string scenario);
|
||||
|
||||
|
|
|
@ -156,7 +156,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
savedSetupsDir = userData +SETUPS_DIR;
|
||||
|
||||
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.getString("Ok"),500,300);
|
||||
mainMessageBox.setEnabled(false);
|
||||
|
@ -725,7 +724,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
|
||||
// Ensure we have set the gamesettings at least once
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
serverInterface->setGameSettings(&gameSettings,false);
|
||||
}
|
||||
|
@ -1143,8 +1142,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
//do nothing
|
||||
}
|
||||
else if(comboBoxLoadSetup.mouseClick(x,y)){
|
||||
// string setupName=comboBoxLoadSetup.getSelectedItem();
|
||||
// loadGameSettingsFromFile(setupName,true);
|
||||
}
|
||||
else if(comboBoxLoadSetup.isDropDownShowing()){
|
||||
//do nothing
|
||||
|
@ -1245,7 +1242,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
}
|
||||
else if ( buttonSaveSetup.mouseClick(x, y)){
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
int humanSlots=0;
|
||||
for( int i=0; i<gameSettings.getFactionCount();i++){
|
||||
switch (gameSettings.getFactionControl(i)) {
|
||||
|
@ -1268,7 +1265,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
}
|
||||
if( setupName!= lang.getString(LAST_SETUP_STRING)) {
|
||||
string filename=setupName+".mgg";
|
||||
saveGameSettingsToFile(SETUPS_DIR+filename);
|
||||
saveGameSettings(SETUPS_DIR+filename);
|
||||
console.addLine("--> " +filename);
|
||||
loadSavedSetupNames();
|
||||
comboBoxLoadSetup.setItems(savedSetupFilenames);
|
||||
|
@ -1810,7 +1807,7 @@ bool MenuStateCustomGame::loadGameSettings(const std::string &fileName) {
|
|||
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__);
|
||||
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
}
|
||||
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
|
@ -1886,7 +1883,7 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
|||
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
if(saveGame == true) {
|
||||
saveGameSettingsToFile(SAVED_SETUP_FILENAME);
|
||||
saveGameSettings(SAVED_SETUP_FILENAME);
|
||||
}
|
||||
|
||||
forceWaitForShutdown = false;
|
||||
|
@ -1960,7 +1957,7 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
|||
safeMutex.ReleaseLock(true);
|
||||
safeMutexCLI.ReleaseLock(true);
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings, true);
|
||||
copyToGameSettings(&gameSettings, true);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
|
@ -2136,13 +2133,13 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||
comboBoxLoadSetup.mouseDown(x, y);
|
||||
}
|
||||
}
|
||||
buttonSaveSetup.mouseMove(x, y);
|
||||
buttonLoadSetup.mouseMove(x, y);
|
||||
buttonDeleteSetup.mouseMove(x, y);
|
||||
|
||||
buttonReturn.mouseMove(x, y);
|
||||
buttonPlayNow.mouseMove(x, y);
|
||||
buttonClearBlockedPlayers.mouseMove(x, y);
|
||||
buttonSaveSetup.mouseMove(x, y);
|
||||
buttonLoadSetup.mouseMove(x, y);
|
||||
buttonDeleteSetup.mouseMove(x, y);
|
||||
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
listBoxRMultiplier[i].mouseMove(x, y);
|
||||
|
@ -2257,6 +2254,7 @@ void MenuStateCustomGame::render() {
|
|||
|
||||
renderer.renderButton(&buttonReturn);
|
||||
renderer.renderButton(&buttonPlayNow);
|
||||
|
||||
renderer.renderLabel(&labelSaveSetupName);
|
||||
renderer.renderButton(&buttonSaveSetup);
|
||||
renderer.renderButton(&buttonLoadSetup);
|
||||
|
@ -2706,7 +2704,7 @@ void MenuStateCustomGame::update() {
|
|||
printf("received Settings map filter=%d\n",settings->getMapFilter());
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
//printf("\n\n\n\n=====#1.1 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),gameSettings.toString().c_str());
|
||||
|
||||
|
@ -2730,7 +2728,7 @@ void MenuStateCustomGame::update() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
listBoxAISwitchTeamAcceptPercent.setVisible(checkBoxEnableSwitchTeamMode.getValue());
|
||||
labelAISwitchTeamAcceptPercent.setVisible(checkBoxEnableSwitchTeamMode.getValue());
|
||||
|
@ -3247,7 +3245,7 @@ void MenuStateCustomGame::publishToMasterserver() {
|
|||
int slotCountConnectedPlayers=0;
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
Config &config= Config::getInstance();
|
||||
//string serverinfo="";
|
||||
|
||||
|
@ -3547,7 +3545,7 @@ void MenuStateCustomGame::simpleTaskForClients(BaseThread *callingThread) {
|
|||
lastGameSettingsreceivedCount++;
|
||||
if(this->headlessServerMode == false || (serverInterface->getGameSettingsUpdateCount() <= lastMasterServerSettingsUpdateCount)) {
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
|
||||
//printf("\n\n\n\n=====#2 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),gameSettings.toString().c_str());
|
||||
|
||||
|
@ -3605,7 +3603,7 @@ void MenuStateCustomGame::simpleTaskForClients(BaseThread *callingThread) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool forceCloseUnusedSlots) {
|
||||
void MenuStateCustomGame::copyToGameSettings(GameSettings *gameSettings,bool forceCloseUnusedSlots) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
int factionCount= 0;
|
||||
|
@ -4105,11 +4103,11 @@ void MenuStateCustomGame::KeepCurrentHumanPlayerSlots(GameSettings &gameSettings
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
||||
void MenuStateCustomGame::saveGameSettings(std::string fileName) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
copyToGameSettings(&gameSettings);
|
||||
CoreData::getInstance().saveGameSettingsToFile(fileName, &gameSettings,checkBoxAdvanced.getValue());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
@ -4119,7 +4117,7 @@ bool MenuStateCustomGame::loadGameSettingsFromFile(GameSettings *gameSettings,st
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
GameSettings originalGameSettings;
|
||||
loadGameSettings(&originalGameSettings);
|
||||
copyToGameSettings(&originalGameSettings);
|
||||
|
||||
try {
|
||||
bool loadSuccessful= CoreData::getInstance().loadGameSettingsFromFile(fileName, gameSettings);
|
||||
|
|
|
@ -130,8 +130,8 @@ private:
|
|||
GraphicButton buttonLoadSetup;
|
||||
GraphicButton buttonDeleteSetup;
|
||||
GraphicComboBox comboBoxLoadSetup;
|
||||
|
||||
string savedSetupsDir;
|
||||
vector<string> savedSetupFilenames;
|
||||
|
||||
GraphicCheckBox checkBoxScenario;
|
||||
GraphicLabel labelScenario;
|
||||
|
@ -233,7 +233,6 @@ private:
|
|||
int lastGameSettingsreceivedCount;
|
||||
|
||||
string lastPreviewedMapFile;
|
||||
vector<string> savedSetupFilenames;
|
||||
|
||||
public:
|
||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
||||
|
@ -268,7 +267,7 @@ private:
|
|||
void setSmallFont(GraphicLabel l);
|
||||
void lastPlayerDisconnected();
|
||||
bool hasNetworkGameSettings();
|
||||
void loadGameSettings(GameSettings *gameSettings, bool forceCloseUnusedSlots=false);
|
||||
void copyToGameSettings(GameSettings *gameSettings, bool forceCloseUnusedSlots=false);
|
||||
void loadMapInfo(string file, MapInfo *mapInfo,bool loadMapPreview, bool doPlayerSetup);
|
||||
void cleanupMapPreviewTexture();
|
||||
|
||||
|
@ -279,7 +278,6 @@ private:
|
|||
void returnToParentMenu();
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
|
||||
void saveGameSettingsToFile(std::string fileName);
|
||||
void switchToNextMapGroup(const int direction);
|
||||
void updateAllResourceMultiplier();
|
||||
void updateResourceMultiplier(const int index);
|
||||
|
@ -289,6 +287,7 @@ private:
|
|||
|
||||
void loadFactionTexture(string filepath);
|
||||
|
||||
void saveGameSettings(std::string fileName);
|
||||
bool loadGameSettingsFromFile(GameSettings *gameSettings,std::string fileName);
|
||||
bool loadGameSettings(const std::string &fileName);
|
||||
void RestoreLastGameSettings();
|
||||
|
|
Loading…
Reference in New Issue