Mercurial > rinkhals
comparison gamelib/main.py @ 584:a1032ab5c1d6
Add check for windows display mode problems
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 23:08:35 +0000 |
parents | 03d5cb669298 |
children | b6f42a09945d 6b21b2140262 |
comparison
equal
deleted
inserted
replaced
583:41864335aeee | 584:a1032ab5c1d6 |
---|---|
8 | 8 |
9 import sys | 9 import sys |
10 | 10 |
11 import pygame | 11 import pygame |
12 from pgu import gui | 12 from pgu import gui |
13 from pygame.locals import SWSURFACE | 13 from pygame.locals import SWSURFACE, SRCALPHA |
14 | 14 |
15 #from engine import Engine, MainMenuState | 15 #from engine import Engine, MainMenuState |
16 from sound import init_sound | 16 from sound import init_sound |
17 import constants | 17 import constants |
18 from config import config | 18 from config import config |
19 import data | 19 import data |
20 from misc import WarnDialog | |
20 | 21 |
21 def create_main_app(screen): | 22 def create_main_app(screen): |
22 """Create an app with a background widget.""" | 23 """Create an app with a background widget.""" |
23 app = gui.App() | 24 app = gui.App() |
24 background = pygame.Surface(screen.get_size()) | 25 background = pygame.Surface(screen.get_size()) |
25 widget = gui.Image(background) | 26 widget = gui.Image(background) |
26 app.init(widget, screen) | 27 app.init(widget, screen) |
27 return app | 28 return app |
28 | 29 |
30 def complaint_dialog(message): | |
31 """Create a complaint dialog""" | |
32 app = gui.App() | |
33 | |
34 def close(_w): | |
35 app.quit() | |
36 | |
37 app.close = close | |
38 | |
39 dialog = WarnDialog('Problem starting Fox Assault', | |
40 message) | |
41 app.run(dialog) | |
42 sys.exit(1) | |
43 | |
44 def sanity_check(): | |
45 """Run some sanity checks, and complain if they fail""" | |
46 try: | |
47 pygame.Surface((100, 100), flags=SRCALPHA) | |
48 except Exception, e: | |
49 complaint_dialog("Unable to create a suitable screen, please check your display settings") | |
50 | |
29 def main(): | 51 def main(): |
30 """Main script.""" | 52 """Main script.""" |
31 config.configure(sys.argv[1:]) | 53 config.configure(sys.argv[1:]) |
32 init_sound() | 54 init_sound() |
55 sanity_check() | |
33 screen = pygame.display.set_mode(constants.SCREEN, SWSURFACE) | 56 screen = pygame.display.set_mode(constants.SCREEN, SWSURFACE) |
34 pygame.display.set_icon(pygame.image.load( | 57 pygame.display.set_icon(pygame.image.load( |
35 data.filepath('icons/foxassault24x24.png'))) | 58 data.filepath('icons/foxassault24x24.png'))) |
36 main_app = create_main_app(screen) | 59 main_app = create_main_app(screen) |
37 | 60 |