Ejemplo n.º 1
0
def save_options():
    # Build a ConfigParser for writing the various preferences out.
    prefs = SafeConfigParser()
    prefs.add_section("Preferences")
    prefs.set("Preferences", "fullscreen",   str(bool(gg.fullscreen)))
    prefs.set("Preferences", "nosound",      str(bool(mixer.nosound)))
    prefs.set("Preferences", "grab",         str(bool(pygame.event.get_grab())))
    prefs.set("Preferences", "daynight",     str(bool(g.daynight)))
    prefs.set("Preferences", "xres",         str(int(gg.screen_size[0])))
    prefs.set("Preferences", "yres",         str(int(gg.screen_size[1])))
    prefs.set("Preferences", "soundbuf",     str(mixer.get_soundbuf()))
    prefs.set("Preferences", "lang",         str(i18n.language))
    prefs.set("Preferences", "theme",        str(theme.current.id))

    for name in mixer.itervolumes():
        prefs.set("Preferences", name + "_volume", str(mixer.get_volume(name)))

    prefs.add_section("Warning")
    for warn_id, warn in warning.warnings.items():
        prefs.set("Warning", warn_id, str(bool(warn.active)))

    # Actually write the preferences out.
    save_loc = dirs.get_writable_file_in_dirs("prefs.dat", "pref")
    savefile = open(save_loc, 'w')
    prefs.write(savefile)
    savefile.close()
Ejemplo n.º 2
0
def savegame_exists(savegame_name):
    save_path = dirs.get_writable_file_in_dirs(savegame_name + ".s2", "saves")

    if (save_path is None
            or not os.path.isfile(convert_string_to_path_name(save_path))):
        return False

    return True
Ejemplo n.º 3
0
def create_savegame(savegame_name):
    global default_savegame_name
    default_savegame_name = savegame_name
    save_loc = convert_string_to_path_name(
        dirs.get_writable_file_in_dirs(savegame_name + ".s2", "saves"))
    # Save in new "JSONish" format
    with open(save_loc, 'wb') as savefile:
        gzipped = not g.debug
        write_game_to_fd(savefile, gzipped=gzipped)
Ejemplo n.º 4
0
def save_options():
    # Build a ConfigParser for writing the various preferences out.
    prefs = ConfigParser.SafeConfigParser()
    prefs.add_section("Preferences")
    prefs.set("Preferences", "fullscreen", str(bool(gg.fullscreen)))
    prefs.set("Preferences", "nosound", str(bool(g.nosound)))
    prefs.set("Preferences", "grab", str(bool(pygame.event.get_grab())))
    prefs.set("Preferences", "daynight", str(bool(g.daynight)))
    prefs.set("Preferences", "xres", str(int(gg.screen_size[0])))
    prefs.set("Preferences", "yres", str(int(gg.screen_size[1])))
    prefs.set("Preferences", "soundbuf", str(int(g.soundbuf)))
    prefs.set("Preferences", "lang", str(g.language))
    prefs.set("Preferences", "theme", str(theme.current.id))

    # Actually write the preferences out.
    save_loc = dirs.get_writable_file_in_dirs("prefs.dat", "pref")
    savefile = open(save_loc, 'w')
    prefs.write(savefile)
    savefile.close()
Ejemplo n.º 5
0
def save_options():
    # Build a ConfigParser for writing the various preferences out.
    prefs = ConfigParser.SafeConfigParser()
    prefs.add_section("Preferences")
    prefs.set("Preferences", "fullscreen",   str(bool(gg.fullscreen)))
    prefs.set("Preferences", "nosound",      str(bool(mixer.nosound)))
    prefs.set("Preferences", "grab",         str(bool(pygame.event.get_grab())))
    prefs.set("Preferences", "daynight",     str(bool(g.daynight)))
    prefs.set("Preferences", "xres",         str(int(gg.screen_size[0])))
    prefs.set("Preferences", "yres",         str(int(gg.screen_size[1])))
    prefs.set("Preferences", "soundbuf",     str(int(mixer.soundbuf)))
    prefs.set("Preferences", "lang",         str(i18n.language))
    prefs.set("Preferences", "theme",        str(theme.current.id))

    for name, value in mixer.soundvolumes.iteritems():
        prefs.set("Preferences", name + "_volume", str(value))

    # Actually write the preferences out.
    save_loc = dirs.get_writable_file_in_dirs("prefs.dat", "pref")
    savefile = open(save_loc, 'w')
    prefs.write(savefile)
    savefile.close()
Ejemplo n.º 6
0
    raise SystemExit("Endgame: Singularity requires NumPy.")
except ImportError:
    raise SystemExit("Endgame: Singularity requires pygame.")

import os.path
import optparse
import logging

from code.pycompat import *
import code.graphics.g as gg
import code.graphics.theme as theme

set_theme = None

#configure global logger
g.logfile = dirs.get_writable_file_in_dirs("error.log", "log")

if len(logging.getLogger().handlers) == 0:
    try:
        logging.getLogger().addHandler(logging.FileHandler(g.logfile, delay=True))
    except TypeError: # Python < 2.6, delay not supported yet.
        try:
            logging.getLogger().addHandler(logging.FileHandler(g.logfile))
        except IOError: # Probably access denied with --singledir. That's ok
            g.logfile = None

# keep g's defaults intact so we can compare after parsing options and prefs
from code import mixer, warning
desired_soundbuf = mixer.soundbuf

desired_set_grab = None