def onInit(self): Logutil.log('onInit ContextMenu', util.LOG_LEVEL_INFO) pos = self.gui.getCurrentListPosition() if (pos != -1): self.selectedGame, self.gameRow = self.gui.getGameByPosition( self.gui.gdb, pos) #set mark favorite text if (self.gameRow != None): if (self.gameRow[util.GAME_isFavorite] == 1): buttonMarkFavorite = self.getControlById( CONTROL_BUTTON_SETFAVORITE_GAME) if (buttonMarkFavorite != None): buttonMarkFavorite.setLabel(util.localize(32133)) buttonMarkFavorite = self.getControlById( CONTROL_BUTTON_SETFAVORITE_SELECTION) if (buttonMarkFavorite != None): buttonMarkFavorite.setLabel(util.localize(32134)) #Hide Set Gameclient option if (not helper.retroPlayerSupportsPythonIntegration()): control = self.getControlById(5224) control.setVisible(False) control.setEnabled(False)
def onInit(self): Logutil.log('onInit Edit Rom Collection', util.LOG_LEVEL_INFO) #Rom Collections Logutil.log('build rom collection list', util.LOG_LEVEL_INFO) romCollectionList = [] for rcId in self.romCollections.keys(): romCollection = self.romCollections[rcId] romCollectionList.append(romCollection.name) self.addItemsToList(CONTROL_LIST_ROMCOLLECTIONS, romCollectionList) Logutil.log('build scraper lists', util.LOG_LEVEL_INFO) self.availableScrapers = self.getAvailableScrapers(False) self.addItemsToList(CONTROL_LIST_SCRAPER1, self.availableScrapers) self.addItemsToList(CONTROL_LIST_SCRAPER2, self.availableScrapers) self.addItemsToList(CONTROL_LIST_SCRAPER3, self.availableScrapers) Logutil.log('build imagePlacing list', util.LOG_LEVEL_INFO) self.imagePlacingList = [] imagePlacingRows = self.gui.config.tree.findall( 'ImagePlacing/fileTypeFor') for imagePlacing in imagePlacingRows: Logutil.log( 'add image placing: ' + str(imagePlacing.attrib.get('name')), util.LOG_LEVEL_INFO) option = imagePlacing.attrib.get('name') #HACK: remove all video options from config if (option.upper().find('VIDEO') >= 0): continue try: option = config.imagePlacingDict[option] except: pass self.imagePlacingList.append(option) self.addItemsToList(CONTROL_LIST_IMAGEPLACING_MAIN, self.imagePlacingList) self.addItemsToList(CONTROL_LIST_IMAGEPLACING_INFO, self.imagePlacingList) if (not helper.isRetroPlayerSupported()): control = self.getControlById(CONTROL_BUTTON_USERETROPLAYER) if (control): control.setEnabled(False) control.setVisible(False) control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if (control): control.setEnabled(False) control.setVisible(False) elif (not helper.retroPlayerSupportsPythonIntegration()): control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if (control): control.setEnabled(False) control.setVisible(False) self.updateRomCollectionControls()
def onInit(self): Logutil.log('onInit Edit Rom Collection', util.LOG_LEVEL_INFO) #Rom Collections Logutil.log('build rom collection list', util.LOG_LEVEL_INFO) romCollectionList = [] for rcId in self.romCollections.keys(): romCollection = self.romCollections[rcId] romCollectionList.append(romCollection.name) self.addItemsToList(CONTROL_LIST_ROMCOLLECTIONS, romCollectionList) Logutil.log('build scraper lists', util.LOG_LEVEL_INFO) self.availableScrapers = self.getAvailableScrapers(False) self.addItemsToList(CONTROL_LIST_SCRAPER1, self.availableScrapers) self.addItemsToList(CONTROL_LIST_SCRAPER2, self.availableScrapers) self.addItemsToList(CONTROL_LIST_SCRAPER3, self.availableScrapers) Logutil.log('build imagePlacing list', util.LOG_LEVEL_INFO) self.imagePlacingList = [] imagePlacingRows = self.gui.config.tree.findall('ImagePlacing/fileTypeFor') for imagePlacing in imagePlacingRows: Logutil.log('add image placing: ' +str(imagePlacing.attrib.get('name')), util.LOG_LEVEL_INFO) option = imagePlacing.attrib.get('name') #HACK: remove all video options from config if(option.upper().find('VIDEO') >= 0): continue try: option = config.imagePlacingDict[option] except: pass self.imagePlacingList.append(option) self.addItemsToList(CONTROL_LIST_IMAGEPLACING_MAIN, self.imagePlacingList) self.addItemsToList(CONTROL_LIST_IMAGEPLACING_INFO, self.imagePlacingList) if(not helper.isRetroPlayerSupported()): control = self.getControlById(CONTROL_BUTTON_USERETROPLAYER) if(control): control.setEnabled(False) control.setVisible(False) control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if(control): control.setEnabled(False) control.setVisible(False) elif(not helper.retroPlayerSupportsPythonIntegration()): control = self.getControlById(CONTROL_BUTTON_GAMECLIENT) if(control): control.setEnabled(False) control.setVisible(False) self.updateRomCollectionControls()
def onInit(self): Logutil.log('onInit ContextMenu', util.LOG_LEVEL_INFO) pos = self.gui.getCurrentListPosition() if(pos != -1): self.selectedGame, self.gameRow = self.gui.getGameByPosition(self.gui.gdb, pos) #set mark favorite text if(self.gameRow != None): if(self.gameRow[util.GAME_isFavorite] == 1): buttonMarkFavorite = self.getControlById(CONTROL_BUTTON_SETFAVORITE_GAME) if(buttonMarkFavorite != None): buttonMarkFavorite.setLabel(util.localize(32133)) buttonMarkFavorite = self.getControlById(CONTROL_BUTTON_SETFAVORITE_SELECTION) if(buttonMarkFavorite != None): buttonMarkFavorite.setLabel(util.localize(32134)) #Hide Set Gameclient option if(not helper.retroPlayerSupportsPythonIntegration()): control = self.getControlById(5224) control.setVisible(False) control.setEnabled(False)
def onClick(self, controlID): if (controlID == 5101): # Close window button self.close() elif (controlID == 5110): # Import games self.close() self.gui.updateDB() elif (controlID == 5121): # Rescrape single games self.close() if(self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32013), util.localize(32014)) return romCollectionId = self.gameRow[util.GAME_romCollectionId] romCollection = self.gui.config.romCollections[str(romCollectionId)] files = File(self.gui.gdb).getRomsByGameId(self.gameRow[util.ROW_ID]) filename = files[0][0] romCollection.romPaths = (filename,) romCollections = {} romCollections[romCollection.id] = romCollection self.gui.rescrapeGames(romCollections) elif (controlID == 5122): # Rescrape selection self.close() romCollections = {} listSize = self.gui.getListSize() for i in range(0, listSize): selectedGame, gameRow = self.gui.getGameByPosition(self.gui.gdb, i) romCollectionId = gameRow[util.GAME_romCollectionId] try: romCollection = romCollections[str(romCollectionId)] except: romCollection = self.gui.config.romCollections[str(romCollectionId)] romCollection.romPaths = [] files = File(self.gui.gdb).getRomsByGameId(gameRow[util.ROW_ID]) filename = files[0][0] romCollection.romPaths.append(filename) romCollections[romCollection.id] = romCollection self.gui.rescrapeGames(romCollections) #self.gui.updateDB() elif (controlID == 5111): # add Rom Collection self.close() statusOk, errorMsg = wizardconfigxml.ConfigXmlWizard().addRomCollection(self.gui.config) if(statusOk == False): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32001), errorMsg) Logutil.log('Error updating config.xml: ' +errorMsg, util.LOG_LEVEL_INFO) return #update self.config statusOk, errorMsg = self.gui.config.readXml() if(statusOk == False): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32002), errorMsg) Logutil.log('Error reading config.xml: ' +errorMsg, util.LOG_LEVEL_INFO) return #import Games self.gui.updateDB() elif (controlID == 5112): # edit Rom Collection self.close() constructorParam = "720p" editRCdialog = dialogeditromcollection.EditRomCollectionDialog("script-RCB-editromcollection.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) del editRCdialog self.gui.config = Config(None) self.gui.config.readXml() elif (controlID == 5117): # edit scraper self.close() constructorParam = "720p" editscraperdialog = dialogeditscraper.EditOfflineScraper("script-RCB-editscraper.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) del editscraperdialog self.gui.config = Config(None) self.gui.config.readXml() elif (controlID == 5113): #Edit Game Command self.close() if(self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return origCommand = self.gameRow[util.GAME_gameCmd] command = '' keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32135)) if(origCommand != None): keyboard.setDefault(origCommand) keyboard.doModal() if (keyboard.isConfirmed()): command = keyboard.getText() if(command != origCommand): Logutil.log("Updating game '%s' with command '%s'" %(str(self.gameRow[util.ROW_NAME]), command), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('gameCmd',), (command,), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit() elif (controlID == 5118): #(Un)Mark as Favorite self.close() if(self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = 1 if(self.gameRow[util.GAME_isFavorite] == 1): isFavorite = 0 Logutil.log("Updating game '%s' set isFavorite = %s" %(str(self.gameRow[util.ROW_NAME]), str(isFavorite)), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('isFavorite',), (isFavorite,), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit() if(isFavorite == 0): isFavorite = '' self.selectedGame.setProperty('isfavorite', str(isFavorite)) elif (controlID == 5119): #(Un)Mark as Favorite self.close() if(self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = 1 if(self.gameRow[util.GAME_isFavorite] == 1): isFavorite = 0 listSize = self.gui.getListSize() for i in range(0, listSize): selectedGame, gameRow = self.gui.getGameByPosition(self.gui.gdb, i) Logutil.log("Updating game '%s' set isFavorite = %s" %(str(gameRow[util.ROW_NAME]), str(isFavorite)), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('isFavorite',), (isFavorite,), gameRow[util.ROW_ID], True) selectedGame.setProperty('isfavorite', str(isFavorite)) self.gui.gdb.commit() #HACK: removing favorites does not update the UI. So do it manually. if(isFavorite == 0): self.gui.loadViewState() elif (controlID == 5120): #Export nfo files self.close() nfowriter.NfoWriter().exportLibrary(self.gui) elif (controlID == 5114): #Delete Rom self.close() pos = self.gui.getCurrentListPosition() if(pos == -1): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32017), util.localize(32018)) return dialog = xbmcgui.Dialog() if dialog.yesno(util.localize(32510), util.localize(32136)): gameID = self.gui.getGameId(self.gui.gdb,pos) self.gui.deleteGame(gameID) self.gui.showGames() if(pos > 0): pos = pos - 1 self.gui.setFilterSelection(self.gui.CONTROL_GAMES_GROUP_START, pos) else: self.gui.setFilterSelection(self.gui.CONTROL_GAMES_GROUP_START, 0) elif (controlID == 5115): #Remove Rom Collection self.close() constructorParam = "720p" removeRCDialog = dialogdeleteromcollection.RemoveRCDialog("script-RCB-removeRC.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) rDelStat = removeRCDialog.getDeleteStatus() if(rDelStat): selectedRCId = removeRCDialog.getSelectedRCId() rcDelStat = removeRCDialog.getRCDeleteStatus() self.gui.deleteRCGames(selectedRCId, rcDelStat, rDelStat) del removeRCDialog elif (controlID == 5116): #Clean DB self.close() self.gui.cleanDB() elif (controlID == 5223): #Open Settings self.close() self.gui.Settings.openSettings() elif (controlID == 5224): #Set gameclient self.close() if(not helper.retroPlayerSupportsPythonIntegration()): Logutil.log("This RetroPlayer branch does not support selecting gameclients.", util.LOG_LEVEL_INFO) return if(self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return #HACK: use alternateGameCmd to store gameclient information origGameClient = self.gameRow[util.GAME_alternateGameCmd] gameclient = '' romCollectionId = self.gameRow[util.GAME_romCollectionId] romCollection = self.gui.config.romCollections[str(romCollectionId)] success, selectedcore = helper.selectlibretrocore(romCollection.name) if success: gameclient = selectedcore else: Logutil.log("No libretro core was chosen. Won't update game command.", util.LOG_LEVEL_INFO) return if(gameclient != origGameClient): Logutil.log("Updating game '%s' with gameclient '%s'" %(str(self.gameRow[util.ROW_NAME]), gameclient), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('alternateGameCmd',), (gameclient,), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit()
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): if (controlID == 5101): # Close window button self.close() elif (controlID == 5110): # Import games self.close() self.gui.updateDB() elif (controlID == 5121): # Rescrape single games self.close() if (self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32013), util.localize(32014)) return romCollectionId = self.gameRow[util.GAME_romCollectionId] romCollection = self.gui.config.romCollections[str( romCollectionId)] files = File(self.gui.gdb).getRomsByGameId( self.gameRow[util.ROW_ID]) filename = files[0][0] romCollection.romPaths = (filename, ) romCollections = {} romCollections[romCollection.id] = romCollection self.gui.rescrapeGames(romCollections) elif (controlID == 5122): # Rescrape selection self.close() romCollections = {} listSize = self.gui.getListSize() for i in range(0, listSize): selectedGame, gameRow = self.gui.getGameByPosition( self.gui.gdb, i) romCollectionId = gameRow[util.GAME_romCollectionId] try: romCollection = romCollections[str(romCollectionId)] except: romCollection = self.gui.config.romCollections[str( romCollectionId)] romCollection.romPaths = [] files = File(self.gui.gdb).getRomsByGameId( gameRow[util.ROW_ID]) filename = files[0][0] romCollection.romPaths.append(filename) romCollections[romCollection.id] = romCollection self.gui.rescrapeGames(romCollections) #self.gui.updateDB() elif (controlID == 5111): # add Rom Collection self.close() statusOk, errorMsg = wizardconfigxml.ConfigXmlWizard( ).addRomCollection(self.gui.config) if (statusOk == False): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32001), errorMsg) Logutil.log('Error updating config.xml: ' + errorMsg, util.LOG_LEVEL_INFO) return #update self.config statusOk, errorMsg = self.gui.config.readXml() if (statusOk == False): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32002), errorMsg) Logutil.log('Error reading config.xml: ' + errorMsg, util.LOG_LEVEL_INFO) return #import Games self.gui.updateDB() elif (controlID == 5112): # edit Rom Collection self.close() constructorParam = "720p" editRCdialog = dialogeditromcollection.EditRomCollectionDialog( "script-RCB-editromcollection.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) del editRCdialog self.gui.config = Config(None) self.gui.config.readXml() elif (controlID == 5117): # edit scraper self.close() constructorParam = "720p" editscraperdialog = dialogeditscraper.EditOfflineScraper( "script-RCB-editscraper.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) del editscraperdialog self.gui.config = Config(None) self.gui.config.readXml() elif (controlID == 5113): #Edit Game Command self.close() if (self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return origCommand = self.gameRow[util.GAME_gameCmd] command = '' keyboard = xbmc.Keyboard() keyboard.setHeading(util.localize(32135)) if (origCommand != None): keyboard.setDefault(origCommand) keyboard.doModal() if (keyboard.isConfirmed()): command = keyboard.getText() if (command != origCommand): Logutil.log( "Updating game '%s' with command '%s'" % (str(self.gameRow[util.ROW_NAME]), command), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('gameCmd', ), (command, ), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit() elif (controlID == 5118): #(Un)Mark as Favorite self.close() if (self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = 1 if (self.gameRow[util.GAME_isFavorite] == 1): isFavorite = 0 Logutil.log( "Updating game '%s' set isFavorite = %s" % (str(self.gameRow[util.ROW_NAME]), str(isFavorite)), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('isFavorite', ), (isFavorite, ), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit() if (isFavorite == 0): isFavorite = '' self.selectedGame.setProperty('isfavorite', str(isFavorite)) elif (controlID == 5119): #(Un)Mark as Favorite self.close() if (self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = 1 if (self.gameRow[util.GAME_isFavorite] == 1): isFavorite = 0 listSize = self.gui.getListSize() for i in range(0, listSize): selectedGame, gameRow = self.gui.getGameByPosition( self.gui.gdb, i) Logutil.log( "Updating game '%s' set isFavorite = %s" % (str(gameRow[util.ROW_NAME]), str(isFavorite)), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('isFavorite', ), (isFavorite, ), gameRow[util.ROW_ID], True) selectedGame.setProperty('isfavorite', str(isFavorite)) self.gui.gdb.commit() #HACK: removing favorites does not update the UI. So do it manually. if (isFavorite == 0): self.gui.loadViewState() elif (controlID == 5120): #Export nfo files self.close() nfowriter.NfoWriter().exportLibrary(self.gui) elif (controlID == 5114): #Delete Rom self.close() pos = self.gui.getCurrentListPosition() if (pos == -1): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32017), util.localize(32018)) return dialog = xbmcgui.Dialog() if dialog.yesno(util.localize(32510), util.localize(32136)): gameID = self.gui.getGameId(self.gui.gdb, pos) self.gui.deleteGame(gameID) self.gui.showGames() if (pos > 0): pos = pos - 1 self.gui.setFilterSelection( self.gui.CONTROL_GAMES_GROUP_START, pos) else: self.gui.setFilterSelection( self.gui.CONTROL_GAMES_GROUP_START, 0) elif (controlID == 5115): #Remove Rom Collection self.close() constructorParam = "720p" removeRCDialog = dialogdeleteromcollection.RemoveRCDialog( "script-RCB-removeRC.xml", util.getAddonInstallPath(), "Default", constructorParam, gui=self.gui) rDelStat = removeRCDialog.getDeleteStatus() if (rDelStat): selectedRCId = removeRCDialog.getSelectedRCId() rcDelStat = removeRCDialog.getRCDeleteStatus() self.gui.deleteRCGames(selectedRCId, rcDelStat, rDelStat) del removeRCDialog elif (controlID == 5116): #Clean DB self.close() self.gui.cleanDB() elif (controlID == 5223): #Open Settings self.close() self.gui.Settings.openSettings() elif (controlID == 5224): #Set gameclient self.close() if (not helper.retroPlayerSupportsPythonIntegration()): Logutil.log( "This RetroPlayer branch does not support selecting gameclients.", util.LOG_LEVEL_INFO) return if (self.selectedGame == None or self.gameRow == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return #HACK: use alternateGameCmd to store gameclient information origGameClient = self.gameRow[util.GAME_alternateGameCmd] gameclient = '' romCollectionId = self.gameRow[util.GAME_romCollectionId] romCollection = self.gui.config.romCollections[str( romCollectionId)] success, selectedcore = helper.selectlibretrocore( romCollection.name) if success: gameclient = selectedcore else: Logutil.log( "No libretro core was chosen. Won't update game command.", util.LOG_LEVEL_INFO) return if (gameclient != origGameClient): Logutil.log( "Updating game '%s' with gameclient '%s'" % (str(self.gameRow[util.ROW_NAME]), gameclient), util.LOG_LEVEL_INFO) Game(self.gui.gdb).update(('alternateGameCmd', ), (gameclient, ), self.gameRow[util.ROW_ID], True) self.gui.gdb.commit()