Skip to content

De-stringify all the info items stuff #2258

Description

@lamont-granquist

The custom window presets:

public static class CustomWindowPresets
{
public struct Preset
{
public string name;
public string sharingString;
}
public static readonly Preset[] presets =
{
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname1"), //Orbit Info
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname1") + @"
Show in: flight
Value:VesselState.SpeedOrbital
Value:VesselState.OrbitApA
Value:VesselState.OrbitPeA
Value:VesselState.OrbitPeriod
Value:VesselState.OrbitTimeToAp
Value:VesselState.OrbitTimeToPe
Value:VesselState.OrbitSemiMajorAxis
Value:VesselState.OrbitInclination
Value:VesselState.OrbitEccentricity
Value:VesselState.OrbitLAN
Value:VesselState.OrbitArgumentOfPeriapsis
Value:VesselState.AngleToPrograde
Value:InfoItems.RelativeInclinationToTarget
-----------------------------" //Orbit Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname2"), //Surface Info
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname2") + @"
Show in: flight
Value:VesselState.AltitudeASL
Value:VesselState.AltitudeTrue
Value:VesselState.Pitch
Value:VesselState.Heading
Value:VesselState.Roll
Value:VesselState.SpeedSurface
Value:VesselState.SpeedVertical
Value:VesselState.SpeedSurfaceHorizontal
Value:InfoItems.GetCoordinateString
Value:InfoItems.CurrentBiome
-----------------------------" //Surface Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname3"), //Vessel Info
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname3") + @"
Show in: flight editor
Value:InfoItems.MaxAcceleration
Value:InfoItems.CurrentAcceleration
Value:InfoItems.MaxThrust
Value:InfoItems.VesselMass
Value:InfoItems.SurfaceTWR
Value:InfoItems.CrewCapacity
-----------------------------" //Vessel Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname4"), //Delta-V Stats
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname4") + @"
Show in: flight editor
Toggle:StageStats.DVLinearThrust
Value:InfoItems.StageDeltaVAtmosphereAndVac
Value:InfoItems.TotalDeltaVAtmosphereAndVac
General:InfoItems.AllStageStats
-----------------------------" //Delta-V Stats
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname5"), //Ascent Stats
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname5") + @"
Show in: flight
Value:FlightRecorder.DeltaVExpended
Value:FlightRecorder.GravityLosses
Value:FlightRecorder.DragLosses
Value:FlightRecorder.SteeringLosses
Value:FlightRecorder.TimeSinceMark
Value:FlightRecorder.PhaseAngleFromMark
Value:FlightRecorder.GroundDistanceFromMark
-----------------------------" //Ascent Stats
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname6"), //Rendezvous Info
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname6") + @"
Show in: flight
Value:InfoItems.TargetTimeToClosestApproach
Value:InfoItems.TargetClosestApproachDistance
Value:InfoItems.TargetClosestApproachRelativeVelocity
Value:InfoItems.TargetDistance
Value:InfoItems.TargetRelativeVelocity
Value:InfoItems.RelativeInclinationToTarget
Value:InfoItems.PhaseAngle
Value:InfoItems.SynodicPeriod
-----------------------------" //Rendezvous Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname7"), //Landing Info
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname7") + @"
Show in: flight
Value:VesselState.AltitudeTrue
Value:VesselState.SpeedVertical
Value:VesselState.SpeedSurfaceHorizontal
Value:InfoItems.SurfaceTWR
Action:TargetController.PickPositionTargetOnMap
Value:InfoItems.TargetDistance
Value:InfoItems.CurrentBiome
-----------------------------" //Landing Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname8"), //"Target Orbit Info"
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname8") + @"
Show in: flight
Value:InfoItems.TargetOrbitSpeed
Value:InfoItems.TargetApoapsis
Value:InfoItems.TargetPeriapsis
Value:InfoItems.TargetOrbitPeriod
Value:InfoItems.TargetOrbitTimeToAp
Value:InfoItems.TargetOrbitTimeToPe
Value:InfoItems.TargetSMA
Value:InfoItems.TargetInclination
Value:InfoItems.TargetEccentricity
Value:InfoItems.TargetLAN
Value:InfoItems.TargetAoP
Value:InfoItems.RelativeInclinationToTarget
-----------------------------" //Target Orbit Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname9"), //Stopwatch
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname9") + @"
Show in: flight
Action:FlightRecorder.Mark
Value:FlightRecorder.TimeSinceMark
Value:VesselState.Time
-----------------------------" //Stopwatch
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname10"), //"Surface Navigation"
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname10") + @"
Show in: flight
Action:TargetController.PickPositionTargetOnMap
Value:InfoItems.TargetDistance
Value:InfoItems.HeadingToTarget
Value:TargetController.GetPositionTargetString
-----------------------------" //Surface Navigation
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname11"), //"Atmosphere Info"
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname11") + @"
Show in: flight
Value:VesselState.AoA
Value:VesselState.AoS
Value:VesselState.AoD
Value:VesselState.Mach
Value:VesselState.DynamicPressure
Value:VesselState.MaxDynamicPressure
Value:VesselState.DragForce
Value:VesselState.LiftForce
Value:VesselState.DragCoefficient
Value:VesselState.AreaDrag
Value:VesselState.IntakeAir
Value:VesselState.IntakeAirAllIntakes
Value:VesselState.IntakeAirNeeded
Value:VesselState.AtmosphericDensityInGrams
Value:InfoItems.AtmosphericPressure
Value:VesselState.TerminalVelocity
-----------------------------" //Atmosphere Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname12"), //"Maneuver Node Info"
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname12") + @"
Show in: flight
Value:InfoItems.TimeToManeuverNode
Value:InfoItems.NextManeuverNodeDeltaV
Value:InfoItems.NextManeuverNodeBurnTime
-----------------------------" //Maneuver Node Info
},
new Preset
{
name = Localizer.Format("#MechJeb_WindowEd_Presetname13"), //"Hoverslam Info"
sharingString =
@"--- MechJeb Custom Window ---
Name: " + Localizer.Format("#MechJeb_WindowEd_Presetname13") + @"
Show in: flight
Value:HoverslamSimulation.Impact
Value:HoverslamSimulation.Ignition
Value:HoverslamSimulation.Touchdown
Value:HoverslamSimulation.HoverslamDeltaV
Value:HoverslamSimulation.HoverslamCoordinates
Value:HoverslamSimulation.Biome
Value:HoverslamSimulation.Slope
Value:HoverslamSimulation.TerrainAltitude
Toggle:HoverslamSimulation.MapLandingPrediction
Editable:HoverslamSimulation.VerticalAltitude
Editable:HoverslamSimulation.VerticalAuthority
Editable:HoverslamAutopilot.TouchdownSpeed
Editable:HoverslamAutopilot.PWMPulseWidth
Editable:HoverslamAutopilot.IgnitionLead
Editable:HoverslamSimulation.SimRecalcInterval
Toggle:HoverslamAutopilot.AutoWarp
Toggle:HoverslamAutopilot.HoldUpright
Action:HoverslamAutopilot.ToggleEnabled
Value:HoverslamAutopilot.HoverslamState
-----------------------------" //Hoverslam Info
}
};
}
}

Along with this code in settings:

ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Settings.useTitlebarDragging").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Menu.useAppLauncher").DrawItem();
if (ToolbarManager.ToolbarAvailable || Core.GetComputerModule<MechJebModuleMenu>().useAppLauncher)
ed.registry.Find(i => i.id == "Toggle:Menu.hideButton").DrawItem();
ed.registry.Find(i => i.id == "General:Menu.MenuPosition").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Settings.rssMode").DrawItem();

refer to info items via strings, and those get out of sync and IDEs don't know about those references.

not sure how to fix that, but it is definitely a bit of a pain.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions