Skip to content

Commit

Permalink
CachedLocalizer cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Oct 30, 2023
1 parent 5a71aa1 commit e60798f
Show file tree
Hide file tree
Showing 9 changed files with 379 additions and 305 deletions.
478 changes: 276 additions & 202 deletions MechJeb2/CachedLocalizer.cs

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions MechJeb2/MechJebModuleAscentMenu.cs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs
Expand Up @@ -108,21 +108,21 @@ protected override void WindowGUI(int windowID)
GUILayout.EndVertical();

GUILayout.BeginVertical(GUI.skin.box);
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label13, _ascentSettings.PitchStartVelocity, "m/s",
40); //Booster Pitch start:
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label14, _ascentSettings.PitchRate, "°/s", 40); //Booster Pitch rate:
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel13, _ascentSettings.PitchStartVelocity, "m/s",
40); //Booster Pitch start:
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel14, _ascentSettings.PitchRate, "°/s", 40); //Booster Pitch rate:
GUILayout.EndVertical();

GUILayout.BeginVertical(GUI.skin.box);
GuiUtils.SimpleTextBox("Q Trigger:", _ascentSettings.DynamicPressureTrigger, "kPa", 40);
GuiUtils.ToggledTextBox(ref _ascentSettings.StagingTriggerFlag, "PVG After Stage:", _ascentSettings.StagingTrigger, width: 40);
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label17, _ascentSettings.LimitQa, "Pa-rad"); //Qα limit
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel17, _ascentSettings.LimitQa, "Pa-rad"); //Qα limit
if (_ascentSettings.LimitQa < 1000 || _ascentSettings.LimitQa > 4000)
{
if (_ascentSettings.LimitQa < 0 || _ascentSettings.LimitQa > 10000)
GUILayout.Label("Qα limit has been clamped to between 0 and 10000 Pa-rad", GuiUtils.redLabel);
else
GUILayout.Label(CachedLocalizer.Instance.MechJeb_Ascent_label20,
GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel20,
GuiUtils.yellowLabel); //Qα limit is recommended to be 1000 to 4000 Pa-rad
}

Expand Down
24 changes: 12 additions & 12 deletions MechJeb2/MechJebModuleAscentSettingsMenu.cs
Expand Up @@ -15,8 +15,8 @@ public MechJebModuleAscentSettingsMenu(MechJebCore core) : base(core)
private MechJebModuleAscentSettings _ascentSettings => Core.AscentSettings;
private MechJebModuleAscentBaseAutopilot _autopilot => Core.Ascent;

private readonly string _climbString = $"{CachedLocalizer.Instance.MechJeb_Ascent_label22}: ";
private readonly string _turnString = $"{CachedLocalizer.Instance.MechJeb_Ascent_label23}: ";
private readonly string _climbString = $"{CachedLocalizer.Instance.MechJebAscentLabel22}: ";
private readonly string _turnString = $"{CachedLocalizer.Instance.MechJebAscentLabel23}: ";

private void ShowAscentSettingsGUIElements()
{
Expand All @@ -37,7 +37,7 @@ private void ShowAscentSettingsGUIElements()
Core.Thrust.ElectricThrottle = false;
}

_ascentSettings.ForceRoll = GUILayout.Toggle(_ascentSettings.ForceRoll, CachedLocalizer.Instance.MechJeb_Ascent_checkbox2); //Force Roll
_ascentSettings.ForceRoll = GUILayout.Toggle(_ascentSettings.ForceRoll, CachedLocalizer.Instance.MechJebAscentCheckbox2); //Force Roll
if (_ascentSettings.ForceRoll)
{
GUILayout.BeginHorizontal();
Expand All @@ -52,7 +52,7 @@ private void ShowAscentSettingsGUIElements()
{
GUIStyle s = _ascentSettings.LimitingAoA ? GuiUtils.greenToggle : null;
string sCurrentMaxAoA = $"º ({_autopilot.CurrentMaxAoA:F1}°)";
GuiUtils.ToggledTextBox(ref _ascentSettings.LimitAoA, CachedLocalizer.Instance.MechJeb_Ascent_checkbox3, _ascentSettings.MaxAoA,
GuiUtils.ToggledTextBox(ref _ascentSettings.LimitAoA, CachedLocalizer.Instance.MechJebAscentCheckbox3, _ascentSettings.MaxAoA,
sCurrentMaxAoA, s,
30); //Limit AoA to

Expand All @@ -63,7 +63,7 @@ private void ShowAscentSettingsGUIElements()
GUIStyle sl = _ascentSettings.LimitingAoA && VesselState.dynamicPressure < _ascentSettings.AOALimitFadeoutPressure
? GuiUtils.greenLabel
: GuiUtils.skin.label;
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label24, _ascentSettings.AOALimitFadeoutPressure, "Pa", 50,
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel24, _ascentSettings.AOALimitFadeoutPressure, "Pa", 50,
sl); //Dynamic Pressure Fadeout
GUILayout.EndHorizontal();
}
Expand All @@ -76,28 +76,28 @@ private void ShowAscentSettingsGUIElements()
// corrective steering only applies to Classic
GUILayout.BeginHorizontal();
_ascentSettings.CorrectiveSteering = GUILayout.Toggle(_ascentSettings.CorrectiveSteering,
CachedLocalizer.Instance.MechJeb_Ascent_checkbox4,
CachedLocalizer.Instance.MechJebAscentCheckbox4,
GuiUtils.ExpandWidth(false)); //Corrective steering
if (_ascentSettings.CorrectiveSteering)
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label25, _ascentSettings.CorrectiveSteeringGain, width: 40,
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel25, _ascentSettings.CorrectiveSteeringGain, width: 40,
horizontalFraming: false); // Gain
GUILayout.EndHorizontal();
}

