Merge pull request #501 from erorcun/erorcun

Screen mode selector and persistent map target fix
This commit is contained in:
erorcun 2020-05-01 21:21:05 +03:00 committed by GitHub
commit 90f5a8fa8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 55 deletions

View File

@ -394,6 +394,9 @@ CMenuManager::ThingsToDoBeforeLeavingPage()
#endif #endif
} else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
m_nDisplayVideoMode = m_nPrefsVideoMode; m_nDisplayVideoMode = m_nPrefsVideoMode;
#ifdef IMPROVED_VIDEOMODE
m_nSelectedScreenMode = m_nPrefsWindowed;
#endif
} }
if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) {
@ -1078,6 +1081,18 @@ CMenuManager::Draw()
AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp); AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp);
rightText = unicodeTemp; rightText = unicodeTemp;
break; break;
#ifdef IMPROVED_VIDEOMODE
case MENUACTION_SCREENMODE:
char mode[32];
if (m_nSelectedScreenMode == 0)
sprintf(mode, "FULLSCREEN");
else
sprintf(mode, "WINDOWED");
AsciiToUnicode(mode, unicodeTemp);
rightText = unicodeTemp;
break;
#endif
case MENUACTION_AUDIOHW: case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex == -1) if (m_nPrefsAudio3DProviderIndex == -1)
rightText = TheText.Get("FEA_NAH"); rightText = TheText.Get("FEA_NAH");
@ -1249,6 +1264,14 @@ CMenuManager::Draw()
SetHelperText(3); SetHelperText(3);
} }
} }
#ifdef IMPROVED_VIDEOMODE
if (m_nSelectedScreenMode != m_nPrefsWindowed) {
if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "SCRFOR") != 0
&& m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
m_nSelectedScreenMode = m_nPrefsWindowed;
}
}
#endif
// Sliders // Sliders
int lastActiveBarX; int lastActiveBarX;
@ -3060,6 +3083,7 @@ CMenuManager::LoadSettings()
m_nPrefsWindowed = 0; m_nPrefsWindowed = 0;
m_nPrefsSubsystem = 0; m_nPrefsSubsystem = 0;
} }
m_nSelectedScreenMode = m_nPrefsWindowed;
#else #else
CFileMgr::Read(fileHandle, gString, 20); CFileMgr::Read(fileHandle, gString, 20);
#endif #endif
@ -4489,6 +4513,16 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings(); SaveSettings();
} }
break; break;
#ifdef IMPROVED_VIDEOMODE
case MENUACTION_SCREENMODE:
if (m_nSelectedScreenMode != m_nPrefsWindowed) {
m_nPrefsWindowed = m_nSelectedScreenMode;
_psSelectScreenVM(m_nPrefsVideoMode); // apply same resolution
SetHelperText(0);
SaveSettings();
}
break;
#endif
case MENUACTION_AUDIOHW: case MENUACTION_AUDIOHW:
{ {
int selectedProvider = m_nPrefsAudio3DProviderIndex; int selectedProvider = m_nPrefsAudio3DProviderIndex;
@ -4762,6 +4796,12 @@ CMenuManager::ProcessButtonPresses(void)
} }
} }
break; break;
#ifdef IMPROVED_VIDEOMODE
case MENUACTION_SCREENMODE:
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
m_nSelectedScreenMode = !m_nSelectedScreenMode;
break;
#endif
case MENUACTION_AUDIOHW: case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex != -1) { if (m_nPrefsAudio3DProviderIndex != -1) {
m_nPrefsAudio3DProviderIndex += changeValueBy; m_nPrefsAudio3DProviderIndex += changeValueBy;

View File

@ -371,6 +371,9 @@ enum eMenuAction
MENUACTION_LANG_RUS, MENUACTION_LANG_RUS,
MENUACTION_LANG_JAP, MENUACTION_LANG_JAP,
#endif #endif
#ifdef IMPROVED_VIDEOMODE
MENUACTION_SCREENMODE
#endif
}; };
enum eCheckHover enum eCheckHover
@ -539,6 +542,7 @@ public:
int32 m_nPrefsDepth; int32 m_nPrefsDepth;
int32 m_nPrefsWindowed; int32 m_nPrefsWindowed;
int32 m_nPrefsSubsystem; int32 m_nPrefsSubsystem;
int32 m_nSelectedScreenMode;
#endif #endif
public: public:

View File

@ -62,6 +62,9 @@ const CMenuScreen aScreens[] = {
MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
#ifdef IMPROVED_VIDEOMODE
MENUACTION_SCREENMODE, "SCRFOR", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
#endif
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
}, },

View File

@ -1064,6 +1064,13 @@ void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
INITSAVEBUF INITSAVEBUF
WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE); WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
#ifdef MENU_MAP
if (TargetMarkerId != -1) {
ClearBlip(TargetMarkerId);
TargetMarkerId = -1;
}
#endif
for (int i = 0; i < NUMRADARBLIPS; i++) for (int i = 0; i < NUMRADARBLIPS; i++)
WriteSaveBuf(buf, ms_RadarTrace[i]); WriteSaveBuf(buf, ms_RadarTrace[i]);

