Compare commits

..

No commits in common. "223881eae36374eda296395efd82c8f5196f1837" and "17d1060a272baf58373d83a030d49f1d365d1eb8" have entirely different histories.

19 changed files with 55 additions and 125 deletions

View File

@ -286,8 +286,6 @@ CProfileStat psCluts/*("Cluts", &proProfile.psMain)*/;
{
Assert(ppal);
Assert(pmat);
if (!ppal)
return nullptr;
//
// Search for palette & material in the array.

View File

@ -10,19 +10,6 @@ WindowMode GetWindowModeConfigured()
return static_cast<WindowMode>(selection);
}
void SetWindowModeConfigured(WindowMode mode)
{
int value = static_cast<int>(mode);
if (value >= 0 && value <= static_cast<int>(WindowMode::EXCLUSIVE))
SetRegValue("WindowMode", value);
}
WindowMode GetWindowModeActive()
{
static WindowMode active = GetWindowModeConfigured();
return active;
}
int GetSystemBitDepth(HWND wnd)
{
return GetSystemBitDepth(GetDC(wnd));

View File

@ -10,8 +10,6 @@ enum class WindowMode {
};
WindowMode GetWindowModeConfigured();
void SetWindowModeConfigured(WindowMode mode);
WindowMode GetWindowModeActive();
int GetSystemBitDepth(HWND wnd);
int GetSystemBitDepth(HDC dc);

View File

@ -126,6 +126,7 @@ namespace Video
//
void EnumerateDisplayModes
(
bool b_highres = true // Enables the enumeration of screen modes higher than 640x480.
);
//
// Enumerates screen resolutions, and stores the results in 'ascrmdList.'

View File

@ -334,11 +334,11 @@ private:
Assert(bWithin(i_buffers, 1, 3));
iBuffers = i_buffers;
bFullScreen = i_bits != 0 && GetWindowModeActive() != WindowMode::FRAMED;
bFullScreen = i_bits != 0 && GetWindowModeConfigured() != WindowMode::FRAMED;
iWidthFront = i_width;
iHeightFront = i_height;
if (i_bits && GetWindowModeActive() == WindowMode::EXCLUSIVE)
if (i_bits && GetWindowModeConfigured() == WindowMode::EXCLUSIVE)
{
// Go fullscreen. We need to call 2 DD functions to do this.
DirectDraw::err = DirectDraw::pdd4->SetCooperativeLevel(hwnd,
@ -1321,7 +1321,7 @@ rptr<CRaster> prasReadBMP(const char* str_bitmap_name, bool b_vid)
// Return to Windows screen if necessary.
if (DirectDraw::pdd4)
{
if (GetWindowModeActive() == WindowMode::EXCLUSIVE)
if (GetWindowModeConfigured() == WindowMode::EXCLUSIVE)
DirectDraw::err = DirectDraw::pdd4->RestoreDisplayMode();
DirectDraw::err = DirectDraw::pdd4->SetCooperativeLevel(0, DDSCL_NORMAL);
}
@ -1735,7 +1735,7 @@ rptr<CRaster> prasReadBMP(const char* str_bitmap_name, bool b_vid)
//******************************************************************************************
bool CRasterWin::CPriv::bConstructD3D(HWND hwnd, int i_width, int i_height, int i_bits, bool force16Bit)
{
if (GetWindowModeActive() == WindowMode::EXCLUSIVE)
if (GetWindowModeConfigured() == WindowMode::EXCLUSIVE)
return bConstructD3DExclusive(hwnd, i_width, i_height, i_bits);
else
return bConstructD3DWindowed(hwnd, i_width, i_height, i_bits, force16Bit);

View File

@ -81,6 +81,7 @@ namespace Video
int iTotalVideoMemory;
SScreenMode ascrmdList[iMAX_MODES];
int iModes;
bool bEnumHighResolutions = true;
//
// Functions needed by CInitVideo.
@ -97,6 +98,10 @@ namespace Video
//
//**********************************
{
// We now only support 16-bit rendering.
if (i_bits != 16)
return;
// Search list to see if already there.
for (int i = 0; i < iModes; i++)
{
@ -131,6 +136,10 @@ namespace Video
//
//**********************************
{
if (!bEnumHighResolutions)
if (pddsd->dwWidth > 800)
return DDENUMRET_OK;
// Suppress resolutions if required.
if (bSuppress512x384 && pddsd->dwWidth == 512)
return DDENUMRET_OK;
@ -170,7 +179,7 @@ namespace Video
//******************************************************************************************
//
void EnumerateDisplayModes()
void EnumerateDisplayModes(bool b_highres)
//
// Generate the list of available display modes. Store it sorted in ascrmdList.
//
@ -185,6 +194,7 @@ namespace Video
//**********************************
{
CDDSize<DDCAPS> ddcaps_hw, ddcaps_sw;
bEnumHighResolutions = b_highres;
EVideoCard evc;
// Get the video card type.

View File

@ -216,8 +216,16 @@ static HRESULT CALLBACK EnumDisplayMode
assert(pddsd);
assert(pv_context);
// Do not enumerate screen resolutions lower than 640x480.
if (pddsd->dwWidth < 640 || pddsd->dwHeight < 480)
// If the mode is not 16 bits, ignore it.
if (pddsd->ddpfPixelFormat.dwRGBBitCount != 16)
return DDENUMRET_OK;
// Suppress resolutions if required.
if (bSuppress512 && pddsd->dwWidth == 512)
return DDENUMRET_OK;
// Do not enumerate screen resolutions higher than 640x480.
if (pddsd->dwWidth > 800)
return DDENUMRET_OK;
// Get the next available element.

View File

@ -1440,15 +1440,6 @@ BOOL CUIListbox::SetFont(HFONT hfont)
return TRUE;
}
void CUIListbox::ScrollToActive()
{
if (m_iCurrSel != -1 && m_iCurrSel < m_vInfo.size())
{
m_iTop = m_iCurrSel;
m_bUpdate = true;
}
}
BOOL CUIListbox::InitSurface()
{
int iWidth;

View File

@ -270,9 +270,7 @@ public:
virtual BOOL GetFontSize() { return m_bFontSize;}
virtual void SetFontSize(BOOL bFontSize) { m_bFontSize = bFontSize; m_bUpdate = TRUE;}
void ScrollToActive();
private:
std::vector<CUILISTBOXINFO> m_vInfo;

View File

@ -28,7 +28,6 @@
#include "../Lib/Sys/RegInit.hpp"
#include "DDDevice.hpp"
#include "Lib/Std/MemLimits.hpp"
#include "Lib/View/DisplayMode.hpp"
//
@ -93,7 +92,6 @@ BOOL CConfigureWnd::OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
m_hwndResolutions = GetDlgItem(m_hwnd, IDC_COMBO_RESOLUTION);
m_hwndTextureSizes = GetDlgItem(m_hwnd, IDC_COMBO_TEXTURESIZE);
m_hwndWindowModes = GetDlgItem(m_hwnd, IDC_COMBO_WINDOWMODE);
m_hwndList = GetDlgItem(m_hwnd, IDC_LIST_CARD);
InitializeCardSelection();
@ -247,16 +245,6 @@ void CConfigureWnd::InitializeTextureSizes()
ComboBox_SetCurSel(m_hwndTextureSizes, i_sel);
}
void CConfigureWnd::InitializeWindowModes()
{
ComboBox_ResetContent(m_hwndWindowModes);
ComboBox_AddString(m_hwndWindowModes, "Window");
ComboBox_AddString(m_hwndWindowModes, "Borderless Window");
ComboBox_AddString(m_hwndWindowModes, "Exclusive Fullscreen");
int selected = static_cast<int>(GetWindowModeConfigured()) - 1;
ComboBox_SetCurSel(m_hwndWindowModes, selected);
}
void CConfigureWnd::InitializeCardSelection()
{
@ -350,7 +338,6 @@ void CConfigureWnd::OnSelchangeListCard()
// Set up the resolution combo box.
InitializeResolutions();
InitializeTextureSizes();
InitializeWindowModes();
// Set up dither check box.
CheckDlgButton(m_hwnd, IDC_CHECK_DITHER, (bGetDither()) ? (BST_CHECKED) : (BST_UNCHECKED));
@ -423,15 +410,12 @@ void CConfigureWnd::OnOK()
// Set the dither flag.
SetDither(IsDlgButtonChecked(m_hwnd, IDC_CHECK_DITHER));
int selectedWindowMode = ComboBox_GetCurSel(m_hwndWindowModes);
SetWindowModeConfigured(static_cast<WindowMode>(selectedWindowMode + 1));
// Close the registry and exit.
CMultiDlg::OnOK();
// Remove the device enumeration object.
delete penumdevDevices;
penumdevDevices = nullptr;
penumdevDevices = 0;
//exit(0);
}
@ -771,7 +755,6 @@ void CRenderWnd::SelectCurrentResolution()
}
plistbox->SetCurrSel(i);
plistbox->ScrollToActive();
}

View File

@ -455,7 +455,7 @@ int DoWinMain(HINSTANCE hInstance,
return -1;
}
if ( !IsDisplayConfigurationValid( GetSystemBitDepth(g_hwnd), bGetD3D(), GetWindowModeActive()))
if ( !IsDisplayConfigurationValid( GetSystemBitDepth(g_hwnd), bGetD3D(), GetWindowModeConfigured()))
{
if (MsgDlg(g_hwnd,
MB_YESNOCANCEL | MB_SETFOREGROUND,
@ -538,14 +538,6 @@ DoRestartWithRenderDlg:
dlg.MultiDialogBox(g_hInst, MAKEINTRESOURCE(IDD_INITIALIZATION), g_hwnd);
g_pMainWnd->m_bRelaunch = true;
bVideoCardChosen = true;
int windowWidth = 0;
int windowHeight = 0;
if (bGetDimensions(windowWidth, windowHeight))
{
SetWindowPos(g_hwnd, NULL, -1, -1, windowWidth, windowHeight,
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
}
}
EnableMenuItem(GetSystemMenu(g_hwnd, FALSE),
@ -631,7 +623,7 @@ DoRestartWithRenderDlg:
}
}
Video::EnumerateDisplayModes();
Video::EnumerateDisplayModes(false);
//
// If safe mode is not active, set some defaults that depend on the CPU speed.
@ -920,7 +912,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
bGetDimensions(windowWidth, windowHeight);
DWORD style = WS_VISIBLE | WS_POPUP | WS_SYSMENU;
if (GetWindowModeActive() == WindowMode::FRAMED)
if (GetWindowModeConfigured() == WindowMode::FRAMED)
style |= WS_OVERLAPPEDWINDOW;
if (!CreateWindowEx(0,

View File

@ -78,7 +78,6 @@ public:
void OnPaint(HWND hwnd);
void OnTimer(HWND hwnd, UINT id);
void OnSysCommand(HWND hwnd, UINT cmd, int x, int y);
void OnWindowPosChanged(HWND hwnd, LPWINDOWPOS pos);
void GameLoop();
void CopyrightScreen();
@ -106,12 +105,10 @@ private:
HWND m_hwndD3DDriver;
HWND m_hwndList;
HWND m_hwndTextureSizes;
HWND m_hwndWindowModes;
void InitializeCardSelection();
void InitializeResolutions();
void InitializeTextureSizes();
void InitializeWindowModes();
void OnSelchangeListCard();
};

View File

@ -170,7 +170,7 @@ void CMainWnd::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
void CMainWnd::OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
{
CUIWnd* puiwnd = nullptr;
CUIWnd * puiwnd;
if (vk == VK_SNAPSHOT)
{
@ -180,8 +180,7 @@ void CMainWnd::OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
return;
}
if (m_pUIMgr)
puiwnd = m_pUIMgr->GetActiveUIWnd();
puiwnd = m_pUIMgr->GetActiveUIWnd();
if (puiwnd && !puiwnd->m_bExitWnd)
{
puiwnd->OnKey(vk, fDown, cRepeat, flags);
@ -192,10 +191,9 @@ void CMainWnd::OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
void CMainWnd::OnChar(HWND hwnd, TCHAR ch, int cRepeat)
{
CUIWnd* puiwnd = nullptr;
CUIWnd * puiwnd;
if (m_pUIMgr)
puiwnd = m_pUIMgr->GetActiveUIWnd();
puiwnd = m_pUIMgr->GetActiveUIWnd();
if (puiwnd && !puiwnd->m_bExitWnd)
{
puiwnd->OnChar(ch, cRepeat);
@ -338,15 +336,6 @@ void CMainWnd::OnSysCommand(HWND hwnd, UINT cmd, int x, int y)
}
}
void CMainWnd::OnWindowPosChanged(HWND hwnd, LPWINDOWPOS pos)
{
if (!m_pUIMgr)
return;
auto* puiwnd = m_pUIMgr->GetActiveUIWnd();
if (puiwnd)
puiwnd->OnWindowPosChanged();
}
void CMainWnd::SendActivate(BOOL fActivate, DWORD dwThreadId)
@ -431,7 +420,7 @@ void CMainWnd::OnActivateApp(HWND hwnd, BOOL fActivate, DWORD dwThreadId)
m_pUIMgr->m_bPause = FALSE;
if (prasMainScreen && GetWindowModeActive() == WindowMode::EXCLUSIVE)
if (prasMainScreen && GetWindowModeConfigured() == WindowMode::EXCLUSIVE)
{
SetRect(&rc,
0,
@ -754,7 +743,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
HANDLE_MSG(hwnd, WM_MBUTTONDOWN, g_pMainWnd->OnMButtonDown);
HANDLE_MSG(hwnd, WM_TIMER, g_pMainWnd->OnTimer);
HANDLE_MSG(hwnd, WM_SYSCOMMAND, g_pMainWnd->OnSysCommand);
HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, g_pMainWnd->OnWindowPosChanged);
}
return DefWindowProc(hwnd, uiMsg, wParam, lParam);

View File

@ -80,7 +80,6 @@
#define IDC_COMBO_TEXTURESIZE 1005
#define IDC_STATIC_SIZES 1006
#define IDC_COMBO_D3D 1006
#define IDC_COMBO_WINDOWMODE 1006
#define IDC_STATIC_BOX 1007
#define IDC_D3D 1008
#define IDC_LIST_CARD 1008
@ -133,7 +132,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 123
#define _APS_NEXT_RESOURCE_VALUE 122
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1039
#define _APS_NEXT_SYMED_VALUE 105

View File

@ -948,7 +948,7 @@ void SetupGameScreen()
bGetDimensions(iWindowWidth, iWindowHeight);
if (GetWindowModeActive() == WindowMode::FRAMED)
if (GetWindowModeConfigured() == WindowMode::FRAMED)
{
POINT clientsize = GetCurrentClientSize();
iClientWidth = clientsize.x;

View File

@ -70,7 +70,7 @@ IDB_DEF_PAL BITMAP DISCARDABLE "res\\smallPal.bmp"
// Dialog
//
IDD_INITIALIZATION DIALOG DISCARDABLE 0, 0, 292, 225
IDD_INITIALIZATION DIALOG DISCARDABLE 0, 0, 272, 185
STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Trespasser 3D Video Driver Setup"
@ -78,34 +78,31 @@ FONT 8, "MS Sans Serif"
BEGIN
LISTBOX IDC_LIST_CARD,16,24,142,52,LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO_RESOLUTION,184,24,85,78,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_RESOLUTION,184,24,72,78,CBS_DROPDOWNLIST |
CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,7,165,48,18
PUSHBUTTON "Cancel",IDCANCEL,63,165,48,18
GROUPBOX "Screen Resolution",IDC_STATIC,176,8,103,36
DEFPUSHBUTTON "OK",IDOK,7,131,48,18
PUSHBUTTON "Cancel",IDCANCEL,63,131,48,18
GROUPBOX "Screen Resolution",IDC_STATIC,176,8,88,36
LTEXT "Unknown",IDC_STATIC_D3D,77,93,78,15
GROUPBOX "Select 3D Video Driver",IDC_STATIC,5,8,163,113
LTEXT "Error",IDC_STATIC_VIDEODRIVER,77,83,78,8
RTEXT "3D Driver Name:",IDC_STATIC,17,83,56,8
RTEXT "Description:",IDC_STATIC,33,92,40,8
GROUPBOX "Features",IDC_STATIC,176,128,103,65
GROUPBOX "Features",IDC_STATIC,176,88,88,65
CONTROL "Hardware Water",IDC_CHECK_HARDWAREWATER,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,184,140,68,10
COMBOBOX IDC_COMBO_TEXTURESIZE,184,64,85,78,CBS_DROPDOWN |
BS_AUTOCHECKBOX | WS_TABSTOP,184,100,68,10
COMBOBOX IDC_COMBO_TEXTURESIZE,184,64,72,78,CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Texture Resolution",IDC_STATIC,176,48,103,36
PUSHBUTTON "Help",IDHELP,119,165,48,18
GROUPBOX "Texture Resolution",IDC_STATIC,176,48,88,36
PUSHBUTTON "Help",IDHELP,119,131,48,18
CONTROL "Triple Buffer",IDC_CHECK_TRIPLEBUFFER,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,184,152,54,10
CTEXT "Applying changes to window mode requires a game restart.",
IDC_STATIC,7,200,268,17
BS_AUTOCHECKBOX | WS_TABSTOP,184,112,54,10
CTEXT "For notes on maximizing performance on hardware, click on the 'Help' button and view the hardware section in the 'Readme.txt' file.",
IDC_STATIC,8,160,253,17
CONTROL "Dither",IDC_CHECK_DITHER,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,184,164,35,10
WS_TABSTOP,184,124,35,10
CONTROL "Page Manager",IDC_CHECK_PAGEMANAGED,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,184,176,63,10
GROUPBOX "Window Mode",IDC_STATIC,176,88,103,36
COMBOBOX IDC_COMBO_WINDOWMODE,184,104,85,78,CBS_DROPDOWN |
CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
BS_AUTOCHECKBOX | WS_TABSTOP,184,136,63,10
END
IDD_DXERROR DIALOG DISCARDABLE 0, 0, 252, 101
@ -135,9 +132,9 @@ BEGIN
IDD_INITIALIZATION, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 285
RIGHTMARGIN, 265
TOPMARGIN, 7
BOTTOMMARGIN, 218
BOTTOMMARGIN, 178
END
IDD_DXERROR, DIALOG

View File

@ -1083,10 +1083,6 @@ void COptionsWnd::UIButtonUp(CUIButton * pbutton)
if (dlg.m_dwExitValue != 0)
{
EndUIWnd(dlg.m_dwExitValue);
if (dlg.m_dwExitValue == 2)
{
g_CTPassGlobals.ResetScreen();
}
}
}
break;

View File

@ -569,18 +569,6 @@ void CUIWnd::ResizeScreen(int iWidth, int iHeight)
}
void CUIWnd::OnWindowPosChanged()
{
if (!m_pUIMgr)
return;
for (auto* wnd : m_pUIMgr->m_vUIWnd)
{
if (wnd)
CenterUIWindow(wnd);
}
}
void CUIWnd::DrawIntoSurface(LPBYTE pbDst,
int iDstWidth,
int iDstHeight,

View File

@ -151,7 +151,6 @@ public:
virtual void OnTimer(UINT uiID);
virtual void OnPaint(HWND hwnd);
virtual BOOL OnEraseBkgnd(HWND hwnd, HDC hdc);
virtual void OnWindowPosChanged();
};