- removed the native graphical startup screens.

ENDOOM is already working with this commit, the start screens still require some work to connect them.
This commit is contained in:
Christoph Oelckers 2022-05-18 22:15:05 +02:00
parent d6886ed44f
commit 79f4a9c0f3
7 changed files with 7 additions and 1635 deletions

View file

@ -79,114 +79,12 @@ protected:
int NetMaxPos, NetCurPos;
};
class FGraphicalStartupScreen : public FBasicStartupScreen
{
public:
FGraphicalStartupScreen(int max_progress);
~FGraphicalStartupScreen();
};
class FHereticStartupScreen : public FGraphicalStartupScreen
{
public:
FHereticStartupScreen(int max_progress, long &hr);
void Progress();
void LoadingStatus(const char *message, int colors);
void AppendStatusLine(const char *status);
protected:
void SetWindowSize();
int ThermX, ThermY, ThermWidth, ThermHeight;
int HMsgY, SMsgX;
};
class FHexenStartupScreen : public FGraphicalStartupScreen
{
public:
FHexenStartupScreen(int max_progress, long &hr);
~FHexenStartupScreen();
void Progress();
void NetProgress(int count);
void NetDone();
void SetWindowSize();
// Hexen's notch graphics, converted to chunky pixels.
uint8_t * NotchBits;
uint8_t * NetNotchBits;
};
class FStrifeStartupScreen : public FGraphicalStartupScreen
{
public:
FStrifeStartupScreen(int max_progress, long &hr);
~FStrifeStartupScreen();
void Progress();
protected:
void DrawStuff(int old_laser, int new_laser);
void SetWindowSize();
uint8_t *StartupPics[4+2+1];
};
extern FStartupScreen *StartScreen;
void DeleteStartupScreen();
extern void ST_Endoom();
// The entire set of functions here uses native Windows types. These are recreations of those types so that the code doesn't need to be changed more than necessary
struct BitmapInfoHeader
{
uint32_t biSize;
int32_t biWidth;
int32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
};
struct RgbQuad
{
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
};
struct BitmapInfo
{
BitmapInfoHeader bmiHeader;
RgbQuad bmiColors[1];
};
extern BitmapInfo* StartupBitmap;
void ST_Util_PlanarToChunky4(uint8_t* dest, const uint8_t* src, int width, int height);
void ST_Util_DrawBlock(BitmapInfo* bitmap_info, const uint8_t* src, int x, int y, int bytewidth, int height);
void ST_Util_DrawBlock4(BitmapInfo* bitmap_info, const uint8_t* src, int x, int y, int bytewidth, int height);
void ST_Util_ClearBlock(BitmapInfo* bitmap_info, uint8_t fill, int x, int y, int bytewidth, int height);
BitmapInfo* ST_Util_CreateBitmap(int width, int height);
uint8_t* ST_Util_BitsForBitmap(BitmapInfo* bitmap_info);
void ST_Util_FreeBitmap(BitmapInfo* bitmap_info);
void ST_Util_BitmapColorsFromPlaypal(BitmapInfo* bitmap_info);
BitmapInfo* ST_Util_AllocTextBitmap();
void ST_Util_DrawTextScreen(BitmapInfo* bitmap_info, const uint8_t* text_screen);
int ST_Util_DrawChar(BitmapInfo* screen, int x, int y, unsigned charnum, uint8_t attrib);
void ST_Util_UpdateTextBlink(BitmapInfo* bitmap_info, const uint8_t* text_screen, bool on);
//===========================================================================
//
// DeleteStartupScreen

View file

