@@ -35,13 +35,18 @@ public class JSISwitchableVariableLabel : InternalModule
3535 [ KSPField ]
3636 public string switchTransform = string . Empty ;
3737 [ KSPField ]
38+ public string decrementSwitchTransform = string . Empty ;
39+ [ KSPField ]
3840 public string switchSound = "Squad/Sounds/sound_click_flick" ;
3941 [ KSPField ]
4042 public float switchSoundVolume = 0.5f ;
4143 [ KSPField ]
4244 public string coloredObject = string . Empty ;
4345 [ KSPField ]
4446 public string colorName = "_EmissiveColor" ;
47+ [ KSPField ]
48+ public string alignment = "TopLeft" ;
49+
4550 private int colorNameId = - 1 ;
4651 private readonly List < VariableLabelSet > labelsEx = new List < VariableLabelSet > ( ) ;
4752 private int activeLabel ;
@@ -65,11 +70,16 @@ public void Start()
6570 rpmComp = RasterPropMonitorComputer . Instantiate ( internalProp , true ) ;
6671
6772 textObjTransform = JUtil . FindPropTransform ( internalProp , labelTransform ) ;
68- textObj = InternalComponents . Instance . CreateText ( fontName , fontSize * 15.5f , textObjTransform , "" , Color . green , false , "TopLeft" ) ;
73+ textObj = InternalComponents . Instance . CreateText ( fontName , fontSize * 15.5f , textObjTransform , "" , Color . green , false , alignment ) ;
6974 activeLabel = 0 ;
7075
7176 SmarterButton . CreateButton ( internalProp , switchTransform , Click ) ;
7277
78+ if ( decrementSwitchTransform != string . Empty )
79+ {
80+ SmarterButton . CreateButton ( internalProp , decrementSwitchTransform , DecremenetClick ) ;
81+ }
82+
7383 ConfigNode moduleConfig = null ;
7484 foreach ( ConfigNode node in GameDatabase . Instance . GetConfigNodes ( "PROP" ) )
7585 {
@@ -188,14 +198,21 @@ public override void OnUpdate()
188198 }
189199 }
190200
201+ private void DecremenetClick ( )
202+ {
203+ UpdateActiveLabel ( - 1 ) ;
204+ }
205+
191206 public void Click ( )
192207 {
193- activeLabel ++ ;
208+ UpdateActiveLabel ( + 1 ) ;
209+ }
194210
195- if ( activeLabel == labelsEx . Count )
196- {
197- activeLabel = 0 ;
198- }
211+ void UpdateActiveLabel ( int direction )
212+ {
213+ if ( labelsEx . Count == 0 ) return ;
214+
215+ activeLabel = ( activeLabel + direction + labelsEx . Count ) % labelsEx . Count ;
199216
200217 if ( labelsEx . Count > 1 && ! labelsEx [ activeLabel ] . oneShot )
201218 {
0 commit comments