diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Cam.cpp | 16 | ||||
-rw-r--r-- | src/core/Camera.cpp | 128 | ||||
-rw-r--r-- | src/core/Camera.h | 37 | ||||
-rw-r--r-- | src/core/Frontend.cpp | 239 | ||||
-rw-r--r-- | src/core/Frontend.h | 35 | ||||
-rw-r--r-- | src/core/MenuScreens.h | 25 | ||||
-rw-r--r-- | src/core/Radar.cpp | 183 | ||||
-rw-r--r-- | src/core/Radar.h | 10 | ||||
-rw-r--r-- | src/core/config.h | 2 |
9 files changed, 549 insertions, 126 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 5b7a53e9..dc9ef74f 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -4672,15 +4672,15 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, else { switch ((int)TheCamera.CarZoomIndicator) { // near - case 1: + case CAM_ZOOM_1: zoomModeAlphaOffset = ZmOneAlphaOffsetLCS[alphaArrPos]; break; // mid - case 2: + case CAM_ZOOM_2: zoomModeAlphaOffset = ZmTwoAlphaOffsetLCS[alphaArrPos]; break; // far - case 3: + case CAM_ZOOM_3: zoomModeAlphaOffset = ZmThreeAlphaOffsetLCS[alphaArrPos]; break; default: @@ -4705,14 +4705,12 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, } } else { // 0.6f = fTestShiftHeliCamTarget - TargetCoors.x += 0.6f * car->GetUp().x * colMaxZ; - TargetCoors.y += 0.6f * car->GetUp().y * colMaxZ; - TargetCoors.z += 0.6f * car->GetUp().z * colMaxZ; + TargetCoors += 0.6f * car->GetUp() * colMaxZ; } float minDistForVehType = CARCAM_SET[camSetArrPos][4]; - if ((int)TheCamera.CarZoomIndicator == 1 && (camSetArrPos < 2 || camSetArrPos == 7)) { + if (TheCamera.CarZoomIndicator == CAM_ZOOM_1 && (camSetArrPos < 2 || camSetArrPos == 7)) { minDistForVehType = minDistForVehType * 0.65f; } @@ -4904,8 +4902,8 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, // yMovement = 0.0; if (!nextDirectionIsForward) { - yMovement = 0.0; - xMovement = 0.0; + yMovement = 0.0f; + xMovement = 0.0f; } if (camSetArrPos == 0 || camSetArrPos == 7) { diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index e5bc09c8..46c17cd2 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -65,8 +65,8 @@ bool &bDidWeProcessAnyCinemaCam = *(bool*)0x95CD46; #define KEYJUSTDOWN(k) ControlsManager.GetIsKeyboardKeyJustDown((RsKeyCodes)k) #define KEYDOWN(k) ControlsManager.GetIsKeyboardKeyDown((RsKeyCodes)k) #define CTRLJUSTDOWN(key) \ - ((KEYDOWN(rsLCTRL) || KEYDOWN(rsRCTRL)) && KEYJUSTDOWN((RsKeyCodes)key) || \ - (KEYJUSTDOWN(rsLCTRL) || KEYJUSTDOWN(rsRCTRL)) && KEYDOWN((RsKeyCodes)key)) + ((KEYDOWN(rsLCTRL) || KEYDOWN(rsRCTRL)) && KEYJUSTDOWN((RsKeyCodes)key) || \ + (KEYJUSTDOWN(rsLCTRL) || KEYJUSTDOWN(rsRCTRL)) && KEYDOWN((RsKeyCodes)key)) #define CTRLDOWN(key) ((KEYDOWN(rsLCTRL) || KEYDOWN(rsRCTRL)) && KEYDOWN((RsKeyCodes)key)) #endif @@ -124,8 +124,8 @@ CCamera::Init(void) m_WideScreenOn = false; m_fFOV_Wide_Screen = 0.0f; m_bRestoreByJumpCut = false; - CarZoomIndicator = 2.0f; - PedZoomIndicator = 2.0f; + CarZoomIndicator = CAM_ZOOM_2; + PedZoomIndicator = CAM_ZOOM_2; CarZoomValueSmooth = 0.0f; m_fPedZoomValueSmooth = 0.0f; pTargetEntity = nil; @@ -623,11 +623,11 @@ CCamera::CamControl(void) if(CPad::GetPad(0)->CycleCameraModeUpJustDown() && !CReplay::IsPlayingBack() && (m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) && !m_WideScreenOn) - CarZoomIndicator -= 1.0f; + CarZoomIndicator--; if(CPad::GetPad(0)->CycleCameraModeDownJustDown() && !CReplay::IsPlayingBack() && (m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) && !m_WideScreenOn) - CarZoomIndicator += 1.0f; + CarZoomIndicator++; if(!m_bFailedCullZoneTestPreviously){ if(CarZoomIndicator < CAM_ZOOM_1STPRS) CarZoomIndicator = CAM_ZOOM_CINEMATIC; else if(CarZoomIndicator > CAM_ZOOM_CINEMATIC) CarZoomIndicator = CAM_ZOOM_1STPRS; @@ -727,12 +727,24 @@ CCamera::CamControl(void) if(CarZoomIndicator == CAM_ZOOM_1STPRS && !m_bPlayerIsInGarage){ CarZoomValue = 0.0f; ReqMode = CCam::MODE_1STPERSON; - }else if(CarZoomIndicator == CAM_ZOOM_1) - CarZoomValue = 0.05f; + } +#ifdef FREE_CAM + else if (bFreeCam) { + if (CarZoomIndicator == CAM_ZOOM_1) + CarZoomValue = ((CVehicle*)pTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_1 : FREE_CAR_ZOOM_VALUE_1; + else if (CarZoomIndicator == CAM_ZOOM_2) + CarZoomValue = ((CVehicle*)pTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_2 : FREE_CAR_ZOOM_VALUE_2; + else if (CarZoomIndicator == CAM_ZOOM_3) + CarZoomValue = ((CVehicle*)pTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_3 : FREE_CAR_ZOOM_VALUE_3; + } +#endif + else if(CarZoomIndicator == CAM_ZOOM_1) + CarZoomValue = DEFAULT_CAR_ZOOM_VALUE_1; else if(CarZoomIndicator == CAM_ZOOM_2) - CarZoomValue = 1.9f; + CarZoomValue = DEFAULT_CAR_ZOOM_VALUE_2; else if(CarZoomIndicator == CAM_ZOOM_3) - CarZoomValue = 3.9f; + CarZoomValue = DEFAULT_CAR_ZOOM_VALUE_3; + if(CarZoomIndicator == CAM_ZOOM_TOPDOWN && !m_bPlayerIsInGarage){ CarZoomValue = 1.0f; ReqMode = CCam::MODE_TOPDOWN; @@ -800,7 +812,7 @@ CCamera::CamControl(void) else PedZoomIndicator = CAM_ZOOM_TOPDOWN; }else - PedZoomIndicator -= 1.0f; + PedZoomIndicator--; } if(CPad::GetPad(0)->CycleCameraModeDownJustDown() && !CReplay::IsPlayingBack() && (m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) && @@ -811,7 +823,7 @@ CCamera::CamControl(void) else PedZoomIndicator = CAM_ZOOM_TOPDOWN; }else - PedZoomIndicator += 1.0f; + PedZoomIndicator++; } // disabled obbe's cam here if(PedZoomIndicator < CAM_ZOOM_1) PedZoomIndicator = CAM_ZOOM_TOPDOWN; @@ -1211,7 +1223,7 @@ CCamera::CamControl(void) ReqMode == CCam::MODE_1STPERSON_RUNABOUT || ReqMode == CCam::MODE_M16_1STPERSON_RUNABOUT || ReqMode == CCam::MODE_FIGHT_CAM_RUNABOUT || ReqMode == CCam::MODE_HELICANNON_1STPERSON || WhoIsInControlOfTheCamera == CAMCONTROL_SCRIPT || - m_bJustCameOutOfGarage || m_bPlayerIsInGarage) + m_bJustCameOutOfGarage || m_bPlayerIsInGarage) canUseObbeCam = false; if(m_bObbeCinematicPedCamOn && canUseObbeCam) @@ -1456,9 +1468,9 @@ CCamera::CamControl(void) // Ped visibility if((Cams[ActiveCam].Mode == CCam::MODE_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_SNIPER || - Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER) && pTargetEntity->IsPed() || + Cams[ActiveCam].Mode == CCam::MODE_SNIPER || + Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || + Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER) && pTargetEntity->IsPed() || Cams[ActiveCam].Mode == CCam::MODE_FLYBY) FindPlayerPed()->bIsVisible = false; else @@ -1512,7 +1524,7 @@ CCamera::UpdateTargetEntity(void) cantOpen = false; if(PLAYER->GetPedState() == PED_ENTER_CAR && !cantOpen){ - if(!enteringCar && CarZoomIndicator != 0.0f){ + if(!enteringCar && CarZoomIndicator != CAM_ZOOM_1STPRS){ pTargetEntity = PLAYER->m_pMyVehicle; if(PLAYER->m_pMyVehicle == nil) pTargetEntity = PLAYER; @@ -1520,7 +1532,7 @@ CCamera::UpdateTargetEntity(void) } if((PLAYER->GetPedState() == PED_CARJACK || PLAYER->GetPedState() == PED_OPEN_DOOR) && !cantOpen){ - if(!enteringCar && CarZoomIndicator != 0.0f) + if(!enteringCar && CarZoomIndicator != CAM_ZOOM_1STPRS) #ifdef GTA_PS2_STUFF // dunno if this has any amazing effects { @@ -1537,7 +1549,7 @@ CCamera::UpdateTargetEntity(void) pTargetEntity = FindPlayerPed(); if(PLAYER->GetPedState() == PED_DRAG_FROM_CAR) pTargetEntity = FindPlayerPed(); - if(pTargetEntity->IsVehicle() && CarZoomIndicator != 0.0f && FindPlayerPed()->GetPedState() == PED_ARRESTED) + if(pTargetEntity->IsVehicle() && CarZoomIndicator != CAM_ZOOM_1STPRS && FindPlayerPed()->GetPedState() == PED_ARRESTED) pTargetEntity = FindPlayerPed(); } } @@ -1554,15 +1566,15 @@ CCamera::UpdateSoundDistances(void) int n; if((Cams[ActiveCam].Mode == CCam::MODE_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_SNIPER || - Cams[ActiveCam].Mode == CCam::MODE_SNIPER_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_1STPERSON_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_HELICANNON_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER) && + Cams[ActiveCam].Mode == CCam::MODE_SNIPER || + Cams[ActiveCam].Mode == CCam::MODE_SNIPER_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_1STPERSON_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_HELICANNON_1STPERSON || + Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || + Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER) && pTargetEntity->IsPed()) center = GetPosition() + 0.5f*GetForward(); else @@ -1844,14 +1856,14 @@ CCamera::StartTransition(int16 newMode) m_bUseTransitionBeta = false; if((Cams[ActiveCam].Mode == CCam::MODE_SNIPER || - Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER || - Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_SNIPER_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM_RUNABOUT || - Cams[ActiveCam].Mode == CCam::MODE_HELICANNON_1STPERSON || - Cams[ActiveCam].Mode == CCam::MODE_1STPERSON_RUNABOUT) && + Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER || + Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON || + Cams[ActiveCam].Mode == CCam::MODE_SNIPER_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM_RUNABOUT || + Cams[ActiveCam].Mode == CCam::MODE_HELICANNON_1STPERSON || + Cams[ActiveCam].Mode == CCam::MODE_1STPERSON_RUNABOUT) && pTargetEntity->IsPed()){ float angle = CGeneral::GetATanOfXY(Cams[ActiveCam].Front.x, Cams[ActiveCam].Front.y) - HALFPI; ((CPed*)pTargetEntity)->m_fRotationCur = angle; @@ -2172,12 +2184,12 @@ CCamera::DrawBordersForWideScreen(void) CSprite2d::DrawRect( CRect(0.0f, (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f, - SCREEN_WIDTH, 0.0f), + SCREEN_WIDTH, 0.0f), CRGBA(0, 0, 0, 255)); CSprite2d::DrawRect( CRect(0.0f, SCREEN_HEIGHT, - SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f), + SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f), CRGBA(0, 0, 0, 255)); } @@ -2619,8 +2631,8 @@ CCamera::ProcessObbeCinemaCameraCar(void) if(!bDidWeProcessAnyCinemaCam || IsItTimeForNewcam(SequenceOfCams[OldMode], TimeForNext)){ // This is very strange code... for(OldMode = (OldMode+1) % 14; - !TryToStartNewCamMode(SequenceOfCams[OldMode]) && i <= 14; - OldMode = (OldMode+1) % 14) + !TryToStartNewCamMode(SequenceOfCams[OldMode]) && i <= 14; + OldMode = (OldMode+1) % 14) i++; TimeForNext = CTimer::GetTimeInMilliseconds(); if(i >= 14){ @@ -2647,8 +2659,8 @@ CCamera::ProcessObbeCinemaCameraPed(void) if(!bDidWeProcessAnyCinemaCam || IsItTimeForNewcam(SequenceOfPedCams[PedOldMode], PedTimeForNext)){ for(PedOldMode = (PedOldMode+1) % 5; - !TryToStartNewCamMode(SequenceOfPedCams[PedOldMode]); - PedOldMode = (PedOldMode+1) % 5); + !TryToStartNewCamMode(SequenceOfPedCams[PedOldMode]); + PedOldMode = (PedOldMode+1) % 5); PedTimeForNext = CTimer::GetTimeInMilliseconds(); } bDidWeProcessAnyCinemaCam = true; @@ -2801,11 +2813,11 @@ CCamera::Process_Train_Camera_Control(void) uint32 node = m_iCurrentTrainCamNode; for(i = 0; i < m_uiNumberOfTrainCamNodes && !found; i++){ if(target->IsWithinArea(m_arrTrainCamNode[node].m_cvecMinPointInRange.x, - m_arrTrainCamNode[node].m_cvecMinPointInRange.y, - m_arrTrainCamNode[node].m_cvecMinPointInRange.z, - m_arrTrainCamNode[node].m_cvecMaxPointInRange.x, - m_arrTrainCamNode[node].m_cvecMaxPointInRange.y, - m_arrTrainCamNode[node].m_cvecMaxPointInRange.z)){ + m_arrTrainCamNode[node].m_cvecMinPointInRange.y, + m_arrTrainCamNode[node].m_cvecMinPointInRange.z, + m_arrTrainCamNode[node].m_cvecMaxPointInRange.x, + m_arrTrainCamNode[node].m_cvecMaxPointInRange.y, + m_arrTrainCamNode[node].m_cvecMaxPointInRange.z)){ m_iCurrentTrainCamNode = node; found = true; } @@ -2956,11 +2968,23 @@ CCamera::SetZoomValueFollowPedScript(int16 dist) void CCamera::SetZoomValueCamStringScript(int16 dist) { - switch (dist) { - case 0: m_fCarZoomValueScript = 0.05f; break; - case 1: m_fCarZoomValueScript = 1.9f; break; - case 2: m_fCarZoomValueScript = 3.9f; break; - default: m_fCarZoomValueScript = m_fCarZoomValueScript; break; +#ifdef FREE_CAM + if (bFreeCam) { + switch (dist) { + case 0: m_fCarZoomValueScript = ((CVehicle*)Cams[ActiveCam].CamTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_1 : FREE_CAR_ZOOM_VALUE_1; break; + case 1: m_fCarZoomValueScript = ((CVehicle*)Cams[ActiveCam].CamTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_2 : FREE_CAR_ZOOM_VALUE_2; break; + case 2: m_fCarZoomValueScript = ((CVehicle*)Cams[ActiveCam].CamTargetEntity)->IsBoat() ? FREE_BOAT_ZOOM_VALUE_3 : FREE_CAR_ZOOM_VALUE_3; break; + default: m_fCarZoomValueScript = m_fCarZoomValueScript; break; + } + } else +#endif + { + switch (dist) { + case 0: m_fCarZoomValueScript = DEFAULT_CAR_ZOOM_VALUE_1; break; + case 1: m_fCarZoomValueScript = DEFAULT_CAR_ZOOM_VALUE_2; break; + case 2: m_fCarZoomValueScript = DEFAULT_CAR_ZOOM_VALUE_3; break; + default: m_fCarZoomValueScript = m_fCarZoomValueScript; break; + } } m_bUseScriptZoomValueCar = true; diff --git a/src/core/Camera.h b/src/core/Camera.h index f21fe913..eca4518a 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -16,12 +16,29 @@ enum }; #define DEFAULT_NEAR (0.9f) -#define CAM_ZOOM_1STPRS (0.0f) -#define CAM_ZOOM_1 (1.0f) -#define CAM_ZOOM_2 (2.0f) -#define CAM_ZOOM_3 (3.0f) -#define CAM_ZOOM_TOPDOWN (4.0f) -#define CAM_ZOOM_CINEMATIC (5.0f) +enum +{ + CAM_ZOOM_1STPRS, + CAM_ZOOM_1, + CAM_ZOOM_2, + CAM_ZOOM_3, + CAM_ZOOM_TOPDOWN, + CAM_ZOOM_CINEMATIC, +}; + +#ifdef FREE_CAM // LCS values +#define FREE_CAR_ZOOM_VALUE_1 (-1.0f) +#define FREE_CAR_ZOOM_VALUE_2 (2.0f) +#define FREE_CAR_ZOOM_VALUE_3 (6.0f) + +#define FREE_BOAT_ZOOM_VALUE_1 (-2.41f) +#define FREE_BOAT_ZOOM_VALUE_2 (6.49f) +#define FREE_BOAT_ZOOM_VALUE_3 (15.0f) +#endif + +#define DEFAULT_CAR_ZOOM_VALUE_1 (0.05f) +#define DEFAULT_CAR_ZOOM_VALUE_2 (1.9f) +#define DEFAULT_CAR_ZOOM_VALUE_3 (3.9f) class CCam { @@ -398,7 +415,11 @@ uint32 unknown; // some counter having to do with music float CamFrontXNorm; float CamFrontYNorm; +#if 0 // TODO: FIX_BUGS once GenericLoad is done + int32 CarZoomIndicator; +#else float CarZoomIndicator; +#endif float CarZoomValue; float CarZoomValueSmooth; @@ -434,7 +455,11 @@ uint32 unknown; // some counter having to do with music float m_ScreenReductionSpeed; float m_AlphaForPlayerAnim1rstPerson; float Orientation; +#if 0 // TODO: FIX_BUGS once GenericLoad is done + int32 PedZoomIndicator; +#else float PedZoomIndicator; +#endif float PlayerExhaustion; float SoundDistUp, SoundDistLeft, SoundDistRight; float SoundDistUpAsRead, SoundDistLeftAsRead, SoundDistRightAsRead; diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index a7851650..98d67fa2 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -27,12 +27,20 @@ #include "World.h" #include "Renderer.h" #include "CdStream.h" +#include "Radar.h" #define DONT_USE_SUSPICIOUS_FUNCS 1 #define TIDY_UP_PBP // ProcessButtonPresses #define MAX_VISIBLE_LIST_ROW 30 #define SCROLLBAR_MAX_HEIGHT 263.0f // actually it's 273. but calculating it from scrollbar drawing code gives 287. i don't know +#ifdef MENU_MAP +bool CMenuManager::bMenuMapActive = false; +float CMenuManager::fMapSize; +float CMenuManager::fMapCenterY; +float CMenuManager::fMapCenterX; +#endif + #ifdef PS2_LIKE_MENU BottomBarOption bbNames[8]; int bbTabCount = 0; @@ -129,7 +137,22 @@ const char* FrontendFilenames[][2] = { {"fe_radio7", "" }, // MSX_FM {"fe_radio8", "" }, // FLASHBACK {"fe_radio9", "" }, // CHATTERBOX -}; +}; + +#ifdef MENU_MAP +const char* MapFilenames[][2] = { + {"mapMid01", "mapMid01A"}, + {"mapMid02", "mapMid02A"}, + {"mapMid03", "mapMid03A"}, + {"mapBot01", "mapBot01A"}, + {"mapBot02", "mapBot02A"}, + {"mapBot03", "mapBot03A"}, + {"mapTop01", "mapTop01A"}, + {"mapTop02", "mapTop02A"}, + {"mapTop03", "mapTop03A"}, +}; +CSprite2d CMenuManager::m_aMapSprites[NUM_MAP_SPRITES]; +#endif // 0x5F3344 const char* MenuFilenames[][2] = { @@ -362,7 +385,7 @@ void CMenuManager::CentreMousePointer() { tagPOINT Point; - if (SCREEN_WIDTH * 0.5f == 0.0f && 0.0f == SCREEN_HEIGHT * 0.5f) { + if (SCREEN_WIDTH * 0.5f != 0.0f && 0.0f != SCREEN_HEIGHT * 0.5f) { Point.x = SCREEN_WIDTH / 2; Point.y = SCREEN_HEIGHT / 2; ClientToScreen(PSGLOBAL(window), &Point); @@ -562,6 +585,11 @@ void CMenuManager::Draw() case MENUPAGE_BRIEFS: PrintBriefs(); break; +#ifdef MENU_MAP + case MENUPAGE_MAP: + PrintMap(); + break; +#endif } // Header height isn't accounted, we will add that later. @@ -1156,7 +1184,7 @@ void CMenuManager::Draw() if (m_nCurrScreen == MENUPAGE_CONTROLLER_SETTINGS) PrintController(); - + /* else if (m_nCurrScreen == MENUPAGE_SKIN_SELECT_OLD) { CSprite2d::DrawRect(CRect(StretchX(180), MENU_Y(98), StretchX(230), MENU_Y(123)), CRGBA(255, 255, 255, FadeIn(255))); CSprite2d::DrawRect(CRect(StretchX(181), MENU_Y(99), StretchX(229), MENU_Y(233)), CRGBA(Player color from PickNewPlayerColour, FadeIn(255))); @@ -2570,7 +2598,12 @@ void CMenuManager::LoadAllTextures() m_aMenuSprites[i].SetTexture(MenuFilenames[i][0], MenuFilenames[i][1]); m_aMenuSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); } - +#ifdef MENU_MAP + for (int i = 0; i < ARRAY_SIZE(MapFilenames); i++) { + m_aMapSprites[i].SetTexture(MapFilenames[i][0], MapFilenames[i][1]); + m_aMapSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); + } +#endif m_bSpritesLoaded = true; CTxdStore::PopCurrentTxd(); } @@ -3756,6 +3789,14 @@ CMenuManager::ProcessButtonPresses(void) break; #endif } else { +#ifdef MENU_MAP + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == MENUPAGE_MAP) { + fMapCenterX = SCREEN_WIDTH / 2; + fMapCenterY = SCREEN_HEIGHT / 3; + fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio(); + } + +#endif ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); } } @@ -4428,7 +4469,10 @@ void CMenuManager::UnloadTextures() printf("REMOVE menu textures\n"); for (int i = 0; i < ARRAY_SIZE(MenuFilenames); ++i) m_aMenuSprites[i].Delete(); - +#ifdef MENU_MAP + for (int i = 0; i < ARRAY_SIZE(MapFilenames); ++i) + m_aMapSprites[i].Delete(); +#endif int menu = CTxdStore::FindTxdSlot("menu"); CTxdStore::RemoveTxd(menu); @@ -4674,6 +4718,191 @@ CMenuManager::PrintController(void) } } +#ifdef MENU_MAP + +#define ZOOM(x, y, in) \ + do { \ + if(fMapSize > SCREEN_WIDTH * 2 && in) \ + break; \ + float z2 = in? 1.1f : 1.f/1.1f; \ + fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \ + fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \ + \ + if (fMapSize < SCREEN_WIDTH / 3 && !in) \ + break; \ + \ + fMapSize *= z2; \ + } while(0) \ + +void +CMenuManager::PrintMap(void) +{ + bMenuMapActive = true; + CRadar::InitFrontEndMap(); + + // Because fMapSize is half of the map length, and map consists of 3x3 tiles. + float halfTile = fMapSize / 3.0f; + + // Darken background a bit + CSprite2d::DrawRect(CRect(0, 0, + SCREEN_WIDTH, SCREEN_HEIGHT), + CRGBA(0, 0, 0, FadeIn(128))); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + + if (SCREEN_WIDTH >= fMapCenterX - fMapSize || SCREEN_HEIGHT >= fMapCenterY - fMapSize) { + m_aMapSprites[MAPTOP1].Draw(CRect(fMapCenterX - fMapSize, fMapCenterY - fMapSize, + fMapCenterX - halfTile, fMapCenterY - halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - fMapSize) { + m_aMapSprites[MAPTOP2].Draw(CRect(fMapCenterX - halfTile, fMapCenterY - fMapSize, + fMapCenterX + halfTile, fMapCenterY - halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - fMapSize) { + m_aMapSprites[MAPTOP3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY - fMapSize, + fMapCenterX + fMapSize, fMapCenterY - halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - fMapSize || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPMID1].Draw(CRect(fMapCenterX - fMapSize, fMapCenterY - halfTile, + fMapCenterX - halfTile, fMapCenterY + halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPMID2].Draw(CRect(fMapCenterX - halfTile, fMapCenterY - halfTile, + fMapCenterX + halfTile, fMapCenterY + halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPMID3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY - halfTile, + fMapCenterX + fMapSize, fMapCenterY + halfTile), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - fMapSize || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPBOT1].Draw(CRect(fMapCenterX - fMapSize, fMapCenterY + halfTile, + fMapCenterX - halfTile, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPBOT2].Draw(CRect(fMapCenterX - halfTile, fMapCenterY + halfTile, + fMapCenterX + halfTile, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); + } + + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + m_aMapSprites[MAPBOT3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY + halfTile, + fMapCenterX + fMapSize, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); + } + + CRadar::DrawBlips(); + + if (CPad::GetPad(0)->GetRightMouseJustDown()) { + if (m_nMousePosY > fMapCenterY - fMapSize && m_nMousePosY < fMapCenterY + fMapSize && + m_nMousePosX > fMapCenterX - fMapSize && m_nMousePosX < fMapCenterX + fMapSize) { + + float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize; + float x = ((m_nMousePosX - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; + float y = 2000.0f - ((m_nMousePosY - diffY) / (fMapSize * 2)) * 4000.0f; + CRadar::ToggleTargetMarker(x, y); + } + } + + if (CPad::GetPad(0)->GetCrossJustDown()) { + if (SCREEN_HEIGHT / 2 > fMapCenterY - fMapSize && SCREEN_HEIGHT / 2 < fMapCenterY + fMapSize && + SCREEN_WIDTH / 2 > fMapCenterX - fMapSize && SCREEN_WIDTH / 2 < fMapCenterX + fMapSize) { + + float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize; + float x = ((SCREEN_WIDTH / 2 - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; + float y = 2000.0f - ((SCREEN_HEIGHT / 2 - diffY) / (fMapSize * 2)) * 4000.0f; + CRadar::ToggleTargetMarker(x, y); + } + } + + if (CPad::GetPad(0)->GetLeftMouse()) { + fMapCenterX += m_nMousePosX - m_nMouseOldPosX; + fMapCenterY += m_nMousePosY - m_nMouseOldPosY; + } else if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetDPadLeft()) { + fMapCenterX += 15.0f; + } else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetDPadRight()) { + fMapCenterX -= 15.0f; + } else if (CPad::GetPad(0)->GetLeftStickX()) { + fMapCenterX -= CPad::GetPad(0)->GetLeftStickX() / 128.0f * 20.0f; + } + + if (CPad::GetPad(0)->GetUp() || CPad::GetPad(0)->GetDPadUp()) { + fMapCenterY += 15.0f; + } else if (CPad::GetPad(0)->GetDown() || CPad::GetPad(0)->GetDPadDown()) { + fMapCenterY -= 15.0f; + } else if (CPad::GetPad(0)->GetLeftStickY()) { + fMapCenterY -= CPad::GetPad(0)->GetLeftStickY() / 128.0f * 20.0f; + } + + if (CPad::GetPad(0)->GetMouseWheelDown() || CPad::GetPad(0)->GetPageUp() || CPad::GetPad(0)->GetRightShoulder2()) { + if (CPad::GetPad(0)->GetMouseWheelDown()) + ZOOM(m_nMousePosX, m_nMousePosY, false); + else + ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, false); + } else if (CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetPageDown() || CPad::GetPad(0)->GetRightShoulder1()) { + if (CPad::GetPad(0)->GetMouseWheelUp()) + ZOOM(m_nMousePosX, m_nMousePosY, true); + else + ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, true); + } + + if (fMapCenterX - fMapSize > SCREEN_WIDTH / 2) + fMapCenterX = fMapSize + SCREEN_WIDTH / 2; + + if (fMapCenterX + fMapSize < SCREEN_WIDTH / 2) + fMapCenterX = SCREEN_WIDTH / 2 - fMapSize; + + if (fMapCenterY + fMapSize < SCREEN_HEIGHT - MENU_Y(60.0f)) + fMapCenterY = SCREEN_HEIGHT - MENU_Y(60.0f) - fMapSize; + + fMapCenterY = min(fMapCenterY, fMapSize); // To not show beyond north border + + bMenuMapActive = false; + + // CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(5.0f)); // From VC + // CFont::SetRightJustifyWrap(10.0f); + + CSprite2d::DrawRect(CRect(MENU_X(14.0f), SCREEN_STRETCH_FROM_BOTTOM(95.0f), + SCREEN_STRETCH_FROM_RIGHT(11.0f), SCREEN_STRETCH_FROM_BOTTOM(59.0f)), + CRGBA(235, 170, 50, 255)); + + CFont::SetScale(MENU_X(0.4f), MENU_Y(0.7f)); + CFont::SetFontStyle(FONT_BANK); + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + + float nextX = MENU_X(30.0f), nextY = 95.0f; + wchar *text; +#define TEXT_PIECE(key,extraSpace) \ + text = TheText.Get(key); CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text); nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace); + + TEXT_PIECE("FEC_MWF", 3.0f); + TEXT_PIECE("FEC_PGD", 1.0f); + TEXT_PIECE("FEC_IBT", 1.0f); + TEXT_PIECE("FEC_ZIN", 20.0f); + TEXT_PIECE("FEC_MWB", 3.0f); + TEXT_PIECE("FEC_PGU", 1.0f); + TEXT_PIECE("FEC_IBT", 1.0f); + CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_ZOT")); nextX = MENU_X(30.0f); nextY -= 11.0f; + TEXT_PIECE("FEC_UPA", 2.0f); + TEXT_PIECE("FEC_DWA", 2.0f); + TEXT_PIECE("FEC_LFA", 2.0f); + TEXT_PIECE("FEC_RFA", 2.0f); + TEXT_PIECE("FEC_MSL", 1.0f); + TEXT_PIECE("FEC_IBT", 1.0f); + CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_MOV")); nextX = MENU_X(30.0f); nextY -= 11.0f; + TEXT_PIECE("FEC_MSR", 2.0f); + TEXT_PIECE("FEC_IBT", 1.0f); + CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_TAR")); +#undef TEXT_PIECE +} + +#undef ZOOM +#endif + #if 0 uint8 CMenuManager::GetNumberOfMenuOptions() { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 4eee198f..a97afb24 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -109,6 +109,8 @@ enum eFrontendSprites FE_RADIO7, FE_RADIO8, FE_RADIO9, + + NUM_FE_SPRITES }; enum eMenuSprites @@ -132,6 +134,8 @@ enum eMenuSprites MENUSPRITE_UPOFF, MENUSPRITE_UPON, MENUSPRITE_GTA3LOGO, + MENUSPRITE_UNUSED, + NUM_MENU_SPRITES }; enum eSaveSlot @@ -149,6 +153,22 @@ enum eSaveSlot SAVESLOT_LABEL = 36 }; +#ifdef MENU_MAP +enum MapSprites +{ + MAPMID1, + MAPMID2, + MAPMID3, + MAPBOT1, + MAPBOT2, + MAPBOT3, + MAPTOP1, + MAPTOP2, + MAPTOP3, + NUM_MAP_SPRITES +}; +#endif + enum eMenuScreen { MENUPAGE_DISABLED = -1, @@ -211,6 +231,9 @@ enum eMenuScreen MENUPAGE_MOUSE_CONTROLS = 56, MENUPAGE_57 = 57, MENUPAGE_58 = 58, +#ifdef MENU_MAP + MENUPAGE_MAP = 59, +#endif MENUPAGES }; @@ -465,8 +488,8 @@ public: char field_455; bool m_bStartWaitingForKeyBind; bool m_bSpritesLoaded; - CSprite2d m_aFrontEndSprites[28]; - CSprite2d m_aMenuSprites[20]; + CSprite2d m_aFrontEndSprites[NUM_FE_SPRITES]; + CSprite2d m_aMenuSprites[NUM_MENU_SPRITES]; int32 field_518; int32 m_nMenuFadeAlpha; bool m_bPressedPgUpOnList; @@ -532,6 +555,14 @@ public: static bool m_PrefsDisableTutorials;
#endif // !MASTER
+#ifdef MENU_MAP + static bool bMenuMapActive; + static float fMapSize; + static float fMapCenterY; + static float fMapCenterX; + static CSprite2d m_aMapSprites[NUM_MAP_SPRITES]; + void PrintMap(); +#endif public: static void BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2); diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index ace6a719..bac8f0a8 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -7,7 +7,11 @@ const CMenuScreen aScreens[] = { { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_STATS = 1 - Both PrintStats and Draw were printing the page name, so deleted the string Draw looked for. +#ifdef MENU_MAP + { ""/*"FET_STA"*/, MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 3, +#else { ""/*"FET_STA"*/, MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, +#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -20,7 +24,11 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_BRIEFS = 3 +#ifdef MENU_MAP + { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 6, 4, +#else { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, +#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -298,7 +306,11 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_OPTIONS = 41 +#ifdef MENU_MAP + { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 5, +#else { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, +#endif MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -308,7 +320,11 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_EXIT = 42 +#ifdef MENU_MAP + { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 6, +#else { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, +#endif MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCELGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, @@ -369,6 +385,9 @@ const CMenuScreen aScreens[] = { { "FET_PAU", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME, "FEM_RES", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, +#ifdef MENU_MAP + MENUACTION_CHANGEMENU, "FEG_MAP", SAVESLOT_NONE, MENUPAGE_MAP, +#endif MENUACTION_CHANGEMENU, "FEP_STA", SAVESLOT_NONE, MENUPAGE_STATS, MENUACTION_CHANGEMENU, "FEP_BRI", SAVESLOT_NONE, MENUPAGE_BRIEFS, MENUACTION_CHANGEMENU, "FET_OPT", SAVESLOT_NONE, MENUPAGE_OPTIONS, @@ -407,4 +426,10 @@ const CMenuScreen aScreens[] = { { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, + +#ifdef MENU_MAP + // MENUPAGE_MAP = 59 + { "FEG_MAP", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, + }, +#endif }; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 3824af7d..07ddb5d8 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -80,7 +80,7 @@ CRGBA CRadar::ArrowBlipColour1; CRGBA CRadar::ArrowBlipColour2;
uint16 CRadar::MapLegendCounter;
uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS];
-bool CRadar::bMenuMapActive;
+int CRadar::TargetMarkerId = -1;
#endif
// taken from VC
@@ -89,6 +89,10 @@ float CRadar::cachedSin; uint8 CRadar::CalculateBlipAlpha(float dist)
{
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive)
+ return 255;
+#endif
if (dist <= 1.0f)
return 255;
@@ -132,9 +136,12 @@ void CRadar::ClearBlip(int32 i) if (index != -1) {
SetRadarMarkerState(index, false);
ms_RadarTrace[index].m_bInUse = false;
+#ifndef MENU_MAP
+ // Ssshhh
ms_RadarTrace[index].m_eBlipType = BLIP_NONE;
ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
- ms_RadarTrace[index].m_IconID = RADAR_SPRITE_NONE;
+ ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE;
+#endif
}
}
@@ -146,7 +153,7 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id) ms_RadarTrace[i].m_bInUse = false;
ms_RadarTrace[i].m_eBlipType = BLIP_NONE;
ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
- ms_RadarTrace[i].m_IconID = RADAR_SPRITE_NONE;
+ ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE;
}
};
}
@@ -233,7 +240,7 @@ int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) bool CRadar::DisplayThisBlip(int32 counter)
{
- switch (ms_RadarTrace[counter].m_IconID) {
+ switch (ms_RadarTrace[counter].m_eRadarSprite) {
case RADAR_SPRITE_BOMB:
case RADAR_SPRITE_SPRAY:
case RADAR_SPRITE_WEAPON:
@@ -309,28 +316,39 @@ void CRadar::DrawBlips() CVector2D in = CVector2D(0.0f, 0.0f);
TransformRadarPointToScreenSpace(out, in);
- float angle;
- if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN)
- angle = PI + FindPlayerHeading();
+#ifdef MENU_MAP
+ if (!CMenuManager::bMenuMapActive) {
+#endif
+ float angle;
+ if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN)
+ angle = PI + FindPlayerHeading();
#ifdef FIX_BUGS
- else if (TheCamera.GetLookDirection() != LOOKING_FORWARD)
- angle = FindPlayerHeading() - (PI + (TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind).Heading());
+ else if (TheCamera.GetLookDirection() != LOOKING_FORWARD)
+ angle = FindPlayerHeading() - (PI + (TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind).Heading());
#endif
- else
- angle = FindPlayerHeading() - (PI + TheCamera.GetForward().Heading());
+ else
+ angle = FindPlayerHeading() - (PI + TheCamera.GetForward().Heading());
- DrawRotatingRadarSprite(&CentreSprite, out.x, out.y, angle, 255);
+ DrawRotatingRadarSprite(&CentreSprite, out.x, out.y, angle, 255);
- CVector2D vec2d;
- vec2d.x = vec2DRadarOrigin.x;
- vec2d.y = M_SQRT2 * m_radarRange + vec2DRadarOrigin.y;
- TransformRealWorldPointToRadarSpace(in, vec2d);
- LimitRadarPoint(in);
- TransformRadarPointToScreenSpace(out, in);
- DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255);
+ CVector2D vec2d;
+ vec2d.x = vec2DRadarOrigin.x;
+ vec2d.y = M_SQRT2 * m_radarRange + vec2DRadarOrigin.y;
+ TransformRealWorldPointToRadarSpace(in, vec2d);
+ LimitRadarPoint(in);
+ TransformRadarPointToScreenSpace(out, in);
+ DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255);
+#ifdef MENU_MAP
+ }
+#endif
CEntity *blipEntity = nil;
for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) {
+#ifdef MENU_MAP
+ // A little hack to reuse cleared blips in menu map. hehe
+ if (!CMenuManager::bMenuMapActive || ms_RadarTrace[blipId].m_eBlipType == BLIP_CAR ||
+ ms_RadarTrace[blipId].m_eBlipType == BLIP_CHAR || ms_RadarTrace[blipId].m_eBlipType == BLIP_OBJECT)
+#endif
if (!ms_RadarTrace[blipId].m_bInUse)
continue;
@@ -338,8 +356,8 @@ void CRadar::DrawBlips() case BLIP_CAR:
case BLIP_CHAR:
case BLIP_OBJECT:
- if (ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SAVE
- || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_WEAPON) {
+ if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
+ || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON) {
switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_CAR:
@@ -372,8 +390,8 @@ void CRadar::DrawBlips() TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) {
- DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist));
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
@@ -394,8 +412,8 @@ void CRadar::DrawBlips() break;
case BLIP_COORD:
case BLIP_CONTACT_POINT:
- if ((ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SAVE
- || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_IconID == RADAR_SPRITE_WEAPON)
+ if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
+ || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON)
&& (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
@@ -411,8 +429,8 @@ void CRadar::DrawBlips() TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE) {
- DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist));
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
@@ -442,8 +460,8 @@ void CRadar::DrawBlips() case BLIP_CAR:
case BLIP_CHAR:
case BLIP_OBJECT:
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SAVE
- && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_WEAPON) {
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
+ && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON) {
switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_CAR:
@@ -477,8 +495,8 @@ void CRadar::DrawBlips() TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE)
- DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist));
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else
#ifdef TRIANGULAR_BLIPS
{
@@ -509,8 +527,8 @@ void CRadar::DrawBlips() switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_COORD:
case BLIP_CONTACT_POINT:
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SAVE
- && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_WEAPON
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
+ && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON
&& (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
@@ -526,8 +544,8 @@ void CRadar::DrawBlips() TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in);
- if (ms_RadarTrace[blipId].m_IconID != RADAR_SPRITE_NONE)
- DrawRadarSprite(ms_RadarTrace[blipId].m_IconID, out.x, out.y, CalculateBlipAlpha(dist));
+ if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
+ DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else
#ifdef TRIANGULAR_BLIPS
{
@@ -550,6 +568,14 @@ void CRadar::DrawBlips() break;
}
}
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive) {
+ CVector2D in, out;
+ TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift());
+ TransformRadarPointToScreenSpace(out, in);
+ DrawYouAreHereSprite(out.x, out.y);
+ }
+#endif
}
}
@@ -701,8 +727,8 @@ void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) {
RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha));
#ifdef MENU_MAP
- if (bMenuMapActive) {
- bool alreadyThere;
+ if (CMenuManager::bMenuMapActive) {
+ bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == sprite)
alreadyThere = true;
@@ -834,7 +860,7 @@ CRadar::Initialise() ms_RadarTrace[i].m_bInUse = false;
ms_RadarTrace[i].m_eBlipType = BLIP_NONE;
ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
- ms_RadarTrace[i].m_IconID = RADAR_SPRITE_NONE;
+ ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE;
}
m_radarRange = 350.0f;
@@ -847,6 +873,10 @@ float CRadar::LimitRadarPoint(CVector2D &point) float dist, invdist;
dist = point.Magnitude();
+#ifdef MENU_MAP
+ if (CMenuManager::bMenuMapActive)
+ return dist;
+#endif
if (dist > 1.0f) {
invdist = 1.0f / dist;
point.x *= invdist;
@@ -930,7 +960,7 @@ void CRadar::SetBlipSprite(int32 i, int32 icon) {
int index = CRadar::GetActualBlipArrayIndex(i);
if (index != -1) {
- ms_RadarTrace[index].m_IconID = icon;
+ ms_RadarTrace[index].m_eRadarSprite = icon;
}
}
@@ -951,7 +981,7 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay ms_RadarTrace[nextBlip].m_nEntityHandle = 0;
ms_RadarTrace[nextBlip].m_wScale = 1;
ms_RadarTrace[nextBlip].m_eBlipDisplay = display;
- ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE;
+ ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_NONE;
return CRadar::GetNewUniqueBlipIndex(nextBlip);
}
@@ -970,7 +1000,7 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla ms_RadarTrace[nextBlip].m_nEntityHandle = handle;
ms_RadarTrace[nextBlip].m_wScale = 1;
ms_RadarTrace[nextBlip].m_eBlipDisplay = display;
- ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE;
+ ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_NONE;
return GetNewUniqueBlipIndex(nextBlip);
}
@@ -1050,8 +1080,8 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, }
#ifdef MENU_MAP
// VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips
- if (bMenuMapActive) {
- bool alreadyThere;
+ if (CMenuManager::bMenuMapActive) {
+ bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == -1)
alreadyThere = true;
@@ -1156,9 +1186,10 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
{ #ifdef MENU_MAP
- if (bMenuMapActive) {
- out.x = MENU_X_LEFT_ALIGNED((0.66193402f * m_nMapNegativePadding * in.x) + (0.2348f * m_nMapNegativePadding) + m_nMapLeftPadding);
- out.y = MENU_Y(m_nMapTopPadding - (0.065807f * m_nMapNegativePadding) - (0.66563499f * m_nMapNegativePadding * in.y));
+ if (CMenuManager::bMenuMapActive) {
+ // fMapSize is actually half map size. Radar range is 1000, so if x is -2000, in.x + 2.0f is 0.
+ out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (in.x + 2.0f) * CMenuManager::fMapSize * 2.0f / 4.0f;
+ out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (2.0f - in.y) * CMenuManager::fMapSize * 2.0f / 4.0f;
} else
#endif
{
@@ -1331,7 +1362,7 @@ CRadar::CalculateCachedSinCos() {
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED
#ifdef MENU_MAP
- || bMenuMapActive
+ || CMenuManager::bMenuMapActive
#endif
) {
cachedSin = 0.0f;
@@ -1361,7 +1392,7 @@ CRadar::InitFrontEndMap() CalculateCachedSinCos();
vec2DRadarOrigin.x = 0.0f;
vec2DRadarOrigin.y = 0.0f;
- m_radarRange = 1190.0f;
+ m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
MapLegendList[i] = RADAR_SPRITE_NONE;
}
@@ -1369,6 +1400,62 @@ CRadar::InitFrontEndMap() ArrowBlipColour1 = CRGBA(0, 0, 0, 0);
ArrowBlipColour2 = CRGBA(0, 0, 0, 0);
}
+
+void
+CRadar::DrawYouAreHereSprite(float x, float y)
+{
+ static uint32 lastChange = 0;
+ static bool show = true;
+
+ if (show) {
+ if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 500) {
+ lastChange = CTimer::GetTimeInMillisecondsPauseMode();
+ show = !show;
+ }
+ } else {
+ if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 200) {
+ lastChange = CTimer::GetTimeInMillisecondsPauseMode();
+ show = !show;
+ }
+ }
+
+ if (show) {
+ float left = x - SCREEN_SCALE_X(12.0f);
+ float top = y - SCREEN_SCALE_Y(2.0f);
+ float right = SCREEN_SCALE_X(12.0) + x;
+ float bottom = y - SCREEN_SCALE_Y(26.0f);
+ CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 217, 106, 255));
+ }
+ MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
+}
+
+void
+CRadar::ToggleTargetMarker(float x, float y)
+{
+ if (TargetMarkerId == -1) {
+ int nextBlip;
+ for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) {
+ if (!ms_RadarTrace[nextBlip].m_bInUse)
+ break;
+ }
+ ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD;
+ ms_RadarTrace[nextBlip].m_nColor = 0x333333FF;
+ ms_RadarTrace[nextBlip].m_bDim = 1;
+ ms_RadarTrace[nextBlip].m_bInUse = 1;
+ ms_RadarTrace[nextBlip].m_Radius = 1.0f;
+ CVector pos(x, y, CWorld::FindGroundZForCoord(x,y));
+ ms_RadarTrace[nextBlip].m_vec2DPos = pos;
+ ms_RadarTrace[nextBlip].m_vecPos = pos;
+ ms_RadarTrace[nextBlip].m_nEntityHandle = 0;
+ ms_RadarTrace[nextBlip].m_wScale = 5;
+ ms_RadarTrace[nextBlip].m_eBlipDisplay = BLIP_DISPLAY_BLIP_ONLY;
+ ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_NONE;
+ TargetMarkerId = CRadar::GetNewUniqueBlipIndex(nextBlip);
+ } else {
+ ClearBlip(TargetMarkerId);
+ TargetMarkerId = -1;
+ }
+}
#endif
STARTPATCHES
diff --git a/src/core/Radar.h b/src/core/Radar.h index fb10967b..6d5bb196 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -69,7 +69,7 @@ struct CBlip float m_Radius; int16 m_wScale; uint16 m_eBlipDisplay; // eBlipDisplay - uint16 m_IconID; // eRadarSprite + uint16 m_eRadarSprite; // eRadarSprite }; static_assert(sizeof(CBlip) == 0x30, "CBlip: error"); @@ -108,12 +108,16 @@ public: static float cachedCos; static float cachedSin; #ifdef MENU_MAP +#define NUM_MAP_LEGENDS 75 static CRGBA ArrowBlipColour1; static CRGBA ArrowBlipColour2; - static uint16 MapLegendList[75]; - static bool bMenuMapActive; + static uint16 MapLegendList[NUM_MAP_LEGENDS]; + static uint16 MapLegendCounter; + static int TargetMarkerId; static void InitFrontEndMap(); + static void DrawYouAreHereSprite(float, float); + static void ToggleTargetMarker(float, float); #endif static uint8 CalculateBlipAlpha(float dist); static void ChangeBlipBrightness(int32 i, int32 bright); diff --git a/src/core/config.h b/src/core/config.h index dfc454a8..f653f724 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -195,7 +195,7 @@ enum Config { #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. -// #define MENU_MAP // Very WIP +#define MENU_MAP // VC-like menu map. Make sure you have new menu.txd // Script #define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default |