@@ -104,11 +104,18 @@ private void AddLauncher()
104104 launcher ? . Disable ( true ) ;
105105 }
106106
107+ string lockReason ;
108+ if ( ! unlocked ( out lockReason ) ) {
109+ launcher ? . Disable ( true ) ;
110+ }
111+
107112 launcher ? . gameObject ? . SetTooltip (
108113 "PlanningNode_mainTitle" ,
109114 launcher . IsEnabled
110115 ? "PlanningNode_mainTooltip"
111- : "PlanningNode_viewOnlyTooltip"
116+ : string . IsNullOrEmpty ( lockReason )
117+ ? "PlanningNode_viewOnlyTooltip"
118+ : lockReason
112119 ) ;
113120 }
114121 }
@@ -121,6 +128,40 @@ private void RemoveLauncher()
121128 }
122129 }
123130
131+ /// <summary>
132+ /// Check whether the mod should be available for use in the current save.
133+ /// We need patched conics and flight planning.
134+ /// </summary>
135+ /// <param name="reason">User friendly explanation of why we're not available</param>
136+ /// <returns>
137+ /// true if unlocked, false if locked
138+ /// </returns>
139+ private static bool unlocked ( out string reason )
140+ {
141+ if ( ScenarioUpgradeableFacilities . Instance == null ) {
142+ reason = "" ;
143+ return true ;
144+ }
145+ var gVars = GameVariables . Instance ;
146+ var stationLevel = ScenarioUpgradeableFacilities . GetFacilityLevel ( SpaceCenterFacility . TrackingStation ) ;
147+ var stationOK = gVars . GetOrbitDisplayMode ( stationLevel ) == GameVariables . OrbitDisplayMode . PatchedConics ;
148+ var missionLevel = ScenarioUpgradeableFacilities . GetFacilityLevel ( SpaceCenterFacility . MissionControl ) ;
149+ var missionOK = gVars . UnlockedFlightPlanning ( missionLevel ) ;
150+ if ( ! stationOK ) {
151+ reason = ! missionOK ? "PlanningNode_unlockBothTooltip"
152+ : "PlanningNode_unlockStationTooltip" ;
153+ return false ;
154+ } else {
155+ if ( ! missionOK ) {
156+ reason = "PlanningNode_unlockMisConTooltip" ;
157+ return false ;
158+ } else {
159+ reason = "" ;
160+ return true ;
161+ }
162+ }
163+ }
164+
124165 /// <summary>
125166 /// This is called when they click our toolbar button
126167 /// </summary>
0 commit comments