Jump to content
LaunchBox Community Forums

<SOLVED> Launchbox media naming algorithm?


Recommended Posts

Hi all. Currently developing a Swiss army knife plugin where one of its features will be a full media management system, including choice to download media from an alternative scraper api. 

Part of this involves understanding how Launchbox names its media files. I know how to access all the game/system objects through the PluginHelper Class. I'm assuming this data is pulled from the relevant .xmls in <root>\Data

Examining a pre-populated media set, I see games named thusly (game on Atari 7200):

Tomcat_ The F-14 Fighter Simulator-01.jpg

the only two game fields that could possibly be linked are:

<ApplicationPath>S:\Unversioned\Projects\ArcadeAssets\ROMS\Atari 7800\Hyperspin Ready\Tomcat - The F-14 Fighter Simulator (USA).7z</ApplicationPath>

<Title>Tomcat: The F-14 Fighter Simulator</Title>

I am deducing, therefore, that the media name is derived from <Title>, as presumably underscore replaces the colon, and the result would not fit the pattern of the rom name. 

The question is, what is the replacement algorithm for all invalid filename chars? I.e. "\ / : * ? " < > |"

Also, if there's two "Pong_01.png" and Pong_01.jpg", which is given priority?

Lastly (for Bully's special prize), is there any way to set the image name in the database manually? For example, if I wished the media name to be the rom name?

PS. Wot, no syntax highlighting? 😞

Edited by stigzler
Link to comment
Share on other sites

1 hour ago, stigzler said:

the media name is derived from `<Title>`, as presumably underscore replaces the colon, and the result would not fit the pattern of the rom name. 

When LaunchBox imports images, pretty sure it bases it off the game Tile. As you deduced.  That said, if you bring in your own images, LaunchBox will match them to either the games Title or the ROM name.  Both of these will work:

Tomcat - The F-14 Fighter Simulator (USA).png
Tomcat_ The F-14 Fighter Simulator.png

 

1 hour ago, stigzler said:

what is the replacement algorithm for all invalid filename chars?

To replace invalid (filename) characters, you can make use of the built in System.IO.Path.GetInvalidFileNameChars().  When doing one of my [more obscure] plugins, I found that LB also replaces the single quote ( ' ).  Since I was needing to do this often, I created a method that accommodates both the built in list and the single quote.

private string ReplaceInvalidChars(string filename)
{
   return string.Join("_", filename.Split(System.IO.Path.GetInvalidFileNameChars())).Replace("'","_");
}

(Hint: Click "Code" next to the above smiley face to inset code with syntax highlighting.  The forum does use Markdown.  I commend the attempt though. ;))

 

1 hour ago, stigzler said:

if there's two "Pong_01.png" and Pong_01.jpg", which is given priority?

Don't know.  But if you select a game in LB that has both image formats, you can press F5 and it will randomly switch between the 2.  The key here being "random".  (as opposed to 'alternating')  Actually, as I think about it, that may be just if you have _01, _02 etc.

 

1 hour ago, stigzler said:

is there any way to set the image name in the database manually?

LB doesn't store a record(s) of your images.  (That would get ugly, fast.)  But if you wish to rename your images that are stored on your HDD (or wherever you may have them stored) to the ROM name (ugh), there's a plugin that will do that for you.  

  • Thanks 1
Link to comment
Share on other sites

Awesome reply as ever, @JoeViking245 - thanks. 👍

10 print "JoeViking Rocks OK"
20 goto 10

 

4 hours ago, JoeViking245 said:

LaunchBox will match them to either the games Title or the ROM name.

Now that is an awesome mindful bit of coding by Jason. Great futureproofing/flexibility. 

Now I can mould LB a bit, looking forward to getting stuck in properly. You seem quite active in the plugin development front, Joe. Are there others who are into it? It's just really helpful. 

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

  • stigzler changed the title to <SOLVED> Launchbox media naming algorithm?

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