Skip to content

Commit

Permalink
*Added*: The new world generation settings object builder, to give mo…
Browse files Browse the repository at this point in the history
…re control over system generation
  • Loading branch information
8vogt committed Dec 19, 2020
1 parent 6c1c3ca commit caa0e3a
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 306 deletions.
6 changes: 3 additions & 3 deletions SEWorldGenPlugin/GUI/PluginSettingsGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public void BuildControls()
Controls.Add(scrollPane);
}

public void SetSettings(MyObjectBuilder_WorldSettings settings, bool useGlobal)
public void SetSettings(LegacyMyObjectBuilder_WorldSettings settings, bool useGlobal)
{
m_useGlobalCheck.IsChecked = useGlobal;

Expand Down Expand Up @@ -534,10 +534,10 @@ public void SetSettings(MyObjectBuilder_WorldSettings settings, bool useGlobal)
/// </summary>
/// <param name="settings">The plugin settings to set</param>
/// <returns>If global config should be used</returns>
public bool GetSettings(ref MyObjectBuilder_WorldSettings settings)
public bool GetSettings(ref LegacyMyObjectBuilder_WorldSettings settings)
{
if (settings == null)
settings = new MyObjectBuilder_WorldSettings();
settings = new LegacyMyObjectBuilder_WorldSettings();

settings.GeneratorSettings.SemiRandomizedGeneration = m_useSemiRandomGenerationCheck.IsChecked;
settings.GeneratorSettings.UseVanillaPlanets = m_useVanillaPlanetsCheck.IsChecked;
Expand Down
10 changes: 5 additions & 5 deletions SEWorldGenPlugin/GUI/PluginWorldSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class PluginWorldSettings : MyGuiScreenWorldSettings
{

public static MyGuiScreenWorldSettings Static;
public MyObjectBuilder_WorldSettings PluginSettings;
public LegacyMyObjectBuilder_WorldSettings PluginSettings;

private MyGuiControlCheckbox m_enablePlugin;
private MyGuiControlLabel m_enablePluginLabel;
Expand All @@ -43,7 +43,7 @@ public class PluginWorldSettings : MyGuiScreenWorldSettings

internal PluginSettingsGui SettingsGui;

public MyObjectBuilder_WorldSettings PlSettings;
public LegacyMyObjectBuilder_WorldSettings PlSettings;

/// <summary>
/// If the world should use the global configuration file
Expand Down Expand Up @@ -129,7 +129,7 @@ protected override void BuildControls()
}
else
{
MySettings.Static.SessionSettings = new MyObjectBuilder_WorldSettings();
MySettings.Static.SessionSettings = new LegacyMyObjectBuilder_WorldSettings();
MySettings.Static.SessionSettings.Enable = m_enablePlugin.IsChecked;
}
};
Expand Down Expand Up @@ -179,11 +179,11 @@ private void LoadValues()
var path = Path.Combine(MyFileSystem.SavesPath, Checkpoint.SessionName.Replace(":", "-"));
if(FileUtils.FileExistsInPath(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings)))
{
PlSettings = FileUtils.ReadXmlFileFromPath<MyObjectBuilder_WorldSettings>(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings));
PlSettings = FileUtils.ReadXmlFileFromPath<LegacyMyObjectBuilder_WorldSettings>(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings));
}
else
{
PlSettings = new MyObjectBuilder_WorldSettings();
PlSettings = new LegacyMyObjectBuilder_WorldSettings();
}
m_enablePlugin.IsChecked = PlSettings.Enable;
}
Expand Down
12 changes: 6 additions & 6 deletions SEWorldGenPlugin/MySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static MySettings Static
/// <summary>
/// Global configuration settings
/// </summary>
public MyObjectBuilder_WorldSettings Settings
public LegacyMyObjectBuilder_WorldSettings Settings
{
get;
private set;
Expand All @@ -36,7 +36,7 @@ public MyObjectBuilder_WorldSettings Settings
/// <summary>
/// To be loaded session settings
/// </summary>
public MyObjectBuilder_WorldSettings SessionSettings
public LegacyMyObjectBuilder_WorldSettings SessionSettings
{
get;
set;
Expand All @@ -48,7 +48,7 @@ public MyObjectBuilder_WorldSettings SessionSettings
public MySettings()
{
Static = this;
Settings = new MyObjectBuilder_WorldSettings();
Settings = new LegacyMyObjectBuilder_WorldSettings();
}

/// <summary>
Expand All @@ -63,7 +63,7 @@ public void LoadSettings()
{
using (var reader = FileUtils.ReadFileInGlobalStorage(FILENAME))
{
MyObjectBuilder_WorldSettings saveFile = FileUtils.SerializeFromXml<MyObjectBuilder_WorldSettings>(reader.ReadToEnd());
LegacyMyObjectBuilder_WorldSettings saveFile = FileUtils.SerializeFromXml<LegacyMyObjectBuilder_WorldSettings>(reader.ReadToEnd());
if (saveFile != null)
Settings = saveFile;
}
Expand All @@ -73,13 +73,13 @@ public void LoadSettings()
PluginLog.Log("Couldnt load Plugin config file.", LogLevel.ERROR);
PluginLog.Log(e.Message + "\n" + e.StackTrace, LogLevel.ERROR);
FileUtils.DeleteFileInGlobalStorage(FILENAME);
Settings = new MyObjectBuilder_WorldSettings();
Settings = new LegacyMyObjectBuilder_WorldSettings();
}
}
else
{
PluginLog.Log("Config does not exist, creating default one");
Settings = new MyObjectBuilder_WorldSettings();
Settings = new LegacyMyObjectBuilder_WorldSettings();
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Moon");
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Titan");
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Europa");
Expand Down
Loading

0 comments on commit caa0e3a

Please sign in to comment.