Jump to content

[1.3.1] Upgrade Editor - Choose upgrades for each part in VAB or SPH.


NotTheRealRMS

Recommended Posts

This was originally meant to become UpgradesGUI Continued, but for several reasons starting "from scratch" proved more practical, and this Add-On inherited only a little from the former by @Gotmachine. For now it remains more limited than UpgradesGUI in certain ways.

This plugin works in the VAB or SPH and adds a button to the right-click menu on any parts with upgrades to expand their applications and allow for implementing upgrades as alternatives which can be chosen at any time, regardless of newer ones being unlocked in the Tech Tree.

DISCLAIMER:

A lot needs to be improved before it gets even close to completed. This plugin was tested on Engines and RCS where, with the aid of the MM patches, it worked both in  Editor and Flight, but there are almost certainly bugs.

Download

Upgrade Editor 0.3.4 (includes source code):

https://drive.google.com/open?id=1Cm5WA73G3IEONZ-JjEXQC0ULmpUA3Og1

Older versions:

https://drive.google.com/open?id=1Zlj9p-RIceb1yP-43V-8SjG_30FIP_fk

DEPENDENCIES:

ModuleManager (bundled version may become temporarily outdated in the future)

License: GNU General Public License(GPL) 3.0 except for:

LKn51I3.jpg

Upgrade Editor

Upgrade Editor was created to make the part/module upgrades feature introduced in 1.2 about as flexible as RealFuels engine and RCS upgrades: configurable per part. Note that the plugin doesn't add any upgrades. If you want to have them in your game you need to download other mods that implement the upgrade feature. It also highlights part upgrades in the  the nodes part list with a pale green background to better differentiate them from parts.

How to Use:

  • If you really want to browse every upgrade, even max diameter changes for procedural parts, delete UpgradesToIgnore.cfg
  • While designing a vessel in the VAB/SPH, add a part for it which has unlocked upgrades.
  • After placing the part in the editor, click on "Upgrade Editor" in the Part's right-click menu.
  • "Toggle All" will either disable or enable all upgrades at once. "Always Enable" ignores custom settings.
  • When you're finished with a part, just close the Upgrade Editor by clicking on "Close". Check its "Show Upgraded Stats".
  • After that, any part featuring the same upgrades that is added to the craft will inherit such settings as well.
  • To reset settings, use the reset & close button in the menu, which will enable again all upgrades before closing the UI.

 

Suggested mods with upgrades:

  • Sufficiently Realistic Progression Zero - this was created to support it and is bundled together with it(not necessarily the latest version).
  • SSTULabs - upgrades that come with SSTU aren't of the type that would be significantly improved by the features of the Upgrade Editor(yet), but I'm recommending it anyway.
  • Bluedog Design Bureau - might not really have two upgrades that can be considered tradeoffs, giving this editor a purpose for its parts, but it does have many upgrades.

If you're interested in implementing part upgrades for yours, another mod's or Stock engines or RCS as alternatives where the capabilities of this Add-On would be very useful, PM me and I'll include your mod in the list. If you want to bundle this plugin with your mod because it would be useful for it, you don't need to ask for permission. Just keep its license and readme in your bundle, and if you want to remove its source code from it, add a link to this thread or to its download link with source included in its readme should it not have either one yet by then.

A few examples of potential uses:

  • An engine or RCS that can be switched between MonoPropellant and LF/Ox. Could be added to any Stock part through ModuleManager.
  • Several upgrades for engines or RCS placed in the same tech tree's node with different tradeoffs between thrust, specific impulse and cost.

Known Issues and Limitations:

  • This plugin was not tested for every imaginable situation where it could be of use. Bugs may exist.
  • There is no in-game interface to edit the ignore list of upgrades yet.
  • Terrible support for part symmetry. First this won't apply automatically to all symmetrical counterparts of the selected part yet. Then there are bugs: if you open the Upgrade Editor Menu in a part, change its upgrade settings then alter its symmetry, argument out of range exception spam will happen and the Upgrade Editor button may disappear in all affected parts. Doesn't happen when picking a new part for symmetry from the left part menu, which inherits upgrade settings from latest edited similar with Upgrade Editor, and can also be avoided by saving and reloading the vessel after using the Upgrade Editor Menu to only then apply symmetry.

