Jump to content
LaunchBox Community Forums

Recommended Posts

Hi folks. 

Been working on a plugin for 2 years to do various things, but main feature being per game/platform controls layouts. However, just recently hit a major blocking point. 

It seems each IPlatform has no unique identifier? I had been working around it historically, but I now need to map data against each launchbox (lb) IPlatform and thus need a unique identifier on the lb platform to ensure these are mapped correctly. 

However, I can find no unique identifier on the data object. I have scoped this out in VS and via the api ref here: https://pluginapi.launchbox-app.com/html/092c865d-74b6-4a39-e6d9-cda1235d8355.htm

I did try getting a hash via IPlatform.GetHashCode, but this produces different Hash on each lb run without any discernible changes to the IPlatform data object

Also tried examining the GUID via Iplatform.GetType(), but this returns the guid of the data object type, not the instance.

Frustratingly, I see IGame and IEmulator both have an Id field, but cannot leverage the latter to form a unique ID in my plugin as there appears to be no link to the ascribed emulator for a platform via `IPlatform[] platforms = PluginHelper.DataManager.GetAllPlatforms();`

So onto trying to generate a unique ID:

Sadly, there also seems to be no 'created date' (i.e. when the IPlatform data object was created) which I could have leveraged for a unique ID. 

I also considered using ScrapeAs, Name or other such variable, but these of course can change and contain duplicates. 

So, in short, is there any way to get or generate a unique ID for each IPlatform function? 

Edited by stigzler
Link to comment
Share on other sites

27 minutes ago, stigzler said:

is there any way to get or generate a unique ID for each IPlatform function? 

Essentially, the platforms Name property is its unique identifier since there can be no duplicates of that property.

So, the get that specific IPlatform

IPlatform specificPlatform = PluginHelper.DataManager.GetPlatformByName("Nintendo Entertainment System");
Link to comment
Share on other sites

Hey. Thanks for the reply, Joe. Yes - I had considered that, but the issue is if I create an associated data object linked via the LB Platform name, and then the user changes the platform name in LB that then breaks the link between the LB IPlatform and the data object. I was hoping that there was a unique (unchangeable) ID assigned at the point of creation of a new LB platform, but I'm thinking that this facility just isn't there?

I've also had a look at Metadata/Platforms.xml and see no ID there either, so I'm thinking I'm going to have to do some convoluted design accommodating the possibility that the user changes the Platform name (and with no date created property, there's going to be no way to detect a platform name change, I think - so on running my plugin it'll either be a new platform created by the user or the user has changed the name). 

Not ideal, but I guess you have to work with what you've got. Any other ideas, Jo, just in case I'm missing something? Merry Chrimbo by the way.

Edited by stigzler
Link to comment
Share on other sites

13 minutes ago, stigzler said:

if I create an associated data object linked via the LB Platform name, and then the user changes the platform name in LB that then breaks the link between the LB IPlatform and the data object

Tell them not to change the Platforms' name. ;) 

Add some checks-and-balances.  if (specificPlatform == null)    Or (worse case) use a try { } catch { }.  Then process accordingly.

 

26 minutes ago, stigzler said:

I've also had a look at Metadata/Platforms.xml and see no ID there either, so I'm thinking I'm going to have to do some convoluted design accommodating the possibility that the user changes the Platform name

Nothing is "convoluted" in programming.  It's called expect-the-worst or being creative. :D

If you have to add 10-20 more lines of code or create new ViewModel methods to handle the checks-and-balances, it's all part of the game (figuratively speaking). 

Link to comment
Share on other sites

Fair points, Joe and pretty much where I've gone with it. There are some nasty edge cases that might happen (e.g. user 'swaps' the Names of two systems in LB which would be undetectable by my plugin where linked DO is via Platform Name) but that's the issue with plugin development: some things are beyond your control. Even 'multi-key' approaches are fallible, so it will have to do!

Thanks for your input. 👍

Edited by stigzler
  • 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...