Skip to content

Commit

Permalink
Fixed a bug, that would cause an edited world that is not in the defa…
Browse files Browse the repository at this point in the history
…ult save location to save its worldsettings to the default save location instead of its actual folder
  • Loading branch information
thorwin99 committed Aug 9, 2021
1 parent a3e7ae0 commit 1b9bd66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 7 additions & 6 deletions SEWorldGenPlugin/GUI/PluginWorldSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PluginWorldSettings : MyGuiScreenWorldSettings
private MyGuiControlCheckbox m_enablePlugin;
private MyGuiControlLabel m_enablePluginLabel;
private MyGuiControlButton m_pluginSettingsButton;
private string m_path;

private float MARGIN_TOP = 0.22f;

Expand All @@ -52,6 +53,9 @@ public PluginWorldSettings(MyObjectBuilder_Checkpoint checkpoint, string path, b
{
Static = this;
m_isNewGame = (checkpoint == null);
m_path = path;

RecreateControls(true);
}

/// <summary>
Expand Down Expand Up @@ -127,9 +131,7 @@ protected override void BuildControls()
{
b.ButtonClicked += delegate
{
var name = Checkpoint.SessionName;
var path = Path.Combine(MyFileSystem.SavesPath, name.Replace(":", "-"));
MyFileUtils.WriteXmlFileToPath(PlSettings, path, MySettingsSession.FILE_NAME);
MyFileUtils.WriteXmlFileToPath(PlSettings, m_path, MySettingsSession.FILE_NAME);
};
}
}
Expand Down Expand Up @@ -165,10 +167,9 @@ private Vector2 GetControlPosition()
/// </summary>
private void LoadValues()
{
var path = Path.Combine(MyFileSystem.SavesPath, Checkpoint.SessionName.Replace(":", "-"));
if(MyFileUtils.FileExistsInPath(path, MySettingsSession.FILE_NAME))
if(m_path != null && MyFileUtils.FileExistsInPath(m_path, MySettingsSession.FILE_NAME))
{
PlSettings = MyFileUtils.ReadXmlFileFromPath<MyObjectBuilder_WorldSettings>(path, MySettingsSession.FILE_NAME);
PlSettings = MyFileUtils.ReadXmlFileFromPath<MyObjectBuilder_WorldSettings>(m_path, MySettingsSession.FILE_NAME);
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions SEWorldGenPlugin/MySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,5 @@ public void SaveSettings()
writer.Close();
}
}


}
}
2 changes: 1 addition & 1 deletion SEWorldGenPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.6.7")]
[assembly: AssemblyVersion("2.0.6.8")]
[assembly: AssemblyFileVersion("1.0.0")]

0 comments on commit 1b9bd66

Please sign in to comment.