/usr/share/games/kiki-the-nano-bot/py/config.py is in kiki-the-nano-bot-data 1.0.2+dfsg1-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | if Controller.isDebugVersion(): print "[config.py]"
from ConfigParser import ConfigParser
# .................................................................................................................
# KIKI CONFIG
# .................................................................................................................
class KikiConfig (ConfigParser):
"""kiki configuration parser"""
def __init__ (self):
"""initialization"""
ConfigParser.__init__ (self)
self.readfp (open(kikipy_path + "kiki.cfg"))
try:
if os.uname()[0] == "Darwin":
self.config_file_path = os.path.expanduser ("~/Library/Preferences/kiki.cfg")
else:
self.config_file_path = os.path.expanduser ("~/.kiki.cfg")
except:
console.out("--- writing config to %s" % (os.path.expanduser ("~/.kiki.cfg"),))
self.config_file_path = os.path.expanduser ("~/.kiki.cfg")
self.read (self.config_file_path)
for section in self.sections():
for option in self.options (section):
self.apply (section, option, self.get (section, option))
def apply (self, section, option, value):
"""sets and applies value for option in section"""
self.set (section, option, value)
if section == "sound":
if option == "volume":
volume = int(int(value)*(128/9))
sound.setSoundVolume (volume)
elif option == "mute":
sound.setMute (self.getboolean(section, option))
elif section == "display":
if option == "fov":
Controller.getPlayer().getProjection().setFov (int(value))
elif option == "gamma":
Controller.setGamma(int(value))
elif option == "fullscreen":
fullscreen = self.getboolean(section, option)
if fullscreen:
# remember window size before switching to fullscreen
if not Controller.getFullscreen():
self.set (section, "window size", "%dx%d" % Controller.getScreenSize())
Controller.changeScreenSize (0, 0, true)
else:
window_size = map (int, self.get (section, "window size").split("x"))
Controller.changeScreenSize (window_size[0], window_size[1], false)
elif section == "keyboard":
player = Controller.getPlayer()
player.setKeyForAction (value, option.replace("_", " "))
elif section == "game":
if option == "speed":
Controller.setSpeed (int(value))
elif option == "language":
Controller.language = value
def set (self, section, option, value):
"""overwritten to allow spaces in option names"""
ConfigParser.set (self, section, str(option).replace(" ", "_"), str(value))
def get (self, section, option):
"""overwritten to allow spaces in option names"""
return ConfigParser.get (self, section, str(option).replace(" ", "_"))
def save (self):
"""save the configuration"""
# Save the window size. We need to do this here as the resize
# notifications don't get transfered to the Python code (AFAICS).
if not Controller.getFullscreen():
self.set ("display", "window size", "%dx%d" % Controller.getScreenSize())
try:
cfg_file = file (self.config_file_path, "w+")
self.write (cfg_file)
cfg_file.close()
except:
console.printError ("unable to write configuration to " + self.config_file_path)
# .................................................................................................................
config = KikiConfig ()
|