Jump to content
LaunchBox Community Forums

LaunchBox Plugin Overhaul for 9.2-beta-3


Jason Carr

Recommended Posts

Plugins have been overhauled for LaunchBox and Big Box 9.2-beta-3 with three major objectives:

  • Make it easier to track games that are launching (including knowing which game, app, and/or emulator that is launching)
  • Allow plugins to launch games using the entire game startup process, including the new startup screens
  • Provide access to the LaunchBox.Next interface in the same way that the old LaunchBox Windows Forms interface was accessible

The documentation has been updated here: http://pluginapi.launchbox-app.com/

Please make sure to do a Ctrl+F5 when first loading the documentation, because the site has a tendency to cache itself otherwise, and you may not be immediately seeing the new stuff if you've accessed it recently.

Here are the most notable new items:

That should do it. As always, big thanks goes out to all you guys who have come up with some amazing plugins already. Hopefully this stuff helps; let me know if anything isn't working or if there's something specific that you still need. :)

@UnderwoodNC @starplayer @eatkinola @Undertherainbow @srxz @wasili @matiaspons @Lahma @alec100_94 @loueradun @Axenn @binarygeek119 @bbweiners @Grila @jayjay @epicfail @malarrya @xiaumaster @fraganator @dbinott @NJDave71 @locvez @slipsystem @CoinTos @dingodan @harryoke @pdavis @dragon57 @Hexxxer @MTyrealhanla @superfurry @Nielk1 @Echoshard1 @Ize @Fayne Aldan @SpaceMidget75 @teeedubb @goblindriver @JaysArcade @Brian @DOS76 @Nyny77 @nicknamex @IlhanK @jadekitten @kmoney @Sithel @Sdentau92 @CriticalCid @elliot763

  • Like 7
  • Thanks 4
Link to comment
Share on other sites

I'm not at all sure what seems to be the problem, but all I know is most of my Arcade stuff isn't running like it used to. I have some stuff set to MAME 155, and even when I have turned off the Startup feature on both the Emulator and as a whole I still get a black screen when I used to see a percentage being loaded as usual. Any clue what happened in Beta 3? Didn't seem to be problem at all in Beta 2 though.

UPDATE: So it seems after restarting with a Windows 10 Update is when things seem to be getting back the way it once was. I'm not totally sure yet since I pretty much just ran 1 game in Arcade and unsure which version of MAME it was under. Before Restarting the Laptop for Windows 10's Update I had D3D issues and all that with CCS64 and Project64. I'm gonna try put the Startup feature back on and see how it turns out

Edited by RULLUR
Link to comment
Share on other sites

6 hours ago, RULLUR said:

I'm not at all sure what seems to be the problem, but all I know is most of my Arcade stuff isn't running like it used to. I have some stuff set to MAME 155, and even when I have turned off the Startup feature on both the Emulator and as a whole I still get a black screen when I used to see a percentage being loaded as usual. Any clue what happened in Beta 3? Didn't seem to be problem at all in Beta 2 though.

UPDATE: So it seems after restarting with a Windows 10 Update is when things seem to be getting back the way it once was. I'm not totally sure yet since I pretty much just ran 1 game in Arcade and unsure which version of MAME it was under. Before Restarting the Laptop for Windows 10's Update I had D3D issues and all that with CCS64 and Project64. I'm gonna try put the Startup feature back on and see how it turns out

Please keep the beta testing stuff over in the other thread @RULLUR if you can. Not much of that is making any sense though, so I'm guessing either it was some kind of weird fluke, or something got confused.

Link to comment
Share on other sites

I was wondering if you could help me with a question about Bigbox. I'm using the default theme and i noticed recently that my games are Autoloading by themselves after 20-30sec if my game is hovered over any favorites and recently played item on the main default wheel setup. I'm using the latest beta with load screens not using rocket launcher. The games are only autoloading from fav and recent list and not inside game wheels. So when I play a game and Exit then it goes back to the default wheel and just loads the game again or if I just hover over any recent or favorite game it just auto loads. It's so weird. Any ideas? I been looking for solutions. Is this related to the latest Betas?

Edited by Merc33
Link to comment
Share on other sites

4 hours ago, Jason Carr said:

