From 467809301fad61959214f98a3c9d27e57aae51d4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 22 Oct 2011 04:13:36 -0400
Subject: [PATCH] Fixed the about screen to render everything each frame.
---
netlogic/about.cpp | 221 +++++++++++++++++++++++----------------------
1 file changed, 112 insertions(+), 109 deletions(-)
diff --git a/netlogic/about.cpp b/netlogic/about.cpp
index aa321f0f..7619b6fd 100644
--- a/netlogic/about.cpp
+++ b/netlogic/about.cpp
@@ -13,11 +13,14 @@
void DoAbout(void)
{
+ SDL_Texture *title = NULL;
SDL_Event event;
Uint32 clr, ltClr, ltrClr;
Bool done = false;
int idOn = 133;
- Bool drawscreen = true;
+ Bool next_screen = true;
+ int width, height;
+ int xOff, yOff;
int numsprites=0, i;
Object *objects[MAX_SPRITES];
@@ -27,84 +30,19 @@ void DoAbout(void)
ltrClr = screen->MapRGB(50000>>8, 50000>>8, 0xFF);
while ( ! done ) {
- int sound_to_play = 0;
-
- /* Rotate any sprites */
- for ( i=0; i<numsprites; ++i ) {
- objects[i]->Move(0);
- objects[i]->BlitSprite();
- }
- screen->Update();
-
- /* Wait for keyboard input */
- while ( SDL_PollEvent(&event) ) {
-
- if ( KEYPRESS(event) || BUTTONPRESS(event) ) {
- Bool next_screen;
-
- next_screen = (
- (event.type == SDL_MOUSEBUTTONDOWN) ||
- (event.key.keysym.sym == SDLK_RETURN)
- );
- drawscreen = true;
-
- if ( next_screen ) {
- sound_to_play = gExplosionSound;
- } else {
- done = true;
- sound_to_play = gMultiplierGone;
- }
-
- if ( ++idOn > 135 ) {
- done = true;
- sound_to_play = gPrettyGood;
- }
- Delay(SOUND_DELAY);
- sound->PlaySound(sound_to_play, 5);
-
- for ( i=0; i<numsprites; ++i )
- delete objects[i];
- numsprites = 0;
- }
- }
- Delay(1);
-
/* -- Handle updates */
- if ( drawscreen && !done ) {
- SDL_Texture *title;
- int width, height;
- int xOff, yOff;
-
+ if ( next_screen ) {
screen->Fade();
- screen->Clear();
-
- /* -- Draw the screen frame */
- width = 512;
- height = 384;
- xOff = ((gScrnRect.right - gScrnRect.left) - width) /2;
- yOff = ((gScrnRect.bottom - gScrnRect.top) - height)/2;
-
- screen->DrawRect(xOff-1,yOff-1,width+2,height+2,clr);
- screen->DrawRect(xOff-2,yOff-2,width+4,height+4,clr);
- screen->DrawRect(xOff-3,yOff-3,width+6,height+6,ltClr);
- screen->DrawRect(xOff-4,yOff-4,width+8,height+8,ltClr);
- screen->DrawRect(xOff-5,yOff-5,width+10,height+10,ltrClr);
- screen->DrawRect(xOff-6,yOff-6,width+12,height+12,ltClr);
- screen->DrawRect(xOff-7,yOff-7,width+14,height+14,clr);
- screen->DrawRect(xOff,yOff,width,height,ltClr);
-
- /* -- Now draw the picture */
+
+ if ( title ) {
+ screen->FreeImage(title);
+ }
title = Load_Title(screen, idOn);
if ( title == NULL ) {
- error(
- "Can't load 'about' title! (ID=%d)\n", idOn);
- exit(255);
+ error("Can't load 'about' title! (ID=%d)\n", idOn);
+ break;
}
- screen->QueueBlit(xOff, yOff, title, NOCLIP);
- screen->Update();
- screen->FreeImage(title);
- /* Draw color icons if this is Game screen */
if ( idOn == 134 ) {
int x, y, off;
@@ -152,45 +90,110 @@ void DoAbout(void)
new Object(x, y, 0, 0, gEnemyShip, 1);
y += off;
- /* Now for the icons */
- x = xOff+25;
- y = yOff+314;
- screen->QueueBlit(x, y, gShieldIcon, NOCLIP);
- screen->QueueBlit(x+16, y,
- gAirBrakesIcon, NOCLIP);
- y += ICON_V_OFF;
- screen->QueueBlit(x, y, gLongFireIcon, NOCLIP);
- screen->QueueBlit(x+16, y,
- gTripleFireIcon, NOCLIP);
- y += ICON_V_OFF;
- screen->QueueBlit(x, y, gAutoFireIcon, NOCLIP);
- screen->QueueBlit(x+16, y,
- gLuckOfTheIrishIcon, NOCLIP);
-
}
- if ( idOn == 135 ) {
- MFont *font;
- SDL_Texture *text1, *text2;
-
- /* Put in the right credits / mask the old... */
- clr = screen->MapRGB(0x00, 0x00, 0x00);
- screen->FillRect(xOff+166,yOff+282,338,62,clr);
- font = fonts[NEWYORK_18];
- text1 = fontserv->TextImage("Port to Linux: ",
- font, STYLE_NORM, 0xFF, 0xFF, 0x55);
- text2 = fontserv->TextImage("Sam Lantinga",
- font, STYLE_NORM, 0xFF, 0xFF, 0xFF);
- screen->QueueBlit(xOff+178, yOff+298,
- text1, NOCLIP);
- screen->QueueBlit(xOff+178+screen->GetImageWidth(text1), yOff+298,
- text2, NOCLIP);
- fontserv->FreeText(text1);
- fontserv->FreeText(text2);
- }
- screen->Update();
+ }
+
+ screen->Clear();
+
+ /* -- Draw the screen frame */
+ width = 512;
+ height = 384;
+ xOff = ((gScrnRect.right - gScrnRect.left) - width) /2;
+ yOff = ((gScrnRect.bottom - gScrnRect.top) - height)/2;
+
+ screen->DrawRect(xOff-1,yOff-1,width+2,height+2,clr);
+ screen->DrawRect(xOff-2,yOff-2,width+4,height+4,clr);
+ screen->DrawRect(xOff-3,yOff-3,width+6,height+6,ltClr);
+ screen->DrawRect(xOff-4,yOff-4,width+8,height+8,ltClr);
+ screen->DrawRect(xOff-5,yOff-5,width+10,height+10,ltrClr);
+ screen->DrawRect(xOff-6,yOff-6,width+12,height+12,ltClr);
+ screen->DrawRect(xOff-7,yOff-7,width+14,height+14,clr);
+ screen->DrawRect(xOff,yOff,width,height,ltClr);
+
+ /* -- Now draw the picture */
+ screen->QueueBlit(xOff, yOff, title, NOCLIP);
+
+ /* Draw color icons if this is Game screen */
+ if ( idOn == 134 ) {
+ int x, y;
+
+ /* Now for the icons */
+ x = xOff+25;
+ y = yOff+314;
+ screen->QueueBlit(x, y, gShieldIcon, NOCLIP);
+ screen->QueueBlit(x+16, y, gAirBrakesIcon, NOCLIP);
+ y += ICON_V_OFF;
+ screen->QueueBlit(x, y, gLongFireIcon, NOCLIP);
+ screen->QueueBlit(x+16, y, gTripleFireIcon, NOCLIP);
+ y += ICON_V_OFF;
+ screen->QueueBlit(x, y, gAutoFireIcon, NOCLIP);
+ screen->QueueBlit(x+16, y, gLuckOfTheIrishIcon, NOCLIP);
+ }
+ if ( idOn == 135 ) {
+ MFont *font;
+ SDL_Texture *text1, *text2;
+
+ /* Put in the right credits / mask the old... */
+ clr = screen->MapRGB(0x00, 0x00, 0x00);
+ screen->FillRect(xOff+166,yOff+282,338,62,clr);
+ font = fonts[NEWYORK_18];
+ text1 = fontserv->TextImage("Port to Linux: ",
+ font, STYLE_NORM, 0xFF, 0xFF, 0x55);
+ text2 = fontserv->TextImage("Sam Lantinga",
+ font, STYLE_NORM, 0xFF, 0xFF, 0xFF);
+ screen->QueueBlit(xOff+178, yOff+298, text1, NOCLIP);
+ screen->QueueBlit(xOff+178+screen->GetImageWidth(text1), yOff+298, text2, NOCLIP);
+ fontserv->FreeText(text1);
+ fontserv->FreeText(text2);
+ }
+
+ /* Rotate any sprites */
+ for ( i=0; i<numsprites; ++i ) {
+ objects[i]->Move(0);
+ objects[i]->BlitSprite();
+ }
+ screen->Update();
+
+ if ( next_screen ) {
screen->Fade();
- drawscreen = false;
+ next_screen = false;
+ }
+
+ /* Wait for keyboard input */
+ while ( SDL_PollEvent(&event) ) {
+
+ if ( KEYPRESS(event) || BUTTONPRESS(event) ) {
+ int sound_to_play = 0;
+
+ next_screen = (
+ (event.type == SDL_MOUSEBUTTONDOWN) ||
+ (event.key.keysym.sym == SDLK_RETURN)
+ );
+
+ if ( next_screen ) {
+ sound_to_play = gExplosionSound;
+ } else {
+ done = true;
+ sound_to_play = gMultiplierGone;
+ }
+
+ if ( ++idOn > 135 ) {
+ done = true;
+ sound_to_play = gPrettyGood;
+ }
+ Delay(SOUND_DELAY);
+ sound->PlaySound(sound_to_play, 5);
+
+ for ( i=0; i<numsprites; ++i )
+ delete objects[i];
+ numsprites = 0;
+ }
}
+ Delay(1);
+
+ }
+ if ( title ) {
+ screen->FreeImage(title);
}
screen->Fade();
gUpdateBuffer = true;