summaryrefslogtreecommitdiffstats
path: root/src/skel/win/win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/skel/win/win.cpp')
-rw-r--r--src/skel/win/win.cpp129
1 files changed, 121 insertions, 8 deletions
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 288788c0..d20cc0bf 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -59,8 +59,6 @@ static RwBool startupDeactivate;
static RwBool useDefault;
-static RwBool defaultFullscreenRes = TRUE;
-
/* Class name for the MS Window's window class. */
static const RwChar *AppClassName = RWSTRING("Grand theft auto 3");
@@ -113,6 +111,14 @@ DWORD _dwOperatingSystemVersion;
RwUInt32 gGameState;
CJoySticks AllValidWinJoys;
+// What is that for anyway?
+#ifndef IMPROVED_VIDEOMODE
+static RwBool defaultFullscreenRes = TRUE;
+#else
+static RwBool defaultFullscreenRes = FALSE;
+static RwInt32 bestWndMode = -1;
+#endif
+
CJoySticks::CJoySticks()
{
for (int i = 0; i < MAX_JOYSTICKS; i++)
@@ -1310,6 +1316,10 @@ psSelectDevice()
/* Get the default selection */
GcurSel = RwEngineGetCurrentSubSystem();
+#ifdef IMPROVED_VIDEOMODE
+ if(FrontEndMenuManager.m_nPrefsSubsystem < GnumSubSystems)
+ GcurSel = FrontEndMenuManager.m_nPrefsSubsystem;
+#endif
}
/* Set the driver to use the correct sub system */
@@ -1317,8 +1327,12 @@ psSelectDevice()
{
return FALSE;
}
-
-
+
+#ifdef IMPROVED_VIDEOMODE
+ FrontEndMenuManager.m_nPrefsSubsystem = GcurSel;
+#endif
+
+#ifndef IMPROVED_VIDEOMODE
if ( !useDefault )
{
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
@@ -1362,9 +1376,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 bestFsMode = -1;
+ RwInt32 bestWidth = -1;
+ RwInt32 bestHeight = -1;
+ RwInt32 bestDepth = -1;
+ for (GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++) {
+ RwEngineGetVideoModeInfo(&vm, GcurSelVM);
+
+ if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)) {
+ bestWndMode = 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;
+ bestFsMode = GcurSelVM;
+ }
+ }
+ }
+
+ if(bestFsMode < 0){
+ MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
+ return FALSE;
+ }
+ GcurSelVM = bestFsMode;
+
+ FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
+ FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
+
+ FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
+ }
+#endif
+
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
-
+
+#ifdef IMPROVED_VIDEOMODE
+ if (FrontEndMenuManager.m_nPrefsWindowed)
+ GcurSelVM = bestWndMode;
+
+ // Now GcurSelVM is 0 but vm has sizes(and fullscreen flag) of the video mode we want, that's why we changed the rwVIDEOMODEEXCLUSIVE conditions below
+ FrontEndMenuManager.m_nPrefsWidth = vm.width;
+ FrontEndMenuManager.m_nPrefsHeight = vm.height;
+ FrontEndMenuManager.m_nPrefsDepth = vm.depth;
+#endif
+
FrontEndMenuManager.m_nCurrOption = 0;
/* Set up the video mode and set the apps window
@@ -1374,7 +1446,11 @@ psSelectDevice()
return FALSE;
}
+#ifdef IMPROVED_VIDEOMODE
+ if (!FrontEndMenuManager.m_nPrefsWindowed)
+#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
+#endif
{
debug("%dx%dx%d", vm.width, vm.height, vm.depth);
@@ -1387,7 +1463,11 @@ psSelectDevice()
}
}
+#ifdef IMPROVED_VIDEOMODE
+ if (!FrontEndMenuManager.m_nPrefsWindowed)
+#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
+#endif
{
RsGlobal.maximumWidth = vm.width;
RsGlobal.maximumHeight = vm.height;
@@ -1395,8 +1475,39 @@ psSelectDevice()
RsGlobal.height = vm.height;
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;
}
@@ -1840,11 +1951,13 @@ WinMain(HINSTANCE instance,
}
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
-
+
+#ifndef 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);
+#endif
/*
* Initialize the 3D (RenderWare) components of the app...