Game aligns window to center by default
This commit is contained in:
parent
92c1ee3164
commit
1fa85ac867
|
@ -35,6 +35,7 @@ class Configuration(RawConfigParser):
|
|||
self.set("display", "frame-duration", "33")
|
||||
self.set("display", "wait-duration", "2")
|
||||
self.set("display", "caption", None)
|
||||
self.set("display", "centered", True)
|
||||
self.add_section("resources")
|
||||
self.set("resources", "installation-path", ".")
|
||||
self.add_section("screen-captures")
|
||||
|
@ -50,7 +51,7 @@ class Configuration(RawConfigParser):
|
|||
types = self.type_declarations
|
||||
if type(value) == str:
|
||||
if pair in types["bool"]:
|
||||
return True if value == "T" else False
|
||||
return True if value == "yes" else False
|
||||
elif pair in types["int"]:
|
||||
return int(value)
|
||||
elif pair in types["float"]:
|
||||
|
@ -121,6 +122,7 @@ class TypeDeclarations(dict):
|
|||
"list": [], "int-list": []})
|
||||
self.add("int", "display", "frame-duration")
|
||||
self.add("int", "display", "wait-duration")
|
||||
self.add("bool", "display", "centered")
|
||||
self.add("int-list", "display", "dimensions")
|
||||
self.add("path", "resources", "installation-path")
|
||||
self.add("path", "screen-captures", "path")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sys
|
||||
from os import environ
|
||||
|
||||
import pygame
|
||||
from pygame import display
|
||||
|
@ -21,6 +21,7 @@ class Game(GameChild, Animation):
|
|||
self.config_rel_path = config_rel_path
|
||||
self.set_configuration()
|
||||
self.init_animation()
|
||||
self.align_window()
|
||||
pygame.init()
|
||||
self.set_children()
|
||||
self.subscribe_to(QUIT, self.end)
|
||||
|
@ -39,6 +40,10 @@ class Game(GameChild, Animation):
|
|||
Animation.__init__(self,
|
||||
self.configuration.get("display", "frame-duration"))
|
||||
|
||||
def align_window(self):
|
||||
if self.configuration.get("display", "centered"):
|
||||
environ["SDL_VIDEO_CENTERED"] = "1"
|
||||
|
||||
def set_children(self):
|
||||
self.set_display()
|
||||
self.set_delegate()
|
||||
|
|
Loading…
Reference in New Issue