View File

@ -49,7 +49,13 @@ static RwInt32 GcurSel = 0, GcurSelVM = 0;
static RwBool useDefault; static RwBool useDefault;
// What is that for anyway?
#ifndef IMPROVED_VIDEOMODE
static RwBool defaultFullscreenRes = TRUE; static RwBool defaultFullscreenRes = TRUE;
#else
static RwBool defaultFullscreenRes = FALSE;
static RwInt32 bestWndMode = -1;
#endif
static psGlobalType PsGlobal; static psGlobalType PsGlobal;
@ -421,11 +427,7 @@ 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;
@ -607,17 +609,15 @@ psSelectDevice()
} }
// Find the videomode that best fits what we got from the settings file // Find the videomode that best fits what we got from the settings file
RwInt32 bestMode = -1; RwInt32 bestFsMode = -1;
RwInt32 bestWidth = -1; RwInt32 bestWidth = -1;
RwInt32 bestHeight = -1; RwInt32 bestHeight = -1;
RwInt32 bestDepth = -1; RwInt32 bestDepth = -1;
for(GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++){ for(GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++){
RwEngineGetVideoModeInfo(&vm, GcurSelVM); RwEngineGetVideoModeInfo(&vm, GcurSelVM);
if(!(vm.flags & rwVIDEOMODEEXCLUSIVE) != FrontEndMenuManager.m_nPrefsWindowed)
continue;
if(FrontEndMenuManager.m_nPrefsWindowed){ if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)){
bestMode = GcurSelVM; bestWndMode = GcurSelVM;
} else { } else {
// try the largest one that isn't larger than what we wanted // try the largest one that isn't larger than what we wanted
if(vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth && if(vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
@ -626,32 +626,34 @@ psSelectDevice()
bestWidth = vm.width; bestWidth = vm.width;
bestHeight = vm.height; bestHeight = vm.height;
bestDepth = vm.depth; bestDepth = vm.depth;
bestMode = GcurSelVM; bestFsMode = GcurSelVM;
} }
} }
} }
if(bestMode < 0){ if(bestFsMode < 0){
MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK); MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
return FALSE; return FALSE;
} }
GcurSelVM = bestMode; GcurSelVM = bestFsMode;
FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM; FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode; FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
GcurSelVM = FrontEndMenuManager.m_nDisplayVideoMode;
FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
} }
#endif #endif
RwEngineGetVideoModeInfo(&vm, GcurSelVM); RwEngineGetVideoModeInfo(&vm, GcurSelVM);
#ifdef IMPROVED_VIDEOMODE #ifdef IMPROVED_VIDEOMODE
if(vm.flags & rwVIDEOMODEEXCLUSIVE){ 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_nPrefsWidth = vm.width;
FrontEndMenuManager.m_nPrefsHeight = vm.height; FrontEndMenuManager.m_nPrefsHeight = vm.height;
FrontEndMenuManager.m_nPrefsDepth = vm.depth; FrontEndMenuManager.m_nPrefsDepth = vm.depth;
}
FrontEndMenuManager.m_nPrefsWindowed = !(vm.flags & rwVIDEOMODEEXCLUSIVE);
#endif #endif
FrontEndMenuManager.m_nCurrOption = 0; FrontEndMenuManager.m_nCurrOption = 0;
@ -677,6 +679,7 @@ psSelectDevice()
} }
} }
*/ */
#ifndef IMPROVED_VIDEOMODE
if (vm.flags & rwVIDEOMODEEXCLUSIVE) if (vm.flags & rwVIDEOMODEEXCLUSIVE)
{ {
RsGlobal.maximumWidth = vm.width; RsGlobal.maximumWidth = vm.width;
@ -686,15 +689,13 @@ psSelectDevice()
PSGLOBAL(fullScreen) = TRUE; PSGLOBAL(fullScreen) = TRUE;
} }
#ifdef IMPROVED_VIDEOMODE #else
else{
RsGlobal.maximumWidth = FrontEndMenuManager.m_nPrefsWidth; RsGlobal.maximumWidth = FrontEndMenuManager.m_nPrefsWidth;
RsGlobal.maximumHeight = FrontEndMenuManager.m_nPrefsHeight; RsGlobal.maximumHeight = FrontEndMenuManager.m_nPrefsHeight;
RsGlobal.width = FrontEndMenuManager.m_nPrefsWidth; RsGlobal.width = FrontEndMenuManager.m_nPrefsWidth;
RsGlobal.height = FrontEndMenuManager.m_nPrefsHeight; RsGlobal.height = FrontEndMenuManager.m_nPrefsHeight;
PSGLOBAL(fullScreen) = FALSE; PSGLOBAL(fullScreen) = !FrontEndMenuManager.m_nPrefsWindowed;
}
#endif #endif
return TRUE; return TRUE;
@ -1023,6 +1024,8 @@ void resizeCB(GLFWwindow* window, int width, int height) {
if (RwInitialised && height > 0 && width > 0) { if (RwInitialised && height > 0 && width > 0) {
RwRect r; RwRect r;
// TODO support resizing with mouse. Now enabling this makes weird things to trails and CameraSize messing with sizes
r.x = 0; r.x = 0;
r.y = 0; r.y = 0;
r.w = RsGlobal.maximumWidth; r.w = RsGlobal.maximumWidth;

View File

@ -59,8 +59,6 @@ static RwBool startupDeactivate;
static RwBool useDefault; static RwBool useDefault;
static RwBool defaultFullscreenRes = TRUE;
/* Class name for the MS Window's window class. */ /* Class name for the MS Window's window class. */
static const RwChar *AppClassName = RWSTRING("Grand theft auto 3"); static const RwChar *AppClassName = RWSTRING("Grand theft auto 3");
@ -113,6 +111,14 @@ DWORD _dwOperatingSystemVersion;
RwUInt32 gGameState; RwUInt32 gGameState;
CJoySticks AllValidWinJoys; 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() CJoySticks::CJoySticks()
{ {
for (int i = 0; i < MAX_JOYSTICKS; i++) for (int i = 0; i < MAX_JOYSTICKS; i++)
@ -791,11 +797,7 @@ 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;
@ -1388,17 +1390,15 @@ psSelectDevice()
} }
// Find the videomode that best fits what we got from the settings file // Find the videomode that best fits what we got from the settings file
RwInt32 bestMode = -1; RwInt32 bestFsMode = -1;
RwInt32 bestWidth = -1; RwInt32 bestWidth = -1;
RwInt32 bestHeight = -1; RwInt32 bestHeight = -1;
RwInt32 bestDepth = -1; RwInt32 bestDepth = -1;
for (GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++) { for (GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++) {
RwEngineGetVideoModeInfo(&vm, GcurSelVM); RwEngineGetVideoModeInfo(&vm, GcurSelVM);
if(!(vm.flags & rwVIDEOMODEEXCLUSIVE) != FrontEndMenuManager.m_nPrefsWindowed)
continue;
if(FrontEndMenuManager.m_nPrefsWindowed){ if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)) {
bestMode = GcurSelVM; bestWndMode = GcurSelVM;
} else { } else {
// try the largest one that isn't larger than what we wanted // try the largest one that isn't larger than what we wanted
if (vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth && if (vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
@ -1407,32 +1407,34 @@ psSelectDevice()
bestWidth = vm.width; bestWidth = vm.width;
bestHeight = vm.height; bestHeight = vm.height;
bestDepth = vm.depth; bestDepth = vm.depth;
bestMode = GcurSelVM; bestFsMode = GcurSelVM;
} }
} }
} }
if(bestMode < 0){ if(bestFsMode < 0){
MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK); MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
return FALSE; return FALSE;
} }
GcurSelVM = bestMode; GcurSelVM = bestFsMode;
FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM; FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode; FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
GcurSelVM = FrontEndMenuManager.m_nDisplayVideoMode;
FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
} }
#endif #endif
RwEngineGetVideoModeInfo(&vm, GcurSelVM); RwEngineGetVideoModeInfo(&vm, GcurSelVM);
#ifdef IMPROVED_VIDEOMODE #ifdef IMPROVED_VIDEOMODE
if(vm.flags & rwVIDEOMODEEXCLUSIVE){ 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_nPrefsWidth = vm.width;
FrontEndMenuManager.m_nPrefsHeight = vm.height; FrontEndMenuManager.m_nPrefsHeight = vm.height;
FrontEndMenuManager.m_nPrefsDepth = vm.depth; FrontEndMenuManager.m_nPrefsDepth = vm.depth;
}
FrontEndMenuManager.m_nPrefsWindowed = !(vm.flags & rwVIDEOMODEEXCLUSIVE);
#endif #endif
FrontEndMenuManager.m_nCurrOption = 0; FrontEndMenuManager.m_nCurrOption = 0;
@ -1444,7 +1446,11 @@ psSelectDevice()
return FALSE; return FALSE;
} }
#ifdef IMPROVED_VIDEOMODE
if (!FrontEndMenuManager.m_nPrefsWindowed)
#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE) if (vm.flags & rwVIDEOMODEEXCLUSIVE)
#endif
{ {
debug("%dx%dx%d", vm.width, vm.height, vm.depth); debug("%dx%dx%d", vm.width, vm.height, vm.depth);
@ -1457,7 +1463,11 @@ psSelectDevice()
} }
} }
#ifdef IMPROVED_VIDEOMODE
if (!FrontEndMenuManager.m_nPrefsWindowed)
#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE) if (vm.flags & rwVIDEOMODEEXCLUSIVE)
#endif
{ {
RsGlobal.maximumWidth = vm.width; RsGlobal.maximumWidth = vm.width;
RsGlobal.maximumHeight = vm.height; RsGlobal.maximumHeight = vm.height;