mouse visibility, bool test

This commit is contained in:
Frank DeMarco 2013-03-03 22:25:41 +09:00
parent c8f7d7785f
commit 1c70279d3d
5 changed files with 23 additions and 14 deletions

View File

@ -39,13 +39,13 @@ class Configuration(RawConfigParser):
add_section(section)
set_option(section, "package-root", basename(getcwd()))
set_option(section, "additional-packages", "")
set_option(section, "title", "")
set_option(section, "title", "")
set_option(section, "classifiers", "")
set_option(section, "resources-search-path", "./, resources/")
set_option(section, "installation-dir", "/usr/local/share/games/")
set_option(section, "changelog", "changelog")
set_option(section, "description-file", "")
set_option(section, "init-script", "")
set_option(section, "init-script", "")
set_option(section, "version", "")
set_option(section, "summary", "")
set_option(section, "license", "")
@ -58,15 +58,17 @@ class Configuration(RawConfigParser):
set_option(section, "resources-path-identifier", "resources_path")
set_option(section, "special-char-placeholder", "_")
set_option(section, "whitespace-placeholder", "-")
set_option(section, "icon-path", "")
set_option(section, "windows-dist-path", "dist/win/")
set_option(section, "windows-icon-path", "")
set_option(section, "lowercase-boolean-true", "yes")
section = "display"
add_section(section)
set_option(section, "dimensions", "480, 320")
set_option(section, "dimensions", "480, 360")
set_option(section, "frame-duration", "33")
set_option(section, "wait-duration", "2")
set_option(section, "caption", "")
set_option(section, "caption", "")
set_option(section, "centered", "yes")
set_option(section, "icon-path", "")
section = "screen-captures"
add_section(section)
set_option(section, "rel-path", "caps")
@ -74,6 +76,7 @@ class Configuration(RawConfigParser):
set_option(section, "file-extension", "png")
section = "mouse"
add_section(section)
set_option(section, "visible", "yes")
set_option(section, "double-click-time-limit", ".5")
section = "keys"
add_section(section)
@ -120,7 +123,7 @@ class Configuration(RawConfigParser):
def print_debug(self, statement):
if self.is_debug_mode():
print statement
def is_debug_mode(self):
return "-d" in argv
@ -161,7 +164,7 @@ class Configuration(RawConfigParser):
types = self.type_declarations
if type(value) == str:
if pair in types["bool"]:
if value == "yes":
if value.lower() == self.get("setup", "lowercase-boolean-true"):
return True
return False
elif pair in types["int"]:
@ -229,7 +232,7 @@ class Configuration(RawConfigParser):
for option in self.options(section):
items.append((option, self.get(section, option)))
return items
class TypeDeclarations(dict):
@ -245,7 +248,8 @@ class TypeDeclarations(dict):
"description-file", "main-object",
"icon-path", "windows-dist-path",
"package-root"]},
"mouse": {"float": "double-click-time-limit"},
"mouse": {"float": "double-click-time-limit",
"bool": "visible"},
"keys": {"list": ["up", "right", "down", "left"]},
"joy": {"int": ["advance", "pause"]},
"audio": {"path": "sfx-path"}}

View File

@ -1,4 +1,4 @@
from pygame import display, image
from pygame import display, image, mouse
from pygame.locals import *
from GameChild import *
@ -11,6 +11,7 @@ class Display(GameChild):
self.set_screen()
self.set_caption()
self.set_icon()
self.set_mouse_visibility()
self.subscribe_to(self.get_custom_event_id(), self.toggle_fullscreen)
def set_screen(self, flags=0):
@ -24,6 +25,11 @@ class Display(GameChild):
path = self.get_resource("display", "icon-path")
display.set_icon(image.load(path).convert_alpha())
def set_mouse_visibility(self, visibility=None):
if visibility is None:
visibility = self.get_configuration("mouse", "visible")
mouse.set_visible(visibility)
def get_screen(self):
return self.screen

View File

@ -14,7 +14,7 @@ from Input import *
from ScreenGrabber import *
class Game(GameChild, Animation):
resources_path = None
def __init__(self, config_rel_path=None, type_declarations=None):

View File

@ -83,4 +83,3 @@ class GameChild:
name = self.get_configuration().get("event", "command-event-name")
event.post(event.Event(self.get_custom_event_id(), name=name,
command=command))

View File

@ -27,8 +27,8 @@ class SetupWin(Setup):
windows = [{}]
if config["init-script"]:
windows[0]["script"] = config["init-script"]
if config["icon-path"]:
windows[0]["icon-resources"] = [(1, config["icon-path"])]
if config["windows-icon-path"]:
windows[0]["icon-resources"] = [(1, config["windows-icon-path"])]
Setup.setup(self, windows,
{"py2exe": {"packages": self.build_package_list(),
"dist_dir": config["windows-dist-path"]}})