implemented improved video modes for win.cpp
This commit is contained in:
parent
474b0418d3
commit
804b022e67
@ -3038,7 +3038,24 @@ CMenuManager::LoadSettings()
|
|||||||
if (strncmp(Ver, TopLineEmptyFile, sizeof(TopLineEmptyFile) - 1)) {
|
if (strncmp(Ver, TopLineEmptyFile, sizeof(TopLineEmptyFile) - 1)) {
|
||||||
CFileMgr::Seek(fileHandle, 0, 0);
|
CFileMgr::Seek(fileHandle, 0, 0);
|
||||||
ControlsManager.LoadSettings(fileHandle);
|
ControlsManager.LoadSettings(fileHandle);
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
CFileMgr::Read(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
|
||||||
|
CFileMgr::Read(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
|
||||||
|
CFileMgr::Read(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
|
||||||
|
CFileMgr::Read(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
|
||||||
|
CFileMgr::Read(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
|
||||||
|
if(m_nPrefsWindowed != 0 && m_nPrefsWindowed != 1){
|
||||||
|
// garbage data from vanilla settings file
|
||||||
|
// let skeleton find something
|
||||||
|
m_nPrefsWidth = 0;
|
||||||
|
m_nPrefsHeight = 0;
|
||||||
|
m_nPrefsDepth = 0;
|
||||||
|
m_nPrefsWindowed = 0;
|
||||||
|
m_nPrefsSubsystem = 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
CFileMgr::Read(fileHandle, gString, 20);
|
CFileMgr::Read(fileHandle, gString, 20);
|
||||||
|
#endif
|
||||||
CFileMgr::Read(fileHandle, gString, 20);
|
CFileMgr::Read(fileHandle, gString, 20);
|
||||||
CFileMgr::Read(fileHandle, gString, 4);
|
CFileMgr::Read(fileHandle, gString, 4);
|
||||||
CFileMgr::Read(fileHandle, gString, 4);
|
CFileMgr::Read(fileHandle, gString, 4);
|
||||||
@ -3120,7 +3137,15 @@ CMenuManager::SaveSettings()
|
|||||||
int fileHandle = CFileMgr::OpenFile("gta3.set", "w+");
|
int fileHandle = CFileMgr::OpenFile("gta3.set", "w+");
|
||||||
if (fileHandle) {
|
if (fileHandle) {
|
||||||
ControlsManager.SaveSettings(fileHandle);
|
ControlsManager.SaveSettings(fileHandle);
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
CFileMgr::Write(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
|
||||||
|
CFileMgr::Write(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
|
||||||
|
CFileMgr::Write(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
|
||||||
|
CFileMgr::Write(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
|
||||||
|
CFileMgr::Write(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
|
||||||
|
#else
|
||||||
CFileMgr::Write(fileHandle, RubbishString, 20);
|
CFileMgr::Write(fileHandle, RubbishString, 20);
|
||||||
|
#endif
|
||||||
CFileMgr::Write(fileHandle, RubbishString, 20);
|
CFileMgr::Write(fileHandle, RubbishString, 20);
|
||||||
CFileMgr::Write(fileHandle, RubbishString, 4);
|
CFileMgr::Write(fileHandle, RubbishString, 4);
|
||||||
CFileMgr::Write(fileHandle, RubbishString, 4);
|
CFileMgr::Write(fileHandle, RubbishString, 4);
|
||||||
|
@ -533,6 +533,14 @@ public:
|
|||||||
int32 m_nCurrSaveSlot;
|
int32 m_nCurrSaveSlot;
|
||||||
int32 m_nScreenChangeDelayTimer;
|
int32 m_nScreenChangeDelayTimer;
|
||||||
|
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
int32 m_nPrefsWidth;
|
||||||
|
int32 m_nPrefsHeight;
|
||||||
|
int32 m_nPrefsDepth;
|
||||||
|
int32 m_nPrefsWindowed;
|
||||||
|
int32 m_nPrefsSubsystem;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool GetIsMenuActive() {return !!m_bMenuActive;}
|
bool GetIsMenuActive() {return !!m_bMenuActive;}
|
||||||
|
|
||||||
@ -645,7 +653,9 @@ public:
|
|||||||
// uint8 GetNumberOfMenuOptions();
|
// uint8 GetNumberOfMenuOptions();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef IMPROVED_VIDEOMODE
|
||||||
static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");
|
static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");
|
||||||
|
#endif
|
||||||
|
|
||||||
extern CMenuManager FrontEndMenuManager;
|
extern CMenuManager FrontEndMenuManager;
|
||||||
extern unsigned long _dwOperatingSystemVersion;
|
extern unsigned long _dwOperatingSystemVersion;
|
@ -192,6 +192,7 @@ enum Config {
|
|||||||
#define MORE_LANGUAGES // Add more translations to the game
|
#define MORE_LANGUAGES // Add more translations to the game
|
||||||
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
|
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
|
||||||
#define USE_TXD_CDIMAGE // generate and load textures from txd.img
|
#define USE_TXD_CDIMAGE // generate and load textures from txd.img
|
||||||
|
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
|
||||||
//#define USE_TEXTURE_POOL
|
//#define USE_TEXTURE_POOL
|
||||||
//#define OPENAL
|
//#define OPENAL
|
||||||
|
|
||||||
|
@ -791,7 +791,11 @@ RwChar **_psGetVideoModeList()
|
|||||||
_VMList[i] = nil;
|
_VMList[i] = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
_VMList[i] = strdup("WINDOW");
|
||||||
|
#else
|
||||||
_VMList[i] = nil;
|
_VMList[i] = nil;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return _VMList;
|
return _VMList;
|
||||||
@ -1310,6 +1314,10 @@ psSelectDevice()
|
|||||||
|
|
||||||
/* Get the default selection */
|
/* Get the default selection */
|
||||||
GcurSel = RwEngineGetCurrentSubSystem();
|
GcurSel = RwEngineGetCurrentSubSystem();
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
if(FrontEndMenuManager.m_nPrefsSubsystem < GnumSubSystems)
|
||||||
|
GcurSel = FrontEndMenuManager.m_nPrefsSubsystem;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the driver to use the correct sub system */
|
/* Set the driver to use the correct sub system */
|
||||||
@ -1318,7 +1326,11 @@ psSelectDevice()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
FrontEndMenuManager.m_nPrefsSubsystem = GcurSel;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IMPROVED_VIDEOMODE
|
||||||
if ( !useDefault )
|
if ( !useDefault )
|
||||||
{
|
{
|
||||||
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
|
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
|
||||||
@ -1362,9 +1374,67 @@ psSelectDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if ( !useDefault )
|
||||||
|
{
|
||||||
|
if(FrontEndMenuManager.m_nPrefsWidth == 0 ||
|
||||||
|
FrontEndMenuManager.m_nPrefsHeight == 0 ||
|
||||||
|
FrontEndMenuManager.m_nPrefsDepth == 0){
|
||||||
|
// Defaults if nothing specified
|
||||||
|
FrontEndMenuManager.m_nPrefsWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
FrontEndMenuManager.m_nPrefsHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
FrontEndMenuManager.m_nPrefsDepth = 32;
|
||||||
|
FrontEndMenuManager.m_nPrefsWindowed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the videomode that best fits what we got from the settings file
|
||||||
|
RwInt32 bestMode = -1;
|
||||||
|
RwInt32 bestWidth = -1;
|
||||||
|
RwInt32 bestHeight = -1;
|
||||||
|
RwInt32 bestDepth = -1;
|
||||||
|
for(GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++){
|
||||||
|
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
|
||||||
|
if(!(vm.flags & rwVIDEOMODEEXCLUSIVE) != FrontEndMenuManager.m_nPrefsWindowed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(FrontEndMenuManager.m_nPrefsWindowed){
|
||||||
|
bestMode = GcurSelVM;
|
||||||
|
}else{
|
||||||
|
// try the largest one that isn't larger than what we wanted
|
||||||
|
if(vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
|
||||||
|
vm.height >= bestHeight && vm.height <= FrontEndMenuManager.m_nPrefsHeight &&
|
||||||
|
vm.depth >= bestDepth && vm.depth <= FrontEndMenuManager.m_nPrefsDepth){
|
||||||
|
bestWidth = vm.width;
|
||||||
|
bestHeight = vm.height;
|
||||||
|
bestDepth = vm.depth;
|
||||||
|
bestMode = GcurSelVM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bestMode < 0){
|
||||||
|
MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
GcurSelVM = bestMode;
|
||||||
|
|
||||||
|
FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
|
||||||
|
FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
|
||||||
|
GcurSelVM = FrontEndMenuManager.m_nDisplayVideoMode;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
|
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
|
||||||
|
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
if(vm.flags & rwVIDEOMODEEXCLUSIVE){
|
||||||
|
FrontEndMenuManager.m_nPrefsWidth = vm.width;
|
||||||
|
FrontEndMenuManager.m_nPrefsHeight = vm.height;
|
||||||
|
FrontEndMenuManager.m_nPrefsDepth = vm.depth;
|
||||||
|
}
|
||||||
|
FrontEndMenuManager.m_nPrefsWindowed = !(vm.flags & rwVIDEOMODEEXCLUSIVE);
|
||||||
|
#endif
|
||||||
|
|
||||||
FrontEndMenuManager.m_nCurrOption = 0;
|
FrontEndMenuManager.m_nCurrOption = 0;
|
||||||
|
|
||||||
/* Set up the video mode and set the apps window
|
/* Set up the video mode and set the apps window
|
||||||
@ -1395,6 +1465,37 @@ psSelectDevice()
|
|||||||
RsGlobal.height = vm.height;
|
RsGlobal.height = vm.height;
|
||||||
|
|
||||||
PSGLOBAL(fullScreen) = TRUE;
|
PSGLOBAL(fullScreen) = TRUE;
|
||||||
|
|
||||||
|
#ifdef IMPROVED_VIDEOMODE
|
||||||
|
SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_POPUP);
|
||||||
|
SetWindowPos(PSGLOBAL(window), nil, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
|
||||||
|
SWP_FRAMECHANGED);
|
||||||
|
}else{
|
||||||
|
RECT rect;
|
||||||
|
rect.left = rect.top = 0;
|
||||||
|
rect.right = FrontEndMenuManager.m_nPrefsWidth;
|
||||||
|
rect.bottom = FrontEndMenuManager.m_nPrefsHeight;
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
|
||||||
|
// center it
|
||||||
|
int spaceX = GetSystemMetrics(SM_CXSCREEN) - (rect.right-rect.left);
|
||||||
|
int spaceY = GetSystemMetrics(SM_CYSCREEN) - (rect.bottom-rect.top);
|
||||||
|
|
||||||
|
SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW);
|
||||||
|
SetWindowPos(PSGLOBAL(window), HWND_NOTOPMOST, spaceX/2, spaceY/2,
|
||||||
|
(rect.right - rect.left),
|
||||||
|
(rect.bottom - rect.top), 0);
|
||||||
|
|
||||||
|
// Have to get actual size because the window perhaps didn't fit
|
||||||
|
GetClientRect(PSGLOBAL(window), &rect);
|
||||||
|
RsGlobal.maximumWidth = rect.right;
|
||||||
|
RsGlobal.maximumHeight = rect.bottom;
|
||||||
|
RsGlobal.width = rect.right;
|
||||||
|
RsGlobal.height = rect.bottom;
|
||||||
|
|
||||||
|
PSGLOBAL(fullScreen) = FALSE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1841,10 +1942,12 @@ WinMain(HINSTANCE instance,
|
|||||||
|
|
||||||
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
|
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
|
||||||
|
|
||||||
|
#ifndef IMPROVED_VIDEOMODE
|
||||||
SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_POPUP);
|
SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_POPUP);
|
||||||
SetWindowPos(PSGLOBAL(window), nil, 0, 0, 0, 0,
|
SetWindowPos(PSGLOBAL(window), nil, 0, 0, 0, 0,
|
||||||
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
|
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
|
||||||
SWP_FRAMECHANGED);
|
SWP_FRAMECHANGED);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the 3D (RenderWare) components of the app...
|
* Initialize the 3D (RenderWare) components of the app...
|
||||||
|
Loading…
Reference in New Issue
Block a user