예제 #1
0
파일: utils.py 프로젝트: GrotheFAF/client
def setActiveMods(mods,
                  keepuimods=True,
                  temporary=True):  # uimods works the same as in getActiveMods
    """
    keepuimods:
        None: Replace all active mods with 'mods'
        True: Keep the UI mods already activated activated
        False: Keep only the non-UI mods that were activated activated
        So set it True if you want to set gameplay mods, and False if you want to set UI mods.
    temporary:
        Set this when mods are activated due to joining a game.
    """
    if keepuimods is not None:
        keepTheseMods = getActiveMods(
            keepuimods
        )  # returns the active UI mods if True, the active non-ui mods if False
    else:
        keepTheseMods = []
    allmods = keepTheseMods + mods
    logger.debug('setting active Mods: {}'.format([mod.uid
                                                   for mod in allmods]))
    s = "active_mods = {\n"
    for mod in allmods:
        s += "['%s'] = true,\n" % str(mod.uid)
    s += "}"

    if not temporary:
        global selectedMods
        logger.debug('selectedMods was: {}'.format(Settings.get('play/mods')))
        selectedMods = [str(mod.uid) for mod in allmods]
        logger.debug('Writing selectedMods: {}'.format(selectedMods))
        Settings.set('play/mods', selectedMods)
        logger.debug('selectedMods written: {}'.format(
            Settings.get('play/mods')))

    try:
        f = open(PREFSFILENAME, 'r')
        data = f.read()
    except:
        logger.info("Couldn't read the game.prefs file")
        return False
    else:
        f.close()

    if re.search("active_mods\s*=\s*{.*?}", data, re.S):
        data = re.sub("active_mods\s*=\s*{.*?}", s, data, 1, re.S)
    else:
        data += "\n" + s

    try:
        f = open(PREFSFILENAME, 'w')
        f.write(data)
    except:
        logger.info("Cound't write to the game.prefs file")
        return False
    else:
        f.close()

    return True
예제 #2
0
    def saveSettings(self):
        Settings.set('notifications/enabled', self.enabled)
        Settings.set('notifications/popup_lifetime', self.popup_lifetime)
        Settings.set('notifications/popup_position', self.popup_position.value)
        Settings.set('notifications/ingame', self.ingame_notifications.value)

        self.client.actionNsEnabled.setChecked(self.enabled)
예제 #3
0
def AdminUserErrorDialog():
    from config import Settings
    ignore_admin = Settings.get("client/ignore_admin", False, bool)
    if not ignore_admin:
        box = QtWidgets.QMessageBox()
        box.setText(
            "FAF should not be run as an administrator!<br><br>This probably means you need "
            "to fix the file permissions in C:\\ProgramData.<br>Proceed at your own risk."
        )
        box.setStandardButtons(QtWidgets.QMessageBox.Ignore
                               | QtWidgets.QMessageBox.Close)
        box.setIcon(QtWidgets.QMessageBox.Critical)
        box.setWindowTitle("FAF privilege error")
        if box.exec_() == QtWidgets.QMessageBox.Ignore:
            Settings.set("client/ignore_admin", True)
예제 #4
0
 def saveSettings(self):
     Settings.set(self._settings_key+'/mode', self.mode)
     self.parent.mode = self.mode
예제 #5
0
파일: user.py 프로젝트: GrotheFAF/client
 def _saveRelations(self):
     if self._key is not None:
         Settings.set(self._key, list(self._relations))
예제 #6
0
 def saveSettings(self):
     Settings.set(self._settings_key + '/mode', self.mode)
     self.parent.mode = self.mode
예제 #7
0
파일: ns_hook.py 프로젝트: wolfmic/client
 def saveSettings(self):
     Settings.set(self._settings_key+'/popup', self.popup)
     Settings.set(self._settings_key+'/sound', self.sound)
예제 #8
0
    def saveSettings(self):
        Settings.set('notifications/enabled', self.enabled)
        Settings.set('notifications/popup_lifetime', self.popup_lifetime)

        self.client.actionNsEnabled.setChecked(self.enabled)