Changelog:

Version 0.3.4

  • Fixed crippling bug with RCS part upgrades by disabling the OnAwake() command for ModuleRCS and RCSFX. Now works correctly instead of having no RCS thrust at all.
  • Fixed major bug where the first part with modified upgrade settings in a vessel loaded in VAB/SPH didn't have its upgrades properly applied.
  • Fixed lack of reset to original Part Stats modified by PartStatsUpgradeModule upon disabling relevant upgrades.
  • Fixed occasional bug where an Engine or RCS with upgrades that did not change propellant type would not have such reverted back during the load of a craft file if upgrades that changed such settings were disabled, depending on the quantity and position of the involved parts in a saved craft.
  • Toggle All Upgrades now is set to false by default, which makes any part picked from the left menu in the Editor inherit the same settings last applied to a similar part through the Upgrade Editor.

Version 0.3.3

  • Added capability of loading original part configs without upgrades and removed no longer necessary ModuleManager workaround patches.
  • Added an Ignore List so upgrades that are utterly pointless to disable like diameter increases for procedural parts won't show up.

Version 0.3.2.5

  • Added full persistence for upgrade settings. Saved crafts now store which upgrades should not be enabled for every part in them.

Version 0.3.2

  • First test release, inheriting only the R&D tech tree highlight from UpgradesGUI and relying on wholly new code for everything else.

 

Special Thanks:

To @Gotmachine for doing UpgradesGUI, which inspired this project and served as reference for it.

To @Shadowmage for unintentionally giving me a hint on how to achieve this when I was about to give up on this and mostly because I really like SSTU.

To everyone who shared and/or created examples of PopupDialog uses , references without which I'd never succeed in creating this.

Edited by NotTheRealRMS
0.3.4 and added new screenshot
Link to comment
Share on other sites

Very interesting mod -- really a feature that should have been included in the stock upgrade system.  A way to pick which upgrades are applied seems like a very basic part of the system.

If this plays well with SSTU code, it removes some of the reasons I've been hesitating on engine and other part upgrades.

 

12 hours ago, NotTheRealRMS said:

To @Shadowmage for unintentionally giving me a hint on how to achieve this when I was about to give up on this and mostly because I really like SSTU.

Yeah... I sometimes do that kind of thing  (usually it is intentional though) :)

Link to comment
Share on other sites

Interesting. I gave up on updating UpgradesGUI after 1.3 because I couldn't get a reliable way to manage the per-part status of upgrades. It's a big mess.

Doing it with a partmodule is a good idea and may work in the end, but you haven't overcome what made me give up : they added some custom logic in the editor, upgrades are always reapplied to parts that gets loaded in the editor based on the current enabled/disabled status in the PartUpgradeHandler, regardless of what was saved. Try this :

  • create a new sandbox game, set the difficulty settings to have all upgrades enabled (the effect would be the same in career mode with unlocked upgrades)
  • go to the editor, add a part
  • edit the upgrades
  • save the craft
  • open the craft
  • all stats are reverted to non-upgraded state. I think this is because your plugin is setting AllEnabled to false in Start(). If AllEnabled was set to the default (true), all existing upgrades would be applied to all partmodules on the craft.

This mean that when loading an existing craft in the editor, you need to iterate trough each module of each part, enable/disable upgrades in the PartUpgradeHandler according to the craft saved Upgrade confignode and apply them. Since you have gone the partmodule way, it shouldn't be too difficult.

As for reverting to base stats when no upgrades are applied, it is indeed messy. Here is how I'm doing it. It won't handle sub-nodes but in my tests for a 1.3 version, I found a workaround : instead of copying the field values from the prefab partinfo confignodes, I instantiate the part, get the field values from it and then destroy it. A bit hacky but it works and will support every possible partmodule.

