コード例 #1
0
ファイル: _gameswidget.py プロジェクト: AThorley/lobby
    def hostGameClicked(self, item):
        '''
        Hosting a game event
        '''
        if not fa.exe.available():
            return

        self.stopSearchRanked()

        # A simple Hosting dialog.
        if fa.exe.check(item.mod):
            hostgamewidget = HostgameWidget(self, item)

            if hostgamewidget.exec_() == 1 :
                if self.gamename:
                    gameoptions = []

                    if len(self.options) != 0 :
                        oneChecked = False
                        for option in self.options :
                            if option.isChecked() :
                                oneChecked = True
                            gameoptions.append(option.isChecked())

                        if oneChecked == False :
                            QtGui.QMessageBox.warning(None, "No option checked !", "You have to check at least one option !")
                            return
                    modnames = [str(moditem.text()) for moditem in hostgamewidget.modList.selectedItems()]
                    mods = [hostgamewidget.mods[modstr] for modstr in modnames]
                    modvault.setActiveMods(mods, True) #should be removed later as it should be managed by the server.
#                #Send a message to the server with our intent.
                    if self.ispassworded:
                        self.client.send(dict(command="game_host", access="password", password = self.gamepassword, mod=item.mod, title=self.gamename, mapname=self.gamemap, gameport=self.client.gamePort, options = gameoptions))
                    else :
                        self.client.send(dict(command="game_host", access="public", mod=item.mod, title=self.gamename, mapname=self.gamemap, gameport=self.client.gamePort, options = gameoptions))
コード例 #2
0
ファイル: _gameswidget.py プロジェクト: Arkonen8/client
    def hostGameClicked(self, item):
        '''
        Hosting a game event
        '''
        self.load_last_hosted_settings()
        if not fa.instance.available():
            return

        self.stopSearchRanked()

        hostgamewidget = HostgameWidget(self, item)
        # Abort if the client cancelled the host game dialogue.
        if hostgamewidget.exec_() != 1 :
            return

        # Make sure the binaries are all up to date, and abort if the update fails or is cancelled.
        if not fa.check.game(self.client):
            return

        # Ensure all mods are up-to-date, and abort up if the update process fails.
        if not fa.check.check(item.mod):
            return

        modnames = [str(moditem.text()) for moditem in hostgamewidget.modList.selectedItems()]
        mods = [hostgamewidget.mods[modstr] for modstr in modnames]
        modvault.setActiveMods(mods, True) #should be removed later as it should be managed by the server.

        self.client.host_game(title=self.gamename,
                              mod=item.mod,
                              visibility="friends" if self.friends_only else "public",
                              mapname=self.gamemap,
                              password=self.gamepassword if self.ispassworded else None)
コード例 #3
0
ファイル: _coopwidget.py プロジェクト: Arkonen8/client
    def coopListDoubleClicked(self, item):
        '''
        Hosting a coop event
        '''
        if not hasattr(item, "mapUrl") :
            return
        
        if not fa.instance.available():
            return
            
        self.client.games.stopSearchRanked()
        self.gamemap = fa.maps.link2name(item.mapUrl)
        
        fa.check.map(self.gamemap, force=True)
        
        # A simple Hosting dialog.
        if fa.check.check("coop"):
            hostgamewidget = HostgameWidget(self, item)
            
            if hostgamewidget.exec_() == 1 :
                if self.gamename:
                    modnames = [str(moditem.text()) for moditem in hostgamewidget.modList.selectedItems()]
                    mods = [hostgamewidget.mods[modstr] for modstr in modnames]
                    modvault.setActiveMods(mods, True) #should be removed later as it should be managed by the server.
#                #Send a message to the server with our intent.
                    if self.ispassworded:
                        self.client.send(dict(command="game_host", access="password", password = self.gamepassword, mod=item.mod, title=self.gamename, mapname=self.gamemap, gameport=self.client.gamePort))
                    else :
                        self.client.send(dict(command="game_host", access="public", mod=item.mod, title=self.gamename, mapname=self.gamemap, gameport=self.client.gamePort))
コード例 #4
0
ファイル: _gameswidget.py プロジェクト: tenconamei/client
    def hostGameClicked(self, item):
        '''
        Hosting a game event
        '''
        if not fa.exe.available():
            return

        self.stopSearchRanked()

        # A simple Hosting dialog.
        if fa.exe.check(item.mod):
            hostgamewidget = HostgameWidget(self, item)

            if hostgamewidget.exec_() == 1:
                if self.gamename:
                    gameoptions = []

                    if len(self.options) != 0:
                        oneChecked = False
                        for option in self.options:
                            if option.isChecked():
                                oneChecked = True
                            gameoptions.append(option.isChecked())

                        if oneChecked == False:
                            QtGui.QMessageBox.warning(
                                None, "No option checked !",
                                "You have to check at least one option !")
                            return
                    modnames = [
                        str(moditem.text())
                        for moditem in hostgamewidget.modList.selectedItems()
                    ]
                    mods = [hostgamewidget.mods[modstr] for modstr in modnames]
                    modvault.setActiveMods(
                        mods, True
                    )  #should be removed later as it should be managed by the server.
                    #                #Send a message to the server with our intent.
                    if self.ispassworded:
                        self.client.send(
                            dict(command="game_host",
                                 access="password",
                                 password=self.gamepassword,
                                 mod=item.mod,
                                 title=self.gamename,
                                 mapname=self.gamemap,
                                 gameport=self.client.gamePort,
                                 options=gameoptions))
                    else:
                        self.client.send(
                            dict(command="game_host",
                                 access="public",
                                 mod=item.mod,
                                 title=self.gamename,
                                 mapname=self.gamemap,
                                 gameport=self.client.gamePort,
                                 options=gameoptions))
