def editEmuCmd(self): # Maybe there is autoconfig support preconfiguredEmulator = None emulatorPath = '' dialog = xbmcgui.Dialog() if self.selectedRomCollection.name == 'Linux' \ or self.selectedRomCollection.name == 'Macintosh' \ or self.selectedRomCollection.name == 'Windows': emulatorPath = self.editTextProperty(CONTROL_BUTTON_EMUCMD, util.localize(32624)) else: autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) emulist = [] log.info( u"Running on {0}. Trying to find emulator per autoconfig.". format(util.current_os)) emulators = autoconfig.findEmulators( util.current_os, self.selectedRomCollection.name, True) for emulator in emulators: if emulator.isInstalled: emulist.append(util.localize(32202) % emulator.name) else: emulist.append(emulator.name) # Ask the user which emulator they want if len(emulist) > 0: emuIndex = dialog.select(util.localize(32203), emulist) try: if (emuIndex >= 0): preconfiguredEmulator = emulators[emuIndex] except IndexError: log.info("No Emulator selected.") preconfiguredEmulator = None if preconfiguredEmulator: emulatorPath = preconfiguredEmulator.emuCmd self.selectedRomCollection.emulatorParams = preconfiguredEmulator.emuParams control = self.getControlById(CONTROL_BUTTON_PARAMS) control.setLabel(self.selectedRomCollection.emulatorParams) else: emulatorPath = dialog.browse( 1, '%s ' % self.selectedRomCollection.name + util.localize(32139), 'files') if emulatorPath == '': return self.selectedRomCollection.emulatorCmd = emulatorPath control = self.getControlById(CONTROL_BUTTON_EMUCMD) control.setLabel(emulatorPath)
def addRomCollections(self, id, configObj, consoleList, isUpdate): romCollections = {} dialog = xbmcgui.Dialog() #scraping scenario scenarioIndex = dialog.select(util.localize(32173), [util.localize(32174), util.localize(32175)]) Logutil.log('scenarioIndex: ' +str(scenarioIndex), util.LOG_LEVEL_INFO) if(scenarioIndex == -1): del dialog Logutil.log('No scenario selected. Action canceled.', util.LOG_LEVEL_INFO) return False, romCollections autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) while True: fileTypeList, errorMsg = self.buildMediaTypeList(configObj, isUpdate) romCollection = RomCollection() #console platformIndex = dialog.select(util.localize(32176), consoleList) Logutil.log('platformIndex: ' +str(platformIndex), util.LOG_LEVEL_INFO) if(platformIndex == -1): Logutil.log('No Platform selected. Action canceled.', util.LOG_LEVEL_INFO) break else: console = consoleList[platformIndex] if(console =='Other'): keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32177)) keyboard.doModal() if (keyboard.isConfirmed()): console = keyboard.getText() Logutil.log('Platform entered manually: ' +console, util.LOG_LEVEL_INFO) else: Logutil.log('No Platform entered. Action canceled.', util.LOG_LEVEL_INFO) break else: consoleList.remove(console) Logutil.log('selected platform: ' +console, util.LOG_LEVEL_INFO) romCollection.name = console romCollection.id = id id = id +1 #check if we have general RetroPlayer support if(helper.isRetroPlayerSupported()): supportsRetroPlayer = True #if we have full python integration we can also check if specific platform supports RetroPlayer if(helper.retroPlayerSupportsPythonIntegration()): supportsRetroPlayer = False success, installedAddons = helper.readLibretroCores("all", True, romCollection.name) if(success and len(installedAddons) > 0): supportsRetroPlayer = True else: success, installedAddons = helper.readLibretroCores("uninstalled", False, romCollection.name) if(success and len(installedAddons) > 0): supportsRetroPlayer = True if(supportsRetroPlayer): retValue = dialog.yesno(util.localize(32999), util.localize(32198)) if(retValue == True): romCollection.useBuiltinEmulator = True #only ask for emulator and params if we don't use builtin emulator if(not romCollection.useBuiltinEmulator): #maybe there is autoconfig support preconfiguredEmulator = None #emulator #xbox games on xbox will be launched directly if (os.environ.get( "OS", "xbox" ) == "xbox" and romCollection.name == 'Xbox'): romCollection.emulatorCmd = '%ROM%' Logutil.log('emuCmd set to "%ROM%" on Xbox.', util.LOG_LEVEL_INFO) #check for standalone games elif (romCollection.name == 'Linux' or romCollection.name == 'Macintosh' or romCollection.name == 'Windows'): romCollection.emulatorCmd = '"%ROM%"' Logutil.log('emuCmd set to "%ROM%" for standalone games.', util.LOG_LEVEL_INFO) else: #TODO: Windows and Linux support #xbmc.getCondVisibility('System.Platform.Windows') #xbmc.getCondVisibility('System.Platform.Linux') if(xbmc.getCondVisibility('System.Platform.Android')): Logutil.log('Running on Android. Trying to find emulator per autoconfig.', util.LOG_LEVEL_INFO) emulators = autoconfig.findEmulators('Android', romCollection.name, True) emulist = [] for emulator in emulators: if(emulator.isInstalled): emulist.append(util.localize(32202) %emulator.name) else: emulist.append(emulator.name) if(len(emulist) > 0): emuIndex = dialog.select(util.localize(32203), emulist) Logutil.log('emuIndex: ' +str(emuIndex), util.LOG_LEVEL_INFO) if(emuIndex == -1): Logutil.log('No Emulator selected.', util.LOG_LEVEL_INFO) else: preconfiguredEmulator = emulators[emuIndex] if(preconfiguredEmulator): romCollection.emulatorCmd = preconfiguredEmulator.emuCmd else: consolePath = dialog.browse(1, util.localize(32178) %console, 'files') Logutil.log('consolePath: ' +str(consolePath), util.LOG_LEVEL_INFO) if(consolePath == ''): Logutil.log('No consolePath selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.emulatorCmd = consolePath #params #on xbox we will create .cut files without params if (os.environ.get( "OS", "xbox" ) == "xbox"): romCollection.emulatorParams = '' Logutil.log('emuParams set to "" on Xbox.', util.LOG_LEVEL_INFO) elif (romCollection.name == 'Linux' or romCollection.name == 'Macintosh' or romCollection.name == 'Windows'): romCollection.emulatorParams = '' Logutil.log('emuParams set to "" for standalone games.', util.LOG_LEVEL_INFO) else: defaultParams = '"%ROM%"' if(preconfiguredEmulator): defaultParams = preconfiguredEmulator.emuParams keyboard = xbmc.Keyboard() keyboard.setDefault(defaultParams) keyboard.setHeading(util.localize(32179)) keyboard.doModal() if (keyboard.isConfirmed()): emuParams = keyboard.getText() Logutil.log('emuParams: ' +str(emuParams), util.LOG_LEVEL_INFO) else: Logutil.log('No emuParams selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.emulatorParams = emuParams #roms romPath = dialog.browse(0, util.localize(32180) %console, 'files') if(romPath == ''): Logutil.log('No romPath selected. Action canceled.', util.LOG_LEVEL_INFO) break #TODO: find out how to deal with non-ascii characters try: unicode(romPath) except: Logutil.log("RCB can't acces your Rom Path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32041), errorMsg) break #filemask #xbox games always use default.xbe as executable if (os.environ.get( "OS", "xbox" ) == "xbox" and romCollection.name == 'Xbox'): Logutil.log('filemask "default.xbe" for Xbox games on Xbox.', util.LOG_LEVEL_INFO) romPathComplete = util.joinPath(romPath, 'default.xbe') romCollection.romPaths = [] romCollection.romPaths.append(romPathComplete) else: keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32181)) keyboard.doModal() if (keyboard.isConfirmed()): fileMaskInput = keyboard.getText() Logutil.log('fileMask: ' +str(fileMaskInput), util.LOG_LEVEL_INFO) fileMasks = fileMaskInput.split(',') romCollection.romPaths = [] for fileMask in fileMasks: romPathComplete = util.joinPath(romPath, fileMask.strip()) romCollection.romPaths.append(romPathComplete) else: Logutil.log('No fileMask selected. Action canceled.', util.LOG_LEVEL_INFO) break if (os.environ.get( "OS", "xbox" ) == "xbox"): romCollection.xboxCreateShortcut = True romCollection.xboxCreateShortcutAddRomfile = True romCollection.xboxCreateShortcutUseShortGamename = False #TODO use flags for complete platform list (not only xbox) if(romCollection.name == 'Xbox'): romCollection.useFoldernameAsGamename = True romCollection.searchGameByCRC = False romCollection.maxFolderDepth = 1 if(scenarioIndex == 0): artworkPath = dialog.browse(0, util.localize(32193) %console, 'files', '', False, False, romPath) Logutil.log('artworkPath: ' +str(artworkPath), util.LOG_LEVEL_INFO) #TODO: find out how to deal with non-ascii characters try: unicode(artworkPath) except: Logutil.log("RCB can't acces your artwork path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32042), errorMsg) break if(artworkPath == ''): Logutil.log('No artworkPath selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.descFilePerGame= True #mediaPaths romCollection.mediaPaths = [] if(romCollection.name == 'MAME'): romCollection.mediaPaths.append(self.createMediaPath('boxfront', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('action', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('title', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('cabinet', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('marquee', artworkPath, scenarioIndex)) else: romCollection.mediaPaths.append(self.createMediaPath('boxfront', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('boxback', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('cartridge', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('screenshot', artworkPath, scenarioIndex)) romCollection.mediaPaths.append(self.createMediaPath('fanart', artworkPath, scenarioIndex)) #other MAME specific properties if(romCollection.name == 'MAME'): romCollection.imagePlacingMain = ImagePlacing() romCollection.imagePlacingMain.name = 'gameinfomamecabinet' #MAME zip files contain several files but they must be passed to the emu as zip file romCollection.doNotExtractZipFiles = True #create MAWS scraper site = Site() site.name = 'maws.mameworld.info' scrapers = [] scraper = Scraper() scraper.parseInstruction = '06 - maws.xml' scraper.source = 'http://maws.mameworld.info/maws/romset/%GAME%' scrapers.append(scraper) site.scrapers = scrapers romCollection.scraperSites = [] romCollection.scraperSites.append(site) else: if(romCollection.name == 'MAME'): romCollection.imagePlacingMain = ImagePlacing() romCollection.imagePlacingMain.name = 'gameinfomamecabinet' #MAME zip files contain several files but they must be passed to the emu as zip file romCollection.doNotExtractZipFiles = True romCollection.mediaPaths = [] lastArtworkPath = '' while True: fileTypeIndex = dialog.select(util.localize(32183), fileTypeList) Logutil.log('fileTypeIndex: ' +str(fileTypeIndex), util.LOG_LEVEL_INFO) if(fileTypeIndex == -1): Logutil.log('No fileTypeIndex selected.', util.LOG_LEVEL_INFO) break fileType = fileTypeList[fileTypeIndex] fileTypeList.remove(fileType) if(lastArtworkPath == ''): artworkPath = dialog.browse(0, util.localize(32182) %(console, fileType), 'files', '', False, False, romPath) else: artworkPath = dialog.browse(0, util.localize(32182) %(console, fileType), 'files', '', False, False, lastArtworkPath) try: unicode(artworkPath) except: Logutil.log("RCB can't acces your artwork path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32042), errorMsg) break lastArtworkPath = artworkPath Logutil.log('artworkPath: ' +str(artworkPath), util.LOG_LEVEL_INFO) if(artworkPath == ''): Logutil.log('No artworkPath selected.', util.LOG_LEVEL_INFO) break romCollection.mediaPaths.append(self.createMediaPath(fileType, artworkPath, scenarioIndex)) retValue = dialog.yesno(util.localize(32999), util.localize(32184)) if(retValue == False): break descIndex = dialog.select(util.localize(32185), [util.localize(32186), util.localize(32187), util.localize(32188)]) Logutil.log('descIndex: ' +str(descIndex), util.LOG_LEVEL_INFO) if(descIndex == -1): Logutil.log('No descIndex selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.descFilePerGame = (descIndex != 1) if(descIndex == 2): #leave scraperSites empty - they will be filled in configwriter pass else: descPath = '' if(romCollection.descFilePerGame): #get path pathValue = dialog.browse(0, util.localize(32189) %console, 'files') if(pathValue == ''): break #get file mask keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32190)) keyboard.setDefault('%GAME%.txt') keyboard.doModal() if (keyboard.isConfirmed()): filemask = keyboard.getText() descPath = util.joinPath(pathValue, filemask.strip()) else: descPath = dialog.browse(1, util.localize(32189) %console, 'files', '', False, False, lastArtworkPath) Logutil.log('descPath: ' +str(descPath), util.LOG_LEVEL_INFO) if(descPath == ''): Logutil.log('No descPath selected. Action canceled.', util.LOG_LEVEL_INFO) break parserPath = dialog.browse(1, util.localize(32191) %console, 'files', '', False, False, descPath) Logutil.log('parserPath: ' +str(parserPath), util.LOG_LEVEL_INFO) if(parserPath == ''): Logutil.log('No parserPath selected. Action canceled.', util.LOG_LEVEL_INFO) break #create scraper site = Site() site.name = console site.descFilePerGame = (descIndex == 0) site.searchGameByCRC = True scrapers = [] scraper = Scraper() scraper.parseInstruction = parserPath scraper.source = descPath scraper.encoding = 'iso-8859-1' scrapers.append(scraper) site.scrapers = scrapers romCollection.scraperSites = [] romCollection.scraperSites.append(site) romCollections[romCollection.id] = romCollection retValue = dialog.yesno(util.localize(32999), util.localize(32192)) if(retValue == False): break del dialog return True, romCollections
def addRomCollections(self, id, configObj, consoleList, isUpdate): romCollections = {} dialog = xbmcgui.Dialog() #scraping scenario scenarioIndex = dialog.select( util.localize(32173), [util.localize(32174), util.localize(32175)]) Logutil.log('scenarioIndex: ' + str(scenarioIndex), util.LOG_LEVEL_INFO) if (scenarioIndex == -1): del dialog Logutil.log('No scenario selected. Action canceled.', util.LOG_LEVEL_INFO) return False, romCollections autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) while True: fileTypeList, errorMsg = self.buildMediaTypeList( configObj, isUpdate) romCollection = RomCollection() #console platformIndex = dialog.select(util.localize(32176), consoleList) Logutil.log('platformIndex: ' + str(platformIndex), util.LOG_LEVEL_INFO) if (platformIndex == -1): Logutil.log('No Platform selected. Action canceled.', util.LOG_LEVEL_INFO) break else: console = consoleList[platformIndex] if (console == 'Other'): keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32177)) keyboard.doModal() if (keyboard.isConfirmed()): console = keyboard.getText() Logutil.log('Platform entered manually: ' + console, util.LOG_LEVEL_INFO) else: Logutil.log('No Platform entered. Action canceled.', util.LOG_LEVEL_INFO) break else: consoleList.remove(console) Logutil.log('selected platform: ' + console, util.LOG_LEVEL_INFO) romCollection.name = console romCollection.id = id id = id + 1 #check if we have general RetroPlayer support if (helper.isRetroPlayerSupported()): supportsRetroPlayer = True #if we have full python integration we can also check if specific platform supports RetroPlayer if (helper.retroPlayerSupportsPythonIntegration()): supportsRetroPlayer = False success, installedAddons = helper.readLibretroCores( "all", True, romCollection.name) if (success and len(installedAddons) > 0): supportsRetroPlayer = True else: success, installedAddons = helper.readLibretroCores( "uninstalled", False, romCollection.name) if (success and len(installedAddons) > 0): supportsRetroPlayer = True if (supportsRetroPlayer): retValue = dialog.yesno(util.localize(32999), util.localize(32198)) if (retValue == True): romCollection.useBuiltinEmulator = True #only ask for emulator and params if we don't use builtin emulator if (not romCollection.useBuiltinEmulator): #maybe there is autoconfig support preconfiguredEmulator = None #emulator #xbox games on xbox will be launched directly if (os.environ.get("OS", "xbox") == "xbox" and romCollection.name == 'Xbox'): romCollection.emulatorCmd = '%ROM%' Logutil.log('emuCmd set to "%ROM%" on Xbox.', util.LOG_LEVEL_INFO) #check for standalone games elif (romCollection.name == 'Linux' or romCollection.name == 'Macintosh' or romCollection.name == 'Windows'): romCollection.emulatorCmd = '"%ROM%"' Logutil.log('emuCmd set to "%ROM%" for standalone games.', util.LOG_LEVEL_INFO) else: #TODO: Windows and Linux support #xbmc.getCondVisibility('System.Platform.Windows') #xbmc.getCondVisibility('System.Platform.Linux') if (xbmc.getCondVisibility('System.Platform.Android')): Logutil.log( 'Running on Android. Trying to find emulator per autoconfig.', util.LOG_LEVEL_INFO) emulators = autoconfig.findEmulators( 'Android', romCollection.name, True) emulist = [] for emulator in emulators: if (emulator.isInstalled): emulist.append( util.localize(32202) % emulator.name) else: emulist.append(emulator.name) if (len(emulist) > 0): emuIndex = dialog.select(util.localize(32203), emulist) Logutil.log('emuIndex: ' + str(emuIndex), util.LOG_LEVEL_INFO) if (emuIndex == -1): Logutil.log('No Emulator selected.', util.LOG_LEVEL_INFO) else: preconfiguredEmulator = emulators[emuIndex] if (preconfiguredEmulator): romCollection.emulatorCmd = preconfiguredEmulator.emuCmd else: consolePath = dialog.browse( 1, util.localize(32178) % console, 'files') Logutil.log('consolePath: ' + str(consolePath), util.LOG_LEVEL_INFO) if (consolePath == ''): Logutil.log( 'No consolePath selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.emulatorCmd = consolePath #params #on xbox we will create .cut files without params if (os.environ.get("OS", "xbox") == "xbox"): romCollection.emulatorParams = '' Logutil.log('emuParams set to "" on Xbox.', util.LOG_LEVEL_INFO) elif (romCollection.name == 'Linux' or romCollection.name == 'Macintosh' or romCollection.name == 'Windows'): romCollection.emulatorParams = '' Logutil.log('emuParams set to "" for standalone games.', util.LOG_LEVEL_INFO) else: defaultParams = '"%ROM%"' if (preconfiguredEmulator): defaultParams = preconfiguredEmulator.emuParams keyboard = xbmc.Keyboard() keyboard.setDefault(defaultParams) keyboard.setHeading(util.localize(32179)) keyboard.doModal() if (keyboard.isConfirmed()): emuParams = keyboard.getText() Logutil.log('emuParams: ' + str(emuParams), util.LOG_LEVEL_INFO) else: Logutil.log('No emuParams selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.emulatorParams = emuParams #roms romPath = dialog.browse(0, util.localize(32180) % console, 'files') if (romPath == ''): Logutil.log('No romPath selected. Action canceled.', util.LOG_LEVEL_INFO) break #TODO: find out how to deal with non-ascii characters try: unicode(romPath) except: Logutil.log( "RCB can't acces your Rom Path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32041), errorMsg) break #filemask #xbox games always use default.xbe as executable if (os.environ.get("OS", "xbox") == "xbox" and romCollection.name == 'Xbox'): Logutil.log('filemask "default.xbe" for Xbox games on Xbox.', util.LOG_LEVEL_INFO) romPathComplete = util.joinPath(romPath, 'default.xbe') romCollection.romPaths = [] romCollection.romPaths.append(romPathComplete) else: keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32181)) keyboard.doModal() if (keyboard.isConfirmed()): fileMaskInput = keyboard.getText() Logutil.log('fileMask: ' + str(fileMaskInput), util.LOG_LEVEL_INFO) fileMasks = fileMaskInput.split(',') romCollection.romPaths = [] for fileMask in fileMasks: romPathComplete = util.joinPath( romPath, fileMask.strip()) romCollection.romPaths.append(romPathComplete) else: Logutil.log('No fileMask selected. Action canceled.', util.LOG_LEVEL_INFO) break if (os.environ.get("OS", "xbox") == "xbox"): romCollection.xboxCreateShortcut = True romCollection.xboxCreateShortcutAddRomfile = True romCollection.xboxCreateShortcutUseShortGamename = False #TODO use flags for complete platform list (not only xbox) if (romCollection.name == 'Xbox'): romCollection.useFoldernameAsGamename = True romCollection.searchGameByCRC = False romCollection.maxFolderDepth = 1 if (scenarioIndex == 0): artworkPath = dialog.browse(0, util.localize(32193) % console, 'files', '', False, False, romPath) Logutil.log('artworkPath: ' + str(artworkPath), util.LOG_LEVEL_INFO) #TODO: find out how to deal with non-ascii characters try: unicode(artworkPath) except: Logutil.log( "RCB can't acces your artwork path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32042), errorMsg) break if (artworkPath == ''): Logutil.log('No artworkPath selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.descFilePerGame = True #mediaPaths romCollection.mediaPaths = [] if (romCollection.name == 'MAME'): romCollection.mediaPaths.append( self.createMediaPath('boxfront', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('action', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('title', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('cabinet', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('marquee', artworkPath, scenarioIndex)) else: romCollection.mediaPaths.append( self.createMediaPath('boxfront', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('boxback', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('cartridge', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('screenshot', artworkPath, scenarioIndex)) romCollection.mediaPaths.append( self.createMediaPath('fanart', artworkPath, scenarioIndex)) #other MAME specific properties if (romCollection.name == 'MAME'): romCollection.imagePlacingMain = ImagePlacing() romCollection.imagePlacingMain.name = 'gameinfomamecabinet' #MAME zip files contain several files but they must be passed to the emu as zip file romCollection.doNotExtractZipFiles = True #create MAWS scraper site = Site() site.name = 'maws.mameworld.info' scrapers = [] scraper = Scraper() scraper.parseInstruction = '06 - maws.xml' scraper.source = 'http://maws.mameworld.info/maws/romset/%GAME%' scrapers.append(scraper) site.scrapers = scrapers romCollection.scraperSites = [] romCollection.scraperSites.append(site) else: if (romCollection.name == 'MAME'): romCollection.imagePlacingMain = ImagePlacing() romCollection.imagePlacingMain.name = 'gameinfomamecabinet' #MAME zip files contain several files but they must be passed to the emu as zip file romCollection.doNotExtractZipFiles = True romCollection.mediaPaths = [] lastArtworkPath = '' while True: fileTypeIndex = dialog.select(util.localize(32183), fileTypeList) Logutil.log('fileTypeIndex: ' + str(fileTypeIndex), util.LOG_LEVEL_INFO) if (fileTypeIndex == -1): Logutil.log('No fileTypeIndex selected.', util.LOG_LEVEL_INFO) break fileType = fileTypeList[fileTypeIndex] fileTypeList.remove(fileType) if (lastArtworkPath == ''): artworkPath = dialog.browse( 0, util.localize(32182) % (console, fileType), 'files', '', False, False, romPath) else: artworkPath = dialog.browse( 0, util.localize(32182) % (console, fileType), 'files', '', False, False, lastArtworkPath) try: unicode(artworkPath) except: Logutil.log( "RCB can't acces your artwork path. Make sure it does not contain any non-ascii characters.", util.LOG_LEVEL_INFO) xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32042), errorMsg) break lastArtworkPath = artworkPath Logutil.log('artworkPath: ' + str(artworkPath), util.LOG_LEVEL_INFO) if (artworkPath == ''): Logutil.log('No artworkPath selected.', util.LOG_LEVEL_INFO) break romCollection.mediaPaths.append( self.createMediaPath(fileType, artworkPath, scenarioIndex)) retValue = dialog.yesno(util.localize(32999), util.localize(32184)) if (retValue == False): break descIndex = dialog.select(util.localize(32185), [ util.localize(32186), util.localize(32187), util.localize(32188) ]) Logutil.log('descIndex: ' + str(descIndex), util.LOG_LEVEL_INFO) if (descIndex == -1): Logutil.log('No descIndex selected. Action canceled.', util.LOG_LEVEL_INFO) break romCollection.descFilePerGame = (descIndex != 1) if (descIndex == 2): #leave scraperSites empty - they will be filled in configwriter pass else: descPath = '' if (romCollection.descFilePerGame): #get path pathValue = dialog.browse( 0, util.localize(32189) % console, 'files') if (pathValue == ''): break #get file mask keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32190)) keyboard.setDefault('%GAME%.txt') keyboard.doModal() if (keyboard.isConfirmed()): filemask = keyboard.getText() descPath = util.joinPath(pathValue, filemask.strip()) else: descPath = dialog.browse( 1, util.localize(32189) % console, 'files', '', False, False, lastArtworkPath) Logutil.log('descPath: ' + str(descPath), util.LOG_LEVEL_INFO) if (descPath == ''): Logutil.log('No descPath selected. Action canceled.', util.LOG_LEVEL_INFO) break parserPath = dialog.browse(1, util.localize(32191) % console, 'files', '', False, False, descPath) Logutil.log('parserPath: ' + str(parserPath), util.LOG_LEVEL_INFO) if (parserPath == ''): Logutil.log('No parserPath selected. Action canceled.', util.LOG_LEVEL_INFO) break #create scraper site = Site() site.name = console site.descFilePerGame = (descIndex == 0) site.searchGameByCRC = True scrapers = [] scraper = Scraper() scraper.parseInstruction = parserPath scraper.source = descPath scraper.encoding = 'iso-8859-1' scrapers.append(scraper) site.scrapers = scrapers romCollection.scraperSites = [] romCollection.scraperSites.append(site) romCollections[romCollection.id] = romCollection retValue = dialog.yesno(util.localize(32999), util.localize(32192)) if (retValue == False): break del dialog return True, romCollections
def onClick(self, controlID): log.info("onClick") if controlID == CONTROL_BUTTON_EXIT: # Close window button log.info("close") self.close() # OK elif controlID == CONTROL_BUTTON_SAVE: log.info("save") # Store selectedRomCollection if self.selectedRomCollection is not None: self.updateSelectedRomCollection() self.romCollections[self.selectedRomCollection.id] = self.selectedRomCollection configWriter = ConfigXmlWriter(False) success, message = configWriter.writeRomCollections(self.romCollections, True) if not success: xbmcgui.Dialog().ok(util.localize(32021), message) self.close() # Cancel elif controlID == CONTROL_BUTTON_CANCEL: self.close() # Rom Collection list elif self.selectedControlId in (CONTROL_BUTTON_RC_DOWN, CONTROL_BUTTON_RC_UP): if self.selectedRomCollection is not None: # Save current values to selected Rom Collection self.updateSelectedRomCollection() # Store previous selectedRomCollections state self.romCollections[self.selectedRomCollection.id] = self.selectedRomCollection # HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateRomCollectionControls() # Media Path elif self.selectedControlId in (CONTROL_BUTTON_MEDIA_DOWN, CONTROL_BUTTON_MEDIA_UP): # HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateMediaPathControls() elif controlID == CONTROL_BUTTON_GAMECLIENT: success, gameclient = helper.selectlibretrocore(self.selectedRomCollection.name) if success: self.selectedRomCollection.gameclient = gameclient control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if gameclient == "": control.setLabel("None") else: control.setLabel(gameclient) elif controlID == CONTROL_BUTTON_EMUCMD: # Maybe there is autoconfig support preconfiguredEmulator = None emulatorPath = '' dialog = xbmcgui.Dialog() if self.selectedRomCollection.name == 'Linux' \ or self.selectedRomCollection.name == 'Macintosh' \ or self.selectedRomCollection.name == 'Windows': emulatorPath = self.editTextProperty(CONTROL_BUTTON_EMUCMD, util.localize(32624)) else: autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) emulist = [] log.info(u"Running on {0}. Trying to find emulator per autoconfig.".format(self.current_os)) emulators = autoconfig.findEmulators(self.current_os, self.selectedRomCollection.name, True) for emulator in emulators: if emulator.isInstalled: emulist.append(util.localize(32202) % emulator.name) else: emulist.append(emulator.name) # Ask the user which emulator they want if len(emulist) > 0: emuIndex = dialog.select(util.localize(32203), emulist) try: if(emuIndex >= 0): preconfiguredEmulator = emulators[emuIndex] except IndexError: log.info("No Emulator selected.") preconfiguredEmulator = None if preconfiguredEmulator: emulatorPath = preconfiguredEmulator.emuCmd self.selectedRomCollection.emulatorParams = preconfiguredEmulator.emuParams control = self.getControlById(CONTROL_BUTTON_PARAMS) control.setLabel(self.selectedRomCollection.emulatorParams) else: emulatorPath = dialog.browse(1, '%s ' % self.selectedRomCollection.name + util.localize(32139), 'files') if emulatorPath == '': return self.selectedRomCollection.emulatorCmd = emulatorPath control = self.getControlById(CONTROL_BUTTON_EMUCMD) control.setLabel(emulatorPath) elif controlID == CONTROL_BUTTON_PARAMS: emulatorParams = self.editTextProperty(CONTROL_BUTTON_PARAMS, util.localize(32625)) self.selectedRomCollection.emulatorParams = emulatorParams elif controlID == CONTROL_BUTTON_ROMPATH: self.editRomPath() elif controlID == CONTROL_BUTTON_FILEMASK: self.editRomFileMask() elif controlID == CONTROL_BUTTON_MEDIAPATH: self.editMediaPath() elif controlID == CONTROL_BUTTON_MEDIAFILEMASK: self.editMediaFileMask() elif controlID == CONTROL_BUTTON_ADDMEDIAPATH: self.addMediaPath() elif controlID == CONTROL_BUTTON_REMOVEMEDIAPATH: self.removeMediaPath() elif controlID == CONTROL_BUTTON_MAXFOLDERDEPTH: maxFolderDepth = self.editTextProperty(CONTROL_BUTTON_MAXFOLDERDEPTH, util.localize(32610)) self.selectedRomCollection.maxFolderDepth = maxFolderDepth elif controlID == CONTROL_BUTTON_DISKINDICATOR: diskIndicator = self.editTextProperty(CONTROL_BUTTON_DISKINDICATOR, util.localize(32611)) self.selectedRomCollection.diskPrefix = diskIndicator elif controlID == CONTROL_BUTTON_SAVESTATEPATH: saveStatePathComplete = self.editPathWithFileMask(CONTROL_BUTTON_SAVESTATEPATH, '%s ' % self.selectedRomCollection.name + util.localize(32629), CONTROL_BUTTON_SAVESTATEMASK) if saveStatePathComplete != '': self.selectedRomCollection.saveStatePath = saveStatePathComplete elif controlID == CONTROL_BUTTON_SAVESTATEMASK: self.selectedRomCollection.saveStatePath = self.editFilemask(CONTROL_BUTTON_SAVESTATEMASK, util.localize(32630), self.selectedRomCollection.saveStatePath) elif controlID == CONTROL_BUTTON_SAVESTATEPARAMS: saveStateParams = self.editTextProperty(CONTROL_BUTTON_SAVESTATEPARAMS, util.localize(32631)) self.selectedRomCollection.saveStateParams = saveStateParams elif controlID == CONTROL_BUTTON_PRECMD: preCmd = self.editTextProperty(CONTROL_BUTTON_PRECMD, util.localize(32632)) self.selectedRomCollection.preCmd = preCmd log.info("OnClick: precmd = {0}".format(self.selectedRomCollection.preCmd)) elif controlID == CONTROL_BUTTON_POSTCMD: postCmd = self.editTextProperty(CONTROL_BUTTON_POSTCMD, util.localize(32633)) self.selectedRomCollection.postCmd = postCmd
def onClick(self, controlID): Logutil.log('onClick', util.LOG_LEVEL_INFO) if (controlID == CONTROL_BUTTON_EXIT): # Close window button Logutil.log('close', util.LOG_LEVEL_INFO) self.close() #OK elif (controlID == CONTROL_BUTTON_SAVE): Logutil.log('save', util.LOG_LEVEL_INFO) #store selectedRomCollection if(self.selectedRomCollection != None): self.updateSelectedRomCollection() self.romCollections[self.selectedRomCollection.id] = self.selectedRomCollection configWriter = ConfigXmlWriter(False) success, message = configWriter.writeRomCollections(self.romCollections, True) if not success: xbmcgui.Dialog().ok(util.localize(32021), message) self.close() #Cancel elif (controlID == CONTROL_BUTTON_CANCEL): self.close() #Rom Collection list elif(self.selectedControlId in (CONTROL_BUTTON_RC_DOWN, CONTROL_BUTTON_RC_UP)): if(self.selectedRomCollection != None): #save current values to selected Rom Collection self.updateSelectedRomCollection() #store previous selectedRomCollections state self.romCollections[self.selectedRomCollection.id] = self.selectedRomCollection #HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateRomCollectionControls() #Media Path elif(self.selectedControlId in (CONTROL_BUTTON_MEDIA_DOWN, CONTROL_BUTTON_MEDIA_UP)): #HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateMediaPathControls() elif (controlID == CONTROL_BUTTON_GAMECLIENT): success, gameclient = helper.selectlibretrocore(self.selectedRomCollection.name) if success: self.selectedRomCollection.gameclient = gameclient control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if(gameclient == ""): control.setLabel("None") else: control.setLabel(gameclient) elif (controlID == CONTROL_BUTTON_EMUCMD): #maybe there is autoconfig support preconfiguredEmulator = None emulatorPath = '' dialog = xbmcgui.Dialog() if (self.selectedRomCollection.name == 'Linux' or self.selectedRomCollection.name == 'Macintosh' or self.selectedRomCollection.name == 'Windows'): emulatorPath = self.editTextProperty(CONTROL_BUTTON_EMUCMD, util.localize(32624)) else: if(xbmc.getCondVisibility('System.Platform.Android')): autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) Logutil.log('Running on Android. Trying to find emulator per autoconfig.', util.LOG_LEVEL_INFO) emulators = autoconfig.findEmulators('Android', self.selectedRomCollection.name, True) emulist = [] if(emulators): for emulator in emulators: if(emulator.isInstalled): emulist.append(util.localize(32202) %emulator.name) else: emulist.append(emulator.name) if(len(emulist) > 0): emuIndex = dialog.select(util.localize(32203), emulist) Logutil.log('emuIndex: ' +str(emuIndex), util.LOG_LEVEL_INFO) if(emuIndex == -1): Logutil.log('No Emulator selected.', util.LOG_LEVEL_INFO) else: preconfiguredEmulator = emulators[emuIndex] if(preconfiguredEmulator): emulatorPath = preconfiguredEmulator.emuCmd self.selectedRomCollection.emulatorParams = preconfiguredEmulator.emuParams control = self.getControlById(CONTROL_BUTTON_PARAMS) control.setLabel(self.selectedRomCollection.emulatorParams) else: emulatorPath = dialog.browse(1, '%s ' %self.selectedRomCollection.name +util.localize(32139), 'files') if(emulatorPath == ''): return self.selectedRomCollection.emulatorCmd = emulatorPath control = self.getControlById(CONTROL_BUTTON_EMUCMD) control.setLabel(emulatorPath) elif (controlID == CONTROL_BUTTON_PARAMS): emulatorParams = self.editTextProperty(CONTROL_BUTTON_PARAMS, util.localize(32625)) self.selectedRomCollection.emulatorParams = emulatorParams elif (controlID == CONTROL_BUTTON_ROMPATH): self.editRomPath() elif (controlID == CONTROL_BUTTON_FILEMASK): self.editRomFileMask() elif (controlID == CONTROL_BUTTON_MEDIAPATH): self.editMediaPath() elif (controlID == CONTROL_BUTTON_MEDIAFILEMASK): self.editMediaFileMask() elif (controlID == CONTROL_BUTTON_ADDMEDIAPATH): self.addMediaPath() elif (controlID == CONTROL_BUTTON_REMOVEMEDIAPATH): self.removeMediaPath() elif (controlID == CONTROL_BUTTON_MAXFOLDERDEPTH): maxFolderDepth = self.editTextProperty(CONTROL_BUTTON_MAXFOLDERDEPTH, util.localize(32610)) self.selectedRomCollection.maxFolderDepth = maxFolderDepth elif (controlID == CONTROL_BUTTON_DISKINDICATOR): diskIndicator = self.editTextProperty(CONTROL_BUTTON_DISKINDICATOR, util.localize(32611)) self.selectedRomCollection.diskPrefix = diskIndicator elif (controlID == CONTROL_BUTTON_SAVESTATEPATH): saveStatePathComplete = self.editPathWithFileMask(CONTROL_BUTTON_SAVESTATEPATH, '%s ' %self.selectedRomCollection.name +util.localize(32629), CONTROL_BUTTON_SAVESTATEMASK) if(saveStatePathComplete != ''): self.selectedRomCollection.saveStatePath = saveStatePathComplete elif (controlID == CONTROL_BUTTON_SAVESTATEMASK): self.selectedRomCollection.saveStatePath = self.editFilemask(CONTROL_BUTTON_SAVESTATEMASK, util.localize(32630), self.selectedRomCollection.saveStatePath) elif (controlID == CONTROL_BUTTON_SAVESTATEPARAMS): saveStateParams = self.editTextProperty(CONTROL_BUTTON_SAVESTATEPARAMS, util.localize(32631)) self.selectedRomCollection.saveStateParams = saveStateParams elif (controlID == CONTROL_BUTTON_PRECMD): preCmd = self.editTextProperty(CONTROL_BUTTON_PRECMD, util.localize(32632)) self.selectedRomCollection.preCmd = preCmd Logutil.log('OnClick: precmd = ' +self.selectedRomCollection.preCmd, util.LOG_LEVEL_INFO) elif (controlID == CONTROL_BUTTON_POSTCMD): postCmd = self.editTextProperty(CONTROL_BUTTON_POSTCMD, util.localize(32633)) self.selectedRomCollection.postCmd = postCmd
parseInstruction = "E:\\XBMC\\RCB\\develop\\scraper\\offline\\mame\\parserconfig.xml" descParser = DescriptionParserFactory.getParser(parseInstruction) results = descParser.parseDescription(str(descFile), 'iso-8859-15') for result in results: print result print len(results) ''' from emulatorautoconfig.autoconfig import EmulatorAutoconfig config = EmulatorAutoconfig('C:\\Users\\lom\\AppData\\Roaming\\XBMC\\addons\\script.games.rom.collection.browser.dev\\resources\\emu_autoconfig.xml') ''' config.readXml() for op in config.operatingSystems: print op.name for platform in op.platforms: print platform.name for alias in platform.aliases: print alias for emulator in platform.emulators: print emulator.name print emulator.emuCmd print emulator.emuParams for detection in emulator.detectionMethods: print detection.name
descFile = "E:\\XBMC\\RCB\\develop\\scraper\\offline\\mame\\astrowar.xml" parseInstruction = "E:\\XBMC\\RCB\\develop\\scraper\\offline\\mame\\parserconfig.xml" descParser = DescriptionParserFactory.getParser(parseInstruction) results = descParser.parseDescription(str(descFile), 'iso-8859-15') for result in results: print result print len(results) ''' from emulatorautoconfig.autoconfig import EmulatorAutoconfig config = EmulatorAutoconfig( 'C:\\Users\\lom\\AppData\\Roaming\\XBMC\\addons\\script.games.rom.collection.browser.dev\\resources\\emu_autoconfig.xml' ) ''' config.readXml() for op in config.operatingSystems: print op.name for platform in op.platforms: print platform.name for alias in platform.aliases: print alias for emulator in platform.emulators: print emulator.name print emulator.emuCmd print emulator.emuParams for detection in emulator.detectionMethods: print detection.name
def onClick(self, controlID): Logutil.log('onClick', util.LOG_LEVEL_INFO) if (controlID == CONTROL_BUTTON_EXIT): # Close window button Logutil.log('close', util.LOG_LEVEL_INFO) self.close() #OK elif (controlID == CONTROL_BUTTON_SAVE): Logutil.log('save', util.LOG_LEVEL_INFO) #store selectedRomCollection if (self.selectedRomCollection != None): self.updateSelectedRomCollection() self.romCollections[ self.selectedRomCollection.id] = self.selectedRomCollection configWriter = ConfigXmlWriter(False) success, message = configWriter.writeRomCollections( self.romCollections, True) if not success: xbmcgui.Dialog().ok(util.localize(32021), message) self.close() #Cancel elif (controlID == CONTROL_BUTTON_CANCEL): self.close() #Rom Collection list elif (self.selectedControlId in (CONTROL_BUTTON_RC_DOWN, CONTROL_BUTTON_RC_UP)): if (self.selectedRomCollection != None): #save current values to selected Rom Collection self.updateSelectedRomCollection() #store previous selectedRomCollections state self.romCollections[ self.selectedRomCollection.id] = self.selectedRomCollection #HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateRomCollectionControls() #Media Path elif (self.selectedControlId in (CONTROL_BUTTON_MEDIA_DOWN, CONTROL_BUTTON_MEDIA_UP)): #HACK: add a little wait time as XBMC needs some ms to execute the MoveUp/MoveDown actions from the skin xbmc.sleep(util.WAITTIME_UPDATECONTROLS) self.updateMediaPathControls() elif (controlID == CONTROL_BUTTON_GAMECLIENT): success, gameclient = helper.selectlibretrocore( self.selectedRomCollection.name) if success: self.selectedRomCollection.gameclient = gameclient control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if (gameclient == ""): control.setLabel("None") else: control.setLabel(gameclient) elif (controlID == CONTROL_BUTTON_EMUCMD): #maybe there is autoconfig support preconfiguredEmulator = None emulatorPath = '' dialog = xbmcgui.Dialog() if (self.selectedRomCollection.name == 'Linux' or self.selectedRomCollection.name == 'Macintosh' or self.selectedRomCollection.name == 'Windows'): emulatorPath = self.editTextProperty(CONTROL_BUTTON_EMUCMD, util.localize(32624)) else: if (xbmc.getCondVisibility('System.Platform.Android')): autoconfig = EmulatorAutoconfig( util.getEmuAutoConfigPath()) Logutil.log( 'Running on Android. Trying to find emulator per autoconfig.', util.LOG_LEVEL_INFO) emulators = autoconfig.findEmulators( 'Android', self.selectedRomCollection.name, True) emulist = [] if (emulators): for emulator in emulators: if (emulator.isInstalled): emulist.append( util.localize(32202) % emulator.name) else: emulist.append(emulator.name) if (len(emulist) > 0): emuIndex = dialog.select(util.localize(32203), emulist) Logutil.log('emuIndex: ' + str(emuIndex), util.LOG_LEVEL_INFO) if (emuIndex == -1): Logutil.log('No Emulator selected.', util.LOG_LEVEL_INFO) else: preconfiguredEmulator = emulators[emuIndex] if (preconfiguredEmulator): emulatorPath = preconfiguredEmulator.emuCmd self.selectedRomCollection.emulatorParams = preconfiguredEmulator.emuParams control = self.getControlById(CONTROL_BUTTON_PARAMS) control.setLabel(self.selectedRomCollection.emulatorParams) else: emulatorPath = dialog.browse( 1, '%s ' % self.selectedRomCollection.name + util.localize(32139), 'files') if (emulatorPath == ''): return self.selectedRomCollection.emulatorCmd = emulatorPath control = self.getControlById(CONTROL_BUTTON_EMUCMD) control.setLabel(emulatorPath) elif (controlID == CONTROL_BUTTON_PARAMS): emulatorParams = self.editTextProperty(CONTROL_BUTTON_PARAMS, util.localize(32625)) self.selectedRomCollection.emulatorParams = emulatorParams elif (controlID == CONTROL_BUTTON_ROMPATH): self.editRomPath() elif (controlID == CONTROL_BUTTON_FILEMASK): self.editRomFileMask() elif (controlID == CONTROL_BUTTON_MEDIAPATH): self.editMediaPath() elif (controlID == CONTROL_BUTTON_MEDIAFILEMASK): self.editMediaFileMask() elif (controlID == CONTROL_BUTTON_ADDMEDIAPATH): self.addMediaPath() elif (controlID == CONTROL_BUTTON_REMOVEMEDIAPATH): self.removeMediaPath() elif (controlID == CONTROL_BUTTON_MAXFOLDERDEPTH): maxFolderDepth = self.editTextProperty( CONTROL_BUTTON_MAXFOLDERDEPTH, util.localize(32610)) self.selectedRomCollection.maxFolderDepth = maxFolderDepth elif (controlID == CONTROL_BUTTON_DISKINDICATOR): diskIndicator = self.editTextProperty(CONTROL_BUTTON_DISKINDICATOR, util.localize(32611)) self.selectedRomCollection.diskPrefix = diskIndicator elif (controlID == CONTROL_BUTTON_SAVESTATEPATH): saveStatePathComplete = self.editPathWithFileMask( CONTROL_BUTTON_SAVESTATEPATH, '%s ' % self.selectedRomCollection.name + util.localize(32629), CONTROL_BUTTON_SAVESTATEMASK) if (saveStatePathComplete != ''): self.selectedRomCollection.saveStatePath = saveStatePathComplete elif (controlID == CONTROL_BUTTON_SAVESTATEMASK): self.selectedRomCollection.saveStatePath = self.editFilemask( CONTROL_BUTTON_SAVESTATEMASK, util.localize(32630), self.selectedRomCollection.saveStatePath) elif (controlID == CONTROL_BUTTON_SAVESTATEPARAMS): saveStateParams = self.editTextProperty( CONTROL_BUTTON_SAVESTATEPARAMS, util.localize(32631)) self.selectedRomCollection.saveStateParams = saveStateParams elif (controlID == CONTROL_BUTTON_PRECMD): preCmd = self.editTextProperty(CONTROL_BUTTON_PRECMD, util.localize(32632)) self.selectedRomCollection.preCmd = preCmd Logutil.log( 'OnClick: precmd = ' + self.selectedRomCollection.preCmd, util.LOG_LEVEL_INFO) elif (controlID == CONTROL_BUTTON_POSTCMD): postCmd = self.editTextProperty(CONTROL_BUTTON_POSTCMD, util.localize(32633)) self.selectedRomCollection.postCmd = postCmd
def addRomCollections(self, rcId, configObj, consoleList, isUpdate): romCollections = {} dialog = xbmcgui.Dialog() # Scraping scenario - game descriptions and artwork retrieved from online or available locally scenarioIndex = dialog.select( util.localize(32173), [util.localize(32174), util.localize(32175), util.localize(32207)]) log.info("scenarioIndex: " + str(scenarioIndex)) if scenarioIndex == -1: del dialog log.info("No scenario selected. Action canceled.") return False, romCollections autoconfig = EmulatorAutoconfig(util.getEmuAutoConfigPath()) while True: fileTypeList, errorMsg = self.buildMediaTypeList( configObj, isUpdate) romCollection = RomCollection() if (errorMsg): log.warn("Error building Media Type List: {0}" % errorMsg) break # Console platformIndex = dialog.select(util.localize(32176), consoleList) log.info("platformIndex: " + str(platformIndex)) if platformIndex == -1: log.info("No Platform selected. Action canceled.") break console = consoleList[platformIndex] if console == 'Other': console = self.promptOtherConsoleName() if console == '': break else: consoleList.remove(console) log.info("Selected platform: " + console) romCollection.name = console romCollection.id = rcId rcId = rcId + 1 # Check if we have general RetroPlayer support if helper.isRetroPlayerSupported(): #32198 = Use RetroPlayer to launch games? romCollection.useBuiltinEmulator = bool( dialog.yesno(util.SCRIPTNAME, util.localize(32198))) # Only ask for emulator and params if we don't use builtin emulator if not romCollection.useBuiltinEmulator: # Maybe there is autoconfig support preconfiguredEmulator = None # Emulator if romCollection.name in ['Linux', 'Macintosh', 'Windows']: # Check for standalone games romCollection.emulatorCmd = '"%ROM%"' log.info("emuCmd set to '%ROM%' for standalone games.") else: emulist = [] log.info( u'Running on {0}. Trying to find emulator per autoconfig.' .format(util.current_os)) emulators = autoconfig.findEmulators( util.current_os, romCollection.name, True) for emulator in emulators: if emulator.isInstalled: emulist.append( util.localize(32202) % emulator.name) else: emulist.append(emulator.name) # Ask the user which one they want if len(emulist) > 0: try: emuIndex = dialog.select(util.localize(32203), emulist) if emuIndex >= 0: preconfiguredEmulator = emulators[emuIndex] except IndexError: log.info("No Emulator selected.") preconfiguredEmulator = None if preconfiguredEmulator: romCollection.emulatorCmd = preconfiguredEmulator.emuCmd else: consolePath = dialog.browse( 1, util.localize(32178) % console, 'files') Logutil.log('consolePath: ' + str(consolePath), util.LOG_LEVEL_INFO) if consolePath == '': log.info( "No consolePath selected. Action canceled.") break romCollection.emulatorCmd = consolePath # Set emulator parameters if romCollection.name in ['Linux', 'Macintosh', 'Windows']: romCollection.emulatorParams = '' log.info("emuParams set to " " for standalone games.") else: if preconfiguredEmulator: defaultParams = preconfiguredEmulator.emuParams else: defaultParams = '"%ROM%"' romCollection.emulatorParams = self.promptEmulatorParams( defaultParams) # Prompt for rompath romPath = self.promptRomPath(console) if romPath == '': log.info("No romPath selected. Action canceled.") break # Filemask fileMasks = self.promptEmulatorFileMasks() if fileMasks == []: break romCollection.romPaths = [] for fileMask in fileMasks: romCollection.romPaths.append( util.joinPath(romPath, fileMask.strip())) # Specific MAME settings if romCollection.name == 'MAME': romCollection.imagePlacingMain = ImagePlacing() romCollection.imagePlacingMain.name = 'gameinfomamecabinet' # MAME zip files contain several files but they must be passed to the emu as zip file romCollection.doNotExtractZipFiles = True if scenarioIndex == RETRIEVE_INFO_ONLINE_ARTWORK_ONLINE: # Prompt for artwork path artworkPath = self.promptArtworkPath(console, romPath) if artworkPath == '': log.info("No artworkPath selected. Action canceled.") break romCollection.descFilePerGame = True # Media Paths romCollection.mediaPaths = [] if romCollection.name == 'MAME': mediaTypes = [ 'boxfront', 'action', 'title', 'cabinet', 'marquee', 'clearlogo', 'gameplay' ] else: mediaTypes = [ 'boxfront', 'boxback', 'cartridge', 'screenshot', 'fanart', 'clearlogo', 'gameplay' ] for t in mediaTypes: romCollection.mediaPaths.append( self.createMediaPath(t, artworkPath, scenarioIndex)) else: romCollection.mediaPaths = [] # Default to looking in the romPath for the first artwork path lastArtworkPath = romPath while True: # Prompt the user for which artwork type we are selecting fileTypeIndex = dialog.select(util.localize(32183), fileTypeList) if fileTypeIndex == -1: log.info("No fileTypeIndex selected.") break fileType = fileTypeList[fileTypeIndex] fileTypeList.remove(fileType) # Prompt user for path for existing artwork artworkPath = util.convertToUnicodeString( dialog.browse( 0, util.localize(32182) % (console, fileType), 'files', '', False, False, lastArtworkPath)) log.debug(u"artworkPath selected: {0}".format(artworkPath)) if artworkPath == '': log.info("No artworkPath selected.") break lastArtworkPath = artworkPath romCollection.mediaPaths.append( self.createMediaPath(fileType, artworkPath, scenarioIndex)) # Ask to add another artwork path #32184 = Do you want to add another Artwork Path? if not dialog.yesno(util.SCRIPTNAME, util.localize(32184)): break #not used atm as we don't have any offline scrapers with descfile per game """ # Ask user for source of game descriptions (description file per game or for all games) descIndex = dialog.select(util.localize(32185), [util.localize(32186), util.localize(32187)]) log.debug("descIndex: " + str(descIndex)) if descIndex == -1: log.info("No descIndex selected. Action canceled.") break romCollection.descFilePerGame = (descIndex != GAME_DESCRIPTION_SINGLE_FILE) """ if scenarioIndex == RETRIEVE_INFO_LOCAL_ARTWORK_LOCAL: offline_scrapers = AbstractScraper( ).get_available_offline_scrapers(console) scraperIndex = dialog.select(util.localize(32206), offline_scrapers) if scraperIndex == -1: log.info("No Scraper type selected. Action canceled.") break selectedscraper = offline_scrapers[scraperIndex] log.info("Selected scraper = {0}".format(selectedscraper)) #not used atm as we don't have any offline scrapers with descfile per game """ if romCollection.descFilePerGame: # Assume the files are in a single directory with the mask %GAME%.txt # Prompt the user for the path pathValue = dialog.browse(0, util.localize(32189) % console, 'files') if pathValue == '': break # Prompt the user for the description file mask filemask = xbmcgui.Dialog().input(util.localize(32190), defaultt='%GAME%.xml', type=xbmcgui.INPUT_ALPHANUM) descPath = util.joinPath(pathValue, filemask.strip()) else: """ descPath = dialog.browse(1, util.localize(32189) % console, 'files', '', False, False, lastArtworkPath) log.info("descPath: " + str(descPath)) if descPath == '': log.info("No descPath selected. Action canceled.") break # Create scraper site = Site(name=selectedscraper, path=descPath, default=True) romCollection.scraperSites = [site] log.debug("Created new rom collection: {0}".format(romCollection)) romCollections[romCollection.id] = romCollection # Ask the user if they want to add another rom collection #32192 = Do you want to add another Rom Collection? if not dialog.yesno(util.SCRIPTNAME, util.localize(32192)): break del dialog return True, romCollections