- allow setting the startup screen's title through GAMEINFO lump.

SVN r2850 (trunk)
This commit is contained in:
Christoph Oelckers 2010-09-24 14:27:52 +00:00
parent 4397ef3323
commit 3f420c97bd
7 changed files with 51 additions and 26 deletions

View File

@ -668,6 +668,12 @@ const IWADInfo *D_FindIWAD(TArray<FString> &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;
}

View File

@ -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<FString> &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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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();