Search the Community
Showing results for tags 'ui_floatrange'.
-
As far as I can tell, it seems to be impossible to make two different instances of the same PartModule class end up having two different min/max ranges for the same UI slider on the right-click context menu. It's acting for all the world as if all instances of the PartModule must share the same min/max values and whichever instance happens to have altered them most recently, those values get used from then on by all the other instances too. (in other words, it's behaving exactly like static member fields on a class would). Here's an example of how I'm trying to dynamically change the min/max range values at runtime per-instance: It does this by reading the values from the part.cfg file (so instances of this PartModule for different parts can have different settings for the range allowed on the slider), and applying the value to the slider, like so: BaseField field; DebugMsg("LaserDist is trying to config GUI panel fields from settings:"); DebugMsg(String.Format("Part name = {0}, MaxBendX = {1}, MaxBendY = {2}", part.name, MaxBendX, MaxBendY)); field = Fields["BendX"]; ((UI_FloatRange)field.uiControlEditor).minValue = -MaxBendX; ((UI_FloatRange)field.uiControlEditor).maxValue = MaxBendX; if( MaxBendX == 0f ) { field.guiActive = false; field.guiActiveEditor = false; } else { field.guiActive = true; field.guiActiveEditor = true; } I verified that it is indeed seeing a different value for MaxBendX for two different parts, and is indeed running the code above two different times once for each part, and that it is indeed storing two different values for the *other* properties of the field "BendX" just fine - i.e. the guiActive and guiActiveEditor boolean flags *are* indeed behaving differently for the two different instances. If I set one of them to have a MaxBendX of 0 and the other to have a MaxBendX of 15, then it *does* hide the one with a value of 0 just like the above code shows it trying to do. But when I try to make them both have a nonzero value for MaxBendX, but a different nonzero value from each other, I just can't seem to force them to have different settings for max and min. If I set one partA's MaxBendX to 15 in the part.cfg file, and set partB's MaxBendX to 20 in its part.cfg file, then either *both* end up having ranges from -15 to +15 on their sliders, or *both* end up having ranges from -20 to +20 on their sliders. Which one I end up with seems to depend on which part KSP loads last. I proved this by changing the names of the parts to make them get sorted differently, and thus get KSP to load them in the opposite order. If partA loads last, then both partA and partB have a range of -15 to +15. If partB loads last, then both partA and PartB have a range of -20 to +20. I can't get partA to go from -15 to +15 and make partB go from -20 to +20. Is there a way for me to break out of this static-like behavior of the minValue and MaxValue so I can make them differ or am I just stuck?