Skip to content

Commit

Permalink
Settings page controls update rate display toggle
Browse files Browse the repository at this point in the history
Don't implement toggle in selected DispalyModules, implement globally in Settings.  Access static value via GuiUtils.
Per-window refresh rate currently implemented for Ascent Guidance and Custom Info Window as copy-pasta.
  • Loading branch information
DRVeyl committed Feb 28, 2022
1 parent 594fd9a commit ae24ad7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions MechJeb2/GuiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public enum SkinType { Default, MechJeb1, Compact }
public static int scaledScreenWidth = 1;
public static int scaledScreenHeight = 1;
public static bool dontUseDropDownMenu = false;
public static bool showAdvancedWindowSettings = false;
public static GUISkin defaultSkin;
public static GUISkin compactSkin;
public static GUISkin transparentSkin;
Expand Down
3 changes: 1 addition & 2 deletions MechJeb2/MechJebModuleAscentGuidance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,10 @@ private void UpdateStrings()
}
}

private bool advancedSettings = false;
private void RefreshRateGUI()
{
int oldRate = refreshRate;
if (advancedSettings = GUILayout.Toggle(advancedSettings,"Advanced Window Settings"))
if (GuiUtils.showAdvancedWindowSettings)
GuiUtils.SimpleTextBox("Update Interval",refreshRate,"Hz");
if (oldRate != refreshRate)
{
Expand Down
3 changes: 1 addition & 2 deletions MechJeb2/MechJebModuleCustomInfoWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ public virtual void UpdateWindowItems()
lastRefresh = now;
}

private bool advancedSettings = false;
private void RefreshRateGUI()
{
int oldRate = refreshRate;
if (advancedSettings = GUILayout.Toggle(advancedSettings,"Advanced Window Settings"))
if (GuiUtils.showAdvancedWindowSettings)
GuiUtils.SimpleTextBox("Update Interval",refreshRate,"Hz");
if (oldRate != refreshRate)
{
Expand Down
6 changes: 6 additions & 0 deletions MechJeb2/MechJebModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public MechJebModuleSettings(MechJebCore core) : base(core)
[ToggleInfoItem("#MechJeb_rssMode", InfoItem.Category.Misc), Persistent(pass = (int)Pass.Global)]//Module disabling does not kill throttle (RSS/RO)
public bool rssMode = false;

[Persistent(pass = (int)Pass.Global)]
public bool showAdvancedWindowSettings = false;

public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global)
{
base.OnLoad(local, type, global);
Expand Down Expand Up @@ -96,6 +99,9 @@ protected override void WindowGUI(int windowID)
dontUseDropDownMenu = GUILayout.Toggle(dontUseDropDownMenu, Localizer.Format("#MechJeb_Settings_checkbox1"));//"Replace drop down menu with arrow selector"
GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu;

showAdvancedWindowSettings = GUILayout.Toggle(showAdvancedWindowSettings,"Show Advanced Window Settings");
GuiUtils.showAdvancedWindowSettings = showAdvancedWindowSettings;

MechJebModuleCustomWindowEditor ed = core.GetComputerModule<MechJebModuleCustomWindowEditor>();
ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();

Expand Down

0 comments on commit ae24ad7

Please sign in to comment.