def testFileForControl_DB(self):
        config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata',
                                       'config',
                                       'romcollections_imageloading.xml')
        conf = Config(config_xml_file)
        conf.readXml()

        rc_id = 1
        rom_collection = conf.romCollections[str(rc_id)]

        game = GameView(self.gdb).getGameById(28)

        file = helper.get_file_for_control_from_db(
            rom_collection.imagePlacingMain.fileTypesForGameList, game)

        print(file)
示例#2
0
    def gatherWidgetData(self, param):
        xbmc.log('start gatherWidgetData')
        import util, helper
        from gamedatabase import DataBaseObject, GameView, GameDataBase
        from config import Config

        gdb = GameDataBase(util.getAddonDataPath())
        gdb.connect()

        doImport, errorMsg = gdb.checkDBStructure()
        if (doImport) > 0:
            xbmc.log("RCB: No database available. Won't gather any data.")
            gdb.close()
            return
        elif (doImport < 0):
            xbmc.log("RCB: Error occured while checking db structure: {0}" % errorMsg)

        limit = param.replace('limit=', '')
        query = 'Select * From GameView Where launchCount > 0 Order by launchCount desc Limit %s;' % str(limit)
        games = GameView(gdb).getGamesByQueryNoArgs(query)
        xbmc.log('most played games: %s' % games)

        config = Config(None)
        statusOk, errorMsg = config.readXml()

        if (not statusOk):
            xbmc.log('RCB: Error reading config.xml: {0}' % errorMsg)
            return

        import xbmcgui
        count = 0
        for game in games:

            count += 1
            try:
                xbmc.log("RCB widget: Gathering data for rom no %i: %s" % (count, game[GameView.COL_NAME]))

                romCollection = config.romCollections[str(game[GameView.COL_romCollectionId])]

                #get artwork that is chosen to be shown in gamelist
                thumb = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.fileTypesForGameList, game)
                fanart = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.fileTypesForMainViewBackground, game)

                url = "plugin://script.games.rom.collection.browser/?launchid=%s" % game[GameView.COL_ID]

                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" % count, str(game[GameView.COL_ID]))
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" % count, romCollection.name)
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" % count, game[GameView.COL_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, game[GameView.COL_description])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" % count, game[GameView.COL_year])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" % count, game[GameView.COL_publisher])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" % count, game[GameView.COL_developer])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" % count, game[GameView.COL_genre])

                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" % count, game[GameView.COL_maxPlayers])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" % count, game[GameView.COL_region])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" % count, game[GameView.COL_description])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" % count, game[GameView.COL_perspective])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" % count, game[GameView.COL_controllerType])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" % count, game[GameView.COL_launchCount])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" % count, game[GameView.COL_rating])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" % count, game[GameView.COL_numVotes])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" % count, game[GameView.COL_url])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" % count, game[GameView.COL_originalTitle])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" % count, game[GameView.COL_alternateTitle])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" % count, game[GameView.COL_version])

            except Exception as exc:
                xbmc.log('RCB: Error while getting most played games: ' + str(exc))

        gdb.close()
示例#3
0
    def addGamesToDirectory(self, gdb, games, limit, platformId):
        xbmc.log('RCB widget: addGamesToDirectory')

        xbmc.log('RCB widget: read config.xml')
        config = Config(None)
        statusOk, errorMsg = config.readXml()
        xbmc.log('RCB widget: read config.xml done')

        if (not statusOk):
            xbmc.log('RCB widget: Error reading config.xml: {0}' % errorMsg)
            #TODO: Error handling
            return

        if not platformId:
            platformId = 0

        count = 0
        for game in games:

            count += 1
            try:
                xbmc.log("RCB widget: Gathering data for rom no %i: %s" %
                         (count, game[GameView.COL_NAME]))

                romCollection = config.romCollections[str(
                    game[GameView.COL_romCollectionId])]

                #get artwork that is chosen to be shown in gamelist
                thumb = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.fileTypesForGameList, game)
                fanart = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.
                    fileTypesForMainViewBackground, game)

                title = '%s (%s)' % (game[GameView.COL_NAME],
                                     romCollection.name)

                infoLabels = infoLabels = {
                    "Title": title,
                    "Year": game[GameView.COL_year],
                    "Genre": game[GameView.COL_genre],
                    "Studio": game[GameView.COL_developer],
                    "Plot": game[GameView.COL_description],
                    "PlayCount": str(game[GameView.COL_launchCount]),
                    "Rating": game[GameView.COL_rating],
                    "Votes": game[GameView.COL_numVotes],
                    "Country": game[GameView.COL_region],
                    "OriginalTitle": game[GameView.COL_originalTitle]
                }

                url = "plugin://script.games.rom.collection.browser/?launchid=%s" % game[
                    GameView.COL_ID]

                listitem = xbmcgui.ListItem(title)
                listitem.setInfo(type="Video", infoLabels=infoLabels)
                listitem.setArt({"fanart": fanart, "thumb": thumb})
                xbmcplugin.addDirectoryItem(thisPlugin,
                                            url,
                                            listitem,
                                            isFolder=False)

            except Exception as exc:
                xbmc.log(
                    'RCB widget: Error while getting games for RCB widget: ' +
                    str(exc))

        gdb.close()
