Facebook
From LegzRwheelz (not og author), 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 118
  1. MCRC := "522BEDFD"
  2. MVersion := "1.0.3"
  3.  
  4. ; LaunchBox Plugin (by bleasby)
  5. ; Requires at least LaunchBox version 6.10
  6. #MaxMem 256
  7.  
  8. PluginInit:
  9.         Log("PluginInit - Started")
  10.  
  11.         ;---- FrontEnd Information
  12.         frontendPlugin := "LaunchBox"
  13.         frontendPID := Process("Exist","LaunchBox.exe") ? Process("Exist","LaunchBox.exe") : Process("Exist","BigBox.exe")
  14.         WinGet, windowIDList, list, Ahk_pid %frontendPID%
  15.         loop, % windowIDList
  16.         {       WinGetTitle, frontendWinTitle, % "Ahk_id " . windowIDList%a_index%
  17.                 if (InStr(frontendWinTitle, "LaunchBox Premium")) or (InStr(frontendWinTitle, "LaunchBox Games Database")) or (InStr(frontendWinTitle, "LaunchBox Big Box")){
  18.                         WinGetClass, frontendWinClass, % "Ahk_id " . windowIDList%a_index%
  19.                         break
  20.                 }
  21.         }
  22.        
  23.         ;---- Game Info
  24.         frontendDatabaseFields := "Developer|Notes|Platform|Publisher|Rating|ReleaseDate|StarRating|Title|Version|Series|PlayMode|Genre|Status|Source|Region|Favorite|Completed|Portable|Clone"
  25.         frontendDatabaseLabels := "Developer|Notes|Platform|Publisher|Rating|Year|StarRating|Name|CloneOf|Series|PlayMode|Genre|Status|Source|Region|Favorite|Completed|Portable|CloneOf"
  26.         gameInfo := Object()
  27.         gameInfo := BuildDatabaseTable(dbName,systemName,frontendDatabaseFields,frontendDatabaseLabels)
  28.        
  29.         ;----------Loading FrontEnd asset labels
  30.         feMedia := {}
  31.         feLogoLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Logo_Labels", "Game Logo|System Logo")   ; if label "keepFileName" the filename will be used as label
  32.         feBackgroundsLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Backgrounds_Labels", "Background|Fanart - Background")
  33.         feDiscArtworkLabel:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Disc_Artwork_Label", "")
  34.        
  35.         ;Acquiring Logos
  36.         logoPath := frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Clear Logo"
  37.         systemLogoPath := frontendPath . "\Images\Platforms\" . gameInfo["Platform"].Value . "\Clear Logo"
  38.         feMedia.Logos := launchboxProcessExtraFiles(logoPath . "|" . systemLogoPath, feLogoLabels, "game|system", "png|bmp|gif|jpg|tif")
  39.        
  40.         ;Acquiring Backgrounds
  41.         gameBackgroundsPath := frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Background\Background"
  42.         gameFanartBackgroundPath := frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Background"
  43.         feMedia.Backgrounds := launchboxProcessExtraFiles(gameBackgroundsPath . "|" . gameFanartBackgroundPath,feBackgroundsLabels,"game|game","png|bmp|gif|jpg|tif")
  44.  
  45.         ;Acquiring Disc artwork (not available or location unknown on LaunchBox folders)
  46.  
  47.         Log("PluginInit - Ended")
  48. Return
  49.  
  50. BuildDatabaseTable(game,system,ByRef frontendDatabaseFields, ByRef frontendDatabaseLabels){ ; required for rom mapping menu name
  51.         Log("BuildDatabaseTable - Started - Building Table for: " . frontendDatabaseLabels,4)
  52.         Global frontendPath, logLevel, dbName, romPath, romExtension, RLObject
  53.         infoObject := Object()
  54.         stringSplit, label, frontendDatabaseLabels, |
  55.         systemXML := CheckFile(frontendPath . "\Data\Platforms\" . system . ".xml")
  56.         FileRead, xmlContents, %systemXML%
  57.         ;search for a relative game path in relation with launchbox if the game is on the same drive as Launchbox (required because the way Launchbox saves the ApplicationPath info)
  58.         if (substr(frontendPath,1,1) = substr(romPath . "\" . dbName . romExtension, 1, 1))
  59.                 searchStringStart := RLObject.getRelativePathFromFull(frontendPath, romPath . "\" . dbName . romExtension)
  60.         else
  61.                 searchStringStart := romPath . "\" . dbName . romExtension
  62.         ; Replacing XML invalid characters
  63.         replace :=   {"&":"&"}
  64.         ;replace :=   {"&":"&amp;","'":"&apos;","<":"&lt;",">":"&gt;","""":"&quot;"} ; there is no need for replacing other invalid xml characters either because they are invalid file names or because LaunchBox does not replace them on its databases
  65.         For what, with in replace
  66.                 StringReplace, searchStringStart, searchStringStart, %what%, %with%, All
  67.         searchStringStart := "<ApplicationPath>" . searchStringStart . "</ApplicationPath>"    
  68.         Log("BuildDatabaseTable - Searching LaunchBox database file for XML section: " . searchStringStart,4)
  69.         searchStringEnd := "</Game>"
  70.         GameXMLInfo := StrX(xmlContents,searchStringStart,1,0,searchStringEnd,1,0)      ; full game section from HS xml
  71.         if !(GameXMLInfo) { ; no info found, setting name info to the game value
  72.                 currentobj:={}
  73.                 currentobj.Label := "Name"
  74.                 currentobj.Value := game
  75.                 infoObject.Insert(currentobj["Label"], currentobj)
  76.                 Log("BuildDatabaseTable - Ended - no ""Game Name"" found. Assigning """ . game . """ to the label ""Name""",2)
  77.                 Return infoObject
  78.         } Else
  79.                 Log("BuildDatabaseTable - Found ""Game Name"" in the database!",4)
  80.         ; game xml info
  81.         loop, parse, frontendDatabaseFields,|,
  82.         {       currentLabel := label%A_index%
  83.                 Log("BuildDatabaseTable - Looking database for: " . currentLabel,4)
  84.                 XMLDbInfo := StrX(GameXMLInfo,"<" . A_Loopfield . ">",1,StrLen("<" . A_Loopfield . ">"),"</" . A_Loopfield . ">"d,1,StrLen("</" . A_Loopfield . ">"))
  85.                 XMLDbInfo := RegexReplace( XMLDbInfo, "^\s+|\s+$" )
  86.                 ;post processing some of the LaunchBox database info
  87.                 if (currentLabel="Year")
  88.                         XMLDbInfo :=  SubStr(XMLDbInfo,1,4)
  89.                 currentobj:={}
  90.                 currentobj.Label := currentLabel
  91.                 currentobj.Value := XMLDbInfo
  92.                 infoObject.Insert(currentobj["Label"], currentobj)
  93.                 if (XMLDbInfo)
  94.                         Log("BuildDatabaseTable - Found """ . currentLabel . """ with a value: """ . XMLDbInfo . """",4)
  95.         }
  96.         ;platform info
  97.         if (infoObject["Platform"].Value){
  98.                 searchStringStart := "<Name>" . infoObject["Platform"].Value . "</Name>"
  99.                 searchStringEnd := "</Platform>"
  100.                 platformPathInfo := StrX(xmlContents,searchStringStart,1,0,searchStringEnd,1,0)
  101.                 mediaFoldersXMLKeys := "VideosFolder|FrontImagesFolder|BackImagesFolder|ClearLogoImagesFolder|FanartImagesFolder|ScreenshotImagesFolder|BannerImagesFolder|SteamBannerImagesFolder|ManualsFolder|MusicFolder"
  102.                 mediaFoldersLabels := "Videos_Path|Front_Path|Back_Path|ClearLogo_Path|Fanart_Path|Screenshot_Path|Banner_Path|SteamBanner_Path|Manuals_Path|Music_Path"
  103.                 stringSplit, label, mediaFoldersLabels, |
  104.                 loop, parse, mediaFoldersXMLKeys,|,
  105.                 {       currentLabel := label%A_index%
  106.                         Log("BuildDatabaseTable - Looking database for platform path for: " . currentLabel,4)
  107.                         XMLDbInfo := StrX(platformPathInfo,"<" . A_Loopfield . ">",1,StrLen("<" . A_Loopfield . ">"),"</" . A_Loopfield . ">"d,1,StrLen("</" . A_Loopfield . ">"))
  108.                         currentobj:={}
  109.                         currentobj.Label := currentLabel
  110.                         currentobj.Value := XMLDbInfo
  111.                         infoObject.Insert(currentobj["Label"], currentobj)
  112.                         if (XMLDbInfo)
  113.                                 Log("BuildDatabaseTable - Found """ . currentLabel . """ with a value: """ . XMLDbInfo . """",4)
  114.                 }
  115.         }
  116.         if (logLevel>=5){
  117.                 for index, element in infoObject
  118.                         gameInfoLog := % gameInfoLog . "`r`n`t`t`t`t`tGameInfo Label: " . element.Label . " | GameInfo Value: " . element.Value
  119.                 Log("PluginInit - GameInfo:" gameInfoLog ,5)
  120.         }
  121.         Log("BuildDatabaseTable - Ended",4)
  122.         Return infoObject
  123. }
  124.  
  125. launchboxProcessExtraFiles(list,label,AssetType,extensions){
  126.         Global gameInfo, romName
  127.         obj := {}
  128.         StringSplit, labelArray, label, |,
  129.         StringSplit, AssetTypeArray, AssetType, |,
  130.         Loop, Parse, list,|
  131.         {       currentLabel := A_Index
  132.                 If !(labelArray%currentLabel% = "#disabled#"){ 
  133.                         If (AssetTypeArray%currentLabel% = "game"){
  134.                                 ;adding dbnamed assets
  135.                                 obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["Name"].Value . ".*",labelArray%currentLabel%,AssetTypeArray%currentLabel%,extensions, obj)
  136.                                 Loop, 9
  137.                                         obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["Name"].Value . "-0" . a_index . ".*",labelArray%currentLabel% . "-0" . a_index,AssetTypeArray%currentLabel%,extensions, obj)
  138.                                 if (parentDbName){
  139.                                         obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["CloneOf"].Value . ".*","Parent " . labelArray%currentLabel%,AssetTypeArray%currentLabel%,extensions, obj)
  140.                                         Loop, 9
  141.                                                 obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["CloneOf"].Value . "-0" . a_index . ".*","Parent " . labelArray%currentLabel% . "-0" . a_index,AssetTypeArray%currentLabel%,extensions, obj)
  142.                                 }
  143.                                 ;adding rom named assets
  144.                                 obj := BuildAssetsTable(A_loopfield . "\" . romName . ".*","Rom " . labelArray%currentLabel%,AssetTypeArray%currentLabel%,extensions, obj)
  145.                                 Loop, 9
  146.                                         obj := BuildAssetsTable(A_loopfield . "\" . romName . "-0" . a_index . ".*","Rom " . labelArray%currentLabel% . "-0" . a_index,AssetTypeArray%currentLabel%,extensions, obj)
  147.                         } else { ;system assets
  148.                                 obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["Platform"].Value . ".*",labelArray%currentLabel%,AssetTypeArray%currentLabel%,extensions, obj)
  149.                                 Loop, 9
  150.                                         obj := BuildAssetsTable(A_loopfield . "\" . gameInfo["Platform"].Value . "-0" . a_index . ".*",labelArray%currentLabel% . "-0" . a_index,AssetTypeArray%currentLabel%,extensions, obj)
  151.                         }
  152.                 }
  153.         }
  154.         Return obj
  155. }
  156.  
  157. loadAdditionalFEAssets(){
  158.         Global additionalFEAssetsLoaded, feMedia, frontendPath, gameInfo
  159.        
  160.         ;Loading labels from ini files
  161.         feArtworkLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Artwork_Labels", "Advertisement Flyer - Back|Advertisement Flyer - Front|Arcade - Cabinet|Arcade - Circuit Board|Arcade - Control Panel|Arcade - Controls Information|Arcade - Marquee|Banner|Box - 3D|Box - Back|Box - Back - Reconstructed|Box - Front|Box - Front - Reconstructed|Cart - 3D|Cart - Back|Cart - Front|Disc|Fanart - Box - Back|Fanart - Box - Front|Fanart - Cart - Back|Fanart - Cart - Front|Fanart - Disc|Screenshot - Game Over|Screenshot - Game Select|Screenshot - Game Title|Screenshot - Gameplay|Screenshot - High Scores|Steam Banner|Screenshot - Gameplay - Cabinet|Screenshot - Gameplay - Controls|Screenshot - Gameplay - CP|Screenshot - Gameplay - GameOver|Screenshot - Gameplay - Marquee|Screenshot - Gameplay - PCB|Screenshot - Gameplay - Score|Screenshot - Gameplay - Select|Screenshot - Gameplay - Snap|Screenshot - Gameplay - Title")
  162.         feControllerLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Controller_Labels", "")
  163.         feGuidesLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Guides_Labels", "")
  164.         feManualsLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Manuals_Labels", "Game Manual")
  165.         feVideosLabels:= RIniLoadVar("GlobalPluginsIni","SystemPluginsIni", "LaunchBox", "Fe_Videos_Labels", "Game Video|System Video")
  166.        
  167.         ;Acquiring ArtWork
  168.         feArtworkPaths1 := frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Advertisement Flyer - Back" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Advertisement Flyer - Front" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Arcade - Cabinet" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Arcade - Circuit Board" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Arcade - Control Panel" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Arcade - Controls Information" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Arcade - Marquee" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Banner" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Box - 3D" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Box - Back" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Box - Back - Reconstructed" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Box - Front" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Box - Front - Reconstructed" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Cart - 3D" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Cart - Back" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Cart - Front" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Disc"
  169.         feArtworkPaths2 := frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Box - Back" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Box - Front" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Cart - Back" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Cart - Front" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Fanart - Disc" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Game Over" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Game Select" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Game Title" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - High Scores" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Steam Banner" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Cabinet" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Controls" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\CP" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\GameOver" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Marquee" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\PCB" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Score" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Select" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Snap" . "|" . frontendPath . "\Images\" . gameInfo["Platform"].Value . "\Screenshot - Gameplay\Title"
  170.         feMedia.Artwork := launchboxProcessExtraFiles(feArtworkPaths1 . "|" . feArtworkPaths2, feArtworkLabels, "game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game|game", "png|bmp|gif|jpg|tif")
  171.        
  172.         ;Acquiring Videos
  173.         gameVideoPath := frontendPath . "\Videos\" . gameInfo["Platform"].Value
  174.         systemVideoPath := frontendPath . "\Videos\Platforms\" . gameInfo["Platform"].Value
  175.         feMedia.Videos := launchboxProcessExtraFiles(gameVideoPath . "|" . systemVideoPath,feVideosLabels,"game|system","mp4,flv")
  176.        
  177.         ;Acquiring Manuals
  178.         gameManualPath := frontendPath . "\Manuals\" . gameInfo["Platform"].Value
  179.         feMedia.Manuals := launchboxProcessExtraFiles(gameManualPath,feManualsLabels,"game","pdf")
  180.  
  181.         ;Acquiring Controller (not available or location unknown on LaunchBox folders)
  182.         ;Acquiring Guides (not available or location unknown on LaunchBox folders)
  183.        
  184.         additionalFEAssetsLoaded := true
  185.         Return
  186. }
  187.