コード例 #5
0
ファイル: _coopwidget.py プロジェクト: wolfmic/client
    def coopListDoubleClicked(self, item):
        '''
        Hosting a coop event
        '''
        if not hasattr(item, "mapUrl"):
            return

        if not fa.instance.available():
            return

        self.client.games.stopSearchRanked()
        self.gamemap = fa.maps.link2name(item.mapUrl)

        fa.check.map(self.gamemap, force=True)

        # A simple Hosting dialog.
        if fa.check.check("coop"):
            hostgamewidget = HostgameWidget(self, item)

            if hostgamewidget.exec_() == 1:
                if self.gamename:
                    modnames = [
                        str(moditem.text())
                        for moditem in hostgamewidget.modList.selectedItems()
                    ]
                    mods = [hostgamewidget.mods[modstr] for modstr in modnames]
                    modvault.setActiveMods(
                        mods, True
                    )  #should be removed later as it should be managed by the server.
                    #                #Send a message to the server with our intent.
                    if self.ispassworded:
                        self.client.send(
                            dict(command="game_host",
                                 access="password",
                                 password=self.gamepassword,
                                 mod=item.mod,
                                 title=self.gamename,
                                 mapname=self.gamemap,
                                 gameport=self.client.gamePort))
                    else:
                        self.client.send(
                            dict(command="game_host",
                                 access="public",
                                 mod=item.mod,
                                 title=self.gamename,
                                 mapname=self.gamemap,
                                 gameport=self.client.gamePort))
コード例 #6
0
ファイル: mods.py プロジェクト: GrotheFAF/client
def checkMods(mods):  # mods is a dictionary of uid-name pairs
    """
    Assures that the specified mods are available in FA, or returns False.
    Also sets the correct active mods in the ingame mod manager.
    """
    logger.info("Updating FA for mods %s" % ", ".join(mods))
    to_download = []
    inst = modvault.getInstalledMods()
    uids = [mod.uid for mod in inst]
    for uid in mods:
        if uid not in uids:
            to_download.append(uid)

    auto = config.Settings.get('mods/autodownload', default=False, type=bool)
    if not auto:
        mod_names = ", ".join([mods[uid] for uid in mods])
        msgbox = QtWidgets.QMessageBox()
        msgbox.setWindowTitle("Download Mod")
        msgbox.setText(
            "Seems that you don't have mods used in this game. Do you want to download them?<br/><b>"
            + mod_names + "</b>")
        msgbox.setInformativeText(
            "If you respond 'Yes to All' mods will be downloaded automatically in the future"
        )
        msgbox.setStandardButtons(QtWidgets.QMessageBox.Yes
                                  | QtWidgets.QMessageBox.YesToAll
                                  | QtWidgets.QMessageBox.No)
        result = msgbox.exec_()
        if result == QtWidgets.QMessageBox.No:
            return False
        elif result == QtWidgets.QMessageBox.YesToAll:
            config.Settings.set('mods/autodownload', True)

    for uid in to_download:
        # Spawn an update for the required mod
        updater = fa.updater.Updater(uid, sim=True)
        result = updater.run()
        if result != fa.updater.Updater.RESULT_SUCCESS:
            logger.warning("Failure getting {}: {}".format(uid, mods[uid]))
            return False

    actual_mods = []
    inst = modvault.getInstalledMods()
    uids = {}
    for mod in inst:
        uids[mod.uid] = mod
    for uid in mods:
        if uid not in uids:
            QtWidgets.QMessageBox.warning(
                None, "Mod not Found",
                "%s was apparently not installed correctly. Please check this."
                % mods[uid])
            return
        actual_mods.append(uids[uid])
    if not modvault.setActiveMods(actual_mods):
        logger.warning("Couldn't set the active mods in the game.prefs file")
        return False

    return True
コード例 #7
0
ファイル: uimodwidget.py プロジェクト: GrotheFAF/client
 def doneClicked(self):
     selected_mods = [
         self.uimods[str(item.text())]
         for item in self.modList.selectedItems()
     ]
     succes = modvault.setActiveMods(selected_mods, False)
     if not succes:
         QtWidgets.QMessageBox.information(
             None, "Error",
             "Could not set the active UI mods. Maybe something is "
             "wrong with your game.prefs file. Please send your log.")
     self.done(1)
コード例 #8
0
ファイル: _gameswidget.py プロジェクト: wolfmic/client
    def hostGameClicked(self, item):
        '''
        Hosting a game event
        '''
        self.load_last_hosted_settings()
        if not fa.instance.available():
            return

        self.stopSearchRanked()

        hostgamewidget = HostgameWidget(self, item)
        # Abort if the client cancelled the host game dialogue.
        if hostgamewidget.exec_() != 1:
            return

        # Make sure the binaries are all up to date, and abort if the update fails or is cancelled.
        if not fa.check.game(self.client):
            return

        # Ensure all mods are up-to-date, and abort up if the update process fails.
        if not fa.check.check(item.mod):
            return

        modnames = [
            str(moditem.text())
            for moditem in hostgamewidget.modList.selectedItems()
        ]
        mods = [hostgamewidget.mods[modstr] for modstr in modnames]
        modvault.setActiveMods(
            mods, True
        )  #should be removed later as it should be managed by the server.

        self.client.host_game(
            title=self.gamename,
            mod=item.mod,
            visibility="friends" if self.friends_only else "public",
            mapname=self.gamemap,
            password=self.gamepassword if self.ispassworded else None)
コード例 #9
0
ファイル: mods.py プロジェクト: speed2CZ/client
def checkMods(mods):  #mods is a dictionary of uid-name pairs
    """
    Assures that the specified mods are available in FA, or returns False.
    Also sets the correct active mods in the ingame mod manager.
    """
    logger.info("Updating FA for mods %s" % ", ".join(mods))
    to_download = []
    inst = modvault.getInstalledMods()
    uids = [mod.uid for mod in inst]
    for uid in mods:
        if uid not in uids:
            to_download.append(uid)

    for uid in to_download:
        result = QtGui.QMessageBox.question(
            None, "Download Mod",
            "Seems that you don't have this mod. Do you want to download it?<br/><b>"
            + mods[uid] + "</b>", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
        if result == QtGui.QMessageBox.Yes:
            # Spawn an update for the required mod
            updater = fa.updater.Updater(uid, sim=True)
            result = updater.run()
            updater = None  #Our work here is done
            if (result != fa.updater.Updater.RESULT_SUCCESS):
                return False
        else:
            return False

    actual_mods = []
    inst = modvault.getInstalledMods()
    uids = {}
    for mod in inst:
        uids[mod.uid] = mod
    for uid in mods:
        if uid not in uids:
            QtGui.QMessageBox.warning(
                None, "Mod not Found",
                "%s was apparently not installed correctly. Please check this."
                % mods[uid])
            return
        actual_mods.append(uids[uid])
    if not modvault.setActiveMods(actual_mods):
        logger.warn("Couldn't set the active mods in the game.prefs file")
        return False

    return True
コード例 #10
0
ファイル: mods.py プロジェクト: Arkonen8/client
def checkMods(mods):  #mods is a dictionary of uid-name pairs
    """
    Assures that the specified mods are available in FA, or returns False.
    Also sets the correct active mods in the ingame mod manager.
    """
    logger.info("Updating FA for mods %s" % ", ".join(mods))
    to_download = []
    inst = modvault.getInstalledMods()
    uids = [mod.uid for mod in inst]
    for uid in mods:
        if uid not in uids:
            to_download.append(uid)

    for uid in to_download:
        result = QtGui.QMessageBox.question(None, "Download Mod",
                                            "Seems that you don't have this mod. Do you want to download it?<br/><b>" +
                                            mods[uid] + "</b>", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
        if result == QtGui.QMessageBox.Yes:
            # Spawn an update for the required mod
            updater = fa.updater.Updater(uid, sim=True)
            result = updater.run()
            updater = None  #Our work here is done
            if (result != fa.updater.Updater.RESULT_SUCCESS):
                return False
        else:
            return False

    actual_mods = []
    inst = modvault.getInstalledMods()
    uids = {}
    for mod in inst:
        uids[mod.uid] = mod
    for uid in mods:
        if uid not in uids:
            QtGui.QMessageBox.warning(None, "Mod not Found",
                                      "%s was apparently not installed correctly. Please check this." % mods[uid])
            return
        actual_mods.append(uids[uid])
    if not modvault.setActiveMods(actual_mods):
        logger.warn("Couldn't set the active mods in the game.prefs file")
        return False

    return True
コード例 #11
0
ファイル: uimodwidget.py プロジェクト: AThorley/lobby
 def doneClicked(self):
     selected_mods = [self.uimods[str(item.text())] for item in self.modList.selectedItems()]
     succes = modvault.setActiveMods(selected_mods, False)
     if not succes:
         QtGui.QMessageBox.information(None, "Error", "Could not set the active UI mods. Maybe something is wrong with your game.prefs file. Please send your log.")
     self.done(1)