_ascentSettings.Autostage = GUILayout.Toggle(_ascentSettings.Autostage, CachedLocalizer.Instance.MechJeb_Ascent_checkbox5); //Autostage
_ascentSettings.Autostage = GUILayout.Toggle(_ascentSettings.Autostage, CachedLocalizer.Instance.MechJebAscentCheckbox5); //Autostage
if (_ascentSettings.Autostage) Core.Staging.AutostageSettingsInfoItem();

_ascentSettings.AutodeploySolarPanels =
GUILayout.Toggle(_ascentSettings.AutodeploySolarPanels, CachedLocalizer.Instance.MechJeb_Ascent_checkbox6); //Auto-deploy solar panels
GUILayout.Toggle(_ascentSettings.AutodeploySolarPanels, CachedLocalizer.Instance.MechJebAscentCheckbox6); //Auto-deploy solar panels
_ascentSettings.AutoDeployAntennas =
GUILayout.Toggle(_ascentSettings.AutoDeployAntennas, CachedLocalizer.Instance.MechJeb_Ascent_checkbox7); //Auto-deploy antennas
GUILayout.Toggle(_ascentSettings.AutoDeployAntennas, CachedLocalizer.Instance.MechJebAscentCheckbox7); //Auto-deploy antennas

GUILayout.BeginHorizontal();
Core.Node.Autowarp = GUILayout.Toggle(Core.Node.Autowarp, CachedLocalizer.Instance.MechJeb_Ascent_checkbox8); //Auto-warp
Core.Node.Autowarp = GUILayout.Toggle(Core.Node.Autowarp, CachedLocalizer.Instance.MechJebAscentCheckbox8); //Auto-warp
if (_ascentSettings.AscentType != AscentType.PVG)
{
_ascentSettings.SkipCircularization =
GUILayout.Toggle(_ascentSettings.SkipCircularization, CachedLocalizer.Instance.MechJeb_Ascent_checkbox9); //Skip Circularization
GUILayout.Toggle(_ascentSettings.SkipCircularization, CachedLocalizer.Instance.MechJebAscentCheckbox9); //Skip Circularization
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions MechJeb2/MechJebModuleCustomInfoWindow.cs
Expand Up @@ -109,7 +109,7 @@ protected override void WindowGUI(int windowID)

if (items.Count == 0)
GUILayout.Label(CachedLocalizer.Instance
.MechJeb_WindowEd_CustomInfoWindow_Label1); //Add items to this window with the custom window editor.
.MechJebWindowEdCustomInfoWindowLabel1); //Add items to this window with the custom window editor.

RefreshRateGUI();

Expand Down Expand Up @@ -554,7 +554,7 @@ protected override void WindowGUI(int windowID)

public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(540) };

public override string GetName() => CachedLocalizer.Instance.MechJeb_WindowEd_title; //Custom Window Editor
public override string GetName() => CachedLocalizer.Instance.MechJebWindowEdTitle; //Custom Window Editor

public override string IconName() => "Custom Window Editor";

Expand Down
2 changes: 1 addition & 1 deletion MechJeb2/MechJebModuleInfoItems.cs
Expand Up @@ -309,7 +309,7 @@ public string MaximumVesselMass()
EditorDriver.editorFacility == EditorFacility.VAB);
return maximumVesselMass < float.MaxValue
? $"{maximumVesselMass:F3} t"
: CachedLocalizer.Instance.MechJeb_InfoItems_UnlimitedText; //"Unlimited"
: CachedLocalizer.Instance.MechJebInfoItemsUnlimitedText; //"Unlimited"
}

[ValueInfoItem("#MechJeb_DryMass", InfoItem.Category.Vessel, showInEditor = true, format = "F3", units = "t")] //Dry mass
Expand Down
28 changes: 14 additions & 14 deletions MechJeb2/MechJebModuleStagingController.cs
Expand Up @@ -176,24 +176,24 @@ public void AutostageOnce(object user)

protected override void OnModuleDisabled() => AutostagingOnce = false;

private readonly string _sFairingMinDynamicPressure = $" {CachedLocalizer.Instance.MechJeb_Ascent_label39} <";
private readonly string _sFairingMinAltitude = $" {CachedLocalizer.Instance.MechJeb_Ascent_label40} >";
private readonly string _sFairingMaxAerothermalFlux = $" {CachedLocalizer.Instance.MechJeb_Ascent_label41} <";
private readonly string _sFairingMinDynamicPressure = $" {CachedLocalizer.Instance.MechJebAscentLabel39} <";
private readonly string _sFairingMinAltitude = $" {CachedLocalizer.Instance.MechJebAscentLabel40} >";
private readonly string _sFairingMaxAerothermalFlux = $" {CachedLocalizer.Instance.MechJebAscentLabel41} <";

