diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-03-17 19:03:13 +0100 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-03-21 12:58:54 +0100 |
commit | d5a6e17079ab87b946132155bbe37bd20e27c239 (patch) | |
tree | 87a72ec36821bb04d9c08ed0e5730c2393b8fcf4 /src | |
parent | Merge pull request #346 from Sergeanur/Radar2 (diff) | |
download | re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar.gz re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar.bz2 re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar.lz re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar.xz re3-d5a6e17079ab87b946132155bbe37bd20e27c239.tar.zst re3-d5a6e17079ab87b946132155bbe37bd20e27c239.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/control/CarCtrl.cpp | 4 | ||||
-rw-r--r-- | src/control/Gangs.cpp | 15 | ||||
-rw-r--r-- | src/control/Gangs.h | 8 | ||||
-rw-r--r-- | src/control/Garages.cpp | 4 | ||||
-rw-r--r-- | src/core/ControllerConfig.cpp | 2 | ||||
-rw-r--r-- | src/core/Frontend.cpp | 2191 | ||||
-rw-r--r-- | src/core/Frontend.h | 116 | ||||
-rw-r--r-- | src/core/MenuScreens.h | 47 | ||||
-rw-r--r-- | src/core/Pad.h | 18 | ||||
-rw-r--r-- | src/core/config.h | 1 | ||||
-rw-r--r-- | src/modelinfo/PedModelInfo.h | 3 | ||||
-rw-r--r-- | src/peds/CopPed.cpp | 14 | ||||
-rw-r--r-- | src/peds/Ped.cpp | 8 | ||||
-rw-r--r-- | src/peds/PedStats.cpp | 14 | ||||
-rw-r--r-- | src/peds/PedStats.h | 4 | ||||
-rw-r--r-- | src/peds/PedType.cpp | 7 | ||||
-rw-r--r-- | src/peds/Population.cpp | 11 | ||||
-rw-r--r-- | src/peds/Population.h | 2 |
18 files changed, 1738 insertions, 731 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index ab7a4aa1..de8c799e 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -596,10 +596,10 @@ CCarCtrl::ChooseCarModel(int32 vehclass) case TAXI: { if (TotalNumOfCarsOfRating[vehclass] == 0) - debug("ChooseCarModel : No cars of type %d have been declared\n"); + debug("ChooseCarModel : No cars of type %d have been declared\n", vehclass); model = CarArrays[vehclass][NextCarOfRating[vehclass]]; int32 total = TotalNumOfCarsOfRating[vehclass]; - NextCarOfRating[vehclass] += 1 + CGeneral::GetRandomNumberInRange(0, total - 1); + NextCarOfRating[vehclass] += CGeneral::GetRandomNumberInRange(1, total); while (NextCarOfRating[vehclass] >= total) NextCarOfRating[vehclass] -= total; //NextCarOfRating[vehclass] %= total; diff --git a/src/control/Gangs.cpp b/src/control/Gangs.cpp index f6f9261e..6be1ef9c 100644 --- a/src/control/Gangs.cpp +++ b/src/control/Gangs.cpp @@ -3,7 +3,8 @@ #include "ModelIndices.h" #include "Gangs.h" -CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[NUM_GANGS])*(uintptr*)0x6EDF78; +//CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[NUM_GANGS])*(uintptr*)0x6EDF78; +CGangInfo CGangs::Gang[NUM_GANGS]; CGangInfo::CGangInfo() : m_nVehicleMI(MI_BUS), @@ -30,11 +31,11 @@ void CGangs::SetGangVehicleModel(int16 gang, int32 model) GetGangInfo(gang)->m_nVehicleMI = model; } -void CGangs::SetGangWeapons(int16 gang, eWeaponType weapon1, eWeaponType weapon2) +void CGangs::SetGangWeapons(int16 gang, int32 weapon1, int32 weapon2) { CGangInfo *gi = GetGangInfo(gang); - gi->m_Weapon1 = weapon1; - gi->m_Weapon2 = weapon2; + gi->m_Weapon1 = (eWeaponType)weapon1; + gi->m_Weapon2 = (eWeaponType)weapon2; } void CGangs::SetGangPedModelOverride(int16 gang, int8 ovrd) @@ -64,11 +65,11 @@ void CGangs::LoadAllGangData(uint8 *buf, uint32 size) Initialize();
INITSAVEBUF
-
- WriteSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); + // original: SkipSaveBuf(buf, SAVE_HEADER_SIZE);
+ CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); + for (int i = 0; i < NUM_GANGS; i++) Gang[i] = ReadSaveBuf<CGangInfo>(buf); - VALIDATESAVEBUF(size); } diff --git a/src/control/Gangs.h b/src/control/Gangs.h index 93ebe663..1ffc5ddd 100644 --- a/src/control/Gangs.h +++ b/src/control/Gangs.h @@ -34,18 +34,16 @@ class CGangs public: static void Initialize(void); static void SetGangVehicleModel(int16, int32); - static void SetGangWeapons(int16, eWeaponType, eWeaponType); + static void SetGangWeapons(int16, int32, int32); static void SetGangPedModelOverride(int16, int8); static int8 GetGangPedModelOverride(int16); static void SaveAllGangData(uint8 *, uint32 *); static void LoadAllGangData(uint8 *, uint32); static int32 GetGangVehicleModel(int16 gang) { return Gang[gang].m_nVehicleMI; } - static eWeaponType GetGangWeapon1(int16 gang) { return Gang[gang].m_Weapon1; } - static eWeaponType GetGangWeapon2(int16 gang) { return Gang[gang].m_Weapon2; } - static CGangInfo* GetGangInfo(int16 gang) { return &Gang[gang]; } + static CGangInfo *GetGangInfo(int16 gang) { return &Gang[gang]; } private: - static CGangInfo(&Gang)[NUM_GANGS]; + static CGangInfo Gang[NUM_GANGS]; }; diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 9f300257..5ac15377 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -14,7 +14,7 @@ int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34; bool &CGarages::BombsAreFree = *(bool *)0x95CD7A; bool &CGarages::RespraysAreFree = *(bool *)0x95CD1D; int32 &CGarages::CarsCollected = *(int32 *)0x880E18; -int32 (&CGarages::CarTypesCollected)[TOTAL_COLLECTCARS_GARAGES] = *(int32 (*)[TOTAL_COLLECTCARS_GARAGES])(uintptr*)0x8E286C; +int32 (&CGarages::CarTypesCollected)[TOTAL_COLLECTCARS_GARAGES] = *(int32 (*)[TOTAL_COLLECTCARS_GARAGES])*(uintptr*)0x8E286C; int32 &CGarages::CrushedCarId = *(int32 *)0x943060; uint32 &CGarages::LastTimeHelpMessage = *(uint32 *)0x8F1B58; int32 &CGarages::MessageNumberInString = *(int32 *)0x885BA8; @@ -27,7 +27,7 @@ bool &CGarages::PlayerInGarage = *(bool *)0x95CD83; int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444; uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570; -CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])(uintptr*)0x72BCD0; +CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])*(uintptr*)0x72BCD0; WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); } WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); } diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 02230df7..92c51182 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2327,7 +2327,7 @@ void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action) bool init = false; - if (isexist) + if (!isexist) { for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++) { diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 069a9caf..4c2f3afa 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -28,7 +28,21 @@ #include "Renderer.h" #include "CdStream.h" -#define ALL_ORIGINAL_FRONTEND 1 +#define DONT_USE_SUSPICIOUS_FUNCS 1 +#define TIDY_UP_PBP // ProcessButtonPresses +#define MAX_VISIBLE_LIST_ROW 30 +#define LIST_HEIGHT 263.0f + +#ifdef PS2_LIKE_MENU +BottomBarOption bbNames[8]; +int bbTabCount = 0; +bool bottomBarActive = false; +bool reverseAlpha = false; +int pendingScreen = -1; +int pendingOption = -1; +int curBottomBarOption = -1; +int hoveredBottomBarOption = -1; +#endif WRAPPER void CMenuManager::PrintController(void) { EAXJMP(0x483990); } @@ -65,8 +79,8 @@ float &CMenuManager::menuXYpadding = *(float*)0x5F355C; // don't know the origin float &CMenuManager::actionTextScaleX = *(float*)0x5F2E40; float &CMenuManager::actionTextScaleY = *(float*)0x5F2E44; -int& CMenuManager::sthWithButtons = *(int32*)0x8E2880; -int &CMenuManager::sthWithButtons2 = *(int32*)0x942F88; +int32 &CMenuManager::sthWithButtons = *(int32*)0x8E2880; +int32 &CMenuManager::sthWithButtons2 = *(int32*)0x942F88; CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; @@ -80,30 +94,10 @@ int32 *&pControlEdit = *(int32**)0x628D08; bool &DisplayComboButtonErrMsg = *(bool*)0x628D14; int32 &MouseButtonJustClicked = *(int32*)0x628D0C; int32 &JoyButtonJustClicked = *(int32*)0x628D10; -int32 &nTimeForSomething = *(int32*)0x628D54; +uint32 &nTimeForSomething = *(uint32*)0x628D54; +bool &holdingScrollBar = *(bool*)0x628D59; //int32 *pControlTemp = 0; -// Frontend inputs. -bool GetPadBack(); -bool GetPadExitEnter(); -bool GetPadForward(); -bool GetPadMoveUp(); -bool GetPadMoveDown(); -bool GetPadMoveLeft(); -bool GetPadMoveRight(); -bool GetMouseClickLeft(); -bool GetMouseClickRight(); -bool GetMouseClickMiddle(); -bool GetMouseWheelUp(); -bool GetMouseWheelDown(); -bool GetMouseForward(); -bool GetMouseBack(); -bool GetMousePos(); -bool GetMouseMoveLeft(); -bool GetMouseMoveRight(); -bool GetPadInput(); -bool GetMouseInput(); - // 0x5F311C const char* FrontendFilenames[][2] = { {"fe2_mainpanel_ul", "" }, @@ -186,6 +180,123 @@ ScaleAndCenterX(float x) #define MENU_Y(y) StretchY(y) #endif +#define isPlainTextScreen(screen) (screen == MENUPAGE_BRIEFS || screen == MENUPAGE_STATS) +#ifdef PS2_LIKE_MENU +#define ChangeScreen(screen, option, updateDelay, withReverseAlpha) \ + do { \ + if (reverseAlpha) { \ + m_nPrevScreen = m_nCurrScreen; \ + m_nCurrScreen = pendingScreen; \ + m_nCurrOption = pendingOption; \ + reverseAlpha = false; \ + if (updateDelay) \ + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); \ + } \ + if (withReverseAlpha) { \ + pendingOption = option; \ + pendingScreen = screen; \ + reverseAlpha = true; \ + } else { \ + m_nPrevScreen = m_nCurrScreen; \ + m_nCurrScreen = screen; \ + m_nCurrOption = option; \ + if (updateDelay) \ + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); \ + } \ + m_nMenuFadeAlpha = 255; \ + } while(0) +#else +#define ChangeScreen(screen, option, updateDelay, clearAlpha) \ + do { \ + m_nPrevScreen = m_nCurrScreen; \ + m_nCurrScreen = screen; \ + m_nCurrOption = option; \ + if(updateDelay) \ + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); \ + if(clearAlpha) \ + m_nMenuFadeAlpha = 0; \ + } while(0) +#endif + +#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \ + do { \ + lastBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ + if (i != m_nCurrOption || !itemsAreSelectable) \ + break; \ + \ + if (CheckHover(hoverStartX, lastBarX - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ + m_nHoverOption = decreaseAction; \ + \ + if (!CheckHover(MENU_X(10.0f) + lastBarX, hoverEndX, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ + break; \ + \ + m_nHoverOption = increaseAction; \ + if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) \ + m_nHoverOption = HOVEROPTION_NOT_HOVERING; \ + } while(0) + +#define ScrollUpListByOne() \ + do { \ + if (m_nSelectedListRow == m_nFirstVisibleRowOnList) { \ + if (m_nFirstVisibleRowOnList > 0) { \ + m_nSelectedListRow--; \ + m_nFirstVisibleRowOnList--; \ + m_nCurListItemY -= LIST_HEIGHT / m_nTotalListRow; \ + } \ + } else { \ + m_nSelectedListRow--; \ + } \ + } while(0) + +#define ScrollDownListByOne() \ + do { \ + if (m_nSelectedListRow == m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1) { \ + if (m_nFirstVisibleRowOnList < m_nTotalListRow - MAX_VISIBLE_LIST_ROW) { \ + m_nSelectedListRow++; \ + m_nFirstVisibleRowOnList++; \ + m_nCurListItemY += LIST_HEIGHT / m_nTotalListRow; \ + } \ + } else { \ + if (m_nSelectedListRow < m_nTotalListRow - 1) { \ + m_nSelectedListRow++; \ + } \ + } \ + } while(0) + +#define PageUpList(playSoundOnSuccess) \ + do { \ + if (m_nTotalListRow > MAX_VISIBLE_LIST_ROW) { \ + if (m_nFirstVisibleRowOnList > 0) { \ + if(playSoundOnSuccess) \ + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); \ + \ + m_nFirstVisibleRowOnList = max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW); \ + m_nSelectedListRow = min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1); \ + } else { \ + m_nFirstVisibleRowOnList = 0; \ + m_nSelectedListRow = 0; \ + } \ + m_nCurListItemY = (LIST_HEIGHT / m_nTotalListRow) * m_nFirstVisibleRowOnList; \ + } \ + } while(0) + +#define PageDownList(playSoundOnSuccess) \ + do { \ + if (m_nTotalListRow > MAX_VISIBLE_LIST_ROW) { \ + if (m_nFirstVisibleRowOnList < m_nTotalListRow - MAX_VISIBLE_LIST_ROW) { \ + if(playSoundOnSuccess) \ + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); \ + \ + m_nFirstVisibleRowOnList = min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW); \ + m_nSelectedListRow = max(m_nSelectedListRow, m_nFirstVisibleRowOnList); \ + } else { \ + m_nFirstVisibleRowOnList = m_nTotalListRow - MAX_VISIBLE_LIST_ROW; \ + m_nSelectedListRow = m_nTotalListRow - 1; \ + } \ + m_nCurListItemY = (LIST_HEIGHT / m_nTotalListRow) * m_nFirstVisibleRowOnList; \ + } \ + } while(0) + void CMenuManager::BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2) { @@ -251,11 +362,14 @@ void CMenuManager::CheckSliderMovement(int value) { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_BRIGHTNESS: - m_PrefsBrightness += m_PrefsBrightness + value * (512/16); + m_PrefsBrightness += value * (512/16); m_PrefsBrightness = clamp(m_PrefsBrightness, 0, 511); break; case MENUACTION_DRAWDIST: - m_PrefsLOD += value * ((1.8f - 0.8f)/16.0f); + if(value > 0) + m_PrefsLOD += ((1.8f - 0.8f) / 16.0f); + else + m_PrefsLOD -= ((1.8f - 0.8f) / 16.0f); m_PrefsLOD = clamp(m_PrefsLOD, 0.8f, 1.8f); CRenderer::ms_lodDistScale = m_PrefsLOD; break; @@ -289,7 +403,7 @@ int CMenuManager::CostructStatLine(int) } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } #else void CMenuManager::DisplayHelperText() @@ -342,7 +456,7 @@ void CMenuManager::DisplayHelperText() } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER int CMenuManager::DisplaySlider(float, float, float, float, float, float) { EAXJMP(0x488420); } #else int CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightSize, float rectSize, float progress) @@ -378,7 +492,7 @@ WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } #else void CMenuManager::DoSettingsBeforeStartingAGame() { - CCamera::m_bUseMouse3rdPerson = m_ControlMethod == 0; + CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDART; if (m_PrefsVsyncDisp != m_PrefsVsync) m_PrefsVsync = m_PrefsVsyncDisp; @@ -423,11 +537,18 @@ void CMenuManager::Draw() if(!m_bRenderGameInMenu) #endif if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') { - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); +#ifdef PS2_LIKE_MENU + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(1.3f)); + CFont::PrintString(MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(75.0f), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); +#else + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); +#endif // Weird place to put that. nextYToUse += 24.0f + 10.0f; } @@ -474,7 +595,11 @@ void CMenuManager::Draw() CFont::SetCentreSize(SCREEN_WIDTH); +#ifdef PS2_LIKE_MENU + bool itemsAreSelectable = !bottomBarActive; +#else bool itemsAreSelectable = true; +#endif int lineHeight; int headerHeight; int columnWidth; @@ -568,7 +693,7 @@ void CMenuManager::Draw() case MENUPAGE_CONTROLLER_PC_OLD3: case MENUPAGE_CONTROLLER_PC_OLD4: case MENUPAGE_CONTROLLER_DEBUG: - if (field_113) + if (m_bWaitingForNewKeyBind) itemsAreSelectable = false; CMenuManager::DrawControllerScreenExtraText(nextYToUse - 8.0f, 350, lineHeight); @@ -855,11 +980,11 @@ void CMenuManager::Draw() if (lastScreen == m_nPrevScreen) lastScreen = m_nCurrScreen; - m_nHoverOption = HOVEROPTION_DEFAULT; + m_nHoverOption = HOVEROPTION_RANDOM_ITEM; foundTheHoveringItem = true; break; } - m_nHoverOption = HOVEROPTION_42; + m_nHoverOption = HOVEROPTION_NOT_HOVERING; nextYToCheck += extraOffset + lineHeight; } } @@ -874,6 +999,7 @@ void CMenuManager::Draw() SCREEN_STRETCH_FROM_RIGHT(11.0f), MENU_Y(usableLineHeight + nextItemY)), CRGBA(100, 200, 50, FadeIn(50))); } + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90))); // Button and it's shadow @@ -894,7 +1020,7 @@ void CMenuManager::Draw() } CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText); } - if (i == m_nCurrOption && itemsAreSelectable) { + if (i == m_nCurrOption && itemsAreSelectable){ CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); } else { CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); @@ -919,14 +1045,15 @@ void CMenuManager::Draw() } if (m_nPrefsAudio3DProviderIndex != DMAudio.GetCurrent3DProviderIndex()) { if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEA_3DH") != 0 - && m_nCurrScreen == 5 && m_nPrefsAudio3DProviderIndex != -1) { + && m_nCurrScreen == MENUPAGE_SOUND_SETTINGS && m_nPrefsAudio3DProviderIndex != -1) { m_nPrefsAudio3DProviderIndex = DMAudio.GetCurrent3DProviderIndex(); SetHelperText(3); } } if (m_nDisplayVideoMode != m_nPrefsVideoMode) { - if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_RES") != 0 && m_nCurrScreen == 6) { + if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_RES") != 0 + && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { m_nDisplayVideoMode = m_nPrefsVideoMode; SetHelperText(3); } @@ -934,91 +1061,29 @@ void CMenuManager::Draw() // Sliders // We stretch slider start X here(like original code), because it will always be center of screen - int sliderValue; + int lastBarX; switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { - case MENUACTION_BRIGHTNESS: { - sliderValue = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), m_PrefsBrightness / 512.0f); - if (i != m_nCurrOption || !itemsAreSelectable) - break; - - if (CheckHover(MENU_X_LEFT_ALIGNED(170.0f), sliderValue - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - m_nHoverOption = HOVEROPTION_DECREASE_BRIGHTNESS; - - if (!CheckHover(MENU_X(10.0f) + sliderValue, SCREEN_WIDTH, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - break; - - m_nHoverOption = HOVEROPTION_INCREASE_BRIGHTNESS; - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) - m_nHoverOption = HOVEROPTION_42; + case MENUACTION_BRIGHTNESS: + ProcessSlider(m_PrefsBrightness / 512.0f, HOVEROPTION_INCREASE_BRIGHTNESS, HOVEROPTION_DECREASE_BRIGHTNESS, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH); break; - } - case MENUACTION_DRAWDIST: { - sliderValue = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), (m_PrefsLOD - 0.8f) * 1.0f); - if (i != m_nCurrOption || !itemsAreSelectable) - break; - - if (CheckHover(MENU_X_LEFT_ALIGNED(170.0f), sliderValue - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - m_nHoverOption = HOVEROPTION_DECREASE_DRAWDIST; - - if (!CheckHover(MENU_X(10.0f) + sliderValue, SCREEN_WIDTH, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - break; - - m_nHoverOption = HOVEROPTION_INCREASE_DRAWDIST; - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) - m_nHoverOption = HOVEROPTION_42; + case MENUACTION_DRAWDIST: + ProcessSlider((m_PrefsLOD - 0.8f) * 1.0f, HOVEROPTION_INCREASE_DRAWDIST, HOVEROPTION_DECREASE_DRAWDIST, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH); break; - } - case MENUACTION_MUSICVOLUME: { - sliderValue = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), m_PrefsMusicVolume / 128.0f); - if (i != m_nCurrOption || !itemsAreSelectable) - break; - - if (CheckHover(MENU_X_LEFT_ALIGNED(170.0f), sliderValue - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - m_nHoverOption = HOVEROPTION_DECREASE_MUSICVOLUME; - - if (!CheckHover(MENU_X(10.0f) + sliderValue, SCREEN_WIDTH, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - break; - m_nHoverOption = HOVEROPTION_INCREASE_MUSICVOLUME; - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) - m_nHoverOption = HOVEROPTION_42; + case MENUACTION_MUSICVOLUME: + ProcessSlider(m_PrefsMusicVolume / 128.0f, HOVEROPTION_INCREASE_MUSICVOLUME, HOVEROPTION_DECREASE_MUSICVOLUME, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH); break; - } - case MENUACTION_SFXVOLUME: { - sliderValue = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), m_PrefsSfxVolume / 128.0f); - if (i != m_nCurrOption || !itemsAreSelectable) - break; - - if (CheckHover(MENU_X_LEFT_ALIGNED(170.0f), sliderValue - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - m_nHoverOption = HOVEROPTION_DECREASE_SFXVOLUME; - - if (!CheckHover(MENU_X(10.0f) + sliderValue, SCREEN_WIDTH, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - break; - m_nHoverOption = HOVEROPTION_INCREASE_SFXVOLUME; - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) - m_nHoverOption = HOVEROPTION_42; + case MENUACTION_SFXVOLUME: + ProcessSlider(m_PrefsSfxVolume / 128.0f, HOVEROPTION_INCREASE_SFXVOLUME, HOVEROPTION_DECREASE_SFXVOLUME, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH); break; - } - case MENUACTION_MOUSESENS: { - sliderValue = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(freeSpaceInLine), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), TheCamera.m_fMouseAccelHorzntl * 200.0f); - if (i != m_nCurrOption || !itemsAreSelectable) - break; - - if (CheckHover(MENU_X_LEFT_ALIGNED(200.0f), sliderValue - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - m_nHoverOption = HOVEROPTION_DECREASE_MOUSESENS; - - if (!CheckHover(MENU_X(10.0f) + sliderValue, SCREEN_WIDTH, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) - break; - m_nHoverOption = HOVEROPTION_INCREASE_MOUSESENS; - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) - m_nHoverOption = HOVEROPTION_42; + case MENUACTION_MOUSESENS: + ProcessSlider(TheCamera.m_fMouseAccelHorzntl * 200.0f, HOVEROPTION_INCREASE_MOUSESENS, HOVEROPTION_DECREASE_MOUSESENS, MENU_X_LEFT_ALIGNED(200.0f), SCREEN_WIDTH); break; - } } nextYToUse += lineHeight * CFont::GetNumberLines(menuXYpadding, nextYToUse, leftText); - // Radio icons. - // TO-DO: This is missing/broken + // TODO: This should be rewritten as multiple macro calls instead of loop, radio order is wrong. + // And hover detection is missing. float fIconSpacing = 59.52f; if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_RADIO) { for (int i = 0; i < POLICE_RADIO; i++) { @@ -1096,12 +1161,45 @@ void CMenuManager::DrawFrontEnd() { CFont::SetAlphaFade(255.0f); +#ifdef PS2_LIKE_MENU if (m_nCurrScreen == MENUPAGE_NONE) { - if (m_bGameNotLoaded) + if (m_bGameNotLoaded) { + if (bbTabCount != 6) { + bbNames[0] = { "FEB_SAV",MENUPAGE_NEW_GAME }; + bbNames[1] = { "FEB_CON",MENUPAGE_CONTROLLER_PC }; + bbNames[2] = { "FEB_AUD",MENUPAGE_SOUND_SETTINGS }; + bbNames[3] = { "FEB_DIS",MENUPAGE_GRAPHICS_SETTINGS }; + bbNames[4] = { "FEB_LAN",MENUPAGE_LANGUAGE_SETTINGS }; + bbNames[5] = { "FESZ_QU",MENUPAGE_EXIT }; + bbTabCount = 6; + } + m_nCurrScreen = MENUPAGE_NEW_GAME; + } else { + if (bbTabCount != 8) { + bbNames[0] = { "FEB_STA",MENUPAGE_STATS }; + bbNames[1] = { "FEB_SAV",MENUPAGE_NEW_GAME }; + bbNames[2] = { "FEB_BRI",MENUPAGE_BRIEFS }; + bbNames[3] = { "FEB_CON",MENUPAGE_CONTROLLER_PC }; + bbNames[4] = { "FEB_AUD",MENUPAGE_SOUND_SETTINGS }; + bbNames[5] = { "FEB_DIS",MENUPAGE_GRAPHICS_SETTINGS }; + bbNames[6] = { "FEB_LAN",MENUPAGE_LANGUAGE_SETTINGS }; + bbNames[7] = { "FESZ_QU",MENUPAGE_EXIT }; + bbTabCount = 8; + } + m_nCurrScreen = MENUPAGE_STATS; + } + bottomBarActive = true; + curBottomBarOption = 0; + } +#else + if (m_nCurrScreen == MENUPAGE_NONE) { + if (m_bGameNotLoaded) { m_nCurrScreen = MENUPAGE_START_MENU; - else + } else { m_nCurrScreen = MENUPAGE_PAUSE_MENU; + } } +#endif if (m_nCurrOption == 0 && aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) m_nCurrOption = 1; @@ -1159,14 +1257,194 @@ void CMenuManager::DrawFrontEndSaveZone() } #endif +#ifdef PS2_LIKE_MENU void CMenuManager::DrawFrontEndNormal() { CSprite2d::InitPerFrame(); CFont::InitPerFrame(); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); - LoadSplash(nil); + if (!m_bGameNotLoaded) { + CSprite2d *bg = LoadSplash(nil); + bg->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + } else { + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255)); + } + + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + m_aFrontEndSprites[FE2_MAINPANEL_UL].Draw(CRect(MENU_X_LEFT_ALIGNED(0.0f), 0.0f, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2), CRGBA(255, 255, 255, 255)); + m_aFrontEndSprites[FE2_MAINPANEL_UR].Draw(CRect(SCREEN_WIDTH / 2, 0.0f, MENU_X_RIGHT_ALIGNED(0.0f), SCREEN_HEIGHT / 2), CRGBA(255, 255, 255, 255)); + m_aFrontEndSprites[FE2_MAINPANEL_DL].Draw(CRect(MENU_X_LEFT_ALIGNED(0.0f), SCREEN_HEIGHT / 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + m_aFrontEndSprites[FE2_MAINPANEL_DR].Draw(CRect(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, MENU_X_RIGHT_ALIGNED(0.0f), SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + eFrontendSprites currentSprite; + switch (m_nCurrScreen) { + case MENUPAGE_STATS: + case MENUPAGE_NEW_GAME: + case MENUPAGE_START_MENU: + case MENUPAGE_PAUSE_MENU: + case MENUPAGE_EXIT: + currentSprite = FE_ICONSTATS; + break; + case MENUPAGE_LANGUAGE_SETTINGS: + currentSprite = FE_ICONLANGUAGE; + break; + case MENUPAGE_CHOOSE_LOAD_SLOT: + case MENUPAGE_CHOOSE_DELETE_SLOT: + case MENUPAGE_NEW_GAME_RELOAD: + case MENUPAGE_LOAD_SLOT_CONFIRM: + case MENUPAGE_DELETE_SLOT_CONFIRM: + currentSprite = FE_ICONSAVE; + break; + case MENUPAGE_GRAPHICS_SETTINGS: + currentSprite = FE_ICONDISPLAY; + break; + case MENUPAGE_SOUND_SETTINGS: + currentSprite = FE_ICONAUDIO; + break; + case MENUPAGE_CONTROLLER_PC: + case MENUPAGE_OPTIONS: + case MENUPAGE_CONTROLLER_SETTINGS: + case MENUPAGE_KEYBOARD_CONTROLS: + case MENUPAGE_MOUSE_CONTROLS: + currentSprite = FE_ICONCONTROLS; + break; + default: + /* actually MENUPAGE_NEW_GAME too*/ + /*case MENUPAGE_BRIEFS: */ + currentSprite = FE_ICONBRIEF; + break; + } + + m_aFrontEndSprites[currentSprite].Draw(CRect(MENU_X_LEFT_ALIGNED(50.0f), MENU_Y(50.0f), MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(95.0f)), CRGBA(255, 255, 255, m_nMenuFadeAlpha > 255 ? 255 : m_nMenuFadeAlpha)); + + if (m_nMenuFadeAlpha < 255) { + static int LastFade = 0; + + if (m_nMenuFadeAlpha <= 0 && reverseAlpha) { + reverseAlpha = false; + ChangeScreen(pendingScreen, pendingOption, true, false); + } else if(CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 10){ + if (!reverseAlpha) + m_nMenuFadeAlpha += 20; + else + m_nMenuFadeAlpha = max(m_nMenuFadeAlpha - 30, 0); + + LastFade = CTimer::GetTimeInMillisecondsPauseMode(); + } + } else { + if (reverseAlpha) + m_nMenuFadeAlpha -= 20; + + // TODO: what is this? waiting mouse? + if(field_518 == 4){ + if(m_nHoverOption == HOVEROPTION_3 || m_nHoverOption == HOVEROPTION_4 || + m_nHoverOption == HOVEROPTION_5 || m_nHoverOption == HOVEROPTION_6 || m_nHoverOption == HOVEROPTION_7) + + field_518 = 2; + else + field_518 = 1; + } + } + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + switch (m_nCurrScreen) { + case MENUPAGE_SKIN_SELECT: + CMenuManager::DrawPlayerSetupScreen(); + break; + case MENUPAGE_KEYBOARD_CONTROLS: + CMenuManager::DrawControllerSetupScreen(); + break; + default: + CMenuManager::Draw(); + break; + } + + #define optionWidth MENU_X(66.0f) + #define rawOptionHeight 20.0f + #define optionBottom SCREEN_SCALE_FROM_BOTTOM(20.0f) + #define optionTop SCREEN_SCALE_FROM_BOTTOM(20.0f + rawOptionHeight) + #define leftPadding MENU_X_LEFT_ALIGNED(90.0f) + wchar *str; + hoveredBottomBarOption = -1; + if (curBottomBarOption != -1) { + + // This active tab sprite is weird... + m_aFrontEndSprites[FE2_TABACTIVE].Draw(CRect(leftPadding - MENU_X(2.0f) + (optionWidth) * curBottomBarOption, optionTop, + leftPadding - MENU_X(5.0f) + optionWidth * (curBottomBarOption + 2), optionBottom + MENU_Y(rawOptionHeight - 9.0f)), + CRGBA(CRGBA(255, 255, 255, 255))); + + for (int i = 0; i < bbTabCount; i++) { + float xStart = leftPadding + optionWidth * i; + if (CheckHover(xStart, xStart + optionWidth, optionTop, optionBottom)) + hoveredBottomBarOption = i; + + CFont::SetFontStyle(FONT_BANK); + CFont::SetScale(MENU_X(0.35f), MENU_Y(0.7f)); + CFont::SetRightJustifyOff(); + if (hoveredBottomBarOption == i && hoveredBottomBarOption != curBottomBarOption) + CFont::SetColor(CRGBA(235, 170, 50, 255)); + else { + if(bottomBarActive || curBottomBarOption == i) + CFont::SetColor(CRGBA(0, 0, 0, 255)); + else + CFont::SetColor(CRGBA(0, 0, 0, 110)); + } + + str = TheText.Get(bbNames[i].name); + + CFont::PrintString(xStart + MENU_X(4.0f), SCREEN_SCALE_FROM_BOTTOM(39.0f), str); + + } + } + #undef optionBottom + #undef optionTop + #undef leftPadding + #undef optionWidth + #undef rawOptionHeight + + CFont::DrawFonts(); + + // Draw mouse + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + if (m_bShowMouse) { + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + + CRect mouse(0.0f, 0.0f, MENU_X(75.0f), MENU_Y(75.0f)); + CRect shad(MENU_X(10.0f), MENU_Y(3.0f), MENU_X(85.0f), MENU_Y(78.0f)); + + mouse.Translate(m_nMousePosX, m_nMousePosY); + shad.Translate(m_nMousePosX, m_nMousePosY); + if(field_518 == 4){ + m_aMenuSprites[MENUSPRITE_MOUSET].Draw(shad, CRGBA(100, 100, 100, 50)); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + m_aMenuSprites[MENUSPRITE_MOUSET].Draw(mouse, CRGBA(255, 255, 255, 255)); + }else{ + m_aMenuSprites[MENUSPRITE_MOUSE].Draw(shad, CRGBA(100, 100, 100, 50)); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + m_aMenuSprites[MENUSPRITE_MOUSE].Draw(mouse, CRGBA(255, 255, 255, 255)); + } + } +} +#else +void CMenuManager::DrawFrontEndNormal() +{ + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + LoadSplash(nil); + eMenuSprites previousSprite; if (m_nMenuFadeAlpha < 255) { switch (m_nPrevScreen) { @@ -1209,7 +1487,7 @@ void CMenuManager::DrawFrontEndNormal() previousSprite = MENUSPRITE_MAINMENU; break; } - + if (m_nPrevScreen == m_nCurrScreen) CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255 - m_nMenuFadeAlpha)); else @@ -1265,15 +1543,14 @@ void CMenuManager::DrawFrontEndNormal() m_nMenuFadeAlpha += 20; LastFade = CTimer::GetTimeInMillisecondsPauseMode(); } - + if (m_nMenuFadeAlpha > 255){ m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); - }else{ + } else { RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); } - } - else { + } else { m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); // TODO: what is this? waiting mouse? if(field_518 == 4){ @@ -1337,6 +1614,7 @@ void CMenuManager::DrawFrontEndNormal() } } } +#endif #if 1 WRAPPER void CMenuManager::DrawPlayerSetupScreen() { EAXJMP(0x47F2B0); } @@ -1356,6 +1634,7 @@ int CMenuManager::FadeIn(int alpha) m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS || m_nCurrScreen == MENUPAGE_DELETING) return alpha; + return min(m_nMenuFadeAlpha, alpha); } #endif @@ -1378,7 +1657,7 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens() } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); } #else void CMenuManager::InitialiseChangedLanguageSettings() @@ -1633,7 +1912,7 @@ void CMenuManager::PrintBriefs() } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::PrintErrorMessage() { EAXJMP(0x484F70); } #else void CMenuManager::PrintErrorMessage() @@ -1671,7 +1950,7 @@ WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { - field_112 = 0; + m_bMenuNotProcessed = false; if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus() != FADE_0) return; @@ -1699,35 +1978,27 @@ void CMenuManager::Process(void) SlotPopulated = true; } - if (SlotPopulated) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } + if (SlotPopulated) + ChangeScreen(MENUPAGE_DELETE_SUCCESS, 0, true, false); 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(); - } + if (SaveSlot) + ChangeScreen(MENUPAGE_SAVE_SUCCESSFUL, 0, true, false); else SaveLoadFileError_SetUpErrorScreen(); } if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { if (CheckSlotDataValid(m_nCurrSaveSlot)) { - TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDART; if (m_PrefsVsyncDisp != m_PrefsVsync) m_PrefsVsync = m_PrefsVsyncDisp; DMAudio.Service(); m_bStartGameLoading = true; - RequestFrontEndShutdown(); + RequestFrontEndShutDown(); m_bLoadingSavedGame = true; b_FoundRecentSavedGameWantToLoad = true; DMAudio.SetEffectsFadeVol(0); @@ -1748,25 +2019,25 @@ void CMenuManager::Process(void) SaveSettings(); } - if (field_113) { - if (field_456) - field_456 = 0; + if (m_bWaitingForNewKeyBind) { + if (m_bStartWaitingForKeyBind) + m_bStartWaitingForKeyBind = false; else { pControlEdit = CPad::EditCodesForControls(pControlEdit, 1); JoyButtonJustClicked = 0; MouseButtonJustClicked = 0; - if (GetMouseClickLeft()) + if (CPad::GetPad(0)->GetLeftMouseJustDown()) MouseButtonJustClicked = 1; - else if (GetMouseClickRight()) + else if (CPad::GetPad(0)->GetRightMouseJustUp()) MouseButtonJustClicked = 3; - else if (GetMouseClickMiddle()) + else if (CPad::GetPad(0)->GetMiddleMouseJustUp()) MouseButtonJustClicked = 2; - else if (GetMouseWheelUp()) + else if (CPad::GetPad(0)->GetMouseWheelUpJustUp()) MouseButtonJustClicked = 4; - else if (GetMouseWheelDown()) + else if (CPad::GetPad(0)->GetMouseWheelDownJustUp()) MouseButtonJustClicked = 5; - //XXX two more buttons + // TODO two more buttons JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); @@ -1778,29 +2049,29 @@ void CMenuManager::Process(void) if (*pControlEdit != rsNULL) TypeOfControl = 0; - if (!field_534) { + if (!m_bKeyIsOK) { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); pControlEdit = nil; - field_113 = 0; + m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; - field_456 = 0; + m_bStartWaitingForKeyBind = false; } else if (!m_bKeyChangeNotProcessed) { if (*pControlEdit != rsNULL || MouseButtonJustClicked || JoyButtonJustClicked) CheckCodesForControls(TypeOfControl); - field_535 = 1; + field_535 = true; } else { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); for (int i = 0; i < 4; i++) ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)m_CurrCntrlAction, (eControllerType)i); - field_534 = false; + m_bKeyIsOK = false; m_bKeyChangeNotProcessed = false; pControlEdit = nil; - field_113 = 0; + m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; - field_456 = 0; + m_bStartWaitingForKeyBind = false; } } } @@ -1820,11 +2091,9 @@ void CMenuManager::Process(void) UnloadTextures(); m_bRenderGameInMenu = false; // byte_5F33E4 = 1; // unused - m_nPrevScreen = 0; - m_nCurrScreen = m_nPrevScreen; - m_nCurrOption = 0; + ChangeScreen(MENUPAGE_NONE, 0, false, false); pEditString = nil; - field_113 = 0; + m_bWaitingForNewKeyBind = false; } if (!m_bStartGameLoading) { @@ -1834,255 +2103,1211 @@ void CMenuManager::Process(void) } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else -void CMenuManager::ProcessButtonPresses() +void +CMenuManager::ProcessButtonPresses(void) { if (pEditString || pControlEdit) return; - // Update mouse position + bool goBack = false; + bool optionSelected = false; + bool goUp = false; + bool goDown = false; +#ifdef TIDY_UP_PBP + bool assumeIncrease = false; +#endif + + if (!m_bShowMouse && (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY)) { + m_bShowMouse = true; + } + 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; - - if (m_nCurrScreen == MENUPAGE_MULTIPLAYER_FIND_GAME || m_nCurrScreen == MENUPAGE_SKIN_SELECT || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) - m_nCurrExSize = m_nSkinsTotal; + 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; - if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) - m_nCurrExSize = m_ControlMethod ? 30 : 25; + if (m_nCurrScreen == MENUPAGE_MULTIPLAYER_FIND_GAME || m_nCurrScreen == MENUPAGE_SKIN_SELECT + || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - if (!GetPadBack() || m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS || field_535) - field_535 = 0; - else if (m_nCurrExLayer == 19) { - m_nHoverOption = HOVEROPTION_42; - field_113 = 1; - field_456 = 1; - m_bKeyChangeNotProcessed = true; - pControlEdit = &m_KeyPressedCode; + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + m_nTotalListRow = m_nSkinsTotal; + } + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + m_nTotalListRow = m_ControlMethod == CONTROL_CLASSIC ? 30 : 25; + if (m_nSelectedListRow > m_nTotalListRow) + m_nSelectedListRow = m_nTotalListRow - 1; } - bool Trigger = false; - if (!Trigger) { - nTimeForSomething = 0; - Trigger = true; +#ifndef TIDY_UP_PBP + if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { + m_bShowMouse = 0; + optionSelected = true; + } +#endif + if (CPad::GetPad(0)->GetBackspaceJustDown() && m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS && !field_535) { + if (m_nCurrExLayer == 19) { + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + m_bWaitingForNewKeyBind = true; + m_bStartWaitingForKeyBind = true; + m_bKeyChangeNotProcessed = true; + pControlEdit = &m_KeyPressedCode; + } + } else { + field_535 = false; } - if ((CTimer::GetTimeInMillisecondsPauseMode() - nTimeForSomething) > 200) { - field_520 = 0; - field_521 = 0; - field_522 = 0; - field_523 = 0; - field_524 = 0; + static int nTimeForSomething = 0; + + if (CTimer::GetTimeInMillisecondsPauseMode() - nTimeForSomething >= 200) { + m_bPressedPgUpOnList = false; + m_bPressedPgDnOnList = false; + m_bPressedUpOnList = false; + m_bPressedDownOnList = false; + m_bPressedScrollButton = false; nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); } - if (CPad::GetPad(0)->NewKeyState.TAB && !CPad::GetPad(0)->OldKeyState.TAB) { + if (CPad::GetPad(0)->GetTabJustDown()) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + m_bShowMouse = false; switch (m_nCurrExLayer) { - case 9: - m_nCurrExLayer = 19; - break; - case 19: - m_nCurrExLayer = 21; - break; - case 21: - m_nCurrExLayer = 9; - break; + case 9: + default: + m_nCurrExLayer = 19; + break; + case 19: + m_nCurrExLayer = 21; + break; + case 21: + m_nCurrExLayer = 9; } - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT && m_nCurrExLayer == 21 && !strcmp(m_aSkinName, m_PrefsSkinFile)) { + if (((m_nCurrScreen == MENUPAGE_SKIN_SELECT) && (m_nCurrExLayer == 21)) && strcmp(m_aSkinName, m_PrefsSkinFile) == 0) { m_nCurrExLayer = 9; } - if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS && m_nCurrExLayer == 21) + if ((m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) && (m_nCurrExLayer == 21)) { m_nCurrExLayer = 9; + } } - if (GetPadForward()) { - switch (m_nCurrExLayer) { - case 19: - if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - field_113 = 1; - field_456 = 1; - pControlEdit = &m_KeyPressedCode; + bool pressed = false; + if (CPad::GetPad(0)->GetUp() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { + m_bShowMouse = false; + pressed = true; + } else if (CPad::GetPad(0)->GetMouseWheelUpJustUp()) { + m_bShowMouse = true; + pressed = true; + } + + // Up + if (pressed) { + m_nCurrExLayer = 19; + if (!m_bPressedUpOnList) { + m_bPressedUpOnList = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + ScrollUpListByOne(); + } + } else { + m_bPressedUpOnList = false; + } + + pressed = false; + if (CPad::GetPad(0)->GetDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { + m_bShowMouse = false; + pressed = true; + } else if (CPad::GetPad(0)->GetMouseWheelDownJustDown()) { + m_bShowMouse = true; + pressed = true; + } + + // Down + if (pressed) { + m_nCurrExLayer = 19; + if (!m_bPressedDownOnList) { + m_bPressedDownOnList = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + ScrollDownListByOne(); + } + } else { + m_bPressedDownOnList = false; + } + + if (m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) { + if (!CPad::GetPad(0)->GetPageUp()) { + m_bPressedPgUpOnList = false; + } else { + m_nCurrExLayer = 19; + if (!m_bPressedPgUpOnList) { + m_bPressedPgUpOnList = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + PageUpList(false); } - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - strcpy(m_PrefsSkinFile, m_aSkinName); - CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); - m_nCurrExLayer = 9; + } + if (!CPad::GetPad(0)->GetPageDown()) { + m_bPressedPgDnOnList = false; + } else { + m_nCurrExLayer = 19; + if (!m_bPressedPgDnOnList) { + m_bPressedPgDnOnList = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + PageDownList(false); + } + } + if (CPad::GetPad(0)->GetHome()) { + m_nCurrExLayer = 19; + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (m_nTotalListRow >= MAX_VISIBLE_LIST_ROW) { + m_nFirstVisibleRowOnList = 0; } + m_nSelectedListRow = 0; + m_nCurListItemY = (LIST_HEIGHT / m_nTotalListRow) * m_nFirstVisibleRowOnList; + } + if (CPad::GetPad(0)->GetEnd()) { + m_nCurrExLayer = 19; + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (m_nTotalListRow >= MAX_VISIBLE_LIST_ROW) { + m_nFirstVisibleRowOnList = m_nTotalListRow - MAX_VISIBLE_LIST_ROW; + } + m_nSelectedListRow = m_nTotalListRow - 1; + m_nCurListItemY = (LIST_HEIGHT / m_nTotalListRow) * m_nFirstVisibleRowOnList; + } + } - m_nHoverOption = HOVEROPTION_42; +#ifndef TIDY_UP_PBP + if (CPad::GetPad(0)->GetEscapeJustDown() || CPad::GetPad(0)->GetSquareJustDown()) { + m_bShowMouse = false; + goBack = true; + } +#endif + + if (CPad::GetPad(0)->GetLeftMouseJustDown()) { + switch (m_nHoverOption) { + case HOVEROPTION_BACK: + goBack = true; + break; + case HOVEROPTION_PAGEUP: + PageUpList(true); + break; + case HOVEROPTION_PAGEDOWN: + PageDownList(true); + break; + case HOVEROPTION_CHANGESKIN: + if (m_nSkinsTotal > 0) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + m_pSelectedSkin = m_sSkin.field_304; + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); + SaveSettings(); + } + } + } + + if (CPad::GetPad(0)->GetLeftMouseJustDown()) { + switch (m_nHoverOption) { + case HOVEROPTION_OVER_SCROLL_UP: + m_nHoverOption = HOVEROPTION_CLICKED_SCROLL_UP; + break; + case HOVEROPTION_OVER_SCROLL_DOWN: + m_nHoverOption = HOVEROPTION_CLICKED_SCROLL_DOWN; + break; + case HOVEROPTION_19: + m_nHoverOption = HOVEROPTION_20; + } + } else if ((CPad::GetPad(0)->GetLeftMouseJustUp()) + && ((m_nHoverOption == HOVEROPTION_CLICKED_SCROLL_UP || (m_nHoverOption == HOVEROPTION_CLICKED_SCROLL_DOWN)))) { + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + } + + if (!CPad::GetPad(0)->GetLeftMouse()) { + holdingScrollBar = false; + } else { + if ((m_nHoverOption == HOVEROPTION_HOLDING_SCROLLBAR) || holdingScrollBar) { + holdingScrollBar = true; + // TODO: This part is a bit hard to reverse. Not much code tho + assert(0 && "Not done yet"); + } else { + switch (m_nHoverOption) { + case HOVEROPTION_OVER_SCROLL_UP: + case HOVEROPTION_CLICKED_SCROLL_UP: + if (!m_bPressedScrollButton) { + m_bPressedScrollButton = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + ScrollUpListByOne(); + } + break; + case HOVEROPTION_OVER_SCROLL_DOWN: + case HOVEROPTION_CLICKED_SCROLL_DOWN: + if (!m_bPressedScrollButton) { + m_bPressedScrollButton = true; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + ScrollDownListByOne(); + } + break; + default: + m_bPressedScrollButton = false; + } + } + } + } else if (isPlainTextScreen(m_nCurrScreen)) { +#ifndef TIDY_UP_PBP + if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown() || CPad::GetPad(0)->GetLeftMouseJustDown()) { + optionSelected = true; + } + if (CPad::GetPad(0)->GetEscapeJustDown() || CPad::GetPad(0)->GetSquareJustUp()) { + if (m_nCurrScreen != MENUPAGE_START_MENU) { + goBack = true; + } + } +#endif + } else { + if (CPad::GetPad(0)->GetDownJustDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + goDown = true; + } else if (CPad::GetPad(0)->GetUpJustDown() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + goUp = true; + } + +#ifndef TIDY_UP_PBP + if ((m_nCurrOption == 0) && (m_nCurrScreen == MENUPAGE_PAUSE_MENU)) { + if (CPad::GetPad(0)->GetEnterJustUp() || CPad::GetPad(0)->GetCrossJustUp()) { + m_bShowMouse = false; + optionSelected = true; + } + } else { + if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { + m_bShowMouse = false; + optionSelected = true; + } + } +#endif + + if (CPad::GetPad(0)->GetLeftMouseJustUp()) { +#ifndef TIDY_UP_PBP + if (((m_nCurrOption == 0) && (m_nCurrScreen == MENUPAGE_PAUSE_MENU)) && +#else + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_RESUME && +#endif + (m_nHoverOption == HOVEROPTION_RANDOM_ITEM)) { + m_nCurrOption = m_nPrevOption; + optionSelected = true; + } + } else if (CPad::GetPad(0)->GetLeftMouseJustDown()) { +#ifdef TIDY_UP_PBP + if (m_nHoverOption >= HOVEROPTION_RADIO_0 && m_nHoverOption <= HOVEROPTION_RADIO_9) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = m_nHoverOption - HOVEROPTION_RADIO_0; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + } else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM + && aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) { + m_nCurrOption = m_nPrevOption; + optionSelected = true; + } +#else + switch (m_nHoverOption) { + case HOVEROPTION_RADIO_0: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = HEAD_RADIO; SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; - case 21: - strcpy(m_PrefsSkinFile, m_aSkinName); - CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); - m_nCurrExLayer = 9; + case HOVEROPTION_RADIO_1: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = DOUBLE_CLEF; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; - default: + case HOVEROPTION_RADIO_2: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = JAH_RADIO; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_3: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = RISE_FM; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_4: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = LIPS_106; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_5: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = GAME_FM; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_6: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = MSX_FM; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_7: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = FLASHBACK; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_8: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = CHATTERBOX; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RADIO_9: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::m_PrefsRadioStation = USERTRACK; + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case HOVEROPTION_RANDOM_ITEM: + if (((m_nCurrOption != 0) || (m_nCurrScreen != MENUPAGE_PAUSE_MENU)) { + m_nCurrOption = m_nPrevOption; + optionSelected = true; + } break; } +#endif } - } - // Get number of menu options. - uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); + if (CPad::GetPad(0)->GetLeftMouse()) { +#ifndef TIDY_UP_PBP + switch (m_nHoverOption) { + case HOVEROPTION_INCREASE_BRIGHTNESS: + CMenuManager::m_PrefsBrightness = CMenuManager::m_PrefsBrightness + 32; + if (CMenuManager::m_PrefsBrightness < 0) { + CMenuManager::m_PrefsBrightness = 0; + } + if (510 < CMenuManager::m_PrefsBrightness) { + CMenuManager::m_PrefsBrightness = 511; + } + SaveSettings(); + break; + case HOVEROPTION_DECREASE_BRIGHTNESS: + CMenuManager::m_PrefsBrightness = CMenuManager::m_PrefsBrightness - 32; + if (CMenuManager::m_PrefsBrightness < 0) { + CMenuManager::m_PrefsBrightness = 0; + } + if (510 < CMenuManager::m_PrefsBrightness) { + CMenuManager::m_PrefsBrightness = 511; + } + SaveSettings(); + break; + case HOVEROPTION_INCREASE_DRAWDIST: + CMenuManager::m_PrefsLOD = CMenuManager::m_PrefsLOD + (1.0f / 16); + m_PrefsLOD = min(1.8f, m_PrefsLOD); + CRenderer::ms_lodDistScale = CMenuManager::m_PrefsLOD; + SaveSettings(); + break; + case HOVEROPTION_DECREASE_DRAWDIST: + CMenuManager::m_PrefsLOD = CMenuManager::m_PrefsLOD - (1.0f / 16); + m_PrefsLOD = max(0.8f, m_PrefsLOD); + CRenderer::ms_lodDistScale = CMenuManager::m_PrefsLOD; + SaveSettings(); + break; + case HOVEROPTION_INCREASE_MUSICVOLUME: + CMenuManager::m_PrefsMusicVolume = CMenuManager::m_PrefsMusicVolume + 8; + m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 127); + DMAudio.SetMusicMasterVolume(uchar)(CMenuManager::m_PrefsMusicVolume); + SaveSettings(); + break; + case HOVEROPTION_DECREASE_MUSICVOLUME: + CMenuManager::m_PrefsMusicVolume = CMenuManager::m_PrefsMusicVolume - 8; + if (CMenuManager::m_PrefsMusicVolume < 0) { + CMenuManager::m_PrefsMusicVolume = 0; + } + if (126 < CMenuManager::m_PrefsMusicVolume) { + CMenuManager::m_PrefsMusicVolume = 127; + } + DMAudio.SetMusicMasterVolume(uchar)(CMenuManager::m_PrefsMusicVolume); + SaveSettings(); + break; + case HOVEROPTION_INCREASE_SFXVOLUME: + CMenuManager::m_PrefsSFXVolume = CMenuManager::m_PrefsSFXVolume + 8; + if (CMenuManager::m_PrefsSFXVolume < 0) { + CMenuManager::m_PrefsSFXVolume = 0; + } + if (126 < CMenuManager::m_PrefsSFXVolume) { + CMenuManager::m_PrefsSFXVolume = 127; + } + DMAudio.SetEffectsMasterVolume(uchar)(CMenuManager::m_PrefsSFXVolume); + SaveSettings(); + break; + case HOVEROPTION_DECREASE_SFXVOLUME: + CMenuManager::m_PrefsSFXVolume = CMenuManager::m_PrefsSFXVolume - 8; + if (CMenuManager::m_PrefsSFXVolume < 0) { + CMenuManager::m_PrefsSFXVolume = 0; + } + if (126 < CMenuManager::m_PrefsSFXVolume) { + CMenuManager::m_PrefsSFXVolume = 127; + } + DMAudio.SetEffectsMasterVolume(uchar)(CMenuManager::m_PrefsSFXVolume); + SaveSettings(); + break; + case HOVEROPTION_INCREASE_MOUSESENS: + TheCamera.m_fMouseAccelHorzntl += (1.0f / 3000); + TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200); + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; + SaveSettings(); + break; + case HOVEROPTION_DECREASE_MOUSESENS: + TheCamera.m_fMouseAccelHorzntl -= (1.0f / 3000); + TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200); + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; + SaveSettings(); + break; + } +#else + switch (m_nHoverOption) { + case HOVEROPTION_INCREASE_BRIGHTNESS: + case HOVEROPTION_INCREASE_DRAWDIST: + case HOVEROPTION_INCREASE_MUSICVOLUME: + case HOVEROPTION_INCREASE_SFXVOLUME: + case HOVEROPTION_INCREASE_MOUSESENS: + CheckSliderMovement(1); + break; + case HOVEROPTION_DECREASE_BRIGHTNESS: + case HOVEROPTION_DECREASE_DRAWDIST: + case HOVEROPTION_DECREASE_MUSICVOLUME: + case HOVEROPTION_DECREASE_SFXVOLUME: + case HOVEROPTION_DECREASE_MOUSESENS: + CheckSliderMovement(-1); + break; + } +#endif + } + + if (CPad::GetPad(0)->GetLeftMouseJustUp() || CPad::GetPad(0)->GetLeftJustUp() || CPad::GetPad(0)->GetRightJustUp() + || CPad::GetPad(0)->GetDPadLeftJustUp() || CPad::GetPad(0)->GetDPadRightJustUp() + || CPad::GetPad(0)->GetAnaloguePadLeftJustUp() || CPad::GetPad(0)->GetAnaloguePadRightJustUp() + || CPad::GetPad(0)->GetMouseWheelUpJustDown() || CPad::GetPad(0)->GetMouseWheelDownJustDown()) { + int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + if (option == MENUACTION_BRIGHTNESS || option == MENUACTION_DRAWDIST) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + else if (option == MENUACTION_SFXVOLUME) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_AUDIO_TEST, 0); + else if (option == MENUACTION_MOUSESENS) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + + } +#ifndef TIDY_UP_PBP + if (CPad::GetPad(0)->GetSquareJustDown()) { + if (m_nCurrScreen != MENUPAGE_START_MENU && m_nCurrScreen != MENUPAGE_PAUSE_MENU) { + m_bShowMouse = false; + goBack = true; + } + } - // Select next/previous option with pad. Mouse is done in drawing function. - if (GetPadMoveUp()) { - m_nPrevOption = m_nCurrOption; - m_nCurrOption -= 1; - m_nCurrExOption -= 1; - //field_438 -= 1; + if (CPad::GetPad(0)->GetEscapeJustDown()) { + if (m_nCurrScreen != MENUPAGE_START_MENU) { + m_bShowMouse = false; + goBack = true; + } + } - if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { - if (m_nCurrOption < 1) - m_nCurrOption = NumberOfMenuOptions; + if (((goDown) || (goUp)) || (optionSelected)) { + goBack = false; } - else { - if (m_nCurrOption < 0) - m_nCurrOption = NumberOfMenuOptions; +#endif } - if (m_nCurrExOption < 0) - m_nCurrExOption = 0; + // Centralized enter/back (except some conditions) +#ifdef TIDY_UP_PBP + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) { + if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown() || + (isPlainTextScreen(m_nCurrScreen) && CPad::GetPad(0)->GetLeftMouseJustDown())) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } - else if (GetPadMoveDown()) { - m_nPrevOption = m_nCurrOption; - m_nCurrOption += 1; - m_nCurrExOption += 1; - //field_438 = += 1; + if (!isPlainTextScreen(m_nCurrScreen)) + m_bShowMouse = false; - if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { - if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = 1; + optionSelected = true; } - else { - if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = 0; + } else { + if (CPad::GetPad(0)->GetEnterJustUp() || CPad::GetPad(0)->GetCrossJustUp()) { + m_bShowMouse = false; + optionSelected = true; } + } - if (m_nCurrExOption > m_nCurrExSize - 1) - m_nCurrExOption = m_nCurrExSize - 1; + if (!goDown && !goUp && !optionSelected) { + if (m_nCurrScreen != MENUPAGE_START_MENU) { + if (isPlainTextScreen(m_nCurrScreen)) { + if (CPad::GetPad(0)->GetEscapeJustDown() || CPad::GetPad(0)->GetSquareJustUp()) { + goBack = true; + } + } else { + if (CPad::GetPad(0)->GetEscapeJustDown() || (m_nCurrScreen != MENUPAGE_PAUSE_MENU && CPad::GetPad(0)->GetSquareJustDown())) { + m_bShowMouse = false; + goBack = true; + } + } + } + } +#endif +#ifdef PS2_LIKE_MENU + if (CPad::GetPad(0)->GetLeftMouseJustDown() && hoveredBottomBarOption != -1) { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + bottomBarActive = false; + curBottomBarOption = hoveredBottomBarOption; + ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, false); + return; + } else if (bottomBarActive) { + if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + bottomBarActive = false; + if (reverseAlpha) + m_nMenuFadeAlpha = 0; + return; + } else if (CPad::GetPad(0)->GetLeftJustDown() || CPad::GetPad(0)->GetAnaloguePadLeft() || CPad::GetPad(0)->GetDPadLeftJustDown() + || CPad::GetPad(0)->GetUpJustDown() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (curBottomBarOption > 0) + curBottomBarOption--; + ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); + return; + } else if (CPad::GetPad(0)->GetRightJustDown() || CPad::GetPad(0)->GetAnaloguePadRight() || CPad::GetPad(0)->GetDPadRightJustDown() + || CPad::GetPad(0)->GetDownJustDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { + m_bShowMouse = false; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (curBottomBarOption < bbTabCount-1) + curBottomBarOption++; + ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); + return; + } + optionSelected = false; + goDown = false; + goUp = false; } +#endif - // 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; - case MENUPAGE_KEYBOARD_CONTROLS: - if (!m_bKeyChangeNotProcessed) { - m_bKeyChangeNotProcessed = true; - field_534 = 0; + if (goDown && (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME)) { + m_nCurrOption++; + if (m_nCurrOption == NUM_MENUROWS || (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_NOTHING)) { + m_nCurrOption = 0; + } + } + if (goUp && (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME)) { + if (m_nCurrOption == (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL)) { + while (m_nCurrOption != NUM_MENUROWS - 1 + && aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption + 1].m_Action != MENUACTION_NOTHING) { + m_nCurrOption++; } - else - SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); - - PlayEscSound = true; - break; - default: - SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); - PlayEscSound = true; - break; + } else { + m_nCurrOption--; } - - if (PlayEscSound) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); } - // Set hover options, how it is supposed to be used isn't really clear yet. - if (GetMouseForward()) { - switch (m_nHoverOption) { - case HOVEROPTION_DEFAULT: - if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) - m_nCurrOption = m_nPrevOption; + if (optionSelected) { + int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + if ((option == MENUACTION_CHANGEMENU) || (option == MENUACTION_POPULATESLOTS_CHANGEMENU)) { + if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) != 0 && + strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FESZ_CA", 8) != 0) { + + if (m_nCurrScreen == MENUPAGE_CHOOSE_DELETE_SLOT) { + if (Slots[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 1] == SLOT_EMPTY) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + } else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_COMPLETED, 0); + } else { + // This is duplicate, back button already processed below +#ifndef TIDY_UP_PBP + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { + DMAudio.StopFrontEndTrack(); + OutputDebugString("FRONTEND AUDIO TRACK STOPPED"); + } +#endif + } + } else if (option == MENUACTION_CHECKSAVE) { + if (Slots[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 1] == SLOT_EMPTY) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + } else { + if (m_nCurrScreen != MENUPAGE_NEW_GAME_RELOAD) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + } + } + } else if (option != MENUACTION_CHANGEMENU && option != MENUACTION_BRIGHTNESS && option != MENUACTION_DRAWDIST + && option != MENUACTION_MUSICVOLUME && option != MENUACTION_SFXVOLUME + && option != MENUACTION_CHECKSAVE && option != MENUACTION_UNK24 + && option != MENUACTION_MOUSESENS && option != MENUACTION_SCREENRES) { - m_nHoverOption = HOVEROPTION_DEFAULT; - break; - case HOVEROPTION_12: - m_nHoverOption = HOVEROPTION_14; - break; - case HOVEROPTION_13: - m_nHoverOption = HOVEROPTION_15; - break; - case HOVEROPTION_19: - m_nHoverOption = HOVEROPTION_20; - break; - case HOVEROPTION_CHANGESKIN: + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + } + + if ((m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) || (m_nCurrScreen == MENUPAGE_SKIN_SELECT)) { + switch (m_nCurrExLayer) { + default: + goBack = true; + break; + case 19: + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + m_bWaitingForNewKeyBind = true; + m_bStartWaitingForKeyBind = true; + pControlEdit = &m_KeyPressedCode; + } + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); + m_nCurrExLayer = 9; + CMenuManager::SaveSettings(); + } + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + break; + case 21: + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); + m_nCurrExLayer = 9; + SaveSettings(); + break; + } + } else if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == MENUPAGE_NEW_GAME_RELOAD && m_bGameNotLoaded) { + DoSettingsBeforeStartingAGame(); +/* } else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + // .. either empty or there was some outer if. :shrug: pointless anyway, keyboard_controls is handled in first if. +*/ + } else if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { if (m_nSkinsTotal > 0) { - m_pSelectedSkin = m_sSkin.field_304; + m_pSelectedSkin = (tSkinInfo*)(m_sSkin).field_304; strcpy(m_PrefsSkinFile, m_aSkinName); - CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); + CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); SaveSettings(); + } else { + if (!m_bGameNotLoaded) + ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); + else + ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[0], aScreens[m_nCurrScreen].m_ParentEntry[0], true, true); + } + } else if (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME) { + option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + switch (option) { + case MENUACTION_RADIO: +#ifdef TIDY_UP_PBP + assumeIncrease = true; +#else + ++CMenuManager::m_PrefsRadioStation; + if (cDMAudio::IsMP3RadioChannelAvailable()) { + if (CMenuManager::m_PrefsRadioStation > USERTRACK) + CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + } else if (CMenuManager::m_PrefsRadioStation > CHATTERBOX) { + CMenuManager::m_PrefsRadioStation = USERTRACK; + } + SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); +#endif + break; + case MENUACTION_LANG_ENG: + m_PrefsLanguage = LANGUAGE_AMERICAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + CMenuManager::InitialiseChangedLanguageSettings(); + CMenuManager::SaveSettings(); + break; + case MENUACTION_LANG_FRE: + m_PrefsLanguage = LANGUAGE_FRENCH; + m_bFrontEnd_ReloadObrTxtGxt = true; + CMenuManager::InitialiseChangedLanguageSettings(); + CMenuManager::SaveSettings(); + break; + case MENUACTION_LANG_GER: + m_PrefsLanguage = LANGUAGE_GERMAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + CMenuManager::InitialiseChangedLanguageSettings(); + CMenuManager::SaveSettings(); + break; + case MENUACTION_LANG_ITA: + m_PrefsLanguage = LANGUAGE_ITALIAN; + m_bFrontEnd_ReloadObrTxtGxt = true; + CMenuManager::InitialiseChangedLanguageSettings(); + CMenuManager::SaveSettings(); + break; + case MENUACTION_LANG_SPA: + m_PrefsLanguage = LANGUAGE_SPANISH; + m_bFrontEnd_ReloadObrTxtGxt = true; + CMenuManager::InitialiseChangedLanguageSettings(); + SaveSettings(); + break; + case MENUACTION_POPULATESLOTS_CHANGEMENU: + PcSaveHelper.PopulateSlotInfo(); + + // fall through + case MENUACTION_CHANGEMENU: + { + bool changeMenu = true; + int saveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot; + + // This should be unused. + if (saveSlot >= 2 && saveSlot <= 9) { + m_nCurrSaveSlot = saveSlot - 2; + switch (m_nCurrScreen) { + case MENUPAGE_CHOOSE_LOAD_SLOT: + if (Slots[m_nCurrSaveSlot + 1] != SLOT_EMPTY) + changeMenu = false; + + break; + case MENUPAGE_CHOOSE_DELETE_SLOT: + if (Slots[m_nCurrSaveSlot + 1] == SLOT_EMPTY) + changeMenu = false; + + break; + } + } + if (changeMenu) { + if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) == 0) { +#ifndef TIDY_UP_PBP + CMenuManager::ResetHelperText(); + if (!m_bGameNotLoaded) + ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); + else + ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[0], aScreens[m_nCurrScreen].m_ParentEntry[0], true, true); +#else + goBack = true; + break; +#endif + } else { + ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); + } + } + break; + } + case MENUACTION_CHECKSAVE: + { + int saveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot; + + if (saveSlot >= 2 && saveSlot <= 9) { + m_nCurrSaveSlot = saveSlot - 2; + if (Slots[m_nCurrSaveSlot + 1] != SLOT_EMPTY && Slots[m_nCurrSaveSlot + 1] != SLOT_CORRUPTED) { + ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); + } + } + break; + } + case MENUACTION_NEWGAME: + CMenuManager::DoSettingsBeforeStartingAGame(); + break; + case MENUACTION_RELOADIDE: + // TODO + // CFileLoader::ReloadObjectTypes("GTA3.IDE"); + break; + case MENUACTION_RELOADIPL: + CGame::ReloadIPLs(); + break; + case MENUACTION_SHOWCULL: + gbShowCullZoneDebugStuff = !gbShowCullZoneDebugStuff; + break; + case MENUACTION_MEMCARDSAVECONFIRM: + return; + case MENUACTION_RESUME_FROM_SAVEZONE: + CMenuManager::RequestFrontEndShutDown(); + break; + case MENUACTION_MPMAP_LIBERTY: + case MENUACTION_MPMAP_REDLIGHT: + case MENUACTION_MPMAP_CHINATOWN: + case MENUACTION_MPMAP_TOWER: + case MENUACTION_MPMAP_SEWER: + case MENUACTION_MPMAP_INDUSTPARK: + case MENUACTION_MPMAP_DOCKS: + case MENUACTION_MPMAP_STAUNTON: + sthWithButtons = option - MENUACTION_MPMAP_LIBERTY; + CMenuManager::SaveSettings(); + ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); + break; + case MENUACTION_MPMAP_DEATHMATCH1: + case MENUACTION_MPMAP_DEATHMATCH2: + case MENUACTION_MPMAP_TEAMDEATH1: + case MENUACTION_MPMAP_TEAMDEATH2: + case MENUACTION_MPMAP_STASH: + case MENUACTION_MPMAP_CAPTURE: + case MENUACTION_MPMAP_RATRACE: + case MENUACTION_MPMAP_DOMINATION: + sthWithButtons2 = option - MENUACTION_MPMAP_DEATHMATCH1; + CMenuManager::SaveSettings(); + ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); + break; + case MENUACTION_REDEFCTRL: + ChangeScreen(MENUPAGE_KEYBOARD_CONTROLS, 0, true, true); + m_nSelectedListRow = 0; + m_nCurrExLayer = 19; + break; + case MENUACTION_GETKEY: + m_CurrCntrlAction = GetStartOptionsCntrlConfigScreens() + m_nCurrOption; + m_bKeyIsOK = true; + m_bWaitingForNewKeyBind = true; + m_bStartWaitingForKeyBind = true; + pControlEdit = &m_KeyPressedCode; + break; + case MENUACTION_CANCELGAME: + DMAudio.Service(); + RsEventHandler(rsQUITAPP, nil); + break; + case MENUACTION_RESUME: +#ifndef TIDY_UP_PBP + if (CMenuManager::m_PrefsVsyncDisp != CMenuManager::m_PrefsVsync) { + CMenuManager::m_PrefsVsync = CMenuManager::m_PrefsVsyncDisp; + } + CMenuManager::RequestFrontEndShutDown(); +#else + goBack = true; +#endif + break; + case MENUACTION_DONTCANCEL: + ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); + break; + case MENUACTION_SCREENRES: + if (m_nDisplayVideoMode != m_nPrefsVideoMode) { + m_nPrefsVideoMode = m_nDisplayVideoMode; + _psSelectScreenVM(m_nPrefsVideoMode); + SetHelperText(0); + SaveSettings(); + } + break; + case MENUACTION_AUDIOHW: + { + int selectedProvider = m_nPrefsAudio3DProviderIndex; + if (selectedProvider != -1) { + m_nPrefsAudio3DProviderIndex = DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); + if (selectedProvider == m_nPrefsAudio3DProviderIndex) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + SetHelperText(0); + } else { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + SetHelperText(4); + } + SaveSettings(); + } + break; + } + case MENUACTION_SPEAKERCONF: +#ifndef TIDY_UP_PBP + if (m_nPrefsAudio3DProviderIndex != -1) { + if (--m_PrefsSpeakers < 0) + m_PrefsSpeakers = 2; + DMAudio.SetSpeakerConfig(m_PrefsSpeakers); + SaveSettings(); + } +#else + assumeIncrease = true; +#endif + break; + case MENUACTION_PLAYERSETUP: + CPlayerSkin::BeginFrontendSkinEdit(); + ChangeScreen(MENUPAGE_SKIN_SELECT, 0, true, true); + m_nCurrExLayer = 19; + m_bSkinsFound = 0; + break; + case MENUACTION_RESTOREDEF: + if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { + CMenuManager::m_PrefsSfxVolume = 102; + m_PrefsSpeakers = 0; + CMenuManager::m_PrefsMusicVolume = 102; + // unused + // byte_95CDB5 = 0; + CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + DMAudio.SetMusicMasterVolume(102); + DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + SaveSettings(); + } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { + CMenuManager::m_PrefsFrameLimiter = true; + CMenuManager::m_PrefsBrightness = 256; + CMenuManager::m_PrefsVsyncDisp = true; + CMenuManager::m_PrefsLOD = 1.2f; + CMenuManager::m_PrefsVsync = true; + CRenderer::ms_lodDistScale = 1.2f; + CMenuManager::m_PrefsUseWideScreen = false; + CMenuManager::m_PrefsShowSubtitles = true; + m_nDisplayVideoMode = m_nPrefsVideoMode; + CMBlur::BlurOn = true; + SaveSettings(); + } else if ((m_nCurrScreen != MENUPAGE_SKIN_SELECT_OLD) && (m_nCurrScreen == MENUPAGE_CONTROLLER_PC)) { + ControlsManager.MakeControllerActionsBlank(); + ControlsManager.InitDefaultControlConfiguration(); + ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp()); + if (AllValidWinJoys.m_aJoys[0].m_bInitialised) { + DIDEVCAPS devCaps; + devCaps.dwSize = sizeof(DIDEVCAPS); + PSGLOBAL(joy1)->GetCapabilities(&devCaps); + ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons); + } + CMenuManager::m_ControlMethod = CONTROL_STANDART; + MousePointerStateHelper.bInvertVertically = false; + TheCamera.m_fMouseAccelHorzntl = 0.0025f; + m_bDisableMouseSteering = true; + TheCamera.m_bHeadBob = false; + SaveSettings(); + } + CMenuManager::SetHelperText(2); + break; + case MENUACTION_CTRLMETHOD: +#ifndef TIDY_UP_PBP + if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) { + CCamera::m_bUseMouse3rdPerson = true; + CMenuManager::m_ControlMethod = CONTROL_STANDART; + } else { + CCamera::m_bUseMouse3rdPerson = false; + CMenuManager::m_ControlMethod = CONTROL_CLASSIC; + } + SaveSettings(); +#else + assumeIncrease = true; +#endif + break; + case MENUACTION_LOADRADIO: + ChangeScreen(MENUPAGE_SOUND_SETTINGS, 0, true, true); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK"); + break; } - break; - default: - m_nHoverOption = HOVEROPTION_42; - break; } + ProcessOnOffMenuOptions(); } - // 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); + if (goBack) { + CMenuManager::ResetHelperText(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + if (m_nCurrScreen == MENUPAGE_PAUSE_MENU && !m_bGameNotLoaded && !m_bMenuNotProcessed){ + if (CMenuManager::m_PrefsVsyncDisp != CMenuManager::m_PrefsVsync) { + CMenuManager::m_PrefsVsync = CMenuManager::m_PrefsVsyncDisp; + } + CMenuManager::RequestFrontEndShutDown(); + } else if (m_nCurrScreen == MENUPAGE_CHOOSE_SAVE_SLOT +#ifdef PS2_SAVE_DIALOG + || m_nCurrScreen == MENUPAGE_SAVE +#endif + ) { + CMenuManager::RequestFrontEndShutDown(); + } else if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { + DMAudio.StopFrontEndTrack(); + OutputDebugString("FRONTEND AUDIO TRACK STOPPED"); + } - ProcessOnOffMenuOptions(); + int oldScreen = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0]; + int oldOption = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; + +#ifdef PS2_LIKE_MENU + if (bottomBarActive){ + bottomBarActive = false; + if (!m_bGameNotLoaded) { + if (CMenuManager::m_PrefsVsyncDisp != CMenuManager::m_PrefsVsync) { + CMenuManager::m_PrefsVsync = CMenuManager::m_PrefsVsyncDisp; + } + CMenuManager::RequestFrontEndShutDown(); + } + return; + } +#endif + + if (oldScreen != -1) { + if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) && strcmp(m_aSkinName, m_PrefsSkinFile) != 0) { + CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); + } + if ((m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) && (m_nPrefsAudio3DProviderIndex != -1)) { + m_nPrefsAudio3DProviderIndex = DMAudio.GetCurrent3DProviderIndex(); + } + if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { + m_nDisplayVideoMode = m_nPrefsVideoMode; + } + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + CPlayerSkin::EndFrontendSkinEdit(); + } + +#ifdef PS2_LIKE_MENU + if (!bottomBarActive && + (oldScreen == MENUPAGE_NONE || oldScreen == MENUPAGE_OPTIONS)) { + bottomBarActive = true; + } else +#endif + ChangeScreen(oldScreen, oldOption, true, true); + + if ((m_nPrevScreen == MENUPAGE_SKIN_SELECT) || (m_nPrevScreen == MENUPAGE_KEYBOARD_CONTROLS)) { + m_nTotalListRow = 0; + } + + // We will go back for sure at this point, why process other things?! +#ifdef FIX_BUGS + return; +#endif + } } - // 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; +#ifdef PS2_LIKE_MENU + if (bottomBarActive) + return; +#endif + + int changeValueBy = 0; + bool decrease = false; +#ifdef TIDY_UP_PBP + bool increase = assumeIncrease; +#else + bool increase = false; +#endif + if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetPedWalkLeftRight() < 0 || CPad::GetPad(0)->GetDPadLeft()) { + static uint32 lastSliderDecrease = 0; + if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderDecrease > 150) { + CMenuManager::CheckSliderMovement(-1); + lastSliderDecrease = CTimer::GetTimeInMillisecondsPauseMode(); + } + } else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetPedWalkLeftRight() > 0 || CPad::GetPad(0)->GetDPadRight()) { + static uint32 lastSliderIncrease = 0; + if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderIncrease > 150) { + CMenuManager::CheckSliderMovement(1); + lastSliderIncrease = CTimer::GetTimeInMillisecondsPauseMode(); + } + } + + if (CPad::GetPad(0)->GetRightJustDown() || CPad::GetPad(0)->GetAnaloguePadRight() || CPad::GetPad(0)->GetDPadRightJustDown()) { + m_bShowMouse = false; + increase = true; + } else if (CPad::GetPad(0)->GetMouseWheelUpJustDown() && m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) { + increase = true; + CMenuManager::CheckSliderMovement(1); + m_bShowMouse = true; + } + + if (!CPad::GetPad(0)->GetLeftJustDown() && !CPad::GetPad(0)->GetAnaloguePadLeft() && !CPad::GetPad(0)->GetDPadLeftJustDown()) { + if (CPad::GetPad(0)->GetMouseWheelDownJustDown()) { + if (m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) { + decrease = true; + CMenuManager::CheckSliderMovement(-1); + m_bShowMouse = true; + } + } + } else { + m_bShowMouse = false; + decrease = true; + } + + if (increase) + changeValueBy++; + else if (decrease) + changeValueBy--; + + if (changeValueBy != 0) { + switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { + case MENUACTION_RADIO: + CMenuManager::m_PrefsRadioStation += changeValueBy; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + if (DMAudio.IsMP3RadioChannelAvailable()) { + if (CMenuManager::m_PrefsRadioStation < HEAD_RADIO) + CMenuManager::m_PrefsRadioStation = USERTRACK; + if (CMenuManager::m_PrefsRadioStation > USERTRACK) + CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + } else { + if (CMenuManager::m_PrefsRadioStation < HEAD_RADIO) + CMenuManager::m_PrefsRadioStation = CHATTERBOX; + if (CMenuManager::m_PrefsRadioStation > CHATTERBOX) + CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + } + CMenuManager::SaveSettings(); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + OutputDebugString("FRONTEND RADIO STATION CHANGED"); + break; + case MENUACTION_SCREENRES: + if (m_bGameNotLoaded) { + RwChar** videoMods = _psGetVideoModeList(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (changeValueBy > 0) { + do { + ++m_nDisplayVideoMode; + + if (m_nDisplayVideoMode >= _psGetNumVideModes()) + m_nDisplayVideoMode = 0; + } while (!videoMods[m_nDisplayVideoMode]); + } else { + do { + --m_nDisplayVideoMode; + + if (m_nDisplayVideoMode < 0) + m_nDisplayVideoMode = _psGetNumVideModes() - 1; + } while (!videoMods[m_nDisplayVideoMode]); + } + } + break; + case MENUACTION_AUDIOHW: + if (m_nPrefsAudio3DProviderIndex != -1) { + m_nPrefsAudio3DProviderIndex += changeValueBy; + m_nPrefsAudio3DProviderIndex = clamp(m_nPrefsAudio3DProviderIndex, 0, DMAudio.GetNum3DProvidersAvailable() - 1); + } + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + break; + case MENUACTION_SPEAKERCONF: + if (m_nPrefsAudio3DProviderIndex != -1) { + m_PrefsSpeakers -= changeValueBy; + m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2); + DMAudio.SetSpeakerConfig(m_PrefsSpeakers); + CMenuManager::SaveSettings(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + } + break; + case MENUACTION_CTRLMETHOD: + CMenuManager::m_ControlMethod = !m_ControlMethod; + CCamera::m_bUseMouse3rdPerson = !m_ControlMethod; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + CMenuManager::SaveSettings(); + break; + } + ProcessOnOffMenuOptions(); + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + if (changeValueBy < 1) { + field_530 = 0; + } else { + field_530 = 14; + } + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } } } #endif @@ -2141,7 +3366,7 @@ void CMenuManager::ProcessOnOffMenuOptions() m_PrefsUseWideScreen = !m_PrefsUseWideScreen; #else m_PrefsUseWideScreen++; - if(m_PrefsUseWideScreen > 2) + if (m_PrefsUseWideScreen > 2) m_PrefsUseWideScreen = 0; #endif DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); @@ -2180,7 +3405,7 @@ void CMenuManager::ProcessOnOffMenuOptions() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); SaveSettings(); break; - case MENUACTION_DYNAMICACOUSTIC: + case MENUACTION_DYNAMICACOUSTIC: m_PrefsDMA = !m_PrefsDMA; DMAudio.SetDynamicAcousticModelingStatus(m_PrefsDMA); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); @@ -2195,26 +3420,22 @@ void CMenuManager::ProcessOnOffMenuOptions() } #endif -#if ALL_ORIGINAL_FRONTEND -WRAPPER void CMenuManager::RequestFrontEndShutdown() { EAXJMP(0x488750); } -#else -void CMenuManager::RequestFrontEndShutdown() +void CMenuManager::RequestFrontEndShutDown() { m_bShutDownFrontEndRequested = true; DMAudio.ChangeMusicMode(MUSICMODE_GAME); } -#endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::RequestFrontEndStartUp() { EAXJMP(0x488770); } #else void CMenuManager::RequestFrontEndStartUp() { - m_bStartUpFrontEndRequested = 1; + m_bStartUpFrontEndRequested = true; } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::ResetHelperText() { EAXJMP(0x48B470); } #else void CMenuManager::ResetHelperText() @@ -2230,37 +3451,25 @@ void CMenuManager::SaveLoadFileError_SetUpErrorScreen() case SAVESTATUS_ERR_SAVE_CREATE: case SAVESTATUS_ERR_SAVE_WRITE: case SAVESTATUS_ERR_SAVE_CLOSE: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_FAILED; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + ChangeScreen(MENUPAGE_SAVE_FAILED, 0, true, false); break; case SAVESTATUS_ERR_LOAD_OPEN: case SAVESTATUS_ERR_LOAD_READ: case SAVESTATUS_ERR_LOAD_CLOSE: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_LOAD_FAILED; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + ChangeScreen(MENUPAGE_LOAD_FAILED, 0, true, false); break; case SAVESTATUS_ERR_DATA_INVALID: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_LOAD_FAILED_2; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + ChangeScreen(MENUPAGE_LOAD_FAILED_2, 0, true, false); break; case SAVESTATUS_DELETEFAILED8: case SAVESTATUS_DELETEFAILED9: case SAVESTATUS_DELETEFAILED10: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_FAILED; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + ChangeScreen(MENUPAGE_DELETE_FAILED, 0, true, false); break; } } -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::SetHelperText(int text) { EAXJMP(0x48B450); } #else void CMenuManager::SetHelperText(int text) @@ -2270,7 +3479,7 @@ void CMenuManager::SetHelperText(int text) } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::ShutdownJustMenu() { EAXJMP(0x488920); } #else void CMenuManager::ShutdownJustMenu() @@ -2329,6 +3538,8 @@ void CMenuManager::SwitchMenuOnAndOff() m_nCurrScreen = MENUPAGE_NONE; } } + + // Just entered the save/safe zone if (m_bSaveMenuActive && !m_bQuitGameNoCD) { m_bSaveMenuActive = false; m_bMenuActive = true; @@ -2351,7 +3562,7 @@ void CMenuManager::SwitchMenuOnAndOff() } */ if (!m_bMenuActive) - field_112 = 1; + m_bMenuNotProcessed = true; m_bStartUpFrontEndRequested = false; m_bShutDownFrontEndRequested = false; @@ -2384,7 +3595,7 @@ void CMenuManager::UnloadTextures() } #endif -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } #else void CMenuManager::WaitForUserCD() @@ -2403,7 +3614,6 @@ void CMenuManager::WaitForUserCD() } #endif -// New content: #if 0 uint8 CMenuManager::GetNumberOfMenuOptions() { @@ -2416,250 +3626,15 @@ uint8 CMenuManager::GetNumberOfMenuOptions() } return Rows; } - -void CMenuManager::SwitchToNewScreen(int32 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 = 0; - // - m_nCurrExOption = 0; - m_nCurrExLayer = 19; - // - m_nMenuFadeAlpha = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else { - m_nPrevScreen = MENUPAGE_NONE; - m_nCurrScreen = MENUPAGE_NONE; - m_nCurrOption = 0; - } - } - - // Set player skin. - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - CPlayerSkin::BeginFrontendSkinEdit(); - 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(int32 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.2f; - 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; - } -} #endif -// 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 GetMouseClickLeft() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB); -} - -bool GetMouseClickRight() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB); -} - -bool GetMouseClickMiddle() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.MMB && !CPad::GetPad(0)->OldMouseControllerState.MMB); -} - -bool GetMouseWheelUp() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP); -} - -bool GetMouseWheelDown() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN); -} - - -bool GetMouseForward() -{ - return GetMouseClickLeft(); -} - -bool GetMouseBack() -{ - return GetMouseClickRight(); -} - -bool GetMousePos() -{ - return - (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->OldMouseControllerState.y != 0.0f); -} - -bool GetMouseMoveLeft() -{ - return GetMouseWheelDown(); -} - -bool GetMouseMoveRight() -{ - return GetMouseWheelUp(); -} - -bool GetPadInput() -{ - return - GetPadBack() || - GetPadForward() || - GetPadMoveUp() || - GetPadMoveDown() || - GetPadMoveLeft() || - GetPadMoveRight(); -} - -bool GetMouseInput() -{ - return - GetMouseForward() || - GetMouseBack() || - GetMousePos() || - GetMouseMoveLeft() || - GetMouseMoveRight(); -} - STARTPATCHES -#if ALL_ORIGINAL_FRONTEND +#if DONT_USE_SUSPICIOUS_FUNCS #else - InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); - for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); #endif + InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A540, &CMenuManager::DrawFrontEnd, PATCH_JUMP); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 18a324ed..6d7327d3 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -212,7 +212,7 @@ enum eMenuAction MENUACTION_LANG_GER, MENUACTION_LANG_ITA, MENUACTION_LANG_SPA, - MENUACTION_UPDATESAVE, + MENUACTION_POPULATESLOTS_CHANGEMENU, MENUACTION_CHECKSAVE, MENUACTION_UNK24, MENUACTION_NEWGAME, @@ -239,7 +239,7 @@ enum eMenuAction MENUACTION_PARSEHEAP, MENUACTION_SHOWCULL, MENUACTION_MEMCARDSAVECONFIRM, - MENUACTION_UPDATEMEMCARDSAVE, + MENUACTION_RESUME_FROM_SAVEZONE, MENUACTION_UNK50, MENUACTION_DEBUGSTREAM, MENUACTION_MPMAP_LIBERTY, @@ -272,7 +272,7 @@ enum eMenuAction MENUACTION_SHOWHEADBOB, MENUACTION_UNK80, MENUACTION_INVVERT, - MENUACTION_CANCLEGAME, + MENUACTION_CANCELGAME, MENUACTION_MP_PLAYERNUMBER, MENUACTION_MOUSESENS, MENUACTION_CHECKMPGAMES, @@ -283,7 +283,7 @@ enum eMenuAction MENUACTION_MP_LAN, MENUACTION_MP_INTERNET, MENUACTION_RESUME, - MENUACTION_DONTCANCLE, + MENUACTION_DONTCANCEL, MENUACTION_SCREENRES, MENUACTION_AUDIOHW, MENUACTION_SPEAKERCONF, @@ -307,27 +307,37 @@ enum eCheckHover { HOVEROPTION_0, HOVEROPTION_1, - HOVEROPTION_DEFAULT, + HOVEROPTION_RANDOM_ITEM, HOVEROPTION_3, HOVEROPTION_4, HOVEROPTION_5, HOVEROPTION_6, HOVEROPTION_7, HOVEROPTION_8, - HOVEROPTION_9, + HOVEROPTION_BACK, // used in controller setup HOVEROPTION_10, HOVEROPTION_11, - HOVEROPTION_12, - HOVEROPTION_13, - HOVEROPTION_14, - HOVEROPTION_15, - HOVEROPTION_16, - HOVEROPTION_17, - HOVEROPTION_18, + HOVEROPTION_OVER_SCROLL_UP, + HOVEROPTION_OVER_SCROLL_DOWN, + HOVEROPTION_CLICKED_SCROLL_UP, + HOVEROPTION_CLICKED_SCROLL_DOWN, + HOVEROPTION_HOLDING_SCROLLBAR, + HOVEROPTION_PAGEUP, + HOVEROPTION_PAGEDOWN, HOVEROPTION_19, HOVEROPTION_20, HOVEROPTION_CHANGESKIN, - HOVEROPTION_INCREASE_BRIGHTNESS = 32, + HOVEROPTION_RADIO_0, + HOVEROPTION_RADIO_1, + HOVEROPTION_RADIO_2, + HOVEROPTION_RADIO_3, + HOVEROPTION_RADIO_4, + HOVEROPTION_RADIO_5, + HOVEROPTION_RADIO_6, + HOVEROPTION_RADIO_7, + HOVEROPTION_RADIO_8, + HOVEROPTION_RADIO_9, + HOVEROPTION_INCREASE_BRIGHTNESS, HOVEROPTION_DECREASE_BRIGHTNESS, HOVEROPTION_INCREASE_DRAWDIST, HOVEROPTION_DECREASE_DRAWDIST, @@ -337,7 +347,7 @@ enum eCheckHover HOVEROPTION_DECREASE_SFXVOLUME, HOVEROPTION_INCREASE_MOUSESENS, HOVEROPTION_DECREASE_MOUSESENS, - HOVEROPTION_42, + HOVEROPTION_NOT_HOVERING, }; enum @@ -353,13 +363,19 @@ enum eControlMethod struct tSkinInfo { - int field_0; + int32 field_0; char skinName[256]; char currSkinName[256]; char date[256]; tSkinInfo *field_304; }; +struct BottomBarOption +{ + char name[8]; + int32 screenId; +}; + struct CMenuScreen { char m_ScreenName[8]; @@ -387,8 +403,8 @@ public: int32 m_nHelperTextMsgId; bool m_bLanguageLoaded; bool m_bMenuActive; - char field_112; - char field_113; + bool m_bMenuNotProcessed; + bool m_bWaitingForNewKeyBind; bool m_bStartGameLoading; bool m_bFirstTime; bool m_bGameNotLoaded; @@ -399,46 +415,46 @@ public: bool m_bShowMouse; tSkinInfo m_sSkin; tSkinInfo *m_pSelectedSkin; - tSkinInfo *field_438; - float field_43C; - int m_nCurrExSize; - int m_nSkinsTotal; + int32 m_nFirstVisibleRowOnList; + float m_nCurListItemY; + int32 m_nTotalListRow; + int32 m_nSkinsTotal; char _unk0[4]; - int m_nCurrExOption; + int32 m_nSelectedListRow; bool m_bSkinsFound; bool m_bQuitGameNoCD; bool m_bRenderGameInMenu; bool m_bSaveMenuActive; bool m_bLoadingSavedGame; char field_455; - char field_456; + bool m_bStartWaitingForKeyBind; bool m_bSpritesLoaded; CSprite2d m_aFrontEndSprites[28]; CSprite2d m_aMenuSprites[20]; - int field_518; - int m_nMenuFadeAlpha; - char field_520; - char field_521; - char field_522; - char field_523; - char field_524; - int m_CurrCntrlAction; + int32 field_518; + int32 m_nMenuFadeAlpha; + bool m_bPressedPgUpOnList; + bool m_bPressedPgDnOnList; + bool m_bPressedUpOnList; + bool m_bPressedDownOnList; + bool m_bPressedScrollButton; + int32 m_CurrCntrlAction; char _unk1[4]; - int field_530; - char field_534; - char field_535; - int8 m_nCurrExLayer; - int m_nHelperTextAlpha; - int m_nMouseOldPosX; - int m_nMouseOldPosY; - int m_nHoverOption; - int m_nCurrScreen; - int m_nCurrOption; - int m_nPrevOption; - int m_nPrevScreen; + int32 field_530; + bool m_bKeyIsOK; + bool field_535; + int8 m_nCurrExLayer; // TODO: What's that? + int32 m_nHelperTextAlpha; + int32 m_nMouseOldPosX; + int32 m_nMouseOldPosY; + int32 m_nHoverOption; + int32 m_nCurrScreen; + int32 m_nCurrOption; + int32 m_nPrevOption; + int32 m_nPrevScreen; uint32 field_558; - int m_nCurrSaveSlot; - int m_nScreenChangeDelayTimer; + int32 m_nCurrSaveSlot; + int32 m_nScreenChangeDelayTimer; public: bool GetIsMenuActive() {return !!m_bMenuActive;} @@ -473,8 +489,8 @@ public: static float &menuXYpadding; static float &actionTextScaleX; static float &actionTextScaleY; - static int &sthWithButtons; - static int &sthWithButtons2; + static int32 &sthWithButtons; + static int32 &sthWithButtons2; public: static void BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2); @@ -510,7 +526,7 @@ public: void Process(); void ProcessButtonPresses(); void ProcessOnOffMenuOptions(); - static void RequestFrontEndShutdown(); + static void RequestFrontEndShutDown(); static void RequestFrontEndStartUp(); void ResetHelperText(); void SaveLoadFileError_SetUpErrorScreen(); @@ -526,8 +542,6 @@ public: // New content: uint8 GetNumberOfMenuOptions(); - void SwitchToNewScreen(int32 screen); - void SetDefaultPreferences(int32 screen); }; static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 7796484c..427d01bf 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -14,8 +14,8 @@ const CMenuScreen aScreens[] = { // MENUPAGE_NEW_GAME = 2 { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 0, 1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, - MENUACTION_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, - MENUACTION_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, + MENUACTION_POPULATESLOTS_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, + MENUACTION_POPULATESLOTS_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -29,7 +29,7 @@ const CMenuScreen aScreens[] = { MENUACTION_CTRLCONFIG, "FEC_CCF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, MENUACTION_CTRLDISPLAY, "FEC_CDP", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, MENUACTION_CTRLVIBRATION, "FEC_VIB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SOUND_SETTINGS = 5 @@ -41,7 +41,7 @@ const CMenuScreen aScreens[] = { MENUACTION_DYNAMICACOUSTIC, "FET_DAM", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_RADIO, "FEA_RSS", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_GRAPHICS_SETTINGS = 6 @@ -98,7 +98,7 @@ const CMenuScreen aScreens[] = { { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 0, 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 @@ -175,15 +175,14 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SAVE = 24 #ifdef PS2_SAVE_DIALOG { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FESZ_SA", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, - MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, #else { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_UPDATESAVE, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, - MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_POPULATESLOTS_CHANGEMENU, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, + MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, #endif @@ -194,15 +193,15 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CHOOSE_SAVE_SLOT = 26 { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 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_RESUME_FROM_SAVEZONE, "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, }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 @@ -298,10 +297,10 @@ const CMenuScreen aScreens[] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 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, }, @@ -309,7 +308,7 @@ const CMenuScreen aScreens[] = { { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_CANCLEGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CANCELGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVING_IN_PROGRESS = 43 @@ -320,7 +319,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SAVE_SUCCESSFUL = 44 { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FES_SSC", SAVESLOT_LABEL, MENUPAGE_NONE, - MENUACTION_UPDATEMEMCARDSAVE, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, + MENUACTION_RESUME_FROM_SAVEZONE, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_DELETING = 45 @@ -380,12 +379,12 @@ const CMenuScreen aScreens[] = { // MENUPAGE_SKIN_SELECT = 54 { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 4, 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, 1, 1, - //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 diff --git a/src/core/Pad.h b/src/core/Pad.h index 09e6b39d..09691128 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -256,6 +256,11 @@ public: bool GetMouseX1JustDown() { return !!(NewMouseControllerState.MXB1 && !OldMouseControllerState.MXB1); } bool GetMouseX2JustDown() { return !!(NewMouseControllerState.MXB2 && !OldMouseControllerState.MXB2); } + bool GetLeftMouseJustUp() { return !!(!NewMouseControllerState.LMB && OldMouseControllerState.LMB); } + bool GetRightMouseJustUp() { return !!(!NewMouseControllerState.RMB && OldMouseControllerState.RMB); } + bool GetMiddleMouseJustUp() { return !!(!NewMouseControllerState.MMB && OldMouseControllerState.MMB); } + bool GetMouseWheelUpJustUp() { return !!(!NewMouseControllerState.WHEELUP && OldMouseControllerState.WHEELUP); } + bool GetMouseWheelDownJustUp() { return !!(!NewMouseControllerState.WHEELDN && OldMouseControllerState.WHEELDN); } bool GetLeftMouse() { return NewMouseControllerState.LMB; } bool GetRightMouse() { return NewMouseControllerState.RMB; } @@ -328,6 +333,12 @@ public: bool GetEnterJustDown() { return GetPadEnterJustDown() || GetReturnJustDown(); } bool GetAltJustDown() { return GetLeftAltJustDown() || GetRightAltJustDown(); } + bool GetLeftJustUp() { return !!(!NewKeyState.LEFT && OldKeyState.LEFT); } + bool GetRightJustUp() { return !!(!NewKeyState.RIGHT && OldKeyState.RIGHT); } + bool GetEnterJustUp() { return GetPadEnterJustUp() || GetReturnJustUp(); } + bool GetReturnJustUp() { return !!(!NewKeyState.EXTENTER && OldKeyState.EXTENTER); } + bool GetPadEnterJustUp() { return !!(!NewKeyState.ENTER && OldKeyState.ENTER); } + bool GetChar(int32 c) { return NewKeyState.VK_KEYS[c]; } bool GetF(int32 n) { return NewKeyState.F[n]; } bool GetEscape() { return NewKeyState.ESC; } @@ -392,6 +403,13 @@ public: bool GetLeftStickXJustDown() { return !!(NewState.LeftStickX && !OldState.LeftStickX); } bool GetLeftStickYJustDown() { return !!(NewState.LeftStickY && !OldState.LeftStickY); } + bool GetCrossJustUp() { return !!(!NewState.Cross && OldState.Cross); } + bool GetSquareJustUp() { return !!(!NewState.Square && OldState.Square); } + bool GetDPadUpJustUp() { return !!(!NewState.DPadUp && OldState.DPadUp); } + bool GetDPadDownJustUp() { return !!(!NewState.DPadDown && OldState.DPadDown); } + bool GetDPadLeftJustUp() { return !!(!NewState.DPadLeft && OldState.DPadLeft); } + bool GetDPadRightJustUp() { return !!(!NewState.DPadRight && OldState.DPadRight); } + bool GetTriangle() { return !!NewState.Triangle; } bool GetCircle() { return !!NewState.Circle; } bool GetCross() { return !!NewState.Cross; } diff --git a/src/core/config.h b/src/core/config.h index 03b8a019..d12b0809 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -162,6 +162,7 @@ enum Config { #define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC #define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box +// #define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. // Script #define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index e8260fa2..0336fa9b 100644 --- a/src/modelinfo/PedModelInfo.h +++ b/src/modelinfo/PedModelInfo.h @@ -2,6 +2,7 @@ #include "ClumpModelInfo.h" #include "PedType.h" +#include "PedStats.h" enum PedNode { PED_TORSO, @@ -24,7 +25,7 @@ class CPedModelInfo : public CClumpModelInfo public: uint32 m_animGroup; ePedType m_pedType; - uint32 m_pedStatType; + ePedStats m_pedStatType; uint32 m_carsCanDrive; CColModel *m_hitColModel; RpAtomic *m_head; diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index bf0cc59c..53ae1747 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -259,17 +259,17 @@ CCopPed::ScanForCrimes(void) } } - // Look for stolen cop cars (it was broken until now) + // Look for stolen cop cars if (!m_bIsInPursuit) { CPlayerPed *player = FindPlayerPed(); -#ifdef FIX_BUGS - if ((player->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || player->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) -#else if ((m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) -#endif - && player->m_pWanted->m_nWantedLevel == 0 && player->m_pMyVehicle) { + && player->m_pWanted->m_nWantedLevel == 0) { - if (player->m_pMyVehicle->bIsLawEnforcer) + if (player->m_pMyVehicle +#ifdef FIX_BUGS + && m_pMyVehicle == player->m_pMyVehicle +#endif + && player->m_pMyVehicle->bIsLawEnforcer) player->SetWantedLevelNoDrop(1); } } diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 3c62512e..b7dbab82 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2261,7 +2261,7 @@ CPed::SetModelIndex(uint32 mi) RpAnimBlendClumpInit(GetClump()); RpAnimBlendClumpFillFrameArray(GetClump(), m_pFrames); CPedModelInfo *modelInfo = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex); - SetPedStats((ePedStats) modelInfo->m_pedStatType); + SetPedStats(modelInfo->m_pedStatType); m_headingRate = m_pedStats->m_headingChangeRate; m_animGroup = (AssocGroupId) modelInfo->m_animGroup; CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE); @@ -6928,11 +6928,9 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg) if (obstacle) { animAssoc->flags |= ASSOC_DELETEFADEDOUT; -#ifndef VC_PED_PORTS + + // ANIM_HIT_WALL in VC (which makes more sense) CAnimBlendAssociation *handsCoverAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_HANDSCOWER, 8.0f); -#else - CAnimBlendAssociation* handsCoverAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_HIT_WALL, 8.0f); -#endif handsCoverAssoc->flags &= ~ASSOC_FADEOUTWHENDONE; handsCoverAssoc->SetFinishCallback(FinishHitHeadCB, ped); ped->bIsLanding = true; diff --git a/src/peds/PedStats.cpp b/src/peds/PedStats.cpp index c393fddc..147f11e2 100644 --- a/src/peds/PedStats.cpp +++ b/src/peds/PedStats.cpp @@ -4,7 +4,8 @@ #include "FileMgr.h" #include "PedStats.h" -CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4; +//CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4; +CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS]; void CPedStats::Initialise(void) @@ -68,9 +69,9 @@ CPedStats::LoadPedStats(void) line[linelen++] = ' '; else line[linelen++] = buf[bp]; - line[linelen] = '\0'; } bp++; + line[linelen] = '\0'; // skip white space for(lp = 0; line[lp] <= ' '; lp++); @@ -107,14 +108,13 @@ CPedStats::LoadPedStats(void) delete[] buf; } -int32 +ePedStats CPedStats::GetPedStatType(char *name) { - int type; - - for(type = 0; type < NUM_PEDSTATS; type++) + for(uint16 type = 0; type < NUM_PEDSTATS; type++) if(!CGeneral::faststrcmp(ms_apPedStats[type]->m_name, name)) - return type; + return (ePedStats) type; + return NUM_PEDSTATS; } diff --git a/src/peds/PedStats.h b/src/peds/PedStats.h index ce92d4da..4c35e8ee 100644 --- a/src/peds/PedStats.h +++ b/src/peds/PedStats.h @@ -69,11 +69,11 @@ public: float m_defendWeakness; int16 m_flags; - static CPedStats* (&ms_apPedStats)[NUM_PEDSTATS]; + static CPedStats *ms_apPedStats[NUM_PEDSTATS]; static void Initialise(void); static void Shutdown(void); static void LoadPedStats(void); - static int32 GetPedStatType(char *name); + static ePedStats GetPedStatType(char *name); }; static_assert(sizeof(CPedStats) == 0x34, "CPedStats: error"); diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index 3b95109d..4c9d6b3f 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -63,9 +63,9 @@ CPedType::LoadPedData(void) line[linelen++] = ' '; else line[linelen++] = buf[bp]; - line[linelen] = '\0'; } bp++; + line[linelen] = '\0'; // skip white space for(lp = 0; line[lp] <= ' '; lp++); @@ -74,7 +74,7 @@ CPedType::LoadPedData(void) line[lp] == '#') continue; - // FIX: game just uses line here + // Game uses just "line" here since sscanf already trims whitespace, but this is safer sscanf(&line[lp], "%s", word); if(strncmp(word, "Threat", 7) == 0){ @@ -195,7 +195,8 @@ void CPedType::Load(uint8 *buf, uint32 size) { INITSAVEBUF - CheckSaveHeader(buf, 'P','T','P','\0', size - SAVE_HEADER_SIZE); + // original: SkipSaveBuf(buf, SAVE_HEADER_SIZE); + CheckSaveHeader(buf, 'P', 'T', 'P', '\0', size - SAVE_HEADER_SIZE); for(int i = 0; i < NUM_PEDTYPES; i++) *ms_apPedType[i] = ReadSaveBuf<CPedType>(buf); diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 496ece34..bb5ec475 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -30,7 +30,8 @@ // More clearly they're transition areas between zones. RegenerationPoint (&aSafeZones)[8] = *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578; -PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; +//PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; +PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6; int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; @@ -80,7 +81,7 @@ CPopulation::Initialise() ms_nNumDummy = 0; m_AllRandomPedsThisType = -1; - PedDensityMultiplier = 1.0; + PedDensityMultiplier = 1.0f; bZoneChangeHasHappened = false; m_CountDownToPedsAtStart = 2; @@ -511,9 +512,9 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors) uint32 weapon; if (CGeneral::GetRandomNumberInRange(0, 100) >= 50) - weapon = ped->GiveWeapon(CGangs::GetGangWeapon2(pedType - PEDTYPE_GANG1), 25001); + weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon2, 25001); else - weapon = ped->GiveWeapon(CGangs::GetGangWeapon1(pedType - PEDTYPE_GANG1), 25001); + weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon1, 25001); ped->SetCurrentWeapon(weapon); return ped; } @@ -770,7 +771,7 @@ CPopulation::AddPedInCar(CVehicle* car) // fall through default: - int gangOfPed = GANG_MAFIA; + int gangOfPed = 0; imSureThatModelIsLoaded = false; while (gangOfPed < NUM_GANGS && CGangs::GetGangInfo(gangOfPed)->m_nVehicleMI != car->m_modelIndex) diff --git a/src/peds/Population.h b/src/peds/Population.h index 152fb7ae..b299c0a1 100644 --- a/src/peds/Population.h +++ b/src/peds/Population.h @@ -33,7 +33,7 @@ struct RegenerationPoint class CPopulation { public: - static PedGroup (&ms_pPedGroups)[NUMPEDGROUPS]; + static PedGroup ms_pPedGroups[NUMPEDGROUPS]; static bool &ms_bGivePedsWeapons; static int32 &m_AllRandomPedsThisType; static float &PedDensityMultiplier; |