コード例 #1
0
def launchGame(params):
    app_id = int(params.get('id'))
    username = urllib.unquote_plus(params.get('username'))
    hostname = urllib.unquote_plus(params.get('hostname'))

    start = []

    with Service() as service:
        app = service.update_app((hostname, username), app_id)
        if app["state"] == 4 or app["state"] == 8 or app["state"] == 16 or app["state"] == 64 or app["state"] == 8196:
            result = service.start_game((hostname, username), app_id)
            if result[0] != eresult.k_EResultOK:
                dialog = xbmcgui.Dialog()
                ok = dialog.ok(utils.translation(32012), utils.translation(32013) + "(Code: "+str(result[0])+")." + utils.translation(32014))
            else:
                player = xbmc.Player()
                if player.isPlaying():
                    player.pause()
                dialog = xbmcgui.DialogProgress()
                dialog.update(0, utils.translation(32043), "", "")
                service.launch_client(result[1], result[2], result[3], app_id, (hostname, username))
                dialog.close()
        elif app["state"] == -1 or app["state"] == 1:
            if xbmcgui.Dialog().yesno(utils.translation(32015), utils.translation(32016)):
                result = service.start_game((hostname, username), app_id)
                if result[0] == -1: #steam seems to use only positiv values, this is a little hacky. (TODO we should refactor this result to a dictionary)
                    dialog = xbmcgui.Dialog()
                    ok = dialog.ok(utils.translation(32012), utils.translation(32017))
                elif result[0] == 3: #no idea, how that number comes for that case
                    dialog = xbmcgui.Dialog()
                    ok = dialog.ok(utils.translation(32018), utils.translation(32019))
                else:
                    if result[0] != eresult.k_EResultBusy:
                        print "Unknown Result: "+str(result[0]) #TODO find a way to collect those (is informing the user to aggresive?)
                    start.append(status.status(service, params))

        else:
            print "Interesting state: "+str(app["state"]) #TODO find a way to collect those (is informing the user to aggresive?)
            start.append(status.status(service, params))

    if len(start) > 0:
        if start[0] == "start":
            launchGame(params)
        if start[0] == "list":
            import listGames
            listGames.listGames(params)
コード例 #2
0
def main(mode):
    if mode == 'game':
        import launchGame
        launchGame.launchGame(params)
    elif mode == 'games':
        import listGames
        listGames.listGames(params)
    elif mode == 'clients':
        import listClients
        listClients.listClients(params)
    elif mode == 'noauth':
        import listClients
        listClients.no_authentification(params)
    elif mode == 'achievements':
        import listAchievements
        listAchievements.listAchievements(params)
    elif mode == 'movies':
        import listMovies
        listMovies.listMovies(params)
    elif mode == 'wakeIndex':
        import wakeIndex
        wakeIndex.wakeIndex()
    elif mode == 'wake':
        import wake
        wake.wake(params)
    elif mode == 'clearMacs':
        try:
            import cPickle as pickle
        except:
            import pickle
        pickle.dump(set(), open(os.path.join(utils.USER_DATA, "macs.pickle"), "w+"))
    elif mode == 'reset':
        main("clearMacs")
        utils.addon.setSetting("invalid_steam_api_key", "false")
        utils.addon.setSetting("steam_api_key", "")
        utils.addon.setSetting("prescript", "")
        utils.addon.setSetting("postscript", "")
        utils.addon.setSetting("first_run", "true")
    elif mode == 'settings':
        utils.addon.openSettings()
    else:
        import index
        index.index()