private readonly string _sHotstaging =
$"{CachedLocalizer.Instance.MechJeb_Ascent_hotStaging} {CachedLocalizer.Instance.MechJeb_Ascent_leadTime}";
$"{CachedLocalizer.Instance.MechJebAscentHotStaging} {CachedLocalizer.Instance.MechJebAscentLeadTime}";

private readonly string _sDropSolids =
$"{CachedLocalizer.Instance.MechJeb_Ascent_dropSolids} {CachedLocalizer.Instance.MechJeb_Ascent_leadTime}";
$"{CachedLocalizer.Instance.MechJebAscentDropSolids} {CachedLocalizer.Instance.MechJebAscentLeadTime}";

private readonly string _sLeadTime = $"{CachedLocalizer.Instance.MechJeb_Ascent_leadTime}: ";
private readonly string _sLeadTime = $"{CachedLocalizer.Instance.MechJebAscentLeadTime}: ";

[GeneralInfoItem("#MechJeb_AutostagingSettings", InfoItem.Category.Misc)] //Autostaging settings
public void AutostageSettingsInfoItem()
{
GUILayout.BeginVertical(GUI.skin.box);

GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label42, AutostageLimit, width: 40); //"Stop at stage #"
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel42, AutostageLimit, width: 40); //"Stop at stage #"

GUILayout.BeginHorizontal();
GUILayout.Label("Delays: ");
Expand All @@ -205,19 +205,19 @@ public void AutostageSettingsInfoItem()

ClampAutostageThrust();

GUILayout.Label(CachedLocalizer.Instance.MechJeb_Ascent_label38); //"Stage fairings when:"
GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel38); //"Stage fairings when:"
GuiUtils.SimpleTextBox(_sFairingMinDynamicPressure, FairingMaxDynamicPressure, "kPa", 50); //"dynamic pressure"
GuiUtils.SimpleTextBox(_sFairingMinAltitude, FairingMinAltitude, "km", 50); //altitude
GuiUtils.SimpleTextBox(_sFairingMaxAerothermalFlux, FairingMaxAerothermalFlux, "W/m²", 50); //aerothermal flux

GUILayout.BeginHorizontal();
HotStaging = GUILayout.Toggle(HotStaging, CachedLocalizer.Instance.MechJeb_Ascent_hotStaging); //"Support hotstaging"
HotStaging = GUILayout.Toggle(HotStaging, CachedLocalizer.Instance.MechJebAscentHotStaging); //"Support hotstaging"
GUILayout.FlexibleSpace();
GuiUtils.SimpleTextBox(_sLeadTime, HotStagingLeadTime, "s", 35); //"lead time"
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
DropSolids = GUILayout.Toggle(DropSolids, CachedLocalizer.Instance.MechJeb_Ascent_dropSolids); //"Drop solids early"
DropSolids = GUILayout.Toggle(DropSolids, CachedLocalizer.Instance.MechJebAscentDropSolids); //"Drop solids early"
GUILayout.FlexibleSpace();
GuiUtils.SimpleTextBox(_sLeadTime, DropSolidsLeadTime, "s", 35); //"lead time"
GUILayout.EndHorizontal();
Expand All @@ -228,16 +228,16 @@ public void AutostageSettingsInfoItem()
[ValueInfoItem("#MechJeb_Autostagingstatus", InfoItem.Category.Misc)] //Autostaging status
public string AutostageStatus()
{
if (!Enabled) return CachedLocalizer.Instance.MechJeb_Ascent_status9; //"Autostaging off"
if (AutostagingOnce) return CachedLocalizer.Instance.MechJeb_Ascent_status10; //"Will autostage next stage only"
return CachedLocalizer.Instance.MechJeb_Ascent_status11 + (int)AutostageLimit; //"Autostaging until stage #"
if (!Enabled) return CachedLocalizer.Instance.MechJebAscentStatus9; //"Autostaging off"
if (AutostagingOnce) return CachedLocalizer.Instance.MechJebAscentStatus10; //"Will autostage next stage only"
return CachedLocalizer.Instance.MechJebAscentStatus11 + (int)AutostageLimit; //"Autostaging until stage #"
}

[GeneralInfoItem("#MechJeb_ClampAutostageThrust", InfoItem.Category.Misc)] //Clamp Autostage Thrust
private void ClampAutostageThrust()
{
double prev = Core.Staging.ClampAutoStageThrustPct;
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJeb_Ascent_label44, Core.Staging.ClampAutoStageThrustPct, "%",
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel44, Core.Staging.ClampAutoStageThrustPct, "%",
50); //"Clamp AutoStage Thrust "
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (prev != Core.Staging.ClampAutoStageThrustPct)
Expand Down

0 comments on commit e60798f

Please sign in to comment.