Biotronic
Members-
Posts
359 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by Biotronic
-
That is kinda neat, and maybe I'll try it out. Given I already use scale types to make templates, one could define these once and be done with it. No more need for a new dll version to support a new addon's modules. I'm pretty sure there will be exceptions, though - where one should call an Update() function or somesuch after changing things. To be frank, that's not code I've written, so I had to check the source. This line does the scaling: savedScale = part.transform.GetChild(0).localScale = Vector3.Scale(basePart.transform.GetChild(0).localScale, rescaleVector); So it changes only the transform of the part, no special handling is done for multiple models. Actually, I have. Logarithmic scaling for instance, would be nice for at least some use cases.
-
@ZodiusInfuser: TweakScale has now been updated and released as a separate plugin. Given the set of scales you use, might I suggest this configuration in a separate file: SCALETYPE { name = IR freeScale = false scaleFactors = 0.25, 0.5, 1.0 scaleNames = Small, Medium, Large defaultScale = 1.0 } and this for each part: MODULE { name = TweakScale type = IR } That should give a nice little slider where you can choose between the sizes Small, Medium and Large.
-
[0.23.5] Goodspeed Aerospace Parts v2014.4.1B
Biotronic replied to Gaius's topic in KSP1 Mod Releases
Since people may be following TweakScale here, and since Gaius is the original author, I feel I should inform that TweakScale has found a new home: TweakScale - Rescale Everything! -
TweakScale is under new administraction Due to pressures outside the game, and the fact I rarely play KSP these days, I do not have the time to maintain TweakScale. In my absence, pellinor has accepted the burden and is currently the maintainer of TweakScale. Please visit his new release thread for updates. TweakScale lets you change the size of a part. Not just that, but it will figure out how much fuel is in the resized part. And if it's an engine, it will become more powerful by scaling it bigger, or weaker by scaling it smaller. This plugin was initially made by Gaius Goodspeed, and I heartily recommend you also take a look at his parts. TweakScale is already used by Gaius' parts above, and ZodiusInfuser's Infernal Robotics model rework, which I also recommend to anyone who likes having fun. TweakScale uses Swamp-Ig's KSPAPIExtensions. TweakScale is made available under the terms of the Do What the .... You Want to Public License. DOWNLOAD Alternative Download from Dropbox KerbalStuff Curse Page Source on GitHub Current Version: v1.50 (2014-12-24 10:40 UTC) HALP! It no worky! / FAQ Alright, calm down. We will get to the bottom of this. What symptoms are you experiencing? The scale slider is missing, and/or there's a gaping hole in the right-click menu! This is usually caused by an outdated KSPAPIExtensions.dll. If you have any of these mods installed, please update them. Also make sure you have the latest TweakScale installed. Sometimes when updating, you need to completely remove the old mod first. There may be other mods that use KSPAPIExtensions.dll than those listed there, so if that doesn't solve your problem, try a search for that file name. Lastly, this may be caused by Goodspeed Aerospace Parts. If you have it installed, find and remove its Scale.dll file. Part X of mod Y isn't rescalable! Great! That means I either have not updated the mod, or it's not on the list of supported mods, as seen below. I'm very happy to get updated cfgs, or just a note that some parts are not working. I don't use all the mods listed, so it's hard to keep them all updated. Part Z becomes too heavy when scaled up! Yeah, I'm a bit lazy, so all parts' mass scale with the cube of the size. That's the equivalent of saying every part is solid, or filled with heavy cream. Some parts are probably not filled, and may consist of but a thin skin over an empty inner. Maybe some day I'll get around to updating that kind of stuff. Otherwise, if someone else were to do it, I'd be more than happy to include their work! TweakScale and some other mod are having problems cooperating! First make sure both mods are up to date. Occasionally, a mod may change the names of files, so just overwriting with an updated version might not be enough. If necessary, take a backup. Then delete the folder in which the mod is installed, and install the updated version. If this does not solve your problem, or you're scared of breaking you game, please post here. As below, please post your output_log.txt. I'm having a problem and it's not listed here! Great! That means I can make TweakScale even better! Please post here and describe your problem. Make sure you have the newest version of TweakScale, and please post your output_log.txt. It's going to be too big to place in a single post, so upload it to Dropbox, Pastebin or some other service that lets you upload large text files. Please add TweakScale to your mod! If you are a mod author and you want to bundle TweakScale with your mod, please do! A few notes: Please place your TweakScale .cfgs in your mod's folder, not in the TweakScale folder. This way users can delete TweakScale and install a new version without breaking your mod. If your mod is already on the list of supported mods, please post here or PM me, and I will remove support, giving you full control over the .cfgs. Anyways, features: Scaling Control You as the author of a part or addon get complete control over which parts you want to offer in which sizes. Should that fuel tank only be available in size 2.5m and 3.75m? Make it so! That RCS thruster on the other hand, could be scalable freely between half regular scale and double regular scale. Mass Control For heavy, solid parts, mass increases with the cube of the scale - you scale it in three dimensions, after all. For parts that are a thin layer of aluminium plates over a rigid skeleton - like fairings, crew compartments, empty fuel tanks - mass probably scales closer to the square of the scale. Control Over Every Feature of a Part This is not all! Engines can be made more powerful as they increase in size, generators more efficient, and wings more lifty. All by writing a simple config file, and then automatically for all rescalable parts of that type. How to Use First add a part that's the wrong size: Right click: See how it says 3.75m? Well, the command capsule is 2.5m, so let's change it. You do this by pressing the << >> buttons or dragging the slider. See how well it fits? Example Configurations For a part that should be available in 62.5cm, 1.25m, 2.5m, 3.75m and 5m configurations, and by default is 1.25m, use the following definition: { name = TweakScale defaultScale = 1.25 type = stack }MODULE If the part should instead be freely rescalable, use this: { name = TweakScale type = free }MODULE And for a part that should be available in 25%, 50%, 100% and 200% scales, use: { name = TweakScale type = surface }MODULE But I said you had full control of scales, didn't I? If you want your parts to be available only in 2.5m and 3.75m versions, use this definition: { name = TweakScale type = stack scaleFactors = 2.5, 3.75 scaleNames = 2.5m, 3.75m }MODULE If your mod has a collection of parts that will all be available in the same set of sizes, you might want to make your own scale type: { name = MyMod freeScale = false scaleFactors = 0.5, 1.0, 2.0 scaleNames = Small, Medium, Large defaultScale = 1.0 }SCALETYPE After defining this once, you can then start using it for your parts: { name = TweakScale type = MyMod }MODULE As you can see the scale type uses the same names as the module definition, and they can even inherit from other scale types (if you want to change just a small detail): { name = spaceplane type = stack scaleFactors = 1.25, 2.5, 3.75, 5.0 scaleNames = 1.25m, 2.5m, 3.75m, 5m }SCALETYPE This will use all the defined properties of the 'stack' scaletype, but will not be available in 62.5cm size (because some poor kerbal is going to sit inside there). Adding module support You can now add support for your own modules! For a simple module that's happy with having its values changed when OnLoad is called, this is how: { name = MyPartModule flooberRate = 2 }TWEAKSCALEEXPONENTS When a user rescales a part with a MyPartModule module, TweakScale will automatically update the flooberRate of the part with the square of the scale (so if it's a 2.5m part and it's scaled to 3.75m, the flooberRate will be 2.25 times its usual value [3.75/2.5 = 1.5; 1.5^2 = 2.25]). New in 1.10 is the ability to change fields of fields - that is, myPartModule.someStruct.value or myPartModule.someList[x]: { name = ModuleGenerator outputList { rate = 3 } }TWEAKSCALEEXPONENTS The above config will scale all members of the list outputList on ModuleGenerator, to the cube of the current scale. Note that this system works for any depth: { name = ModuleMyModule foo { bar { quxRate = 3 } } }TWEAKSCALEEXPONENTS The above would scale ModuleMyModule.foo[x].bar.quxRate. New in 1.19 is tech requirements: { name = TweakScale type = stack techRequired = basicRocketry, start, generalRocketry, advRocketry, heavyRocketry }MODULE Here, each option in the stack SCALETYPE will be unlocked by a corresponding tech. If there are fewer techRequired than scaleNames/scaleFactors, the unmatched scales will be unlocked by default. It might be that your module would benefit more from using a list of values than an exponent. In that case, you may specify the list in the tweakscale module statement in the .cfg: { name = TweakScale type = stack defaultScale = 3.75 MODULE { name = ModuleEngines maxThrust = 1, 2, 3, 4, 5 } }MODULE Here, a 62.5cm version would have a maxThrust of 1, 1.25m would be 2, and so on until the 5m version has a maxThrust of 5. New in 1.23: Forced relative scaling! This is invaluable for persistent values. If they were to use absolute scaling, the default value would be loaded from the prefab part, scaled up, and used without a second thought. With relative scaling, the current value is loaded, the multiplied by the scale factor difference since last we looked. And it's super easy to use: { name = MyModule !MyValue = 2 }TWEAKSCALEEXPONENTS New in 1.30: Cost scaling! As 0.24.1 introduced the beautiful IPartCostModifier, TweakScale now supports changing the cost of a part: { name = TweakScale dryCost = 2 }TWEAKSCALEEXPONENTS The above configuration will make the cost of a part scale with its surface area. Useful for fuel tanks, solar sails, balloons and rugs. Thanks to NathanKell, 1.44 added support for not doing scaling when a specific module is added to a part. This is useful when TweakScale can do some updates on its own, but should keep its hands off when another module can do better. { name = MyModule socksPerMinute = 2 ignore = SockManager }TWEAKSCALEEXPONENTS This code will scale socksPerMinute by the square of the scale, or if there's a SockManager partmodule on the part, leave it all alone and let the SockManager do its thang. 1.48 adds Auto Scaling - a part will automatically choose an appropriate scale, based on the scale of the parent. This feature can be toggled with Ctrl+L, and temporarily disabled by holding Left Shift. 1.48 also adds Chain Scaling - if two 1.25m parts are placed atop one another, and you rescale the parent to 2.5m, the child will be scaled along with it. Chain Scaling can be toggled with Ctrl+K, and temporarily disabled by holding Left Shift. Lastly, 1.48 Auto Scaling and Chain Scaling both support asymmetric scaling. This means if you choose a 1.25m to 2.5m adapter as your first (root) part, and add a fuel tank in both ends of it, one will be scaled to 1.25m, the other to 2.5m. In order to wield this amazing power, TweakScale must be made aware of the sizes of the attach nodes of a part. This can be done on a per-part or per-scaletype basis. For a regular stack-mounted fuel tank, the nodes may be something like this: node_stack_bottom = 0.0, -0.3125, 0.0, 0.0, 1.0, 0.0, 1 node_attach = 0.5, 0.0, 0.0, 1.0, 0.0, 0.0node_stack_top = 0.0, 0.3125, 0.0, 0.0, 1.0, 0.0, 1 node_attach is the surface node. You should probably not auto-scale based on that. For the other two, we get this config: { MODULE { name = TweakScale defaultScale = 1.25 type = stack ATTACHNODES { base = 1 top = stack:1 bottom = stack:1 } } }@PART[MyFuelTank] For a 1.25m to 2.5m adapter, we instead get this: { MODULE { name = TweakScale defaultScale = 2.5 type = adapter_2_1 ATTACHNODES { base = 2 top = stack:1 bottom = stack:2 } } }@PART[MyAdapter] This basically means that node_stack_top for the adapter has a scale of (top/base) = (1/2) of the scale of the part, so 1.25m, while node_stack_bottom has a scale of (bottom/base) = (2/2) = 1 times the scale of the part, so 2.5m. The reason it says stack:1 is to have a system of families. This is the stack family, mostly intended for ...you guessed it - stack-mounted parts. This is just a string, so if you need a 'floopnurger' family, go right ahead. Only nodes with matching families will auto-scale, and one node can belong to more than one family. Advanced features If more advanced logic is required, TweakScale offers an IRescalable interface. It is defined in Scale_Redist.dll, and its definition is as follows: { void OnRescale(ScalingFactor factor); } public interface IRescalable<T> ScalingFactor has the properties 'absolute' and 'relative'. Most likely, you want to use absolute. relative is the change in scale since last time OnRescale was called, while absolute is the change in scale in relation to defaultScale. absolute and relative have properties linear, quadratic and cubic, which are shorthands for different scaling factors. If you want something different, you'll have to figure out the math yourself. IRescalable can be used in conjunction with .cfg exponents. In that case, TweakScale will first call IRescalable's OnRescale, followed by updates from .cfgs. (this may be changed in the future, as I'm not sure it's the best solution) An example implementation of an IRescalable may be: class MyModuleUpdater : TweakScale.IRescalable<MyPartModule> { MyPartModule _module; public MyModuleUpdater(MyPartModule module) { _module = module; } public void OnRescale(TweakScale.ScalingFactor factor) { _module.flooberRate = _module.flooberRate * factor.relative.quadratic; _module.ReactToFlooberRate(13); } } For an example implementation, check out how Modular Fuel Tanks/Real Fuels support is implemented. Version History: v1.50 (2014-12-24 10:40 UTC) Fixed erroneous placement of attach nodes when duplicating parts. Updated Scale_Editor.dll. Easier than removing it. v1.49 (2014-12-18 11:03 UTC) Now saving hotkey states correctly. 'Free' scaletype actually free. Fixed bug in OnStart. First attempt at scaling offsets. 1.48 (2014-12-16 22:54 UTC) Updated for .90! Cleaned up autoscaling and chain scaling. 1.47 (2014-11-17 20:03 UTC) Removed RealChute support. Fixed a bug where TweakScale would try to set erroneous values for some fields and properties, which notably affected Infernal Robotics. Fixed a bug where cloned fuel tanks would have erroneous volumes. 1.46 - 2014-11-16 20:03 UTC) Fixed an issue where features were incorrectly scaled upon loading a ship, Scaling a part now scales its children if they have the same size. Parts now automatically guess which size they should be. 1.44 (2014-10-10 19:20 UTC) Now updating UI sliders for float values. Better support for KSP Interstellar. Added support for TweakableEverything. Added support for FireSpitter's FSFuelSwitch. 1.44 (2014-10-10 19:20 UTC) Updated for KSP 0.25 Added ability to not update certain properties when a specific partmodule is on the part. Many thanks to NathanKell, who has all the credit for this release! 1.43 (2014-08-24 23:52 UTC) Added licence file (sorry, mods!) No longer chokes on null particle emitters. 1.41 (2014-08-15 11:43 UTC) Fixed scaling of Part values in unnamed TWEAKSCALEEXPONENTS blocks. 1.40 (2014-08-13 12:55 UTC) Removed Karbonite cfg, since that project does its own TweakScale config. 1.39 (2014-08-12 23:03 UTC) Fixed cost calculation for non-full tanks. 1.38 (2014-08-12 20:45 UTC) Added scaling of FX. Added support for Banana for Scale. Updated Karbonite support. Fixed a bug where no scalingfactors available due to tech requirements would lead to unintended consequences. 1.37 (2014-08-05 13:35 UTC) Updated cost calculation. 1.36 (2014-08-04 21:58 UTC) Updated Real Fuels and Modular Fuel Tanks support. Added KSPX support. 1.35 (2014-08-03 16:24 UTC) Corrected cost calculation. Updated to KSPAPIExtensions 1.7.0 1.34 (2014-08-02 00:49 UTC) Fixed a bug where repeated scaling led to inaccurate placing of child parts. Added Karbonite support. 1.33 (2014-07-28 20:00 UTC) Updated for RealFuels 7.1 1.32 (2014-07-25 22:29 UTC) Updated with KSPAPIExtensions 1.6.3 for 0.24.2 1.31 (2014-07-25 15:58 UTC) Fixed a bug where parts with defaultScale inaccessible due to tech requirements were incorrectly scaled. 1.30 (2014-07-25 11:23 UTC) Updated KSPAPIExtensions with 24.1 support. Re-enabled Real Fuels support. Added support for IPartCostModifier 1.29 (2014-07-24 11:50 UTC) Fixed Modular Fuel Tanks support. 1.28 (2014-07-24 10:32 UTC)) Fixed the rest of the bug that was partly fixed in 1.27. Added support for Tantares Space Technologies. 1.27 (2014-07-23 21:44 UTC) Fixed a bug on non-Windows platforms. 1.26 (2014-07-23 16:60 UTC) Fixed typo in DefaultScales.cfg. type = free, type = surface and so on should now work. Updated support for KW Rocketry and NFT. 1.25 (2014-07-23 12:31 UTC) Modular Fuel Tanks yet again supported! (Still waiting for Real Fuels) Refactored IRescalable system to be easier for mod authors. Fixed a bug where one field could have multiple exponents, and thus be rescaled multiple times. 1.24 (2014-07-21 20:51 UTC) Nodes are now correctly scaled when parts are duplicated. Per-scaletype exponents are now used correctly. 1.23 (2014-07-21 12:44 UTC) Multiple TweakScale .dlls no longer interfer with each other. 1.22 (2014-07-20 22:21 UTC) Fixed tanks that refill when you change between ships. Fixed tech lookup time, which was way too slow. 1.21 (2014-07-18 18:47 UTC) Updated for 0.24! More flexibility of configuration. Mod authors can now have feature scale definitions per part, per scaletype or global. 1.20 (2014-06-12 22:15 UTC) New algorithm for rescaling attach nodes. Tell me what you think! Added Deadly Reentry Continued and Large Structural/Station Components. 1.19 (2014-06-06 10:56 UTC) Added support for tech requirements for non-freeScale parts. 1.18 (2014-06-04 00:58 UTC) Factored out Real Fuels and Modular Fuel Tanks support to separate dlls. 1.17 (2014-06-03 22:21 UTC) Fixed bug where attachment nodes were incorrectly scaled after reloading. This time with more fix! Added support for Near Future Technologies. 1.16 (2014-06-03 21:31 UTC) Fixed bug where attachment nodes were incorrectly scaled after reloading. 1.15 (2014-06-03 20:50 UTC) Finally squished the bug where crafts wouldn't load correctly. This bug is present in 1.13 and 1.14, and affects certain parts from Spaceplane+, MechJeb, and KAX. 1.14 (2014-06-03 19:50 UTC) Fixed a bug where nodes with the same name were moved to the same location regardless of correct location. (Only observed with KW fairing bases, but there could be others) 1.13 (2014-06-02 18:25 UTC) Added support for MechJeb, Kerbal Aircraft eXpanion, Spaceplane+, Stack eXTensions, Kerbal Attachment System, Lack Luster Labs, Firespitter, Taverio's Pizza and Aerospace, Better RoveMates, and Sum Dum Heavy Industries Service Module System. Fixed a bug where Modular Fuel Tanks were not correctly updated. 1.12 (2014-06-02 11:10 UTC) Added support for ÚÞáÃœÞá. No longer scaling heatDissipation, which I was informed was a mistake. 1.11 (2014-06-01 20:24 UTC) Removed silly requirement of 'name = *' for updating all elements of a list. Added .cfg controlled scaling of Part fields. 1.10 (2014-06-01 14:53 UTC) Added support for nested fields. 1.9 (2014-05-31 00:57 UTC) Fixed a bug where rescaleFactor caused erroneous scaling. Added (some) support for Kethane parts. 1.8.1 (2014-05-30 22:41 UTC) Don't use 1.8.1, either. 1.8 Don't use 1.8 1.7 (2014-05-22 21:09 UTC) Removed spurious debug log printing. You can now use a list of value instead of an exponent! Exponents and value lists can be specified per part, not just per module type. (And per-part values take precedence) Fixed erroneous scale for Rockomax 48-7S, and added missing scale for KW Rocketry 2.5m Nose Cone. 1.6 (2014-05-22 14:04 UTC) Fixed a problem where parts were scaled back to their default scale after loading, duplicating and changing scenes. Fixed defaultScale for Rockomax 48-7S (was 625, should be .625. Who'd guess someone'd notice that, eh?) 1.5.0.1 (2014-05-21 00:36 UTC) Fixed a bug in 1.5 where scale was not correctly preserved. Updated KSPAPIExtensions.dll - please delete the version in GameData/. Added support for KSO. 1.5 (2014-05-20 22:23 UTC) Changed from hardcoded updaters to a system using .cfgs. Made registration of custom IRescalables possible. 1.4 (2014-05-20 17:53 UTC) Fixes compatibility with GoodspeedTweakScale (but not old versions of TweakScale, but that should be a much, much smaller problem anyway). Added scaling support for KW Rocketry, NovaPunch and KSP Interstellar. 1.3 (2014-05-19 22:49 UTC) Fixed a bug where parts would get rescaled to stupid sizes after loading. Breaks compatibility with old version of the plugin (pre-1.0) and GoodspeedTweakScale. 1.2 (2014-05-18 22:00 UTC) Fixed default scale for freeScale parts. Fixed node sizes, which could get absolutely redonkulous. Probably not perfect now either. B9 Aerospace, Talisar's Cargo Transportation Solutions, and NASA Module Manager configs. Now does scaling at onload, removing the problem where the rockets gets embedded in the ground and forcibly eject at launch. Fixed a silly bug in surface scale type. 1.1 (2014-05-17 23:30 UTC): Added scaling support for B9 Aerospace and Talisar's Cargo Transportation Solutions. Will now correctly load (some) save games using an older version of the plugin. 1.0 (2014-05-16 18:00 UTC): Initial Release! Supported Mods B9 Aerospace Cargo Transportation Solutions KW Rocketry NovaPunch 2 KSP Interstellar Kerbin Shuttle Orbiter System Kethane KOSMOS MechJeb Kerbal Aircraft eXpansion Spaceplane+ Stack eXTensions Kerbal Attachment System Lack Luster Labs Firespitter Taverio's Pizza and Aerospace Better RoveMates Sum Dum Heavy Industries Service Module System Near Future Technologies Deadly Reentry Continued Large Structural/Station Components Infernal Robotics USI Kolonization Systems (MKS/OKS) Klockheed Martian Special Parts Tantares Space Technologies Karbonite Modular Fuel Tanks Real Fuels KSPX RLA Stockalike Smart Parts Known Issues/TODO: More mods should be supported. I'm open to suggestions. Enlarged engines burn too hot. Exhaust trails are the wrong size. I think. Support for more modules (addons)? Suboptimal interactions with Procedural Parts and Procedural Fairings - parts may intersect after loading. I have no idea how FAR feels about the updating of drag and lift. Weird TWR in MechJeb. (ref post 22) Camera can end up in weird positions. (ref post 22) Add ModuleEngineConfig support. Do what Taverius says about engines and possibly other stuff.
-
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
*ahem* I knew that. -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
Apparently this is covered by KSP API Extensions's UI_ChooseOption Next question: can i hide a tweakable? -
[0.90] Magic Smoke Industries Infernal Robotics - 0.19.3
Biotronic replied to sirkut's topic in KSP1 Mod Releases
I've found an even better solution to the speed slider. Procedural Fairings makes use of a library called KSP API Extensions, which includes this tweakable, which I'm probably gonna use in the next version of TweakScale: It does basically what the current solution does, but with half the number of sliders (at the cost of lots of buttons). I believe the perfect solution would be closer to a logarithmic scale, though. But now that you have some code to work from, you might be able to make that. Or maybe I will. -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
For a moment I thought I'd gotten widget.fieldName.text to do what I wanted, but no. -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
After giving up on my previous idea, I had a new one: How's about I just find that slider and change the text on it? So I do: public void UpdateWindowText() { var win = FindObjectsOfType<UIPartActionWindow>() .Where(a => a.part == part).FirstOrDefault(); if (win == null) return; var widget = win.GetComponentsInChildren<UIPartActionFloatRange>() .Where(a => a.Control == UiControl) .FirstOrDefault(); if (widget == null) return; widget.fieldAmount.text = "Hello world!"; } And it works! ...sorta. I do get the text there, but it's immediately overwritten on the next frame. I guess UIPartActionItem.UpdateItem() is called every frame and recalculates it all? -
[0.90] Magic Smoke Industries Infernal Robotics - 0.19.3
Biotronic replied to sirkut's topic in KSP1 Mod Releases
For the tweakable discussion, you could go with two sliders - one having a large stepIncrement and maxValue, the other being simply an offset on that. Something like: [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Rough Speed")] [UI_FloatRange(minValue = 0f, maxValue = 5f, stepIncrement = 0.2f)] public float roughSpeed = 1; [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Detail Speed")] [UI_FloatRange(minValue = -0.1f, maxValue = 0.1f, stepIncrement = 0.01f)] public float detailSpeed = 0; float realSpeed { get { return roughSpeed + detailSpeed; } } Or, maybe: [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Rough Speed")] [UI_FloatRange(minValue = 0f, maxValue = 5f, stepIncrement = 0.2f)] public float roughSpeed = 1; [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Detail Speed")] [UI_FloatRange(minValue = 0.9f, maxValue = 1.1f, stepIncrement = 0.01f)] public float detailSpeed = 1; float realSpeed { get { return detailSpeed; } } public void Update() { if (savedRoughSpeed != roughSpeed) { var detailOffset = detailSpeed - savedRoughSpeed; var range = (UI_FloatRange)this.Fields["detailSpeed"].uiControlCurrent; range.minValue = roughSpeed - 0.1f; range.maxValue = roughSpeed + 0.1f; detailSpeed = roughSpeed + detailOffset; } } or maybe it's better to accept that the tweakable system is not ideal for this. -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
So I wrote some code. Any wizards here who can tell me why this doesn't work? using System; using UnityEngine; namespace TweakScale { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field)] public class UI_TextRange : UI_Control { public string[] valueSet; public UI_TextRange() { valueSet = new string[] { }; } public override void Load(ConfigNode node, object host) { base.Load(node, host); string tmp; if (UI_Control.ParseString(out tmp, node, "valueSet", "TextRange", "No value provided")) { valueSet = tmp.Split(',').Select(a => a.Trim()).ToArray(); } } public override void Save(ConfigNode node, object host) { node.AddValue("valueSet", string.Join(", ", valueSet)); } } [UI_TextRange] public class UIPartActionTextRange : UIPartActionFieldItem { private float realValue; private float offset; private float tmpValue; public SpriteText fieldAmount; public SpriteText fieldName; public UIProgressSlider slider; protected UI_TextRange progBarControl { get { return (UI_TextRange)control; } } public UIPartActionTextRange() { } private void Awake() { slider.SetValueChangedDelegate(new EZValueChangedDelegate(OnValueChanged)); } private float GetFieldValue() { if (!this.isModule) { return this.field.GetValue<float>((object)this.part); } else { return this.field.GetValue<float>((object)this.partModule); } } private void OnValueChanged(IUIObject obj) { this.tmpValue = Mathf.Lerp(0, this.progBarControl.valueSet.Length, this.slider.Value); this.offset = this.tmpValue % 1; if (this.offset != 0.0) { if (this.offset < 0.5) { this.realValue = this.tmpValue - this.offset; } else { this.realValue = this.tmpValue + 1 - this.offset; } } else { this.realValue = this.tmpValue; } this.slider.Value = Mathf.InverseLerp(0, this.progBarControl.valueSet.Length, this.realValue); this.realValue = (float)Math.Round(this.realValue, 5); this.field.SetValue(this.realValue, this.field.host); if (this.scene == UI_Scene.Editor) { this.SetSymCounterpartValue((object)this.realValue); } } private void SetSliderValue(float rawValue) { this.slider.Value = Mathf.Clamp01(rawValue / this.progBarControl.valueSet.Length); } public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); this.SetSliderValue(this.GetFieldValue()); this.slider.AddValueChangedDelegate(new EZValueChangedDelegate(this.OnValueChanged)); this.slider.ignoreDefault = true; } public override void UpdateItem() { this.realValue = this.GetFieldValue(); this.fieldName.Text = this.field.guiName; this.fieldAmount.Text = this.progBarControl.valueSet[(int)realValue]; this.SetSliderValue(this.realValue); } } } -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
Is it possible to get a slider as with UI_FloatRange, but with a set of text values? Say for scale, you could have 'small', 'medium', 'large' instead of 0, 1, 2. -
[0.90] Magic Smoke Industries Infernal Robotics - 0.19.3
Biotronic replied to sirkut's topic in KSP1 Mod Releases
I think the latter is the better choice. -
[0.23.5] Goodspeed Aerospace Parts v2014.4.1B
Biotronic replied to Gaius's topic in KSP1 Mod Releases
That's the idea, yes. It's a bit finicky with scales 0.25, 0.5, 1.0, 2.0, 4.0, since the gap between 0.25 and 0.5 is so tiny. What I'd love to have is a list of string values, so the gaps between values would be the same for 0.25->0.5 as for 2.0->4.0. Currently however, that's simply not possible. Makes sense, and I'm actually glad you have a specific vision. I just want to make this thing. This is true. I guess part of it is just me wanting to write code. -
[0.23.5] Goodspeed Aerospace Parts v2014.4.1B
Biotronic replied to Gaius's topic in KSP1 Mod Releases
I wrote some logic for modes, but for some reason thought type sounded more betterer. Dll here. Default scale types/modes here. Usage: MODULE { name = GoodspeedTweakScale type = surface } MODULE { name = GoodspeedTweakScale type = free maxScale = 2.0 } And for IR parts: SCALETYPE { name = IR type = surface maxScale = 1.0 } MODULE { name = GoodspeedTweakScale type = IR } As you can see, IR is derived from surface, and will take from there any values not specified in IR. You can create any depth hierarchies like this, but why on earth would you? Also, it's possible to make a scaletype derive from itself. Don't do that. [edit]Oh, and it's not at all necessary to specify everything in a scaletype, I just did it for clarity.[/edit] -
[0.23.5] Goodspeed Aerospace Parts v2014.4.1B
Biotronic replied to Gaius's topic in KSP1 Mod Releases
I also kinda consider adding 'modes', so that you use this for stack parts: MODULE { name = GoodspeedTweakScale mode = stack } and get 0.625, 1.25, 2.5, 3.75, 5.0 scales, and MODULE { name = GoodspeedTweakScale mode = surface } for 0.25, 0.5, 1.0, 2.0. And lastly, MODULE { name = GoodspeedTweakScale mode = free } For free scaling between 0.25 and 4.0. This wouldn't add any 'real' features, only make a convenient shorthand for users for setting scaleFactors. -
[0.23.5] Goodspeed Aerospace Parts v2014.4.1B
Biotronic replied to Gaius's topic in KSP1 Mod Releases
You can still have whatever numbers you want if you want to. For your parts, I would argue that 0.25, 0.5, 1.0 would make more sense anyway. In that case, you'd use this configuration: MODULE { name= GoodspeedTweakScale scaleFactors = 0.25, 0.5, 1.0 defaultScale = 1.0 } Actually, I would argue in favor of adding 2.0 as well. Now that it doesn't take up more space in the list, adding more sizes has a lower cost (there is still some in terms of cognitive overhead). -
The Tweakables Thread
Biotronic replied to dtobi's topic in KSP1 C# Plugin Development Help and Support
My (and Gaius') TweakScale plugin does that. Code from Scale.cs around line 140: var range = (UI_FloatRange)this.Fields["tweakScale"].uiControlEditor; range.minValue = configValue("minScale", defaultValue: isFreeScale ? 0.5f : (float)scaleFactors.First()); range.maxValue = configValue("maxScale", defaultValue: isFreeScale ? 2.0f : (float)scaleFactors.Last()); range.stepIncrement = configValue("stepIncrement", defaultValue: 0.01f); There's also a uiControlFlight, which I assume is the same thing except while flying, but I haven't tested that.