Jump to content
LaunchBox Community Forums

Plugins Not Fully Working With LaunchBox Next


Recommended Posts

Hi I am looking to get back into LaunchBox plugin Development, and make a LB.Next compatible (and hopefully better) version of my existing PCSX2 Configurator Plugin, but noticed that SystemEventsPlugin and SystemMenuItemPlugin do not seem to work at all in the latest build of Launchbox.Next. I made a very simple project with bare bones implementations of all three types of plugins (in a single dll), and it works just fine in OG LaunchBox but seems to crash LaunchBox.Next. In Particular it's the SystemEventPlugin That crashes LaunchBox.Next at startup, the SystemMenuItemPlugin just doesn't show at all in the tools menu. The GameMenuItemPlugin appears to be working as expected. Don't know if I'm missing something obvious here, but as far as I can see this is broken in LaunchBox.Next and has probably already stopped a lot of pre-existing plugins from functioning correctly.

*Edit - I was able to fix my issue with the SystemEventPlugin, by running the message box in another thread (I have updated the code to reflect this), and all the events appear to report just fine, But there is still an issue the Issue with SystemMenuItemPlugin's not showing up at all (possibly not yet implemented?).

It's a very simple project so I may as well just post the source code below.

using System;
using System.Drawing;
using Unbroken.LaunchBox.Plugins;
using Unbroken.LaunchBox.Plugins.Data;

namespace PCSX2_Configurator_Next
{
    public class GameMenuItemPlugin : IGameMenuItemPlugin
    {
        public bool SupportsMultipleGames => false;

        public string Caption => "PCSX2 Configurator";

        public Image IconImage => null;

        public bool ShowInLaunchBox => true;

        public bool ShowInBigBox => false;

        public bool GetIsValidForGame(IGame selectedGame)
        {
            return false;
        }

        public bool GetIsValidForGames(IGame[] selectedGames)
        {
            return SupportsMultipleGames;
        }

        public void OnSelected(IGame selectedGame)
        {

        }

        public void OnSelected(IGame[] selectedGames)
        {

        }
    }
}
using System;
using System.Windows.Forms;
using Unbroken.LaunchBox.Plugins;

namespace PCSX2_Configurator_Next
{
    public class SystemEventsPlugin : ISystemEventsPlugin
    {
        public void OnEventRaised(string eventType)
        {
          	Task.Run(() => MessageBox.Show(new Form { TopMost = true }, eventType));
        }
    }
}
using System;
using System.Drawing;
using Unbroken.LaunchBox.Plugins;

namespace PCSX2_Configurator_Next
{
    public class SystemMenuItemPlugin : ISystemMenuItemPlugin
    {
        public string Caption => "PCSX2 Configurator";

        public Image IconImage => null;

        public bool ShowInLaunchBox => true;

        public bool ShowInBigBox => false;

        public bool AllowInBigBoxWhenLocked => false;

        public void OnSelected()
        {

        }
    }
}

 

Edited by alec100_94
Link to comment
Share on other sites

23 hours ago, Jason Carr said:

Hi alec, yes, previously the System menu stuff just hadn't been implemented, but it is implemented in the latest betas. The official release should hopefully be out early next week.

Let me know if you run into any additional issues. :)

Ok, cool, it's working in the beta version. There another thing I noticed and that is that the "LaunchBoxStartupComplete" Event never fires in LB.Next, but the "PluginInitialized" does fire when LaunchBox pretty much appears to be ready, So I was wondering if this means that the "LaunchBoxStartupComplete" event is obsolete and all actions can be moved to "PluginInitialized" for LB.Next or whether the event simply hasn't been implemented yet? I am also curious about the reference to "LaunchBoxMainForm" in the PluginHelper class, will this eventually be updated to refer to the LB.Next Main View, or will it be removed completely?

Link to comment
Share on other sites

19 minutes ago, alec100_94 said:

Ok, cool, it's working in the beta version. There another thing I noticed and that is that the "LaunchBoxStartupComplete" Event never fires in LB.Next, but the "PluginInitialized" does fire when LaunchBox pretty much appears to be ready, So I was wondering if this means that the "LaunchBoxStartupComplete" event is obsolete and all actions can be moved to "PluginInitialized" for LB.Next or whether the event simply hasn't been implemented yet? I am also curious about the reference to "LaunchBoxMainForm" in the PluginHelper class, will this eventually be updated to refer to the LB.Next Main View, or will it be removed completely?

Ah, okay. To be honest I didn't know about LaunchBoxStartupComplete; I'm guessing I just need to add that in. Hopefully I can do that before the 8.6 release.

