Пример #1
0
    def __copyLauncherScriptsToUserdata(self):
        log.info('__copyLauncherScriptsToUserdata')

        oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources',
                                   'scriptfiles')
        newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')

        files = []
        # Copy applaunch shell script/batch file
        if self.env == 'win32':
            files.append('applaunch.bat')
        else:
            files.append('applaunch.sh')

        # Copy VBS files
        if self.env == 'win32' and __addon__.getSetting(
                util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true':
            files += ['applaunch-vbs.bat', 'LaunchKodi.vbs', 'Sleep.vbs']

        for f in files:
            if not xbmcvfs.exists(os.path.join(newBasePath, f)):
                log.debug("Copying file {0} from {1} to {2}".format(
                    f, oldBasePath, newBasePath))
                if not xbmcvfs.copy(os.path.join(oldBasePath, f),
                                    os.path.join(newBasePath, f)):
                    log.warn("Error copying file")
Пример #2
0
def copyLauncherScriptsToUserdata(settings):

    Logutil.log('copyLauncherScriptsToUserdata', util.LOG_LEVEL_INFO)

    oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources',
                               'scriptfiles')
    newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')

    if (util.getEnvironment() == 'win32'):
        oldPath = os.path.join(oldBasePath, 'applaunch.bat')
        newPath = os.path.join(newBasePath, 'applaunch.bat')
    else:
        oldPath = os.path.join(oldBasePath, 'applaunch.sh')
        newPath = os.path.join(newBasePath, 'applaunch.sh')

    util.copyFile(oldPath, newPath)

    #copy VBS files
    if (util.getEnvironment() == 'win32' and settings.getSetting(
            util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
        oldPath = os.path.join(oldBasePath, 'applaunch-vbs.bat')
        newPath = os.path.join(newBasePath, 'applaunch-vbs.bat')
        util.copyFile(oldPath, newPath)

        oldPath = os.path.join(oldBasePath, 'LaunchXBMC.vbs')
        newPath = os.path.join(newBasePath, 'LaunchXBMC.vbs')
        util.copyFile(oldPath, newPath)

        oldPath = os.path.join(oldBasePath, 'Sleep.vbs')
        newPath = os.path.join(newBasePath, 'Sleep.vbs')
        util.copyFile(oldPath, newPath)
def copyLauncherScriptsToUserdata(settings):
	
	Logutil.log('copyLauncherScriptsToUserdata', util.LOG_LEVEL_INFO)
	
	oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
	newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
	
	if(util.getEnvironment() == 'win32'):
		oldPath = os.path.join(oldBasePath, 'applaunch.bat')
		newPath = os.path.join(newBasePath, 'applaunch.bat')
	else:
		oldPath = os.path.join(oldBasePath, 'applaunch.sh')
		newPath = os.path.join(newBasePath, 'applaunch.sh')
		
	util.copyFile(oldPath, newPath)
	
	#copy VBS files
	if(util.getEnvironment() == 'win32' and settings.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
		oldPath = os.path.join(oldBasePath, 'applaunch-vbs.bat')
		newPath = os.path.join(newBasePath, 'applaunch-vbs.bat')
		util.copyFile(oldPath, newPath)
		
		oldPath = os.path.join(oldBasePath, 'LaunchXBMC.vbs')
		newPath = os.path.join(newBasePath, 'LaunchXBMC.vbs')
		util.copyFile(oldPath, newPath)
		
		oldPath = os.path.join(oldBasePath, 'Sleep.vbs')
		newPath = os.path.join(newBasePath, 'Sleep.vbs')
		util.copyFile(oldPath, newPath)
Пример #4
0
	def __init__(self, createNew):

		Logutil.log('init ConfigXmlWriter', util.LOG_LEVEL_INFO)

		self.createNew = createNew

		if(createNew):
			configFile = os.path.join(util.getAddonInstallPath(), 'resources', 'database', 'config_template.xml')
		else:
			configFile = util.getConfigXmlPath()

		if(not os.path.isfile(configFile)):
			Logutil.log('File config.xml does not exist. Place a valid config file here: ' + str(configFile), util.LOG_LEVEL_ERROR)
		else:
			self.tree = ElementTree().parse(configFile)
Пример #5
0
    def __init__(self, createNew):

        Logutil.log('init ConfigXmlWriter', util.LOG_LEVEL_INFO)

        self.createNew = createNew

        if createNew:
            configFile = os.path.join(util.getAddonInstallPath(), 'resources', 'database', 'config_template.xml')
        else:
            configFile = util.getConfigXmlPath()

        if not os.path.isfile(configFile):
            Logutil.log('File config.xml does not exist. Place a valid config file here: ' + str(configFile),
                        util.LOG_LEVEL_ERROR)
        else:
            self.tree = ElementTree().parse(configFile)
Пример #6
0
	def __copyLauncherScriptsToUserdata(self):
		log.info('__copyLauncherScriptsToUserdata')

		oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
		newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')

		files = []
		# Copy applaunch shell script/batch file
		if self.env == 'win32':
			files.append('applaunch.bat')
		else:
			files.append('applaunch.sh')

		# Copy VBS files
		if self.env == 'win32' and __addon__.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true':
			files += ['applaunch-vbs.bat', 'LaunchKodi.vbs', 'Sleep.vbs']

		for f in files:
			if not xbmcvfs.exists(os.path.join(newBasePath, f)):
				log.debug("Copying file {0} from {1} to {2}".format(f, oldBasePath, newBasePath))
				if not xbmcvfs.copy(os.path.join(oldBasePath, f), os.path.join(newBasePath, f)):
					log.warn("Error copying file")
Пример #7
0
ACTION_CANCEL_DIALOG = (9, 10, 51, 92, 110)
ACTION_MOVEMENT_LEFT = (1,)
ACTION_MOVEMENT_RIGHT = (2,)
ACTION_MOVEMENT_UP = (3,)
ACTION_MOVEMENT_DOWN = (4,)
ACTION_MOVEMENT = (1, 2, 3, 4)

CONTROL_BUTTON_PLAYGAME = 3000
CONTROL_BUTTON_PLAYVIDEO = 3001

CONTROL_GAME_LIST_GROUP = 1000
CONTROL_GAME_LIST = 59

CONTROL_LABEL_MSG = 4000

RCBHOME = util.getAddonInstallPath()


class UIGameInfoView(xbmcgui.WindowXMLDialog):
    def __init__(self, *args, **kwargs):
        xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)

        Logutil.log("Init GameInfoView", util.LOG_LEVEL_INFO)

        self.gdb = kwargs["gdb"]
        self.selectedGameId = kwargs["gameId"]
        self.selectedGame = kwargs["listItem"]
        self.config = kwargs["config"]
        self.settings = kwargs["settings"]
        self.selectedConsoleId = kwargs["consoleId"]
        self.selectedGenreId = kwargs["genreId"]
    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
Пример #9
0
	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()
Пример #10
0
    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(35013), util.localize(35014))
                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(35001), 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(35002), 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(35015), util.localize(35014))
                return

            origCommand = self.gameRow[util.GAME_gameCmd]
            command = ""

            romCollectionId = self.gameRow[util.GAME_romCollectionId]
            romCollection = self.gui.config.romCollections[str(romCollectionId)]
            if romCollection.useBuiltinEmulator:
                success, selectedcore = self.selectlibretrocore(romCollection.name)
                if success:
                    command = selectedcore
                else:
                    Logutil.log("No libretro core was chosen. Won't update game command.", util.LOG_LEVEL_INFO)
                    return
            else:
                keyboard = xbmc.Keyboard()
                keyboard.setHeading(util.localize(40035))
                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(35016), util.localize(35014))
                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(35016), util.localize(35014))
                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()

        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(35017), util.localize(35018))
                return
            dialog = xbmcgui.Dialog()
            if dialog.yesno(util.localize(51010), util.localize(40036)):
                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()
