11using System ;
2+ using System . Collections . Generic ;
23using System . Linq ;
34using HotSpot . Model ;
45using HotSpot . Reflection ;
@@ -20,7 +21,7 @@ public sealed class HotSpotGuiBehavior : MonoBehaviour
2021 private bool _showConfigWindow ;
2122 private Rect _configWindowRect ;
2223 private ConfigWindowTab _configWindowTabActive = ConfigWindowTab . Context ;
23- private bool _configWindowContextShowTemperatureUnit ;
24+ private readonly Dictionary < string , bool > _configWindowContextShowUnits = new Dictionary < string , bool > ( ) ;
2425 private bool _configWindowOverlayShowMetrics ;
2526 private bool _configWindowOverlayShowSchemes ;
2627
@@ -30,6 +31,11 @@ public void Start()
3031 {
3132 Log . Trace ( "Entering HotSpotGuiBehavior.Start()" ) ;
3233
34+ foreach ( var metricNode in Config . Instance . ContextMenu . Metrics )
35+ {
36+ _configWindowContextShowUnits [ metricNode . Name . Name ] = false ;
37+ }
38+
3339 var buttonTexture = GameDatabase
3440 . Instance
3541 . GetTexture ( Config . Instance . Gui . ButtonTexture , asNormalMap : false ) ;
@@ -117,7 +123,7 @@ private void LateUpdateScreenMessage()
117123 {
118124 var scheme = Config . Instance . Overlay . GetActiveMetric ( ) . GetActiveScheme ( ) ;
119125
120- var metricMsg = Config . Instance . Overlay . Metric . FriendlyName ;
126+ var metricMsg = Config . Instance . Overlay . Metric . LongFriendlyName ;
121127 var schemMsg = scheme . FriendlyName == null ? string . Empty : $ " ({ scheme . FriendlyName } )";
122128 var stateMsg = PhysicsGlobals . ThermalColorsDebug ? "Enabled" : "Disabled" ;
123129
@@ -194,60 +200,40 @@ private void OnContextTab()
194200 {
195201 GUILayout . BeginHorizontal ( ) ;
196202
197- metricNode . Enable = GUILayout . Toggle ( metricNode . Enable , metricNode . Name . FriendlyName ) ;
203+ metricNode . Enable = GUILayout . Toggle ( metricNode . Enable , metricNode . Name . LongFriendlyName ) ;
198204
199- var isTemperatureMetric = metricNode . Name . Name == "Temperature" ;
200-
201- if ( isTemperatureMetric )
205+ if ( metricNode . Name . Units . Length > 1 )
202206 {
203207 GUILayout . FlexibleSpace ( ) ;
204208
205209 if ( GUILayout . Button ( "Unit" ) )
206210 {
207- _configWindowContextShowTemperatureUnit = ! _configWindowContextShowTemperatureUnit ;
211+ _configWindowContextShowUnits [ metricNode . Name . Name ] =
212+ ! _configWindowContextShowUnits [ metricNode . Name . Name ] ;
208213 }
209214 }
210215
211216 GUILayout . EndHorizontal ( ) ;
212217
213- if ( _configWindowContextShowTemperatureUnit && isTemperatureMetric )
218+ if ( _configWindowContextShowUnits [ metricNode . Name . Name ] )
214219 {
215- var temperatureMetricNode = Config
216- . Instance
217- . ContextMenu
218- . Metrics
219- . SingleOrDefault ( i => i . Name . Name == "Temperature" ) ;
220+ GUILayout . BeginVertical ( ) ;
220221
221- if ( temperatureMetricNode != null )
222+ var unitIndex = 0 ;
223+ for ( var i = 0 ; i < metricNode . Name . Units . Length ; i ++ )
222224 {
223- GUILayout . BeginVertical ( ) ;
224- var units = new [ ] { Unit . Kelvin , Unit . Rankine , Unit . Celsius , Unit . Fahrenheit } ;
225-
226- int unitIndex ;
227- switch ( temperatureMetricNode . Unit )
225+ if ( metricNode . Name . Units [ i ] == metricNode . Unit )
228226 {
229- case Unit . Kelvin :
230- unitIndex = 0 ;
231- break ;
232- case Unit . Rankine :
233- unitIndex = 1 ;
234- break ;
235- case Unit . Celsius :
236- unitIndex = 2 ;
237- break ;
238- case Unit . Fahrenheit :
239- unitIndex = 3 ;
240- break ;
241- default :
242- throw new ArgumentOutOfRangeException ( ) ;
227+ unitIndex = i ;
228+ break ;
243229 }
230+ }
244231
245- var newUnitIndex = GUILayout . SelectionGrid ( unitIndex , units . Select ( i => i . ToString ( ) ) . ToArray ( ) , 2 ) ;
232+ var newUnitIndex = GUILayout . SelectionGrid ( unitIndex , metricNode . Name . Units . Select ( i => i . ToString ( ) ) . ToArray ( ) , 2 ) ;
246233
247- temperatureMetricNode . Unit = units [ newUnitIndex ] ;
234+ metricNode . Unit = metricNode . Name . Units [ newUnitIndex ] ;
248235
249- GUILayout . EndVertical ( ) ;
250- }
236+ GUILayout . EndVertical ( ) ;
251237 }
252238 }
253239 GUILayout . EndVertical ( ) ;
@@ -261,7 +247,7 @@ private void OnOverlayTab()
261247
262248 GUILayout . Label ( "Metric:" ,
263249 new GUIStyle ( GUI . skin . label ) { fontStyle = FontStyle . Bold } , GUILayout . Width ( 55 ) ) ;
264- GUILayout . Label ( Config . Instance . Overlay . Metric . FriendlyName ) ;
250+ GUILayout . Label ( Config . Instance . Overlay . Metric . LongFriendlyName ) ;
265251 GUILayout . FlexibleSpace ( ) ;
266252 if ( GUILayout . Button ( "Select" , GUILayout . Width ( 50 ) ) )
267253 {
@@ -285,7 +271,7 @@ private void OnOverlayTab()
285271 }
286272
287273 var newMetricIndex = GUILayout . SelectionGrid (
288- metricIndex , metrics . Select ( i => i . Name . FriendlyName ) . ToArray ( ) , 1
274+ metricIndex , metrics . Select ( i => i . Name . LongFriendlyName ) . ToArray ( ) , 1
289275 ) ;
290276
291277 Config . Instance . Overlay . Metric = metrics [ newMetricIndex ] . Name ;
0 commit comments