Make chess puzzle level (Kasparov to F3) winnable.
[naja.git] / naja / __main__.py
index 1ac982e35aa015bd94b6ef8f272d4782e093dbd3..e3d00872c31df33c74ab10a2afafe6b514d26d26 100644 (file)
@@ -6,8 +6,10 @@ import pygame.locals as pgl
 from naja.constants import SCREEN
 from naja.engine import Engine
 from naja.sound import sound
-from naja.options import parse_args
+from naja.options import parse_args, options
+from naja.resources.loader import Loader
 from naja.scenes.menu import MenuScene
+from naja.utils import warp_to_game_state
 
 
 def main():
@@ -16,13 +18,32 @@ def main():
     pygame.display.init()
     pygame.font.init()
 
+    # set_icon needs to be called before set_mode on some platforms, but we
+    # can't use convert_alpha until we've created a window with set_mode
+    r = Loader('data')
+    r.CONVERT_ALPHA = False
+    if sys.platform == 'darwin':
+        # OSX accepts big icons, but scales up small icons smoothly
+        icon_size = 512
+    elif sys.platform == 'win32':
+        # It's corrupted at any smaller size. And crashes, at larger sizes.
+        icon_size = 32
+    else:
+        icon_size = 24
+    pygame.display.set_icon(
+        r.get_image('robot_%i.png' % icon_size, basedir='icons'))
+
     pygame.display.set_mode(SCREEN, pgl.SWSURFACE)
-    pygame.display.set_caption('Naja')
+    pygame.display.set_caption('Robolock II')
     sound.init()
 
     screen = pygame.display.get_surface()
-    scene = MenuScene()
-    engine = Engine(screen, scene)
+    scene = MenuScene(None)
+    engine = Engine(screen, scene, None)
+
+    if options.game_state is not None:
+        warp_to_game_state(options.game_state)
+
     engine.run()