From: <av...@us...> - 2009-11-17 21:41:48
|
Revision: 3312 http://sc2.svn.sourceforge.net/sc2/?rev=3312&view=rev Author: avolkov Date: 2009-11-17 21:41:37 +0000 (Tue, 17 Nov 2009) Log Message: ----------- Uncouple DrawStatusMessage() from pMenuState (carry the required parameter forward) Modified Paths: -------------- trunk/sc2/src/uqm/comm/melnorm/melnorm.c trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/planets/cargo.c trunk/sc2/src/uqm/shipyard.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h trunk/sc2/src/uqm/starbase.c trunk/sc2/src/uqm/starcon.c Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -194,6 +194,7 @@ } }; +static StatMsgMode prevMsgMode; static void DoFirstMeeting (RESPONSE_REF R); @@ -574,7 +575,7 @@ SET_GAME_STATE (MELNORME_CREDIT0, LOBYTE (Credit)); SET_GAME_STATE (MELNORME_CREDIT1, HIBYTE (Credit)); LockMutex (GraphicsLock); - DrawStatusMessage ((UNICODE *)~0); + DrawStatusMessage (NULL); UnlockMutex (GraphicsLock); } else @@ -1810,6 +1811,8 @@ static void Intro (void) { + prevMsgMode = SetStatusMessageMode (SMM_CREDITS); + if (GET_GAME_STATE (MET_MELNORME) == 0) { SET_GAME_STATE (MET_MELNORME, 1); @@ -1841,14 +1844,16 @@ static COUNT uninit_melnorme (void) { - return (0); + return 0; } static void post_melnorme_enc (void) { LockMutex (GraphicsLock); - DrawStatusMessage (0); + if (prevMsgMode != SMM_UNDEFINED) + SetStatusMessageMode (prevMsgMode); + DrawStatusMessage (NULL); UnlockMutex (GraphicsLock); } @@ -1868,6 +1873,8 @@ local_stack0 = 0; local_stack1 = 0; + prevMsgMode = SMM_UNDEFINED; + SET_GAME_STATE (BATTLE_SEGUE, 0); AskedToBuy = FALSE; retval = &melnorme_desc; Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/encount.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -443,6 +443,7 @@ STAMP ship_s; const UNICODE *str1 = NULL; const UNICODE *str2 = NULL; + StatMsgMode prevMsgMode; UNICODE buf[80]; HSHIPFRAG hStarShip; SHIP_FRAGMENT *FragPtr; @@ -486,6 +487,7 @@ } UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip); + prevMsgMode = SetStatusMessageMode (SMM_RES_UNITS); Sleepy = TRUE; for (i = 0; i < NUM_SIDES; ++i) { @@ -539,7 +541,7 @@ { RecycleAmount = 0; - DrawStatusMessage ((UNICODE *)~0); + DrawStatusMessage (NULL); ship_s.origin.x = scavenge_r.corner.x + 32; ship_s.origin.y = scavenge_r.corner.y + 56; @@ -651,6 +653,7 @@ UnlockShipFrag (pQueue, hStarShip); } } + SetStatusMessageMode (prevMsgMode); if (VictoryState) { Modified: trunk/sc2/src/uqm/planets/cargo.c =================================================================== --- trunk/sc2/src/uqm/planets/cargo.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/planets/cargo.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -376,10 +376,6 @@ --pMS->Initialized; pMS->CurState = 1; - LockMutex (GraphicsLock); - DrawStatusMessage ((UNICODE *)~0); - UnlockMutex (GraphicsLock); - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); DoInput (pMS, TRUE); Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/shipyard.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -802,7 +802,6 @@ // refresh SIS display DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); - DrawStatusMessage ((UNICODE *)~0); r.corner.x = pMS->flash_rect0.corner.x; r.corner.y = pMS->flash_rect0.corner.y; r.extent.width = SHIP_WIN_WIDTH; Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/sis.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -33,6 +33,8 @@ #include <stdio.h> +static StatMsgMode curMsgMode = SMM_DEFAULT; + static const UNICODE *describeWeapon (BYTE moduleType); void @@ -363,34 +365,40 @@ BUILD_COLOR (MAKE_RGB15 (0x00, 0x08, 0x00), 0x6E)); ClearDrawable (); - if (pStr == (UNICODE *)~0) + if (!pStr) { - if (pMenuState == 0 - && CommData.ConversationPhrases /* Melnorme shenanigans */ - && cur_comm == MELNORME_CONVERSATION) + if (curMsgMode == SMM_CREDITS) + { sprintf (buf, "%u %s", MAKE_WORD ( GET_GAME_STATE (MELNORME_CREDIT0), GET_GAME_STATE (MELNORME_CREDIT1) ), GAME_STRING (STATUS_STRING_BASE + 0)); // "Cr" - else if (GET_GAME_STATE (CHMMR_BOMB_STATE) < 2) - sprintf (buf, "%u %s", GLOBAL_SIS (ResUnits), - GAME_STRING (STATUS_STRING_BASE + 1)); // "RU" + } + else if (curMsgMode == SMM_RES_UNITS) + { + if (GET_GAME_STATE (CHMMR_BOMB_STATE) < 2) + { + sprintf (buf, "%u %s", GLOBAL_SIS (ResUnits), + GAME_STRING (STATUS_STRING_BASE + 1)); // "RU" + } + else + { + sprintf (buf, "%s %s", + (optWhichMenu == OPT_PC) ? + GAME_STRING (STATUS_STRING_BASE + 2) + : STR_INFINITY_SIGN, // "UNLIMITED" + GAME_STRING (STATUS_STRING_BASE + 1)); // "RU" + } + } else - sprintf (buf, "%s %s", - (optWhichMenu == OPT_PC) ? - GAME_STRING (STATUS_STRING_BASE + 2) - : STR_INFINITY_SIGN, // "UNLIMITED" - GAME_STRING (STATUS_STRING_BASE + 1)); // "RU" + { // Just a date + DateToString (buf, sizeof buf, + GLOBAL (GameClock.month_index), + GLOBAL (GameClock.day_index), + GLOBAL (GameClock.year_index)); + } pStr = buf; } - else if (pStr == 0) - { - DateToString (buf, sizeof buf, - GLOBAL (GameClock.month_index), - GLOBAL (GameClock.day_index), - GLOBAL (GameClock.year_index)); - pStr = buf; - } t.baseline.x = STATUS_MESSAGE_WIDTH >> 1; t.baseline.y = STATUS_MESSAGE_HEIGHT - 1; @@ -409,6 +417,14 @@ SetContext (OldContext); } +StatMsgMode +SetStatusMessageMode (StatMsgMode newMode) +{ + StatMsgMode oldMode = curMsgMode; + curMsgMode = newMode; + return oldMode; +} + void DrawCaptainsName (void) { @@ -1041,7 +1057,8 @@ else GLOBAL_SIS (ResUnits) += resunit_delta; - DrawStatusMessage ((UNICODE *)~0); + assert (curMsgMode == SMM_RES_UNITS); + DrawStatusMessage (NULL); } else { @@ -1052,17 +1069,7 @@ SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x00, 0x08, 0x00), 0x6E)); DrawFilledRectangle (&r); - - if ((pMenuState == 0 - && CommData.ConversationPhrases /* Melnorme shenanigans */ - && cur_comm == MELNORME_CONVERSATION) - || (pMenuState - && (pMenuState->InputFunc == DoStarBase - || pMenuState->InputFunc == DoOutfit - || pMenuState->InputFunc == DoShipyard))) - DrawStatusMessage ((UNICODE *)~0); - else - DrawStatusMessage (NULL); + DrawStatusMessage (NULL); } } UnbatchGraphics (); Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/sis.h 2009-11-17 21:41:37 UTC (rev 3312) @@ -277,7 +277,20 @@ extern void DrawGameDate (void); extern void DateToString (unsigned char *buf, size_t bufLen, BYTE month_index, BYTE day_index, COUNT year_index); + extern void DrawStatusMessage (const UNICODE *pStr); +typedef enum +{ + SMM_UNDEFINED = 0, + SMM_DATE, + SMM_RES_UNITS, + SMM_CREDITS, + + SMM_DEFAULT = SMM_DATE, +} StatMsgMode; +// Sets the new mode and return the previous +extern StatMsgMode SetStatusMessageMode (StatMsgMode); + extern void DrawLanders (void); extern void DrawStorageBays (BOOLEAN Refresh); extern void GetGaugeRect (RECT *pRect, BOOLEAN IsCrewRect); Modified: trunk/sc2/src/uqm/starbase.c =================================================================== --- trunk/sc2/src/uqm/starbase.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/starbase.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -451,6 +451,7 @@ { MENU_STATE MenuState; CONTEXT OldContext; + StatMsgMode prevMsgMode = SMM_UNDEFINED; if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) { @@ -497,6 +498,7 @@ } } + prevMsgMode = SetStatusMessageMode (SMM_RES_UNITS); pMenuState = &MenuState; memset (&MenuState, 0, sizeof (MenuState)); @@ -514,6 +516,7 @@ SetContext (OldContext); pMenuState = 0; + SetStatusMessageMode (prevMsgMode); ExitStarBase: if (!(GLOBAL (CurrentActivity) & (CHECK_LOAD | CHECK_ABORT))) Modified: trunk/sc2/src/uqm/starcon.c =================================================================== --- trunk/sc2/src/uqm/starcon.c 2009-11-17 09:56:02 UTC (rev 3311) +++ trunk/sc2/src/uqm/starcon.c 2009-11-17 21:41:37 UTC (rev 3312) @@ -209,7 +209,8 @@ continue; } #endif - + SetStatusMessageMode (SMM_DEFAULT); + if (!((GLOBAL (CurrentActivity) | NextActivity) & CHECK_LOAD)) ZeroVelocityComponents (&GLOBAL (velocity)); // not going into talking pet conversation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |