Ejemplo n.º 1
0
  raise SystemExit("Endgame: Singularity requires pygame.")

import sys
import ConfigParser
import os.path
import optparse

import g, graphics.g
from screens import main_menu, map

pygame.init()
pygame.font.init()
pygame.key.set_repeat(1000, 50)

#load prefs from file:
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:
            if prefs.getboolean("Preferences", "fullscreen"):
                graphics.g.fullscreen = pygame.FULLSCREEN
Ejemplo n.º 2
0
pygame.mixer.pre_init(*g.soundargs, buffer=g.soundbuf)
pygame.init()
#pygame.mixer.quit()  # simulate mixer init failure (eg, no soundcard available)
g.mixerinit = bool(pygame.mixer.get_init())
pygame.font.init()
pygame.key.set_repeat(1000, 50)

# Manually "pre-parse" command line arguments for -s|--singledir and --multidir,
# so g.get_save_folder reports the correct location of preferences file
for parser in sys.argv[1:]:
    if parser == "--singledir" or parser == "-s": g.force_single_dir = True
    if parser == "--multidir"                   : g.force_single_dir = False

#configure global logger
logfile = os.path.join(g.get_save_folder(True), "error.log")
if len(logging.getLogger().handlers) == 0:
    try:
        logging.getLogger().addHandler(logging.FileHandler(logfile, delay=True))
    except TypeError: # Python < 2.6, delay not supported yet.
        try:
            logging.getLogger().addHandler(logging.FileHandler(logfile))
        except IOError: # Probably access denied with --singledir. That's ok
            pass

# keep g's defaults intact so we can compare after parsing options and prefs
desired_soundbuf = g.soundbuf

#load prefs from file:
save_dir = g.get_save_folder(True)
save_loc = os.path.join(save_dir, "prefs.dat")
Ejemplo n.º 3
0
    raise SystemExit("Endgame: Singularity requires pygame.")

import sys
import ConfigParser
import os.path
import optparse

import g, graphics.g
from screens import main_menu, map

pygame.init()
pygame.font.init()
pygame.key.set_repeat(1000, 50)

#load prefs from file:
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:
            if prefs.getboolean("Preferences", "fullscreen"):
Ejemplo n.º 4
0
pygame.mixer.pre_init(*g.soundargs, buffer=g.soundbuf)
pygame.init()
#pygame.mixer.quit()  # simulate mixer init failure (eg, no soundcard available)
g.mixerinit = bool(pygame.mixer.get_init())
pygame.font.init()
pygame.key.set_repeat(1000, 50)

# Manually "pre-parse" command line arguments for -s|--singledir and --multidir,
# so g.get_save_folder reports the correct location of preferences file
for parser in sys.argv[1:]:
    if parser == "--singledir" or parser == "-s": g.force_single_dir = True
    if parser == "--multidir": g.force_single_dir = False

#configure global logger
logfile = os.path.join(g.get_save_folder(True), "error.log")
if len(logging.getLogger().handlers) == 0:
    try:
        logging.getLogger().addHandler(logging.FileHandler(logfile,
                                                           delay=True))
    except TypeError:  # Python < 2.6, delay not supported yet.
        try:
            logging.getLogger().addHandler(logging.FileHandler(logfile))
        except IOError:  # Probably access denied with --singledir. That's ok
            pass

# keep g's defaults intact so we can compare after parsing options and prefs
desired_soundbuf = g.soundbuf

#load prefs from file:
save_dir = g.get_save_folder(True)