Jump to content

[WIP][Plugin/Tool][November 1] AssemblyReloader - Tool for plugin authors


xEvilReeperx

Recommended Posts

Since it doesn't appear to integrate with Stock toolbar yet, if you accidentally hit the "X" button is there a way to bring the Assembly Reloader window back up? (Sorry if I missed this in the manual)

Not yet (it's the very next thing on the list!). I completely forgot they fixed ApplicationLauncher to work in the main menu which solves the dilemma I was having there

Re: automation, yeah that would be pretty handy. I'll think about how we might get it to work

Link to comment
Share on other sites

Also, would love to know - have you had any luck using this with any of the basic popular mods like Chatterer? Or with EnvironmentalVisualEnhancements (and the various packs people have released for it)?

I tried with Chatterer - it looked like it was partially working but the toolbar button disappeared after trying to reload. However I'm making some modifications to the source code for Chatterer so it could have been something I did.

It would be super handy to be able to load new EVE textures and cfg's in on the fly, although I realize that one may not be practical since the size of some of the assets in addon packs for it can get huge.

Link to comment
Share on other sites

In Chatterer's case, it creates its button when GameEvents.onGUIApplicationLauncherReady is fired. That event doesn't get fired mid-scene, so no button ;) If you don't want to write custom code for that kind of situation, you could prevent AssemblyReloader from replacing things instantly in the options menu for the relevant plugin. In Chatterer's case, unchecking "Start Addons for current scene" and then switching scenes or reloading a quicksave works ... well, it would work if I didn't just find a facepalm programmer error which I am now fixing :blush:

For something like EVE, again it should work -- it just might require some custom code to undo changes.

I don't have any config or texture reloading in there currently because you can already reload the game database to achieve that. It's definitely possible but I don't have a use case for it at the moment

Link to comment
Share on other sites

  • 2 weeks later...
Updated with a new version and some minor bugfixes, plus there is now an AppButton to toggle the main window.

Don't be shy with feedback. You're not going to hurt my feelings if you tell me the documentation sucks or it's hard to use. It'd be nice to make this a staple in every modder's toolkit but I'll never get it there without some criticism :)
Link to comment
Share on other sites

[quote name='xEvilReeperx']In Chatterer's case, it creates its button when GameEvents.onGUIApplicationLauncherReady is fired. That event doesn't get fired mid-scene, so no button ;) If you don't want to write custom code for that kind of situation, you could prevent AssemblyReloader from replacing things instantly in the options menu for the relevant plugin. In Chatterer's case, unchecking "Start Addons for current scene" and then switching scenes or reloading a quicksave works ... well, it would work if I didn't just find a facepalm programmer error which I am now fixing :blush:[/QUOTE]

Thanks for the explanation! I'm still new to KSP mod development so may need to chew on this a bit. Incidentally, I'm doing some work in the Chatterer codebase. While I'm in there, is there anything I can do to make it "just work", out of the box, with your mod? (e.g. Implement an OnPluginReloadRequested() method and somehow queue up a deferred onGUIApplicationLauncherReady? I'm hoping you can point me in the direction of a cleaner approach)
Link to comment
Share on other sites

The absolute minimum-effort method would be disabling the in-scene addon loading for Chatterer and loading a quicksave/switching scenes after reloading the plugin, now that the new version is out that fixed the problem with that before. Doing this should work for almost any mod with no other changes necessary.

In the AppLauncher case, you could replace the event code with a coroutine that waits for ApplicationLauncher to be ready. I prefer that method(something like this:)
[code]private IEnumerator Start()
{
while (ApplicationLauncher.Instance == null || !ApplicationLauncher.Ready)
yield return 0;

_button = ApplicationLauncher.Instance.AddModApplication(...);
}

private void OnDestroy()
{
if (_button != null && ApplicationLauncher.Instance != null)
ApplicationLauncher.Instance.RemoveModApplication(_button);
}[/code]
You might find some other small issues, like Chatterer seems to assume an OnVesselChange event will be fired right after it starts up which won't be the case when reloading in-scene. That prevents some vessel-related stuff from being set
Link to comment
Share on other sites

Which one(s)? The main window starts out as compact as it can be to be efficient. The main window and the plugin options window can both be resized by dragging the right or bottom edges of the window when you see the resize hint. They'll be scalable, too in a future update

Edit: I should note it's possible there's some size bug happening here which is why I'm curious Edited by xEvilReeperx
Link to comment
Share on other sites