Please keep the beta testing stuff over in the other thread @RULLUR if you can. Not much of that is making any sense though, so I'm guessing either it was some kind of weird fluke, or something got confused.

Will do..and yeah I think it came down to something wasn't set right between Windows 10 and/or maybe LaunchBox didn't Install correctly. Seems fine now.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Merc33 said:

I was wondering if you could help me with a question about Bigbox. I'm using the default theme and i noticed recently that my games are Autoloading by themselves after 20-30sec if my game is hovered over any favorites and recently played item on the main default wheel setup. I'm using the latest beta with load screens not using rocket launcher. The games are only autoloading from fav and recent list and not inside game wheels. So when I play a game and Exit then it goes back to the default wheel and just loads the game again or if I just hover over any recent or favorite game it just auto loads. It's so weird. Any ideas? I been looking for solutions. Is this related to the latest Betas?

@Merc33 If you would, please create a separate thread for this as this is not a troubleshooting thread. That said, I'm honestly very doubtful that this is a glitch with LaunchBox or Big Box. I would first try disabling game controllers in Big Box to see if maybe it's being caused by a stray controller or something of that nature. If you are convinced it's an issue with the betas, then the next step would be to install the latest 9.1 official release to see if you have the same issue.

Link to comment
Share on other sites

2 hours ago, Jason Carr said:

@Merc33 If you would, please create a separate thread for this as this is not a troubleshooting thread. That said, I'm honestly very doubtful that this is a glitch with LaunchBox or Big Box. I would first try disabling game controllers in Big Box to see if maybe it's being caused by a stray controller or something of that nature. If you are convinced it's an issue with the betas, then the next step would be to install the latest 9.1 official release to see if you have the same issue.

@Jason Carr I was about to make a new thread from your response but I did what you recommended and removed all controllers and used Keyboard only and the games still Autoloaded on the Favs and Recent on the main default. I then moved over to my fresh install on my GPDwin2 which had official 9.1 release and it didn't autoboot my games. But soon as I updated to the latest Beta my games are now autobooting on my GPDwin2 on the main wheel Favs and Recent like my other setups. Seems like when the wheel wants to spin it triggers to load a game? It takes like 90secs on my GPDwin2 to trigger the autoboot. The games don't autoboot on any other menu or wheel. So I figured this is still a recent Beta issue. I even turned off Game Startup load screens but games still autoboot no matter the theme. If this still persists then I'll make a thread.

Edited by Merc33
Link to comment
Share on other sites

2 hours ago, Merc33 said:

@Jason Carr I was about to make a new thread from your response but I did what you recommended and removed all controllers and used Keyboard only and the games still Autoloaded on the Favs and Recent on the main default. I then moved over to my fresh install on my GPDwin2 which had official 9.1 release and it didn't autoboot my games. But soon as I updated to the latest Beta my games are now autobooting on my GPDwin2 on the main wheel Favs and Recent like my other setups. Seems like when the wheel wants to spin it triggers to load a game? It takes like 90secs on my GPDwin2 to trigger the autoboot. The games don't autoboot on any other menu or wheel. So I figured this is still a recent Beta issue. I even turned off Game Startup load screens but games still autoboot no matter the theme. If this still persists then I'll make a thread.

That's pretty weird. I just tested to be sure and I can't replicate that issue with the betas. Do you have any plugins installed?

Link to comment
Share on other sites

20 minutes ago, Jason Carr said:

That's pretty weird. I just tested to be sure and I can't replicate that issue with the betas. Do you have any plugins installed?

Thanks for looking into it. I guess i'll have to double check everything. Anyways great work on the fade ins and load screens. Bigbox is looking smoother then ever with a beautiful transitioning flow now.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Thanks for implementing these new features into the plugin API @Jason Carr! I'm a little late to the game since I only just now noticed that you updated the plugin API, but I will definitely be diving into the new features ASAP. Hopefully these changes will allow me to implement some of the features I've been wanting to implement into my SteamLauncher plugin for quite awhile. 

  • Like 1
Link to comment
Share on other sites

