Skip to content

Commit

Permalink
Added enable patching button for the global configuration settings.
Browse files Browse the repository at this point in the history
This was done to make players aware of the setting and make it easier to find it.
  • Loading branch information
thorwin99 committed Jan 5, 2022
1 parent 1a215d1 commit 75e1cd9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
32 changes: 32 additions & 0 deletions SEWorldGenPlugin/GUI/MyPluginGlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,38 @@ public override void RecreateControls(bool constructor)
var moonNameLabel = new MyGuiControlLabel(null, null, "Moon name format");
var beltNameLabel = new MyGuiControlLabel(null, null, "Belt name format");

var enablePatchingLabel = new MyGuiControlLabel(null, null, "Enable Patching?");

MyGuiControlCheckbox enablePatchingCheckbox = new MyGuiControlCheckbox(null, null, "Requires Restart. Enables patching for the plugin. Please read the wiki for more information about it.");
enablePatchingCheckbox.IsChecked = MySettings.Static.Settings.EnablePatching;
enablePatchingCheckbox.IsCheckedChanged += delegate
{
if (enablePatchingCheckbox.IsChecked)
{
MyPluginGuiHelper.DisplayQuestion("Do you want to enable Patching?", "Warning", delegate (MyGuiScreenMessageBox.ResultEnum res)
{
if(res == MyGuiScreenMessageBox.ResultEnum.YES)
{
MySettings.Static.Settings.EnablePatching = true;
}
else
{
MySettings.Static.Settings.EnablePatching = false;
enablePatchingCheckbox.IsChecked = false;
}
});
}
else
{
MySettings.Static.Settings.EnablePatching = false;
enablePatchingCheckbox.IsChecked = false;
}
};

parent.AddTableRow(enablePatchingLabel, enablePatchingCheckbox);

parent.AddTableSeparator();

#region Tables

///Moons table
Expand Down
12 changes: 12 additions & 0 deletions SEWorldGenPlugin/GUI/MyPluginGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,17 @@ public static void DisplayMessage(string message, string caption, Action<ResultE
MyGuiScreenMessageBox msg = new MyGuiScreenMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.OK, new StringBuilder(message), new StringBuilder(caption), MyCommonTexts.Ok, MyCommonTexts.Cancel, MyCommonTexts.Yes, MyCommonTexts.No, callback, 10000, MyGuiScreenMessageBox.ResultEnum.CANCEL, true, null); ;
MyGuiSandbox.AddScreen(msg);
}

/// <summary>
/// Displays a question box to the user and calls the given callback, when it is closed.
/// </summary>
/// <param name="message">The question</param>
/// <param name="caption">The caption of the box</param>
/// <param name="callback">Callback to call when closed</param>
public static void DisplayQuestion(string message, string caption, Action<ResultEnum> callback = null)
{
MyGuiScreenMessageBox msg = new MyGuiScreenMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, new StringBuilder(message), new StringBuilder(caption), MyCommonTexts.Ok, MyCommonTexts.Cancel, MyCommonTexts.Yes, MyCommonTexts.No, callback, 10000, MyGuiScreenMessageBox.ResultEnum.CANCEL, true, null); ;
MyGuiSandbox.AddScreen(msg);
}
}
}
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.1.2.0")]
[assembly: AssemblyVersion("2.1.3.0")]
[assembly: AssemblyFileVersion("2.1.2.0")]
2 changes: 1 addition & 1 deletion SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void TrackEntity(MyEntity entity)
{
if (!MySettingsSession.Static.IsEnabled() || !Sync.IsServer) return;


if (entity is MyCharacter)
{
if (m_trackedEntities == null || m_newTrackedEntities == null || m_trackedEntities.Contains(entity)) return;
Expand Down

0 comments on commit 75e1cd9

Please sign in to comment.