[s]IIRC, both of them. I think they both start out the same width.[/s] [I]Can't remember now, I might have already resized. Do the resized settings get persisted yet?[/I]

I do know the plugin options looked something like this, out of the box:

[IMG]http://i.imgur.com/KCQjAO5.png[/IMG]

Note I have non-default (smaller) settings for my UI font size so that might be a factor. Also running DirectX 11 under Win 64-bit (insert ominous chords). Edited by Fwiffo
Edits, clarification and add picture
Link to comment
Share on other sites

That looks right to me. I'll fix it (horizontal scrollbar at least). Yes, window positions and size should persist so if they're not definitely let me know ... I'm using a lot of this window code in another project so you'd be doing me a double-favor ;)
Link to comment
Share on other sites

[quote name='xEvilReeperx'][COLOR=#333333]window positions and size should persist so if they're not definitely let me know[/COLOR][/QUOTE]
I'm a terrible test case for this - most of the time lately I can't bother waiting for KSP to quit or it freezes up when I try to exit, so I just zap it with task manager ;-).
Link to comment
Share on other sites

  • 5 months later...
  • 4 months later...
On 5/13/2016 at 0:57 AM, xEvilReeperx said:

I've been using it. I updated the download link. There might be something wrong with the symbol loading so if the game crashes on startup, try removing the MDBs. I haven't had time to track down the cause yet

I tried it today in 1.1.3.  If an MDB is alongside my .reloadable the game crashes almost immediately on startup.  Any headway on that yet?  I miss my debug symbols! ;-)

Also... and sorry if this is a dumb question... does AssemblyReloader do anything about reloading part file CFG's?  i.e. Could it be used by modders to dynamically reload an individual part file from the database rather than reloading the whole thing?

Edited by Fwiffo
Link to comment
Share on other sites

On 9/15/2016 at 0:32 AM, Fwiffo said:

I tried it today in 1.1.3.  If an MDB is alongside my .reloadable the game crashes almost immediately on startup.  Any headway on that yet?  I miss my debug symbols! ;-)

Are you using the pdb2mdb from the same Unity version as KSP? I haven't nailed down exactly what the problem is unfortunately, though symbols do work for most of my projects. As for the other, AssemblyReloader doesn't do that. Writing a small tool that does shouldn't be too difficult though

Link to comment
Share on other sites

9 minutes ago, xEvilReeperx said:

Are you using the pdb2mdb from the same Unity version as KSP?

Ah, very possibly not!  I updated my DLL references but not this part of my tooling.  Whoops.

 

On 9/15/2016 at 0:32 AM, Fwiffo said:

Does AssemblyReloader do anything about reloading part file CFG's?  i.e. Could it be used by modders to dynamically reload an individual part file from the database rather than reloading the whole thing?

9 minutes ago, xEvilReeperx said:

AssemblyReloader doesn't do that. Writing a small tool that does shouldn't be too difficult though.

Wow, that would be SO DARN USEFUL to modders when making lots of iterative edits to a CFG file (e.g. to fine tune position of MODEL elements).  I don't know how many times I had to reload KSP (or the whole database) over and over while doing that.  Double-props if it even worked with dynamic ModuleManager CFG's.

Edited by Fwiffo
Link to comment
Share on other sites

  • 1 month later...
  • 11 months later...

This would be amazing but I haven't had any luck getting it to work with a PartModule - seems to work fine with a KSPAddon, though.
I have the log file here. This is on a clean install and the only mod used (apart from the obvious) is ModuleManager.

Issue can be reproduced with the following mod:

using UnityEngine;

namespace ReloadingModTest
{
    public class ReloadableTestModule : PartModule
    {
        public override void OnStart(StartState state)
        {
            Debug.Log("On Start before reloading");
        }
    }
}

Changing "before" to "after", compiling, renaming, overwriting the original file then clicking Reload leads to the error.

I had a look through the manual and didn't find anything that would fix this.
Adding the OnDestroy method with Destroy(gameobject) makes it worse because it destroys the part the module belongs to causing issues in game and leading to a different error. Using Destroy(this) instead is the same as not having anything, as expected.

Unfortunately, I believe the exception is thrown on the method that would log the actual error reloading the module, so I have no idea what it might be.
Any help would be appreciated.

Thanks!

(I know this is an old thread but the download link points to a 1.3 version so I guess this is still updated.)

Link to comment
Share on other sites

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...