def getMenuInfo(menuType): title = '' buttonPrefix = '' if menuType == 'home': buttonPrefix = 'HomeMenuButton' title = localize(33024) elif menuType == 'sub': buttonPrefix = 'HomeGameButton' title = localize(33025) return title, buttonPrefix
def addContextMenu(game,listItem): menuTuple = None if (isInFavorites(game)): menuTuple = (xbmc.getLocalizedString(14077), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=removefromfavorites&mode=context&gameid={0})'.format(game.gameId),) else: menuTuple = (xbmc.getLocalizedString(14076), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=addtofavorites&mode=context&gameid={0})'.format(game.gameId),) if (game.type == 1): listItem.addContextMenuItems([menuTuple, (localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})'.format(game.gameId),), (localize(33007), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})'.format(game.gameId),), (localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})'.format(game.gameId),),],True) else: listItem.addContextMenuItems([menuTuple, (localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})'.format(game.gameId),), (localize(33006), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editpath&mode=context&gameid={0})'.format(game.gameId),), (localize(33007), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})'.format(game.gameId),), (localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})'.format(game.gameId),),],True)
def findGames(): # Addon paths creation if not os.path.exists(DEFAULT_THUMB_PATH): os.makedirs(DEFAULT_THUMB_PATH) if not os.path.exists(DEFAULT_FANART_PATH): os.makedirs(DEFAULT_FANART_PATH) xbmc.executebuiltin("Dialog.Close(busydialog)") steamPath = getSteamPath() steamAppPath = os.path.join(os.path.abspath(steamPath),'steamapps') games = {} files = glob('{0}/*.acf'.format(steamAppPath)) numFiles = len(files) counter = 0 pDialog = xbmcgui.DialogProgress() pDialog.create(__addonname__, localize(33003)) pDialog.update(0, localize(33003)) orgGames = getGames() for filePath in glob('{0}/*.acf'.format(steamAppPath)): log('findGames()::filepath -> %s' % filePath) try: gameDict = parse_acf(filePath) if (gameDict['appstate']['bytestodownload'] != '0' and gameDict['appstate']['bytestodownload'] == gameDict['appstate']['bytesdownloaded']): orgGame = None for game in orgGames: if (game.gameId == gameDict['appstate']['appid']): orgGame = game break; name = gameDict['appstate']['name'] path = '' isNameChanged = 0 isPathChanged = 0 isIconChanged = 0 isFanartChanged = 0 thumbImage = '' fanartImage = '' type = 1 if ((not orgGame) or (orgGame is not None and orgGame.isFanartChanged == 0 and orgGame.isIconChanged == 0)): gameFiles = downloadGameImage(gameDict['appstate']['appid'],gameDict['appstate']['name']) thumbImage = gameFiles[0] fanartImage = gameFiles[1] elif (orgGame is not None and orgGame.isFanartChanged == 0): gameFiles = downloadGameImage(gameDict['appstate']['appid'],gameDict['appstate']['name']) thumbImage = orgGame.thumbImage fanartImage = gameFiles[1] isIconChanged = 1 elif (orgGame is not None and orgGame.isIconChanged == 0): gameFiles = downloadGameImage(gameDict['appstate']['appid'],gameDict['appstate']['name']) thumbImage = gameFiles[0] fanartImage = orgGame.fanartImage isFanartChanged = 1 else: thumbImage = orgGame.thumbImage fanartImage = orgGame.fanartImage isIconChanged = 1 isFanartChanged = 1 if (orgGame is not None and orgGame.isNameChanged == 1): name = orgGame.title isNameChanged = 1 if (orgGame is not None and orgGame.isPathChanged == 1): name = orgGame.path isPathChanged = 1 games[gameDict['appstate']['appid']] = {} games[gameDict['appstate']['appid']]['name'] = name games[gameDict['appstate']['appid']]['path'] = path games[gameDict['appstate']['appid']]['isNameChanged'] = isNameChanged games[gameDict['appstate']['appid']]['isPathChanged'] = isPathChanged games[gameDict['appstate']['appid']]['isIconChanged'] = isIconChanged games[gameDict['appstate']['appid']]['isFanartChanged'] = isFanartChanged games[gameDict['appstate']['appid']]['type'] = type games[gameDict['appstate']['appid']]['thumbImage'] = thumbImage games[gameDict['appstate']['appid']]['fanartImage'] = fanartImage counter = counter + 1 except: log('unable to parse the file %s' % filePath) if (pDialog.iscanceled()): break; pDialog.update(int((float(counter)/float(numFiles))*100), localize(33003)) #games = sorted(games.iteritems(), key= operator.itemgetter(1)) gamesDbObj = open(GAMES_DB_PATH, 'w') log(json.dumps(games)) gamesDbObj.write(json.dumps(games)) gamesDbObj.close() pDialog.close() dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__, str(counter) + ' ' + localize(33004))
#xbmcplugin.setContent(int(sys.argv[1]), 'games') #log("base_url => + " + base_url + ", args => " + sys.argv[2][1:]) if mode is None: viewModeId = xbmc.getInfoLabel('Skin.String(GamesDefaultViewMode)') if(viewModeId): viewModeId = get_view_mode(); xbmc.executebuiltin('Skin.SetString(GamesDefaultViewMode, %s)' % viewModeId) imageFilePath = os.path.join(CURRENT_ADDON_PATH, 'resources','skins','Default','media','alienware') url = build_url({'mode': 'folder', 'action': 'games'}) li = xbmcgui.ListItem(localize(33000), iconImage=os.path.join(imageFilePath, 'games.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li,totalItems=3,isFolder=True) url = build_url({'mode': 'folder', 'action': 'findgames'}) li = xbmcgui.ListItem(localize(33001), iconImage=os.path.join(imageFilePath, 'findgames.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li,totalItems=3, isFolder=True) url = build_url({'mode': 'folder', 'action': 'steam'}) li = xbmcgui.ListItem(localize(33002), iconImage=os.path.join(imageFilePath, 'steam.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li,totalItems=3, isFolder=True) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=False)
def addContextMenu(game, listItem): menuTuple = None homeMenuAction = 'addtohomemenu' homeMenuTitle = localize(33018) isGameAdded = isAddedtoMenu('HomeMenuButton', game.gameId) if isGameAdded: homeMenuAction = 'removefromhomemenu' homeMenuTitle = localize(33019) subMenuAction = 'addtogamesubmenu' subMenuTitle = localize(33020) isSubMenuAdded = isAddedtoMenu('HomeGameButton', game.gameId) if isSubMenuAdded: subMenuAction = 'removefromgamesubmenu' subMenuTitle = localize(33021) if (isInFavorites(game)): menuTuple = (xbmc.getLocalizedString(14077), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=removefromfavorites&mode=context&gameid={0})'.format( game.gameId),) else: menuTuple = (xbmc.getLocalizedString(14076), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=addtofavorites&mode=context&gameid={0})'.format( game.gameId),) if (game.type == 0): listItem.addContextMenuItems([], True) elif (game.type != CUSTOM_GAME_TYPE): listItem.addContextMenuItems([menuTuple, (localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})'.format( game.gameId),), (localize(33007), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})'.format( game.gameId),), (localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})'.format( game.gameId),), (homeMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction='+ homeMenuAction +'&mode=context&gameid={0})'.format( game.gameId),), (subMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction='+ subMenuAction +'&mode=context&gameid={0})'.format( game.gameId),), ], True) else: listItem.addContextMenuItems([menuTuple, (localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})'.format( game.gameId),), (localize(33006), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})'.format( game.gameId),), (localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})'.format( game.gameId),), (homeMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction='+ homeMenuAction +'&mode=context&gameid={0})'.format( game.gameId),), (subMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction='+ subMenuAction +'&mode=context&gameid={0})'.format( game.gameId),), (localize(33026), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=remove&mode=context&gameid={0})'.format( game.gameId),), ], True)
def findGames(): games = {} orgGames = getGames() isCanceled = False #find all custom installed games for game in orgGames: if (game.type == CUSTOM_GAME_TYPE): gameId = game.gameId games[gameId] = {} games[gameId]['name'] = game.title games[gameId]['path'] = game.path games[gameId]['isNameChanged'] = game.isNameChanged games[gameId]['isPathChanged'] = game.isPathChanged games[gameId]['isIconChanged'] = game.isIconChanged games[gameId]['isFanartChanged'] = game.isFanartChanged games[gameId]['type'] = game.type games[gameId]['thumbImage'] = game.thumbImage games[gameId]['fanartImage'] = game.fanartImage steamGame = SteamGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = steamGame.findGames(orgGames, games) originGame = OriginGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = originGame.findGames(orgGames, games) gogGame = GogGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = gogGame.findGames(orgGames, games) uplayGame = UplayGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = uplayGame.findGames(orgGames, games) battleGame = BattleGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = battleGame.findGames(orgGames, games) if(not isCanceled): for game in orgGames: if (game.type == 0 or game.type == int(CUSTOM_GAME_TYPE)): gameId = game.gameId games[gameId] = {} games[gameId]['name'] = game.title games[gameId]['path'] = game.path games[gameId]['isNameChanged'] = game.isNameChanged games[gameId]['isPathChanged'] = game.isPathChanged games[gameId]['isIconChanged'] = game.isIconChanged games[gameId]['isFanartChanged'] = game.isFanartChanged games[gameId]['type'] = game.type games[gameId]['thumbImage'] = game.thumbImage games[gameId]['fanartImage'] = game.fanartImage for game in games: if (game.title == ''): games.pop(game) writeToGameDB(games) dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__, str(len(games) - 1) + ' ' + localize(33004))
addon_handle = int(sys.argv[1]) args = urlparse.parse_qs(sys.argv[2][1:]) mode = args.get('mode', None) # xbmcplugin.setContent(int(sys.argv[1]), 'games') # log("base_url => + " + base_url + ", args => " + sys.argv[2][1:]) if mode is None: imageFilePath = os.path.join(CURRENT_ADDON_PATH, 'resources', 'skins', 'Default', 'media', 'alienware') noOfItems = 7 url = build_url({'mode': 'folder', 'action': 'games'}) li = xbmcgui.ListItem(localize(33000), iconImage=os.path.join(imageFilePath, 'games.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=noOfItems, isFolder=True) url = build_url({'mode': 'folder', 'action': 'findgames'}) li = xbmcgui.ListItem(localize(33001), iconImage=os.path.join(imageFilePath, 'findgames.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=noOfItems, isFolder=True) url = build_url({'mode': 'folder', 'action': 'launchsteam'}) li = xbmcgui.ListItem(localize(33002), iconImage=os.path.join(imageFilePath, 'steam.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=noOfItems, isFolder=True) url = build_url({'mode': 'folder', 'action': 'launchorigin'}) li = xbmcgui.ListItem(localize(33009), iconImage=os.path.join(imageFilePath, 'origin.png'))
def addContextMenu(game, listItem): menuTuple = None homeMenuAction = 'addtohomemenu' homeMenuTitle = localize(33018) isGameAdded = isAddedtoMenu('HomeMenuButton', game.gameId) if isGameAdded: homeMenuAction = 'removefromhomemenu' homeMenuTitle = localize(33019) subMenuAction = 'addtogamesubmenu' subMenuTitle = localize(33020) isSubMenuAdded = isAddedtoMenu('HomeGameButton', game.gameId) if isSubMenuAdded: subMenuAction = 'removefromgamesubmenu' subMenuTitle = localize(33021) if (isInFavorites(game)): menuTuple = ( xbmc.getLocalizedString(14077), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=removefromfavorites&mode=context&gameid={0})' .format(game.gameId), ) else: menuTuple = ( xbmc.getLocalizedString(14076), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=addtofavorites&mode=context&gameid={0})' .format(game.gameId), ) if (game.type == 0): listItem.addContextMenuItems([], True) elif (game.type != CUSTOM_GAME_TYPE): listItem.addContextMenuItems([ menuTuple, ( localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})' .format(game.gameId), ), ( localize(33007), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})' .format(game.gameId), ), ( localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})' .format(game.gameId), ), ( homeMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=' + homeMenuAction + '&mode=context&gameid={0})'.format(game.gameId), ), ( subMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=' + subMenuAction + '&mode=context&gameid={0})'.format(game.gameId), ), ], True) else: listItem.addContextMenuItems([ menuTuple, ( localize(33005), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=edittitle&mode=context&gameid={0})' .format(game.gameId), ), ( localize(33006), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editicon&mode=context&gameid={0})' .format(game.gameId), ), ( localize(33008), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=editfanart&mode=context&gameid={0})' .format(game.gameId), ), ( homeMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=' + homeMenuAction + '&mode=context&gameid={0})'.format(game.gameId), ), ( subMenuTitle, 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=' + subMenuAction + '&mode=context&gameid={0})'.format(game.gameId), ), ( localize(33026), 'XBMC.Container.Refresh(plugin://plugin.program.aw.gamelauncher/?action=games&menuaction=remove&mode=context&gameid={0})' .format(game.gameId), ), ], True)
def findGames(): games = {} orgGames = getGames() isCanceled = False #find all custom installed games for game in orgGames: if (game.type == CUSTOM_GAME_TYPE): gameId = game.gameId games[gameId] = {} games[gameId]['name'] = game.title games[gameId]['path'] = game.path games[gameId]['isNameChanged'] = game.isNameChanged games[gameId]['isPathChanged'] = game.isPathChanged games[gameId]['isIconChanged'] = game.isIconChanged games[gameId]['isFanartChanged'] = game.isFanartChanged games[gameId]['type'] = game.type games[gameId]['thumbImage'] = game.thumbImage games[gameId]['fanartImage'] = game.fanartImage steamGame = SteamGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = steamGame.findGames(orgGames, games) originGame = OriginGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = originGame.findGames(orgGames, games) gogGame = GogGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = gogGame.findGames(orgGames, games) uplayGame = UplayGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = uplayGame.findGames(orgGames, games) battleGame = BattleGame(DEFAULT_THUMB_PATH, DEFAULT_FANART_PATH) if (not isCanceled): games, isCanceled = battleGame.findGames(orgGames, games) if (not isCanceled): for game in orgGames: if (game.type == 0 or game.type == int(CUSTOM_GAME_TYPE)): gameId = game.gameId games[gameId] = {} games[gameId]['name'] = game.title games[gameId]['path'] = game.path games[gameId]['isNameChanged'] = game.isNameChanged games[gameId]['isPathChanged'] = game.isPathChanged games[gameId]['isIconChanged'] = game.isIconChanged games[gameId]['isFanartChanged'] = game.isFanartChanged games[gameId]['type'] = game.type games[gameId]['thumbImage'] = game.thumbImage games[gameId]['fanartImage'] = game.fanartImage for game in games: if (game.title == ''): games.pop(game) writeToGameDB(games) dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__, str(len(games) - 1) + ' ' + localize(33004))
args = urlparse.parse_qs(sys.argv[2][1:]) mode = args.get('mode', None) # xbmcplugin.setContent(int(sys.argv[1]), 'games') # log("base_url => + " + base_url + ", args => " + sys.argv[2][1:]) if mode is None: imageFilePath = os.path.join(CURRENT_ADDON_PATH, 'resources', 'skins', 'Default', 'media', 'alienware') noOfItems = 7 url = build_url({'mode': 'folder', 'action': 'games'}) li = xbmcgui.ListItem(localize(33000), iconImage=os.path.join(imageFilePath, 'games.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, totalItems=noOfItems, isFolder=True) url = build_url({'mode': 'folder', 'action': 'findgames'}) li = xbmcgui.ListItem(localize(33001), iconImage=os.path.join(imageFilePath, 'findgames.png')) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li,