def setImage(self, controlName, fileTypes, gameId, publisherId, developerId, romCollectionId, defaultImage, selectedGame, fileDict): Logutil.log("Begin setImage", util.LOG_LEVEL_DEBUG) images = helper.getFilesByControl_Cached(self.gdb, fileTypes, gameId, publisherId, developerId, romCollectionId, fileDict) #TODO more than one image? image = '' if (images != None and len(images) != 0): image = images[0] #control.setVisible(1) else: if (defaultImage == None): pass #control.setVisible(0) else: image = defaultImage selectedGame.setProperty(controlName, image) Logutil.log("End setImage", util.LOG_LEVEL_DEBUG)
def setImage( self, controlName, fileTypes, gameId, publisherId, developerId, romCollectionId, defaultImage, selectedGame, fileDict, ): Logutil.log("Begin setImage", util.LOG_LEVEL_DEBUG) images = helper.getFilesByControl_Cached( self.gdb, fileTypes, gameId, publisherId, developerId, romCollectionId, fileDict ) # TODO more than one image? image = "" if images != None and len(images) != 0: image = images[0] # control.setVisible(1) else: if defaultImage == None: pass # control.setVisible(0) else: image = defaultImage selectedGame.setProperty(controlName, image) Logutil.log("End setImage", util.LOG_LEVEL_DEBUG)
def getFileForControl(self, controlName, gameId, publisherId, developerId, romCollectionId, fileDict): files = helper.getFilesByControl_Cached(self.gdb, controlName, gameId, publisherId, developerId, romCollectionId, fileDict) if(files != None and len(files) != 0): file = files[0] else: file = "" return file
def showGameList(self): Logutil.log("Begin showGameList", util.LOG_LEVEL_INFO) #likeStatement = helper.buildLikeStatement(self.selectedCharacter) #games = Game(self.gdb).getFilteredGames(self.selectedConsoleId, self.selectedGenreId, self.selectedYearId, self.selectedPublisherId, likeStatement) self.writeMsg(util.localize(32121)) self.clearList() gameRow = Game(self.gdb).getObjectById(self.selectedGameId) fileDict = self.getFileDictByGameRow(self.gdb, gameRow) romCollection = None try: romCollection = self.config.romCollections[str(gameRow[util.GAME_romCollectionId])] except: Logutil.log(util.localize(32023) %str(gameRow[util.GAME_romCollectionId]), util.LOG_LEVEL_ERROR) imageGameList = self.getFileForControl(romCollection.imagePlacingInfo.fileTypesForGameList, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) imageGameListSelected = self.getFileForControl(romCollection.imagePlacingInfo.fileTypesForGameListSelected, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) item = xbmcgui.ListItem(gameRow[util.ROW_NAME], str(gameRow[util.ROW_ID]), imageGameList, imageGameListSelected) item.setProperty('gameId', str(gameRow[util.ROW_ID])) #check if we should use autoplay video if(romCollection.autoplayVideoInfo): item.setProperty('autoplayvideoinfo', 'true') else: item.setProperty('autoplayvideoinfo', '') #get video window size if (romCollection.imagePlacingInfo.name.startswith('gameinfosmall')): item.setProperty('videosizesmall', 'small') item.setProperty('videosizebig', '') else: item.setProperty('videosizebig', 'big') item.setProperty('videosizesmall', '') videos = helper.getFilesByControl_Cached(self.gdb, (self.fileTypeGameplay,), gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) if(videos != None and len(videos) != 0): video = videos[0] item.setProperty('gameplayinfo', video) self.addItem(item) xbmc.executebuiltin("Container.SortDirection") self.writeMsg("") Logutil.log("End showGameList", util.LOG_LEVEL_INFO)
def showGameList(self): Logutil.log("Begin showGameList", util.LOG_LEVEL_INFO) #likeStatement = helper.buildLikeStatement(self.selectedCharacter) #games = Game(self.gdb).getFilteredGames(self.selectedConsoleId, self.selectedGenreId, self.selectedYearId, self.selectedPublisherId, likeStatement) self.writeMsg(util.localize(40021)) self.clearList() gameRow = Game(self.gdb).getObjectById(self.selectedGameId) fileDict = self.getFileDictByGameRow(self.gdb, gameRow) romCollection = None try: romCollection = self.config.romCollections[str(gameRow[util.GAME_romCollectionId])] except: Logutil.log(util.localize(35023) %str(gameRow[util.GAME_romCollectionId]), util.LOG_LEVEL_ERROR) imageGameList = self.getFileForControl(romCollection.imagePlacingInfo.fileTypesForGameList, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) imageGameListSelected = self.getFileForControl(romCollection.imagePlacingInfo.fileTypesForGameListSelected, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) item = xbmcgui.ListItem(gameRow[util.ROW_NAME], str(gameRow[util.ROW_ID]), imageGameList, imageGameListSelected) item.setProperty('gameId', str(gameRow[util.ROW_ID])) #check if we should use autoplay video if(romCollection.autoplayVideoInfo): item.setProperty('autoplayvideoinfo', 'true') else: item.setProperty('autoplayvideoinfo', '') #get video window size if (romCollection.imagePlacingInfo.name.startswith('gameinfosmall')): item.setProperty('videosizesmall', 'small') item.setProperty('videosizebig', '') else: item.setProperty('videosizebig', 'big') item.setProperty('videosizesmall', '') videos = helper.getFilesByControl_Cached(self.gdb, (self.fileTypeGameplay,), gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) if(videos != None and len(videos) != 0): video = videos[0] item.setProperty('gameplayinfo', video) self.addItem(item) xbmc.executebuiltin("Container.SortDirection") self.writeMsg("") Logutil.log("End showGameList", util.LOG_LEVEL_INFO)
def gatherWidgetData(self, param): print 'start gatherWidgetData' import util, helper from gamedatabase import Game, GameDataBase, File from config import Config, RomCollection gdb = GameDataBase(util.getAddonDataPath()) gdb.connect() doImport, errorMsg = gdb.checkDBStructure() if(doImport) > 0: print "RCB: No database available. Won't gather any data." gdb.close() return #cache lookup tables yearDict = helper.cacheYears(gdb) publisherDict = helper.cachePublishers(gdb) developerDict = helper.cacheDevelopers(gdb) reviewerDict = helper.cacheReviewers(gdb) genreDict = helper.cacheGenres(gdb) limit = int(param.replace('limit=', '')) games = Game(gdb).getMostPlayedGames(limit) print 'most played games: %s' %games config = Config(None) statusOk, errorMsg = config.readXml() settings = util.getSettings() import xbmcgui count = 0 for gameRow in games: count += 1 try: print "Gathering data for rom no %i: %s" %(count, gameRow[util.ROW_NAME]) romCollection = config.romCollections[str(gameRow[util.GAME_romCollectionId])] #get artwork that is chosen to be shown in gamelist files = File(gdb).getFilesByParentIds(gameRow[util.ROW_ID], gameRow[util.GAME_romCollectionId], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId]) fileDict = helper.cacheFiles(files) files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForGameList, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) if(files != None and len(files) != 0): thumb = files[0] else: thumb = "" files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForMainViewBackground, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict) if(files != None and len(files) != 0): fanart = files[0] else: fanart = "" description = gameRow[util.GAME_description] if(description == None): description = "" year = helper.getPropertyFromCache(gameRow, yearDict, util.GAME_yearId, util.ROW_NAME) publisher = helper.getPropertyFromCache(gameRow, publisherDict, util.GAME_publisherId, util.ROW_NAME) developer = helper.getPropertyFromCache(gameRow, developerDict, util.GAME_developerId, util.ROW_NAME) genre = genreDict[gameRow[util.ROW_ID]] maxplayers = helper.saveReadString(gameRow[util.GAME_maxPlayers]) rating = helper.saveReadString(gameRow[util.GAME_rating]) votes = helper.saveReadString(gameRow[util.GAME_numVotes]) url = helper.saveReadString(gameRow[util.GAME_url]) region = helper.saveReadString(gameRow[util.GAME_region]) media = helper.saveReadString(gameRow[util.GAME_media]) perspective = helper.saveReadString(gameRow[util.GAME_perspective]) controllertype = helper.saveReadString(gameRow[util.GAME_controllerType]) originaltitle = helper.saveReadString(gameRow[util.GAME_originalTitle]) alternatetitle = helper.saveReadString(gameRow[util.GAME_alternateTitle]) translatedby = helper.saveReadString(gameRow[util.GAME_translatedBy]) version = helper.saveReadString(gameRow[util.GAME_version]) playcount = helper.saveReadString(gameRow[util.GAME_launchCount]) #get launch command filenameRows = File(gdb).getRomsByGameId(gameRow[util.ROW_ID]) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" %count, str(gameRow[util.ROW_ID])) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" %count, romCollection.name) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" %count, gameRow[util.ROW_NAME]) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Thumb" %count, thumb) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Fanart" %count, fanart) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Plot" %count, description) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" %count, year) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" %count, publisher) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" %count, developer) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" %count, genre) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" %count, maxplayers) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" %count, region) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" %count, media) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" %count, perspective) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" %count, controllertype) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" %count, playcount) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" %count, rating) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" %count, votes) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" %count, url) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" %count, originaltitle) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" %count, alternatetitle) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Translatedby" %count, translatedby) xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" %count, version) except Exception, (exc): print 'RCB: Error while getting most played games: ' +str(exc)