示例#4
0
    def showGame(self):

        Logutil.log("Begin showGameList UIGameInfoView", util.LOG_LEVEL_INFO)

        self.clearList()

        game = GameView(self.gdb).getGameById(self.selectedGameId)

        item = xbmcgui.ListItem(game[DataBaseObject.COL_NAME], str(game[GameView.COL_ID]))

        romcollection_id = str(game[GameView.COL_romCollectionId])
        try:
            romCollection = self.config.romCollections[romcollection_id]
        except KeyError:
            Logutil.log('Cannot get rom collection with id: ' + romcollection_id,
                        util.LOG_LEVEL_ERROR)

        item.setProperty('romCollectionId', romcollection_id)
        item.setProperty('romcollection', romCollection.name)
        item.setProperty('console', romCollection.name)
        item.setProperty('gameId', str(game[GameView.COL_ID]))
        item.setProperty('plot', game[GameView.COL_description])
        item.setProperty('developer', game[GameView.COL_developer])
        item.setProperty('publisher', game[GameView.COL_publisher])
        item.setProperty('year', game[GameView.COL_year])
        item.setProperty('genre', game[GameView.COL_genre])
        item.setProperty('gameCmd', game[GameView.COL_gameCmd])
        item.setProperty('alternateGameCmd', game[GameView.COL_alternateGameCmd])
        item.setProperty('playcount', str(game[GameView.COL_launchCount]))
        item.setProperty('originalTitle', game[GameView.COL_originalTitle])
        item.setProperty('alternateTitle', game[GameView.COL_alternateTitle])

        item.setProperty('rating', str(game[GameView.COL_rating]))
        item.setProperty('media', str(game[GameView.COL_media]))
        item.setProperty('controllertype', str(game[GameView.COL_controllerType]))
        item.setProperty('region', str(game[GameView.COL_region]))
        item.setProperty('maxplayers', str(game[GameView.COL_maxPlayers]))
        item.setProperty('url', str(game[GameView.COL_url]))

        if game[GameView.COL_isFavorite] == 1:
            item.setProperty('isfavorite', '1')
        else:
            item.setProperty('isfavorite', '')

        item.setArt({
            'icon': helper.get_file_for_control_from_db(
                romCollection.imagePlacingMain.fileTypesForGameList, game),
            'thumb': helper.get_file_for_control_from_db(
                romCollection.imagePlacingMain.fileTypesForGameListSelected, game),

            IMAGE_CONTROL_BACKGROUND: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewBackground, game),
            IMAGE_CONTROL_GAMEINFO_BIG: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoBig, game),

            IMAGE_CONTROL_GAMEINFO_UPPERLEFT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoUpperLeft, game),
            IMAGE_CONTROL_GAMEINFO_UPPERRIGHT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoUpperRight, game),
            IMAGE_CONTROL_GAMEINFO_LOWERLEFT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoLowerLeft, game),
            IMAGE_CONTROL_GAMEINFO_LOWERRIGHT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoLowerRight, game),

            IMAGE_CONTROL_GAMEINFO_UPPER: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoUpper, game),
            IMAGE_CONTROL_GAMEINFO_LOWER: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoLower, game),
            IMAGE_CONTROL_GAMEINFO_LEFT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoLeft, game),
            IMAGE_CONTROL_GAMEINFO_RIGHT: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainViewGameInfoRight, game),

            IMAGE_CONTROL_1: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainView1, game),
            IMAGE_CONTROL_2: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainView2, game),
            IMAGE_CONTROL_3: helper.get_file_for_control_from_db(
                romCollection.imagePlacingInfo.fileTypesForMainView3, game)
        })

        #add item to listcontrol
        listcontrol = self.getControlById(CONTROL_GAME_LIST)
        listcontrol.addItem(item)

        self.writeMsg("")

        Logutil.log("End showGameList UIGameInfoView", util.LOG_LEVEL_INFO)