From 3f420c97bda59bda52ccd3fed8daa5a34353c66d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Sep 2010 14:27:52 +0000 Subject: [PATCH] - allow setting the startup screen's title through GAMEINFO lump. SVN r2850 (trunk) --- src/d_iwad.cpp | 6 ++++++ src/d_main.cpp | 14 ++++++++++++++ src/d_main.h | 9 +++++++++ src/p_setup.cpp | 2 ++ src/win32/i_main.cpp | 27 ++++++++++++++++++++------- src/win32/i_system.cpp | 16 ---------------- src/win32/i_system.h | 3 --- 7 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 499d7cbd7..ae208e25a 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -668,6 +668,12 @@ const IWADInfo *D_FindIWAD(TArray &wadfiles, const char *iwad, const ch EIWADType iwadType = IdentifyVersion(wadfiles, iwad, basewad); gameiwad = iwadType; const IWADInfo *iwad_info = &IWADInfos[iwadType]; + if (DoomStartupInfo.Name.IsEmpty()) DoomStartupInfo.Name = iwad_info->Name; + if (DoomStartupInfo.BkColor == 0 && DoomStartupInfo.FgColor == 0) + { + DoomStartupInfo.BkColor = iwad_info->BkColor; + DoomStartupInfo.FgColor = iwad_info->FgColor; + } I_SetIWADInfo(iwad_info); return iwad_info; } \ No newline at end of file diff --git a/src/d_main.cpp b/src/d_main.cpp index d24b8c57d..b26d29575 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -203,6 +203,7 @@ bool PageBlank; FTexture *Page; FTexture *Advisory; bool nospriterename; +FStartupInfo DoomStartupInfo; cycle_t FrameCycles; @@ -1697,6 +1698,19 @@ static FString ParseGameInfo(TArray &pwads, const char *fn, const char { nospriterename = true; } + else if (!nextKey.CompareNoCase("STARTUPTITLE")) + { + sc.MustGetString(); + DoomStartupInfo.Name = sc.String; + } + else if (!nextKey.CompareNoCase("STARTUPCOLORS")) + { + sc.MustGetString(); + DoomStartupInfo.FgColor = V_GetColor(NULL, sc.String); + sc.MustGetStringName(","); + sc.MustGetString(); + DoomStartupInfo.BkColor = V_GetColor(NULL, sc.String); + } } return iwad; } diff --git a/src/d_main.h b/src/d_main.h index 517653bec..f72f7a69b 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -106,6 +106,15 @@ struct IWADInfo int flags; }; +struct FStartupInfo +{ + FString Name; + DWORD FgColor; // Foreground color for title banner + DWORD BkColor; // Background color for title banner +}; + +extern FStartupInfo DoomStartupInfo; + extern const IWADInfo IWADInfos[NUM_IWAD_TYPES]; extern EIWADType gameiwad; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 09d2d2e8d..b26d44ee5 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2250,6 +2250,8 @@ static void P_LoopSidedefs (bool firstloop) right = bestright; } } + assert((unsigned)i<(unsigned)numsides); + assert(right<(unsigned)numsides); sides[i].RightSide = right; sides[right].LeftSide = i; } diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 808ae4fbe..782f9fa5f 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -355,7 +355,7 @@ void LayoutMainWindow (HWND hWnd, HWND pane) w = rect.right; h = rect.bottom; - if (DoomStartupInfo != NULL && GameTitleWindow != NULL) + if (DoomStartupInfo.Name.IsNotEmpty() && GameTitleWindow != NULL) { bannerheight = GameTitleFontHeight + 5; MoveWindow (GameTitleWindow, 0, 0, w, bannerheight, TRUE); @@ -399,6 +399,19 @@ void LayoutMainWindow (HWND hWnd, HWND pane) } } + +//========================================================================== +// +// I_SetIWADInfo +// +//========================================================================== + +void I_SetIWADInfo(const IWADInfo *info) +{ + // Make the startup banner show itself + LayoutMainWindow(Window, NULL); +} + //========================================================================== // // LConProc @@ -501,7 +514,7 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_DRAWITEM: // Draw title banner. - if (wParam == IDC_STATIC_TITLE && DoomStartupInfo != NULL) + if (wParam == IDC_STATIC_TITLE && DoomStartupInfo.Name.IsNotEmpty()) { const PalEntry *c; @@ -511,7 +524,7 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // Draw the background. rect = drawitem->rcItem; rect.bottom -= 1; - c = (const PalEntry *)&DoomStartupInfo->BkColor; + c = (const PalEntry *)&DoomStartupInfo.BkColor; hbr = CreateSolidBrush (RGB(c->r,c->g,c->b)); FillRect (drawitem->hDC, &drawitem->rcItem, hbr); DeleteObject (hbr); @@ -519,14 +532,14 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // Calculate width of the title string. SetTextAlign (drawitem->hDC, TA_TOP); oldfont = SelectObject (drawitem->hDC, GameTitleFont != NULL ? GameTitleFont : (HFONT)GetStockObject (DEFAULT_GUI_FONT)); - titlelen = (int)strlen (DoomStartupInfo->Name); - GetTextExtentPoint32 (drawitem->hDC, DoomStartupInfo->Name, titlelen, &size); + titlelen = (int)DoomStartupInfo.Name.Len(); + GetTextExtentPoint32 (drawitem->hDC, DoomStartupInfo.Name, titlelen, &size); // Draw the title. - c = (const PalEntry *)&DoomStartupInfo->FgColor; + c = (const PalEntry *)&DoomStartupInfo.FgColor; SetTextColor (drawitem->hDC, RGB(c->r,c->g,c->b)); SetBkMode (drawitem->hDC, TRANSPARENT); - TextOut (drawitem->hDC, rect.left + (rect.right - rect.left - size.cx) / 2, 2, DoomStartupInfo->Name, titlelen); + TextOut (drawitem->hDC, rect.left + (rect.right - rect.left - size.cx) / 2, 2, DoomStartupInfo.Name, titlelen); SelectObject (drawitem->hDC, oldfont); return TRUE; } diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index f2178ffbf..d0362b13f 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -143,8 +143,6 @@ UINT MillisecondsPerTic; HANDLE NewTicArrived; uint32 LanguageIDs[4]; -const IWADInfo *DoomStartupInfo; - int (*I_GetTime) (bool saveMS); int (*I_WaitForTic) (int); void (*I_FreezeTime) (bool frozen); @@ -833,20 +831,6 @@ void STACK_ARGS I_Error(const char *error, ...) throw CRecoverableError(errortext); } -//========================================================================== -// -// I_SetIWADInfo -// -//========================================================================== - -void I_SetIWADInfo(const IWADInfo *info) -{ - DoomStartupInfo = info; - - // Make the startup banner show itself - LayoutMainWindow(Window, NULL); -} - //========================================================================== // // ToEditControl diff --git a/src/win32/i_system.h b/src/win32/i_system.h index 1a5e755e3..d7af1b4b1 100644 --- a/src/win32/i_system.h +++ b/src/win32/i_system.h @@ -138,9 +138,6 @@ bool I_WriteIniFailed (); unsigned int I_MSTime (void); unsigned int I_FPSTime(); -// [RH] Title banner to display during startup -extern const IWADInfo *DoomStartupInfo; - // [RH] Used by the display code to set the normal window procedure void I_SetWndProc();