Jump to content
LaunchBox Community Forums

phlaange

Members
  • Posts

    8
  • Joined

  • Last visited

About phlaange

  • Birthday October 19

Recent Profile Visitors

390 profile views

phlaange's Achievements

4-Bit Adder

4-Bit Adder (2/7)

0

Reputation

  1. And, of course, it's easy as in Python. Thanks. I'll have to have a look at the object to see if need to check for uniqueness.
  2. It is not a plugin. Completely external code creating XML files in the LB directory.
  3. Or... are PlaylistId's even needed in playlists? LB seems to be able to load playlists that don't have a PlaylistId. I'm writing external code to generate playlists and am wondering what to do about the PlaylistId for each playlist. Any suggestions?
  4. Disregard, I figured it out. https://www.nuget.org/packages/System.Drawing.Common/
  5. Hi all, I'm attempting the "Let's Build Some Plugins" tutorial but am unable to build the solution and I'm not sure what I've missed. I've added references to Unbroken.LaunchBox.Plugins and System.Drawing but am getting errors: Error CS0012 The type 'Image' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. LiveStreamPluginDemo C:\Users\phlaange\Documents\Development\Source\LiveStreamPluginDemo\LiveStreamPluginDemo\DemoGameMenuItemPlugin.cs 15 Active I'm using Visual Studio Community 2017. I've installed .NET Framework 4.6.2 Developer Pack (do I need to install the runtime?). Code: using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Unbroken.LaunchBox.Plugins; using Unbroken.LaunchBox.Plugins.Data; namespace LiveStreamPluginDemo { public class DemoGameMenuItemPlugin : IGameMenuItemPlugin { public DemoGameMenuItemPlugin() { } public bool SupportsMultipleGames { get { return true; } } public string Caption { get { return "Demo Menu Item"; } } public System.Drawing.Image IconImage { get { return null; } } public bool ShowInLaunchBox { get { return true; } } public bool ShowInBigBox { get { return true; } } public bool GetIsValidForGame(IGame selectedGame) { /* Choose this based on what you want the criteria to be */ return !string.IsNullOrEmpty(selectedGame.Version); } public bool GetIsValidForGames(IGame[] selectedGames) { return selectedGames.Any(g => !string.IsNullOrEmpty(g.Version)); } public void OnSelected(IGame selectedGame) { MessageBox.Show(selectedGame.Title); } void IGameMenuItemPlugin.OnSelected(IGame[] selectedGames) { foreach (var game in selectedGames) { if (string.IsNullOrEmpty(game.Version)) { continue; } MessageBox.Show(game.Title); } } } } Edit: found some typos and fixed.
  6. I wish there was a zoom, too. A 320x240 screenshot kinda disappears on a 4K TV from across the room. Especially with my old eyes.
  7. There is, but it looks like it costs $$$! https://www.internetvideoarchive.com/apis/metacritic-api/ https://www.internetvideoarchive.com/pricing-2/
  8. I've been trying to figure out which (Arcade) games to play but the MAME ROMset just has sooo many. Sure, Launchbox lets us filter and sort by Star Rating but this seemed a little problematic to me. Now, I'm sure that the *7* people that gave Super Puzzle Bobble a 5 felt it earned it but that's just not enough sentiment for me to thrust it into the best of the best games. So I decided I needed another metric to discover the best content. One that, despite the data being present in Launchbox, was not offered as either a filter or sort by option. Total Community Star Rating Votes. I figured if enough of you voted for a game, I should probably play it. So I created a Playlist. Well, 2 actually. Here's how. Caveats: It can be dangerous altering Launchbox's files This requires at least some familiarity with Python Do NOT run this when Launchbox is running You will need to edit the filename paths to match those on your system. There a five places in the code You will need to create each of the Playlists in Launchbox first to get the PlaylistId (from the Playlist XML file), then replace the PlaylistId's in the code If you decide to use a different Playlist name, change that in the code, too Code description: Read in Arcade.xml and get the list of all Arcade games Open the first XML file (Most Rated 30-49.xml) and write the XML header and Playlist definition Loop through the list of Arcade games with between 30 and 49 votes, saving each to the XML Write the closing XML tag Open the second XML file (Most Rated 50+.xml) and write the XML header and Playlist definition Loop through the list of Arcade games with 50 or more votes, saving each to the XML Write the closing XML tag from bs4 import BeautifulSoup as soup filename = 'C:\Emulators\LaunchBox\Data\Platforms\Arcade.xml' f = open(filename, encoding='UTF-8') xml_soup = soup(f, 'xml') games = xml_soup.findAll('Game', {}) filename = 'C:\\Emulators\\LaunchBox\\Data\\Playlists\\Most Rated 30-49.xml' f = open(filename, 'w') f.truncate() header = '''<?xml version="1.0" standalone="yes"?> <LaunchBox> <Playlist> <PlaylistId>876c8f1c-1e01-4966-90b6-63d7a87a9a27</PlaylistId> <Name>Most Rated 30-49</Name> <NestedName>Most Rated 30-49</NestedName> <SortBy>Default</SortBy> <Notes /> <VideoPath /> <IncludeWithPlatforms>true</IncludeWithPlatforms> <AutoPopulate>false</AutoPopulate> <SortTitle /> <IsAutogenerated>false</IsAutogenerated> </Playlist> ''' f.write(header) man_order = 0 for game in games: if int(game.CommunityStarRatingTotalVotes.text) > 30 and int(game.CommunityStarRatingTotalVotes.text) < 49: g_id = str(game.ID.text) lb_id = str(game.DatabaseID.text) g_title = str(game.Title.text) g_title = g_title.replace('&', '&') if len(game.ApplicationPath.text) > 0: g_filename = str(game.ApplicationPath.text).replace('G:\\Games\\mame\\roms\\','') g_platform = str(game.Platform.text) xml_string = " <PlaylistGame>\n <GameId>" + g_id + "</GameId>\n <LaunchBoxDbId>" + lb_id + "</LaunchBoxDbId>\n <GameTitle>" + g_title + "</GameTitle>\n <GameFileName>" + g_filename + "</GameFileName>\n <GamePlatform>" + g_platform + "</GamePlatform>\n <ManualOrder>" + str(man_order) + "</ManualOrder>\n </PlaylistGame>\n" f.write(xml_string) man_order += 1 f.write("</LaunchBox>") filename = 'C:\\Emulators\\LaunchBox\\Data\\Playlists\\Most Rated 50+.xml' f = open(filename, 'w') f.truncate() header = '''<?xml version="1.0" standalone="yes"?> <LaunchBox> <Playlist> <PlaylistId>b5cc4b9c-09df-4409-9786-a1c44f43a318</PlaylistId> <Name>Most Rated 50+</Name> <NestedName>Most Rated 50+</NestedName> <SortBy>Default</SortBy> <Notes /> <VideoPath /> <IncludeWithPlatforms>true</IncludeWithPlatforms> <AutoPopulate>false</AutoPopulate> <SortTitle /> <IsAutogenerated>false</IsAutogenerated> </Playlist> ''' f.write(header) man_order = 0 for game in games: if int(game.CommunityStarRatingTotalVotes.text) > 50: g_id = str(game.ID.text) lb_id = str(game.DatabaseID.text) g_title = str(game.Title.text) g_title = g_title.replace('&', '&') if len(game.ApplicationPath.text) > 0: g_filename = str(game.ApplicationPath.text).replace('G:\\Games\\mame\\roms\\','') g_platform = str(game.Platform.text) xml_string = " <PlaylistGame>\n <GameId>" + g_id + "</GameId>\n <LaunchBoxDbId>" + lb_id + "</LaunchBoxDbId>\n <GameTitle>" + g_title + "</GameTitle>\n <GameFileName>" + g_filename + "</GameFileName>\n <GamePlatform>" + g_platform + "</GamePlatform>\n <ManualOrder>" + str(man_order) + "</ManualOrder>\n </PlaylistGame>\n" f.write(xml_string) man_order += 1 f.write("</LaunchBox>") Tips Python is indent sensitive. I can't guarantee that the forum won't munge the indentation (although it looks okay after posting). Multiple line strings in Python are denoted by triple quotes. That's how the header variable is defined. I use a Jupyter Notebook to run this code. This is part of Anaconda (https://www.anaconda.com/distribution/) and is a fairly easy way to get started with Python. I'd link a tutorial but I've learned how to use it on a paid site. When I initially created the Playlists I did it by adding a single game to the Playlist and entering only the Unique Name and Nested Name. What have I forgotten?
×
×
  • Create New...