@@ -24,6 +24,9 @@ public class StageInfoOABController : MonoBehaviour
2424 private static ManualLogSource _logger = BepInEx . Logging . Logger . CreateLogSource ( "MicroEngineer.StageInfoOABController" ) ;
2525 private bool _lockUiRefresh ;
2626
27+ private double _totalDeltaVASL ;
28+ private double _totalDeltaVVac ;
29+
2730 public StageInfoOABController ( )
2831 { }
2932
@@ -97,6 +100,9 @@ private void BuildStages(List<DeltaVStageInfo_OAB> stages)
97100 stage . CelestialBody . Name
98101 ) ;
99102
103+ _totalDeltaVASL += stage . DeltaVASL ;
104+ _totalDeltaVVac += stage . DeltaVVac ;
105+
100106 var celestialBodyDropdown = control . Q < DropdownField > ( "body-dropdown" ) ;
101107 celestialBodyDropdown . RegisterCallback < MouseDownEvent > ( evt =>
102108 {
@@ -132,27 +138,44 @@ private void HandleStageInfoChanged(List<DeltaVStageInfo_OAB> stages)
132138 if ( _lockUiRefresh ) return ;
133139
134140 Body . Clear ( ) ;
141+ TotalAslDeltaVContainer . Clear ( ) ;
142+ _totalDeltaVASL = 0 ;
143+ TotalVacDeltaVContainer . Clear ( ) ;
144+ _totalDeltaVVac = 0 ;
145+ TotalBurnTimeContainer . Clear ( ) ;
135146 BuildStages ( stages ) ;
147+ SetTotalValues ( ) ;
136148 }
137149
138150 private void BuildFooter ( )
151+ {
152+ Footer = Root . Q < VisualElement > ( "footer" ) ;
153+ TotalAslDeltaVContainer = Root . Q < VisualElement > ( "asl-dv-container" ) ;
154+ TotalVacDeltaVContainer = Root . Q < VisualElement > ( "vac-dv-container" ) ;
155+ TotalBurnTimeContainer = Root . Q < VisualElement > ( "burn-time-container" ) ;
156+
157+ SetTotalValues ( ) ;
158+ }
159+
160+ private void SetTotalValues ( )
139161 {
140162 BaseEntry entry ;
141163 VisualElement control ;
142164
143- Footer = Root . Q < VisualElement > ( "footer" ) ;
144-
145- TotalAslDeltaVContainer = Root . Q < VisualElement > ( "asl-dv-container" ) ;
146165 entry = StageInfoOABWindow . Entries . Find ( e => e is TotalDeltaVASL_OAB ) ;
147- control = new BaseEntryControl ( entry ) ;
166+ // total deltav from stock stage info is wrong because it doesn't take into account different bodies.
167+ // so here we'll sum up values for all calculated stages and won't subscribe to automatic value changes
168+ entry . EntryValue = _totalDeltaVASL ;
169+ control = new BaseEntryControl ( entry , false ) ;
148170 TotalAslDeltaVContainer . Add ( control ) ;
149-
150- TotalVacDeltaVContainer = Root . Q < VisualElement > ( "vac-dv-container" ) ;
171+
151172 entry = StageInfoOABWindow . Entries . Find ( e => e is TotalDeltaVVac_OAB ) ;
152- control = new BaseEntryControl ( entry ) ;
173+ // total deltav from stock stage info is wrong because it doesn't take into account different bodies.
174+ // so here we'll sum up values for all calculated stages and won't subscribe to automatic value changes
175+ entry . EntryValue = _totalDeltaVVac ;
176+ control = new BaseEntryControl ( entry , false ) ;
153177 TotalVacDeltaVContainer . Add ( control ) ;
154178
155- TotalBurnTimeContainer = Root . Q < VisualElement > ( "burn-time-container" ) ;
156179 entry = StageInfoOABWindow . Entries . Find ( e => e is TotalBurnTime_OAB ) ;
157180 control = new TimeEntryControl ( entry ) ;
158181 TotalBurnTimeContainer . Add ( control ) ;
0 commit comments