From 784dfe7756a28d1f67ad581e61d217648687b7ec Mon Sep 17 00:00:00 2001 From: AnotherCommander Date: Tue, 4 Jul 2017 23:49:44 +0200 Subject: [PATCH] Further fixes to the display of gui messages (game over messages are now displayed too) plus some refactoring to make the messages displaying code more compact. --- src/Core/GuiDisplayGen.m | 3 ++- src/Core/Universe.h | 2 +- src/Core/Universe.m | 23 ++++++++++++++--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Core/GuiDisplayGen.m b/src/Core/GuiDisplayGen.m index a990ff38c..9ebc381ef 100644 --- a/src/Core/GuiDisplayGen.m +++ b/src/Core/GuiDisplayGen.m @@ -1411,7 +1411,8 @@ - (void) drawGLDisplay:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha // don't draw it on the intro screens if (backgroundColor) { - if ([PLAYER status] != STATUS_START_GAME) + int playerStatus = [PLAYER status]; + if (playerStatus != STATUS_START_GAME && playerStatus != STATUS_DEAD) { OOGL(glColor4f([backgroundColor redComponent], [backgroundColor greenComponent], [backgroundColor blueComponent], alpha * [backgroundColor alphaComponent])); OOGLBEGIN(GL_QUADS); diff --git a/src/Core/Universe.h b/src/Core/Universe.h index 19794cc6c..1f9a13cf0 100644 --- a/src/Core/Universe.h +++ b/src/Core/Universe.h @@ -592,7 +592,7 @@ enum - (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count; - (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly; - (void) showCommsLog:(OOTimeDelta) how_long; -- (void) fadeOutMessageGuiBackground:(OOTimeDelta)how_long; +- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll overDuration:(OOTimeDelta)how_long; - (void) update:(OOTimeDelta)delta_t; diff --git a/src/Core/Universe.m b/src/Core/Universe.m index 8f2a52b19..c7b425a75 100644 --- a/src/Core/Universe.m +++ b/src/Core/Universe.m @@ -6312,7 +6312,7 @@ - (void) displayMessage:(NSString *) text forCount:(OOTimeDelta)count if (currentMessage) [currentMessage release]; currentMessage = [text retain]; messageRepeatTime=universal_time + 6.0; - [message_gui printLongText:text align:GUI_ALIGN_CENTER color:[OOColor yellowColor] fadeTime:count key:nil addToArray:nil]; + [self showGUIMessage:text withScroll:YES overDuration:count]; } } @@ -6324,8 +6324,7 @@ - (void) displayCountdownMessage:(NSString *) text forCount:(OOTimeDelta)count if (currentMessage) [currentMessage release]; currentMessage = [text retain]; countdown_messageRepeatTime=universal_time + count; - [message_gui printLineNoScroll:text align:GUI_ALIGN_CENTER color:[OOColor yellowColor] fadeTime:count key:nil addToArray:nil]; - [message_gui setAlpha:[[PLAYER hud] overallAlpha]]; + [self showGUIMessage:text withScroll:NO overDuration:count]; } } @@ -6418,8 +6417,7 @@ - (void) addMessage:(NSString *) text forCount:(OOTimeDelta) count forceDisplay: [self speakWithSubstitutions:text]; } - [message_gui printLongText:text align:GUI_ALIGN_CENTER color:[OOColor yellowColor] fadeTime:([self permanentMessageLog]?0.0:count) key:nil addToArray:nil]; - [self fadeOutMessageGuiBackground:count]; + [self showGUIMessage:text withScroll:YES overDuration:count]; [currentMessage release]; currentMessage = [text retain]; @@ -6451,8 +6449,7 @@ - (void) addCommsMessage:(NSString *)text forCount:(OOTimeDelta)count andShowCom [self speakWithSubstitutions:[NSString stringWithFormat:format, text]]; } - [message_gui printLongText:text align:GUI_ALIGN_CENTER color:[OOColor greenColor] fadeTime:([self permanentMessageLog]?0.0:count) key:nil addToArray:nil]; - [self fadeOutMessageGuiBackground:count]; + [self showGUIMessage:text withScroll:YES overDuration:count]; [currentMessage release]; currentMessage = [text retain]; @@ -6473,9 +6470,17 @@ - (void) showCommsLog:(OOTimeDelta)how_long } -- (void) fadeOutMessageGuiBackground:(OOTimeDelta)how_long +- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll overDuration:(OOTimeDelta)how_long { - [message_gui setAlpha:1.0]; + if (scroll) + { + [message_gui printLongText:text align:GUI_ALIGN_CENTER color:[OOColor yellowColor] fadeTime:how_long key:nil addToArray:nil]; + } + else + { + [message_gui printLineNoScroll:text align:GUI_ALIGN_CENTER color:[OOColor yellowColor] fadeTime:how_long key:nil addToArray:nil]; + } + [message_gui setAlpha:1.0f]; if (![self permanentMessageLog]) [message_gui fadeOutFromTime:[self getTime] overDuration:how_long]; }