ACTION_MOVEMENT_DOWN = (4, )
ACTION_MOVEMENT = (
    1,
    2,
    3,
    4,
)

CONTROL_BUTTON_PLAYGAME = 3000

CONTROL_GAME_LIST_GROUP = 1000
CONTROL_GAME_LIST = 8200

CONTROL_LABEL_MSG = 4000

RCBHOME = util.getAddonInstallPath()


class MyPlayer(xbmc.Player):

    gui = None

    def onPlayBackEnded(self):
        print 'RCB: onPlaybackEnded'

        if (self.gui == None):
            print "RCB_WARNING: gui == None in MyPlayer"
            return

        self.gui.setFocus(self.gui.getControl(CONTROL_BUTTON_PLAYGAME))
Пример #12
0
	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(35013), util.localize(35014))
				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(35001), 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(35002), 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(35015), util.localize(35014))
				return

			origCommand = self.gameRow[util.GAME_gameCmd]
			command = ''
			
			romCollectionId = self.gameRow[util.GAME_romCollectionId]
			romCollection = self.gui.config.romCollections[str(romCollectionId)]
			if(romCollection.useBuiltinEmulator):
				success, selectedcore = self.selectlibretrocore(romCollection.name)
				if success:
					command = selectedcore
				else:
					Logutil.log("No libretro core was chosen. Won't update game command.", util.LOG_LEVEL_INFO)
					return
			else:
				keyboard = xbmc.Keyboard()
				keyboard.setHeading(util.localize(40035))
				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(35016), util.localize(35014))
				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(35016), util.localize(35014))
				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()
			
		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(35017), util.localize(35018))
				return					
			dialog = xbmcgui.Dialog()
			if dialog.yesno(util.localize(51010), util.localize(40036)):
				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()
	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()
Пример #14
0
        del window
    
    def exit(self):             
        self.close()

    # Helper methods 
    def getControlById(self, controlId):
        try:
            control = self.getControl(controlId)
        except Exception, (exc):
            # There seems to be a problem with recognizing the scrollbar controls
            if(controlId not in (CONTROL_SCROLLBARS)):
                #print "Control with id: %s could not be found. Check WindowXML file. Error: %s" % (str(controlId), str(exc))
                self.writeMsg(util.localize(35025) % str(controlId))
            return None
        return control
    
    def writeMsg(self, msg, count=0):
        control = self.getControlById(CONTROL_LABEL_MSG)
        if(control == None):
            return
        try:
            control.setLabel(msg)
        except:
            pass
    

ui = UIGameDB('main.xml', util.getAddonInstallPath())
ui.doModal()
del ui
Пример #15
0
	def onClick(self, controlID):
		if (controlID == 5101): # Close window button
			self.close()
		elif (controlID == 5110): # Import games
			self.close()
			self.gui.updateDB()		
		elif (controlID == 5111): # add Rom Collection			
			self.close()
			wizardconfigxml.ConfigXmlWizard().addRomCollection(self.gui.config)
			
			#update self.config
			statusOk, errorMsg = self.gui.config.readXml()
			if(statusOk == False):
				xbmcgui.Dialog().ok(util.SCRIPTNAME, 'Error reading config.xml.', errorMsg)
				Logutil.log('Error reading config.xml: ' +errorMsg, util.LOG_LEVEL_INFO)
				return False, 'Error reading config.xml: ' +errorMsg
			
			#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()
			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()
			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, 'Edit Game Command Error', "Can't load selected Game")
				return

			command = self.gameRow[util.GAME_gameCmd]
			
			keyboard = xbmc.Keyboard()
			keyboard.setHeading('Enter Game Command')
			if(command != None):
				keyboard.setDefault(command)
			keyboard.doModal()
			if (keyboard.isConfirmed()):
				command = keyboard.getText()
				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])
				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, 'Add To Favorites Error', "Can't load selected Game")
				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])
			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, 'Add To Favorites Error', "Can't load selected Game")
				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])
				selectedGame.setProperty('isfavorite', str(isFavorite))
			self.gui.gdb.commit()
			
		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, 'Delete Game Error', "Can't delete selected Game")
				return					
			dialog = xbmcgui.Dialog()
			if dialog.yesno("Delete Game", "Are you sure you want to delete this game?"):
				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()