Hey @Jason Carr , I got a couple of quick questions for you. I've only done a cursory glance over the new plugin features, so forgive me if I'm missing something obvious, but I figured it might be easier to just get a quick answer from you than to waste a lot of time with trial/error testing only to find out what I'm trying to do still isn't possible. Oh, and just for reference, in case a little more context would help, this is the thread where I initially requested some of these features in more detail:
https://forums.launchbox-app.com/topic/44497-lb-api-additions-time-table/

Question #1:
Do the new plugin API features provide any way for me to create a dynamic number of game/rom context menu items at runtime?

In case its not clear, let me explain in a little more detail. Prior to the plugin API changes (and possibly still), I was only able to implement the IGameMenuItemPlugin interface at design time, so any changes made during runtime were not reflected in the context menu in LB/BB. This prevented me from being able to create my own context menu item similar to your "Launch With" menu item where I could create a dynamic number of "Launch via Steam (Emulator X/Y/Z)" context menu items based on the number of "Launch With" configurations available for that particular game/rom. Perhaps it is possible to get full access to change the context menu via ILaunchBoxMainViewModel, and I just missed it? 

Question #2:
Does the new OnBeforeGameLaunching method/event provide any way to cancel the game from launching (such as many events that allow you to assign e.Cancel = true) so that the game launch can be intercepted and re-launched using a custom launch procedure (in my plugin's case, I am hooking the running Steam process and calling an internal function in steamclient.dll to launch a custom command line through Steam). If needed, I think I could actually do away with calling an internal Steam function to launch the game and instead pass a specific command line cmd/args to LB so that it could run the command itself, but as far as I can tell, this doesn't appear to be possible either. 

Question #3:
In the new PlayGame function, is the overrideCommandLine parameter used for asking LB to run a given rom/game with a completely custom command line or is this just used to add additional parameters to the command that LB would already normally be running? 

Thanks in advance for taking the time to answer my questions, and thanks again for implementing these new features into the plugin API. Some of these new features look like they were implemented as a direct answer to some of these requests I made in the thread I referenced above. I know spending the time to implement this stuff is probably only valuable to a very small subset of your users, so it means a lot that you expend the effort to implement my/our requests. Hopefully I'm just misunderstanding/missing some of the functionality and the new features will allow me to implement the changes I've been wanting to make in my plugin for quite awhile (without additional changes/work needing to be done to the API). Thanks Jason!

Link to comment
Share on other sites

Hey @Jason Carr , in addition to the questions I posted previously, I just thought I would let you know that the version # of Unbroken.LaunchBox.Plugins.dll is still set to 1.0.0.0 in the DLL properties. It is also referenced as 1.0.0.0 in the plugin API documentation that you added for the newly added methods. Example:

ILaunchBoxMainViewModel Interface
Provides plugin access to the LaunchBox interface. Added in LaunchBox and Big Box 9.2-beta-3.
Namespace:  Unbroken.LaunchBox.Plugins.Data
Assembly:  Unbroken.LaunchBox.Plugins (in Unbroken.LaunchBox.Plugins.dll) Version: 1.0.0.0 (1.0.0.0)

Maybe you meant to leave the version # unchanged, but I just thought I would make you aware in case you didn't know.

Edited by Lahma
Link to comment
Share on other sites

On 12/30/2018 at 7:43 PM, Lahma said:

Question #1:
Do the new plugin API features provide any way for me to create a dynamic number of game/rom context menu items at runtime?

In case its not clear, let me explain in a little more detail. Prior to the plugin API changes (and possibly still), I was only able to implement the IGameMenuItemPlugin interface at design time, so any changes made during runtime were not reflected in the context menu in LB/BB. This prevented me from being able to create my own context menu item similar to your "Launch With" menu item where I could create a dynamic number of "Launch via Steam (Emulator X/Y/Z)" context menu items based on the number of "Launch With" configurations available for that particular game/rom. Perhaps it is possible to get full access to change the context menu via ILaunchBoxMainViewModel, and I just missed it? 

The API changes do not yet allow for dynamically adding a bunch of menu items, so currently you'd have to create your own interface for this in a popup window of sorts. I may come back this request here relatively soon, but it will probably still be a while as I have quite a few large things to tackle on the shortlist.

On 12/30/2018 at 7:43 PM, Lahma said:

Question #2:
Does the new OnBeforeGameLaunching method/event provide any way to cancel the game from launching (such as many events that allow you to assign e.Cancel = true) so that the game launch can be intercepted and re-launched using a custom launch procedure (in my plugin's case, I am hooking the running Steam process and calling an internal function in steamclient.dll to launch a custom command line through Steam). If needed, I think I could actually do away with calling an internal Steam function to launch the game and instead pass a specific command line cmd/args to LB so that it could run the command itself, but as far as I can tell, this doesn't appear to be possible either. 

Unfortunately there's no proper way to cancel the game being launched, as of yet. You might be able to get away with some trickery (like temporarily removing the startup path), but that's probably not a good idea. I'm not exactly sure what you mean by having LaunchBox run the command instead of hooking into an internal Steam function; I don't see how those would be tied together. Can you explain?

On 12/30/2018 at 7:43 PM, Lahma said:

Question #3:
In the new PlayGame function, is the overrideCommandLine parameter used for asking LB to run a given rom/game with a completely custom command line or is this just used to add additional parameters to the command that LB would already normally be running? 

The overrideCommandLine parameter is used by LaunchBox if a game-specific command line is provided, which will override the emulator's command line parameters. This might be possible for you to hook into. It doesn't add additional parameters; it completely overrides the existing ones, but you could process the existing parameters, tweak them, and then send them back.

On 1/1/2019 at 3:17 PM, Lahma said:

Hey @Jason Carr , in addition to the questions I posted previously, I just thought I would let you know that the version # of Unbroken.LaunchBox.Plugins.dll is still set to 1.0.0.0 in the DLL properties. It is also referenced as 1.0.0.0 in the plugin API documentation that you added for the newly added methods. Example:


ILaunchBoxMainViewModel Interface
Provides plugin access to the LaunchBox interface. Added in LaunchBox and Big Box 9.2-beta-3.
Namespace:  Unbroken.LaunchBox.Plugins.Data
Assembly:  Unbroken.LaunchBox.Plugins (in Unbroken.LaunchBox.Plugins.dll) Version: 1.0.0.0 (1.0.0.0)

Maybe you meant to leave the version # unchanged, but I just thought I would make you aware in case you didn't know.

Yeah, the version number stays the same in order to ensure effortless compatibility with previous plugins. That's the best way to do it in .NET; I just have to be careful to only add new interfaces and methods, and not change existing ones.

Link to comment
Share on other sites

Quote

Unfortunately there's no proper way to cancel the game being launched, as of yet. You might be able to get away with some trickery (like temporarily removing the startup path), but that's probably not a good idea. I'm not exactly sure what you mean by having LaunchBox run the command instead of hooking into an internal Steam function; I don't see how those would be tied together. Can you explain?

I was simply trying to make the point that instead of my plugin having to handle the launch process itself, I could simply hand LB a command line string for it to run itself. For example, if the OnBeforeGameLaunching method had a string parameter that contained the full command that LB is going to use to launch the game/emulator, my plugin could simply change that string inside of OnBeforeGameLaunching and allow LB to continue the game launching process (instead of cancelling the launch process and having to handle it myself in the plugin). This would have the added benefit of all of the startup/exit screens working as normal and it would allow LB to still handle rom decompression and everything on its own (although it would be helpful to have a path to the decompressed rom provided in one of the parameters to avoid the messy procedure of extracting it out of the [theoretical] "full command" parameter). 

As an example, lets say the OnBeforeGameLaunching method had a parameter named fullCmd, and it had a value of:

"C:\RetroArch\retroarch.exe" -L "cores\snes9x_libretro.dll" "C:\roms\snes\Super Mario World (U) [!].smc"

After my plugin is finished doing all of its background work to setup a hidden Steam shortcut, all it would need to do is change the value of fullCmd (inside OnBeforeGameLaunching) to a value such as:

steam://rungameid/16354049154579693568

Then LB would continue on with its normal launch process passing that new fullcmd value to Process.Start() (or however you launch the game/emulator). The only potential problem I see with this is if LB is keeping track of when the newly launched process ends (in order to show the exit screen, call OnGameExited(), and/or clean up the decompressed rom), its going to think the process ends immediately since it would be launching an intermediate process that launches the game/emulator itself. If that would indeed be a problem, there are several relatively simple ways I can think of to get around this issue, but I guess its not worth crossing that road right now.

Quote

The overrideCommandLine parameter is used by LaunchBox if a game-specific command line is provided, which will override the emulator's command line parameters. This might be possible for you to hook into. It doesn't add additional parameters; it completely overrides the existing ones, but you could process the existing parameters, tweak them, and then send them back.

Unfortunately, this won't work for me, because as described above, my plugin would need to use a completely custom command (ex: steam://rungameid/16354049154579693568). As it is right now, the overrideCommandLine parameter is being appended to the path to the emulator, which would result in something like:

"C:\RetroArch\retroarch.exe" "steam://rungameid/16354049154579693568"

And this clearly isn't what I need.

Hopefully this hasn't give you a little better idea of what functionality I'm trying to achieve... Essentially, I just need some way to "hijack" the launch process. Let me know if there is any more info I can provide. Thanks again for taking thetime to try to understand my madness ;) 

Link to comment
Share on other sites

Thank you @Lahma; I do understand what you're looking for now. That approach would definitely mess with the startup screens I think, even if we did get everything in place, especially since Steam closes out the process immediately. I did get Steam games working with the startup screens, but it's messy and doesn't always work well. So unfortunately, I don't think we're likely to find an ideal solution.

Link to comment
Share on other sites

1 hour ago, Jason Carr said:

Thank you @Lahma; I do understand what you're looking for now. That approach would definitely mess with the startup screens I think, even if we did get everything in place, especially since Steam closes out the process immediately. I did get Steam games working with the startup screens, but it's messy and doesn't always work well. So unfortunately, I don't think we're likely to find an ideal solution.

How does LB currently handle cleanup of decompressed roms? Does it wait for the emulator/game process to end and then delete the decompressed rom, or does it delete all decompressed roms when LB is closed/shutdown? It would be great to still be able to do what I described even if the startup screens had to be disabled during such a use case.

Just an idea, but monitoring the game/emulator exe for file locks would be one elegant way of detecting the start/end of gaming sessions (instead of monitoring a child process.) Basically, during your "PlayGame" method, you could wait a short period (say 5 sec) for a file lock to show up on the game/emulator exe, and if it doesn't, you would determine that the game failed to load, but if the file does get locked, then you know the game is running and simply wait until the file lock is removed to know the game has ended. I can't think of any instance in which this would not work since it extremely unlikely that anyone would be running multiple instances of any given game/emulator exe.

A simple method such as the following could be used in combination with a timed loop to check if the file lock has expired:

private bool IsFileLocked(string file)
{
    FileStream stream = null;
    var fileInfo = new FileInfo(file);

    try
    {
        stream = fileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
    }
    catch (IOException)
    {
        return true;
    }
    finally
    {
        if (stream != null)
            stream.Close();
    }
    return false;
}

 

Link to comment
Share on other sites

On 1/4/2019 at 12:09 PM, Lahma said:

How does LB currently handle cleanup of decompressed roms? Does it wait for the emulator/game process to end and then delete the decompressed rom, or does it delete all decompressed roms when LB is closed/shutdown? It would be great to still be able to do what I described even if the startup screens had to be disabled during such a use case.

Currently the extracted files are just deleted once the emulator closes.

On 1/4/2019 at 12:09 PM, Lahma said:

Just an idea, but monitoring the game/emulator exe for file locks would be one elegant way of detecting the start/end of gaming sessions (instead of monitoring a child process.) Basically, during your "PlayGame" method, you could wait a short period (say 5 sec) for a file lock to show up on the game/emulator exe, and if it doesn't, you would determine that the game failed to load, but if the file does get locked, then you know the game is running and simply wait until the file lock is removed to know the game has ended. I can't think of any instance in which this would not work since it extremely unlikely that anyone would be running multiple instances of any given game/emulator exe.

The issue I can see with the file lock approach, is that LaunchBox doesn't necessarily know what file to check the lock of. If you check the lock on the ROM file, depending on the way the emulator is coded, that may or may not work (not every emulator is likely to hold a lock on the ROM file for the entire time that the game is loaded). So you'd need to check the lock on the emulator's EXE file, which would be a guaranteed way to do it, but in the case of Steam, we wouldn't necessarily even know the path to that EXE file. That is an interesting thought that I hadn't considered though.

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