Jump to content

[0.20] Subassembly Loader - 0.20 Compatibility Patch


TheUndeadFish

Recommended Posts

I didn't find a thread dedicated to the Subassembly Loader mod, so I had to create this one.

Using the source code provided along with the mod, I just made a patched version that will work with 0.20. This moves the button to a usable location in the VAB as well as eliminates the lag caused by the plugin not loading properly.

I only intend this as a quick-and-dirty fix until the mod's author can release a proper updated version of it. You still need the original files, then override the dll with the one from my path.

Download:

For the sake of those playing the game at much lower resolutions, I've made a second version of my patch. This one moves the button to the upper right corner, but under the other buttons instead of beside them. It's not as pretty as being on the top bar, but it should be functional.

Download:

Disclaimer: Use at your own risk, since I'm rather new to KSP modding.

A few other people in this thread have made their own patches. So if one of my patches doesn't work for some reason, then you could try one of theirs:

Edited by sal_vager
Had to remove the links on copyright grounds.
Link to comment
Share on other sites

I didn't find a thread dedicated to the Subassembly Loader mod, so I had to create this one.

Using the source code provided along with the mod, I just made a patched version that will work with 0.20. This moves the button to a usable location in the VAB as well as eliminates the lag caused by the plugin not loading properly.

I only intend this as a quick-and-dirty fix until the mod's author can release a proper updated version of it.

Download:

Disclaimer: Use at your own risk, since I'm rather new to KSP modding.

All I can say is THANK YOU. I wondered where DEADBEEF went after the forum catastrophe, though.

Edited by sal_vager
Link to comment
Share on other sites

Would it be possible to have a version/full repackage of the mod with the new directory structure? I am not quite sure what is involved in switching between from the old .19 to the new .20 directory structure so I don't know how to do this myself. I am hoping to be able to get a "clean" setup as I am starting a new ksp save and it would be nice to use the new .20 way, much less of a mess that way!

Link to comment
Share on other sites

He's not working on the mod, he just made a quick fix for the main DLL file so that it would work instead of completely not work.

It works for me. The loading seems to be funky, and the icon is a tiny little question mark " ? " instead of the usual icon, but it works so I'm fine with this until its updated officially. :D

Thanks mate.

Link to comment
Share on other sites

Would you mind releasing the source for your changes, so that those who are interested can look through the code?

I actually only made two little changes to the code:

The first was to comment out line 11:

//private static PluginConfiguration config = PluginConfiguration.CreateForType<subassemblyLoader>();

A problem happens when the game runs that, as was evident by the errors in the output log. And it was consequently causing the plugin to fail to load, which causes the game to try to reload it over and over, which causes the lag. But since the mod doesn't seem to make use of that configuration file stuff, commenting out the line way a simple was the deal with the issue.

The second was to adjust the first number on line 129, which is the x coordinate of where the button is drawn in the VAB:

if (GUI.Button(new Rect(350, 1, 48, 36), new GUIContent(button, "Subassembly"), buttonStyle) && !EditorLogic.softLock)

Link to comment
Share on other sites

thank you for your quick fix, it works great, I don't have a question mark like the person above, I have the jigsaw picture on mine..

To the person asking about new directory structure, do not use it, just use the old folders for this mod, it works in them at the moment.

Link to comment
Share on other sites

Thanks for the source tip (I prefer using the mod without the whole "Bad Subassembly" nonsense, so this makes it really simple to update what I have)

Also

The new way to make Part-less plugins is to use the KSPAddon attribute, like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

[KSPAddon(KSPAddon.Startup.EditorAny, false)]
public class Class1 : MonoBehaviour
{
private float lastUpdate = 0;

void Awake()
{
Debug.Log("TAC [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "] Awake");
}

void Update()
{
float delta = Time.time - lastUpdate;
if (delta > 15)
{
Debug.Log("TAC [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "] Update");
lastUpdate = Time.time;
}
}
}

This class will be loaded every time the scene is changed to the Editor, and Awake will be called. And it will be unloaded when the scene is changed to something else, but until then Update() will be called.

(Haven't tried yet; but just what has been said)

Link to comment
Share on other sites

Hi all, love this mod so decided to delve a tad deeper into updating it for 0.20 :D:

Extract the GameData folder inside the zip in your KSP folder, directory structure should be good.

Basically all I did was use TheUndeadFish's edits along with changing the file references to a folder in GameData, seems to run OK and shouldn't have any problems with little question mark icons.

@Fel

This hooks in to Unity's OnGui function and already checks if the editor is open so the [KSPAddon] shouldn't be needed. Performance gain, if any would be tiny (I think:)).

Edited by sal_vager
Link to comment
Share on other sites

I changed the number for mine to something else:

new Rect(526-45, 1, 48, 36)

Maybe it has to do with screen sizes, but with 350 it put it almost in the middle of the blank space on the top bar. I guess the reason deadbeaf put

screen.width -

whatever number it was originally, was to make it so it positioned its self no matter the resolution settings, but thats just a guess. I did originally try leaving screen.width and changing the amount subtracted from it but I wasn't compiling it correctly then and it wasn't loading I guess. Got it working now though. I did try doing it my self before I read your post completely and did happen to find line 129, but didn't comment out line 11 so I bet that was part of my original problem. Thats when I thought I'd do it like you did but with my own numbers. No offence meant by not using the one you uploaded but I sometimes find coding fun and not having done c# before thought it'd be a fun little exercise.

Anyway, enough of my rambling, just thought I'd mention the number thing. Glad you thought about editing the source code other wise a lot of us wouldn't be able to use sub assembly until an official update came out. :)

I actually only made two little changes to the code:

The first was to comment out line 11:

//private static PluginConfiguration config = PluginConfiguration.CreateForType<subassemblyLoader>();

A problem happens when the game runs that, as was evident by the errors in the output log. And it was consequently causing the plugin to fail to load, which causes the game to try to reload it over and over, which causes the lag. But since the mod doesn't seem to make use of that configuration file stuff, commenting out the line way a simple was the deal with the issue.

The second was to adjust the first number on line 129, which is the x coordinate of where the button is drawn in the VAB:

if (GUI.Button(new Rect(350, 1, 48, 36), new GUIContent(button, "Subassembly"), buttonStyle) && !EditorLogic.softLock)

Link to comment
Share on other sites

The .CS file is in the main directory outside the GameData folder (not to mention the subassemblyLoader folder...)

Enlighten me, please, as the the intended usage?

Hi all, love this mod so decided to delve a tad deeper into updating it for 0.20
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...