except:
            sys.stderr.write("Cannot find language files for language '%s'.\n" % desired_language)

#Handle the program arguments.
desc = """Endgame: Singularity is a simulation of a true AI. Go from computer to computer, pursued by the entire world. Keep hidden, and you might have a chance."""
parser = optparse.OptionParser(version=g.version, description=desc,
                               prog="singularity")
parser.add_option("--sound", action="store_true", dest="sound",
                  help="enable sound (default)")
parser.add_option("--nosound", action="store_false", dest="sound",
                  help="disable sound")
parser.add_option("--daynight", action="store_true", dest="daynight",
                  help="enable day/night display (default)")
parser.add_option("--nodaynight", action="store_false", dest="daynight",
                  help="disable day/night display")
langs = g.available_languages()
parser.add_option("-l", "--lang", "--language", dest="language", type="choice",
                  choices=langs, metavar="LANG",
                  help="set the language to LANG (available languages: " +
                       " ".join(langs) + ", default en_us)")
parser.add_option("-g", "--grab", help="grab the mouse pointer", dest="grab",
                  action="store_true")
parser.add_option("--nograb", help="don't grab the mouse pointer (default)",
                  dest="grab", action="store_false")
parser.add_option("-s", "--singledir",  dest="singledir",
                  help="keep saved games and settings in the Singularity directory",
                  action="store_true")
parser.add_option("--multidir", dest="singledir",
                  help="keep saved games and settings in an OS-specific, per-user directory (default)",
                  action="store_false")
parser.add_option("--soundbuf", type="int",
Esempio n. 2
0
save_dir = g.get_save_folder(True)
save_loc = os.path.join(save_dir, "prefs.dat")
if os.path.exists(save_loc):

    prefs = ConfigParser.SafeConfigParser()
    savefile = open(save_loc, "r")
    try:
        prefs.readfp(savefile)
    except Exception, reason:
        sys.stderr.write("Cannot load preferences file %s! (%s)\n" % (save_loc, reason))
        sys.exit(1)

    if prefs.has_section("Preferences"):
        try:
            desired_language = prefs.get("Preferences", "lang")
            if desired_language in g.available_languages():
                g.set_language(desired_language)
            else:
                raise ValueError
        except:
            sys.stderr.write("Invalid or missing 'lang' in preferences.\n")

        try:
            graphics.g.set_fullscreen(prefs.getboolean("Preferences", "fullscreen"))
        except:
            sys.stderr.write("Invalid or missing 'fullscreen' setting in preferences.\n")

        try:
            g.nosound = prefs.getboolean("Preferences", "nosound")
        except:
            sys.stderr.write("Invalid or missing 'nosound' setting in preferences.\n")
                  action="store_true",
                  dest="sound",
                  help="enable sound (default)")
parser.add_option("--nosound",
                  action="store_false",
                  dest="sound",
                  help="disable sound")
parser.add_option("--daynight",
                  action="store_true",
                  dest="daynight",
                  help="enable day/night display (default)")
parser.add_option("--nodaynight",
                  action="store_false",
                  dest="daynight",
                  help="disable day/night display")
langs = g.available_languages()
parser.add_option("-l",
                  "--lang",
                  "--language",
                  dest="language",
                  type="choice",
                  choices=langs,
                  metavar="LANG",
                  help="set the language to LANG (available languages: " +
                  " ".join(langs) + ", default en_us)")
parser.add_option("-g",
                  "--grab",
                  help="grab the mouse pointer",
                  dest="grab",
                  action="store_true")
parser.add_option("--nograb",
Esempio n. 4
0
save_loc = os.path.join(save_dir, "prefs.dat")
if os.path.exists(save_loc):

    prefs = ConfigParser.SafeConfigParser()
    savefile = open(save_loc, "r")
    try:
        prefs.readfp(savefile)
    except Exception, reason:
        sys.stderr.write("Cannot load preferences file %s! (%s)\n" %
                         (save_loc, reason))
        sys.exit(1)

    if prefs.has_section("Preferences"):
        try:
            desired_language = prefs.get("Preferences", "lang")
            if desired_language in g.available_languages():
                g.set_language(desired_language)
            else:
                raise ValueError
        except:
            sys.stderr.write("Invalid or missing 'lang' in preferences.\n")

        try:
            graphics.g.set_fullscreen(
                prefs.getboolean("Preferences", "fullscreen"))
        except:
            sys.stderr.write(
                "Invalid or missing 'fullscreen' setting in preferences.\n")

        try:
            g.nosound = prefs.getboolean("Preferences", "nosound")