本文整理汇总了Python中fofix.core.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetAllSoundFxObjectVolumes
def SetAllSoundFxObjectVolumes(self, volume = None): #MFH - single function to go through all sound objects (and iterate through all sound lists) and set object volume to the given volume
#MFH TODO - set every sound object's volume here...
if volume is None:
self.sfxVolume = Config.get("audio", "SFX_volume")
self.crowdVolume = Config.get("audio", "crowd_volume")
volume = self.sfxVolume
self.starDingSound.setVolume(volume)
self.bassDrumSound.setVolume(volume)
self.T1DrumSound.setVolume(volume)
self.T2DrumSound.setVolume(volume)
self.T3DrumSound.setVolume(volume)
self.CDrumSound.setVolume(volume)
for s in self.acceptSounds:
s.setVolume(volume)
for s in self.cancelSounds:
s.setVolume(volume)
self.rockSound.setVolume(volume)
self.starDeActivateSound.setVolume(volume)
self.starActivateSound.setVolume(volume)
self.battleUsedSound.setVolume(volume)
self.rescueSound.setVolume(volume)
self.coOpFailSound.setVolume(volume)
self.crowdSound.setVolume(self.crowdVolume)
self.starReadySound.setVolume(volume)
self.clapSound.setVolume(volume)
self.failSound.setVolume(volume)
self.starSound.setVolume(volume)
self.startSound.setVolume(volume)
self.selectSound1.setVolume(volume)
self.selectSound2.setVolume(volume)
self.selectSound3.setVolume(volume)
示例2: init
def init(engine):
# define configuration keys for all available mods
for m in getAvailableMods(engine):
Config.define("mods", "mod_" + m, bool, False, text = m, options = {False: _("Off"), True: _("On")})
# init all active mods
for m in getActiveMods(engine):
activateMod(engine, m)
示例3: init_oneshot
def init_oneshot(self):
""" Determine if oneshot mode is valid. """
# I think this code can be moved elsewhere...
self.engine.cmdPlay = 0
# Check for a valid invocation of one-shot mode.
if self.playing is not None:
Log.debug("Validating song directory for one-shot mode.")
library = Config.get("setlist", "base_library")
basefolder = os.path.join(Version.dataPath(), library, "songs", self.playing)
if not os.path.exists(os.path.join(basefolder, "song.ini")):
if not (
os.path.exists(os.path.join(basefolder, "notes.mid"))
or os.path.exists(os.path.join(basefolder, "notes-unedited.mid"))
):
if not (
os.path.exists(os.path.join(basefolder, "song.ogg"))
or os.path.exists(os.path.join(basefolder, "guitar.ogg"))
):
Log.warn(
"Song directory provided ('%s') is not a valid song directory. Starting up FoFiX in standard mode."
% self.playing
)
self.engine.startupMessages.append(
_(
"Song directory provided ('%s') is not a valid song directory. Starting up FoFiX in standard mode."
)
% self.playing
)
return
# Set up one-shot mode
Log.debug("Entering one-shot mode.")
Config.set("setlist", "selected_song", playing)
self.engine.cmdPlay = 1
if diff is not None:
self.engine.cmdDiff = int(diff)
if part is not None:
self.engine.cmdPart = int(part)
if players == 1:
self.engine.cmdMode = players, mode, 0
else:
self.engine.cmdMode = players, 0, mode
示例4: loadControls
def loadControls():
global controllerDict
controllers = []
allcontrollers = VFS.listdir(controlpath)
default = ["defaultd.ini", "defaultg.ini", "defaultm.ini"]
for name in allcontrollers:
if name.lower().endswith(".ini") and len(name) > 4:
if name in default:
continue
controllers.append(name[0:len(name)-4])
i = len(controllers)
controllerDict = dict([(str(controllers[n]),controllers[n]) for n in range(0, i)])
controllerDict["defaultg"] = _("Default Guitar")
controllerDict["defaultd"] = _("Default Drum")
defMic = None
if Microphone.supported:
controllerDict["defaultm"] = _("Default Microphone")
defMic = "defaultm"
tsControl = _("Controller %d")
tsControlTip = _("Select the controller for slot %d")
i = 1
Config.define("game", "control0", str, "defaultg", text = tsControl % 1, options = controllerDict, tipText = tsControlTip % 1)
controllerDict[_("None")] = None
Config.define("game", "control1", str, "defaultd", text = tsControl % 2, options = controllerDict, tipText = tsControlTip % 2)
Config.define("game", "control2", str, defMic, text = tsControl % 3, options = controllerDict, tipText = tsControlTip % 3)
Config.define("game", "control3", str, None, text = tsControl % 4, options = controllerDict, tipText = tsControlTip % 4)
示例5: setPriority
def setPriority(self, pid = None, priority = 2):
""" Set The Priority of a Windows Process. Priority is a value between 0-5 where
2 is normal priority. Default sets the priority of the current
python process but can take any valid process ID. """
import win32api, win32process, win32con
priorityClasses = [win32process.IDLE_PRIORITY_CLASS,
win32process.BELOW_NORMAL_PRIORITY_CLASS,
win32process.NORMAL_PRIORITY_CLASS,
win32process.ABOVE_NORMAL_PRIORITY_CLASS,
win32process.HIGH_PRIORITY_CLASS,
win32process.REALTIME_PRIORITY_CLASS]
threadPriorities = [win32process.THREAD_PRIORITY_IDLE,
#win32process.THREAD_PRIORITY_ABOVE_IDLE,
#win32process.THREAD_PRIORITY_LOWEST,
win32process.THREAD_PRIORITY_BELOW_NORMAL,
win32process.THREAD_PRIORITY_NORMAL,
win32process.THREAD_PRIORITY_ABOVE_NORMAL,
win32process.THREAD_PRIORITY_HIGHEST,
win32process.THREAD_PRIORITY_TIME_CRITICAL]
pid = win32api.GetCurrentProcessId()
tid = win32api.GetCurrentThread()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, priorityClasses[priority])
win32process.SetThreadPriority(tid, threadPriorities[priority])
if Config.get('performance', 'restrict_to_first_processor'):
win32process.SetProcessAffinityMask(handle, 1)
示例6: setUp
def setUp(self):
# set config file
config_file = Version.PROGRAM_UNIXSTYLE_NAME + ".ini"
self.config = Config.load(config_file, setAsDefault=True)
# init the game engine
self.engine = GameEngine(self.config)
示例7: activateMod
def activateMod(engine, modName):
modPath = _getModPath(engine)
m = os.path.join(modPath, modName)
t = os.path.join(m, "theme.ini")
if os.path.isdir(m):
engine.resource.addDataPath(m)
if os.path.isfile(t):
theme = Config.load(t)
Theme.open(theme)
示例8: load_config
def load_config(configPath):
''' Load the configuration file. '''
if configPath is not None:
if configPath.lower() == "reset":
# Get os specific location of config file, and remove it.
fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNIXSTYLE_NAME + ".ini")
os.remove(fileName)
# Recreate it
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
else:
# Load specified config file
config = Config.load(configPath, setAsDefault = True)
else:
# Use default configuration file
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
return config
示例9: __init__
def __init__(self, dataPath = os.path.join("..", "data")):
self.resultQueue = Queue()
self.dataPaths = [dataPath]
self.loaderSemaphore = BoundedSemaphore(value = 1)
self.loaders = []
#myfingershurt: the following should be global, and only done at startup. Not every damn time a file is loaded.
self.songPath = []
self.baseLibrary = Config.get("setlist", "base_library")
#evilynux - Support for songs in ~/.fretsonfire/songs (GNU/Linux and MacOS X)
if self.baseLibrary == "None" and os.name == "posix":
path = os.path.expanduser("~/." + Version.PROGRAM_UNIXSTYLE_NAME)
if os.path.isdir(path):
self.baseLibrary = path
Config.set("setlist", "base_library", path)
if self.baseLibrary and os.path.isdir(self.baseLibrary):
self.songPath = [self.baseLibrary]
self.logLoadings = Config.get("game", "log_loadings")
示例10: run
def run(self):
self.semaphore.acquire()
game_priority = Config.get("performance", "game_priority")
# Reduce priority on posix
if os.name == "posix":
# evilynux - Beware, os.nice _decreases_ priority, hence the reverse logic
os.nice(5 - game_priority)
elif os.name == "nt":
self.setPriority(priority = game_priority)
self.load()
self.semaphore.release()
self.resultQueue.put(self)
示例11: __init__
def __init__(self):
global args
self.args = args
self.playing = self.args['song']
self.configFile = self.args['config']
self.fullscreen = self.args['fullscreen']
self.resolution = self.args['resolution']
self.theme = self.args['theme']
self.diff = self.args['diff']
self.part = self.args['part']
self.mode = self.args['mode']
self.players = self.args['players']
self.config = self.load_config(self.configFile)
#Lysdestic - Allow support for manipulating fullscreen via CLI
if self.fullscreen is not None:
Config.set("video", "fullscreen", self.fullscreen)
#Lysdestic - Change resolution from CLI
if self.resolution is not None:
Config.set("video", "resolution", self.resolution)
#Lysdestic - Alter theme from CLI
if self.theme is not None:
Config.set("coffee", "themename", self.theme)
self.engine = GameEngine(self.config)
self.init_oneshot()
self.videoLayer = False
self.restartRequested = False
示例12: __init__
def __init__(self):
# get args
self.args = _cmd_args
self.configFile = self.args['config']
self.fullscreen = self.args['fullscreen']
self.resolution = self.args['resolution']
self.theme = self.args['theme']
# load config
self.config = self.load_config(self.configFile)
# allow support for manipulating fullscreen via CLI
if self.fullscreen is not None:
Config.set("video", "fullscreen", self.fullscreen)
# change resolution from CLI
if self.resolution is not None:
Config.set("video", "resolution", self.resolution)
# alter theme from CLI
if self.theme is not None:
Config.set("coffee", "themename", self.theme)
self.engine = GameEngine(self.config)
self.videoLayer = False
self.restartRequested = False
示例13: __init__
def __init__(self, name, number):
self.logClassInits = Config.get("game", "log_class_inits")
if self.logClassInits == 1:
log.debug("Player class init (Player.py)...")
self.name = name
self.reset()
self.keyList = None
self.progressKeys = []
self.drums = []
self.keys = []
self.soloKeys = []
self.soloShift = None
self.soloSlide = False
self.actions = []
self.yes = []
self.no = []
self.conf = []
self.up = []
self.down = []
self.left = []
self.right = []
self.controller = -1
self.controlType = -1
self.guitarNum = None
self.number = number
self.bassGrooveEnabled = False
self.currentTheme = 1
self.lefty = _playerDB.execute('SELECT `lefty` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.twoChordMax = _playerDB.execute('SELECT `twochord` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.drumflip = _playerDB.execute('SELECT `drumflip` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.assistMode = _playerDB.execute('SELECT `assist` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.autoKick = _playerDB.execute('SELECT `autokick` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.neck = _playerDB.execute('SELECT `neck` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.neckType = _playerDB.execute('SELECT `necktype` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self.whichPart = _playerDB.execute('SELECT `part` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self._upname = _playerDB.execute('SELECT `upname` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
self._difficulty = _playerDB.execute('SELECT `difficulty` FROM `players` WHERE `name` = ?', [self.name]).fetchone()[0]
#MFH - need to store selected practice mode and start position here
self.practiceMode = False
self.practiceSpeed = 1.0
self.practiceSection = None
self.startPos = 0.0
self.hopoFreq = None
示例14: setUp
def setUp(self):
# set config file
config_file = Version.PROGRAM_UNIXSTYLE_NAME + ".ini"
self.config = Config.load(config_file, setAsDefault=True)
# set choices
choices = [
("Choice 1", my_callback),
]
# init the engine
engine = GameEngine(self.config)
# init the menu
self.menu = Menu(engine, choices)
示例15: savePlayers
def savePlayers():
for pref in _playerDB.execute('SELECT * FROM `players` WHERE `changed` = 1').fetchall():
try:
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
except:
c = VFS.open(_makePlayerIniName(str(pref[0])), "w")
c.close()
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
_playerDB.execute('UPDATE `players` SET `loaded` = 0')
_playerDB.commit()