Skip to content

Commit bb671b9

Browse files
finish player map naming refactor
1 parent 4ed8a8e commit bb671b9

File tree

7 files changed

+65
-67
lines changed

7 files changed

+65
-67
lines changed

Client/mods/deathmatch/ClientCommands.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,21 @@ void COMMAND_PlayerMap(const char* szCmdLine)
245245
void COMMAND_PlayerMapZoomIn(const char* szCmdLine)
246246
{
247247
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
248-
if (playerMap->IsRadarShowing())
248+
if (playerMap->IsPlayerMapShowing())
249249
playerMap->ZoomIn();
250250
}
251251

252252
void COMMAND_PlayerMapZoomOut(const char* szCmdLine)
253253
{
254254
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
255-
if (playerMap->IsRadarShowing())
255+
if (playerMap->IsPlayerMapShowing())
256256
playerMap->ZoomOut();
257257
}
258258

259259
void COMMAND_PlayerMapMoveNorth(const char* szCmdLine)
260260
{
261261
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
262-
if (!playerMap->IsRadarShowing())
262+
if (!playerMap->IsPlayerMapShowing())
263263
return;
264264

265265
if (playerMap->IsMovingNorth())
@@ -278,7 +278,7 @@ void COMMAND_PlayerMapMoveNorth(const char* szCmdLine)
278278
void COMMAND_PlayerMapMoveSouth(const char* szCmdLine)
279279
{
280280
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
281-
if (!playerMap->IsRadarShowing())
281+
if (!playerMap->IsPlayerMapShowing())
282282
return;
283283

284284
if (playerMap->IsMovingSouth())
@@ -297,7 +297,7 @@ void COMMAND_PlayerMapMoveSouth(const char* szCmdLine)
297297
void COMMAND_PlayerMapMoveEast(const char* szCmdLine)
298298
{
299299
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
300-
if (!playerMap->IsRadarShowing())
300+
if (!playerMap->IsPlayerMapShowing())
301301
return;
302302

303303
if (playerMap->IsMovingEast())
@@ -316,7 +316,7 @@ void COMMAND_PlayerMapMoveEast(const char* szCmdLine)
316316
void COMMAND_PlayerMapMoveWest(const char* szCmdLine)
317317
{
318318
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
319-
if (!playerMap->IsRadarShowing())
319+
if (!playerMap->IsPlayerMapShowing())
320320
return;
321321

322322
if (playerMap->IsMovingWest())
@@ -335,14 +335,14 @@ void COMMAND_PlayerMapMoveWest(const char* szCmdLine)
335335
void COMMAND_PlayerMapAttach(const char* szCmdLine)
336336
{
337337
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
338-
if (playerMap->IsRadarShowing())
338+
if (playerMap->IsPlayerMapShowing())
339339
playerMap->SetAttachedToLocalPlayer(!g_pClientGame->GetPlayerMap()->IsAttachedToLocalPlayer());
340340
}
341341

342342
void COMMAND_PlayerMapOpacityDown(const char* szCmdLine)
343343
{
344344
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
345-
if (!playerMap->IsRadarShowing())
345+
if (!playerMap->IsPlayerMapShowing())
346346
return;
347347

348348
int mapAlpha;
@@ -354,7 +354,7 @@ void COMMAND_PlayerMapOpacityDown(const char* szCmdLine)
354354
void COMMAND_PlayerMapOpacityUp(const char* szCmdLine)
355355
{
356356
CPlayerMap* playerMap = g_pClientGame->GetPlayerMap();
357-
if (!playerMap->IsRadarShowing())
357+
if (!playerMap->IsPlayerMapShowing())
358358
return;
359359

360360
int mapAlpha;

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ void CClientGame::DoPulses()
14361436

14371437
// Check for radar input
14381438
m_pPlayerMap->DoPulse();
1439-
g_pCore->GetGraphics()->SetAspectRatioAdjustmentSuspended(m_pPlayerMap->IsRadarShowing());
1439+
g_pCore->GetGraphics()->SetAspectRatioAdjustmentSuspended(m_pPlayerMap->IsPlayerMapShowing());
14401440

14411441
// Got a local player?
14421442
if (m_pLocalPlayer)

Client/mods/deathmatch/logic/CPlayerMap.cpp

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ enum
2323
MARKER_LAST_SPRITE_INDEX = MARKER_FIRST_SPRITE_INDEX + RADAR_MARKER_LIMIT - 1,
2424
};
2525

26-
constexpr std::array<std::uint32_t, 2> RADAR_IMAGE_SIZES = {1024, 2048};
26+
constexpr std::array<std::uint32_t, 2> MAP_IMAGE_SIZES = {1024, 2048};
2727

2828
CPlayerMap::CPlayerMap(CClientManager* pManager)
2929
{
@@ -32,8 +32,8 @@ CPlayerMap::CPlayerMap(CClientManager* pManager)
3232
m_pRadarMarkerManager = pManager->GetRadarMarkerManager();
3333
m_pRadarAreaManager = m_pManager->GetRadarAreaManager();
3434

35-
// Set the radar bools
36-
m_bIsRadarEnabled = false;
35+
// Set the map bools
36+
m_bIsPlayerMapEnabled = false;
3737
m_bForcedState = false;
3838
m_bIsAttachedToLocal = false;
3939
m_bHideHelpText = false;
@@ -59,9 +59,9 @@ CPlayerMap::CPlayerMap(CClientManager* pManager)
5959
m_pLocalPlayerBlip = g_pCore->GetGraphics()->GetRenderItemManager()->CreateTexture(CalcMTASAPath("MTA\\cgui\\images\\radarset\\02.png"));
6060

6161
// Create the map image
62-
m_pRadarImage = nullptr;
63-
m_radarImageIndex = g_pCore->GetCVars()->GetValue<std::size_t>("mapimage");
64-
SetMapImage(m_radarImageIndex);
62+
m_pPlayerMapImage = nullptr;
63+
m_playerMapImageIndex = g_pCore->GetCVars()->GetValue<std::size_t>("mapimage");
64+
SetMapImage(m_playerMapImageIndex);
6565

6666
// Create the marker textures
6767
CreateMarkerTextures();
@@ -79,13 +79,11 @@ CPlayerMap::CPlayerMap(CClientManager* pManager)
7979
{colorWhiteTransparent, 0.92f, 1.5f, ""},
8080
{colorWhite, 0.95f, 1.0f, SString(_("Change mode: %s"), *GetBoundKeyName("radar_attach"))},
8181

82-
{colorWhite, 0.05f, 1.0f,
83-
SString(_("Zoom: %s/%s Movement: %s, %s, %s, %s Opacity: %s/%s"),
82+
{colorWhite, 0.05f, 1.0f, SString(_("Zoom: %s/%s Movement: %s, %s, %s, %s Opacity: %s/%s"),
8483
*GetBoundKeyName("radar_zoom_in"), *GetBoundKeyName("radar_zoom_out"), *GetBoundKeyName("radar_move_north"),
8584
*GetBoundKeyName("radar_move_east"), *GetBoundKeyName("radar_move_south"), *GetBoundKeyName("radar_move_west"),
8685
*GetBoundKeyName("radar_opacity_down"), *GetBoundKeyName("radar_opacity_up"))},
87-
{colorWhite, 0.07f, 1.0f,
88-
SString(_("Toggle map: %s Toggle help text: %s"),
86+
{colorWhite, 0.07f, 1.0f, SString(_("Toggle map: %s Toggle help text: %s"),
8987
*GetBoundKeyName("radar"), *GetBoundKeyName("radar_help"))},
9088
};
9189

@@ -111,7 +109,7 @@ CPlayerMap::CPlayerMap(CClientManager* pManager)
111109
CPlayerMap::~CPlayerMap()
112110
{
113111
// Delete our images
114-
SAFE_RELEASE(m_pRadarImage);
112+
SAFE_RELEASE(m_pPlayerMapImage);
115113
SAFE_RELEASE(m_pLocalPlayerBlip);
116114

117115
for (uint i = 0; i < m_MarkerTextureList.size(); i++)
@@ -125,25 +123,25 @@ CPlayerMap::~CPlayerMap()
125123
void CPlayerMap::SetMapImage(std::size_t imageIndex)
126124
{
127125
std::uint32_t width, height;
128-
if (imageIndex < RADAR_IMAGE_SIZES.size())
129-
width = height = RADAR_IMAGE_SIZES[imageIndex];
126+
if (imageIndex < MAP_IMAGE_SIZES.size())
127+
width = height = MAP_IMAGE_SIZES[imageIndex];
130128
else // Fail safe, ideally client settings system should not allow this case
131-
width = height = RADAR_IMAGE_SIZES[0];
129+
width = height = MAP_IMAGE_SIZES[0];
132130

133-
SString fileName("MTA\\cgui\\images\\radar_%d.png", width);
131+
SString fileName("MTA\\cgui\\images\\map_%d.png", width);
134132

135-
if (m_pRadarImage)
136-
SAFE_RELEASE(m_pRadarImage);
133+
if (m_pPlayerMapImage)
134+
SAFE_RELEASE(m_pPlayerMapImage);
137135

138-
m_pRadarImage = g_pCore->GetGraphics()->GetRenderItemManager()->CreateTexture(CalcMTASAPath(fileName), nullptr, false, width, height, RFORMAT_DXT1);
136+
m_pPlayerMapImage = g_pCore->GetGraphics()->GetRenderItemManager()->CreateTexture(CalcMTASAPath(fileName), nullptr, false, width, height, RFORMAT_DXT1);
139137

140138
g_pCore->GetConsole()->Printf("Player map image loaded: %s", fileName);
141139
}
142140

143141
void CPlayerMap::DoPulse()
144142
{
145-
// If our radar image exists
146-
if (IsRadarShowing())
143+
// If our map image exists
144+
if (IsPlayerMapShowing())
147145
{
148146
// If we are following the local player blip
149147
if (m_bIsAttachedToLocal)
@@ -254,26 +252,26 @@ CTextureItem* CPlayerMap::GetMarkerTexture(CClientRadarMarker* pMarker, float fL
254252

255253
void CPlayerMap::DoRender()
256254
{
257-
bool bIsRadarShowing = IsRadarShowing();
255+
bool isMapShowing = IsPlayerMapShowing();
258256

259257
// Render if showing
260-
if (bIsRadarShowing)
258+
if (isMapShowing)
261259
{
262260
// Get the alpha value from the settings
263-
int iRadarAlpha;
264-
g_pCore->GetCVars()->Get("mapalpha", iRadarAlpha);
261+
int mapAlpha;
262+
g_pCore->GetCVars()->Get("mapalpha", mapAlpha);
263+
const SColorARGB mapColor(mapAlpha, 255, 255, 255);
265264

266265
// Update the image if the user changed it via a setting
267-
auto radarImageIndex = g_pCore->GetCVars()->GetValue<std::size_t>("mapimage");
268-
if (radarImageIndex != m_radarImageIndex)
266+
auto mapImageIndex = g_pCore->GetCVars()->GetValue<std::size_t>("mapimage");
267+
if (mapImageIndex != m_playerMapImageIndex)
269268
{
270-
m_radarImageIndex = radarImageIndex;
271-
SetMapImage(m_radarImageIndex);
269+
m_playerMapImageIndex = mapImageIndex;
270+
SetMapImage(m_playerMapImageIndex);
272271
}
273272

274-
g_pCore->GetGraphics()->DrawTexture(m_pRadarImage, static_cast<float>(m_iMapMinX), static_cast<float>(m_iMapMinY),
275-
m_fMapSize / m_pRadarImage->m_uiSizeX, m_fMapSize / m_pRadarImage->m_uiSizeY, 0.0f, 0.0f, 0.0f,
276-
SColorARGB(iRadarAlpha, 255, 255, 255));
273+
g_pCore->GetGraphics()->DrawTexture(m_pPlayerMapImage, static_cast<float>(m_iMapMinX), static_cast<float>(m_iMapMinY),
274+
m_fMapSize / m_pPlayerMapImage->m_uiSizeX, m_fMapSize / m_pPlayerMapImage->m_uiSizeY, 0.0f, 0.0f, 0.0f, mapColor);
277275

278276
// Grab the info for the local player blip
279277
CVector2D vecLocalPos;
@@ -354,7 +352,7 @@ void CPlayerMap::DoRender()
354352
}
355353

356354
// Update visibility of help text
357-
bool bRequiredTextVisible = bIsRadarShowing && !m_bHideHelpText;
355+
bool bRequiredTextVisible = isMapShowing && !m_bHideHelpText;
358356
if (bRequiredTextVisible != m_bTextVisible)
359357
{
360358
m_bTextVisible = bRequiredTextVisible;
@@ -365,31 +363,31 @@ void CPlayerMap::DoRender()
365363
}
366364
}
367365

368-
void CPlayerMap::SetPlayerMapEnabled(bool bIsRadarEnabled)
366+
void CPlayerMap::SetPlayerMapEnabled(bool show)
369367
{
370-
bool bAlreadyEnabled = (m_bIsRadarEnabled || m_bForcedState);
371-
bool bWillShow = (bIsRadarEnabled || m_bForcedState);
372-
if (bAlreadyEnabled != bWillShow)
368+
bool alreadyEnabled = (m_bIsPlayerMapEnabled || m_bForcedState);
369+
bool definitiveShow = (show || m_bForcedState);
370+
if (alreadyEnabled != definitiveShow)
373371
{
374-
InternalSetRadarEnabled(bWillShow);
372+
InternalSetPlayerMapEnabled(definitiveShow);
375373
}
376-
m_bIsRadarEnabled = bIsRadarEnabled;
374+
m_bIsPlayerMapEnabled = show;
377375
}
378376

379-
void CPlayerMap::SetForcedState(bool bState)
377+
void CPlayerMap::SetForcedState(bool state)
380378
{
381-
bool bAlreadyShowing = (m_bIsRadarEnabled || m_bForcedState);
382-
bool bWillShow = (m_bIsRadarEnabled || bState);
383-
if (bAlreadyShowing != bWillShow)
379+
bool currState = (m_bIsPlayerMapEnabled || m_bForcedState);
380+
bool definitiveState = (m_bIsPlayerMapEnabled || state);
381+
if (currState != definitiveState)
384382
{
385-
InternalSetRadarEnabled(bWillShow);
383+
InternalSetPlayerMapEnabled(definitiveState);
386384
}
387-
m_bForcedState = bState;
385+
m_bForcedState = state;
388386
}
389387

390-
void CPlayerMap::InternalSetRadarEnabled(bool bEnabled)
388+
void CPlayerMap::InternalSetPlayerMapEnabled(bool enable)
391389
{
392-
if (bEnabled)
390+
if (enable)
393391
{
394392
m_bChatVisible = g_pCore->IsChatVisible();
395393
m_bChatInputBlocked = g_pCore->IsChatInputBlocked();
@@ -684,15 +682,15 @@ void CPlayerMap::SetAttachedToLocalPlayer(bool bIsAttachedToLocal)
684682
m_HelpTextList[0]->SetCaption(_("Free Movement"));
685683
}
686684

687-
bool CPlayerMap::IsRadarShowing()
685+
bool CPlayerMap::IsPlayerMapShowing()
688686
{
689-
return ((m_bIsRadarEnabled || m_bForcedState) && m_pRadarImage && m_pLocalPlayerBlip && (!g_pCore->GetConsole()->IsVisible() && !g_pCore->IsMenuVisible()));
687+
return ((m_bIsPlayerMapEnabled || m_bForcedState) && m_pPlayerMapImage && m_pLocalPlayerBlip && (!g_pCore->GetConsole()->IsVisible() && !g_pCore->IsMenuVisible()));
690688
}
691689

692690
bool CPlayerMap::GetBoundingBox(CVector& vecMin, CVector& vecMax)
693691
{
694-
// If our radar image exists (Values are not calculated unless map is showing)
695-
if (IsRadarShowing())
692+
// If our map image exists (Values are not calculated unless map is showing)
693+
if (IsPlayerMapShowing())
696694
{
697695
vecMin.fX = static_cast<float>(m_iMapMinX);
698696
vecMin.fY = static_cast<float>(m_iMapMinY);

Client/mods/deathmatch/logic/CPlayerMap.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class CPlayerMap
2525
void DoPulse();
2626
void DoRender();
2727

28-
bool IsRadarShowing();
28+
bool IsPlayerMapShowing();
2929

30-
bool GetPlayerMapEnabled() const { return m_bIsRadarEnabled; };
30+
bool GetPlayerMapEnabled() const { return m_bIsPlayerMapEnabled; };
3131
void SetPlayerMapEnabled(bool bIsRadarEnabled);
3232

3333
bool GetForcedState() const { return m_bForcedState; }
@@ -38,7 +38,7 @@ class CPlayerMap
3838
void ToggleHelpText();
3939

4040
protected:
41-
void InternalSetRadarEnabled(bool bEnabled);
41+
void InternalSetPlayerMapEnabled(bool bEnabled);
4242

4343
void CreateMarkerTextures();
4444
CTextureItem* GetMarkerTexture(CClientRadarMarker* pMarker, float fLocalZ, float* pfScale, SColor* pColor);
@@ -81,9 +81,9 @@ class CPlayerMap
8181
class CClientRadarMarkerManager* m_pRadarMarkerManager;
8282
class CClientRadarAreaManager* m_pRadarAreaManager;
8383

84-
std::size_t m_radarImageIndex;
84+
std::size_t m_playerMapImageIndex;
8585

86-
CTextureItem* m_pRadarImage;
86+
CTextureItem* m_pPlayerMapImage;
8787
CTextureItem* m_pLocalPlayerBlip;
8888
std::vector<CTextureItem*> m_MarkerTextureList;
8989

@@ -101,7 +101,7 @@ class CPlayerMap
101101

102102
float m_fZoom;
103103

104-
bool m_bIsRadarEnabled;
104+
bool m_bIsPlayerMapEnabled;
105105
bool m_bForcedState;
106106
bool m_bIsAttachedToLocal;
107107

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7852,7 +7852,7 @@ bool CStaticFunctionDefinitions::IsPlayerMapForced(bool& bForced)
78527852

78537853
bool CStaticFunctionDefinitions::IsPlayerMapVisible(bool& bVisible)
78547854
{
7855-
bVisible = m_pPlayerMap->IsRadarShowing();
7855+
bVisible = m_pPlayerMap->IsPlayerMapShowing();
78567856
return true;
78577857
}
78587858

0 commit comments

Comments
 (0)