adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[adonthell-wastesedge-commits] Release_0-3-1 c31d284 145/237: MOVED fadi


From: Kai Sterker
Subject: [adonthell-wastesedge-commits] Release_0-3-1 c31d284 145/237: MOVED fading code to mapengine
Date: Mon, 25 Jul 2016 18:15:07 +0000 (UTC)

tag: Release_0-3-1
commit c31d28470b37f5602e3512297779c01c77d1f72c
Author: adondev <adondev>
Commit: adondev <adondev>

    MOVED fading code to mapengine
---
 scripts/init.py              |   73 +++++++++++++++---------------------------
 scripts/modules/main_menu.py |    2 ++
 2 files changed, 27 insertions(+), 48 deletions(-)

diff --git a/scripts/init.py b/scripts/init.py
index 3d44900..b85b546 100755
--- a/scripts/init.py
+++ b/scripts/init.py
@@ -17,32 +17,6 @@ from adonthell import *
 from main_menu import *
 import time
 
-# -- Fade the screen out
-def fade_out ():
-    i = 0
-
-    while i < 60:
-        gamedata_map_engine ().mainloop ()
-
-        screen_transition (i * 2)
-        screen_show ()
-
-        gametime_update ()
-        i = i + (gametime_frames_to_do () * 2)
-
-# -- Fade the screen in
-def fade_in ():
-    i = 60
-
-    while i > 0:
-        gamedata_map_engine ().mainloop ()
-
-        screen_transition (i * 2)
-        screen_show ()
-
-        gametime_update ()
-        i = i - (gametime_frames_to_do () * 2)
-
 class title_screen:
     def __init__ (self):
         # -- load our music
@@ -196,32 +170,14 @@ class title_screen:
 
     # -- on to the main menu
     def on_menu_close (self, retval):
-        fade_out ()
-
-        screen_display.fillrect (0, 0, screen_length (), screen_height (), 0)
-        screen_show ()
-
-        # -- cleanup
-        win_manager_remove (self.window)
-
-        self.window.remove (self.bag_o)
-        self.window.remove (self.bag_c)
-        self.window.remove (self.bag_t)
-
-        del self.bag_o
-        del self.bag_c
-        del self.bag_t
-
-        self.retval = 0
-        audio_pause_music ()
-
-        ##retval = 1
-
         if retval < 5:
             gamedata_map_engine ().set_should_update_map (1)
 
             # -- start new game
             if retval == 1:
+                gamedata_map_engine ().fade_out ()
+                self.cleanup ()
+
                 gamedata_load_characters (0)
                 gamedata_load_quests (0)
 
@@ -233,10 +189,31 @@ class title_screen:
 
                 win_manager_add (self.cs)
                 win_manager_set_focus (self.cs)
+            # -- Load game
+            else:
+                self.cleanup ()
+                gamedata_map_engine ().fade_in ()
 
         else:
             gamedata_map_engine ().quit ()
 
+    # -- cleanup
+    def cleanup (self):
+        win_manager_remove (self.window)
+
+        self.window.remove (self.bag_o)
+        self.window.remove (self.bag_c)
+        self.window.remove (self.bag_t)
+
+        del self.bag_o
+        del self.bag_c
+        del self.bag_t
+
+        self.retval = 0
+        audio_pause_music ()
+
+        screen_display.fillrect (0, 0, 320, 240, 0)
+        screen_show ()
 
     def on_cs_close (self, retval):
         # Launches the intro
@@ -1043,7 +1020,7 @@ class title_screen:
 
         audio_play_background (1)
         gametime_update ()
-        fade_in ()
+        gamedata_map_engine ().fade_in ()
 
 # -- Main --
 title = title_screen ()
diff --git a/scripts/modules/main_menu.py b/scripts/modules/main_menu.py
index 3a9d794..072c5ae 100755
--- a/scripts/modules/main_menu.py
+++ b/scripts/modules/main_menu.py
@@ -177,6 +177,8 @@ class main_menu (win_container):
 
     # -- Callback to close the window
     def on_destroy (self):
+        if self.quit == 0:
+            print "Closing Main Menu ..."
         return self.quit
 
     # -- pressing ESC will close the menu if it's open



reply via email to

[Prev in Thread] Current Thread [Next in Thread]