Maelstrom: Fixed updating the screen when changing the volume.

From 409b4add6ad2c894156961ed29ce07f176c4acff Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 22 Oct 2011 03:41:44 -0400
Subject: [PATCH] Fixed updating the screen when changing the volume. Note that
 updating the main menu will destroy the button list, so we have a hack not to
 execute any more code in the button list after we run the button callbacks.

---
 buttonlist.h |  4 +++-
 main.cpp     | 17 +++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/buttonlist.h b/buttonlist.h
index 7bb37b3b..3a17f78c 100644
--- a/buttonlist.h
+++ b/buttonlist.h
@@ -35,8 +35,10 @@ class ButtonList {
 		for ( belem=button_list.next; belem; belem=belem->next ) {
 			if ( (x >= belem->x1) && (x <= belem->x2) &&
 			     (y >= belem->y1) && (y <= belem->y2) ) {
-				if ( belem->callback )
+				if ( belem->callback ) {
 					(*belem->callback)();
+					return;
+				}
 			}
 		}
 	}
diff --git a/main.cpp b/main.cpp
index 14851f28..8646cda1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -34,7 +34,7 @@ int	gNoDelay;
 static ButtonList buttons;
 
 // Local functions in this file...
-static void DrawMainScreen(void);
+static void DrawMainScreen(bool fade);
 static void DrawSoundLevel(void);
 static void DrawKey(MPoint *pt, const char *ch, const char *str, void (*callback)(void));
 
@@ -77,7 +77,7 @@ static void IncrementSound(void)
 		sound->PlaySound(gNewLife, 5);
 
 		/* -- Draw the new sound level */
-		DrawSoundLevel();
+		DrawMainScreen(false);
 	}
 }
 static void DecrementSound(void)
@@ -87,7 +87,7 @@ static void DecrementSound(void)
 		sound->PlaySound(gNewLife, 5);
 
 		/* -- Draw the new sound level */
-		DrawSoundLevel();
+		DrawMainScreen(false);
 	}
 }
 static void SetSoundLevel(int volume)
@@ -100,7 +100,7 @@ static void SetSoundLevel(int volume)
 	sound->PlaySound(gNewLife, 5);
 
 	/* -- Draw the new sound level */
-	DrawSoundLevel();
+	DrawMainScreen(false);
 }
 
 static void RunZapScores(void)
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
 		
 		/* Update the screen if necessary */
 		if ( gUpdateBuffer )
-			DrawMainScreen();
+			DrawMainScreen(true);
 
 		/* -- Get an event */
 		screen->WaitEvent(&event);
@@ -461,7 +461,7 @@ static void DrawSoundLevel(void)
 /* ----------------------------------------------------------------- */
 /* -- Draw the main screen */
 
-void DrawMainScreen(void)
+void DrawMainScreen(bool fade)
 {
 	SDL_Texture *title;
 	MFont  *font, *bigfont;
@@ -611,9 +611,10 @@ void DrawMainScreen(void)
 
 	DrawSoundLevel();
 
-	/* Always drawing while faded out -- fade in */
 	screen->Update();
-	screen->Fade();
+	if (fade) {
+		screen->Fade();
+	}
 	screen->FreeImage(title);
 
 }	/* -- DrawMainScreen */