From 6c693e3bbfe46cb445e4664eb91ef85c811a6240 Mon Sep 17 00:00:00 2001 From: _AG Date: Tue, 2 Jul 2019 13:59:19 +0200 Subject: Implemented frontend inputs. Fixed #66 and few other stuff. --- src/ControllerConfig.cpp | 5 + src/ControllerConfig.h | 1 + src/Frontend.cpp | 1201 ++++++++++++++++++++++++++++++++++++++++++++-- src/Frontend.h | 21 +- src/MenuScreens.h | 84 ++-- src/PCSave.cpp | 8 + src/PCSave.h | 7 + src/Pad.cpp | 3 +- src/Pad.h | 17 + src/PlayerSkin.cpp | 5 + src/PlayerSkin.h | 7 + src/Radar.h | 7 + src/audio/DMAudio.cpp | 9 +- src/audio/DMAudio.h | 8 +- src/common.h | 1 + src/config.h | 4 + src/entities/Vehicle.cpp | 3 +- src/entities/Vehicle.h | 1 + src/main.cpp | 7 +- src/main.h | 1 + src/render/Draw.cpp | 65 ++- src/render/Draw.h | 12 + src/render/Hud.cpp | 18 +- src/skel/win/win.cpp | 12 +- src/skel/win/win.h | 4 + 25 files changed, 1386 insertions(+), 125 deletions(-) create mode 100644 src/PlayerSkin.cpp create mode 100644 src/PlayerSkin.h diff --git a/src/ControllerConfig.cpp b/src/ControllerConfig.cpp index a401e093..d7567ac4 100644 --- a/src/ControllerConfig.cpp +++ b/src/ControllerConfig.cpp @@ -50,3 +50,8 @@ void CControllerConfigManager::LoadSettings(int32 file) } } } + +WRAPPER void CControllerConfigManager::SaveSettings(int32 file) +{ + EAXJMP(0x58B800); +} diff --git a/src/ControllerConfig.h b/src/ControllerConfig.h index 00cab82e..581efe05 100644 --- a/src/ControllerConfig.h +++ b/src/ControllerConfig.h @@ -42,6 +42,7 @@ public: int32 GetJoyButtonJustDown(); void LoadSettings(int32 file); + void SaveSettings(int32 file); void MakeControllerActionsBlank(); void InitDefaultControlConfiguration(); void InitDefaultControlConfigMouse(CMouseControllerState const &mousestate); diff --git a/src/Frontend.cpp b/src/Frontend.cpp index 8eff0324..8bff985b 100644 --- a/src/Frontend.cpp +++ b/src/Frontend.cpp @@ -20,6 +20,10 @@ #include "Script.h" #include "Camera.h" #include "MenuScreens.h" +#include "ControllerConfig.h" +#include "Vehicle.h" +#include "MBlur.h" +#include "PlayerSkin.h" int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; @@ -47,8 +51,21 @@ int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; +uint8 *CMenuManager::m_PrefsSkinFile = (uint8*)0x5F2E74; + CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; +// Move this somewhere else. +float lodMultiplier = *(float*)0x5F726C; + +// Stuff not in CMenuManager: +int VibrationTime; +char* pEditString; +int32 pControlEdit; +int8 DisplayComboButtonErrMsg; +bool MouseButtonJustClicked; +bool JoyButtonJustClicked; + char *FrontendFilenames[] = { "fe2_mainpanel_ul", "fe2_mainpanel_ur", @@ -150,6 +167,78 @@ bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) } #endif +void CMenuManager::CheckSliderMovement(int value) +{ + float fBrightness = 0.0f; + float fDrawDistance = 0.0f; + float fRadioVolume = 0.0f; + float fSfxVolume = 0.0f; + float fMouseSens = 0.0f; + + switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { + case MENUACTION_BRIGHTNESS: + fBrightness = m_PrefsBrightness + (value * (512.0f) / 16.0f); + + if (fBrightness > 511.0f) + fBrightness = 511.0f; + else if (fBrightness < 0.0f) + fBrightness = 0.0f; + + m_PrefsBrightness = fBrightness; + SaveSettings(); + break; + case MENUACTION_DRAWDIST: + fDrawDistance = m_PrefsLOD + (value * (1.8f - 0.8f) / 16.0f); + + if (fDrawDistance > 1.8f) + fDrawDistance = 1.8f; + else if (fDrawDistance < 0.8f) + fDrawDistance = 0.8f; + + m_PrefsLOD = fDrawDistance; + SaveSettings(); + break; + case MENUACTION_MUSICVOLUME: + fRadioVolume = m_PrefsMusicVolume + (value * (128.0f) / 16.0f); + + if (fRadioVolume > 127.0f) + fRadioVolume = 127.0f; + else if (fRadioVolume < 0.0f) + fRadioVolume = 0.0f; + + m_PrefsMusicVolume = fRadioVolume; + DMAudio.SetMusicMasterVolume(fRadioVolume); + SaveSettings(); + break; + case MENUACTION_SFXVOLUME: + fSfxVolume = m_PrefsSfxVolume + (value * (128.0f) / 16.0f); + + if (fSfxVolume > 127) + fSfxVolume = 127; + else if (fSfxVolume < 0.0f) + fSfxVolume = 0.0f; + + m_PrefsSfxVolume = fSfxVolume; + DMAudio.SetEffectsMasterVolume(fSfxVolume); + SaveSettings(); + break; + case MENUACTION_MOUSESENS: + fMouseSens = TheCamera.m_fMouseAccelHorzntl + (value * (0.005f - 0.0003125f) / 16.0f); + + if (fMouseSens > 0.005f) + fMouseSens = 0.005f; + else if (fMouseSens < 0.0003125f) + fMouseSens = 0.0003125f; + + TheCamera.m_fMouseAccelHorzntl = fMouseSens; + + // BUG: game doesn't set Y Axis. + TheCamera.m_fMouseAccelVertical = fMouseSens; + SaveSettings(); + break; + }; +} + #if 1 WRAPPER int CMenuManager::CostructStatLine(int) { EAXJMP(0x482800); } #else @@ -164,22 +253,38 @@ WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } #else void CMenuManager::DisplayHelperText() { - wchar *str = nil; + static int32 AlphaText = 255; + static int32 Time = 0; + + if (m_nHelperTextMsgId && m_nHelperTextMsgId != 1) { + if (CTimer::GetTimeInMillisecondsPauseMode() - Time > 10) { + Time = CTimer::GetTimeInMillisecondsPauseMode(); + m_nHelperTextAlpha -= 2; + + if (AlphaText < 1) + ResetHelperText(); + + AlphaText = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha; + } + } + + wchar *HelperTextToPrint = nil; + // TODO: name this cases? switch (m_nHelperTextMsgId) { case 0: - str = TheText.Get("FET_MIG"); + HelperTextToPrint = TheText.Get("FET_MIG"); break; case 1: - str = TheText.Get("FET_APP"); + HelperTextToPrint = TheText.Get("FET_APP"); break; case 2: - str = TheText.Get("FET_HRD"); + HelperTextToPrint = TheText.Get("FET_HRD"); break; case 3: - str = TheText.Get("FET_RSO"); + HelperTextToPrint = TheText.Get("FET_RSO"); break; case 4: - str = TheText.Get("FET_RSC"); + HelperTextToPrint = TheText.Get("FET_RSC"); break; default: break; @@ -188,11 +293,11 @@ void CMenuManager::DisplayHelperText() CFont::SetAlignment(ALIGN_CENTER); CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetFontStyle(FONT_HEADING); - CFont::SetDropColor(CRGBA(0, 0, 0, MENUDROP_COLOR_A)); + CFont::SetDropColor(CRGBA(0, 0, 0, AlphaText)); CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); + CFont::SetColor(CRGBA(255, 255, 255, AlphaText)); - CFont::SetColor(CRGBA(255, 255, 255, 255)); - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), str); + CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), HelperTextToPrint); } #endif @@ -227,12 +332,22 @@ float CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightS } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } #else -WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() +void CMenuManager::DoSettingsBeforeStartingAGame() { + CCamera::m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; + m_bStartGameLoading = true; + + ShutdownJustMenu(); + UnloadTextures(); + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); } #endif @@ -311,6 +426,7 @@ void CMenuManager::Draw() for (int i = 0; i < MENUROWS; ++i) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0]) { wchar *textToPrint[MENUCOLUMNS] = { nil, nil }; + bool Locked = false; if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1); @@ -323,6 +439,13 @@ void CMenuManager::Draw() } else { textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); + + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_SCREENRES) { + if (m_bGameNotLoaded) + Locked = false; + else + Locked = true; + } } switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { @@ -359,7 +482,39 @@ void CMenuManager::Draw() textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsShowSubtitles ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_WIDESCREEN: +#ifndef HOR_PLUS textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsUseWideScreen ? "FEM_ON" : "FEM_OFF"); +#else + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"AUTO"; + break; + case AR_3_2: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"3:2"; + break; + case AR_4_3: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"4:3"; + break; + case AR_5_3: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"5:3"; + break; + case AR_5_4: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"5:4"; + break; + case AR_15_9: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"15:9"; + break; + case AR_16_9: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; + break; + case AR_16_10: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:10"; + break; + case AR_64_27: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"64:27"; + break; + }; +#endif break; case MENUACTION_RADIO: sprintf(gString, "FEA_FM%d", m_PrefsRadioStation); @@ -386,16 +541,16 @@ void CMenuManager::Draw() } break; case MENUACTION_AUDIOHW: - if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) + if (m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { - char *provider = MusicManager.Get3DProviderName(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); + char *provider = MusicManager.Get3DProviderName(m_nPrefsAudio3DProviderIndex); AsciiToUnicode(provider, gUString); textToPrint[MENUCOLUMN_RIGHT] = gUString; } break; case MENUACTION_SPEAKERCONF: - if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) + if (m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { switch (m_PrefsSpeakers) { @@ -426,7 +581,7 @@ void CMenuManager::Draw() break; case MENUACTION_MOUSESTEER: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_ON" : "FEM_OFF"); - break; + break; }; CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); @@ -496,6 +651,7 @@ void CMenuManager::Draw() case MENUPAGE_LANGUAGE_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MIN_Y); break; + case MENUPAGE_MOUSE_CONTROLS: case MENUPAGE_GRAPHICS_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MAX_Y); break; @@ -525,7 +681,7 @@ void CMenuManager::Draw() CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); CSprite2d::DrawRect(CRect(SCREEN_STRETCH_X(11.0f), vecPositions.y - SCREEN_STRETCH_Y(fBarSize * 0.13f), SCREEN_STRETCH_FROM_RIGHT(11.0f), vecPositions.y + SCREEN_STRETCH_Y(fBarSize)), CRGBA(100, 200, 50, 50)); } - else + else CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); // Draw @@ -533,32 +689,40 @@ void CMenuManager::Draw() CFont::PrintString(vecPositions.x, vecPositions.y, textToPrint[MENUCOLUMN_LEFT]); if (textToPrint[MENUCOLUMN_RIGHT]) { + if (Locked) + CFont::SetColor(CRGBA(190, 130, 40, FadeIn(255))); + CFont::SetAlignment(ALIGN_RIGHT); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SavePageSlot ? MENUCOLUMN_SAVE_X : MENUCOLUMN_POS_X), vecPositions.y, textToPrint[MENUCOLUMN_RIGHT]); } // Mouse support. - bool bIsMouseInPosition = false; - if (m_nMenuFadeAlpha >= 255) { - CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; - if (m_bShowMouse && - ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) - bIsMouseInPosition = true; - else - bIsMouseInPosition = false; + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + //TODO: inputs for these pages. + } + else { + static bool bIsMouseInPosition = false; + if (m_nMenuFadeAlpha >= 255 && MOUSE_INPUT) { + CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; + if (m_bShowMouse && + ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) + bIsMouseInPosition = true; + else + bIsMouseInPosition = false; - if (bIsMouseInPosition) { - if (m_nCurrOption != i) { - m_nCurrOption = i; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } + if (bIsMouseInPosition) { + if (m_nCurrOption != i) { + m_nCurrOption = i; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } - m_nCurrentInput = m_nCurrOption; + m_nPrevOption = m_nCurrOption; - if (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB) - m_nHoverOption = IGNORE_OPTION; - else - m_nHoverOption = ACTIVATE_OPTION; + if (MOUSE_LMB) + m_nHoverOption = IGNORE_OPTION; + else + m_nHoverOption = ACTIVATE_OPTION; + } } } @@ -586,14 +750,21 @@ void CMenuManager::Draw() float fIconSpacing = 59.52f; if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { for (int i = 0; i < POLICE_RADIO; i++) { - - if (i == MSX_FM) - fIconSpacing -= 1.5f; - +#ifndef MID_RADIOICONS if (i < USERTRACK) m_aFrontEndSprites[i + FE_RADIO1].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, DMAudio.IsMP3RadioChannelAvailable() ? 170 : 25)); + if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) + m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); +#else + float fMp3Pos = 0.0f; + if (DMAudio.IsMP3RadioChannelAvailable()) + fMp3Pos = 34.0f; + + if (i < USERTRACK) + m_aFrontEndSprites[i + FE_RADIO1].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); + if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) + m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); +#endif } } @@ -876,12 +1047,31 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); } #else void CMenuManager::InitialiseChangedLanguageSettings() { + if (m_bFrontEnd_ReloadObrTxtGxt) { + CTimer::Stop(); + TheText.Unload(); + TheText.Load(); + CTimer::Update(); + CGame::frenchGame = false; + CGame::germanGame = false; + switch (CMenuManager::m_PrefsLanguage) { + case LANGUAGE_FRENCH: + CGame::frenchGame = true; + break; + case LANGUAGE_GERMAN: + CGame::germanGame = true; + break; + default: + return; + }; + m_bFrontEnd_ReloadObrTxtGxt = false; + } } #endif @@ -943,12 +1133,103 @@ void CMenuManager::LoadAllTextures() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } #else void CMenuManager::LoadSettings() { + CFileMgr::SetDirMyDocuments(); + + uint8 prevLang = m_PrefsLanguage; + MousePointerStateHelper.bInvertVertically = true; + + static char Ver; + int fileHandle = CFileMgr::OpenFile("gta3.set", "rb"); + if (fileHandle) { + CFileMgr::Read(fileHandle, buf(&Ver), sizeof(Ver)); + + if (strncmp(&Ver, "THIS FILE IS NOT VALID YET", 26)) { + CFileMgr::Seek(fileHandle, 0, 0); + ControlsManager.LoadSettings(fileHandle); + CFileMgr::Read(fileHandle, buf(&gString), 20); + CFileMgr::Read(fileHandle, buf(&gString), 20); + CFileMgr::Read(fileHandle, buf(&gString), 4); + CFileMgr::Read(fileHandle, buf(&gString), 4); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_bHeadBob), sizeof(TheCamera.m_bHeadBob)); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), sizeof(TheCamera.m_fMouseAccelHorzntl)); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), sizeof(TheCamera.m_fMouseAccelVertical)); + CFileMgr::Read(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), sizeof(MousePointerStateHelper.bInvertVertically)); + CFileMgr::Read(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), sizeof(CVehicle::m_bDisableMouseSteering)); + CFileMgr::Read(fileHandle, buf(&m_PrefsSfxVolume), sizeof(m_PrefsSfxVolume)); + CFileMgr::Read(fileHandle, buf(&m_PrefsMusicVolume), sizeof(m_PrefsMusicVolume)); + CFileMgr::Read(fileHandle, buf(&m_PrefsRadioStation), sizeof(m_PrefsRadioStation)); + CFileMgr::Read(fileHandle, buf(&m_PrefsSpeakers), sizeof(m_PrefsSpeakers)); + CFileMgr::Read(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), sizeof(m_nPrefsAudio3DProviderIndex)); + CFileMgr::Read(fileHandle, buf(&m_PrefsDMA), sizeof(m_PrefsDMA)); + CFileMgr::Read(fileHandle, buf(&m_PrefsBrightness), sizeof(m_PrefsBrightness)); + CFileMgr::Read(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); + CFileMgr::Read(fileHandle, buf(&m_PrefsShowSubtitles), sizeof(m_PrefsShowSubtitles)); + CFileMgr::Read(fileHandle, buf(&m_PrefsUseWideScreen), sizeof(m_PrefsUseWideScreen)); + CFileMgr::Read(fileHandle, buf(&m_PrefsVsyncDisp), sizeof(m_PrefsVsyncDisp)); + CFileMgr::Read(fileHandle, buf(&m_PrefsFrameLimiter), sizeof(m_PrefsFrameLimiter)); + CFileMgr::Read(fileHandle, buf(&m_nDisplayVideoMode), sizeof(m_nPrefsVideoMode)); + CFileMgr::Read(fileHandle, buf(&BlurOn), sizeof(BlurOn)); + CFileMgr::Read(fileHandle, buf(&m_PrefsSkinFile), sizeof(m_PrefsSkinFile)); + CFileMgr::Read(fileHandle, buf(&m_ControlMethod), sizeof(m_ControlMethod)); + CFileMgr::Read(fileHandle, buf(&m_PrefsLanguage), sizeof(m_PrefsLanguage)); + } + } + + CFileMgr::CloseFile(fileHandle); + CFileMgr::SetDir(""); + +#ifndef HOR_PLUS +#else + if (m_PrefsUseWideScreen < AR_AUTO || m_PrefsUseWideScreen > AR_64_27) + m_PrefsUseWideScreen = AR_AUTO; +#endif + + m_PrefsVsync = m_PrefsVsyncDisp; + lodMultiplier = m_PrefsLOD; + + if (m_nPrefsAudio3DProviderIndex == -1) + m_nPrefsAudio3DProviderIndex = -2; + + if (m_PrefsLanguage == prevLang) + m_bLanguageLoaded = false; + else { + m_bLanguageLoaded = true; + TheText.Unload(); + TheText.Load(); + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + + debug("The previously saved language is now in use"); + } + + /*struct _WIN32_FIND_DATAA FindFileData; + HANDLE H = FindFirstFileA("skins\*.bmp", &FindFileData); + char Dest; + bool SkinFound = false; + + for (int i = 1; H != (HANDLE)-1 && i; i = FindNextFileA(H, &FindFileData)) { + strcpy(&Dest, buf(m_PrefsSkinFile)); + strcat(&Dest, ".bmp"); + if (!strcmp(FindFileData.cFileName, &Dest)) + SkinFound = true; + } + + FindClose(H); + + if (!SkinFound) { + debug("Default skin set as no other skins are available OR saved skin not found!"); + strcpy((char *)CMenuManager::m_PrefsSkinFile, "$$\"\""); + strcpy(m_aSkinName, "$$\"\""); + }*/ } #endif @@ -1012,31 +1293,623 @@ void CMenuManager::PrintStats() } #endif - -#if 1 +#if 0 WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { + if (m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) + return; + + field_113 = 0; + InitialiseChangedLanguageSettings(); + + SwitchMenuOnAndOff(); + + if (m_bMenuActive) { + LoadAllTextures(); + if (m_nCurrScreen == MENUPAGE_DELETING) { + bool SlotPopulated = false; + + if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { + PcSaveHelper.PopulateSlotInfo(); + SlotPopulated = true; + } + + if (SlotPopulated) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { + int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); + PcSaveHelper.PopulateSlotInfo(); + if (SaveSlot) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { + if (CheckSlotDataValid(m_nCurrSaveSlot)) { + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; + DMAudio.Service(); + m_bStartGameLoading = 1; + RequestFrontEndShutdown(); + m_bLoadingSavedGame = 1; + b_FoundRecentSavedGameWantToLoad = 1; + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + + ProcessButtonPresses(); + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else { + if (PAD_ESC) + RequestFrontEndStartUp(); + + UnloadTextures(); + m_nPrevScreen = MENUPAGE_NONE; + m_nCurrScreen = m_nPrevScreen; + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMilliseconds(); + } } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { + // Update Mouse Position + m_nMouseOldPosX = m_nMousePosX; + m_nMouseOldPosY = m_nMousePosY; + + m_nMousePosX = m_nMouseTempPosX; + m_nMousePosY = m_nMouseTempPosY; + + if (m_nMousePosX < 0) + m_nMousePosX = 0; + if (m_nMousePosX > SCREEN_WIDTH) + m_nMousePosX = SCREEN_WIDTH; + if (m_nMousePosY < 0) + m_nMousePosY = 0; + if (m_nMousePosY > SCREEN_HEIGHT) + m_nMousePosY = SCREEN_HEIGHT; + + // Show/hide mouse cursor. + if (MOUSE_INPUT) + m_bShowMouse = true; + else if (PAD_INPUT) + m_bShowMouse = false; + + // Get number of menu options. + uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); + + // Select next/previous option with pad. Mouse is done in drawing function. + if (PAD_UP) { + m_nPrevOption = m_nCurrOption; + m_nCurrOption -= 1; + + if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { + if (m_nCurrOption < MENUROW_1) + m_nCurrOption = NumberOfMenuOptions; + } + else { + if (m_nCurrOption < MENUROW_0) + m_nCurrOption = NumberOfMenuOptions; + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } + else if (PAD_DOWN) { + m_nPrevOption = m_nCurrOption; + m_nCurrOption += 1; + + if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { + if (m_nCurrOption > NumberOfMenuOptions) + m_nCurrOption = MENUROW_1; + } + else { + if (m_nCurrOption > NumberOfMenuOptions) + m_nCurrOption = MENUROW_0; + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } + // Set what happens if ESC is pressed. + if (PAD_ESC) { + bool PlayEscSound = false; + switch (m_nCurrScreen) { + case MENUPAGE_START_MENU: + break; + case MENUPAGE_CHOOSE_SAVE_SLOT: + case MENUPAGE_PAUSE_MENU: + RequestFrontEndShutdown(); + PlayEscSound = true; + break; + default: + SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); + PlayEscSound = true; + break; + }; + + if (PlayEscSound) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + } + + // TODO: finish hover options. + // Set mouse buttons. + if (MOUSE_LMB) { + switch (m_nHoverOption) { + case ACTIVATE_OPTION: + if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) + m_nCurrOption = m_nPrevOption; + + m_nHoverOption = ACTIVATE_OPTION; + break; + default: + break; + }; + } + + // Process all menu options here, but first check if it's an option or a redirect. + int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + if ((PAD_ENTER || MOUSE_LMB) || + ((PAD_LEFT || MOUSE_WHU) || (PAD_RIGHT || MOUSE_WHD)) && + (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen && + CurrAction != MENUACTION_CHANGEMENU && + CurrAction != MENUACTION_LOADRADIO && + CurrAction != MENUACTION_RESTOREDEF && + CurrAction != MENUACTION_PLAYERSETUP)) { + + if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB")) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + + ProcessOnOffMenuOptions(); + } + + // Process screens that may redirect you somewhere, or may not. + switch (m_nCurrScreen) { + case MENUPAGE_LOAD_SLOT_CONFIRM: + break; + case MENUPAGE_NEW_GAME_RELOAD: + if (m_bGameNotLoaded) + DoSettingsBeforeStartingAGame(); + break; + case MENUPAGE_CHOOSE_DELETE_SLOT: + case MENUPAGE_CHOOSE_SAVE_SLOT: + case MENUPAGE_CHOOSE_LOAD_SLOT: + PcSaveHelper.PopulateSlotInfo(); + break; + default: + break; + }; + + // Reset pad shaking. + if (VibrationTime != 0) { + if (CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { + CPad::GetPad(0)->StopShaking(0); + VibrationTime = 0; + } + } } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } #else void CMenuManager::ProcessOnOffMenuOptions() { + int8 InputDirection = (PAD_LEFT || MOUSE_WHD) && (!PAD_ENTER && !MOUSE_LMB) ? -1 : 1; + int8 InputEnter = PAD_ENTER; + + uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); + + // In numerical order. + switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { + case MENUACTION_CHANGEMENU: + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + break; + case MENUACTION_CTRLVIBRATION: + if (!m_PrefsUseVibration) + m_PrefsUseVibration = true; + + if (m_PrefsUseVibration) { + CPad::GetPad(0)->StartShake(350, 150); + VibrationTime = CTimer::GetTimeInMillisecondsPauseMode() + 500; + } + SaveSettings(); + break; + case MENUACTION_FRAMESYNC: + m_PrefsVsync = m_PrefsVsync == false; + SaveSettings(); + break; + case MENUACTION_FRAMELIMIT: + m_PrefsFrameLimiter = m_PrefsFrameLimiter == false; + SaveSettings(); + break; + case MENUACTION_TRAILS: + BlurOn = BlurOn == false; + if (!BlurOn) + CMBlur::MotionBlurClose(); + else + CMBlur::MotionBlurOpen(Scene.camera); + + SaveSettings(); + break; + case MENUACTION_SUBTITLES: + m_PrefsShowSubtitles = m_PrefsShowSubtitles == false; + SaveSettings(); + break; + case MENUACTION_WIDESCREEN: +#ifndef HOR_PLUS + m_PrefsUseWideScreen = m_PrefsUseWideScreen == false; +#else + if (InputDirection < 0) { + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + m_PrefsUseWideScreen = AR_64_27; + break; + case AR_3_2: + m_PrefsUseWideScreen = AR_AUTO; + break; + case AR_4_3: + m_PrefsUseWideScreen = AR_3_2; + break; + case AR_5_3: + m_PrefsUseWideScreen = AR_4_3; + break; + case AR_5_4: + m_PrefsUseWideScreen = AR_5_3; + break; + case AR_15_9: + m_PrefsUseWideScreen = AR_5_4; + break; + case AR_16_9: + m_PrefsUseWideScreen = AR_15_9; + break; + case AR_16_10: + m_PrefsUseWideScreen = AR_16_9; + break; + case AR_64_27: + m_PrefsUseWideScreen = AR_16_10; + break; + }; + } + else { + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + m_PrefsUseWideScreen = AR_3_2; + break; + case AR_3_2: + m_PrefsUseWideScreen = AR_4_3; + break; + case AR_4_3: + m_PrefsUseWideScreen = AR_5_3; + break; + case AR_5_3: + m_PrefsUseWideScreen = AR_5_4; + break; + case AR_5_4: + m_PrefsUseWideScreen = AR_15_9; + break; + case AR_15_9: + m_PrefsUseWideScreen = AR_16_9; + break; + case AR_16_9: + m_PrefsUseWideScreen = AR_16_10; + break; + case AR_16_10: + m_PrefsUseWideScreen = AR_64_27; + break; + case AR_64_27: + m_PrefsUseWideScreen = AR_AUTO; + break; + }; + } +#endif + SaveSettings(); + break; + case MENUACTION_BRIGHTNESS: + case MENUACTION_DRAWDIST: + case MENUACTION_MUSICVOLUME: + case MENUACTION_SFXVOLUME: + case MENUACTION_MOUSESENS: + if (InputDirection > 0) + CheckSliderMovement(1.0f); + else + CheckSliderMovement(-1.0f); + break; + case MENUACTION_RADIO: + if (InputDirection < 0) + m_PrefsRadioStation -= 1; + else + m_PrefsRadioStation += 1; + + if (DMAudio.IsMP3RadioChannelAvailable()) { + if (m_PrefsRadioStation > USERTRACK) + m_PrefsRadioStation = HEAD_RADIO; + else if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = USERTRACK; + } + else { + if (m_PrefsRadioStation > CHATTERBOX) + m_PrefsRadioStation = HEAD_RADIO; + else if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = CHATTERBOX; + } + + SaveSettings(); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + break; + case MENUACTION_LANG_ENG: + if (m_PrefsLanguage != LANGUAGE_AMERICAN) { + m_PrefsLanguage = LANGUAGE_AMERICAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_FRE: + if (m_PrefsLanguage != LANGUAGE_FRENCH) { + m_PrefsLanguage = LANGUAGE_FRENCH; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_GER: + if (m_PrefsLanguage != LANGUAGE_GERMAN) { + m_PrefsLanguage = LANGUAGE_GERMAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_ITA: + if (m_PrefsLanguage != LANGUAGE_ITALIAN) { + m_PrefsLanguage = LANGUAGE_ITALIAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_SPA: + if (m_PrefsLanguage != LANGUAGE_SPANISH) { + m_PrefsLanguage = LANGUAGE_SPANISH; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_UPDATESAVE: + PcSaveHelper.PopulateSlotInfo(); + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { + m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; + + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + } + break; + case MENUACTION_CHECKSAVE: + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { + m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; + + if (Slots[m_nCurrSaveSlot] != 1 && Slots[m_nCurrSaveSlot] != 2) + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + } + break; + case MENUACTION_NEWGAME: + DoSettingsBeforeStartingAGame(); + break; + case MENUACTION_SETDBGFLAG: + CTheScripts::DbgFlag = CTheScripts::DbgFlag == false; + break; + case MENUACTION_UPDATEMEMCARDSAVE: + RequestFrontEndShutdown(); + break; + case MENUACTION_INVVERT: + MousePointerStateHelper.bInvertVertically = MousePointerStateHelper.bInvertVertically == false; + return; + case MENUACTION_CANCLEGAME: + DMAudio.Service(); + RsEventHandler(rsQUITAPP, 0); + break; + case MENUACTION_RESUME: + RequestFrontEndShutdown(); + break; + case MENUACTION_SCREENRES: + if (m_bGameNotLoaded) { + if (InputEnter) { + if (m_nDisplayVideoMode != m_nPrefsVideoMode) { + m_nPrefsVideoMode = m_nDisplayVideoMode; + _psSelectScreenVM(m_nPrefsVideoMode); + CentreMousePointer(); + m_PrefsUseWideScreen = AR_AUTO; + SaveSettings(); + } + } + else { + char** VideoModeList = _psGetVideoModeList(); + int NumVideoModes = _psGetNumVideModes(); + if (InputDirection > 0) { + int nCurrentVidMode = m_nDisplayVideoMode + 1; + + if (nCurrentVidMode >= NumVideoModes) + nCurrentVidMode = 0; + + while (!VideoModeList[nCurrentVidMode]) { + ++nCurrentVidMode; + + if (nCurrentVidMode >= NumVideoModes) + nCurrentVidMode = 0; + } + + m_nDisplayVideoMode = nCurrentVidMode; + } + else { + int nCurrentVidMode = m_nDisplayVideoMode - 1; + + if (nCurrentVidMode < 0) + nCurrentVidMode = NumVideoModes - 1; + + while (!VideoModeList[nCurrentVidMode]) { + --nCurrentVidMode; + + if (nCurrentVidMode < 0) + nCurrentVidMode = NumVideoModes - 1; + } + + m_nDisplayVideoMode = nCurrentVidMode; + } + } + } + break; + case MENUACTION_AUDIOHW: + { + int8 AudioHardware = m_nPrefsAudio3DProviderIndex; + if (m_nPrefsAudio3DProviderIndex == -1) + break; + + if (InputDirection > 0) { + switch (m_nPrefsAudio3DProviderIndex) { + case 0: + m_nPrefsAudio3DProviderIndex = 1; + break; + case 1: + m_nPrefsAudio3DProviderIndex = 2; + break; + case 2: + m_nPrefsAudio3DProviderIndex = 3; + break; + case 3: + m_nPrefsAudio3DProviderIndex = 4; + break; + case 4: + m_nPrefsAudio3DProviderIndex = 5; + break; + case 5: + m_nPrefsAudio3DProviderIndex = 6; + break; + case 6: + m_nPrefsAudio3DProviderIndex = 0; + break; + } + } + else { + switch (m_nPrefsAudio3DProviderIndex) { + case 0: + m_nPrefsAudio3DProviderIndex = 6; + break; + case 1: + m_nPrefsAudio3DProviderIndex = 0; + break; + case 2: + m_nPrefsAudio3DProviderIndex = 1; + break; + case 3: + m_nPrefsAudio3DProviderIndex = 2; + break; + case 4: + m_nPrefsAudio3DProviderIndex = 3; + break; + case 5: + m_nPrefsAudio3DProviderIndex = 4; + break; + case 6: + m_nPrefsAudio3DProviderIndex = 5; + break; + } + } + + DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); + + if (AudioHardware == m_nPrefsAudio3DProviderIndex) + SetHelperText(0); + else + SetHelperText(4); + + SaveSettings(); + break; + } + case MENUACTION_SPEAKERCONF: + if (m_nPrefsAudio3DProviderIndex == -1) + break; + + if (InputDirection > 0) { + switch (m_PrefsSpeakers) { + case 0: + m_PrefsSpeakers = 1; + break; + case 1: + m_PrefsSpeakers = 2; + break; + case 2: + m_PrefsSpeakers = 0; + break; + }; + } + else { + switch (m_PrefsSpeakers) { + case 0: + m_PrefsSpeakers = 2; + break; + case 1: + m_PrefsSpeakers = 0; + break; + case 2: + m_PrefsSpeakers = 1; + break; + }; + } + + DMAudio.SetSpeakerConfig(m_PrefsSpeakers); + SaveSettings(); + break; + case MENUACTION_RESTOREDEF: + SetDefaultPreferences(m_nCurrScreen); + SetHelperText(2); + SaveSettings(); + break; + case MENUACTION_CTRLMETHOD: + if (m_ControlMethod) { + TheCamera.m_bUseMouse3rdPerson = 1; + m_ControlMethod = 0; + } + else { + TheCamera.m_bUseMouse3rdPerson = 0; + m_ControlMethod = 1; + } + SaveSettings(); + break; + case MENUACTION_DYNAMICACOUSTIC: + m_PrefsDMA = m_PrefsDMA == false; + break; + case MENUACTION_MOUSESTEER: + m_bDisableMouseSteering = m_bDisableMouseSteering == false; + return; + }; } #endif @@ -1069,12 +1942,41 @@ void CMenuManager::ResetHelperText() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { EAXJMP(0x488930); } #else void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { + switch (PcSaveHelper.m_nHelper) { + case 1: + case 2: + case 3: + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_FAILED; + break; + break; + case 4: + case 5: + case 6: + this->m_nPrevScreen = m_nCurrScreen; + this->m_nCurrScreen = MENUPAGE_LOAD_FAILED; + break; + case 7: + this->m_nPrevScreen = m_nCurrScreen; + this->m_nCurrScreen = MENUPAGE_LOAD_FAILED_2; + break; + case 8: + case 9: + case 10: + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_FAILED; + break; + default: + return; + } + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); } #endif @@ -1088,12 +1990,50 @@ void CMenuManager::SetHelperText(int text) } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } #else void CMenuManager::SaveSettings() { + CFileMgr::SetDirMyDocuments(); + + int fileHandle = CFileMgr::OpenFile("gta3.set", "wb"); + if (fileHandle) { + + ControlsManager.SaveSettings(fileHandle); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_bHeadBob), sizeof(TheCamera.m_bHeadBob)); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), sizeof(TheCamera.m_fMouseAccelHorzntl)); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), sizeof(TheCamera.m_fMouseAccelVertical)); + CFileMgr::Write(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), sizeof(MousePointerStateHelper.bInvertVertically)); + CFileMgr::Write(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), sizeof(CVehicle::m_bDisableMouseSteering)); + CFileMgr::Write(fileHandle, buf(&m_PrefsSfxVolume), sizeof(m_PrefsSfxVolume)); + CFileMgr::Write(fileHandle, buf(&m_PrefsMusicVolume), sizeof(m_PrefsMusicVolume)); + CFileMgr::Write(fileHandle, buf(&m_PrefsRadioStation), sizeof(m_PrefsRadioStation)); + CFileMgr::Write(fileHandle, buf(&m_PrefsSpeakers), sizeof(m_PrefsSpeakers)); + CFileMgr::Write(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), sizeof(m_nPrefsAudio3DProviderIndex)); + CFileMgr::Write(fileHandle, buf(&m_PrefsDMA), sizeof(m_PrefsDMA)); + CFileMgr::Write(fileHandle, buf(&m_PrefsBrightness), sizeof(m_PrefsBrightness)); + CFileMgr::Write(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); + CFileMgr::Write(fileHandle, buf(&m_PrefsShowSubtitles), sizeof(m_PrefsShowSubtitles)); + CFileMgr::Write(fileHandle, buf(&m_PrefsUseWideScreen), sizeof(m_PrefsUseWideScreen)); + CFileMgr::Write(fileHandle, buf(&m_PrefsVsyncDisp), sizeof(m_PrefsVsyncDisp)); + CFileMgr::Write(fileHandle, buf(&m_PrefsFrameLimiter), sizeof(m_PrefsFrameLimiter)); + CFileMgr::Write(fileHandle, buf(&m_nDisplayVideoMode), sizeof(m_nPrefsVideoMode)); + CFileMgr::Write(fileHandle, buf(&BlurOn), sizeof(BlurOn)); + CFileMgr::Write(fileHandle, buf(&m_PrefsSkinFile), sizeof(m_PrefsSkinFile)); + CFileMgr::Write(fileHandle, buf(&m_ControlMethod), sizeof(m_ControlMethod)); + CFileMgr::Write(fileHandle, buf(&m_PrefsLanguage), sizeof(m_PrefsLanguage)); + } + CFileMgr::CloseFile(fileHandle); + CFileMgr::SetDir(""); } #endif @@ -1107,6 +2047,7 @@ void CMenuManager::ShutdownJustMenu() } #endif +// We won't ever use this again. #if 0 WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); } #else @@ -1136,7 +2077,44 @@ WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } #else void CMenuManager::SwitchMenuOnAndOff() { + // Just what the function name says. + if (PAD_START || m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { + if (!m_bMenuActive) + m_bMenuActive = true; + + if (m_bShutDownFrontEndRequested) + m_bMenuActive = false; + if (m_bStartUpFrontEndRequested) + m_bMenuActive = true; + + if (m_bMenuActive) { + CTimer::StartUserPause(); + } + else { + ShutdownJustMenu(); + SaveSettings(); + m_bStartUpFrontEndRequested = false; + pControlEdit = 0; + m_bShutDownFrontEndRequested = false; + DisplayComboButtonErrMsg = 0; + CPad::GetPad(0)->Clear(0); + CPad::GetPad(1)->Clear(0); + SwitchToNewScreen(0); + } + } + if (m_bSaveMenuActive && !m_bQuitGameNoCD) { + m_bSaveMenuActive = false; + m_bMenuActive = true; + CTimer::StartUserPause(); + SwitchToNewScreen(MENUPAGE_CHOOSE_SAVE_SLOT); + PcSaveHelper.PopulateSlotInfo(); + } + + if (!m_bMenuActive) + field_112 = 1; + m_bStartUpFrontEndRequested = false; + m_bShutDownFrontEndRequested = false; } #endif @@ -1165,18 +2143,141 @@ void CMenuManager::UnloadTextures() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } #else void CMenuManager::WaitForUserCD() { - + LoadSplash(0); + if (!RsGlobal.quit) { + HandleExit(); + CPad::UpdatePads(); + MessageScreen("NO_PCCD"); + + if (PAD_ESC) { + m_bQuitGameNoCD = true; + RsEventHandler(rsQUITAPP, 0); + } + } } #endif +// New content: +uint8 CMenuManager::GetNumberOfMenuOptions() +{ + uint8 Rows = MENUROW_NONE; + for (int i = 0; i < MENUROWS; i++) { + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_NOTHING) + break; + + ++Rows; + }; + return Rows; +} + +void CMenuManager::SwitchToNewScreen(int8 screen) +{ + ResetHelperText(); + + // Return to - behaviour. + if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") || + (screen == aScreens[m_nCurrScreen].m_PreviousPage[0])) { + if (m_bGameNotLoaded) { + m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[0]; + m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[0]; + } + else { + m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[1]; + m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[1]; + } + + m_nMenuFadeAlpha = 0; + } + else { + // Go through - behaviour. + if (screen) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = screen; + m_nCurrOption = MENUROW_0; + m_nMenuFadeAlpha = 0; + } + else { + m_nPrevScreen = MENUPAGE_NONE; + m_nCurrScreen = MENUPAGE_NONE; + m_nCurrOption = MENUROW_0; + } + } + + // Set player skin. + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + CPlayerSkin::BeginFrontEndSkinEdit(); + field_535 = 19; + m_bSkinsFound = false; + } + + // Set radio station. + if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + OutputDebugStringA("FRONTEND AUDIO TRACK STOPPED"); + } + else + DMAudio.StopFrontEndTrack(); +} + +void CMenuManager::SetDefaultPreferences(int8 screen) +{ + switch (screen) { + case MENUPAGE_SOUND_SETTINGS: + m_PrefsMusicVolume = 102; + m_PrefsSfxVolume = 102; + m_PrefsSpeakers = 0; + m_nPrefsAudio3DProviderIndex = 6; + m_PrefsDMA = true; + DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); + DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); + break; + case MENUPAGE_GRAPHICS_SETTINGS: + m_PrefsBrightness = 256; + m_PrefsFrameLimiter = true; + m_PrefsVsync = true; + m_PrefsLOD = 1.2f; + m_PrefsVsyncDisp = true; + lodMultiplier = 1.2; + BlurOn = true; + CMBlur::MotionBlurOpen(Scene.camera); + m_PrefsUseVibration = false; + m_PrefsShowSubtitles = true; + m_nDisplayVideoMode = m_nPrefsVideoMode; + m_PrefsUseWideScreen = AR_AUTO; + break; + case MENUPAGE_CONTROLLER_PC: + ControlsManager.MakeControllerActionsBlank(); + ControlsManager.InitDefaultControlConfiguration(); + + CMouseControllerState state = MousePointerStateHelper.GetMouseSetUp(); + ControlsManager.InitDefaultControlConfigMouse(state); + + if (1) { + //TODO: JoyPad stuff. + } + m_ControlMethod = 0; + MousePointerStateHelper.bInvertVertically = true; + TheCamera.m_fMouseAccelHorzntl = 0.25f; + CVehicle::m_bDisableMouseSteering = true; + TheCamera.m_bHeadBob = false; + break; + }; +} + STARTPATCHES InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); + InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); + InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); + InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); + InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); + InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); diff --git a/src/Frontend.h b/src/Frontend.h index dd6464b8..a833254a 100644 --- a/src/Frontend.h +++ b/src/Frontend.h @@ -29,7 +29,11 @@ #define MENUSELECT_BOX_MAX 20.5f #define MENUSELECT_BOX_MIN 17.0f +#ifndef MID_RADIOICONS #define MENURADIO_ICON_X 31.5f +#else +#define MENURADIO_ICON_X -262.0f +#endif #define MENURADIO_ICON_Y 29.5f #define MENURADIO_ICON_W 60.0f #define MENURADIO_ICON_H 60.0f @@ -39,6 +43,8 @@ #define MENUSLIDER_X 306.0f +#define buf(a) (char*)(a) + enum eLanguages { LANGUAGE_AMERICAN, @@ -314,6 +320,7 @@ enum eMenuColumns enum eMenuRow { + MENUROW_NONE = -1, MENUROW_0, MENUROW_1, MENUROW_2, @@ -347,7 +354,8 @@ struct tSkinInfo struct CMenuScreen { char m_ScreenName[8]; - int32 m_PreviousPage[3]; // eMenuScreen + int32 unk; + int32 m_PreviousPage[2]; // eMenuScreen int32 m_ParentEntry[2]; // eMenuRow struct CMenuEntry @@ -417,7 +425,7 @@ public: int m_nHoverOption; int m_nCurrScreen; int m_nCurrOption; - int m_nCurrentInput; + int m_nPrevOption; int m_nPrevScreen; int field_558; int m_nCurrSaveSlot; @@ -443,6 +451,8 @@ public: static int8 &m_bFrontEnd_ReloadObrTxtGxt; static int32 &m_PrefsMusicVolume; static int32 &m_PrefsSfxVolume; + static uint8 *m_PrefsSkinFile; + static bool &m_bStartUpFrontEndRequested; static bool &m_bShutDownFrontEndRequested; static bool &m_PrefsAllowNastyGame; @@ -452,6 +462,7 @@ public: static void CentreMousePointer(); void CheckCodesForControls(int, int); bool CheckHover(int x1, int x2, int y1, int y2); + void CheckSliderMovement(int); int CostructStatLine(int); void DisplayHelperText(); float DisplaySlider(float, float, float, float, float, float); @@ -489,6 +500,12 @@ public: void SwitchMenuOnAndOff(); void UnloadTextures(); void WaitForUserCD(); + + // New content: + uint8 GetNumberOfMenuOptions(); + void SwitchToNewScreen(int8 screen); + void SetDefaultPreferences(int8 screen); + }; static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); diff --git a/src/MenuScreens.h b/src/MenuScreens.h index 640952ed..362d4909 100644 --- a/src/MenuScreens.h +++ b/src/MenuScreens.h @@ -12,7 +12,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_NEW_GAME = 2 { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_0, MENUROW_1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, - MENUACTION_UPDATESAVE, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, + MENUACTION_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -43,7 +43,7 @@ const CMenuScreen aScreens[] = { { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_2, MENUROW_2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, + //MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -55,45 +55,45 @@ const CMenuScreen aScreens[] = { // MENUPAGE_LANGUAGE_SETTINGS = 7 { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_3, MENUROW_3, - MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_1, MENUROW_1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_2, MENUROW_2, - MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, }, // MENUPAGE_NEW_GAME_RELOAD = 10 { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_0, MENUROW_0, MENUACTION_LABEL, "FESZ_QR", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, + MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LOAD_SLOT_CONFIRM = 11 @@ -181,14 +181,14 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CHOOSE_SAVE_SLOT = 26 { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 @@ -236,7 +236,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_0, MENUROW_0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_REDEFCTRL, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, + MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, @@ -270,17 +270,17 @@ const CMenuScreen aScreens[] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_1, MENUROW_4, MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, + MENUACTION_CHANGEMENU, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_CHANGEMENU, "FET_LAN", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_PLAYERSETUP, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, + MENUACTION_CHANGEMENU, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_EXIT = 42 { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_2, MENUROW_5, MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_DONTCANCLE, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCLEGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -352,19 +352,19 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SKIN_SELECT = 54 { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_4, MENUROW_4, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, + //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, }, // MENUPAGE_KEYBOARD_CONTROLS = 55 { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_1, MENUROW_1, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_2, MENUROW_2, - MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, + MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, + MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, diff --git a/src/PCSave.cpp b/src/PCSave.cpp index ae5e43b0..628e1218 100644 --- a/src/PCSave.cpp +++ b/src/PCSave.cpp @@ -4,9 +4,17 @@ #include "PCSave.h" WRAPPER void C_PcSave::SetSaveDirectory(const char *path) { EAXJMP(0x591EA0); } +WRAPPER int8 C_PcSave::PopulateSlotInfo() { EAXJMP(0x592090); } +WRAPPER int8 C_PcSave::DeleteSlot(int) { EAXJMP(0x5922F0); } +WRAPPER int8 C_PcSave::SaveSlot(int) { EAXJMP(0x591EC0); } + +WRAPPER int8 CheckSlotDataValid(int) { EAXJMP(0x591A40); } + WRAPPER wchar *GetNameOfSavedGame(int counter) { EAXJMP(0x591B60); } WRAPPER wchar *GetSavedGameDateAndTime(int counter) { EAXJMP(0x591B50); } + +C_PcSave PcSaveHelper = *(C_PcSave*)0x8E2C60; int *Slots = (int*)0x728040; int *SlotFileName = (int*)0x6F07C8; int *SlotSaveDate = (int*)0x72B858; diff --git a/src/PCSave.h b/src/PCSave.h index 79202bc9..696e158a 100644 --- a/src/PCSave.h +++ b/src/PCSave.h @@ -3,12 +3,19 @@ class C_PcSave { public: + int32 m_nHelper; + static void SetSaveDirectory(const char *path); + int8 PopulateSlotInfo(); + int8 DeleteSlot(int); + int8 SaveSlot(int); }; +extern int8 CheckSlotDataValid(int); extern wchar *GetNameOfSavedGame(int counter); extern wchar *GetSavedGameDateAndTime(int counter); +extern C_PcSave PcSaveHelper; extern int *Slots; extern int *SlotFileName; extern int *SlotSaveDate; diff --git a/src/Pad.cpp b/src/Pad.cpp index 002e7180..66bc3bf9 100644 --- a/src/Pad.cpp +++ b/src/Pad.cpp @@ -25,6 +25,7 @@ #include "Weather.h" #include "win.h" + CPad *Pads = (CPad*)0x6F0360; // [2] CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C; @@ -531,7 +532,7 @@ void CPad::AddToPCCheatString(char c) // "NASTYLIMBSCHEAT" if ( !_CHEATCMP("TAEHCSBMILYTSAN") ) NastyLimbsCheat(); - + #ifdef KANGAROO_CHEAT // "KANGAROO" if (!_CHEATCMP("OORAGNAK")) diff --git a/src/Pad.h b/src/Pad.h index e06aa9a6..498731cf 100644 --- a/src/Pad.h +++ b/src/Pad.h @@ -1,5 +1,22 @@ #pragma once +// Some macros for frontend stuff. +#define PAD_START (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->NewState.Start) +#define PAD_ESC (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->NewState.Triangle) +#define PAD_ENTER (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->NewState.Cross) +#define PAD_UP (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0) +#define PAD_DOWN (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0) +#define PAD_LEFT (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0) +#define PAD_RIGHT (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0) +#define MOUSE_LMB (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB) +#define MOUSE_RMB (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB) +#define MOUSE_POS (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->NewMouseControllerState.y != 0.0f) +#define MOUSE_WHU (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f) +#define MOUSE_WHD (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f) + +#define PAD_INPUT (PAD_ESC || PAD_ENTER || PAD_UP || PAD_DOWN || PAD_LEFT || PAD_RIGHT) +#define MOUSE_INPUT (MOUSE_LMB || MOUSE_RMB || MOUSE_POS || MOUSE_WHU || MOUSE_WHD) + // same as RW skeleton /* enum Key diff --git a/src/PlayerSkin.cpp b/src/PlayerSkin.cpp new file mode 100644 index 00000000..1c9ca2c6 --- /dev/null +++ b/src/PlayerSkin.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "PlayerSkin.h" + +WRAPPER void CPlayerSkin::BeginFrontEndSkinEdit() { EAXJMP(0x59BC70); } diff --git a/src/PlayerSkin.h b/src/PlayerSkin.h new file mode 100644 index 00000000..61e09cdf --- /dev/null +++ b/src/PlayerSkin.h @@ -0,0 +1,7 @@ +#pragma once + +class CPlayerSkin +{ +public: + static void BeginFrontEndSkinEdit(); +}; \ No newline at end of file diff --git a/src/Radar.h b/src/Radar.h index e5396a50..ac4e7392 100644 --- a/src/Radar.h +++ b/src/Radar.h @@ -63,10 +63,17 @@ struct CBlip static_assert(sizeof(CBlip) == 0x30, "CBlip: error"); // Values for screen space +#ifndef SA_STYLE_RADAR #define RADAR_LEFT (40.0f) #define RADAR_BOTTOM (47.0f) #define RADAR_WIDTH (94.0f) #define RADAR_HEIGHT (76.0f) +#else +#define RADAR_LEFT (34.0f) +#define RADAR_BOTTOM (25.0f) +#define RADAR_WIDTH (86.0f) +#define RADAR_HEIGHT (82.0f) +#endif class CRadar { diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index b3887c70..824d5c39 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -17,8 +17,13 @@ WRAPPER bool cDMAudio::CheckForAnAudioFileOnCD() { EAXJMP(0x57CA70); } WRAPPER void cDMAudio::ChangeMusicMode(uint8 mode) { EAXJMP(0x57CCF0); } WRAPPER void cDMAudio::PlayFrontEndSound(uint32, uint32) { EAXJMP(0x57CC20); } -WRAPPER void cDMAudio::PlayOneShot(int, uint16, float) { EAXJMP(0x57C840); } - +WRAPPER void cDMAudio::PlayFrontEndTrack(uint32, uint32) { EAXJMP(0x57CC80); } +WRAPPER void cDMAudio::StopFrontEndTrack() { EAXJMP(0x57CCB0); } +WRAPPER void cDMAudio::PlayOneShot(int32, uint16, float) { EAXJMP(0x57C840); } +WRAPPER void cDMAudio::SetMusicMasterVolume(int8) { EAXJMP(0x57C8C0); } +WRAPPER void cDMAudio::SetEffectsMasterVolume(int8) { EAXJMP(0x57C890); } +WRAPPER int8 cDMAudio::SetCurrent3DProvider(int8) { EAXJMP(0x57C9B0); } +WRAPPER int32 cDMAudio::SetSpeakerConfig(int32) { EAXJMP(0x57C9D0); } WRAPPER int32 cDMAudio::GetRadioInCar() { EAXJMP(0x57CE40); } WRAPPER uint8 cDMAudio::IsMP3RadioChannelAvailable() { EAXJMP(0x57C9F0); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 46b40e37..46914aaa 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -188,7 +188,13 @@ public: bool CheckForAnAudioFileOnCD(void); void ChangeMusicMode(uint8 mode); void PlayFrontEndSound(uint32, uint32); - void PlayOneShot(int, uint16, float); + void PlayFrontEndTrack(uint32, uint32); + void StopFrontEndTrack(); + void PlayOneShot(int32, uint16, float); + void SetMusicMasterVolume(int8); + void SetEffectsMasterVolume(int8); + int8 SetCurrent3DProvider(int8); + int32 SetSpeakerConfig(int32); int32 GetRadioInCar(void); void SetEffectsFadeVol(uint8); void SetMusicFadeVol(uint8); diff --git a/src/common.h b/src/common.h index f959de42..a8a99ec9 100644 --- a/src/common.h +++ b/src/common.h @@ -82,6 +82,7 @@ extern void **rwengine; #define SCREEN_STRETCH_FROM_BOTTOM(a) float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) #define SCREEN_MULTIPLIER (CDraw::GetScreenMult()) +#define SCREEN_COORD(a) (a * SCREEN_ASPECT_RATIO) #define SCREEN_SCALE(a) float((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) #define SCREEN_SCALE_X(a) SCREEN_SCALE(SCREEN_STRETCH_X(a) * SCREEN_MULTIPLIER) #define SCREEN_SCALE_Y(a) (SCREEN_STRETCH_Y(a) * SCREEN_MULTIPLIER) diff --git a/src/config.h b/src/config.h index b43a3a9f..87cfd191 100644 --- a/src/config.h +++ b/src/config.h @@ -79,3 +79,7 @@ enum Config { #define NASTY_GAME #define PS2_MATFX #define KANGAROO_CHEAT +#define HOR_PLUS +#define MID_RADIOICONS +#define NO_ROCKET_BORDERS +#define SA_STYLE_RADAR diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp index 8c1ef515..f7c4b065 100644 --- a/src/entities/Vehicle.cpp +++ b/src/entities/Vehicle.cpp @@ -12,7 +12,8 @@ bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75; bool &CVehicle::bCheat3 = *(bool *)0x95CD66; bool &CVehicle::bCheat4 = *(bool *)0x95CD65; bool &CVehicle::bCheat5 = *(bool *)0x95CD64; - +bool &CVehicle::m_bDisableMouseSteering = *(bool *)0x60252C; + void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index 27641e47..ba3e568e 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -135,6 +135,7 @@ public: static bool &bCheat3; static bool &bCheat4; static bool &bCheat5; + static bool &m_bDisableMouseSteering; }; static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); diff --git a/src/main.cpp b/src/main.cpp index 307d0b66..a00447ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -341,7 +341,11 @@ Render2dStuff(void) firstPersonWeapon = true; // Draw black border for sniper and rocket launcher +#ifndef NO_ROCKET_BORDERS if((weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_ROCKETLAUNCHER) && firstPersonWeapon){ +#else + if (weaponType == WEAPONTYPE_SNIPERRIFLE && firstPersonWeapon) { +#endif CRGBA black(0, 0, 0, 255); // top and bottom strips @@ -357,6 +361,7 @@ Render2dStuff(void) CSprite2d::DrawRect(CRect(SCREENW / 2 + SCREEN_SCALE_X(210), 0.0f, SCREENW, SCREENH), black); } + MusicManager.DisplayRadioStationName(); // TheConsole.Display(); /* @@ -782,7 +787,7 @@ AppEventHandler(RsEvent event, void *param) { CameraSize(Scene.camera, (RwRect *)param, - DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO); + DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO); return rsEVENTPROCESSED; } diff --git a/src/main.h b/src/main.h index c7914549..7d3fad9b 100644 --- a/src/main.h +++ b/src/main.h @@ -19,3 +19,4 @@ void LoadingIslandScreen(const char *levelName); CSprite2d *LoadSplash(const char *name); char *GetLevelSplashScreen(int level); char *GetRandomSplashScreen(void); +extern bool &b_FoundRecentSavedGameWantToLoad; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 90875299..f1b2147f 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -16,43 +16,70 @@ uint8 &CDraw::FadeRed = *(uint8*)0x95CD90; uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71; uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53; -void -CDraw::CalculateAspectRatio() +void CDraw::CalculateAspectRatio() { SetScreenMult(DEFAULT_SCALE); - if(FrontEndMenuManager.m_PrefsUseWideScreen) - ms_fAspectRatio = 16.0f/9.0f; +#ifndef HOR_PLUS + if (FrontEndMenuManager.m_PrefsUseWideScreen) + ms_fAspectRatio = 16.0f / 9.0f; else - ms_fAspectRatio = 4.0f/3.0f; + ms_fAspectRatio = 4.0f / 3.0f; +#else + switch (FrontEndMenuManager.m_PrefsUseWideScreen) { + case AR_AUTO: + ms_fAspectRatio = (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT; + return; + case AR_3_2: + ms_fAspectRatio = 3.0f / 2.0f; + return; + case AR_4_3: + ms_fAspectRatio = 4.0f / 3.0f; + return; + case AR_5_3: + ms_fAspectRatio = 5.0f / 3.0f; + return; + case AR_5_4: + ms_fAspectRatio = 5.0f / 4.0f; + return; + case AR_15_9: + ms_fAspectRatio = 15.0f / 9.0f; + return; + case AR_16_9: + ms_fAspectRatio = 16.0f / 9.0f; + return; + case AR_16_10: + ms_fAspectRatio = 16.0f / 10.0f; + return; + case AR_64_27: + ms_fAspectRatio = 64.0f / 27.0f; + return; + }; + +#endif } -static float hFov2vFov(float hfov) +float +HorToVert(float hfov) { - float w = SCREENW; - float h = SCREENH; - - // => tan(hFOV/2) = tan(vFOV/2)*aspectRatio - // => tan(vFOV/2) = tan(hFOV/2)/aspectRatio - float ar1 = 4.0/3.0; - float ar2 = w/h; - hfov = DEGTORAD(hfov); - float vfov = atan(tan(hfov/2) / ar1) *2; - hfov = atan(tan(vfov/2) * ar2) *2; - return RADTODEG(hfov); + float vfov = atan(tan(DEGTORAD(hfov) / 2) / (4.0 / 3.0)) * 2; + return RADTODEG(hfov = atan(tan(vfov / 2) * CDraw::GetAspectRatio()) * 2); } void CDraw::SetFOV(float fov) { -// TODO: fix FOV here or somewhere else? -// ms_fFOV = hFov2vFov(fov); +#ifndef HOR_PLUS ms_fFOV = fov; +#else + ms_fFOV = HorToVert(fov); +#endif } STARTPATCHES InjectHook(0x4FE7B0, CDraw::SetFOV, PATCH_JUMP); + // Some patches to fix aiming offset on "CCamera::Find3rdPersonCamTargetVector". Nop(0x46B618, 2); Patch(0x5F0A64, 1.3333334f); ENDPATCHES diff --git a/src/render/Draw.h b/src/render/Draw.h index 1fcb5212..9e334d02 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -3,6 +3,18 @@ #define HUD_SCALE 0.8f #define DEFAULT_SCALE 1.0f +enum eAspectRatio { + AR_AUTO, + AR_3_2, + AR_4_3, + AR_5_3, + AR_5_4, + AR_15_9, + AR_16_9, + AR_16_10, + AR_64_27, +}; + class CDraw { private: diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 2547ab2b..4b6094f1 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -125,6 +125,15 @@ WRAPPER void CHud::Draw(void) { EAXJMP(0x5052A0); } #else void CHud::Draw() { + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSMIRROR); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + if (CReplay::IsPlayingBack()) return; @@ -168,6 +177,7 @@ void CHud::Draw() float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); CRect rect; +#ifndef HOR_PLUS float fWidescreenOffset[2] = { 0.0f, 0.0f }; if (FrontEndMenuManager.m_PrefsUseWideScreen) { @@ -178,7 +188,11 @@ void CHud::Draw() if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { float f3rdX = SCREENW * TheCamera.m_f3rdPersonCHairMultX + fWidescreenOffset[0]; float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY - fWidescreenOffset[1]; - +#else + if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { + float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (4.0f / 3.0f))) + 0.5f) * SCREENW; + float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY; +#endif if (CWorld::Players[CWorld::PlayerInFocus].m_pPed && WeaponType == WEAPONTYPE_M16) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); @@ -1443,7 +1457,7 @@ STARTPATCHES InjectHook(0x5048F0, &CHud::Initialise, PATCH_JUMP); InjectHook(0x504CC0, &CHud::ReInitialise, PATCH_JUMP); InjectHook(0x50A250, &CHud::SetBigMessage, PATCH_JUMP); - InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); + //InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); InjectHook(0x50A210, &CHud::SetMessage, PATCH_JUMP); InjectHook(0x50A320, &CHud::SetPagerMessage, PATCH_JUMP); InjectHook(0x505290, &CHud::SetVehicleName, PATCH_JUMP); diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 9638e53a..1b91af24 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1355,10 +1355,14 @@ psSelectDevice() { while ( !modeFound && GcurSelVM < RwEngineGetNumVideoModes() ) { + RECT Rect; + GetWindowRect(GetDesktopWindow(), &Rect); + printf(gString, "Cannot find %dx%dx32 video mode", Rect.right, Rect.bottom); + RwEngineGetVideoModeInfo(&vm, GcurSelVM); - if ( defaultFullscreenRes && vm.width != 640 - || vm.height != 480 - || vm.depth != 16 + if ( defaultFullscreenRes && vm.width != Rect.right + || vm.height != Rect.bottom + || vm.depth != 32 || !(vm.flags & rwVIDEOMODEEXCLUSIVE) ) ++GcurSelVM; else @@ -1367,7 +1371,7 @@ psSelectDevice() if ( !modeFound ) { - MessageBox(nil, "Cannot find 640x480 video mode", "GTA3", MB_OK); + MessageBox(nil, gString, "GTA3", MB_OK); return FALSE; } } diff --git a/src/skel/win/win.h b/src/skel/win/win.h index 371b9e44..13564a7f 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -79,6 +79,10 @@ void CenterVideo(void); void CloseClip(void); RwChar **_psGetVideoModeList(); +RwInt32 _psGetNumVideModes(); + +void _psSelectScreenVM(RwInt32 videoMode); +void HandleExit(); #ifdef __cplusplus } -- cgit v1.2.3 From 5afa330e7da88c6da7eb600d545be0bd722b7f1f Mon Sep 17 00:00:00 2001 From: _AG Date: Tue, 2 Jul 2019 21:22:16 +0200 Subject: Removed macros from Pad.cpp: - Turned them in functions. --- src/Frontend.cpp | 154 ++++++++++++++++++++++++++++++++++++++++++++++++------- src/Pad.h | 17 ------ 2 files changed, 136 insertions(+), 35 deletions(-) diff --git a/src/Frontend.cpp b/src/Frontend.cpp index 8bff985b..c16c8c25 100644 --- a/src/Frontend.cpp +++ b/src/Frontend.cpp @@ -66,6 +66,21 @@ int8 DisplayComboButtonErrMsg; bool MouseButtonJustClicked; bool JoyButtonJustClicked; +// Frontend inputs. +bool GetPadBack(); +bool GetPadForward(); +bool GetPadMoveUp(); +bool GetPadMoveDown(); +bool GetPadMoveLeft(); +bool GetPadMoveRight(); +bool GetMouseForward(); +bool GetMouseBack(); +bool GetMousePos(); +bool GetMouseMoveLeft(); +bool GetMouseMoveRight(); +bool GetPadInput(); +bool GetMouseInput(); + char *FrontendFilenames[] = { "fe2_mainpanel_ul", "fe2_mainpanel_ur", @@ -696,13 +711,16 @@ void CMenuManager::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SavePageSlot ? MENUCOLUMN_SAVE_X : MENUCOLUMN_POS_X), vecPositions.y, textToPrint[MENUCOLUMN_RIGHT]); } - // Mouse support. - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - //TODO: inputs for these pages. + // Mouse support. + // TODO: inputs for these pages. + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + } + else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + } else { static bool bIsMouseInPosition = false; - if (m_nMenuFadeAlpha >= 255 && MOUSE_INPUT) { + if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) { CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; if (m_bShowMouse && ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) @@ -718,7 +736,7 @@ void CMenuManager::Draw() m_nPrevOption = m_nCurrOption; - if (MOUSE_LMB) + if (GetMouseForward()) m_nHoverOption = IGNORE_OPTION; else m_nHoverOption = ACTIVATE_OPTION; @@ -1360,7 +1378,7 @@ void CMenuManager::Process(void) m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); } else { - if (PAD_ESC) + if (GetPadBack()) RequestFrontEndStartUp(); UnloadTextures(); @@ -1394,16 +1412,16 @@ void CMenuManager::ProcessButtonPresses() m_nMousePosY = SCREEN_HEIGHT; // Show/hide mouse cursor. - if (MOUSE_INPUT) + if (GetMouseInput()) m_bShowMouse = true; - else if (PAD_INPUT) + else if (GetPadInput()) m_bShowMouse = false; // Get number of menu options. uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); // Select next/previous option with pad. Mouse is done in drawing function. - if (PAD_UP) { + if (GetPadMoveUp()) { m_nPrevOption = m_nCurrOption; m_nCurrOption -= 1; @@ -1418,7 +1436,7 @@ void CMenuManager::ProcessButtonPresses() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); } - else if (PAD_DOWN) { + else if (GetPadMoveDown()) { m_nPrevOption = m_nCurrOption; m_nCurrOption += 1; @@ -1435,7 +1453,7 @@ void CMenuManager::ProcessButtonPresses() } // Set what happens if ESC is pressed. - if (PAD_ESC) { + if (GetPadBack()) { bool PlayEscSound = false; switch (m_nCurrScreen) { case MENUPAGE_START_MENU: @@ -1457,7 +1475,7 @@ void CMenuManager::ProcessButtonPresses() // TODO: finish hover options. // Set mouse buttons. - if (MOUSE_LMB) { + if (GetMouseForward()) { switch (m_nHoverOption) { case ACTIVATE_OPTION: if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) @@ -1472,8 +1490,8 @@ void CMenuManager::ProcessButtonPresses() // Process all menu options here, but first check if it's an option or a redirect. int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; - if ((PAD_ENTER || MOUSE_LMB) || - ((PAD_LEFT || MOUSE_WHU) || (PAD_RIGHT || MOUSE_WHD)) && + if ((GetPadForward() || GetMouseForward()) || + ((GetPadMoveLeft() || GetMouseMoveRight()) || (GetPadMoveRight() || GetMouseMoveLeft())) && (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen && CurrAction != MENUACTION_CHANGEMENU && CurrAction != MENUACTION_LOADRADIO && @@ -1520,8 +1538,8 @@ WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } #else void CMenuManager::ProcessOnOffMenuOptions() { - int8 InputDirection = (PAD_LEFT || MOUSE_WHD) && (!PAD_ENTER && !MOUSE_LMB) ? -1 : 1; - int8 InputEnter = PAD_ENTER; + int8 InputDirection = (GetPadMoveLeft() || GetMouseMoveLeft()) && (!GetPadForward() && !GetMouseForward()) ? -1 : 1; + int8 InputEnter = GetPadForward(); uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); @@ -2078,7 +2096,7 @@ WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } void CMenuManager::SwitchMenuOnAndOff() { // Just what the function name says. - if (PAD_START || m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { + if (m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { if (!m_bMenuActive) m_bMenuActive = true; @@ -2154,7 +2172,7 @@ void CMenuManager::WaitForUserCD() CPad::UpdatePads(); MessageScreen("NO_PCCD"); - if (PAD_ESC) { + if (GetPadBack()) { m_bQuitGameNoCD = true; RsEventHandler(rsQUITAPP, 0); } @@ -2270,6 +2288,106 @@ void CMenuManager::SetDefaultPreferences(int8 screen) }; } +// Frontend inputs. +bool GetPadBack() +{ + return + (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || + (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->OldState.Start) || + (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->OldState.Triangle); +} + +bool GetPadForward() +{ + return + (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || + (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || + (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->OldState.Cross); +} + +bool GetPadMoveUp() +{ + return + (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || + (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || + (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0); +} + +bool GetPadMoveDown() +{ + return + (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || + (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || + (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0); +} + +bool GetPadMoveLeft() +{ + return + (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || + (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || + (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0); +} + +bool GetPadMoveRight() +{ + return + (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || + (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || + (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0); +} + +bool GetMouseForward() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB); +} + +bool GetMouseBack() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB); +} + +bool GetMousePos() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->OldMouseControllerState.y != 0.0f); +} + +bool GetMouseMoveLeft() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f); +} + +bool GetMouseMoveRight() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f); +} + +bool GetPadInput() +{ + return + GetPadBack() || + GetPadForward() || + GetPadMoveUp() || + GetPadMoveDown() || + GetPadMoveLeft() || + GetPadMoveRight(); +} + +bool GetMouseInput() +{ + return + GetMouseForward() || + GetMouseBack() || + GetMousePos() || + GetMouseMoveLeft() || + GetMouseMoveRight(); +} + STARTPATCHES InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); diff --git a/src/Pad.h b/src/Pad.h index 498731cf..e06aa9a6 100644 --- a/src/Pad.h +++ b/src/Pad.h @@ -1,22 +1,5 @@ #pragma once -// Some macros for frontend stuff. -#define PAD_START (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->NewState.Start) -#define PAD_ESC (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->NewState.Triangle) -#define PAD_ENTER (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->NewState.Cross) -#define PAD_UP (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0) -#define PAD_DOWN (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0) -#define PAD_LEFT (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0) -#define PAD_RIGHT (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0) -#define MOUSE_LMB (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB) -#define MOUSE_RMB (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB) -#define MOUSE_POS (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->NewMouseControllerState.y != 0.0f) -#define MOUSE_WHU (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f) -#define MOUSE_WHD (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f) - -#define PAD_INPUT (PAD_ESC || PAD_ENTER || PAD_UP || PAD_DOWN || PAD_LEFT || PAD_RIGHT) -#define MOUSE_INPUT (MOUSE_LMB || MOUSE_RMB || MOUSE_POS || MOUSE_WHU || MOUSE_WHD) - // same as RW skeleton /* enum Key -- cgit v1.2.3 From b6a70ecb315f2f4c361e33ed2803b1ebfd94f031 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 2 Jul 2019 20:28:20 +0200 Subject: Check if address is used twice --- src/patcher.h | 46 +++++++++++++++++++++++++++++----------------- src/re3.cpp | 4 ++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/patcher.h b/src/patcher.h index 43618b47..87a6bea4 100644 --- a/src/patcher.h +++ b/src/patcher.h @@ -9,6 +9,11 @@ #define NOVMT __declspec(novtable) #define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a +#include +#include + +#include "common.h" + enum { PATCH_CALL, @@ -28,6 +33,21 @@ enum extern int gtaversion; +class StaticPatcher +{ +private: + using Patcher = void(*)(); + + Patcher m_func; + StaticPatcher *m_next; + static StaticPatcher *ms_head; + + void Run() { m_func(); } +public: + StaticPatcher(Patcher func); + static void Apply(); +}; + template inline T AddressByVersion(uint32_t addressIII10, uint32_t addressIII11, uint32_t addressIIISteam, uint32_t addressvc10, uint32_t addressvc11, uint32_t addressvcSteam) { @@ -110,9 +130,18 @@ ClearCC(AT address, unsigned int nCount) VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]); } +extern std::vector usedAddresses; + template inline void InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING) { + if(std::any_of(usedAddresses.begin(), usedAddresses.end(), + [address](AT value) { return (int32)value == address; })) { + debug("Used address %#06x twice when injecting hook\n", address); + } + + usedAddresses.push_back((int32)address); + DWORD dwProtect[2]; switch ( nType ) { @@ -159,22 +188,5 @@ inline void InterceptVmethod(void *dst, T func, uint32_t a) Patch(a, func); } - - -class StaticPatcher -{ -private: - using Patcher = void(*)(); - - Patcher m_func; - StaticPatcher *m_next; - static StaticPatcher *ms_head; - - void Run() { m_func(); } -public: - StaticPatcher(Patcher func); - static void Apply(); -}; - #define STARTPATCHES static StaticPatcher Patcher([](){ #define ENDPATCHES }); diff --git a/src/re3.cpp b/src/re3.cpp index 87552214..9dc39d46 100644 --- a/src/re3.cpp +++ b/src/re3.cpp @@ -16,6 +16,10 @@ #include "Automobile.h" #include "debugmenu_public.h" +#include + +std::vector usedAddresses; + void **rwengine = *(void***)0x5A10E1; DebugMenuAPI gDebugMenuAPI; -- cgit v1.2.3 From 34e8fffcb4b41bb3049dfca9d42cea2e1da637f8 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 2 Jul 2019 21:31:12 +0200 Subject: Fix address of IsPedHeadAbovePos --- src/entities/Ped.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp index 14aad60a..61d6d182 100644 --- a/src/entities/Ped.cpp +++ b/src/entities/Ped.cpp @@ -1696,7 +1696,7 @@ STARTPATCHES InjectHook(0x4D2BB0, &CPed::Avoid, PATCH_JUMP); InjectHook(0x4C6A50, &CPed::ClearAimFlag, PATCH_JUMP); InjectHook(0x4C64F0, &CPed::ClearLookFlag, PATCH_JUMP); - InjectHook(0x4E5BD0, &CPed::IsPedHeadAbovePos, PATCH_JUMP); + InjectHook(0x4EB670, &CPed::IsPedHeadAbovePos, PATCH_JUMP); InjectHook(0x4E68A0, &CPed::FinishedAttackCB, PATCH_JUMP); InjectHook(0x4E5BD0, &CheckForPedsOnGroundToAttack, PATCH_JUMP); InjectHook(0x4E6BA0, &CPed::Attack, PATCH_JUMP); -- cgit v1.2.3 From e8215cf560318fdd77817cea485af50fca827552 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 2 Jul 2019 22:05:11 +0200 Subject: Revert "Implemented frontend inputs." --- src/ControllerConfig.cpp | 5 - src/ControllerConfig.h | 1 - src/Frontend.cpp | 1321 ++-------------------------------------------- src/Frontend.h | 21 +- src/MenuScreens.h | 84 +-- src/PCSave.cpp | 8 - src/PCSave.h | 7 - src/Pad.cpp | 3 +- src/PlayerSkin.cpp | 5 - src/PlayerSkin.h | 7 - src/Radar.h | 7 - src/audio/DMAudio.cpp | 9 +- src/audio/DMAudio.h | 8 +- src/common.h | 1 - src/config.h | 4 - src/entities/Vehicle.cpp | 3 +- src/entities/Vehicle.h | 1 - src/main.cpp | 7 +- src/main.h | 1 - src/render/Draw.cpp | 65 +-- src/render/Draw.h | 12 - src/render/Hud.cpp | 18 +- src/skel/win/win.cpp | 12 +- src/skel/win/win.h | 4 - 24 files changed, 126 insertions(+), 1488 deletions(-) delete mode 100644 src/PlayerSkin.cpp delete mode 100644 src/PlayerSkin.h diff --git a/src/ControllerConfig.cpp b/src/ControllerConfig.cpp index d7567ac4..a401e093 100644 --- a/src/ControllerConfig.cpp +++ b/src/ControllerConfig.cpp @@ -50,8 +50,3 @@ void CControllerConfigManager::LoadSettings(int32 file) } } } - -WRAPPER void CControllerConfigManager::SaveSettings(int32 file) -{ - EAXJMP(0x58B800); -} diff --git a/src/ControllerConfig.h b/src/ControllerConfig.h index 581efe05..00cab82e 100644 --- a/src/ControllerConfig.h +++ b/src/ControllerConfig.h @@ -42,7 +42,6 @@ public: int32 GetJoyButtonJustDown(); void LoadSettings(int32 file); - void SaveSettings(int32 file); void MakeControllerActionsBlank(); void InitDefaultControlConfiguration(); void InitDefaultControlConfigMouse(CMouseControllerState const &mousestate); diff --git a/src/Frontend.cpp b/src/Frontend.cpp index c16c8c25..8eff0324 100644 --- a/src/Frontend.cpp +++ b/src/Frontend.cpp @@ -20,10 +20,6 @@ #include "Script.h" #include "Camera.h" #include "MenuScreens.h" -#include "ControllerConfig.h" -#include "Vehicle.h" -#include "MBlur.h" -#include "PlayerSkin.h" int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; @@ -51,36 +47,8 @@ int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; -uint8 *CMenuManager::m_PrefsSkinFile = (uint8*)0x5F2E74; - CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; -// Move this somewhere else. -float lodMultiplier = *(float*)0x5F726C; - -// Stuff not in CMenuManager: -int VibrationTime; -char* pEditString; -int32 pControlEdit; -int8 DisplayComboButtonErrMsg; -bool MouseButtonJustClicked; -bool JoyButtonJustClicked; - -// Frontend inputs. -bool GetPadBack(); -bool GetPadForward(); -bool GetPadMoveUp(); -bool GetPadMoveDown(); -bool GetPadMoveLeft(); -bool GetPadMoveRight(); -bool GetMouseForward(); -bool GetMouseBack(); -bool GetMousePos(); -bool GetMouseMoveLeft(); -bool GetMouseMoveRight(); -bool GetPadInput(); -bool GetMouseInput(); - char *FrontendFilenames[] = { "fe2_mainpanel_ul", "fe2_mainpanel_ur", @@ -182,78 +150,6 @@ bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) } #endif -void CMenuManager::CheckSliderMovement(int value) -{ - float fBrightness = 0.0f; - float fDrawDistance = 0.0f; - float fRadioVolume = 0.0f; - float fSfxVolume = 0.0f; - float fMouseSens = 0.0f; - - switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { - case MENUACTION_BRIGHTNESS: - fBrightness = m_PrefsBrightness + (value * (512.0f) / 16.0f); - - if (fBrightness > 511.0f) - fBrightness = 511.0f; - else if (fBrightness < 0.0f) - fBrightness = 0.0f; - - m_PrefsBrightness = fBrightness; - SaveSettings(); - break; - case MENUACTION_DRAWDIST: - fDrawDistance = m_PrefsLOD + (value * (1.8f - 0.8f) / 16.0f); - - if (fDrawDistance > 1.8f) - fDrawDistance = 1.8f; - else if (fDrawDistance < 0.8f) - fDrawDistance = 0.8f; - - m_PrefsLOD = fDrawDistance; - SaveSettings(); - break; - case MENUACTION_MUSICVOLUME: - fRadioVolume = m_PrefsMusicVolume + (value * (128.0f) / 16.0f); - - if (fRadioVolume > 127.0f) - fRadioVolume = 127.0f; - else if (fRadioVolume < 0.0f) - fRadioVolume = 0.0f; - - m_PrefsMusicVolume = fRadioVolume; - DMAudio.SetMusicMasterVolume(fRadioVolume); - SaveSettings(); - break; - case MENUACTION_SFXVOLUME: - fSfxVolume = m_PrefsSfxVolume + (value * (128.0f) / 16.0f); - - if (fSfxVolume > 127) - fSfxVolume = 127; - else if (fSfxVolume < 0.0f) - fSfxVolume = 0.0f; - - m_PrefsSfxVolume = fSfxVolume; - DMAudio.SetEffectsMasterVolume(fSfxVolume); - SaveSettings(); - break; - case MENUACTION_MOUSESENS: - fMouseSens = TheCamera.m_fMouseAccelHorzntl + (value * (0.005f - 0.0003125f) / 16.0f); - - if (fMouseSens > 0.005f) - fMouseSens = 0.005f; - else if (fMouseSens < 0.0003125f) - fMouseSens = 0.0003125f; - - TheCamera.m_fMouseAccelHorzntl = fMouseSens; - - // BUG: game doesn't set Y Axis. - TheCamera.m_fMouseAccelVertical = fMouseSens; - SaveSettings(); - break; - }; -} - #if 1 WRAPPER int CMenuManager::CostructStatLine(int) { EAXJMP(0x482800); } #else @@ -268,38 +164,22 @@ WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } #else void CMenuManager::DisplayHelperText() { - static int32 AlphaText = 255; - static int32 Time = 0; - - if (m_nHelperTextMsgId && m_nHelperTextMsgId != 1) { - if (CTimer::GetTimeInMillisecondsPauseMode() - Time > 10) { - Time = CTimer::GetTimeInMillisecondsPauseMode(); - m_nHelperTextAlpha -= 2; - - if (AlphaText < 1) - ResetHelperText(); - - AlphaText = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha; - } - } - - wchar *HelperTextToPrint = nil; - // TODO: name this cases? + wchar *str = nil; switch (m_nHelperTextMsgId) { case 0: - HelperTextToPrint = TheText.Get("FET_MIG"); + str = TheText.Get("FET_MIG"); break; case 1: - HelperTextToPrint = TheText.Get("FET_APP"); + str = TheText.Get("FET_APP"); break; case 2: - HelperTextToPrint = TheText.Get("FET_HRD"); + str = TheText.Get("FET_HRD"); break; case 3: - HelperTextToPrint = TheText.Get("FET_RSO"); + str = TheText.Get("FET_RSO"); break; case 4: - HelperTextToPrint = TheText.Get("FET_RSC"); + str = TheText.Get("FET_RSC"); break; default: break; @@ -308,11 +188,11 @@ void CMenuManager::DisplayHelperText() CFont::SetAlignment(ALIGN_CENTER); CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetFontStyle(FONT_HEADING); - CFont::SetDropColor(CRGBA(0, 0, 0, AlphaText)); + CFont::SetDropColor(CRGBA(0, 0, 0, MENUDROP_COLOR_A)); CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); - CFont::SetColor(CRGBA(255, 255, 255, AlphaText)); - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), HelperTextToPrint); + CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), str); } #endif @@ -347,22 +227,12 @@ float CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightS } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } #else -void CMenuManager::DoSettingsBeforeStartingAGame() +WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { - CCamera::m_bUseMouse3rdPerson = m_ControlMethod == 0; - if (m_PrefsVsyncDisp != m_PrefsVsync) - m_PrefsVsync = m_PrefsVsyncDisp; - - m_bStartGameLoading = true; - ShutdownJustMenu(); - UnloadTextures(); - DMAudio.SetEffectsFadeVol(0); - DMAudio.SetMusicFadeVol(0); - DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); } #endif @@ -441,7 +311,6 @@ void CMenuManager::Draw() for (int i = 0; i < MENUROWS; ++i) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0]) { wchar *textToPrint[MENUCOLUMNS] = { nil, nil }; - bool Locked = false; if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1); @@ -454,13 +323,6 @@ void CMenuManager::Draw() } else { textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); - - if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_SCREENRES) { - if (m_bGameNotLoaded) - Locked = false; - else - Locked = true; - } } switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { @@ -497,39 +359,7 @@ void CMenuManager::Draw() textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsShowSubtitles ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_WIDESCREEN: -#ifndef HOR_PLUS textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsUseWideScreen ? "FEM_ON" : "FEM_OFF"); -#else - switch (m_PrefsUseWideScreen) { - case AR_AUTO: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"AUTO"; - break; - case AR_3_2: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"3:2"; - break; - case AR_4_3: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"4:3"; - break; - case AR_5_3: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"5:3"; - break; - case AR_5_4: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"5:4"; - break; - case AR_15_9: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"15:9"; - break; - case AR_16_9: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; - break; - case AR_16_10: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:10"; - break; - case AR_64_27: - textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"64:27"; - break; - }; -#endif break; case MENUACTION_RADIO: sprintf(gString, "FEA_FM%d", m_PrefsRadioStation); @@ -556,16 +386,16 @@ void CMenuManager::Draw() } break; case MENUACTION_AUDIOHW: - if (m_nPrefsAudio3DProviderIndex == -1) + if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { - char *provider = MusicManager.Get3DProviderName(m_nPrefsAudio3DProviderIndex); + char *provider = MusicManager.Get3DProviderName(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); AsciiToUnicode(provider, gUString); textToPrint[MENUCOLUMN_RIGHT] = gUString; } break; case MENUACTION_SPEAKERCONF: - if (m_nPrefsAudio3DProviderIndex == -1) + if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { switch (m_PrefsSpeakers) { @@ -596,7 +426,7 @@ void CMenuManager::Draw() break; case MENUACTION_MOUSESTEER: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_ON" : "FEM_OFF"); - break; + break; }; CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); @@ -666,7 +496,6 @@ void CMenuManager::Draw() case MENUPAGE_LANGUAGE_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MIN_Y); break; - case MENUPAGE_MOUSE_CONTROLS: case MENUPAGE_GRAPHICS_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MAX_Y); break; @@ -696,7 +525,7 @@ void CMenuManager::Draw() CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); CSprite2d::DrawRect(CRect(SCREEN_STRETCH_X(11.0f), vecPositions.y - SCREEN_STRETCH_Y(fBarSize * 0.13f), SCREEN_STRETCH_FROM_RIGHT(11.0f), vecPositions.y + SCREEN_STRETCH_Y(fBarSize)), CRGBA(100, 200, 50, 50)); } - else + else CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); // Draw @@ -704,43 +533,32 @@ void CMenuManager::Draw() CFont::PrintString(vecPositions.x, vecPositions.y, textToPrint[MENUCOLUMN_LEFT]); if (textToPrint[MENUCOLUMN_RIGHT]) { - if (Locked) - CFont::SetColor(CRGBA(190, 130, 40, FadeIn(255))); - CFont::SetAlignment(ALIGN_RIGHT); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SavePageSlot ? MENUCOLUMN_SAVE_X : MENUCOLUMN_POS_X), vecPositions.y, textToPrint[MENUCOLUMN_RIGHT]); } - // Mouse support. - // TODO: inputs for these pages. - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - } - else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - - } - else { - static bool bIsMouseInPosition = false; - if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) { - CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; - if (m_bShowMouse && - ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) - bIsMouseInPosition = true; - else - bIsMouseInPosition = false; + // Mouse support. + bool bIsMouseInPosition = false; + if (m_nMenuFadeAlpha >= 255) { + CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; + if (m_bShowMouse && + ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) + bIsMouseInPosition = true; + else + bIsMouseInPosition = false; - if (bIsMouseInPosition) { - if (m_nCurrOption != i) { - m_nCurrOption = i; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } + if (bIsMouseInPosition) { + if (m_nCurrOption != i) { + m_nCurrOption = i; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } - m_nPrevOption = m_nCurrOption; + m_nCurrentInput = m_nCurrOption; - if (GetMouseForward()) - m_nHoverOption = IGNORE_OPTION; - else - m_nHoverOption = ACTIVATE_OPTION; - } + if (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB) + m_nHoverOption = IGNORE_OPTION; + else + m_nHoverOption = ACTIVATE_OPTION; } } @@ -768,21 +586,14 @@ void CMenuManager::Draw() float fIconSpacing = 59.52f; if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { for (int i = 0; i < POLICE_RADIO; i++) { -#ifndef MID_RADIOICONS - if (i < USERTRACK) - m_aFrontEndSprites[i + FE_RADIO1].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); -#else - float fMp3Pos = 0.0f; - if (DMAudio.IsMP3RadioChannelAvailable()) - fMp3Pos = 34.0f; + + if (i == MSX_FM) + fIconSpacing -= 1.5f; if (i < USERTRACK) - m_aFrontEndSprites[i + FE_RADIO1].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); -#endif + m_aFrontEndSprites[i + FE_RADIO1].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); + if (i > CHATTERBOX) + m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, DMAudio.IsMP3RadioChannelAvailable() ? 170 : 25)); } } @@ -1065,31 +876,12 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens() } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); } #else void CMenuManager::InitialiseChangedLanguageSettings() { - if (m_bFrontEnd_ReloadObrTxtGxt) { - CTimer::Stop(); - TheText.Unload(); - TheText.Load(); - CTimer::Update(); - CGame::frenchGame = false; - CGame::germanGame = false; - switch (CMenuManager::m_PrefsLanguage) { - case LANGUAGE_FRENCH: - CGame::frenchGame = true; - break; - case LANGUAGE_GERMAN: - CGame::germanGame = true; - break; - default: - return; - }; - m_bFrontEnd_ReloadObrTxtGxt = false; - } } #endif @@ -1151,103 +943,12 @@ void CMenuManager::LoadAllTextures() } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } #else void CMenuManager::LoadSettings() { - CFileMgr::SetDirMyDocuments(); - - uint8 prevLang = m_PrefsLanguage; - MousePointerStateHelper.bInvertVertically = true; - - static char Ver; - int fileHandle = CFileMgr::OpenFile("gta3.set", "rb"); - if (fileHandle) { - CFileMgr::Read(fileHandle, buf(&Ver), sizeof(Ver)); - - if (strncmp(&Ver, "THIS FILE IS NOT VALID YET", 26)) { - CFileMgr::Seek(fileHandle, 0, 0); - ControlsManager.LoadSettings(fileHandle); - CFileMgr::Read(fileHandle, buf(&gString), 20); - CFileMgr::Read(fileHandle, buf(&gString), 20); - CFileMgr::Read(fileHandle, buf(&gString), 4); - CFileMgr::Read(fileHandle, buf(&gString), 4); - CFileMgr::Read(fileHandle, buf(&gString), 1); - CFileMgr::Read(fileHandle, buf(&gString), 1); - CFileMgr::Read(fileHandle, buf(&gString), 1); - CFileMgr::Read(fileHandle, buf(&TheCamera.m_bHeadBob), sizeof(TheCamera.m_bHeadBob)); - CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), sizeof(TheCamera.m_fMouseAccelHorzntl)); - CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), sizeof(TheCamera.m_fMouseAccelVertical)); - CFileMgr::Read(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), sizeof(MousePointerStateHelper.bInvertVertically)); - CFileMgr::Read(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), sizeof(CVehicle::m_bDisableMouseSteering)); - CFileMgr::Read(fileHandle, buf(&m_PrefsSfxVolume), sizeof(m_PrefsSfxVolume)); - CFileMgr::Read(fileHandle, buf(&m_PrefsMusicVolume), sizeof(m_PrefsMusicVolume)); - CFileMgr::Read(fileHandle, buf(&m_PrefsRadioStation), sizeof(m_PrefsRadioStation)); - CFileMgr::Read(fileHandle, buf(&m_PrefsSpeakers), sizeof(m_PrefsSpeakers)); - CFileMgr::Read(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), sizeof(m_nPrefsAudio3DProviderIndex)); - CFileMgr::Read(fileHandle, buf(&m_PrefsDMA), sizeof(m_PrefsDMA)); - CFileMgr::Read(fileHandle, buf(&m_PrefsBrightness), sizeof(m_PrefsBrightness)); - CFileMgr::Read(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); - CFileMgr::Read(fileHandle, buf(&m_PrefsShowSubtitles), sizeof(m_PrefsShowSubtitles)); - CFileMgr::Read(fileHandle, buf(&m_PrefsUseWideScreen), sizeof(m_PrefsUseWideScreen)); - CFileMgr::Read(fileHandle, buf(&m_PrefsVsyncDisp), sizeof(m_PrefsVsyncDisp)); - CFileMgr::Read(fileHandle, buf(&m_PrefsFrameLimiter), sizeof(m_PrefsFrameLimiter)); - CFileMgr::Read(fileHandle, buf(&m_nDisplayVideoMode), sizeof(m_nPrefsVideoMode)); - CFileMgr::Read(fileHandle, buf(&BlurOn), sizeof(BlurOn)); - CFileMgr::Read(fileHandle, buf(&m_PrefsSkinFile), sizeof(m_PrefsSkinFile)); - CFileMgr::Read(fileHandle, buf(&m_ControlMethod), sizeof(m_ControlMethod)); - CFileMgr::Read(fileHandle, buf(&m_PrefsLanguage), sizeof(m_PrefsLanguage)); - } - } - - CFileMgr::CloseFile(fileHandle); - CFileMgr::SetDir(""); - -#ifndef HOR_PLUS -#else - if (m_PrefsUseWideScreen < AR_AUTO || m_PrefsUseWideScreen > AR_64_27) - m_PrefsUseWideScreen = AR_AUTO; -#endif - - m_PrefsVsync = m_PrefsVsyncDisp; - lodMultiplier = m_PrefsLOD; - - if (m_nPrefsAudio3DProviderIndex == -1) - m_nPrefsAudio3DProviderIndex = -2; - - if (m_PrefsLanguage == prevLang) - m_bLanguageLoaded = false; - else { - m_bLanguageLoaded = true; - TheText.Unload(); - TheText.Load(); - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - - debug("The previously saved language is now in use"); - } - - /*struct _WIN32_FIND_DATAA FindFileData; - HANDLE H = FindFirstFileA("skins\*.bmp", &FindFileData); - char Dest; - bool SkinFound = false; - - for (int i = 1; H != (HANDLE)-1 && i; i = FindNextFileA(H, &FindFileData)) { - strcpy(&Dest, buf(m_PrefsSkinFile)); - strcat(&Dest, ".bmp"); - if (!strcmp(FindFileData.cFileName, &Dest)) - SkinFound = true; - } - - FindClose(H); - - if (!SkinFound) { - debug("Default skin set as no other skins are available OR saved skin not found!"); - strcpy((char *)CMenuManager::m_PrefsSkinFile, "$$\"\""); - strcpy(m_aSkinName, "$$\"\""); - }*/ } #endif @@ -1311,623 +1012,31 @@ void CMenuManager::PrintStats() } #endif -#if 0 + +#if 1 WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { - if (m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) - return; - - field_113 = 0; - InitialiseChangedLanguageSettings(); - - SwitchMenuOnAndOff(); - - if (m_bMenuActive) { - LoadAllTextures(); - - if (m_nCurrScreen == MENUPAGE_DELETING) { - bool SlotPopulated = false; - - if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { - PcSaveHelper.PopulateSlotInfo(); - SlotPopulated = true; - } - if (SlotPopulated) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { - int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); - PcSaveHelper.PopulateSlotInfo(); - if (SaveSlot) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { - if (CheckSlotDataValid(m_nCurrSaveSlot)) { - TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; - if (m_PrefsVsyncDisp != m_PrefsVsync) - m_PrefsVsync = m_PrefsVsyncDisp; - DMAudio.Service(); - m_bStartGameLoading = 1; - RequestFrontEndShutdown(); - m_bLoadingSavedGame = 1; - b_FoundRecentSavedGameWantToLoad = 1; - DMAudio.SetEffectsFadeVol(0); - DMAudio.SetMusicFadeVol(0); - DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - - ProcessButtonPresses(); - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else { - if (GetPadBack()) - RequestFrontEndStartUp(); - - UnloadTextures(); - m_nPrevScreen = MENUPAGE_NONE; - m_nCurrScreen = m_nPrevScreen; - m_nCurrOption = MENUROW_0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMilliseconds(); - } } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { - // Update Mouse Position - m_nMouseOldPosX = m_nMousePosX; - m_nMouseOldPosY = m_nMousePosY; - - m_nMousePosX = m_nMouseTempPosX; - m_nMousePosY = m_nMouseTempPosY; - - if (m_nMousePosX < 0) - m_nMousePosX = 0; - if (m_nMousePosX > SCREEN_WIDTH) - m_nMousePosX = SCREEN_WIDTH; - if (m_nMousePosY < 0) - m_nMousePosY = 0; - if (m_nMousePosY > SCREEN_HEIGHT) - m_nMousePosY = SCREEN_HEIGHT; - - // Show/hide mouse cursor. - if (GetMouseInput()) - m_bShowMouse = true; - else if (GetPadInput()) - m_bShowMouse = false; - - // Get number of menu options. - uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); - - // Select next/previous option with pad. Mouse is done in drawing function. - if (GetPadMoveUp()) { - m_nPrevOption = m_nCurrOption; - m_nCurrOption -= 1; - - if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { - if (m_nCurrOption < MENUROW_1) - m_nCurrOption = NumberOfMenuOptions; - } - else { - if (m_nCurrOption < MENUROW_0) - m_nCurrOption = NumberOfMenuOptions; - } - - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } - else if (GetPadMoveDown()) { - m_nPrevOption = m_nCurrOption; - m_nCurrOption += 1; - - if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { - if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = MENUROW_1; - } - else { - if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = MENUROW_0; - } - - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } - - // Set what happens if ESC is pressed. - if (GetPadBack()) { - bool PlayEscSound = false; - switch (m_nCurrScreen) { - case MENUPAGE_START_MENU: - break; - case MENUPAGE_CHOOSE_SAVE_SLOT: - case MENUPAGE_PAUSE_MENU: - RequestFrontEndShutdown(); - PlayEscSound = true; - break; - default: - SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); - PlayEscSound = true; - break; - }; - - if (PlayEscSound) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); - } - - // TODO: finish hover options. - // Set mouse buttons. - if (GetMouseForward()) { - switch (m_nHoverOption) { - case ACTIVATE_OPTION: - if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) - m_nCurrOption = m_nPrevOption; - m_nHoverOption = ACTIVATE_OPTION; - break; - default: - break; - }; - } - - // Process all menu options here, but first check if it's an option or a redirect. - int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; - if ((GetPadForward() || GetMouseForward()) || - ((GetPadMoveLeft() || GetMouseMoveRight()) || (GetPadMoveRight() || GetMouseMoveLeft())) && - (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen && - CurrAction != MENUACTION_CHANGEMENU && - CurrAction != MENUACTION_LOADRADIO && - CurrAction != MENUACTION_RESTOREDEF && - CurrAction != MENUACTION_PLAYERSETUP)) { - - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB")) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); - else - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - - ProcessOnOffMenuOptions(); - } - - // Process screens that may redirect you somewhere, or may not. - switch (m_nCurrScreen) { - case MENUPAGE_LOAD_SLOT_CONFIRM: - break; - case MENUPAGE_NEW_GAME_RELOAD: - if (m_bGameNotLoaded) - DoSettingsBeforeStartingAGame(); - break; - case MENUPAGE_CHOOSE_DELETE_SLOT: - case MENUPAGE_CHOOSE_SAVE_SLOT: - case MENUPAGE_CHOOSE_LOAD_SLOT: - PcSaveHelper.PopulateSlotInfo(); - break; - default: - break; - }; - - // Reset pad shaking. - if (VibrationTime != 0) { - if (CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { - CPad::GetPad(0)->StopShaking(0); - VibrationTime = 0; - } - } } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } #else void CMenuManager::ProcessOnOffMenuOptions() { - int8 InputDirection = (GetPadMoveLeft() || GetMouseMoveLeft()) && (!GetPadForward() && !GetMouseForward()) ? -1 : 1; - int8 InputEnter = GetPadForward(); - - uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); - - // In numerical order. - switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { - case MENUACTION_CHANGEMENU: - SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); - break; - case MENUACTION_CTRLVIBRATION: - if (!m_PrefsUseVibration) - m_PrefsUseVibration = true; - - if (m_PrefsUseVibration) { - CPad::GetPad(0)->StartShake(350, 150); - VibrationTime = CTimer::GetTimeInMillisecondsPauseMode() + 500; - } - SaveSettings(); - break; - case MENUACTION_FRAMESYNC: - m_PrefsVsync = m_PrefsVsync == false; - SaveSettings(); - break; - case MENUACTION_FRAMELIMIT: - m_PrefsFrameLimiter = m_PrefsFrameLimiter == false; - SaveSettings(); - break; - case MENUACTION_TRAILS: - BlurOn = BlurOn == false; - if (!BlurOn) - CMBlur::MotionBlurClose(); - else - CMBlur::MotionBlurOpen(Scene.camera); - - SaveSettings(); - break; - case MENUACTION_SUBTITLES: - m_PrefsShowSubtitles = m_PrefsShowSubtitles == false; - SaveSettings(); - break; - case MENUACTION_WIDESCREEN: -#ifndef HOR_PLUS - m_PrefsUseWideScreen = m_PrefsUseWideScreen == false; -#else - if (InputDirection < 0) { - switch (m_PrefsUseWideScreen) { - case AR_AUTO: - m_PrefsUseWideScreen = AR_64_27; - break; - case AR_3_2: - m_PrefsUseWideScreen = AR_AUTO; - break; - case AR_4_3: - m_PrefsUseWideScreen = AR_3_2; - break; - case AR_5_3: - m_PrefsUseWideScreen = AR_4_3; - break; - case AR_5_4: - m_PrefsUseWideScreen = AR_5_3; - break; - case AR_15_9: - m_PrefsUseWideScreen = AR_5_4; - break; - case AR_16_9: - m_PrefsUseWideScreen = AR_15_9; - break; - case AR_16_10: - m_PrefsUseWideScreen = AR_16_9; - break; - case AR_64_27: - m_PrefsUseWideScreen = AR_16_10; - break; - }; - } - else { - switch (m_PrefsUseWideScreen) { - case AR_AUTO: - m_PrefsUseWideScreen = AR_3_2; - break; - case AR_3_2: - m_PrefsUseWideScreen = AR_4_3; - break; - case AR_4_3: - m_PrefsUseWideScreen = AR_5_3; - break; - case AR_5_3: - m_PrefsUseWideScreen = AR_5_4; - break; - case AR_5_4: - m_PrefsUseWideScreen = AR_15_9; - break; - case AR_15_9: - m_PrefsUseWideScreen = AR_16_9; - break; - case AR_16_9: - m_PrefsUseWideScreen = AR_16_10; - break; - case AR_16_10: - m_PrefsUseWideScreen = AR_64_27; - break; - case AR_64_27: - m_PrefsUseWideScreen = AR_AUTO; - break; - }; - } -#endif - SaveSettings(); - break; - case MENUACTION_BRIGHTNESS: - case MENUACTION_DRAWDIST: - case MENUACTION_MUSICVOLUME: - case MENUACTION_SFXVOLUME: - case MENUACTION_MOUSESENS: - if (InputDirection > 0) - CheckSliderMovement(1.0f); - else - CheckSliderMovement(-1.0f); - break; - case MENUACTION_RADIO: - if (InputDirection < 0) - m_PrefsRadioStation -= 1; - else - m_PrefsRadioStation += 1; - - if (DMAudio.IsMP3RadioChannelAvailable()) { - if (m_PrefsRadioStation > USERTRACK) - m_PrefsRadioStation = HEAD_RADIO; - else if (m_PrefsRadioStation < HEAD_RADIO) - m_PrefsRadioStation = USERTRACK; - } - else { - if (m_PrefsRadioStation > CHATTERBOX) - m_PrefsRadioStation = HEAD_RADIO; - else if (m_PrefsRadioStation < HEAD_RADIO) - m_PrefsRadioStation = CHATTERBOX; - } - - SaveSettings(); - DMAudio.SetRadioInCar(m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); - break; - case MENUACTION_LANG_ENG: - if (m_PrefsLanguage != LANGUAGE_AMERICAN) { - m_PrefsLanguage = LANGUAGE_AMERICAN; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - } - break; - case MENUACTION_LANG_FRE: - if (m_PrefsLanguage != LANGUAGE_FRENCH) { - m_PrefsLanguage = LANGUAGE_FRENCH; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - } - break; - case MENUACTION_LANG_GER: - if (m_PrefsLanguage != LANGUAGE_GERMAN) { - m_PrefsLanguage = LANGUAGE_GERMAN; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - } - break; - case MENUACTION_LANG_ITA: - if (m_PrefsLanguage != LANGUAGE_ITALIAN) { - m_PrefsLanguage = LANGUAGE_ITALIAN; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - } - break; - case MENUACTION_LANG_SPA: - if (m_PrefsLanguage != LANGUAGE_SPANISH) { - m_PrefsLanguage = LANGUAGE_SPANISH; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - } - break; - case MENUACTION_UPDATESAVE: - PcSaveHelper.PopulateSlotInfo(); - if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { - m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; - - SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); - } - break; - case MENUACTION_CHECKSAVE: - if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { - m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; - - if (Slots[m_nCurrSaveSlot] != 1 && Slots[m_nCurrSaveSlot] != 2) - SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); - } - break; - case MENUACTION_NEWGAME: - DoSettingsBeforeStartingAGame(); - break; - case MENUACTION_SETDBGFLAG: - CTheScripts::DbgFlag = CTheScripts::DbgFlag == false; - break; - case MENUACTION_UPDATEMEMCARDSAVE: - RequestFrontEndShutdown(); - break; - case MENUACTION_INVVERT: - MousePointerStateHelper.bInvertVertically = MousePointerStateHelper.bInvertVertically == false; - return; - case MENUACTION_CANCLEGAME: - DMAudio.Service(); - RsEventHandler(rsQUITAPP, 0); - break; - case MENUACTION_RESUME: - RequestFrontEndShutdown(); - break; - case MENUACTION_SCREENRES: - if (m_bGameNotLoaded) { - if (InputEnter) { - if (m_nDisplayVideoMode != m_nPrefsVideoMode) { - m_nPrefsVideoMode = m_nDisplayVideoMode; - _psSelectScreenVM(m_nPrefsVideoMode); - CentreMousePointer(); - m_PrefsUseWideScreen = AR_AUTO; - SaveSettings(); - } - } - else { - char** VideoModeList = _psGetVideoModeList(); - int NumVideoModes = _psGetNumVideModes(); - - if (InputDirection > 0) { - int nCurrentVidMode = m_nDisplayVideoMode + 1; - - if (nCurrentVidMode >= NumVideoModes) - nCurrentVidMode = 0; - - while (!VideoModeList[nCurrentVidMode]) { - ++nCurrentVidMode; - - if (nCurrentVidMode >= NumVideoModes) - nCurrentVidMode = 0; - } - - m_nDisplayVideoMode = nCurrentVidMode; - } - else { - int nCurrentVidMode = m_nDisplayVideoMode - 1; - - if (nCurrentVidMode < 0) - nCurrentVidMode = NumVideoModes - 1; - - while (!VideoModeList[nCurrentVidMode]) { - --nCurrentVidMode; - - if (nCurrentVidMode < 0) - nCurrentVidMode = NumVideoModes - 1; - } - m_nDisplayVideoMode = nCurrentVidMode; - } - } - } - break; - case MENUACTION_AUDIOHW: - { - int8 AudioHardware = m_nPrefsAudio3DProviderIndex; - if (m_nPrefsAudio3DProviderIndex == -1) - break; - - if (InputDirection > 0) { - switch (m_nPrefsAudio3DProviderIndex) { - case 0: - m_nPrefsAudio3DProviderIndex = 1; - break; - case 1: - m_nPrefsAudio3DProviderIndex = 2; - break; - case 2: - m_nPrefsAudio3DProviderIndex = 3; - break; - case 3: - m_nPrefsAudio3DProviderIndex = 4; - break; - case 4: - m_nPrefsAudio3DProviderIndex = 5; - break; - case 5: - m_nPrefsAudio3DProviderIndex = 6; - break; - case 6: - m_nPrefsAudio3DProviderIndex = 0; - break; - } - } - else { - switch (m_nPrefsAudio3DProviderIndex) { - case 0: - m_nPrefsAudio3DProviderIndex = 6; - break; - case 1: - m_nPrefsAudio3DProviderIndex = 0; - break; - case 2: - m_nPrefsAudio3DProviderIndex = 1; - break; - case 3: - m_nPrefsAudio3DProviderIndex = 2; - break; - case 4: - m_nPrefsAudio3DProviderIndex = 3; - break; - case 5: - m_nPrefsAudio3DProviderIndex = 4; - break; - case 6: - m_nPrefsAudio3DProviderIndex = 5; - break; - } - } - - DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); - - if (AudioHardware == m_nPrefsAudio3DProviderIndex) - SetHelperText(0); - else - SetHelperText(4); - - SaveSettings(); - break; - } - case MENUACTION_SPEAKERCONF: - if (m_nPrefsAudio3DProviderIndex == -1) - break; - - if (InputDirection > 0) { - switch (m_PrefsSpeakers) { - case 0: - m_PrefsSpeakers = 1; - break; - case 1: - m_PrefsSpeakers = 2; - break; - case 2: - m_PrefsSpeakers = 0; - break; - }; - } - else { - switch (m_PrefsSpeakers) { - case 0: - m_PrefsSpeakers = 2; - break; - case 1: - m_PrefsSpeakers = 0; - break; - case 2: - m_PrefsSpeakers = 1; - break; - }; - } - - DMAudio.SetSpeakerConfig(m_PrefsSpeakers); - SaveSettings(); - break; - case MENUACTION_RESTOREDEF: - SetDefaultPreferences(m_nCurrScreen); - SetHelperText(2); - SaveSettings(); - break; - case MENUACTION_CTRLMETHOD: - if (m_ControlMethod) { - TheCamera.m_bUseMouse3rdPerson = 1; - m_ControlMethod = 0; - } - else { - TheCamera.m_bUseMouse3rdPerson = 0; - m_ControlMethod = 1; - } - SaveSettings(); - break; - case MENUACTION_DYNAMICACOUSTIC: - m_PrefsDMA = m_PrefsDMA == false; - break; - case MENUACTION_MOUSESTEER: - m_bDisableMouseSteering = m_bDisableMouseSteering == false; - return; - }; } #endif @@ -1960,41 +1069,12 @@ void CMenuManager::ResetHelperText() } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { EAXJMP(0x488930); } #else void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { - switch (PcSaveHelper.m_nHelper) { - case 1: - case 2: - case 3: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_FAILED; - break; - break; - case 4: - case 5: - case 6: - this->m_nPrevScreen = m_nCurrScreen; - this->m_nCurrScreen = MENUPAGE_LOAD_FAILED; - break; - case 7: - this->m_nPrevScreen = m_nCurrScreen; - this->m_nCurrScreen = MENUPAGE_LOAD_FAILED_2; - break; - case 8: - case 9: - case 10: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_FAILED; - break; - default: - return; - } - m_nCurrOption = MENUROW_0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); } #endif @@ -2008,50 +1088,12 @@ void CMenuManager::SetHelperText(int text) } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } #else void CMenuManager::SaveSettings() { - CFileMgr::SetDirMyDocuments(); - - int fileHandle = CFileMgr::OpenFile("gta3.set", "wb"); - if (fileHandle) { - - ControlsManager.SaveSettings(fileHandle); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_bHeadBob), sizeof(TheCamera.m_bHeadBob)); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), sizeof(TheCamera.m_fMouseAccelHorzntl)); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), sizeof(TheCamera.m_fMouseAccelVertical)); - CFileMgr::Write(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), sizeof(MousePointerStateHelper.bInvertVertically)); - CFileMgr::Write(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), sizeof(CVehicle::m_bDisableMouseSteering)); - CFileMgr::Write(fileHandle, buf(&m_PrefsSfxVolume), sizeof(m_PrefsSfxVolume)); - CFileMgr::Write(fileHandle, buf(&m_PrefsMusicVolume), sizeof(m_PrefsMusicVolume)); - CFileMgr::Write(fileHandle, buf(&m_PrefsRadioStation), sizeof(m_PrefsRadioStation)); - CFileMgr::Write(fileHandle, buf(&m_PrefsSpeakers), sizeof(m_PrefsSpeakers)); - CFileMgr::Write(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), sizeof(m_nPrefsAudio3DProviderIndex)); - CFileMgr::Write(fileHandle, buf(&m_PrefsDMA), sizeof(m_PrefsDMA)); - CFileMgr::Write(fileHandle, buf(&m_PrefsBrightness), sizeof(m_PrefsBrightness)); - CFileMgr::Write(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); - CFileMgr::Write(fileHandle, buf(&m_PrefsShowSubtitles), sizeof(m_PrefsShowSubtitles)); - CFileMgr::Write(fileHandle, buf(&m_PrefsUseWideScreen), sizeof(m_PrefsUseWideScreen)); - CFileMgr::Write(fileHandle, buf(&m_PrefsVsyncDisp), sizeof(m_PrefsVsyncDisp)); - CFileMgr::Write(fileHandle, buf(&m_PrefsFrameLimiter), sizeof(m_PrefsFrameLimiter)); - CFileMgr::Write(fileHandle, buf(&m_nDisplayVideoMode), sizeof(m_nPrefsVideoMode)); - CFileMgr::Write(fileHandle, buf(&BlurOn), sizeof(BlurOn)); - CFileMgr::Write(fileHandle, buf(&m_PrefsSkinFile), sizeof(m_PrefsSkinFile)); - CFileMgr::Write(fileHandle, buf(&m_ControlMethod), sizeof(m_ControlMethod)); - CFileMgr::Write(fileHandle, buf(&m_PrefsLanguage), sizeof(m_PrefsLanguage)); - } - CFileMgr::CloseFile(fileHandle); - CFileMgr::SetDir(""); } #endif @@ -2065,7 +1107,6 @@ void CMenuManager::ShutdownJustMenu() } #endif -// We won't ever use this again. #if 0 WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); } #else @@ -2095,44 +1136,7 @@ WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } #else void CMenuManager::SwitchMenuOnAndOff() { - // Just what the function name says. - if (m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { - if (!m_bMenuActive) - m_bMenuActive = true; - - if (m_bShutDownFrontEndRequested) - m_bMenuActive = false; - if (m_bStartUpFrontEndRequested) - m_bMenuActive = true; - - if (m_bMenuActive) { - CTimer::StartUserPause(); - } - else { - ShutdownJustMenu(); - SaveSettings(); - m_bStartUpFrontEndRequested = false; - pControlEdit = 0; - m_bShutDownFrontEndRequested = false; - DisplayComboButtonErrMsg = 0; - CPad::GetPad(0)->Clear(0); - CPad::GetPad(1)->Clear(0); - SwitchToNewScreen(0); - } - } - if (m_bSaveMenuActive && !m_bQuitGameNoCD) { - m_bSaveMenuActive = false; - m_bMenuActive = true; - CTimer::StartUserPause(); - SwitchToNewScreen(MENUPAGE_CHOOSE_SAVE_SLOT); - PcSaveHelper.PopulateSlotInfo(); - } - - if (!m_bMenuActive) - field_112 = 1; - m_bStartUpFrontEndRequested = false; - m_bShutDownFrontEndRequested = false; } #endif @@ -2161,241 +1165,18 @@ void CMenuManager::UnloadTextures() } #endif -#if 0 +#if 1 WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } #else void CMenuManager::WaitForUserCD() { - LoadSplash(0); - if (!RsGlobal.quit) { - HandleExit(); - CPad::UpdatePads(); - MessageScreen("NO_PCCD"); - - if (GetPadBack()) { - m_bQuitGameNoCD = true; - RsEventHandler(rsQUITAPP, 0); - } - } -} -#endif - -// New content: -uint8 CMenuManager::GetNumberOfMenuOptions() -{ - uint8 Rows = MENUROW_NONE; - for (int i = 0; i < MENUROWS; i++) { - if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_NOTHING) - break; - ++Rows; - }; - return Rows; -} - -void CMenuManager::SwitchToNewScreen(int8 screen) -{ - ResetHelperText(); - - // Return to - behaviour. - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") || - (screen == aScreens[m_nCurrScreen].m_PreviousPage[0])) { - if (m_bGameNotLoaded) { - m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[0]; - m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[0]; - } - else { - m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[1]; - m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[1]; - } - - m_nMenuFadeAlpha = 0; - } - else { - // Go through - behaviour. - if (screen) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = screen; - m_nCurrOption = MENUROW_0; - m_nMenuFadeAlpha = 0; - } - else { - m_nPrevScreen = MENUPAGE_NONE; - m_nCurrScreen = MENUPAGE_NONE; - m_nCurrOption = MENUROW_0; - } - } - - // Set player skin. - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - CPlayerSkin::BeginFrontEndSkinEdit(); - field_535 = 19; - m_bSkinsFound = false; - } - - // Set radio station. - if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); - OutputDebugStringA("FRONTEND AUDIO TRACK STOPPED"); - } - else - DMAudio.StopFrontEndTrack(); -} - -void CMenuManager::SetDefaultPreferences(int8 screen) -{ - switch (screen) { - case MENUPAGE_SOUND_SETTINGS: - m_PrefsMusicVolume = 102; - m_PrefsSfxVolume = 102; - m_PrefsSpeakers = 0; - m_nPrefsAudio3DProviderIndex = 6; - m_PrefsDMA = true; - DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); - DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); - DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); - break; - case MENUPAGE_GRAPHICS_SETTINGS: - m_PrefsBrightness = 256; - m_PrefsFrameLimiter = true; - m_PrefsVsync = true; - m_PrefsLOD = 1.2f; - m_PrefsVsyncDisp = true; - lodMultiplier = 1.2; - BlurOn = true; - CMBlur::MotionBlurOpen(Scene.camera); - m_PrefsUseVibration = false; - m_PrefsShowSubtitles = true; - m_nDisplayVideoMode = m_nPrefsVideoMode; - m_PrefsUseWideScreen = AR_AUTO; - break; - case MENUPAGE_CONTROLLER_PC: - ControlsManager.MakeControllerActionsBlank(); - ControlsManager.InitDefaultControlConfiguration(); - - CMouseControllerState state = MousePointerStateHelper.GetMouseSetUp(); - ControlsManager.InitDefaultControlConfigMouse(state); - - if (1) { - //TODO: JoyPad stuff. - } - m_ControlMethod = 0; - MousePointerStateHelper.bInvertVertically = true; - TheCamera.m_fMouseAccelHorzntl = 0.25f; - CVehicle::m_bDisableMouseSteering = true; - TheCamera.m_bHeadBob = false; - break; - }; -} - -// Frontend inputs. -bool GetPadBack() -{ - return - (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || - (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->OldState.Start) || - (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->OldState.Triangle); -} - -bool GetPadForward() -{ - return - (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || - (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || - (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->OldState.Cross); -} - -bool GetPadMoveUp() -{ - return - (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || - (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || - (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0); -} - -bool GetPadMoveDown() -{ - return - (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || - (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || - (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0); -} - -bool GetPadMoveLeft() -{ - return - (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || - (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || - (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0); -} - -bool GetPadMoveRight() -{ - return - (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || - (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || - (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0); -} - -bool GetMouseForward() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB); -} - -bool GetMouseBack() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB); -} - -bool GetMousePos() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->OldMouseControllerState.y != 0.0f); -} - -bool GetMouseMoveLeft() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f); -} - -bool GetMouseMoveRight() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f); -} - -bool GetPadInput() -{ - return - GetPadBack() || - GetPadForward() || - GetPadMoveUp() || - GetPadMoveDown() || - GetPadMoveLeft() || - GetPadMoveRight(); -} - -bool GetMouseInput() -{ - return - GetMouseForward() || - GetMouseBack() || - GetMousePos() || - GetMouseMoveLeft() || - GetMouseMoveRight(); } +#endif STARTPATCHES InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); - InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); - InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); - InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); - InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); - InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); diff --git a/src/Frontend.h b/src/Frontend.h index a833254a..dd6464b8 100644 --- a/src/Frontend.h +++ b/src/Frontend.h @@ -29,11 +29,7 @@ #define MENUSELECT_BOX_MAX 20.5f #define MENUSELECT_BOX_MIN 17.0f -#ifndef MID_RADIOICONS #define MENURADIO_ICON_X 31.5f -#else -#define MENURADIO_ICON_X -262.0f -#endif #define MENURADIO_ICON_Y 29.5f #define MENURADIO_ICON_W 60.0f #define MENURADIO_ICON_H 60.0f @@ -43,8 +39,6 @@ #define MENUSLIDER_X 306.0f -#define buf(a) (char*)(a) - enum eLanguages { LANGUAGE_AMERICAN, @@ -320,7 +314,6 @@ enum eMenuColumns enum eMenuRow { - MENUROW_NONE = -1, MENUROW_0, MENUROW_1, MENUROW_2, @@ -354,8 +347,7 @@ struct tSkinInfo struct CMenuScreen { char m_ScreenName[8]; - int32 unk; - int32 m_PreviousPage[2]; // eMenuScreen + int32 m_PreviousPage[3]; // eMenuScreen int32 m_ParentEntry[2]; // eMenuRow struct CMenuEntry @@ -425,7 +417,7 @@ public: int m_nHoverOption; int m_nCurrScreen; int m_nCurrOption; - int m_nPrevOption; + int m_nCurrentInput; int m_nPrevScreen; int field_558; int m_nCurrSaveSlot; @@ -451,8 +443,6 @@ public: static int8 &m_bFrontEnd_ReloadObrTxtGxt; static int32 &m_PrefsMusicVolume; static int32 &m_PrefsSfxVolume; - static uint8 *m_PrefsSkinFile; - static bool &m_bStartUpFrontEndRequested; static bool &m_bShutDownFrontEndRequested; static bool &m_PrefsAllowNastyGame; @@ -462,7 +452,6 @@ public: static void CentreMousePointer(); void CheckCodesForControls(int, int); bool CheckHover(int x1, int x2, int y1, int y2); - void CheckSliderMovement(int); int CostructStatLine(int); void DisplayHelperText(); float DisplaySlider(float, float, float, float, float, float); @@ -500,12 +489,6 @@ public: void SwitchMenuOnAndOff(); void UnloadTextures(); void WaitForUserCD(); - - // New content: - uint8 GetNumberOfMenuOptions(); - void SwitchToNewScreen(int8 screen); - void SetDefaultPreferences(int8 screen); - }; static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); diff --git a/src/MenuScreens.h b/src/MenuScreens.h index 362d4909..640952ed 100644 --- a/src/MenuScreens.h +++ b/src/MenuScreens.h @@ -12,7 +12,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_NEW_GAME = 2 { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_0, MENUROW_1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, - MENUACTION_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, + MENUACTION_UPDATESAVE, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -43,7 +43,7 @@ const CMenuScreen aScreens[] = { { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_2, MENUROW_2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - //MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, + MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -55,45 +55,45 @@ const CMenuScreen aScreens[] = { // MENUPAGE_LANGUAGE_SETTINGS = 7 { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_3, MENUROW_3, - MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_1, MENUROW_1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_2, MENUROW_2, - MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, + MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, }, // MENUPAGE_NEW_GAME_RELOAD = 10 { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_0, MENUROW_0, MENUACTION_LABEL, "FESZ_QR", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, }, // MENUPAGE_LOAD_SLOT_CONFIRM = 11 @@ -181,14 +181,14 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CHOOSE_SAVE_SLOT = 26 { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_UPDATESAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_UPDATESAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 @@ -236,7 +236,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_0, MENUROW_0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, + MENUACTION_REDEFCTRL, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, @@ -270,17 +270,17 @@ const CMenuScreen aScreens[] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_1, MENUROW_4, MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_CHANGEMENU, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, + MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_CHANGEMENU, "FET_LAN", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_CHANGEMENU, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, + MENUACTION_PLAYERSETUP, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_EXIT = 42 { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_2, MENUROW_5, MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_DONTCANCLE, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCLEGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -352,19 +352,19 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SKIN_SELECT = 54 { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_4, MENUROW_4, - //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, }, // MENUPAGE_KEYBOARD_CONTROLS = 55 { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_1, MENUROW_1, - //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_2, MENUROW_2, - MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, - MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, - MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, + MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, diff --git a/src/PCSave.cpp b/src/PCSave.cpp index 628e1218..ae5e43b0 100644 --- a/src/PCSave.cpp +++ b/src/PCSave.cpp @@ -4,17 +4,9 @@ #include "PCSave.h" WRAPPER void C_PcSave::SetSaveDirectory(const char *path) { EAXJMP(0x591EA0); } -WRAPPER int8 C_PcSave::PopulateSlotInfo() { EAXJMP(0x592090); } -WRAPPER int8 C_PcSave::DeleteSlot(int) { EAXJMP(0x5922F0); } -WRAPPER int8 C_PcSave::SaveSlot(int) { EAXJMP(0x591EC0); } - -WRAPPER int8 CheckSlotDataValid(int) { EAXJMP(0x591A40); } - WRAPPER wchar *GetNameOfSavedGame(int counter) { EAXJMP(0x591B60); } WRAPPER wchar *GetSavedGameDateAndTime(int counter) { EAXJMP(0x591B50); } - -C_PcSave PcSaveHelper = *(C_PcSave*)0x8E2C60; int *Slots = (int*)0x728040; int *SlotFileName = (int*)0x6F07C8; int *SlotSaveDate = (int*)0x72B858; diff --git a/src/PCSave.h b/src/PCSave.h index 696e158a..79202bc9 100644 --- a/src/PCSave.h +++ b/src/PCSave.h @@ -3,19 +3,12 @@ class C_PcSave { public: - int32 m_nHelper; - static void SetSaveDirectory(const char *path); - int8 PopulateSlotInfo(); - int8 DeleteSlot(int); - int8 SaveSlot(int); }; -extern int8 CheckSlotDataValid(int); extern wchar *GetNameOfSavedGame(int counter); extern wchar *GetSavedGameDateAndTime(int counter); -extern C_PcSave PcSaveHelper; extern int *Slots; extern int *SlotFileName; extern int *SlotSaveDate; diff --git a/src/Pad.cpp b/src/Pad.cpp index 66bc3bf9..002e7180 100644 --- a/src/Pad.cpp +++ b/src/Pad.cpp @@ -25,7 +25,6 @@ #include "Weather.h" #include "win.h" - CPad *Pads = (CPad*)0x6F0360; // [2] CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C; @@ -532,7 +531,7 @@ void CPad::AddToPCCheatString(char c) // "NASTYLIMBSCHEAT" if ( !_CHEATCMP("TAEHCSBMILYTSAN") ) NastyLimbsCheat(); - + #ifdef KANGAROO_CHEAT // "KANGAROO" if (!_CHEATCMP("OORAGNAK")) diff --git a/src/PlayerSkin.cpp b/src/PlayerSkin.cpp deleted file mode 100644 index 1c9ca2c6..00000000 --- a/src/PlayerSkin.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "PlayerSkin.h" - -WRAPPER void CPlayerSkin::BeginFrontEndSkinEdit() { EAXJMP(0x59BC70); } diff --git a/src/PlayerSkin.h b/src/PlayerSkin.h deleted file mode 100644 index 61e09cdf..00000000 --- a/src/PlayerSkin.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -class CPlayerSkin -{ -public: - static void BeginFrontEndSkinEdit(); -}; \ No newline at end of file diff --git a/src/Radar.h b/src/Radar.h index ac4e7392..e5396a50 100644 --- a/src/Radar.h +++ b/src/Radar.h @@ -63,17 +63,10 @@ struct CBlip static_assert(sizeof(CBlip) == 0x30, "CBlip: error"); // Values for screen space -#ifndef SA_STYLE_RADAR #define RADAR_LEFT (40.0f) #define RADAR_BOTTOM (47.0f) #define RADAR_WIDTH (94.0f) #define RADAR_HEIGHT (76.0f) -#else -#define RADAR_LEFT (34.0f) -#define RADAR_BOTTOM (25.0f) -#define RADAR_WIDTH (86.0f) -#define RADAR_HEIGHT (82.0f) -#endif class CRadar { diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 824d5c39..b3887c70 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -17,13 +17,8 @@ WRAPPER bool cDMAudio::CheckForAnAudioFileOnCD() { EAXJMP(0x57CA70); } WRAPPER void cDMAudio::ChangeMusicMode(uint8 mode) { EAXJMP(0x57CCF0); } WRAPPER void cDMAudio::PlayFrontEndSound(uint32, uint32) { EAXJMP(0x57CC20); } -WRAPPER void cDMAudio::PlayFrontEndTrack(uint32, uint32) { EAXJMP(0x57CC80); } -WRAPPER void cDMAudio::StopFrontEndTrack() { EAXJMP(0x57CCB0); } -WRAPPER void cDMAudio::PlayOneShot(int32, uint16, float) { EAXJMP(0x57C840); } -WRAPPER void cDMAudio::SetMusicMasterVolume(int8) { EAXJMP(0x57C8C0); } -WRAPPER void cDMAudio::SetEffectsMasterVolume(int8) { EAXJMP(0x57C890); } -WRAPPER int8 cDMAudio::SetCurrent3DProvider(int8) { EAXJMP(0x57C9B0); } -WRAPPER int32 cDMAudio::SetSpeakerConfig(int32) { EAXJMP(0x57C9D0); } +WRAPPER void cDMAudio::PlayOneShot(int, uint16, float) { EAXJMP(0x57C840); } + WRAPPER int32 cDMAudio::GetRadioInCar() { EAXJMP(0x57CE40); } WRAPPER uint8 cDMAudio::IsMP3RadioChannelAvailable() { EAXJMP(0x57C9F0); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 46914aaa..46b40e37 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -188,13 +188,7 @@ public: bool CheckForAnAudioFileOnCD(void); void ChangeMusicMode(uint8 mode); void PlayFrontEndSound(uint32, uint32); - void PlayFrontEndTrack(uint32, uint32); - void StopFrontEndTrack(); - void PlayOneShot(int32, uint16, float); - void SetMusicMasterVolume(int8); - void SetEffectsMasterVolume(int8); - int8 SetCurrent3DProvider(int8); - int32 SetSpeakerConfig(int32); + void PlayOneShot(int, uint16, float); int32 GetRadioInCar(void); void SetEffectsFadeVol(uint8); void SetMusicFadeVol(uint8); diff --git a/src/common.h b/src/common.h index a8a99ec9..f959de42 100644 --- a/src/common.h +++ b/src/common.h @@ -82,7 +82,6 @@ extern void **rwengine; #define SCREEN_STRETCH_FROM_BOTTOM(a) float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) #define SCREEN_MULTIPLIER (CDraw::GetScreenMult()) -#define SCREEN_COORD(a) (a * SCREEN_ASPECT_RATIO) #define SCREEN_SCALE(a) float((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) #define SCREEN_SCALE_X(a) SCREEN_SCALE(SCREEN_STRETCH_X(a) * SCREEN_MULTIPLIER) #define SCREEN_SCALE_Y(a) (SCREEN_STRETCH_Y(a) * SCREEN_MULTIPLIER) diff --git a/src/config.h b/src/config.h index 87cfd191..b43a3a9f 100644 --- a/src/config.h +++ b/src/config.h @@ -79,7 +79,3 @@ enum Config { #define NASTY_GAME #define PS2_MATFX #define KANGAROO_CHEAT -#define HOR_PLUS -#define MID_RADIOICONS -#define NO_ROCKET_BORDERS -#define SA_STYLE_RADAR diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp index f7c4b065..8c1ef515 100644 --- a/src/entities/Vehicle.cpp +++ b/src/entities/Vehicle.cpp @@ -12,8 +12,7 @@ bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75; bool &CVehicle::bCheat3 = *(bool *)0x95CD66; bool &CVehicle::bCheat4 = *(bool *)0x95CD65; bool &CVehicle::bCheat5 = *(bool *)0x95CD64; -bool &CVehicle::m_bDisableMouseSteering = *(bool *)0x60252C; - + void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index ba3e568e..27641e47 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -135,7 +135,6 @@ public: static bool &bCheat3; static bool &bCheat4; static bool &bCheat5; - static bool &m_bDisableMouseSteering; }; static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); diff --git a/src/main.cpp b/src/main.cpp index a00447ef..307d0b66 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -341,11 +341,7 @@ Render2dStuff(void) firstPersonWeapon = true; // Draw black border for sniper and rocket launcher -#ifndef NO_ROCKET_BORDERS if((weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_ROCKETLAUNCHER) && firstPersonWeapon){ -#else - if (weaponType == WEAPONTYPE_SNIPERRIFLE && firstPersonWeapon) { -#endif CRGBA black(0, 0, 0, 255); // top and bottom strips @@ -361,7 +357,6 @@ Render2dStuff(void) CSprite2d::DrawRect(CRect(SCREENW / 2 + SCREEN_SCALE_X(210), 0.0f, SCREENW, SCREENH), black); } - MusicManager.DisplayRadioStationName(); // TheConsole.Display(); /* @@ -787,7 +782,7 @@ AppEventHandler(RsEvent event, void *param) { CameraSize(Scene.camera, (RwRect *)param, - DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO); + DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO); return rsEVENTPROCESSED; } diff --git a/src/main.h b/src/main.h index 7d3fad9b..c7914549 100644 --- a/src/main.h +++ b/src/main.h @@ -19,4 +19,3 @@ void LoadingIslandScreen(const char *levelName); CSprite2d *LoadSplash(const char *name); char *GetLevelSplashScreen(int level); char *GetRandomSplashScreen(void); -extern bool &b_FoundRecentSavedGameWantToLoad; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index f1b2147f..90875299 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -16,70 +16,43 @@ uint8 &CDraw::FadeRed = *(uint8*)0x95CD90; uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71; uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53; -void CDraw::CalculateAspectRatio() +void +CDraw::CalculateAspectRatio() { SetScreenMult(DEFAULT_SCALE); -#ifndef HOR_PLUS - if (FrontEndMenuManager.m_PrefsUseWideScreen) - ms_fAspectRatio = 16.0f / 9.0f; + if(FrontEndMenuManager.m_PrefsUseWideScreen) + ms_fAspectRatio = 16.0f/9.0f; else - ms_fAspectRatio = 4.0f / 3.0f; -#else - switch (FrontEndMenuManager.m_PrefsUseWideScreen) { - case AR_AUTO: - ms_fAspectRatio = (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT; - return; - case AR_3_2: - ms_fAspectRatio = 3.0f / 2.0f; - return; - case AR_4_3: - ms_fAspectRatio = 4.0f / 3.0f; - return; - case AR_5_3: - ms_fAspectRatio = 5.0f / 3.0f; - return; - case AR_5_4: - ms_fAspectRatio = 5.0f / 4.0f; - return; - case AR_15_9: - ms_fAspectRatio = 15.0f / 9.0f; - return; - case AR_16_9: - ms_fAspectRatio = 16.0f / 9.0f; - return; - case AR_16_10: - ms_fAspectRatio = 16.0f / 10.0f; - return; - case AR_64_27: - ms_fAspectRatio = 64.0f / 27.0f; - return; - }; - -#endif + ms_fAspectRatio = 4.0f/3.0f; } -float -HorToVert(float hfov) +static float hFov2vFov(float hfov) { - float vfov = atan(tan(DEGTORAD(hfov) / 2) / (4.0 / 3.0)) * 2; - return RADTODEG(hfov = atan(tan(vfov / 2) * CDraw::GetAspectRatio()) * 2); + float w = SCREENW; + float h = SCREENH; + + // => tan(hFOV/2) = tan(vFOV/2)*aspectRatio + // => tan(vFOV/2) = tan(hFOV/2)/aspectRatio + float ar1 = 4.0/3.0; + float ar2 = w/h; + hfov = DEGTORAD(hfov); + float vfov = atan(tan(hfov/2) / ar1) *2; + hfov = atan(tan(vfov/2) * ar2) *2; + return RADTODEG(hfov); } void CDraw::SetFOV(float fov) { -#ifndef HOR_PLUS +// TODO: fix FOV here or somewhere else? +// ms_fFOV = hFov2vFov(fov); ms_fFOV = fov; -#else - ms_fFOV = HorToVert(fov); -#endif } STARTPATCHES InjectHook(0x4FE7B0, CDraw::SetFOV, PATCH_JUMP); - // Some patches to fix aiming offset on "CCamera::Find3rdPersonCamTargetVector". Nop(0x46B618, 2); Patch(0x5F0A64, 1.3333334f); ENDPATCHES diff --git a/src/render/Draw.h b/src/render/Draw.h index 9e334d02..1fcb5212 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -3,18 +3,6 @@ #define HUD_SCALE 0.8f #define DEFAULT_SCALE 1.0f -enum eAspectRatio { - AR_AUTO, - AR_3_2, - AR_4_3, - AR_5_3, - AR_5_4, - AR_15_9, - AR_16_9, - AR_16_10, - AR_64_27, -}; - class CDraw { private: diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 4b6094f1..2547ab2b 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -125,15 +125,6 @@ WRAPPER void CHud::Draw(void) { EAXJMP(0x5052A0); } #else void CHud::Draw() { - RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSMIRROR); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); - RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); - if (CReplay::IsPlayingBack()) return; @@ -177,7 +168,6 @@ void CHud::Draw() float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); CRect rect; -#ifndef HOR_PLUS float fWidescreenOffset[2] = { 0.0f, 0.0f }; if (FrontEndMenuManager.m_PrefsUseWideScreen) { @@ -188,11 +178,7 @@ void CHud::Draw() if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { float f3rdX = SCREENW * TheCamera.m_f3rdPersonCHairMultX + fWidescreenOffset[0]; float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY - fWidescreenOffset[1]; -#else - if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { - float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (4.0f / 3.0f))) + 0.5f) * SCREENW; - float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY; -#endif + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed && WeaponType == WEAPONTYPE_M16) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); @@ -1457,7 +1443,7 @@ STARTPATCHES InjectHook(0x5048F0, &CHud::Initialise, PATCH_JUMP); InjectHook(0x504CC0, &CHud::ReInitialise, PATCH_JUMP); InjectHook(0x50A250, &CHud::SetBigMessage, PATCH_JUMP); - //InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); + InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); InjectHook(0x50A210, &CHud::SetMessage, PATCH_JUMP); InjectHook(0x50A320, &CHud::SetPagerMessage, PATCH_JUMP); InjectHook(0x505290, &CHud::SetVehicleName, PATCH_JUMP); diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 1b91af24..9638e53a 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1355,14 +1355,10 @@ psSelectDevice() { while ( !modeFound && GcurSelVM < RwEngineGetNumVideoModes() ) { - RECT Rect; - GetWindowRect(GetDesktopWindow(), &Rect); - printf(gString, "Cannot find %dx%dx32 video mode", Rect.right, Rect.bottom); - RwEngineGetVideoModeInfo(&vm, GcurSelVM); - if ( defaultFullscreenRes && vm.width != Rect.right - || vm.height != Rect.bottom - || vm.depth != 32 + if ( defaultFullscreenRes && vm.width != 640 + || vm.height != 480 + || vm.depth != 16 || !(vm.flags & rwVIDEOMODEEXCLUSIVE) ) ++GcurSelVM; else @@ -1371,7 +1367,7 @@ psSelectDevice() if ( !modeFound ) { - MessageBox(nil, gString, "GTA3", MB_OK); + MessageBox(nil, "Cannot find 640x480 video mode", "GTA3", MB_OK); return FALSE; } } diff --git a/src/skel/win/win.h b/src/skel/win/win.h index 13564a7f..371b9e44 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -79,10 +79,6 @@ void CenterVideo(void); void CloseClip(void); RwChar **_psGetVideoModeList(); -RwInt32 _psGetNumVideModes(); - -void _psSelectScreenVM(RwInt32 videoMode); -void HandleExit(); #ifdef __cplusplus } -- cgit v1.2.3 From 25865e68c4c87cfe3cf63c8721f3d0ec8dfca35c Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 3 Jul 2019 13:13:55 +0200 Subject: cleaned up to be closer to original game --- src/Radar.cpp | 4 ++-- src/common.h | 40 +++++++++++++++++++------------ src/config.h | 52 ++++++++++++++++++++++++++++++++-------- src/main.cpp | 40 +++++++++++++++---------------- src/render/Draw.cpp | 34 +++++++++++++------------- src/render/Draw.h | 20 ++++++++++------ src/render/Hud.cpp | 4 ++-- src/render/Sprite.cpp | 66 +++++++++++++++++++++++++-------------------------- src/skel/win/win.cpp | 42 ++++++++++++-------------------- src/skel/win/win.h | 4 ++-- 10 files changed, 172 insertions(+), 134 deletions(-) diff --git a/src/Radar.cpp b/src/Radar.cpp index ec02144e..a071b96b 100644 --- a/src/Radar.cpp +++ b/src/Radar.cpp @@ -899,8 +899,8 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D // Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0) void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in) { - // FIX: game doesn't scale RADAR_LEFT here - out.x = (in.x + 1.0f)*0.5f*SCREEN_SCALE_X(RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT); + // FIX? scale RADAR_LEFT here somehow + out.x = (in.x + 1.0f)*0.5f*SCREEN_SCALE_X(RADAR_WIDTH) + RADAR_LEFT; out.y = (1.0f - in.y)*0.5f*SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT); } diff --git a/src/common.h b/src/common.h index f959de42..7f304e90 100644 --- a/src/common.h +++ b/src/common.h @@ -67,27 +67,37 @@ extern void **rwengine; In theory should look good on any screen. */ +#define DEFAULT_SCREEN_WIDTH (640) +#define DEFAULT_SCREEN_HEIGHT (448) +#define DEFAULT_ASPECT_RATIO (4.0f/3.0f) + +// game uses maximumWidth/Height, but this probably won't work +// with RW windowed mode +// TODO: get rid of one of the two +#define SCREENW (RsGlobal.width) +#define SCREENH (RsGlobal.height) +#define SCREEN_WIDTH ((float)RsGlobal.width) +#define SCREEN_HEIGHT ((float)RsGlobal.height) #define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio()) -#define SCREENW (RsGlobal.maximumWidth) -#define SCREENH (RsGlobal.maximumHeight) +// This scales from PS2 pixel coordinates to the real resolution +#define SCREEN_STRETCH_X(a) ((a) * (float) SCREEN_WIDTH / DEFAULT_SCREEN_WIDTH) +#define SCREEN_STRETCH_Y(a) ((a) * (float) SCREEN_HEIGHT / DEFAULT_SCREEN_HEIGHT) +#define SCREEN_STRETCH_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_STRETCH_X(a)) +#define SCREEN_STRETCH_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) -#define DEFAULT_SCREEN_WIDTH (640) -#define DEFAULT_SCREEN_HEIGHT (448) -#define SCREEN_WIDTH float(RsGlobal.width) -#define SCREEN_HEIGHT float(RsGlobal.height) -#define SCREEN_STRETCH_X(a) float((a) * (SCREEN_WIDTH / float(DEFAULT_SCREEN_WIDTH))) -#define SCREEN_STRETCH_Y(a) float((a) * (SCREEN_HEIGHT / float(DEFAULT_SCREEN_HEIGHT))) -#define SCREEN_STRETCH_FROM_RIGHT(a) float(SCREEN_WIDTH - SCREEN_STRETCH_X(a)) -#define SCREEN_STRETCH_FROM_BOTTOM(a) float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) - -#define SCREEN_MULTIPLIER (CDraw::GetScreenMult()) -#define SCREEN_SCALE(a) float((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) -#define SCREEN_SCALE_X(a) SCREEN_SCALE(SCREEN_STRETCH_X(a) * SCREEN_MULTIPLIER) -#define SCREEN_SCALE_Y(a) (SCREEN_STRETCH_Y(a) * SCREEN_MULTIPLIER) +// This scales from PS2 pixel coordinates while optionally maintaining the aspect ratio +#define SCREEN_SCALE_X(a) SCREEN_SCALE_AR(SCREEN_STRETCH_X(a)) +#define SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(a) #define SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_SCALE_X(a)) #define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a)) +#ifdef ASPECT_RATIO_SCALE +#define SCREEN_SCALE_AR(a) ((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) +#else +#define SCREEN_SCALE_AR(a) (a) +#endif + #include "math/Vector.h" #include "math/Vector2D.h" #include "math/Matrix.h" diff --git a/src/config.h b/src/config.h index b43a3a9f..a753b678 100644 --- a/src/config.h +++ b/src/config.h @@ -62,20 +62,52 @@ enum Config { NUMPICKUPS = 336, }; + // We don't expect to compile for PS2 or Xbox // but it might be interesting for documentation purposes #define GTA_PC //#define GTA_PS2 //#define GTA_XBOX -#define GTA3_1_1_PATCH -#define USE_PS2_RAND -#define RANDOMSPLASH -#define CHATTYSPLASH -//#define FIX_BUGS -//#define NO_CDCHECK -#define NO_MOVIES -//#define USE_MY_DOCUMENTS -#define NASTY_GAME -#define PS2_MATFX +// This enables things from the PS2 version on PC +#define GTA_PS2_STUFF + +// This is enabled for all released games. +// any debug stuff that isn't left in any game is not in FINAL +//#define FINAL + +// This is enabled for all released games except mobile +// any debug stuff that is only left in mobile, is not in MASTER +//#define MASTER + +#if defined GTA_PS2 +# define RANDOMSPLASH +#elif defined GTA_PC +# define GTA3_1_1_PATCH +# ifdef GTA_PS2_STUFF +# define USE_PS2_RAND +# define RANDOMSPLASH // use random splash as on PS2 +# define PS2_MATFX +# endif +#elif defined GTA_XBOX +#endif + +#ifdef MASTER + // only in master builds +#else + // not in master builds +#endif + +#ifdef FINAL + // in all games +# define USE_MY_DOCUMENTS // use my documents directory for user files +#else + // not in any game +# define NASTY_GAME // nasty game for all languages +# define NO_MOVIES // disable intro videos +# define CHATTYSPLASH // print what the game is loading +#endif + +#define FIX_BUGS // fix bugs in the game, TODO: use this more #define KANGAROO_CHEAT +#define ASPECT_RATIO_SCALE diff --git a/src/main.cpp b/src/main.cpp index 307d0b66..de3d8b62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,14 +48,8 @@ #include "RpAnimBlend.h" #include "Frontend.h" -#define DEFAULT_VIEWWINDOW (tan(CDraw::GetFOV() * (360.0f / PI))) +#define DEFAULT_VIEWWINDOW (tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) -#ifdef WIDE_SCREEN -#define DEFAULT_ASPECTRATIO (16.0f/9.0f) -#else -#define DEFAULT_ASPECTRATIO (4.0f/3.0f) -#endif - GlobalScene &Scene = *(GlobalScene*)0x726768; @@ -100,6 +94,10 @@ InitialiseGame(void) void Idle(void *arg) { +#ifdef ASPECT_RATIO_SCALE + CDraw::SetAspectRatio(CDraw::FindAspectRatio()); +#endif + CTimer::Update(); CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -160,9 +158,8 @@ Idle(void *arg) Render2dStuff(); }else{ - float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); - CDraw::CalculateAspectRatio(); - CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO); + float viewWindow = DEFAULT_VIEWWINDOW; + CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); if(!RsCameraBeginUpdate(Scene.camera)) @@ -170,7 +167,9 @@ Idle(void *arg) } RenderMenus(); +#ifndef FINAL PrintGameVersion(); +#endif DoFade(); Render2dStuffAfterFade(); CCredits::Render(); @@ -183,6 +182,10 @@ Idle(void *arg) void FrontendIdle(void) { +#ifdef ASPECT_RATIO_SCALE + CDraw::SetAspectRatio(CDraw::FindAspectRatio()); +#endif + CTimer::Update(); CSprite2d::SetRecipNearClip(); CSprite2d::InitPerFrame(); @@ -193,9 +196,8 @@ FrontendIdle(void) if(RsGlobal.quit) return; - float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); - CDraw::CalculateAspectRatio(); - CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO); + float viewWindow = DEFAULT_VIEWWINDOW; + CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); if(!RsCameraBeginUpdate(Scene.camera)) @@ -203,7 +205,9 @@ FrontendIdle(void) DefinedState(); RenderMenus(); +#ifndef FINAL PrintGameVersion(); +#endif DoFade(); Render2dStuffAfterFade(); CFont::DrawFonts(); @@ -216,9 +220,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha); CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha); - float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); - CDraw::CalculateAspectRatio(); - CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO); + CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); @@ -236,9 +238,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha) { - float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); - CDraw::CalculateAspectRatio(); - CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO); + CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); @@ -782,7 +782,7 @@ AppEventHandler(RsEvent event, void *param) { CameraSize(Scene.camera, (RwRect *)param, - DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO); + DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO); return rsEVENTPROCESSED; } diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 90875299..922d96d4 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -4,8 +4,9 @@ #include "Frontend.h" #include "Camera.h" -float CDraw::ms_fAspectRatio; -float CDraw::ms_fScreenMultiplier; +#ifdef ASPECT_RATIO_SCALE +float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO; +#endif float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4; float &CDraw::ms_fFarClipZ = *(float*)0x9434F0; @@ -16,26 +17,25 @@ uint8 &CDraw::FadeRed = *(uint8*)0x95CD90; uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71; uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53; -void -CDraw::CalculateAspectRatio() +float +CDraw::FindAspectRatio(void) { - SetScreenMult(DEFAULT_SCALE); - if(FrontEndMenuManager.m_PrefsUseWideScreen) - ms_fAspectRatio = 16.0f/9.0f; + return 16.0f/9.0f; else - ms_fAspectRatio = 4.0f/3.0f; + return 4.0f/3.0f; } -static float hFov2vFov(float hfov) +// convert a 4:3 hFOV to vFOV, +// then convert that vFOV to hFOV for our aspect ratio, +// i.e. HOR+ +float +CDraw::ConvertFOV(float hfov) { - float w = SCREENW; - float h = SCREENH; - // => tan(hFOV/2) = tan(vFOV/2)*aspectRatio // => tan(vFOV/2) = tan(hFOV/2)/aspectRatio - float ar1 = 4.0/3.0; - float ar2 = w/h; + float ar1 = DEFAULT_ASPECT_RATIO; + float ar2 = GetAspectRatio(); hfov = DEGTORAD(hfov); float vfov = atan(tan(hfov/2) / ar1) *2; hfov = atan(tan(vfov/2) * ar2) *2; @@ -45,9 +45,11 @@ static float hFov2vFov(float hfov) void CDraw::SetFOV(float fov) { -// TODO: fix FOV here or somewhere else? -// ms_fFOV = hFov2vFov(fov); +#ifdef ASPECT_RATIO_SCALE + ms_fFOV = ConvertFOV(fov); +#else ms_fFOV = fov; +#endif } STARTPATCHES diff --git a/src/render/Draw.h b/src/render/Draw.h index 1fcb5212..3349c6c9 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -1,16 +1,18 @@ #pragma once -#define HUD_SCALE 0.8f -#define DEFAULT_SCALE 1.0f - class CDraw { private: static float &ms_fNearClipZ; static float &ms_fFarClipZ; static float &ms_fFOV; + static float ms_fLODDistance; // unused + +#ifdef ASPECT_RATIO_SCALE + // we use this variable to scale a lot of 2D elements + // so better cache it static float ms_fAspectRatio; - static float ms_fScreenMultiplier; +#endif public: static uint8 &FadeValue; @@ -26,8 +28,12 @@ public: static void SetFOV(float fov); static float GetFOV(void) { return ms_fFOV; } - static void CalculateAspectRatio(); + static float FindAspectRatio(void); +#ifdef ASPECT_RATIO_SCALE + static float ConvertFOV(float fov); static float GetAspectRatio(void) { return ms_fAspectRatio; } - static void SetScreenMult(float mult) { ms_fScreenMultiplier = mult; }; - static float GetScreenMult(void) { return ms_fScreenMultiplier; }; + static void SetAspectRatio(float ratio) { ms_fAspectRatio = ratio; } +#else + static float GetAspectRatio(void) { return FindAspectRatio(); } +#endif }; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 2547ab2b..e5a44221 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -787,8 +787,8 @@ void CHud::Draw() if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) { CRadar::DrawMap(); CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT)); - // FIX: game doesn't scale RADAR_LEFT here - rect.Translate(SCREEN_SCALE_X(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); + // FIX? scale RADAR_LEFT here somehow + rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); rect.Grow(4.0f); Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255)); CRadar::DrawBlips(); diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 57a8a22f..d917117a 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -16,7 +16,7 @@ CSprite::CalcHorizonCoors(void) CVector p = TheCamera.GetPosition() + CVector(TheCamera.CamFrontXNorm, TheCamera.CamFrontYNorm, 0.0f)*3000.0f; p.z = 0.0f; p = TheCamera.m_viewMatrix * p; - return p.y * RsGlobal.maximumHeight / p.z; + return p.y * SCREEN_HEIGHT / p.z; } bool @@ -27,13 +27,13 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh, if(out->z <= CDraw::GetNearClipZ() + 1.0f) return false; if(out->z >= CDraw::GetFarClipZ() && farclip) return false; float recip = 1.0f/out->z; - out->x *= RsGlobal.maximumWidth * recip; - out->y *= RsGlobal.maximumHeight * recip; + out->x *= SCREEN_WIDTH * recip; + out->y *= SCREEN_HEIGHT * recip; // What is this? size? *outw = 70.0f/CDraw::GetFOV(); *outh = 70.0f/CDraw::GetFOV(); - *outw *= RsGlobal.maximumWidth * recip; - *outh *= RsGlobal.maximumHeight * recip; + *outw *= SCREEN_WIDTH * recip; + *outh *= SCREEN_HEIGHT * recip; return true; } @@ -99,17 +99,17 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r us[i] = -xs[i] / (2.0f*w); xs[i] = 0.0f; } - if(xs[i] > RsGlobal.maximumWidth){ - us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w); - xs[i] = RsGlobal.maximumWidth; + if(xs[i] > SCREEN_WIDTH){ + us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w); + xs[i] = SCREEN_WIDTH; } if(ys[i] < 0.0f){ vs[i] = -ys[i] / (2.0f*h); ys[i] = 0.0f; } - if(ys[i] > RsGlobal.maximumHeight){ - vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h); - ys[i] = RsGlobal.maximumHeight; + if(ys[i] > SCREEN_HEIGHT){ + vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h); + ys[i] = SCREEN_HEIGHT; } } @@ -169,10 +169,10 @@ CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, fl // No clipping, just culling if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return; - if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth && - xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; - if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && - ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; + if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH && + xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return; + if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT && + ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return; float screenz = m_f2DNearScreenZ + (z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / @@ -221,17 +221,17 @@ CSprite::RenderBufferedOneXLUSprite(float x, float y, float z, float w, float h, us[i] = -xs[i] / (2.0f*w); xs[i] = 0.0f; } - if(xs[i] > RsGlobal.maximumWidth){ - us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w); - xs[i] = RsGlobal.maximumWidth; + if(xs[i] > SCREEN_WIDTH){ + us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w); + xs[i] = SCREEN_WIDTH; } if(ys[i] < 0.0f){ vs[i] = -ys[i] / (2.0f*h); ys[i] = 0.0f; } - if(ys[i] > RsGlobal.maximumHeight){ - vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h); - ys[i] = RsGlobal.maximumHeight; + if(ys[i] > SCREEN_HEIGHT){ + vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h); + ys[i] = SCREEN_HEIGHT; } } @@ -283,10 +283,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z, // No clipping, just culling if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return; - if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth && - xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; - if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && - ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; + if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH && + xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return; + if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT && + ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return; float screenz = m_f2DNearScreenZ + (z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / @@ -335,10 +335,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, flo // No clipping, just culling if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return; - if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth && - xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; - if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && - ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; + if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH && + xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return; + if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT && + ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return; float screenz = m_f2DNearScreenZ + (z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / @@ -388,10 +388,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f // No clipping, just culling if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return; - if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth && - xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; - if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && - ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; + if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH && + xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return; + if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT && + ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return; // Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2 cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 9638e53a..0481e104 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -626,9 +626,7 @@ psInitialise(void) C_PcSave::SetSaveDirectory(_psGetUserFilesFolder()); -#ifndef NASTY_GAME - InitialiseLanguage(); -#endif + InitialiseLanguage(); FrontEndMenuManager.LoadSettings(); @@ -1262,7 +1260,7 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) ASSERT(d3d != nil); - INT refreshRate = -1; + UINT refreshRate = INT_MAX; D3DFORMAT format; if ( depth == 32 ) @@ -1284,12 +1282,9 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) { if ( mode.RefreshRate == 0 ) return 0; -#pragma warning( push ) -#pragma warning( disable : 4018) if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 ) refreshRate = mode.RefreshRate; -#pragma warning( pop ) } } @@ -1540,8 +1535,6 @@ CommandLineToArgv(RwChar *cmdLine, RwInt32 *argCount) */ void InitialiseLanguage() { -#pragma warning( push ) -#pragma warning( disable : 4302) WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID()); WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID()); WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0)); @@ -1549,7 +1542,6 @@ void InitialiseLanguage() WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID()); WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID()); WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0)); -#pragma warning( pop ) if ( primUserLCID == LANG_GERMAN || primSystemLCID == LANG_GERMAN @@ -1573,6 +1565,12 @@ void InitialiseLanguage() || subSystemLCID == SUBLANG_ENGLISH_AUS || subLayout == SUBLANG_ENGLISH_AUS ) CGame::noProstitutes = true; + +#ifdef NASTY_GAME + CGame::nastyGame = true; + CMenuManager::m_PrefsAllowNastyGame = true; + CGame::noProstitutes = false; +#endif int32 lang; @@ -2420,14 +2418,10 @@ void _InputInitialiseJoys() } } -#pragma warning( push ) -#pragma warning( disable : 4700) -HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) +void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) { - HRESULT hr; - DIDEVICEOBJECTINSTANCE objInst; - + objInst.dwSize = sizeof( DIDEVICEOBJECTINSTANCE ); DIPROPRANGE range; @@ -2445,7 +2439,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_X, DIPH_BYOFFSET ) ) ) { if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) - return S_FALSE; + return; else ; } @@ -2457,7 +2451,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Y, DIPH_BYOFFSET ) ) ) { if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) - return S_FALSE; + return; else ; } @@ -2469,7 +2463,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Z, DIPH_BYOFFSET ) ) ) { if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) - return S_FALSE; + return; else AllValidWinJoys.m_aJoys[num].m_bHasAxisZ = true; // z rightStickPos.x } @@ -2481,15 +2475,12 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_RZ, DIPH_BYOFFSET ) ) ) { if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) - return S_FALSE; + return; else AllValidWinJoys.m_aJoys[num].m_bHasAxisR = true; // r rightStickPos.y } } - - return hr; } -#pragma warning( pop ) HRESULT _InputAddJoys() { @@ -2973,9 +2964,7 @@ void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) } } -#pragma warning( push ) -#pragma warning( disable : 4805) -BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown) +BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown) { *rs = rsNULL; switch ( key ) @@ -3002,7 +2991,6 @@ BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown) return TRUE; } -#pragma warning( pop ) BOOL _InputIsExtended(INT flag) { diff --git a/src/skel/win/win.h b/src/skel/win/win.h index 371b9e44..a1f37bfd 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -63,14 +63,14 @@ HRESULT _InputInitialise(); HRESULT _InputInitialiseMouse(); HRESULT CapturePad(RwInt32 padID); void _InputInitialiseJoys(); -HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num); +void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num); HRESULT _InputAddJoys(); HRESULT _InputGetMouseState(DIMOUSESTATE2 *state); void _InputShutdown(); BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ); BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key); void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);; -BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown); +BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown); BOOL _InputIsExtended(INT flag); void InitialiseLanguage(); -- cgit v1.2.3 From ecf29b7769711fb4aebbe7ed6a441cd2bc7b881d Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 3 Jul 2019 13:36:25 +0200 Subject: fixed car colour texture bug --- src/modelinfo/VehicleModelInfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 78eee96c..0d206db0 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -875,6 +875,7 @@ CreateCarColourTexture(uint8 r, uint8 g, uint8 b) pixels[14] = b; pixels[15] = 0xFF; RwImageSetPixels(img, pixels); + RwImageSetStride(img, 8); RwImageSetPalette(img, nil); RwImageFindRasterFormat(img, rwRASTERTYPETEXTURE, &width, &height, &depth, &format); ras = RwRasterCreate(width, height, depth, format); -- cgit v1.2.3 From 936a8e83517fb05c34bca673140172dfa624d7b1 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 3 Jul 2019 14:06:26 +0200 Subject: fixed boat rendering --- src/render/Renderer.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index d8b0bbe6..405b9bb2 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -222,16 +222,16 @@ CRenderer::RenderEverythingBarRoads(void) if(e->IsVehicle() || e->IsPed() && CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255){ if(e->IsVehicle() && ((CVehicle*)e)->IsBoat()){ + ei.ent = e; + dist = ms_vecCameraPosition - e->GetPosition(); + ei.sort = dist.MagnitudeSqr(); + gSortedVehiclesAndPeds.InsertSorted(ei); + }else{ dist = ms_vecCameraPosition - e->GetPosition(); if(!CVisibilityPlugins::InsertEntityIntoSortedList(e, dist.Magnitude())){ printf("Ran out of space in alpha entity list"); RenderOneNonRoad(e); } - }else{ - ei.ent = e; - dist = ms_vecCameraPosition - e->GetPosition(); - ei.sort = dist.MagnitudeSqr(); - gSortedVehiclesAndPeds.InsertSorted(ei); } }else RenderOneNonRoad(e); @@ -241,15 +241,17 @@ CRenderer::RenderEverythingBarRoads(void) void CRenderer::RenderVehiclesButNotBoats(void) { + // This function doesn't do anything + // because only boats are inserted into the list CLink *node; for(node = gSortedVehiclesAndPeds.tail.prev; node != &gSortedVehiclesAndPeds.head; node = node->prev){ + // only boats in this list CVehicle *v = (CVehicle*)node->item.ent; - if(v->IsVehicle() && v->IsBoat()) // BUG: IsVehicle missing in III - continue; - RenderOneNonRoad(v); + if(!v->IsBoat()) + RenderOneNonRoad(v); } } @@ -261,8 +263,9 @@ CRenderer::RenderBoats(void) for(node = gSortedVehiclesAndPeds.tail.prev; node != &gSortedVehiclesAndPeds.head; node = node->prev){ + // only boats in this list CVehicle *v = (CVehicle*)node->item.ent; - if(v->IsVehicle() && v->IsBoat()) // BUG: IsVehicle missing in III + if(v->IsBoat()) RenderOneNonRoad(v); } } -- cgit v1.2.3 From 69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37 Mon Sep 17 00:00:00 2001 From: _AG Date: Wed, 3 Jul 2019 17:26:15 +0200 Subject: Update Frontend. --- src/ControllerConfig.cpp | 5 + src/ControllerConfig.h | 1 + src/Frontend.cpp | 1300 ++++++++++++++++++++++++++++++++++++++++--- src/Frontend.h | 24 +- src/MenuScreens.h | 84 +-- src/PCSave.cpp | 8 + src/PCSave.h | 7 + src/audio/DMAudio.cpp | 9 +- src/audio/DMAudio.h | 8 +- src/common.h | 14 - src/entities/PlayerSkin.cpp | 5 + src/entities/PlayerSkin.h | 7 + src/entities/Vehicle.cpp | 3 +- src/entities/Vehicle.h | 1 + src/main.cpp | 42 +- src/main.h | 1 + src/render/Clouds.cpp | 46 +- src/render/Credits.cpp | 8 +- src/render/Draw.cpp | 13 + src/render/Draw.h | 7 + src/render/Font.cpp | 6 +- src/render/Hud.cpp | 34 +- src/render/MBlur.h | 1 + src/skel/win/win.h | 4 + 24 files changed, 1444 insertions(+), 194 deletions(-) create mode 100644 src/entities/PlayerSkin.cpp create mode 100644 src/entities/PlayerSkin.h diff --git a/src/ControllerConfig.cpp b/src/ControllerConfig.cpp index a401e093..d7567ac4 100644 --- a/src/ControllerConfig.cpp +++ b/src/ControllerConfig.cpp @@ -50,3 +50,8 @@ void CControllerConfigManager::LoadSettings(int32 file) } } } + +WRAPPER void CControllerConfigManager::SaveSettings(int32 file) +{ + EAXJMP(0x58B800); +} diff --git a/src/ControllerConfig.h b/src/ControllerConfig.h index 00cab82e..581efe05 100644 --- a/src/ControllerConfig.h +++ b/src/ControllerConfig.h @@ -42,6 +42,7 @@ public: int32 GetJoyButtonJustDown(); void LoadSettings(int32 file); + void SaveSettings(int32 file); void MakeControllerActionsBlank(); void InitDefaultControlConfiguration(); void InitDefaultControlConfigMouse(CMouseControllerState const &mousestate); diff --git a/src/Frontend.cpp b/src/Frontend.cpp index 8eff0324..fdb2420b 100644 --- a/src/Frontend.cpp +++ b/src/Frontend.cpp @@ -20,6 +20,10 @@ #include "Script.h" #include "Camera.h" #include "MenuScreens.h" +#include "ControllerConfig.h" +#include "Vehicle.h" +#include "MBlur.h" +#include "PlayerSkin.h" int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; @@ -27,7 +31,6 @@ int8 &CMenuManager::m_DisplayControllerOnFoot = *(int8*)0x95CD8D; int8 &CMenuManager::m_PrefsVsync = *(int8*)0x5F2E58; int8 &CMenuManager::m_PrefsVsyncDisp = *(int8*)0x5F2E5C; int8 &CMenuManager::m_PrefsFrameLimiter = *(int8*)0x5F2E60; -int8 &CMenuManager::BlurOn = *(int8*)0x95CDAD; int8 &CMenuManager::m_PrefsShowSubtitles = *(int8*)0x5F2E54; int8 &CMenuManager::m_PrefsSpeakers = *(int8*)0x95CD7E; int8 &CMenuManager::m_ControlMethod = *(int8*)0x8F5F7C; @@ -47,8 +50,37 @@ int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; +uint8 *CMenuManager::m_PrefsSkinFile = (uint8*)0x5F2E74; + CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; +// Move this somewhere else. +float lodMultiplier = *(float*)0x5F726C; + +// Stuff not in CMenuManager: +int VibrationTime; +char* pEditString; +int32 pControlEdit; +int8 DisplayComboButtonErrMsg; +bool MouseButtonJustClicked; +bool JoyButtonJustClicked; + +// Frontend inputs. +bool GetPadBack(); +bool GetPadExitEnter(); +bool GetPadForward(); +bool GetPadMoveUp(); +bool GetPadMoveDown(); +bool GetPadMoveLeft(); +bool GetPadMoveRight(); +bool GetMouseForward(); +bool GetMouseBack(); +bool GetMousePos(); +bool GetMouseMoveLeft(); +bool GetMouseMoveRight(); +bool GetPadInput(); +bool GetMouseInput(); + char *FrontendFilenames[] = { "fe2_mainpanel_ul", "fe2_mainpanel_ur", @@ -119,7 +151,7 @@ void CMenuManager::CentreMousePointer() { tagPOINT Point; - if (SCREENW * 0.5f == 0.0f && 0.0f == SCREENH * 0.5f) { + if (SCREEN_WIDTH * 0.5f == 0.0f && 0.0f == SCREEN_HEIGHT * 0.5f) { Point.x = SCREEN_WIDTH / 2; Point.y = SCREEN_HEIGHT / 2; ClientToScreen(PSGLOBAL(window), &Point); @@ -150,6 +182,78 @@ bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) } #endif +void CMenuManager::CheckSliderMovement(int value) +{ + float fBrightness = 0.0f; + float fDrawDistance = 0.0f; + float fRadioVolume = 0.0f; + float fSfxVolume = 0.0f; + float fMouseSens = 0.0f; + + switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { + case MENUACTION_BRIGHTNESS: + fBrightness = m_PrefsBrightness + (value * (512.0f) / 16.0f); + + if (fBrightness > 511.0f) + fBrightness = 511.0f; + else if (fBrightness < 0.0f) + fBrightness = 0.0f; + + m_PrefsBrightness = fBrightness; + SaveSettings(); + break; + case MENUACTION_DRAWDIST: + fDrawDistance = m_PrefsLOD + (value * (1.8f - 0.8f) / 16.0f); + + if (fDrawDistance > 1.8f) + fDrawDistance = 1.8f; + else if (fDrawDistance < 0.8f) + fDrawDistance = 0.8f; + + m_PrefsLOD = fDrawDistance; + SaveSettings(); + break; + case MENUACTION_MUSICVOLUME: + fRadioVolume = m_PrefsMusicVolume + (value * (128.0f) / 16.0f); + + if (fRadioVolume > 127.0f) + fRadioVolume = 127.0f; + else if (fRadioVolume < 0.0f) + fRadioVolume = 0.0f; + + m_PrefsMusicVolume = fRadioVolume; + DMAudio.SetMusicMasterVolume(fRadioVolume); + SaveSettings(); + break; + case MENUACTION_SFXVOLUME: + fSfxVolume = m_PrefsSfxVolume + (value * (128.0f) / 16.0f); + + if (fSfxVolume > 127) + fSfxVolume = 127; + else if (fSfxVolume < 0.0f) + fSfxVolume = 0.0f; + + m_PrefsSfxVolume = fSfxVolume; + DMAudio.SetEffectsMasterVolume(fSfxVolume); + SaveSettings(); + break; + case MENUACTION_MOUSESENS: + fMouseSens = TheCamera.m_fMouseAccelHorzntl + (value * (0.005f - 0.0003125f) / 16.0f); + + if (fMouseSens > 0.005f) + fMouseSens = 0.005f; + else if (fMouseSens < 0.0003125f) + fMouseSens = 0.0003125f; + + TheCamera.m_fMouseAccelHorzntl = fMouseSens; + + // BUG: game doesn't set Y Axis. + TheCamera.m_fMouseAccelVertical = fMouseSens; + SaveSettings(); + break; + }; +} + #if 1 WRAPPER int CMenuManager::CostructStatLine(int) { EAXJMP(0x482800); } #else @@ -164,22 +268,38 @@ WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } #else void CMenuManager::DisplayHelperText() { - wchar *str = nil; + static int32 AlphaText = 255; + static int32 Time = 0; + + if (m_nHelperTextMsgId && m_nHelperTextMsgId != 1) { + if (CTimer::GetTimeInMillisecondsPauseMode() - Time > 10) { + Time = CTimer::GetTimeInMillisecondsPauseMode(); + m_nHelperTextAlpha -= 2; + + if (AlphaText < 1) + ResetHelperText(); + + AlphaText = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha; + } + } + + wchar *HelperTextToPrint = nil; + // TODO: name this cases? switch (m_nHelperTextMsgId) { case 0: - str = TheText.Get("FET_MIG"); + HelperTextToPrint = TheText.Get("FET_MIG"); break; case 1: - str = TheText.Get("FET_APP"); + HelperTextToPrint = TheText.Get("FET_APP"); break; case 2: - str = TheText.Get("FET_HRD"); + HelperTextToPrint = TheText.Get("FET_HRD"); break; case 3: - str = TheText.Get("FET_RSO"); + HelperTextToPrint = TheText.Get("FET_RSO"); break; case 4: - str = TheText.Get("FET_RSC"); + HelperTextToPrint = TheText.Get("FET_RSC"); break; default: break; @@ -188,11 +308,11 @@ void CMenuManager::DisplayHelperText() CFont::SetAlignment(ALIGN_CENTER); CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetFontStyle(FONT_HEADING); - CFont::SetDropColor(CRGBA(0, 0, 0, MENUDROP_COLOR_A)); + CFont::SetDropColor(CRGBA(0, 0, 0, AlphaText)); CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); + CFont::SetColor(CRGBA(255, 255, 255, AlphaText)); - CFont::SetColor(CRGBA(255, 255, 255, 255)); - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), str); + CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), HelperTextToPrint); } #endif @@ -227,12 +347,22 @@ float CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightS } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } #else -WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() +void CMenuManager::DoSettingsBeforeStartingAGame() { + CCamera::m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; + m_bStartGameLoading = true; + + ShutdownJustMenu(); + UnloadTextures(); + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); } #endif @@ -311,6 +441,7 @@ void CMenuManager::Draw() for (int i = 0; i < MENUROWS; ++i) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0]) { wchar *textToPrint[MENUCOLUMNS] = { nil, nil }; + bool Locked = false; if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1); @@ -323,6 +454,13 @@ void CMenuManager::Draw() } else { textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); + + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_SCREENRES) { + if (m_bGameNotLoaded) + Locked = false; + else + Locked = true; + } } switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { @@ -353,13 +491,27 @@ void CMenuManager::Draw() textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsFrameLimiter ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_TRAILS: - textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(BlurOn ? "FEM_ON" : "FEM_OFF"); + textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CMBlur::BlurOn ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_SUBTITLES: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsShowSubtitles ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_WIDESCREEN: +#ifndef ASPECT_RATIO_SCALE textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsUseWideScreen ? "FEM_ON" : "FEM_OFF"); +#else + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"AUTO"; + break; + case AR_4_3: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"4:3"; + break; + case AR_16_9: + textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; + break; + }; +#endif break; case MENUACTION_RADIO: sprintf(gString, "FEA_FM%d", m_PrefsRadioStation); @@ -386,16 +538,16 @@ void CMenuManager::Draw() } break; case MENUACTION_AUDIOHW: - if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) + if (m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { - char *provider = MusicManager.Get3DProviderName(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); + char *provider = MusicManager.Get3DProviderName(m_nPrefsAudio3DProviderIndex); AsciiToUnicode(provider, gUString); textToPrint[MENUCOLUMN_RIGHT] = gUString; } break; case MENUACTION_SPEAKERCONF: - if (FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -1) + if (m_nPrefsAudio3DProviderIndex == -1) textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); else { switch (m_PrefsSpeakers) { @@ -426,7 +578,7 @@ void CMenuManager::Draw() break; case MENUACTION_MOUSESTEER: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_ON" : "FEM_OFF"); - break; + break; }; CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); @@ -496,6 +648,7 @@ void CMenuManager::Draw() case MENUPAGE_LANGUAGE_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MIN_Y); break; + case MENUPAGE_MOUSE_CONTROLS: case MENUPAGE_GRAPHICS_SETTINGS: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MAX_Y); break; @@ -525,7 +678,7 @@ void CMenuManager::Draw() CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); CSprite2d::DrawRect(CRect(SCREEN_STRETCH_X(11.0f), vecPositions.y - SCREEN_STRETCH_Y(fBarSize * 0.13f), SCREEN_STRETCH_FROM_RIGHT(11.0f), vecPositions.y + SCREEN_STRETCH_Y(fBarSize)), CRGBA(100, 200, 50, 50)); } - else + else CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); // Draw @@ -533,32 +686,43 @@ void CMenuManager::Draw() CFont::PrintString(vecPositions.x, vecPositions.y, textToPrint[MENUCOLUMN_LEFT]); if (textToPrint[MENUCOLUMN_RIGHT]) { + if (Locked) + CFont::SetColor(CRGBA(190, 130, 40, FadeIn(255))); + CFont::SetAlignment(ALIGN_RIGHT); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SavePageSlot ? MENUCOLUMN_SAVE_X : MENUCOLUMN_POS_X), vecPositions.y, textToPrint[MENUCOLUMN_RIGHT]); } - // Mouse support. - bool bIsMouseInPosition = false; - if (m_nMenuFadeAlpha >= 255) { - CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; - if (m_bShowMouse && - ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) - bIsMouseInPosition = true; - else - bIsMouseInPosition = false; + // Mouse support. + // TODO: inputs for these pages. + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + } + else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - if (bIsMouseInPosition) { - if (m_nCurrOption != i) { - m_nCurrOption = i; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } + } + else { + static bool bIsMouseInPosition = false; + if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) { + CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; + if (m_bShowMouse && + ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) + bIsMouseInPosition = true; + else + bIsMouseInPosition = false; - m_nCurrentInput = m_nCurrOption; + if (bIsMouseInPosition) { + if (m_nCurrOption != i) { + m_nCurrOption = i; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } - if (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB) - m_nHoverOption = IGNORE_OPTION; - else - m_nHoverOption = ACTIVATE_OPTION; + m_nPrevOption = m_nCurrOption; + + if (GetMouseForward()) + m_nHoverOption = IGNORE_OPTION; + else + m_nHoverOption = ACTIVATE_OPTION; + } } } @@ -586,14 +750,21 @@ void CMenuManager::Draw() float fIconSpacing = 59.52f; if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { for (int i = 0; i < POLICE_RADIO; i++) { - - if (i == MSX_FM) - fIconSpacing -= 1.5f; - +#ifndef ASPECT_RATIO_SCALE if (i < USERTRACK) m_aFrontEndSprites[i + FE_RADIO1].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, DMAudio.IsMP3RadioChannelAvailable() ? 170 : 25)); + if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) + m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); +#else + float fMp3Pos = 0.0f; + if (DMAudio.IsMP3RadioChannelAvailable()) + fMp3Pos = 34.0f; + + if (i < USERTRACK) + m_aFrontEndSprites[i + FE_RADIO1].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); + if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) + m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); +#endif } } @@ -736,9 +907,9 @@ void CMenuManager::DrawFrontEndNormal() }; if (m_nPrevScreen == MENUPAGE_NONE) - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(0, 0, 0, 255)); + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255)); else - m_aMenuSprites[previousSprite].Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(255, 255, 255, 255)); + m_aMenuSprites[previousSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); } eMenuSprites currentSprite = MENUSPRITE_MAINMENU; @@ -787,7 +958,7 @@ void CMenuManager::DrawFrontEndNormal() RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &savedAlpha); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast(TRUE)); if (m_nMenuFadeAlpha >= 255) { - m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(255, 255, 255, 255)); + m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); } else { if (m_nMenuFadeAlpha < 255) { @@ -796,10 +967,10 @@ void CMenuManager::DrawFrontEndNormal() if (m_nMenuFadeAlpha >= 255) m_nMenuFadeAlpha = 255; - m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); + m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); } else - m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(255, 255, 255, 255)); + m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); } // GTA LOGO @@ -876,12 +1047,30 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); } #else void CMenuManager::InitialiseChangedLanguageSettings() { - + if (m_bFrontEnd_ReloadObrTxtGxt) { + m_bFrontEnd_ReloadObrTxtGxt = false; + CTimer::Stop(); + TheText.Unload(); + TheText.Load(); + CTimer::Update(); + CGame::frenchGame = false; + CGame::germanGame = false; + switch (CMenuManager::m_PrefsLanguage) { + case LANGUAGE_FRENCH: + CGame::frenchGame = true; + break; + case LANGUAGE_GERMAN: + CGame::germanGame = true; + break; + default: + break; + }; + } } #endif @@ -943,12 +1132,97 @@ void CMenuManager::LoadAllTextures() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } #else void CMenuManager::LoadSettings() { + CFileMgr::SetDirMyDocuments(); + + uint8 prevLang = m_PrefsLanguage; + MousePointerStateHelper.bInvertVertically = true; + + static char Ver; + int fileHandle = CFileMgr::OpenFile("gta3.set", "r"); + if (fileHandle) { + CFileMgr::Read(fileHandle, buf(&Ver), sizeof(Ver)); + + if (strncmp(&Ver, "THIS FILE IS NOT VALID YET", 26)) { + CFileMgr::Seek(fileHandle, 0, 0); + ControlsManager.LoadSettings(fileHandle); + CFileMgr::Read(fileHandle, buf(&gString), 20); + CFileMgr::Read(fileHandle, buf(&gString), 20); + CFileMgr::Read(fileHandle, buf(&gString), 4); + CFileMgr::Read(fileHandle, buf(&gString), 4); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_bHeadBob), 1); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), 4); + CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), 4); + CFileMgr::Read(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), 1); + CFileMgr::Read(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsSfxVolume), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsMusicVolume), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsRadioStation), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsSpeakers), 1); + CFileMgr::Read(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsDMA), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsBrightness), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsLOD), 4); + CFileMgr::Read(fileHandle, buf(&m_PrefsShowSubtitles), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsUseWideScreen), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsVsyncDisp), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsFrameLimiter), 1); + CFileMgr::Read(fileHandle, buf(&m_nDisplayVideoMode), 1); + CFileMgr::Read(fileHandle, buf(&CMBlur::BlurOn), 1); + CFileMgr::Read(fileHandle, buf(m_PrefsSkinFile), 256); + CFileMgr::Read(fileHandle, buf(&m_ControlMethod), 1); + CFileMgr::Read(fileHandle, buf(&m_PrefsLanguage), 1); + } + } + + CFileMgr::CloseFile(fileHandle); + CFileMgr::SetDir(""); + + m_PrefsVsync = m_PrefsVsyncDisp; + lodMultiplier = m_PrefsLOD; + + if (m_nPrefsAudio3DProviderIndex == -1) + m_nPrefsAudio3DProviderIndex = -2; + + if (m_PrefsLanguage == prevLang) + m_bLanguageLoaded = false; + else { + m_bLanguageLoaded = true; + TheText.Unload(); + TheText.Load(); + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + + debug("The previously saved language is now in use"); + } + + /*struct _WIN32_FIND_DATAA FindFileData; + HANDLE H = FindFirstFileA("skins\*.bmp", &FindFileData); + char Dest; + bool SkinFound = false; + + for (int i = 1; H != (HANDLE)-1 && i; i = FindNextFileA(H, &FindFileData)) { + strcpy(&Dest, buf(m_PrefsSkinFile)); + strcat(&Dest, ".bmp"); + if (!strcmp(FindFileData.cFileName, &Dest)) + SkinFound = true; + } + + FindClose(H); + + if (!SkinFound) { + debug("Default skin set as no other skins are available OR saved skin not found!"); + strcpy((char *)CMenuManager::m_PrefsSkinFile, "$$\"\""); + strcpy(m_aSkinName, "$$\"\""); + }*/ } #endif @@ -1012,31 +1286,585 @@ void CMenuManager::PrintStats() } #endif - -#if 1 +#if 0 WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { + if (m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) + return; + + field_113 = 0; + InitialiseChangedLanguageSettings(); + + SwitchMenuOnAndOff(); + + if (m_bMenuActive) { + LoadAllTextures(); + + if (m_nCurrScreen == MENUPAGE_DELETING) { + bool SlotPopulated = false; + + if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { + PcSaveHelper.PopulateSlotInfo(); + SlotPopulated = true; + } + + if (SlotPopulated) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { + int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); + PcSaveHelper.PopulateSlotInfo(); + if (SaveSlot) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { + if (CheckSlotDataValid(m_nCurrSaveSlot)) { + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; + DMAudio.Service(); + m_bStartGameLoading = 1; + RequestFrontEndShutdown(); + m_bLoadingSavedGame = 1; + b_FoundRecentSavedGameWantToLoad = 1; + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + ProcessButtonPresses(); + } + else { + if (GetPadExitEnter()) + RequestFrontEndStartUp(); + + UnloadTextures(); + m_nPrevScreen = MENUPAGE_NONE; + m_nCurrScreen = m_nPrevScreen; + m_nCurrOption = MENUROW_0; + } } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { + // Update Mouse Position + m_nMouseOldPosX = m_nMousePosX; + m_nMouseOldPosY = m_nMousePosY; + + m_nMousePosX = m_nMouseTempPosX; + m_nMousePosY = m_nMouseTempPosY; + + if (m_nMousePosX < 0) + m_nMousePosX = 0; + if (m_nMousePosX > SCREEN_WIDTH) + m_nMousePosX = SCREEN_WIDTH; + if (m_nMousePosY < 0) + m_nMousePosY = 0; + if (m_nMousePosY > SCREEN_HEIGHT) + m_nMousePosY = SCREEN_HEIGHT; + + // Show/hide mouse cursor. + if (GetMouseInput()) + m_bShowMouse = true; + else if (GetPadInput()) + m_bShowMouse = false; + + // Get number of menu options. + uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); + + // Select next/previous option with pad. Mouse is done in drawing function. + if (GetPadMoveUp()) { + m_nPrevOption = m_nCurrOption; + m_nCurrOption -= 1; + + if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { + if (m_nCurrOption < MENUROW_1) + m_nCurrOption = NumberOfMenuOptions; + } + else { + if (m_nCurrOption < MENUROW_0) + m_nCurrOption = NumberOfMenuOptions; + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } + else if (GetPadMoveDown()) { + m_nPrevOption = m_nCurrOption; + m_nCurrOption += 1; + + if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { + if (m_nCurrOption > NumberOfMenuOptions) + m_nCurrOption = MENUROW_1; + } + else { + if (m_nCurrOption > NumberOfMenuOptions) + m_nCurrOption = MENUROW_0; + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } + // Set what happens if ESC is pressed. + if (GetPadBack()) { + bool PlayEscSound = false; + switch (m_nCurrScreen) { + case MENUPAGE_START_MENU: + break; + case MENUPAGE_CHOOSE_SAVE_SLOT: + case MENUPAGE_PAUSE_MENU: + RequestFrontEndShutdown(); + PlayEscSound = true; + break; + default: + SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); + PlayEscSound = true; + break; + }; + + if (PlayEscSound) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + } + + // TODO: finish hover options. + // Set mouse buttons. + if (GetMouseForward()) { + switch (m_nHoverOption) { + case ACTIVATE_OPTION: + if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) + m_nCurrOption = m_nPrevOption; + + m_nHoverOption = ACTIVATE_OPTION; + break; + default: + break; + }; + } + + // Process all menu options here, but first check if it's an option or a redirect. + int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + if ((GetPadForward() || GetMouseForward()) || + ((GetPadMoveLeft() || GetMouseMoveRight()) || (GetPadMoveRight() || GetMouseMoveLeft())) && + (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen && + CurrAction != MENUACTION_CHANGEMENU && + CurrAction != MENUACTION_LOADRADIO && + CurrAction != MENUACTION_RESTOREDEF && + CurrAction != MENUACTION_PLAYERSETUP)) { + + if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB")) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + + ProcessOnOffMenuOptions(); + } + + // Process screens that may redirect you somewhere, or may not. + switch (m_nCurrScreen) { + case MENUPAGE_LOAD_SLOT_CONFIRM: + break; + case MENUPAGE_NEW_GAME_RELOAD: + if (m_bGameNotLoaded) + DoSettingsBeforeStartingAGame(); + break; + case MENUPAGE_CHOOSE_DELETE_SLOT: + case MENUPAGE_CHOOSE_SAVE_SLOT: + case MENUPAGE_CHOOSE_LOAD_SLOT: + PcSaveHelper.PopulateSlotInfo(); + break; + default: + break; + }; + + // Reset pad shaking. + if (VibrationTime != 0) { + if (CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { + CPad::GetPad(0)->StopShaking(0); + VibrationTime = 0; + } + } } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } #else void CMenuManager::ProcessOnOffMenuOptions() { + int8 InputDirection = (GetPadMoveLeft() || GetMouseMoveLeft()) && (!GetPadForward() && !GetMouseForward()) ? -1 : 1; + int8 InputEnter = GetPadForward(); + + uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); + + // In numerical order. + switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { + case MENUACTION_CHANGEMENU: + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + break; + case MENUACTION_CTRLVIBRATION: + if (!m_PrefsUseVibration) + m_PrefsUseVibration = true; + + if (m_PrefsUseVibration) { + CPad::GetPad(0)->StartShake(350, 150); + VibrationTime = CTimer::GetTimeInMillisecondsPauseMode() + 500; + } + SaveSettings(); + break; + case MENUACTION_FRAMESYNC: + m_PrefsVsync = m_PrefsVsync == false; + SaveSettings(); + break; + case MENUACTION_FRAMELIMIT: + m_PrefsFrameLimiter = m_PrefsFrameLimiter == false; + SaveSettings(); + break; + case MENUACTION_TRAILS: + CMBlur::BlurOn = CMBlur::BlurOn == false; + if (CMBlur::BlurOn) + CMBlur::MotionBlurOpen(Scene.camera); + else + CMBlur::MotionBlurClose(); + + SaveSettings(); + break; + case MENUACTION_SUBTITLES: + m_PrefsShowSubtitles = m_PrefsShowSubtitles == false; + SaveSettings(); + break; + case MENUACTION_WIDESCREEN: +#ifndef ASPECT_RATIO_SCALE + m_PrefsUseWideScreen = m_PrefsUseWideScreen == false; +#else + if (InputDirection > 0) { + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + m_PrefsUseWideScreen = AR_4_3; + break; + case AR_4_3: + m_PrefsUseWideScreen = AR_16_9; + break; + case AR_16_9: + m_PrefsUseWideScreen = AR_AUTO; + break; + }; + } + else { + switch (m_PrefsUseWideScreen) { + case AR_AUTO: + m_PrefsUseWideScreen = AR_16_9; + break; + case AR_4_3: + m_PrefsUseWideScreen = AR_AUTO; + break; + case AR_16_9: + m_PrefsUseWideScreen = AR_4_3; + break; + }; + } +#endif + SaveSettings(); + break; + case MENUACTION_BRIGHTNESS: + case MENUACTION_DRAWDIST: + case MENUACTION_MUSICVOLUME: + case MENUACTION_SFXVOLUME: + case MENUACTION_MOUSESENS: + if (InputDirection > 0) + CheckSliderMovement(1.0f); + else + CheckSliderMovement(-1.0f); + break; + case MENUACTION_RADIO: + if (InputDirection < 0) + m_PrefsRadioStation -= 1; + else + m_PrefsRadioStation += 1; + + if (DMAudio.IsMP3RadioChannelAvailable()) { + if (m_PrefsRadioStation > USERTRACK) + m_PrefsRadioStation = HEAD_RADIO; + else if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = USERTRACK; + } + else { + if (m_PrefsRadioStation > CHATTERBOX) + m_PrefsRadioStation = HEAD_RADIO; + else if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = CHATTERBOX; + } + SaveSettings(); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + break; + case MENUACTION_LANG_ENG: + if (m_PrefsLanguage != LANGUAGE_AMERICAN) { + m_PrefsLanguage = LANGUAGE_AMERICAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_FRE: + if (m_PrefsLanguage != LANGUAGE_FRENCH) { + m_PrefsLanguage = LANGUAGE_FRENCH; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_GER: + if (m_PrefsLanguage != LANGUAGE_GERMAN) { + m_PrefsLanguage = LANGUAGE_GERMAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_ITA: + if (m_PrefsLanguage != LANGUAGE_ITALIAN) { + m_PrefsLanguage = LANGUAGE_ITALIAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_LANG_SPA: + if (m_PrefsLanguage != LANGUAGE_SPANISH) { + m_PrefsLanguage = LANGUAGE_SPANISH; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + } + break; + case MENUACTION_UPDATESAVE: + PcSaveHelper.PopulateSlotInfo(); + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { + m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; + + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + } + break; + case MENUACTION_CHECKSAVE: + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { + m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; + + if (Slots[m_nCurrSaveSlot] != 1 && Slots[m_nCurrSaveSlot] != 2) + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + } + break; + case MENUACTION_NEWGAME: + DoSettingsBeforeStartingAGame(); + break; + case MENUACTION_SETDBGFLAG: + CTheScripts::DbgFlag = CTheScripts::DbgFlag == false; + break; + case MENUACTION_UPDATEMEMCARDSAVE: + RequestFrontEndShutdown(); + break; + case MENUACTION_INVVERT: + MousePointerStateHelper.bInvertVertically = MousePointerStateHelper.bInvertVertically == false; + return; + case MENUACTION_CANCLEGAME: + DMAudio.Service(); + RsEventHandler(rsQUITAPP, 0); + break; + case MENUACTION_RESUME: + RequestFrontEndShutdown(); + break; + case MENUACTION_SCREENRES: + if (m_bGameNotLoaded) { + if (InputEnter) { + if (m_nDisplayVideoMode != m_nPrefsVideoMode) { + m_nPrefsVideoMode = m_nDisplayVideoMode; + _psSelectScreenVM(m_nPrefsVideoMode); + CentreMousePointer(); + m_PrefsUseWideScreen = false; + SaveSettings(); + } + } + else { + char** VideoModeList = _psGetVideoModeList(); + int NumVideoModes = _psGetNumVideModes(); + + if (InputDirection > 0) { + int nCurrentVidMode = m_nDisplayVideoMode + 1; + + if (nCurrentVidMode >= NumVideoModes) + nCurrentVidMode = 0; + + while (!VideoModeList[nCurrentVidMode]) { + ++nCurrentVidMode; + + if (nCurrentVidMode >= NumVideoModes) + nCurrentVidMode = 0; + } + + m_nDisplayVideoMode = nCurrentVidMode; + } + else { + int nCurrentVidMode = m_nDisplayVideoMode - 1; + + if (nCurrentVidMode < 0) + nCurrentVidMode = NumVideoModes - 1; + + while (!VideoModeList[nCurrentVidMode]) { + --nCurrentVidMode; + + if (nCurrentVidMode < 0) + nCurrentVidMode = NumVideoModes - 1; + } + + m_nDisplayVideoMode = nCurrentVidMode; + } + } + } + break; + case MENUACTION_AUDIOHW: + { + int8 AudioHardware = m_nPrefsAudio3DProviderIndex; + if (m_nPrefsAudio3DProviderIndex == -1) + break; + + if (InputDirection > 0) { + switch (m_nPrefsAudio3DProviderIndex) { + case 0: + m_nPrefsAudio3DProviderIndex = 1; + break; + case 1: + m_nPrefsAudio3DProviderIndex = 2; + break; + case 2: + m_nPrefsAudio3DProviderIndex = 3; + break; + case 3: + m_nPrefsAudio3DProviderIndex = 4; + break; + case 4: + m_nPrefsAudio3DProviderIndex = 5; + break; + case 5: + m_nPrefsAudio3DProviderIndex = 6; + break; + case 6: + m_nPrefsAudio3DProviderIndex = 0; + break; + } + } + else { + switch (m_nPrefsAudio3DProviderIndex) { + case 0: + m_nPrefsAudio3DProviderIndex = 6; + break; + case 1: + m_nPrefsAudio3DProviderIndex = 0; + break; + case 2: + m_nPrefsAudio3DProviderIndex = 1; + break; + case 3: + m_nPrefsAudio3DProviderIndex = 2; + break; + case 4: + m_nPrefsAudio3DProviderIndex = 3; + break; + case 5: + m_nPrefsAudio3DProviderIndex = 4; + break; + case 6: + m_nPrefsAudio3DProviderIndex = 5; + break; + } + } + + DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); + + if (AudioHardware == m_nPrefsAudio3DProviderIndex) + SetHelperText(0); + else + SetHelperText(4); + + SaveSettings(); + break; + } + case MENUACTION_SPEAKERCONF: + if (m_nPrefsAudio3DProviderIndex == -1) + break; + + if (InputDirection > 0) { + switch (m_PrefsSpeakers) { + case 0: + m_PrefsSpeakers = 1; + break; + case 1: + m_PrefsSpeakers = 2; + break; + case 2: + m_PrefsSpeakers = 0; + break; + }; + } + else { + switch (m_PrefsSpeakers) { + case 0: + m_PrefsSpeakers = 2; + break; + case 1: + m_PrefsSpeakers = 0; + break; + case 2: + m_PrefsSpeakers = 1; + break; + }; + } + + DMAudio.SetSpeakerConfig(m_PrefsSpeakers); + SaveSettings(); + break; + case MENUACTION_RESTOREDEF: + SetDefaultPreferences(m_nCurrScreen); + SetHelperText(2); + SaveSettings(); + break; + case MENUACTION_CTRLMETHOD: + if (m_ControlMethod) { + TheCamera.m_bUseMouse3rdPerson = 1; + m_ControlMethod = 0; + } + else { + TheCamera.m_bUseMouse3rdPerson = 0; + m_ControlMethod = 1; + } + SaveSettings(); + break; + case MENUACTION_DYNAMICACOUSTIC: + m_PrefsDMA = m_PrefsDMA == false; + break; + case MENUACTION_MOUSESTEER: + m_bDisableMouseSteering = m_bDisableMouseSteering == false; + return; + }; } #endif @@ -1069,12 +1897,46 @@ void CMenuManager::ResetHelperText() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { EAXJMP(0x488930); } #else void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { - + switch (PcSaveHelper.m_nHelper) { + case 1: + case 2: + case 3: + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_FAILED; + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + break; + break; + case 4: + case 5: + case 6: + this->m_nPrevScreen = m_nCurrScreen; + this->m_nCurrScreen = MENUPAGE_LOAD_FAILED; + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + break; + case 7: + this->m_nPrevScreen = m_nCurrScreen; + this->m_nCurrScreen = MENUPAGE_LOAD_FAILED_2; + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + break; + case 8: + case 9: + case 10: + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_FAILED; + m_nCurrOption = MENUROW_0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + break; + default: + return; + } } #endif @@ -1088,12 +1950,50 @@ void CMenuManager::SetHelperText(int text) } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } #else void CMenuManager::SaveSettings() { + CFileMgr::SetDirMyDocuments(); + + int fileHandle = CFileMgr::OpenFile("gta3.set", "w"); + if (fileHandle) { + + ControlsManager.SaveSettings(fileHandle); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_bHeadBob), 1); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), 4); + CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), 4); + CFileMgr::Write(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), 1); + CFileMgr::Write(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsSfxVolume), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsMusicVolume), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsRadioStation), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsSpeakers), 1); + CFileMgr::Write(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsDMA), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsBrightness), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); + CFileMgr::Write(fileHandle, buf(&m_PrefsShowSubtitles), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsUseWideScreen), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsVsyncDisp), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsFrameLimiter), 1); + CFileMgr::Write(fileHandle, buf(&m_nDisplayVideoMode), 1); + CFileMgr::Write(fileHandle, buf(&CMBlur::BlurOn), 1); + CFileMgr::Write(fileHandle, buf(m_PrefsSkinFile), 256); + CFileMgr::Write(fileHandle, buf(&m_ControlMethod), 1); + CFileMgr::Write(fileHandle, buf(&m_PrefsLanguage), 1); + } + CFileMgr::CloseFile(fileHandle); + CFileMgr::SetDir(""); } #endif @@ -1107,15 +2007,16 @@ void CMenuManager::ShutdownJustMenu() } #endif +// We won't ever use this again. #if 0 WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); } #else float CMenuManager::StretchX(float x) { - if (SCREENW == 640) + if (SCREEN_WIDTH == 640) return x; else - return SCREENW * x * 0.0015625f; + return SCREEN_WIDTH * x * 0.0015625f; } #endif @@ -1124,10 +2025,10 @@ WRAPPER float CMenuManager::StretchY(float) { EAXJMP(0x48AC20); } #else float CMenuManager::StretchY(float y) { - if (SCREENH == 448) + if (SCREEN_HEIGHT == 448) return y; else - return SCREENH * y * 0.002232143f; + return SCREEN_HEIGHT * y * 0.002232143f; } #endif @@ -1136,7 +2037,44 @@ WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } #else void CMenuManager::SwitchMenuOnAndOff() { + // Just what the function name says. + if (m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { + if (!m_bMenuActive) + m_bMenuActive = true; + + if (m_bShutDownFrontEndRequested) + m_bMenuActive = false; + if (m_bStartUpFrontEndRequested) + m_bMenuActive = true; + + if (m_bMenuActive) { + CTimer::StartUserPause(); + } + else { + ShutdownJustMenu(); + SaveSettings(); + m_bStartUpFrontEndRequested = false; + pControlEdit = 0; + m_bShutDownFrontEndRequested = false; + DisplayComboButtonErrMsg = 0; + CPad::GetPad(0)->Clear(0); + CPad::GetPad(1)->Clear(0); + SwitchToNewScreen(0); + } + } + if (m_bSaveMenuActive && !m_bQuitGameNoCD) { + m_bSaveMenuActive = false; + m_bMenuActive = true; + CTimer::StartUserPause(); + SwitchToNewScreen(MENUPAGE_CHOOSE_SAVE_SLOT); + PcSaveHelper.PopulateSlotInfo(); + } + if (!m_bMenuActive) + field_112 = 1; + + m_bStartUpFrontEndRequested = false; + m_bShutDownFrontEndRequested = false; } #endif @@ -1165,18 +2103,250 @@ void CMenuManager::UnloadTextures() } #endif -#if 1 +#if 0 WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } #else void CMenuManager::WaitForUserCD() { - + LoadSplash(0); + if (!RsGlobal.quit) { + HandleExit(); + CPad::UpdatePads(); + MessageScreen("NO_PCCD"); + + if (GetPadBack()) { + m_bQuitGameNoCD = true; + RsEventHandler(rsQUITAPP, 0); + } + } } #endif +// New content: +uint8 CMenuManager::GetNumberOfMenuOptions() +{ + uint8 Rows = MENUROW_NONE; + for (int i = 0; i < MENUROWS; i++) { + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_NOTHING) + break; + + ++Rows; + }; + return Rows; +} + +void CMenuManager::SwitchToNewScreen(int8 screen) +{ + ResetHelperText(); + + // Return to - behaviour. + if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") || + (screen == aScreens[m_nCurrScreen].m_PreviousPage[0])) { + if (m_bGameNotLoaded) { + m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[0]; + m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[0]; + } + else { + m_nCurrOption = aScreens[m_nCurrScreen].m_ParentEntry[1]; + m_nCurrScreen = aScreens[m_nCurrScreen].m_PreviousPage[1]; + } + + m_nMenuFadeAlpha = 0; + } + else { + // Go through - behaviour. + if (screen) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = screen; + m_nCurrOption = MENUROW_0; + m_nMenuFadeAlpha = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else { + m_nPrevScreen = MENUPAGE_NONE; + m_nCurrScreen = MENUPAGE_NONE; + m_nCurrOption = MENUROW_0; + } + } + + // Set player skin. + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + CPlayerSkin::BeginFrontEndSkinEdit(); + field_535 = 19; + m_bSkinsFound = false; + } + + // Set radio station. + if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + OutputDebugStringA("FRONTEND AUDIO TRACK STOPPED"); + } + else + DMAudio.StopFrontEndTrack(); +} + +void CMenuManager::SetDefaultPreferences(int8 screen) +{ + switch (screen) { + case MENUPAGE_SOUND_SETTINGS: + m_PrefsMusicVolume = 102; + m_PrefsSfxVolume = 102; + m_PrefsSpeakers = 0; + m_nPrefsAudio3DProviderIndex = 6; + m_PrefsDMA = true; + DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); + DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); + break; + case MENUPAGE_GRAPHICS_SETTINGS: + m_PrefsBrightness = 256; + m_PrefsFrameLimiter = true; + m_PrefsVsync = true; + m_PrefsLOD = 1.2f; + m_PrefsVsyncDisp = true; + lodMultiplier = 1.2; + CMBlur::BlurOn = true; + CMBlur::MotionBlurOpen(Scene.camera); + m_PrefsUseVibration = false; + m_PrefsShowSubtitles = true; + m_nDisplayVideoMode = m_nPrefsVideoMode; + m_PrefsUseWideScreen = false; + break; + case MENUPAGE_CONTROLLER_PC: + ControlsManager.MakeControllerActionsBlank(); + ControlsManager.InitDefaultControlConfiguration(); + + CMouseControllerState state = MousePointerStateHelper.GetMouseSetUp(); + ControlsManager.InitDefaultControlConfigMouse(state); + + if (1) { + //TODO: JoyPad stuff. + } + TheCamera.m_bUseMouse3rdPerson = 1; + m_ControlMethod = 0; + MousePointerStateHelper.bInvertVertically = true; + TheCamera.m_fMouseAccelHorzntl = 0.0025f; + TheCamera.m_fMouseAccelVertical = 0.0025f; + CVehicle::m_bDisableMouseSteering = true; + TheCamera.m_bHeadBob = false; + break; + }; +} + +// Frontend inputs. +bool GetPadBack() +{ + return + (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || + (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->OldState.Triangle); +} + +bool GetPadExitEnter() +{ + return + (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || + (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->OldState.Start); +} + +bool GetPadForward() +{ + return + (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || + (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || + (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->OldState.Cross); +} + +bool GetPadMoveUp() +{ + return + (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || + (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || + (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0); +} + +bool GetPadMoveDown() +{ + return + (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || + (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || + (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0); +} + +bool GetPadMoveLeft() +{ + return + (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || + (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || + (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0); +} + +bool GetPadMoveRight() +{ + return + (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || + (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || + (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0); +} + +bool GetMouseForward() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB); +} + +bool GetMouseBack() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB); +} + +bool GetMousePos() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->OldMouseControllerState.y != 0.0f); +} + +bool GetMouseMoveLeft() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f); +} + +bool GetMouseMoveRight() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f); +} + +bool GetPadInput() +{ + return + GetPadBack() || + GetPadForward() || + GetPadMoveUp() || + GetPadMoveDown() || + GetPadMoveLeft() || + GetPadMoveRight(); +} + +bool GetMouseInput() +{ + return + GetMouseForward() || + GetMouseBack() || + GetMousePos() || + GetMouseMoveLeft() || + GetMouseMoveRight(); +} + STARTPATCHES InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); + InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); + InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); + InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); + InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); + InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); diff --git a/src/Frontend.h b/src/Frontend.h index dd6464b8..9b9377da 100644 --- a/src/Frontend.h +++ b/src/Frontend.h @@ -29,7 +29,11 @@ #define MENUSELECT_BOX_MAX 20.5f #define MENUSELECT_BOX_MIN 17.0f +#ifndef ASPECT_RATIO_SCALE #define MENURADIO_ICON_X 31.5f +#else +#define MENURADIO_ICON_X -262.0f +#endif #define MENURADIO_ICON_Y 29.5f #define MENURADIO_ICON_W 60.0f #define MENURADIO_ICON_H 60.0f @@ -39,6 +43,8 @@ #define MENUSLIDER_X 306.0f +#define buf(a) (char*)(a) + enum eLanguages { LANGUAGE_AMERICAN, @@ -314,6 +320,7 @@ enum eMenuColumns enum eMenuRow { + MENUROW_NONE = -1, MENUROW_0, MENUROW_1, MENUROW_2, @@ -347,7 +354,8 @@ struct tSkinInfo struct CMenuScreen { char m_ScreenName[8]; - int32 m_PreviousPage[3]; // eMenuScreen + int32 unk; + int32 m_PreviousPage[2]; // eMenuScreen int32 m_ParentEntry[2]; // eMenuRow struct CMenuEntry @@ -417,7 +425,7 @@ public: int m_nHoverOption; int m_nCurrScreen; int m_nCurrOption; - int m_nCurrentInput; + int m_nPrevOption; int m_nPrevScreen; int field_558; int m_nCurrSaveSlot; @@ -431,7 +439,6 @@ public: static int8 &m_PrefsVsync; static int8 &m_PrefsVsyncDisp; static int8 &m_PrefsFrameLimiter; - static int8 &BlurOn; static int8 &m_PrefsShowSubtitles; static int8 &m_PrefsSpeakers; static int8 &m_ControlMethod; @@ -443,6 +450,8 @@ public: static int8 &m_bFrontEnd_ReloadObrTxtGxt; static int32 &m_PrefsMusicVolume; static int32 &m_PrefsSfxVolume; + static uint8 *m_PrefsSkinFile; + static bool &m_bStartUpFrontEndRequested; static bool &m_bShutDownFrontEndRequested; static bool &m_PrefsAllowNastyGame; @@ -452,6 +461,7 @@ public: static void CentreMousePointer(); void CheckCodesForControls(int, int); bool CheckHover(int x1, int x2, int y1, int y2); + void CheckSliderMovement(int); int CostructStatLine(int); void DisplayHelperText(); float DisplaySlider(float, float, float, float, float, float); @@ -485,10 +495,16 @@ public: void SetHelperText(int text); void ShutdownJustMenu(); static float StretchX(float); - static float StretchY(float ); + static float StretchY(float); void SwitchMenuOnAndOff(); void UnloadTextures(); void WaitForUserCD(); + + // New content: + uint8 GetNumberOfMenuOptions(); + void SwitchToNewScreen(int8 screen); + void SetDefaultPreferences(int8 screen); + }; static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); diff --git a/src/MenuScreens.h b/src/MenuScreens.h index 640952ed..2da81f1d 100644 --- a/src/MenuScreens.h +++ b/src/MenuScreens.h @@ -12,7 +12,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_NEW_GAME = 2 { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_0, MENUROW_1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, - MENUACTION_UPDATESAVE, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, + MENUACTION_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -43,7 +43,7 @@ const CMenuScreen aScreens[] = { { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_2, MENUROW_2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, + //MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -55,45 +55,45 @@ const CMenuScreen aScreens[] = { // MENUPAGE_LANGUAGE_SETTINGS = 7 { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_3, MENUROW_3, - MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_1, MENUROW_1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_2, MENUROW_2, - MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, }, // MENUPAGE_NEW_GAME_RELOAD = 10 { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_0, MENUROW_0, MENUACTION_LABEL, "FESZ_QR", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, + MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LOAD_SLOT_CONFIRM = 11 @@ -181,14 +181,14 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CHOOSE_SAVE_SLOT = 26 { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, - MENUACTION_CHANGEMENU, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_SAVE_OVERWRITE_CONFIRM, + MENUACTION_UPDATESAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_SAVE_OVERWRITE_CONFIRM, }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 @@ -236,7 +236,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_0, MENUROW_0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_REDEFCTRL, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, + MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, @@ -270,17 +270,17 @@ const CMenuScreen aScreens[] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_1, MENUROW_4, MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, + MENUACTION_CHANGEMENU, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_CHANGEMENU, "FET_LAN", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - MENUACTION_PLAYERSETUP, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, + //MENUACTION_CHANGEMENU, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_EXIT = 42 { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_2, MENUROW_5, MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_DONTCANCLE, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCLEGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -352,19 +352,19 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SKIN_SELECT = 54 { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_4, MENUROW_4, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, + //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, }, // MENUPAGE_KEYBOARD_CONTROLS = 55 { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_1, MENUROW_1, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_2, MENUROW_2, - MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, + MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, + MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, diff --git a/src/PCSave.cpp b/src/PCSave.cpp index ae5e43b0..628e1218 100644 --- a/src/PCSave.cpp +++ b/src/PCSave.cpp @@ -4,9 +4,17 @@ #include "PCSave.h" WRAPPER void C_PcSave::SetSaveDirectory(const char *path) { EAXJMP(0x591EA0); } +WRAPPER int8 C_PcSave::PopulateSlotInfo() { EAXJMP(0x592090); } +WRAPPER int8 C_PcSave::DeleteSlot(int) { EAXJMP(0x5922F0); } +WRAPPER int8 C_PcSave::SaveSlot(int) { EAXJMP(0x591EC0); } + +WRAPPER int8 CheckSlotDataValid(int) { EAXJMP(0x591A40); } + WRAPPER wchar *GetNameOfSavedGame(int counter) { EAXJMP(0x591B60); } WRAPPER wchar *GetSavedGameDateAndTime(int counter) { EAXJMP(0x591B50); } + +C_PcSave PcSaveHelper = *(C_PcSave*)0x8E2C60; int *Slots = (int*)0x728040; int *SlotFileName = (int*)0x6F07C8; int *SlotSaveDate = (int*)0x72B858; diff --git a/src/PCSave.h b/src/PCSave.h index 79202bc9..696e158a 100644 --- a/src/PCSave.h +++ b/src/PCSave.h @@ -3,12 +3,19 @@ class C_PcSave { public: + int32 m_nHelper; + static void SetSaveDirectory(const char *path); + int8 PopulateSlotInfo(); + int8 DeleteSlot(int); + int8 SaveSlot(int); }; +extern int8 CheckSlotDataValid(int); extern wchar *GetNameOfSavedGame(int counter); extern wchar *GetSavedGameDateAndTime(int counter); +extern C_PcSave PcSaveHelper; extern int *Slots; extern int *SlotFileName; extern int *SlotSaveDate; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index b3887c70..824d5c39 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -17,8 +17,13 @@ WRAPPER bool cDMAudio::CheckForAnAudioFileOnCD() { EAXJMP(0x57CA70); } WRAPPER void cDMAudio::ChangeMusicMode(uint8 mode) { EAXJMP(0x57CCF0); } WRAPPER void cDMAudio::PlayFrontEndSound(uint32, uint32) { EAXJMP(0x57CC20); } -WRAPPER void cDMAudio::PlayOneShot(int, uint16, float) { EAXJMP(0x57C840); } - +WRAPPER void cDMAudio::PlayFrontEndTrack(uint32, uint32) { EAXJMP(0x57CC80); } +WRAPPER void cDMAudio::StopFrontEndTrack() { EAXJMP(0x57CCB0); } +WRAPPER void cDMAudio::PlayOneShot(int32, uint16, float) { EAXJMP(0x57C840); } +WRAPPER void cDMAudio::SetMusicMasterVolume(int8) { EAXJMP(0x57C8C0); } +WRAPPER void cDMAudio::SetEffectsMasterVolume(int8) { EAXJMP(0x57C890); } +WRAPPER int8 cDMAudio::SetCurrent3DProvider(int8) { EAXJMP(0x57C9B0); } +WRAPPER int32 cDMAudio::SetSpeakerConfig(int32) { EAXJMP(0x57C9D0); } WRAPPER int32 cDMAudio::GetRadioInCar() { EAXJMP(0x57CE40); } WRAPPER uint8 cDMAudio::IsMP3RadioChannelAvailable() { EAXJMP(0x57C9F0); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 46b40e37..46914aaa 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -188,7 +188,13 @@ public: bool CheckForAnAudioFileOnCD(void); void ChangeMusicMode(uint8 mode); void PlayFrontEndSound(uint32, uint32); - void PlayOneShot(int, uint16, float); + void PlayFrontEndTrack(uint32, uint32); + void StopFrontEndTrack(); + void PlayOneShot(int32, uint16, float); + void SetMusicMasterVolume(int8); + void SetEffectsMasterVolume(int8); + int8 SetCurrent3DProvider(int8); + int32 SetSpeakerConfig(int32); int32 GetRadioInCar(void); void SetEffectsFadeVol(uint8); void SetMusicFadeVol(uint8); diff --git a/src/common.h b/src/common.h index 7f304e90..3d260f6e 100644 --- a/src/common.h +++ b/src/common.h @@ -56,26 +56,12 @@ extern void **rwengine; #include "skeleton.h" #include "Draw.h" -/* - { SCREEN_STRETCH } Done originally by the game for most of the printed stuff. - Stretches everything to screen avoiding it's aspect ratio. - Looks good only in 4:3. - - { SCREEN_SCALE } Alternative to the one above, it's used in this project to scale - original content to a *DEFINED aspect ratio with the possibility to - set a multiplier and scale content differently. - In theory should look good on any screen. -*/ - #define DEFAULT_SCREEN_WIDTH (640) #define DEFAULT_SCREEN_HEIGHT (448) #define DEFAULT_ASPECT_RATIO (4.0f/3.0f) // game uses maximumWidth/Height, but this probably won't work // with RW windowed mode -// TODO: get rid of one of the two -#define SCREENW (RsGlobal.width) -#define SCREENH (RsGlobal.height) #define SCREEN_WIDTH ((float)RsGlobal.width) #define SCREEN_HEIGHT ((float)RsGlobal.height) #define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio()) diff --git a/src/entities/PlayerSkin.cpp b/src/entities/PlayerSkin.cpp new file mode 100644 index 00000000..1c9ca2c6 --- /dev/null +++ b/src/entities/PlayerSkin.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "PlayerSkin.h" + +WRAPPER void CPlayerSkin::BeginFrontEndSkinEdit() { EAXJMP(0x59BC70); } diff --git a/src/entities/PlayerSkin.h b/src/entities/PlayerSkin.h new file mode 100644 index 00000000..61e09cdf --- /dev/null +++ b/src/entities/PlayerSkin.h @@ -0,0 +1,7 @@ +#pragma once + +class CPlayerSkin +{ +public: + static void BeginFrontEndSkinEdit(); +}; \ No newline at end of file diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp index 8c1ef515..f7c4b065 100644 --- a/src/entities/Vehicle.cpp +++ b/src/entities/Vehicle.cpp @@ -12,7 +12,8 @@ bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75; bool &CVehicle::bCheat3 = *(bool *)0x95CD66; bool &CVehicle::bCheat4 = *(bool *)0x95CD65; bool &CVehicle::bCheat5 = *(bool *)0x95CD64; - +bool &CVehicle::m_bDisableMouseSteering = *(bool *)0x60252C; + void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index 27641e47..ba3e568e 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -135,6 +135,7 @@ public: static bool &bCheat3; static bool &bCheat4; static bool &bCheat5; + static bool &m_bDisableMouseSteering; }; static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); diff --git a/src/main.cpp b/src/main.cpp index de3d8b62..2835f396 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,8 +124,8 @@ Idle(void *arg) #ifdef GTA_PC // This is from SA, but it's nice for windowed mode RwV2d pos; - pos.x = SCREENW/2.0f; - pos.y = SCREENH/2.0f; + pos.x = SCREEN_WIDTH/2.0f; + pos.y = SCREEN_HEIGHT/2.0f; RsMouseSetPos(&pos); #endif CRenderer::ConstructRenderList(); @@ -230,7 +230,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR CSprite2d::InitPerFrame(); if(Alpha != 0) - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH), BottomColor, BottomColor, TopColor, TopColor); + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), BottomColor, BottomColor, TopColor, TopColor); return true; } @@ -346,15 +346,15 @@ Render2dStuff(void) // top and bottom strips if (weaponType == WEAPONTYPE_ROCKETLAUNCHER) { - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH / 2 - SCREEN_SCALE_Y(180)), black); - CSprite2d::DrawRect(CRect(0.0f, SCREENH / 2 + SCREEN_SCALE_Y(170), SCREENW, SCREENH), black); + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(180)), black); + CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(170), SCREEN_WIDTH, SCREEN_HEIGHT), black); } else { - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH / 2 - SCREEN_SCALE_Y(210)), black); - CSprite2d::DrawRect(CRect(0.0f, SCREENH / 2 + SCREEN_SCALE_Y(210), SCREENW, SCREENH), black); + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(210)), black); + CSprite2d::DrawRect(CRect(0.0f, SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(210), SCREEN_WIDTH, SCREEN_HEIGHT), black); } - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW / 2 - SCREEN_SCALE_X(210), SCREENH), black); - CSprite2d::DrawRect(CRect(SCREENW / 2 + SCREEN_SCALE_X(210), 0.0f, SCREENW, SCREENH), black); + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH / 2 - SCREEN_SCALE_X(210), SCREEN_HEIGHT), black); + CSprite2d::DrawRect(CRect(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(210), 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), black); } MusicManager.DisplayRadioStationName(); @@ -444,16 +444,16 @@ DoFade(void) if(TheCamera.m_WideScreenOn){ // what's this? - float y = SCREENH/2 * TheCamera.m_ScreenReductionPercentage/100.0f; + float y = SCREEN_HEIGHT/2 * TheCamera.m_ScreenReductionPercentage/100.0f; rect.left = 0.0f; - rect.right = SCREENW; + rect.right = SCREEN_WIDTH; rect.top = y - 8.0f; - rect.bottom = SCREENH - y - 8.0f; + rect.bottom = SCREEN_HEIGHT - y - 8.0f; }else{ rect.left = 0.0f; - rect.right = SCREENW; + rect.right = SCREEN_WIDTH; rect.top = 0.0f; - rect.bottom = SCREENH; + rect.bottom = SCREEN_HEIGHT; } CSprite2d::DrawRect(rect, fadeColor); @@ -462,7 +462,7 @@ DoFade(void) fadeColor.g = 255; fadeColor.b = 255; fadeColor.a = CDraw::FadeValue; - splash->Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), fadeColor, fadeColor, fadeColor, fadeColor); + splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), fadeColor, fadeColor, fadeColor, fadeColor); } } } @@ -549,14 +549,14 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen) CFont::InitPerFrame(); DefinedState(); RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); - splash->Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), CRGBA(255, 255, 255, 255)); + splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); if(str1){ NumberOfChunksLoaded += 1; float hpos = SCREEN_SCALE_X(40); - float length = SCREENW - SCREEN_SCALE_X(100); - float vpos = SCREENH - SCREEN_SCALE_Y(13); + float length = SCREEN_WIDTH - SCREEN_SCALE_X(100); + float vpos = SCREEN_HEIGHT - SCREEN_SCALE_Y(13); float height = SCREEN_SCALE_Y(7); CSprite2d::DrawRect(CRect(hpos, vpos, hpos + length, vpos + height), CRGBA(40, 53, 68, 255)); @@ -617,7 +617,7 @@ LoadingIslandScreen(const char *levelName) CFont::InitPerFrame(); DefinedState(); col = CRGBA(255, 255, 255, 255); - splash->Draw(CRect(0.0f, 0.0f, SCREENW, SCREENH), col, col, col, col); + splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), col, col, col, col); CFont::SetBackgroundOff(); CFont::SetScale(1.5f, 1.5f); CFont::SetPropOn(); @@ -630,12 +630,12 @@ LoadingIslandScreen(const char *levelName) CFont::SetDropShadowPosition(3); CFont::SetColor(CRGBA(243, 237, 71, 255)); CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f)); - CFont::PrintString(SCREENW - 20, SCREEN_STRETCH_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); + CFont::PrintString(SCREEN_WIDTH - 20, SCREEN_STRETCH_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); TextCopy(wstr, name); TheText.UpperCase(wstr); CFont::SetColor(CRGBA(243, 237, 71, 255)); CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f)); - CFont::PrintString(SCREENW-20, SCREEN_STRETCH_FROM_BOTTOM(80.0f), wstr); + CFont::PrintString(SCREEN_WIDTH-20, SCREEN_STRETCH_FROM_BOTTOM(80.0f), wstr); CFont::DrawFonts(); DoRWStuffEndOfFrame(); } diff --git a/src/main.h b/src/main.h index c7914549..bdb0e008 100644 --- a/src/main.h +++ b/src/main.h @@ -10,6 +10,7 @@ extern GlobalScene &Scene; extern uint8 work_buff[55000]; extern char gString[256]; extern wchar *gUString; +extern bool &b_FoundRecentSavedGameWantToLoad; class CSprite2d; diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 6854c80c..bf572841 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -208,15 +208,15 @@ CClouds::Render(void) int br = CTimeCycle::GetFluffyCloudsBottomRed(); int bg = CTimeCycle::GetFluffyCloudsBottomGreen(); int bb = CTimeCycle::GetFluffyCloudsBottomBlue(); - if(sundist < SCREENW/2){ - hilight = (1.0f - coverage) * (1.0f - sundist/(SCREENW/2)); + if(sundist < SCREEN_WIDTH/2){ + hilight = (1.0f - coverage) * (1.0f - sundist/(SCREEN_WIDTH/2)); tr = tr*(1.0f-hilight) + 255*hilight; tg = tg*(1.0f-hilight) + 190*hilight; tb = tb*(1.0f-hilight) + 190*hilight; br = br*(1.0f-hilight) + 255*hilight; bg = bg*(1.0f-hilight) + 190*hilight; bb = bb*(1.0f-hilight) + 190*hilight; - if(sundist < SCREENW/10) + if(sundist < SCREEN_WIDTH/10) CCoronas::SunBlockedByClouds = true; }else hilight = 0.0f; @@ -317,16 +317,16 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, } } ms_colourBottom = ms_colourTop; - CRect r(0, 0, SCREENW, SCREENH); + CRect r(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); CSprite2d::DrawRect(r, ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); }else{ ms_horizonZ = CSprite::CalcHorizonCoors(); // Draw top/bottom gradient - float gradheight = SCREENH/2.0f; + float gradheight = SCREEN_HEIGHT/2.0f; float topedge = ms_horizonZ - gradheight; float botpos, toppos; - if(ms_horizonZ > 0.0f && topedge < SCREENH){ + if(ms_horizonZ > 0.0f && topedge < SCREEN_HEIGHT){ ms_colourTop.r = topred; ms_colourTop.g = topgreen; ms_colourTop.b = topblue; @@ -336,14 +336,14 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, ms_colourBottom.b = botblue; ms_colourBottom.a = alpha; - if(ms_horizonZ < SCREENH) + if(ms_horizonZ < SCREEN_HEIGHT) botpos = ms_horizonZ; else{ - float f = (ms_horizonZ - SCREENH)/gradheight; + float f = (ms_horizonZ - SCREEN_HEIGHT)/gradheight; ms_colourBottom.r = topred*f + (1.0f-f)*botred; ms_colourBottom.g = topgreen*f + (1.0f-f)*botgreen; ms_colourBottom.b = topblue*f + (1.0f-f)*botblue; - botpos = SCREENH; + botpos = SCREEN_HEIGHT; } if(topedge >= 0.0f) toppos = topedge; @@ -354,17 +354,17 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, ms_colourTop.b = botblue*f + (1.0f-f)*topblue; toppos = 0.0f; } - CSprite2d::DrawRect(CRect(0, toppos, SCREENW, botpos), + CSprite2d::DrawRect(CRect(0, toppos, SCREEN_WIDTH, botpos), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); } // draw the small stripe (whatever it's supposed to be) - if(ms_horizonZ > -SMALLSTRIPHEIGHT && ms_horizonZ < SCREENH){ + if(ms_horizonZ > -SMALLSTRIPHEIGHT && ms_horizonZ < SCREEN_HEIGHT){ // Same colour as fog ms_colourTop.r = (topred + 2 * botred) / 3; ms_colourTop.g = (topgreen + 2 * botgreen) / 3; ms_colourTop.b = (topblue + 2 * botblue) / 3; - CSprite2d::DrawRect(CRect(0, ms_horizonZ, SCREENW, ms_horizonZ+SMALLSTRIPHEIGHT), + CSprite2d::DrawRect(CRect(0, ms_horizonZ, SCREEN_WIDTH, ms_horizonZ+SMALLSTRIPHEIGHT), ms_colourTop, ms_colourTop, ms_colourTop, ms_colourTop); } @@ -379,8 +379,8 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, ms_colourBottom.b = topblue; ms_colourBottom.a = alpha; - botpos = min(SCREENH, topedge); - CSprite2d::DrawRect(CRect(0, 0, SCREENW, botpos), + botpos = min(SCREEN_HEIGHT, topedge); + CSprite2d::DrawRect(CRect(0, 0, SCREEN_WIDTH, botpos), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); } @@ -403,22 +403,22 @@ CClouds::RenderHorizon(void) ms_colourBottom.a = 230; ms_colourTop.a = 80; - if(ms_horizonZ > SCREENH) + if(ms_horizonZ > SCREEN_HEIGHT) return; - float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREENH); - CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREENW, z1), + float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT); + CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREEN_WIDTH, z1), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); // This is just weird - float a = SCREENH/400.0f * HORIZSTRIPHEIGHT + - SCREENH/300.0f * max(TheCamera.GetPosition().z, 0.0f); + float a = SCREEN_HEIGHT/400.0f * HORIZSTRIPHEIGHT + + SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f); float b = TheCamera.GetUp().z < 0.0f ? - SCREENH : - SCREENH * fabs(TheCamera.GetRight().z); + SCREEN_HEIGHT : + SCREEN_HEIGHT * fabs(TheCamera.GetRight().z); float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier; - z2 = min(z2, SCREENH); - CSprite2d::DrawRect(CRect(0, z1, SCREENW, z2), + z2 = min(z2, SCREEN_HEIGHT); + CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); } diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 8365d02b..6d20c1ff 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -39,11 +39,11 @@ CCredits::PrintCreditSpace(float space, uint32 &line) void CCredits::PrintCreditText(float scaleX, float scaleY, wchar *text, uint32 &lineoffset, float scrolloffset) { - float start = SCREENH + 50.0f; + float start = SCREEN_HEIGHT + 50.0f; float y = lineoffset + start - scrolloffset; if(y > -50.0f && y < start){ CFont::SetScale(scaleX, scaleY); - CFont::PrintString(SCREENW/2.0f, y, (uint16*)text); + CFont::PrintString(SCREEN_WIDTH/2.0f, y, (uint16*)text); } lineoffset += scaleY*25.0f; } @@ -62,7 +62,7 @@ CCredits::Render(void) scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f; CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREENW - 20); + CFont::SetCentreSize(SCREEN_WIDTH - 20); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(220, 220, 220, 220)); @@ -489,7 +489,7 @@ CCredits::Render(void) if(TheCamera.m_WideScreenOn) TheCamera.DrawBordersForWideScreen(); - if(lineoffset + SCREENH - scrolloffset < -10.0f) + if(lineoffset + SCREEN_HEIGHT - scrolloffset < -10.0f) bCreditsGoing = false; } diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 922d96d4..f825ba42 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -20,12 +20,24 @@ uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53; float CDraw::FindAspectRatio(void) { +#ifndef ASPECT_RATIO_SCALE if(FrontEndMenuManager.m_PrefsUseWideScreen) return 16.0f/9.0f; else return 4.0f/3.0f; +#else + switch (FrontEndMenuManager.m_PrefsUseWideScreen) { + case AR_AUTO: + return SCREEN_WIDTH / SCREEN_HEIGHT; + case AR_4_3: + return 4.0f / 3.0f; + case AR_16_9: + return 16.0f / 9.0f; + }; +#endif } +#ifdef ASPECT_RATIO_SCALE // convert a 4:3 hFOV to vFOV, // then convert that vFOV to hFOV for our aspect ratio, // i.e. HOR+ @@ -41,6 +53,7 @@ CDraw::ConvertFOV(float hfov) hfov = atan(tan(vfov/2) * ar2) *2; return RADTODEG(hfov); } +#endif void CDraw::SetFOV(float fov) diff --git a/src/render/Draw.h b/src/render/Draw.h index 3349c6c9..ad14e5a9 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -1,5 +1,12 @@ #pragma once +enum eAspectRatio +{ + AR_AUTO, + AR_4_3, + AR_16_9, +}; + class CDraw { private: diff --git a/src/render/Font.cpp b/src/render/Font.cpp index 2130fb95..59023960 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -83,7 +83,7 @@ CFont::Initialise(void) Sprite[1].SetTexture("pager", "pager_mask"); Sprite[2].SetTexture("font1", "font1_mask"); SetScale(1.0f, 1.0f); - SetSlantRefPoint(SCREENW, 0.0f); + SetSlantRefPoint(SCREEN_WIDTH, 0.0f); SetSlant(0.0); SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0)); SetJustifyOff(); @@ -123,8 +123,8 @@ CFont::InitPerFrame(void) void CFont::PrintChar(float x, float y, uint16 c) { - if(x <= 0.0f || x >= SCREENW || - y <= 0.0f || y >= SCREENH) // BUG: game uses SCREENW again + if(x <= 0.0f || x >= SCREEN_WIDTH || + y <= 0.0f || y >= SCREEN_HEIGHT) // BUG: game uses SCREENW again return; float w = GetCharacterWidth(c) / 32.0f; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index e5a44221..0e132392 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -125,6 +125,15 @@ WRAPPER void CHud::Draw(void) { EAXJMP(0x5052A0); } #else void CHud::Draw() { + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSMIRROR); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + if (CReplay::IsPlayingBack()) return; @@ -167,18 +176,15 @@ void CHud::Draw() float fStep = sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127); float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); CRect rect; - - float fWidescreenOffset[2] = { 0.0f, 0.0f }; - - if (FrontEndMenuManager.m_PrefsUseWideScreen) { - fWidescreenOffset[0] = 0.0f; - fWidescreenOffset[1] = SCREEN_SCALE_Y(18.0f); - } - +#ifndef ASPECT_RATIO_SCALE if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { - float f3rdX = SCREENW * TheCamera.m_f3rdPersonCHairMultX + fWidescreenOffset[0]; - float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY - fWidescreenOffset[1]; - + float f3rdX = SCREEN_WIDTH * TheCamera.m_f3rdPersonCHairMultX; + float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY; +#else + if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) { + float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (DEFAULT_ASPECT_RATIO))) + 0.5f) * SCREEN_WIDTH; + float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY + SCREEN_SCALE_Y(-2.0f); +#endif if (CWorld::Players[CWorld::PlayerInFocus].m_pPed && WeaponType == WEAPONTYPE_M16) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); @@ -654,7 +660,7 @@ void CHud::Draw() CFont::SetBackgroundOff(); CFont::SetBackGroundOnlyTextOn(); CFont::SetAlignment(ALIGN_RIGHT); - CFont::SetRightJustifyWrap(-SCREENW); + CFont::SetRightJustifyWrap(-SCREEN_WIDTH); CFont::SetFontStyle(FONT_HEADING); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); @@ -917,7 +923,7 @@ void CHud::Draw() CFont::SetCentreSize(SCREEN_SCALE_X(615.0f)); CFont::SetFontStyle(FONT_HEADING); - if (BigMessageX[0] >= (SCREENW - 20)) { + if (BigMessageX[0] >= (SCREEN_WIDTH - 20)) { BigMessageInUse[0] += (CTimer::GetTimeStep() * 0.02f * 120.0f); if (BigMessageInUse[0] >= 120.0f) { @@ -1190,7 +1196,7 @@ void CHud::DrawAfterFade() CFont::SetRightJustifyWrap(-500); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); - if (BigMessageX[1] >= (SCREENW - 20)) { + if (BigMessageX[1] >= (SCREEN_WIDTH - 20)) { BigMessageInUse[1] += (CTimer::GetTimeStep() * 0.02f * 120.0f); if (BigMessageInUse[1] >= 120.0f) { diff --git a/src/render/MBlur.h b/src/render/MBlur.h index baa82b80..42827f99 100644 --- a/src/render/MBlur.h +++ b/src/render/MBlur.h @@ -2,6 +2,7 @@ class CMBlur { +public: static RwRaster *&pFrontBuffer; static bool &ms_bJustInitialised; static bool &BlurOn; diff --git a/src/skel/win/win.h b/src/skel/win/win.h index a1f37bfd..69d38164 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -79,6 +79,10 @@ void CenterVideo(void); void CloseClip(void); RwChar **_psGetVideoModeList(); +RwInt32 _psGetNumVideModes(); + +void _psSelectScreenVM(RwInt32 videoMode); +void HandleExit(); #ifdef __cplusplus } -- cgit v1.2.3 From 7fae683316db64e772fb82833d73860cc16cf03a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 4 Jul 2019 01:16:24 +0300 Subject: Script stuff + bug fixes --- src/Camera.cpp | 2 + src/Camera.h | 2 + src/audio/DMAudio.cpp | 1 + src/audio/DMAudio.h | 1 + src/control/CarCtrl.cpp | 1 + src/control/CarCtrl.h | 1 + src/control/Population.cpp | 2 + src/control/Population.h | 2 + src/control/Replay.cpp | 2 +- src/control/Script.cpp | 161 +++++++++++++++++++++++++++++++++++++++++-- src/control/Script.h | 109 +++++++++++++++++++++++++++-- src/entities/PlayerInfo.cpp | 2 + src/entities/PlayerInfo.h | 2 + src/modelinfo/ModelIndices.h | 11 +++ src/render/Hud.cpp | 2 +- src/render/Hud.h | 2 +- 16 files changed, 288 insertions(+), 15 deletions(-) diff --git a/src/Camera.cpp b/src/Camera.cpp index e5e50ef2..d20ef5bb 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -20,6 +20,8 @@ bool &CCamera::m_bUseMouse3rdPerson = *(bool *)0x5F03D8; WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); } WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); } +WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); } +WRAPPER void CCamera::SetWidescreenOff(void) { EAXJMP(0x46FF10); } bool CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat) diff --git a/src/Camera.h b/src/Camera.h index 6d20de72..5c5f8a73 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -459,6 +459,8 @@ int m_iModeObbeCamIsInForCar; void CalculateDerivedValues(void); void DrawBordersForWideScreen(void); + void Restore(void); + void SetWidescreenOff(void); void dtor(void) { this->CCamera::~CCamera(); } }; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 824d5c39..60454bdd 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -33,3 +33,4 @@ WRAPPER int32 cDMAudio::CreateEntity(int, void*) { EAXJMP(0x57C7C0); } WRAPPER void cDMAudio::SetEntityStatus(int32 id, uint8 enable) { EAXJMP(0x57C810); } WRAPPER void cDMAudio::SetRadioInCar(int32) { EAXJMP(0x57CE60); } WRAPPER void cDMAudio::DestroyEntity(int32) { EAXJMP(0x57C7F0); } +WRAPPER void cDMAudio::ClearMissionAudio(void) { EAXJMP(0x57CE20); } \ No newline at end of file diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 46914aaa..72e8d316 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -203,5 +203,6 @@ public: void SetRadioInCar(int32); uint8 IsMP3RadioChannelAvailable(); void DestroyEntity(int32); + void ClearMissionAudio(void); }; extern cDMAudio &DMAudio; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 1b389631..b0f4c1ed 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -6,6 +6,7 @@ int &CCarCtrl::NumLawEnforcerCars = *(int*)0x8F1B38; int &CCarCtrl::NumAmbulancesOnDuty = *(int*)0x885BB0; int &CCarCtrl::NumFiretrucksOnDuty = *(int*)0x9411F0; bool &CCarCtrl::bCarsGeneratedAroundCamera = *(bool*)0x95CD8A; +float& CCarCtrl::CarDensityMultiplier = *(float*)0x5EC8B4; WRAPPER void CCarCtrl::SwitchVehicleToRealPhysics(CVehicle*) { EAXJMP(0x41F7F0); } WRAPPER void CCarCtrl::AddToCarArray(int32 id, int32 vehclass) { EAXJMP(0x4182F0); } diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h index 0195219e..c54f747f 100644 --- a/src/control/CarCtrl.h +++ b/src/control/CarCtrl.h @@ -14,4 +14,5 @@ public: static int32 &NumAmbulancesOnDuty; static int32 &NumFiretrucksOnDuty; static bool &bCarsGeneratedAroundCamera; + static float &CarDensityMultiplier; }; diff --git a/src/control/Population.cpp b/src/control/Population.cpp index 7b1acaaf..9af68670 100644 --- a/src/control/Population.cpp +++ b/src/control/Population.cpp @@ -5,6 +5,8 @@ PedGroup *CPopulation::ms_pPedGroups = (PedGroup*)0x6E9248; bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6; +int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; +float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); } WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); } diff --git a/src/control/Population.h b/src/control/Population.h index e93e14fc..4169261a 100644 --- a/src/control/Population.h +++ b/src/control/Population.h @@ -12,6 +12,8 @@ class CPopulation public: static PedGroup *ms_pPedGroups; //[31] static bool &ms_bGivePedsWeapons; + static int32 &m_AllRandomPedsThisType; + static float &PedDensityMultiplier; static void UpdatePedCount(uint32, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index b80b04ba..a2164f6b 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1572,7 +1572,7 @@ void CReplay::Display() if (Mode == MODE_RECORD) return; counter = (counter + 1) % 65536; - if (counter & 0x20 == 0) + if ((counter & 0x20) == 0) return; CFont::SetPropOn(); CFont::SetBackgroundOff(); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 153e98b5..e7f64541 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -3,12 +3,161 @@ #include "Script.h" -uint8 *CTheScripts::ScriptSpace = (uint8*)0x74B248; -CTextLine* CTheScripts::IntroTextLines = (CTextLine*)0x70EA74; -CScriptRectangle* CTheScripts::IntroRectangles = (CScriptRectangle*)0x72D109; -CSprite2d* CTheScripts::ScriptSprites = (CSprite2d*)0x72B090; -bool CTheScripts::DbgFlag = *(bool*)0x95CD87; -uint32 CTheScripts::OnAMissionFlag = *(uint32*)0x8F1B64; +#include "Camera.h" +#include "CarCtrl.h" +#include "DMAudio.h" +#include "Hud.h" +#include "ModelIndices.h" +#include "PlayerInfo.h" +#include "PlayerPed.h" +#include "Pools.h" +#include "Population.h" +#include "Streaming.h" +#include "User.h" +#include "Weather.h" +#include "World.h" +uint8 (&CTheScripts::ScriptSpace)[160 * 1024] = *(uint8(*)[160 * 1024])*(uintptr*)0x74B248; +CTextLine (&CTheScripts::IntroTextLines)[2] = *(CTextLine (*)[2])*(uintptr*)0x70EA74; +CScriptRectangle (&CTheScripts::IntroRectangles)[16] = *(CScriptRectangle (*)[16])*(uintptr*)0x72D108; +CSprite2d (&CTheScripts::ScriptSprites)[16] = *(CSprite2d(*)[16])*(uintptr*)0x72B090; +bool &CTheScripts::DbgFlag = *(bool*)0x95CD87; +uint32 &CTheScripts::OnAMissionFlag = *(uint32*)0x8F2A24; +int32 &CTheScripts::StoreVehicleIndex = *(int32*)0x8F5F3C; +bool &CTheScripts::StoreVehicleWasRandom = *(bool*)0x95CDBC; + +CMissionCleanup(&CTheScripts::MissionCleanup) = *(CMissionCleanup*)0x8F2AD8; +CUpsideDownCarCheck(&CTheScripts::UpsideDownCars) = *(CUpsideDownCarCheck*)0x6EE450; +CStuckCarCheck(&CTheScripts::StuckCars) = *(CStuckCarCheck*)0x87C588; + +CMissionCleanup::CMissionCleanup() +{ + Init(); +} + +void CMissionCleanup::Init() +{ + for (int i = 0; i < MAX_CLEANUP; i++){ + m_sEntities[i].type = CLEANUP_UNUSED; + m_sEntities[i].id = 0; + } +} + +CMissionCleanupEntity* CMissionCleanup::FindFree() +{ + for (int i = 0; i < MAX_CLEANUP; i++){ + if (m_sEntities[i].type == CLEANUP_UNUSED) + return &m_sEntities[i]; + } + assert(0); + return nil; +} + +void CMissionCleanup::AddEntityToList(int32 id, uint8 type) +{ + CMissionCleanupEntity* pNew = FindFree(); + if (!pNew) + return; + pNew->id = id; + pNew->type = type; + m_bCount++; +} + +void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) +{ + for (int i = 0; i < MAX_CLEANUP; i++){ + if (m_sEntities[i].type == type && m_sEntities[i].id == 0){ + m_sEntities[i].id = 0; + m_sEntities[i].type = CLEANUP_UNUSED; + } + } +} + +void CMissionCleanup::Process() +{ + CPopulation::m_AllRandomPedsThisType = -1; + CPopulation::PedDensityMultiplier = 1.0f; + CCarCtrl::CarDensityMultiplier = 1.0; + FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f; + TheCamera.Restore(); + TheCamera.SetWidescreenOff(); + DMAudio.ClearMissionAudio(); + CWeather::ReleaseWeather(); + for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++) + CStreaming::SetMissionDoesntRequireSpecialChar(i); + for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++) + CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i); + CStreaming::ms_disableStreaming = false; + CHud::m_ItemToFlash = -1; + CHud::SetHelpMessage(nil, false); + CUserDisplay::OnscnTimer.m_bDisabled = false; + CWorld::Players[0].m_pPed->m_pWanted->m_IsIgnoredByCops = false; + CWorld::Players[0].m_pPed->m_pWanted->m_IsIgnoredByEveryOne = false; + CWorld::Players[0].MakePlayerSafe(false); + CTheScripts::StoreVehicleIndex = -1; + CTheScripts::StoreVehicleWasRandom = true; + CTheScripts::UpsideDownCars.Init(); + CTheScripts::StuckCars.Init(); + for (int i = 0; i < MAX_CLEANUP; i++){ + if (m_sEntities[i].type == CLEANUP_UNUSED) + continue; + switch (m_sEntities[i].type) { + case CLEANUP_CAR: + { + CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); + if (v) + CTheScripts::CleanUpThisVehicle(v); + break; + } + case CLEANUP_CHAR: + { + CPed* p = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (p) + CTheScripts::CleanUpThisPed(p); + break; + } + case CLEANUP_OBJECT: + { + CObject* o = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); + if (o) + CTheScripts::CleanUpThisObject(o); + break; + } + default: + break; + } + } +} + +void CUpsideDownCarCheck::Init() +{ + for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ + m_sCars[i].m_nVehicleIndex = -1; + m_sCars[i].m_nVehicleIndex = 0; + } +} + +void CStuckCarCheck::Init() +{ + for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++) { + m_sCars[i].m_nVehicleIndex = -1; + m_sCars[i].m_vecPos = CVector(-5000.0f, -5000.0f, -5000.0f); + m_sCars[i].m_nStartTime = -1; + m_sCars[i].m_fDistance = 0.0f; + m_sCars[i].m_nStuckTime = 0; + m_sCars[i].m_bStuck = false; + } +} + +WRAPPER void CTheScripts::CleanUpThisVehicle(CVehicle*) { EAXJMP(0x4548D0); } +WRAPPER void CTheScripts::CleanUpThisPed(CPed*) { EAXJMP(0x4547A0); } +WRAPPER void CTheScripts::CleanUpThisObject(CObject*) { EAXJMP(0x454910); } WRAPPER bool CTheScripts::IsPlayerOnAMission() { EAXJMP(0x439410); } WRAPPER void CTheScripts::ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2) { EAXJMP(0x4534E0); } + +STARTPATCHES +InjectHook(0x437AE0, &CMissionCleanup::Init, PATCH_JUMP); +InjectHook(0x437BA0, &CMissionCleanup::AddEntityToList, PATCH_JUMP); +InjectHook(0x437BD0, &CMissionCleanup::RemoveEntityFromList, PATCH_JUMP); +InjectHook(0x437C10, &CMissionCleanup::Process, PATCH_JUMP); +ENDPATCHES \ No newline at end of file diff --git a/src/control/Script.h b/src/control/Script.h index 1eb02c1b..7b62a1b0 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,5 +1,8 @@ #pragma once +#include "Ped.h" +#include "Object.h" #include "Sprite2d.h" +#include "Vehicle.h" struct CScriptRectangle { @@ -32,17 +35,111 @@ struct CTextLine wchar m_awText[500]; }; +struct CRunningScript +{ + CRunningScript *next; + CRunningScript *prev; + uint8 m_abScriptName[8]; + uint32 m_nIp; + uint32 m_anStack[6]; + uint16 m_nStackPointer; + void* m_anLocalVariables[18]; + bool m_bCondResult; + bool m_bIsMissionThread; + bool m_bSkipWakeTime; + uint32 m_nWakeTime; + uint16 m_wIfOp; + bool m_bNotFlag; + bool m_bWBCheck; + bool m_bWastedOrBusted; + bool m_bMissionFlag; +}; + +enum { + CLEANUP_UNUSED = 0, + CLEANUP_CAR, + CLEANUP_CHAR, + CLEANUP_OBJECT +}; + +struct CMissionCleanupEntity +{ + uint8 type; + int32 id; +}; + +enum { + MAX_CLEANUP = 50, + MAX_UPSIDEDOWN_CAR_CHECKS = 6, + MAX_STUCK_CAR_CHECKS = 6 +}; + +class CMissionCleanup +{ + CMissionCleanupEntity m_sEntities[MAX_CLEANUP]; + uint8 m_bCount; + +public: + CMissionCleanup(); + + void Init(); + CMissionCleanupEntity* FindFree(); + void AddEntityToList(int32, uint8); + void RemoveEntityFromList(int32, uint8); + void Process(); +}; + +struct CUpsideDownCarCheckEntry +{ + int32 m_nVehicleIndex; + uint32 m_nUpsideDownTimer; +}; + +class CUpsideDownCarCheck +{ + CUpsideDownCarCheckEntry m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS]; + +public: + void Init(); +}; + +struct CStuckCarCheckEntry +{ + int32 m_nVehicleIndex; + CVector m_vecPos; + int32 m_nStartTime; + float m_fDistance; + uint32 m_nStuckTime; + bool m_bStuck; +}; + +class CStuckCarCheck +{ + CStuckCarCheckEntry m_sCars[MAX_STUCK_CAR_CHECKS]; + +public: + void Init(); +}; + class CTheScripts { public: - static uint8 *ScriptSpace;//[160*1024] - static CTextLine* IntroTextLines; - static CScriptRectangle* IntroRectangles; - static CSprite2d* ScriptSprites; - static bool DbgFlag; - static uint32 OnAMissionFlag; + static uint8(&ScriptSpace)[160 * 1024]; + static CTextLine(&IntroTextLines)[2]; + static CScriptRectangle(&IntroRectangles)[16]; + static CSprite2d(&ScriptSprites)[16]; + static bool &DbgFlag; + static uint32 &OnAMissionFlag; + static CMissionCleanup &MissionCleanup; + static CStuckCarCheck &StuckCars; + static CUpsideDownCarCheck &UpsideDownCars; + static int32 &StoreVehicleIndex; + static bool &StoreVehicleWasRandom; public: static bool IsPlayerOnAMission(); static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2); + static void CleanUpThisVehicle(CVehicle*); + static void CleanUpThisPed(CPed*); + static void CleanUpThisObject(CObject*); }; diff --git a/src/entities/PlayerInfo.cpp b/src/entities/PlayerInfo.cpp index 796481a4..59efe2ae 100644 --- a/src/entities/PlayerInfo.cpp +++ b/src/entities/PlayerInfo.cpp @@ -1,3 +1,5 @@ #include "common.h" #include "patcher.h" #include "PlayerInfo.h" + +WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); } \ No newline at end of file diff --git a/src/entities/PlayerInfo.h b/src/entities/PlayerInfo.h index 79f379d5..e2b42fe7 100644 --- a/src/entities/PlayerInfo.h +++ b/src/entities/PlayerInfo.h @@ -65,6 +65,8 @@ public: bool m_bGetOutOfHospitalFree; uint8 m_aSkinName[32]; RwTexture *m_pSkinTexture; + + void MakePlayerSafe(bool); }; static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error"); diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index 3a37ac23..ff350b55 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -330,6 +330,12 @@ enum MI_BOMB, MI_FINGERS, + MI_CUTOBJ01 = 185, + MI_CUTOBJ02, + MI_CUTOBJ03, + MI_CUTOBJ04, + MI_CUTOBJ05, + MI_CAR_DOOR = 190, MI_CAR_BUMPER, MI_CAR_PANEL, @@ -345,6 +351,11 @@ enum NUM_DEFAULT_MODELS, }; +enum{ + NUM_OF_SPECIAL_CHARS = 4, + NUM_OF_CUTSCENE_OBJECTS = 5 +}; + void InitModelIndices(void); void MatchModelString(const char *name, int16 id); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 0e132392..d36675cf 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -47,7 +47,7 @@ wchar *CHud::m_PagerMessage = (wchar*)0x878840; bool &CHud::m_Wants_To_Draw_Hud = *(bool*)0x95CD89; bool &CHud::m_Wants_To_Draw_3dMarkers = *(bool*)0x95CD62; wchar(*CHud::m_BigMessage)[128] = (wchar(*)[128])0x664CE0; -int32 CHud::m_ItemToFlash = *(int32*)0x95CC82; +int32 &CHud::m_ItemToFlash = *(int32*)0x95CC82; // These aren't really in CHud float CHud::BigMessageInUse[6]; diff --git a/src/render/Hud.h b/src/render/Hud.h index 1c82b7df..df02b4d0 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -62,7 +62,7 @@ public: static bool &m_Wants_To_Draw_Hud; static bool &m_Wants_To_Draw_3dMarkers; static wchar(*m_BigMessage)[128]; - static int32 m_ItemToFlash; + static int32 &m_ItemToFlash; // These aren't really in CHud static float BigMessageInUse[6]; -- cgit v1.2.3 From 835b7cac2201d09d16b0ea5fcc34e101e8261c2d Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 4 Jul 2019 01:23:19 +0300 Subject: Fixed type of m_ItemToFlash --- src/render/Hud.cpp | 2 +- src/render/Hud.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index d36675cf..081aaa64 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -47,7 +47,7 @@ wchar *CHud::m_PagerMessage = (wchar*)0x878840; bool &CHud::m_Wants_To_Draw_Hud = *(bool*)0x95CD89; bool &CHud::m_Wants_To_Draw_3dMarkers = *(bool*)0x95CD62; wchar(*CHud::m_BigMessage)[128] = (wchar(*)[128])0x664CE0; -int32 &CHud::m_ItemToFlash = *(int32*)0x95CC82; +int16 &CHud::m_ItemToFlash = *(int16*)0x95CC82; // These aren't really in CHud float CHud::BigMessageInUse[6]; diff --git a/src/render/Hud.h b/src/render/Hud.h index df02b4d0..1567abdc 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -62,7 +62,7 @@ public: static bool &m_Wants_To_Draw_Hud; static bool &m_Wants_To_Draw_3dMarkers; static wchar(*m_BigMessage)[128]; - static int32 &m_ItemToFlash; + static int16 &m_ItemToFlash; // These aren't really in CHud static float BigMessageInUse[6]; -- cgit v1.2.3