LaunchBoxMainForm, however, will be completely obsolete (it'll always be null when LaunchBox.Next is running). I'll probably add something to replace it here soon.

  • Like 1
Link to comment
Share on other sites

7 minutes ago, Jason Carr said:

Ah, okay. To be honest I didn't know about LaunchBoxStartupComplete; I'm guessing I just need to add that in. Hopefully I can do that before the 8.6 release.

LaunchBoxMainForm, however, will be completely obsolete (it'll always be null when LaunchBox.Next is running). I'll probably add something to replace it here soon.

Cool, that makes perfect sense. I can easily work around these issues for now.

Link to comment
Share on other sites

I appear to have found another slight difference in the plugin behaviour between OG LB and LB.Next, though am not sure if it's intentional or not. In OG LaunchBox the GetIsValidForGame function in the IGameMenuItemPlugin interface fired when a game is selected, but in LB.Next it seems to only fire when right clicking on the game. I personally preferred the way that OG LB handled this, as it allowed me to set a config path as soon as the game was selected, ensuring the ConfigPath was never cleared by LB (so all configure buttons would always work). Though I guess overall this isn't a big issue, and can probably be worked around, in most cases it is unlikely to make a difference.

A possibly more sensible solution to this specific issue would be to have Launchbox never clear the configuration path and configuration command line (from the edit screen), if they have already been set (though still keeping the field's read-only unless it's a PC/Dos game).

Edited by alec100_94
Link to comment
Share on other sites

Ah, sure. Yeah, I think we'll keep things as-is at least for the 8.6 release, since I'm planning on putting it out tomorrow.

FYI, for this next beta (and the official release), I've wrapped all plugin method calls in try catch statements so that the user never sees any plugin-created errors, but the errors will still show up in the debug logs if they are enabled (or if it's a beta release as they're always enabled for beta releases).

Link to comment
Share on other sites

32 minutes ago, Jason Carr said:

Ah, sure. Yeah, I think we'll keep things as-is at least for the 8.6 release, since I'm planning on putting it out tomorrow.

FYI, for this next beta (and the official release), I've wrapped all plugin method calls in try catch statements so that the user never sees any plugin-created errors, but the errors will still show up in the debug logs if they are enabled (or if it's a beta release as they're always enabled for beta releases).

That's cool. I'm in no real rush to finish my plugin anyway, I'm just trying to figure out what I'll need to work to create the best possible experience for the user, without resorting to less than ideal hacks using reflection (which often tend to cause other issues), which the old version of the plugin very much relied on (and why the Next update broke most of it's functionality). Also not entirely sure how I'd even make that sort of thing work using LB.Next (or if it's even possible), as I'm not really familiar with how WPF displays it's menu items, handles events, etc.

Also I'm not sure about hiding the plugin errors, I guess it makes sense for the user, But as a developer I like to see where things go wrong (or are simply not implemented), I noticed the latest Beta fails to show Not Implemented Exception in one case where I am throwing one, is it possible to turn all errors back on?

Overall LB.Next is an awesome piece of software, and a massive improvement over older versions of LaunchBox, I've just got some minor growing pains while trying to migrate my plugin (most of which are my fault for building it poorly in the first place).

Edited by alec100_94
Link to comment
Share on other sites

8 minutes ago, alec100_94 said:

That's cool. I'm in no real rush to finish my plugin anyway, I'm just trying to figure out what I'll need to work to create the best possible experience for the user, without resorting to less than ideal hacks using reflection (which often tend to cause other issues), which the old version of the plugin very much relied on (and why the Next update broke most of it's functionality). Also not entirely sure how I'd even make that sort of thing work using LB.Next (or if it's even possible), as I'm not really familiar with how WPF displays it's menu items, handles events, etc. Overall LB.Next is an awesome piece of software, and a massive improvement over older versions of LaunchBox.

Sure; let me know what hooks/functionality you need, and I can get them added for you. Most often, things are easy to add, it's just best not to add them when we're close to a release. If you find yourself having to resort to reflection, just let me know and I'll see what it would take to make it easier. :)

  • Like 1
Link to comment
Share on other sites

Sure I fully understand, I'm not really pushing you to add anything right now, this is very much a free-time project for me and that's not actually something I have that much of nowadays (while working full time as a Web Developer).

I probably won't get another chance to look at this properly until next weekend, and it's still likely to need more time than that before I can consider it even sort of releasable. 

As a developer myself I also know how simple a lot of these things generally are (usually just a boolean or if statement), which is why it can sometimes be a little frustrating when I can't do what I want.

Though don't get me wrong when I fully figured out how reflection worked in OG LaunchBox I essentially abused it, by overriding internal events and the likes, and the result ended up being a bit of hot mess in terms of stability, and a real nightmare to maintain. Which is why I am glad to be rebuilding it from the ground up, with much more careful design this time around and trying to mostly work within what the current plugin engine allows, though I may still need a couple of minor things changed/added here and there, to give the best experience.

Edited by alec100_94
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...