def set_gameclient(self): log.info("set_gameclient") if not helper.isRetroPlayerSupported(): log.info( "This RetroPlayer branch does not support selecting gameclients." ) return if self.selectedGame is None or self.gameRow is None: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return #HACK: use alternateGameCmd to store gameclient information origGameClient = self.selectedGame.getProperty('alternateGameCmd') gameclient = '' romCollectionId = self.selectedGame.getProperty('romCollectionId') romCollection = self.gui.config.romCollections[str(romCollectionId)] success, selectedcore = helper.selectlibretrocore(romCollection.name) if success: gameclient = selectedcore else: log.info("No libretro core was chosen. Won't update game command.") return if gameclient != origGameClient: log.info("Updating game '{0}' with gameclient '{1}'".format( self.selectedGame.getLabel(), gameclient)) Game(self.gui.gdb).update(('alternateGameCmd', ), (gameclient, ), self.selectedGame.getProperty('gameId'), True) self.gui.gdb.commit()
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() elif controlID == CONTROL_BUTTON_ADD_RC: statusOk, errorMsg = wizardconfigxml.ConfigXmlWizard().addRomCollection(self.gui.config) if statusOk is False: #32001 = Error while updating config.xml. message = "%s[CR]%s" % (util.localize(32001), errorMsg) xbmcgui.Dialog().ok(util.SCRIPTNAME, message) log.info("Error updating config.xml: {0}".format(errorMsg)) return #update self.config self.gui.config = Config(None) statusOk, errorMsg = self.gui.config.readXml() if statusOk is False: #32002 = Error reading config.xml. message = "%s[CR]%s" % (util.localize(32002), errorMsg) xbmcgui.Dialog().ok(util.SCRIPTNAME, message) log.info("Error reading config.xml: {0}".format(errorMsg)) return self.addItemsToList(CONTROL_LIST_ROMCOLLECTIONS, self.gui.config.getRomCollectionNames()) self.updateRomCollectionControls() elif controlID == CONTROL_BUTTON_REMOVE_RC: constructorParam = "720p" try: removeRCDialog = dialogdeleteromcollection.RemoveRCDialog("script-RCB-removeRC.xml", util.getAddonInstallPath(), util.getConfiguredSkin(), constructorParam, gui=self.gui) except: 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 self.gui.config = Config(None) statusOk, errorMsg = self.gui.config.readXml() if statusOk is False: #32002 = Error reading config.xml. message = "%s[CR]%s" %(util.localize(32002), errorMsg) xbmcgui.Dialog().ok(util.SCRIPTNAME, message) log.info("Error reading config.xml: {0}".format(errorMsg)) return self.addItemsToList(CONTROL_LIST_ROMCOLLECTIONS, self.gui.config.getRomCollectionNames()) self.updateRomCollectionControls() # 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_LIST_OFFLINE_SCRAPER: self.editOfflineScraper() 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: self.editEmuCmd() 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): 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 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
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 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_LIST_OFFLINE_SCRAPER: self.editOfflineScraper() 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: self.editEmuCmd() 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): 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 is None: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32013), util.localize(32014)) return romCollectionId = self.selectedGame.getProperty('romCollectionId') romCollection = self.gui.config.romCollections[str(romCollectionId)] files = File(self.gui.gdb).getRomsByGameId(self.selectedGame.getProperty('gameId')) 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): listItem = self.gui.getListItem(i) romCollectionId = listItem.getProperty('romCollectionId') try: romCollection = romCollections[str(romCollectionId)] except: romCollection = self.gui.config.romCollections[str(romCollectionId)] romCollection.romPaths = [] files = File(self.gui.gdb).getRomsByGameId(listItem.getProperty('gameId')) try: filename = files[0][0] romCollection.romPaths.append(filename) romCollections[romCollection.id] = romCollection except: log.info("Error getting filename for romCollectionId: {0}".format(romCollectionId)) 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 is False: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32001), errorMsg) log.info("Error updating config.xml: {0}".format(errorMsg)) return #update self.config statusOk, errorMsg = self.gui.config.readXml() if statusOk is False: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32002), errorMsg) log.info("Error reading config.xml: {0}".format(errorMsg)) 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(), util.getConfiguredSkin(), constructorParam, gui=self.gui) del editRCdialog self.gui.config = Config(None) self.gui.config.readXml() elif controlID == 5113: # Edit Game Command self.close() if(self.selectedGame == None): xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return origCommand = self.selectedGame.getProperty('gameCmd') command = xbmcgui.Dialog().input(util.localize(32135), defaultt=origCommand, type=xbmcgui.INPUT_ALPHANUM) if command != origCommand: log.info("Updating game '{0}' with command '{1}'".format(self.selectedGame.getLabel(), command)) Game(self.gui.gdb).update(('gameCmd',), (command,), self.selectedGame.getProperty('gameId'), True) self.gui.gdb.commit() elif controlID == 5118: # (Un)Mark as Favorite self.close() if self.selectedGame is None: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = '1' if self.selectedGame.getProperty('isfavorite') == '1': isFavorite = '0' log.info("Updating game '{0}' set isFavorite = {1}".format(self.selectedGame.getLabel(), isFavorite)) Game(self.gui.gdb).update(('isfavorite',), (isFavorite,), self.selectedGame.getProperty('gameId'), 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 is None: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32016), util.localize(32014)) return isFavorite = '1' if self.selectedGame.getProperty('isfavorite') == '1': isFavorite = '0' listSize = self.gui.getListSize() for i in range(0, listSize): listItem = self.gui.getListItem(i) log.info("Updating game '{0}' set isfavorite = {1}".format(listItem.getLabel(), isFavorite)) Game(self.gui.gdb).update(('isfavorite',), (isFavorite,), listItem.getProperty('gameId'), True) listItem.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.gdb, self.gui.config.romCollections) 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.selectedGame.getProperty('gameId') 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(), util.getConfiguredSkin(), 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.isRetroPlayerSupported(): log.info("This RetroPlayer branch does not support selecting gameclients.") return if self.selectedGame is None or self.gameRow is None: xbmcgui.Dialog().ok(util.SCRIPTNAME, util.localize(32015), util.localize(32014)) return #HACK: use alternateGameCmd to store gameclient information origGameClient = self.selectedGame.getProperty('alternateGameCmd') gameclient = '' romCollectionId = self.selectedGame.getProperty('romCollectionId') romCollection = self.gui.config.romCollections[str(romCollectionId)] success, selectedcore = helper.selectlibretrocore(romCollection.name) if success: gameclient = selectedcore else: log.info("No libretro core was chosen. Won't update game command.") return if gameclient != origGameClient: log.info("Updating game '{0}' with gameclient '{1}'".format(self.selectedGame.getLabel(), gameclient)) Game(self.gui.gdb).update(('alternateGameCmd',), (gameclient,), self.selectedGame.getProperty('gameId'), True) self.gui.gdb.commit()
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()