License note :  you can re-license my code under GPL, no need to release some part under the unlicense (it's an unrestricted public domain license). This said, I encourage you to release your work in the public domain too so others can freely reuse your code, in my humble opinion the license hell around here is getting awful.

Link to comment
Share on other sites

On 11/15/2017 at 8:31 PM, Gotmachine said:

Interesting. I gave up on updating UpgradesGUI after 1.3 because I couldn't get a reliable way to manage the per-part status of upgrades. It's a big mess.

Doing it with a partmodule is a good idea and may work in the end, but you haven't overcome what made me give up : they added some custom logic in the editor, upgrades are always reapplied to parts that gets loaded in the editor based on the current enabled/disabled status in the PartUpgradeHandler, regardless of what was saved.

Through a combination of storing the names of all upgrades that should be disabled in a single string separated by commas, processed by the code every time a craft is first loaded through a public override void OnStart(StartState state), it's done, and finally the critical feature of persistence is in:

Version 0.32.5:

https://drive.google.com/open?id=1NLNZ3O65bHJKk8FkIi2PScZW2ouEYIwQ

Creating persistent settings in saved vessels was a much higher priority than improving the code so workarounds won't be needed. Now it's mostly functional for engines and RCS. Tested it with 5 parts including an engine with two modes like the Stock RAPIER where each mode had its own specific upgrade changes and there were no issues, but it may lag a bit when loading crafts with tons of parts featuring upgrades. A version that just reads correctly from the original Part config without upgrades for any module will(or more honestly may) be done later. Same on loading all parts in symmetry at once and applying the changes simultaneously(unless the Stock code already handles upgrades on parts with symmetry like that).

On 11/15/2017 at 8:31 PM, Gotmachine said:

License note :  you can re-license my code under GPL, no need to release some part under the unlicense (it's an unrestricted public domain license). This said, I encourage you to release your work in the public domain too so others can freely reuse your code, in my humble opinion the license hell around here is getting awful.

I'm not going to re-license as a matter of respect. As for the license choice,  every time you release anything under the GNU GPL, you receive a blessing.

Edited by NotTheRealRMS
Link to comment
Share on other sites

Version 0.3.3:

https://drive.google.com/open?id=19E0zdBBullUf4Gt1SfgIMeWa1z5egFvo

Finally devised a method to load the original part config without upgrades in the plugin for each and every module that requires such procedure in a part, so all those workarounds from the previous versions are now obsolete, and most of its shortcomings are gone. Therefore, delete any previous UpgradeEditor folder if you're installing this new version, a recommended acting for updating any KSP mod.

Also, there is something new besides finally getting this to support any possible PartModule with upgrades: ignore lists for things like upgrades that increase max diameter for procedural parts and thus would be pointless to disable. A few default settings exist in UpgradesToIgnore.cfg for the only mod with procedural parts making extensive use of the Part Upgrade system I know of, SSTU.

Link to comment
Share on other sites

  • 3 weeks later...

Version 0.3.4:

https://drive.google.com/open?id=1Cm5WA73G3IEONZ-JjEXQC0ULmpUA3Og1

This version should have been the first one for public release, because besides not having yet a decent setup to support part symmetry(there are ways to deal with limitations in the support for part symmetry though, see the Readme for details), all major issues that could be identified and reproduced were fixed now.

Letting the issue with ModuleRCS and RCSFX slide was a big mistake, but it's solved now. Apparently using OnAwake() on some modules will cause trouble. Perhaps it would be best to not use such command at all, because apparently its lack is not hindering the load of original part configs for RCS parts with upgrades in any form, but unless other Modules also end having problems because of it, it will remain being applied on modules other than RCS for now.

No matter how many bugs are fixed, it won't change the fact the entire code base of this plugin is sort of like duct tape and epoxy plastered over an unfinished framework in an attempt to improve it, but it mostly works now, besides lacking perfect, flawless support for parts with symmetrical counterparts.

Link to comment
Share on other sites

  • 3 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...