Search the Community
Showing results for tags 'kspfield'.
-
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?
-
I have a KSPField with the UI_ChooseOption user interface attached. Now I would really like to make it so, that it was only available on EVA. However, it turns out the KSPField does not have that feature, but UI_ChooseOption cannot be used with KSPEvents since it will not accept a method.... What can be done. I considered simply hiding the UI in flight unless I was on EVA. However, I am not sure how to do that. Does anybody know a nice way to have the above, or something similar to be bound to EVA. Alternatively, can anybody advice on how to detect EVA? And which events to subscribe to to detect it.
- 4 replies
-
- ui_chooseoption
- kspfield
-
(and 1 more)
Tagged with:
-
Is it possible to add arbitrary number of integer ksp fields at runtime in partmodule ? Closest example is at KSPAPIExtensions github page for a pre-defined chooser-type field, but i need one for int variable created at runtime. I did also find some examples in github sources of Infernal Robotics, but they also apply only to predefined variables. I did compile a variable with KSPField that has functions defined in its getter and setter, no errors were thrown. I don't know how to formulate my question but this is what i need : - variable is allocated at runtime as part of array or list - variable needs to be displayed to user in UI (this is where KSPAPiExt helps) Also, is KSP API Extensions at all capable of displaying values inside array or (preferably) List ?
- 16 replies
-
- kspfield
- kspapiextensions
-
(and 1 more)
Tagged with: