Exemplo n.º 1
0
    def __init__(self, prototype, fileName = None, type = 0):
        """
        @param prototype:  The configuration prototype mapping
        @param fileName:   The file that holds this configuration registry
        """
        self.prototype = prototype

        # read configuration
        self.config = MyConfigParser()

        if fileName:
            if not os.path.isfile(fileName):
                path = VFS.getWritableResourcePath()
                fileName = os.path.join(path, fileName)
            self.config.read(fileName)

        self.fileName  = fileName
        self.type = type

        # fix the defaults and non-existing keys
        for section, options in prototype.items():
            if not self.config.has_section(section):
                self.config.add_section(section)
            for option in options.keys():
                type    = options[option].type
                default = options[option].default
                if not self.config.has_option(section, option):
                    self.config.set(section, option, str(default))
Exemplo n.º 2
0
        if opt in ["--song", "-s"]:
            playing = arg
        if opt in ["--part", "-p"]:
            part = arg
        if opt in ["--diff", "-d", "-l"]:
            difficulty = arg
        #evilynux - Multiplayer and mode selection support
        if opt in ["--mode", "-m"]:
            mode = int(arg)
        if opt in ["--nbrplayers", "-n"]:
            nbrplayers = int(arg)

    # Load the configuration file.
    if configFile is not None:
        if configFile.lower() == "reset":
            fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNIXSTYLE_NAME + ".ini")
            os.remove(fileName)
            config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        else:
            config = Config.load(configFile, setAsDefault = True)
    else:
        config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)

    #Lysdestic - Allow support for manipulating fullscreen via CLI
    if fullscreen is not None:
        Config.set("video", "fullscreen", fullscreen)

    #Lysdestic - Change resolution from CLI
    if resolution is not None:
        Config.set("video", "resolution", resolution)