@ -376,38 +376,6 @@ bool MainWindow::RunMessageLoop(bool (*timer_callback)(void*), void* userdata)
return false;
}
void MainWindow::ShowStartupScreen()
{
StartupScreen = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"STATIC", 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, Window, 0, GetModuleHandle(0), 0);
if (StartupScreen != 0)
SetWindowLong(StartupScreen, GWL_ID, IDC_STATIC_STARTUP);
}
void MainWindow::HideStartupScreen()
{
if (StartupScreen != 0)
{
DestroyWindow(StartupScreen);
StartupScreen = 0;
}
}
void MainWindow::InvalidateStartupScreen()
{
InvalidateRect(StartupScreen, 0, TRUE);
}
void MainWindow::InvalidateStartupScreen(int left, int top, int right, int bottom)
{
RECT rect;
GetClientRect(StartupScreen, &rect);
rect.left = left * rect.right / StartupBitmap->bmiHeader.biWidth - 1;
rect.top = top * rect.bottom / StartupBitmap->bmiHeader.biHeight - 1;
rect.right = right * rect.right / StartupBitmap->bmiHeader.biWidth + 1;
rect.bottom = bottom * rect.bottom / StartupBitmap->bmiHeader.biHeight + 1;
InvalidateRect(StartupScreen, &rect, FALSE);
}
void MainWindow::UpdateLayout()
{
LayoutMainWindow(Window, 0);
@ -456,18 +424,8 @@ void MainWindow::LayoutMainWindow(HWND hWnd, HWND pane)
leftside = GetSystemMetrics(SM_CXICON) + 6;
MoveWindow(ErrorIcon, 0, bannerheight, leftside, h - bannerheight - errorpaneheight - progressheight - netpaneheight, TRUE);
}
// If there is a startup screen, it covers the log window
if (StartupScreen != NULL)
{
SetWindowPos(StartupScreen, HWND_TOP, leftside, bannerheight, w - leftside, h - bannerheight - errorpaneheight - progressheight - netpaneheight, SWP_SHOWWINDOW);
InvalidateRect(StartupScreen, NULL, FALSE);
MoveWindow(ConWindow, 0, 0, 0, 0, TRUE);
}
else
{
// The log window uses whatever space is left.
MoveWindow(ConWindow, leftside, bannerheight, w - leftside, h - bannerheight - errorpaneheight - progressheight - netpaneheight, TRUE);
}
// The log window uses whatever space is left.
MoveWindow(ConWindow, leftside, bannerheight, w - leftside, h - bannerheight - errorpaneheight - progressheight - netpaneheight, TRUE);
}
// Lays out the error pane to the desired width, returning the required height.
@ -709,35 +667,6 @@ LRESULT MainWindow::OnDrawItem(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
SelectObject(drawitem->hDC, oldfont);
return TRUE;
}
// Draw startup screen
else if (wParam == IDC_STATIC_STARTUP)
{
if (StartupScreen != NULL)
{
drawitem = (LPDRAWITEMSTRUCT)lParam;
rect = drawitem->rcItem;
// Windows expects DIBs to be bottom-up but ours is top-down,
// so flip it vertically while drawing it.
StretchDIBits(drawitem->hDC, rect.left, rect.bottom - 1, rect.right - rect.left, rect.top - rect.bottom,
0, 0, StartupBitmap->bmiHeader.biWidth, StartupBitmap->bmiHeader.biHeight,
ST_Util_BitsForBitmap(StartupBitmap), reinterpret_cast<const BITMAPINFO*>(StartupBitmap), DIB_RGB_COLORS, SRCCOPY);
// If the title banner is gone, then this is an ENDOOM screen, so draw a short prompt
// where the command prompt would have been in DOS.
if (GameTitleWindow == NULL)
{
auto quitmsg = WideString(GStrings("TXT_QUITENDOOM"));
SetTextColor(drawitem->hDC, RGB(240, 240, 240));
SetBkMode(drawitem->hDC, TRANSPARENT);
oldfont = SelectObject(drawitem->hDC, (HFONT)GetStockObject(DEFAULT_GUI_FONT));
TextOutW(drawitem->hDC, 3, drawitem->rcItem.bottom - DefaultGUIFontHeight - 3, quitmsg.c_str(), (int)quitmsg.length());
SelectObject(drawitem->hDC, oldfont);
}
return TRUE;
}
}
// Draw stop icon.
else if (wParam == IDC_ICONPIC)
{

View file

@ -39,11 +39,6 @@ public:
bool RunMessageLoop(bool (*timer_callback)(void*), void* userdata);
void HideNetStartPane();
void ShowStartupScreen();
void HideStartupScreen();
void InvalidateStartupScreen();
void InvalidateStartupScreen(int left, int top, int right, int bottom);
void SetWindowTitle(const char* caption);
HWND GetHandle() { return Window; }

View file

@ -55,23 +55,10 @@
#include "texturemanager.h"
#include "i_mainwindow.h"
// MACROS ------------------------------------------------------------------
// How many ms elapse between blinking text flips. On a standard VGA
// adapter, the characters are on for 16 frames and then off for another 16.
// The number here therefore corresponds roughly to the blink rate on a
// 60 Hz display.
#define BLINK_PERIOD 267
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void ST_Util_SizeWindowForBitmap (int scale);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern HINSTANCE g_hInst;
@ -80,12 +67,6 @@ extern HINSTANCE g_hInst;
FStartupScreen *StartScreen;
CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
if (self < 0) self = 0;
else if (self > 2) self=2;
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
@ -101,34 +82,7 @@ CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{
FStartupScreen *scr = NULL;
HRESULT hr = E_FAIL;
if (!Args->CheckParm("-nostartup"))
{
if (GameStartupInfo.Type == FStartupInfo::HexenStartup)
{
scr = new FHexenStartupScreen(max_progress, hr);
}
else if (GameStartupInfo.Type == FStartupInfo::HereticStartup)
{
scr = new FHereticStartupScreen(max_progress, hr);
}
else if (GameStartupInfo.Type == FStartupInfo::StrifeStartup)
{
scr = new FStrifeStartupScreen(max_progress, hr);
}
if (scr != NULL && FAILED(hr))
{
delete scr;
scr = NULL;
}
}
if (scr == NULL)
{
scr = new FBasicStartupScreen(max_progress, true);
}
return scr;
return new FBasicStartupScreen(max_progress, true);
}
//==========================================================================
@ -258,235 +212,3 @@ bool FBasicStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata
{
return mainwindow.RunMessageLoop(timer_callback, userdata);
}
//==========================================================================
//
// FGraphicalStartupScreen Constructor
//
// This doesn't really do anything. The subclass is responsible for
// creating the resources that will be freed by this class's destructor.
//
//==========================================================================
FGraphicalStartupScreen::FGraphicalStartupScreen(int max_progress)
: FBasicStartupScreen(max_progress, false)
{
mainwindow.ShowStartupScreen();
}
//==========================================================================
//
// FGraphicalStartupScreen Destructor
//
//==========================================================================
FGraphicalStartupScreen::~FGraphicalStartupScreen()
{
mainwindow.HideStartupScreen();
if (StartupBitmap != NULL)
{
ST_Util_FreeBitmap (StartupBitmap);
StartupBitmap = NULL;
}
}
//==========================================================================
//
//
//
//==========================================================================
void FHexenStartupScreen::SetWindowSize()
{
ST_Util_SizeWindowForBitmap(1);
mainwindow.UpdateLayout();
mainwindow.InvalidateStartupScreen();
}
//==========================================================================
//
//
//
//==========================================================================
void FHereticStartupScreen::SetWindowSize()
{
ST_Util_SizeWindowForBitmap(1);
mainwindow.UpdateLayout();
mainwindow.InvalidateStartupScreen();
}
//==========================================================================
//
//
//
//==========================================================================
void FStrifeStartupScreen::SetWindowSize()
{
ST_Util_SizeWindowForBitmap(2);
mainwindow.UpdateLayout();
mainwindow.InvalidateStartupScreen();
}
//==========================================================================
//
// ST_Endoom
//
// Shows an ENDOOM text screen
//
//==========================================================================
int RunEndoom()
{
if (showendoom == 0 || endoomName.Len() == 0)
{
return 0;
}
int endoom_lump = fileSystem.CheckNumForFullName (endoomName, true);
uint8_t endoom_screen[4000];
MSG mess;
BOOL bRet;
bool blinking = false, blinkstate = false;
int i;
if (endoom_lump < 0 || fileSystem.FileLength (endoom_lump) != 4000)
{
return 0;
}
if (fileSystem.GetFileContainer(endoom_lump) == fileSystem.GetMaxIwadNum() && showendoom == 2)
{
// showendoom==2 means to show only lumps from PWADs.
return 0;
}
mainwindow.ShowStartupScreen();
I_ShutdownGraphics ();
mainwindow.RestoreConView ();
S_StopMusic(true);
fileSystem.ReadFile (endoom_lump, endoom_screen);
// Draw the loading screen to a bitmap.
StartupBitmap = ST_Util_AllocTextBitmap();
ST_Util_DrawTextScreen (StartupBitmap, endoom_screen);
// Make the title banner go away.
mainwindow.HideGameTitleWindow();
ST_Util_SizeWindowForBitmap (1);
mainwindow.UpdateLayout();
mainwindow.InvalidateStartupScreen();
// Does this screen need blinking?
for (i = 0; i < 80*25; ++i)
{
if (endoom_screen[1+i*2] & 0x80)
{
blinking = true;
break;
}
}
if (blinking && SetTimer (mainwindow.GetHandle(), 0x5A15A, BLINK_PERIOD, NULL) == 0)
{
blinking = false;
}
// Wait until any key has been pressed or a quit message has been received
for (;;)
{
bRet = GetMessage (&mess, NULL, 0, 0);
if (bRet == 0 || bRet == -1 || // bRet == 0 means we received WM_QUIT
mess.message == WM_KEYDOWN || mess.message == WM_SYSKEYDOWN || mess.message == WM_LBUTTONDOWN)
{
if (blinking)
{
KillTimer (mainwindow.GetHandle(), 0x5A15A);
}
ST_Util_FreeBitmap (StartupBitmap);
return int(bRet == 0 ? mess.wParam : 0);
}
else if (blinking && mess.message == WM_TIMER && mess.hwnd == mainwindow.GetHandle() && mess.wParam == 0x5A15A)
{
ST_Util_UpdateTextBlink (StartupBitmap, endoom_screen, blinkstate);
blinkstate = !blinkstate;
}
TranslateMessage (&mess);
DispatchMessage (&mess);
}
}
void ST_Endoom()
{
TexMan.DeleteAll();
int code = RunEndoom();
throw CExitEvent(code);
}
//==========================================================================
//
// ST_Util_SizeWindowForBitmap
//
// Resizes the main window so that the startup bitmap will be drawn
// at the desired scale.
//
//==========================================================================
void ST_Util_SizeWindowForBitmap (int scale)
{
DEVMODE displaysettings;
int w, h, cx, cy, x, y;
RECT rect;
RECT sizerect = { 0, 0, StartupBitmap->bmiHeader.biWidth * scale, StartupBitmap->bmiHeader.biHeight * scale + mainwindow.GetGameTitleWindowHeight() };
AdjustWindowRectEx(&sizerect, WS_VISIBLE|WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW);
w = sizerect.right - sizerect.left;
h = sizerect.bottom - sizerect.top;
// Resize the window, but keep its center point the same, unless that
// puts it partially offscreen.
memset (&displaysettings, 0, sizeof(displaysettings));
displaysettings.dmSize = sizeof(displaysettings);
EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &displaysettings);
GetWindowRect (mainwindow.GetHandle(), &rect);
cx = (rect.left + rect.right) / 2;
cy = (rect.top + rect.bottom) / 2;
x = cx - w / 2;
y = cy - h / 2;
if (x + w > (int)displaysettings.dmPelsWidth)
{
x = displaysettings.dmPelsWidth - w;
}
if (x < 0)
{
x = 0;
}
if (y + h > (int)displaysettings.dmPelsHeight)
{
y = displaysettings.dmPelsHeight - h;
}
if (y < 0)
{
y = 0;
}
MoveWindow (mainwindow.GetHandle(), x, y, w, h, TRUE);
}
//==========================================================================
//
// ST_Util_InvalidateRect
//
// Invalidates the portion of the window that the specified rect of the
// bitmap appears in.
//
//==========================================================================
void ST_Util_InvalidateRect(BitmapInfo* bitmap_info, int left, int top, int right, int bottom)
{
mainwindow.InvalidateStartupScreen(left, top, right, bottom);
}

File diff suppressed because it is too large Load diff

View file

@ -66,13 +66,13 @@
// TYPES -------------------------------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
#if 0
CUSTOM_CVAR(Int, showendoom, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
if (self < 0) self = 0;
else if (self > 2) self=2;
}
#endif
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
@ -138,7 +138,6 @@ void FEndoomScreen::Update()
}
#if 0 // this part is not ready yet.
//==========================================================================
//
// ST_Endoom
@ -198,4 +197,3 @@ void ST_Endoom()
int code = RunEndoom();
throw CExitEvent(code);
}
#endif

View file

@ -368,8 +368,9 @@ FStartScreen* GetGameStartScreen(int max_progress)
Printf("Error creating start screen: %s\n", err.what());
// fall through to the generic startup screen
}
return CreateGenericStartScreen(max_progress);
}
return CreateGenericStartScreen(max_progress);
return nullptr;
}
//==========================================================================