saved game setups

and lang file
This commit is contained in:
titiger 2019-11-18 23:32:01 +01:00
parent 68de0209fb
commit 80cf370209
6 changed files with 16 additions and 26 deletions

@ -1 +1 @@
Subproject commit 3a58333854e57feec46f5e6cb1d72fed6eb52e30 Subproject commit 4ae2ba46174ad5a9b5ff1b0fce1d398d6f9c0762

View File

@ -151,6 +151,7 @@ public:
static const char *NETWORK_SLOT_CLOSED_SLOTNAME; static const char *NETWORK_SLOT_CLOSED_SLOTNAME;
static const char *folder_path_screenshots; static const char *folder_path_screenshots;
static const char *folder_path_setups;
static const char *OBSERVER_SLOTNAME; static const char *OBSERVER_SLOTNAME;
static const char *RANDOMFACTION_SLOTNAME; static const char *RANDOMFACTION_SLOTNAME;

View File

@ -47,6 +47,7 @@ const char *GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME = "???";
const char *GameConstants::NETWORK_SLOT_CLOSED_SLOTNAME = "Closed"; const char *GameConstants::NETWORK_SLOT_CLOSED_SLOTNAME = "Closed";
const char *GameConstants::folder_path_screenshots = "screens/"; const char *GameConstants::folder_path_screenshots = "screens/";
const char *GameConstants::folder_path_setups = "setups/";
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*"; const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*"; const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";

View File

@ -47,7 +47,7 @@ static const double REPROMPT_DOWNLOAD_SECONDS = 7;
const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 2; const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 2;
static const char *HEADLESS_SAVED_SETUP_FILENAME = "lastHeadlessGameSettings.mgg"; static const char *HEADLESS_SAVED_SETUP_FILENAME = "lastHeadlessGameSettings.mgg";
static const char *LAST_SETUP_STRING="LastSetup"; static const char *LAST_SETUP_STRING="LastSetup";
static const char *SETUPS_DIR="setups/"; static const char *SETUPS_DIR=GameConstants::folder_path_setups;
const int mapPreviewTexture_X = 5; const int mapPreviewTexture_X = 5;
const int mapPreviewTexture_Y = 260; const int mapPreviewTexture_Y = 260;
@ -180,7 +180,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
int currXLabel=currX+20; int currXLabel=currX+20;
int lineHeightSmall=18; int lineHeightSmall=18;
int buttonx=165; int buttonx=195;
int buttony=180; int buttony=180;
// player status // player status
@ -195,17 +195,12 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxPlayerStatus.setTextColor(Vec3f(0.0f,1.0f,0.0f)); listBoxPlayerStatus.setTextColor(Vec3f(0.0f,1.0f,0.0f));
listBoxPlayerStatus.setLighted(false); listBoxPlayerStatus.setLighted(false);
listBoxPlayerStatus.setVisible(true); listBoxPlayerStatus.setVisible(true);
buttonx+=180; buttonx+=175;
buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect"); buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect");
buttonDisconnect.init(buttonx, buttony, 125); buttonDisconnect.init(buttonx, buttony, 125);
buttonDisconnect.setText(lang.getString("Return")); buttonDisconnect.setText(lang.getString("Return"));
buttonx+=132; buttonx+=135;
buttonRestoreLastSettings.registerGraphicComponent(containerName,"buttonRestoreLastSettings");
buttonRestoreLastSettings.init(buttonx, buttony, 240);
buttonRestoreLastSettings.setText(lang.getString("ReloadLastGameSettings"));
buttonx+=247;
buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow"); buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow");
buttonPlayNow.init(buttonx, buttony, 125); buttonPlayNow.init(buttonx, buttony, 125);
@ -830,7 +825,6 @@ void MenuStateConnectedGame::reloadUI() {
labelAllowNativeLanguageTechtree.setText(lang.getString("AllowNativeLanguageTechtree")); labelAllowNativeLanguageTechtree.setText(lang.getString("AllowNativeLanguageTechtree"));
buttonPlayNow.setText(lang.getString("PlayNow")); buttonPlayNow.setText(lang.getString("PlayNow"));
buttonRestoreLastSettings.setText(lang.getString("ReloadLastGameSettings"));
chatManager.init(&console, -1,true); chatManager.init(&console, -1,true);
@ -1878,15 +1872,6 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
PlayNow(true); PlayNow(true);
return; return;
} }
else if(buttonRestoreLastSettings.mouseClick(x,y) && buttonRestoreLastSettings.getEnabled()) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.playFx(coreData.getClickSoundB());
RestoreLastGameSettings();
}
else if (checkBoxAllowNativeLanguageTechtree.mouseClick(x, y)) { else if (checkBoxAllowNativeLanguageTechtree.mouseClick(x, y)) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
needToBroadcastServerSettings=true; needToBroadcastServerSettings=true;
@ -1944,6 +1929,9 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
setupName=labelSaveSetupName.getText(); setupName=labelSaveSetupName.getText();
setupName=replaceAll(setupName,"/","_"); setupName=replaceAll(setupName,"/","_");
setupName=replaceAll(setupName,"\\","_"); setupName=replaceAll(setupName,"\\","_");
if (StartsWith(setupName,".")){
setupName[0]='_';
}
} }
if( setupName!= lang.getString(LAST_SETUP_STRING)) { if( setupName!= lang.getString(LAST_SETUP_STRING)) {
string filename=SETUPS_DIR+setupName+".mgg"; string filename=SETUPS_DIR+setupName+".mgg";
@ -2708,7 +2696,6 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
checkBoxAllowNativeLanguageTechtree.mouseMove(x, y); checkBoxAllowNativeLanguageTechtree.mouseMove(x, y);
buttonPlayNow.mouseMove(x, y); buttonPlayNow.mouseMove(x, y);
buttonRestoreLastSettings.mouseMove(x, y);
} }
bool MenuStateConnectedGame::isVideoPlaying() { bool MenuStateConnectedGame::isVideoPlaying() {
@ -2958,7 +2945,6 @@ void MenuStateConnectedGame::render() {
renderer.renderCheckBox(&checkBoxAllowTeamResourceSharing); renderer.renderCheckBox(&checkBoxAllowTeamResourceSharing);
renderer.renderButton(&buttonPlayNow); renderer.renderButton(&buttonPlayNow);
renderer.renderButton(&buttonRestoreLastSettings);
renderer.renderLabel(&labelSaveSetupName); renderer.renderLabel(&labelSaveSetupName);
renderer.renderButton(&buttonSaveSetup); renderer.renderButton(&buttonSaveSetup);
@ -3123,7 +3109,6 @@ void MenuStateConnectedGame::update() {
listBoxMapFilter.setEditable(isHeadlessAdmin()); listBoxMapFilter.setEditable(isHeadlessAdmin());
buttonPlayNow.setVisible(isHeadlessAdmin() || buttonPlayNow.setVisible(isHeadlessAdmin() ||
clientInterface->getJoinGameInProgress() == true); clientInterface->getJoinGameInProgress() == true);
buttonRestoreLastSettings.setVisible(isHeadlessAdmin());
listBoxTechTree.setEditable(isHeadlessAdmin()); listBoxTechTree.setEditable(isHeadlessAdmin());
listBoxTileset.setEditable(isHeadlessAdmin()); listBoxTileset.setEditable(isHeadlessAdmin());
checkBoxEnableSwitchTeamMode.setEditable(isHeadlessAdmin()); checkBoxEnableSwitchTeamMode.setEditable(isHeadlessAdmin());

View File

@ -65,7 +65,7 @@ private:
GraphicLabel labelStatus; GraphicLabel labelStatus;
GraphicLabel labelInfo; GraphicLabel labelInfo;
GraphicLabel labelWaitingForPlayers; GraphicLabel labelWaitingForPlayers;
GraphicButton buttonRestoreLastSettings;
//GraphicLabel labelPathFinderType; //GraphicLabel labelPathFinderType;
//GraphicListBox listBoxPathFinderType; //GraphicListBox listBoxPathFinderType;

View File

@ -45,7 +45,7 @@ static const char *SAVED_SETUP_FILENAME = "lastCustomGameSettings.mgg";
static const char *DEFAULT_SETUP_FILENAME = "data/defaultGameSetup.mgg"; static const char *DEFAULT_SETUP_FILENAME = "data/defaultGameSetup.mgg";
static const char *DEFAULT_NETWORK_SETUP_FILENAME = "data/defaultNetworkGameSetup.mgg"; static const char *DEFAULT_NETWORK_SETUP_FILENAME = "data/defaultNetworkGameSetup.mgg";
static const char *LAST_SETUP_STRING="LastSetup"; static const char *LAST_SETUP_STRING="LastSetup";
static const char *SETUPS_DIR="setups/"; static const char *SETUPS_DIR=GameConstants::folder_path_setups;
const int mapPreviewTexture_X = 5; const int mapPreviewTexture_X = 5;
const int mapPreviewTexture_Y = 260; const int mapPreviewTexture_Y = 260;
@ -546,7 +546,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
currY = currY - lineHeightSmall; currY = currY - lineHeightSmall;
buttonShowLanInfo .registerGraphicComponent(containerName,"buttonShowLanInfo"); buttonShowLanInfo .registerGraphicComponent(containerName,"buttonShowLanInfo");
buttonShowLanInfo.init(currX, currY, 200,16); buttonShowLanInfo.init(currX, currY, 200,16);
buttonShowLanInfo.setText(lang.getString("showIP")); buttonShowLanInfo.setText(lang.getString("ShowIP"));
currY = currY - lineHeightSmall; currY = currY - lineHeightSmall;
// Advanced Options // Advanced Options
@ -1262,6 +1262,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
setupName=labelSaveSetupName.getText(); setupName=labelSaveSetupName.getText();
setupName=replaceAll(setupName,"/","_"); setupName=replaceAll(setupName,"/","_");
setupName=replaceAll(setupName,"\\","_"); setupName=replaceAll(setupName,"\\","_");
if (StartsWith(setupName,".")){
setupName[0]='_';
}
} }
if( setupName!= lang.getString(LAST_SETUP_STRING)) { if( setupName!= lang.getString(LAST_SETUP_STRING)) {
string filename=SETUPS_DIR+setupName+".mgg"; string filename=SETUPS_DIR+setupName+".mgg";