Skip to content

Commit

Permalink
Adjust global scale, fix zone names, fix markers.
Browse files Browse the repository at this point in the history
  • Loading branch information
gennariarmando committed Apr 24, 2022
1 parent b4a6e19 commit e31f7a0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MenuMap {
CRadar::LimitRadarPoint(in);
CRadar::TransformRadarPointToScreenSpace(out, in);

DrawWayPoint(out.x, out.y);
DrawWayPoint(out.x, out.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE));
}
};
}
Expand Down
40 changes: 21 additions & 19 deletions source/MenuNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void CMenuNew::DrawMap() {
}

void CMenuNew::DrawCrosshair(float x, float y) {
float lineSize = Scale(3.0f);
float lineSize = ScaleY(2.0f);
CRGBA lineCol = CRGBA(234, 171, 54, FadeIn(155));

RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
Expand All @@ -63,14 +63,19 @@ void CMenuNew::DrawCrosshair(float x, float y) {
}

void CMenuNew::DrawZone() {
CSprite2d::DrawRect(CRect(-5.0f, SCREEN_HEIGHT + 5.0f, SCREEN_WIDTH + 5.0f, SCREEN_HEIGHT - Scale(70.0f)), CRGBA(10, 10, 10, 255));
CSprite2d::DrawRect(CRect(-5.0f, SCREEN_HEIGHT + 5.0f, SCREEN_WIDTH + 5.0f, SCREEN_HEIGHT - ScaleY(42.0f)), CRGBA(10, 10, 10, 255));

CVector pos = MapToWorld(CVector2D(m_vCrosshair.x, m_vCrosshair.y));
CZone* zone = CTheZones::FindSmallestZonePosition(pos);
CZone* zoneType0 = CTheZones::FindSmallestZonePositionType(pos, 0);
CZone* zoneType1 = CTheZones::FindSmallestZonePositionType(pos, 1);

const wchar_t* str = TheText.Get("CITYZON");

if (zone)
str = zone->GetTranslatedName();
if (zoneType0)
str = zoneType0->GetTranslatedName();

if (zoneType1)
str = zoneType1->GetTranslatedName();

if (str) {
CFont::SetPropOn();
Expand All @@ -82,8 +87,8 @@ void CMenuNew::DrawZone() {
CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetFontStyle(0);
CFont::SetColor(CRGBA(255, 255, 255, 255));
CFont::SetScale(Scale(1.2f), Scale(1.8f));
CFont::PrintString(Scale(32.0f), SCREEN_HEIGHT - Scale(56.0f), str);
CFont::SetScale(ScaleX(0.54f), ScaleY(1.12f));
CFont::PrintString(ScaleX(16.0f), SCREEN_HEIGHT - ScaleY(34.0f), str);
}
}

Expand All @@ -97,7 +102,7 @@ void CMenuNew::DrawBlips() {
CVector2D pos = WorldToMap(trace[i].m_vecPos);
CRGBA col = CRadar::GetRadarTraceColour(trace[i].m_nColour, true);
unsigned short id = trace[i].m_nRadarSprite;
unsigned int handle = trace[i].m_nEntityHandle;
int handle = trace[i].m_nEntityHandle >> 8;
CSprite2d* sprite = pRadarSprites[id];
CEntity* e = NULL;

Expand All @@ -107,14 +112,12 @@ void CMenuNew::DrawBlips() {
switch (trace[i].m_nBlipType) {
case BLIP_COORD:
case BLIP_CONTACTPOINT:
case BLIP_PICKUP:
if (!CTheScripts::IsPlayerOnAMission() || trace[i].m_nBlipType == BLIP_COORD || trace[i].m_nBlipType == BLIP_PICKUP) {
if (!CTheScripts::IsPlayerOnAMission() || trace[i].m_nBlipType != BLIP_CONTACTPOINT) {
if (id > RADAR_SPRITE_NONE && id < RADAR_SPRITE_COUNT) {
DrawSpriteWithRotation(sprite, pos.x, pos.y, Scale(24.0f), Scale(24.0f), 0.0f, CRGBA(255, 255, 255, FadeIn(255)));
DrawSpriteWithRotation(sprite, pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE), 0.0f, CRGBA(255, 255, 255, FadeIn(255)));
}
else {
DrawSpriteWithRotation(NULL, pos.x, pos.y, Scale(16.0f), Scale(16.0f), 0.0f, CRGBA(0, 0, 0, FadeIn(255)));
DrawSpriteWithRotation(NULL, pos.x, pos.y, Scale(14.0f), Scale(14.0f), 0.0f, CRGBA(col.r, col.g, col.b, FadeIn(255)));
DrawLevel(pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE * 0.45f), ScaleY(RADAR_BLIPS_SCALE * 0.45f), 0, CRGBA(col.r, col.g, col.b, FadeIn(255)));
}
}
break;
Expand Down Expand Up @@ -146,11 +149,10 @@ void CMenuNew::DrawBlips() {
pos = WorldToMap(e->GetPosition());

if (id > RADAR_SPRITE_NONE && id < RADAR_SPRITE_COUNT) {
DrawSpriteWithRotation(sprite, pos.x, pos.y, Scale(24.0f), Scale(24.0f), 0.0f, CRGBA(255, 255, 255, FadeIn(255)));
DrawSpriteWithRotation(sprite, pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE), 0.0f, CRGBA(255, 255, 255, FadeIn(255)));
}
else {
DrawSpriteWithRotation(NULL, pos.x, pos.y, Scale(16.0f), Scale(16.0f), 0.0f, CRGBA(0, 0, 0, FadeIn(255)));
DrawSpriteWithRotation(NULL, pos.x, pos.y, Scale(14.0f), Scale(14.0f), 0.0f, CRGBA(col.r, col.g, col.b, FadeIn(255)));
DrawLevel(pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE * 0.45f), ScaleY(RADAR_BLIPS_SCALE * 0.45f), 0, CRGBA(col.r, col.g, col.b, FadeIn(255)));
}
}
break;
Expand All @@ -162,7 +164,7 @@ void CMenuNew::DrawBlips() {
// Draw waypoint separately
if (targetBlipIndex) {
CVector2D pos = WorldToMap(targetBlipWorldPos);
DrawWayPoint(pos.x, pos.y);
DrawWayPoint(pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE));
}

CPed* playa = FindPlayerPed();
Expand All @@ -173,7 +175,7 @@ void CMenuNew::DrawBlips() {
CSprite2d* sprite = pRadarSprites[RADAR_SPRITE_CENTRE];

if (sprite && flashItem(1000, 200))
DrawSpriteWithRotation(sprite, pos.x, pos.y, Scale(24.0f), Scale(24.0f), angle, CRGBA(255, 255, 255, FadeIn(255)));
DrawSpriteWithRotation(sprite, pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE), angle, CRGBA(255, 255, 255, FadeIn(255)));
}
}

Expand Down Expand Up @@ -375,7 +377,7 @@ void CMenuNew::SetWaypoint(float x, float y) {
}

float CMenuNew::GetMenuMapTileSize() {
const float tileSize = Scale(48.0f);
const float tileSize = ScaleY(24.0f);
return tileSize;
}

Expand Down
2 changes: 1 addition & 1 deletion source/MenuNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define MAP_ZOOM_MAX 7.1f
#define RADAR_TILE_SIZE (500)
#define RADAR_NUM_TILES (MAP_SIZE / RADAR_TILE_SIZE)
//#define ALTERNATE_LEVEL_HEIGHT
#define RADAR_BLIPS_SCALE 14.0f

#include "plugin.h"
#include "CMenuManager.h"
Expand Down
55 changes: 30 additions & 25 deletions source/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "extensions/Screen.h"
#include "CSprite2d.h"

#define defaultScreenWidth 640.0f
#define defaultScreenHeight 448.0f
#define defaultAspectRatio defaultScreenWidth / defaultScreenHeight
#define flashItem(on, off) (CTimer::m_snTimeInMillisecondsPauseMode % on + off < on)
#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))
#define isNearlyEqualF(a, b, t) (fabs(a - b) <= t)
Expand All @@ -20,8 +23,12 @@ static float GetAspectRatio() {
return fScreenAspectRatio;
}

static float Scale(float a) {
return static_cast<int>(a * GetAspectRatio());
static float ScaleX(float a) {
return static_cast<float>(a * SCREEN_WIDTH / defaultScreenWidth) * defaultAspectRatio / GetAspectRatio();
}

static float ScaleY(float a) {
return static_cast<float>(a * SCREEN_HEIGHT / defaultScreenHeight);
}

static void Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA& color) {
Expand All @@ -37,16 +44,6 @@ static void Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, floa
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD);
}

static CVector2D RotateUV(CVector2D& uv, float rotation, CVector2D center) {
CVector2D v = {
cos(rotation) * (uv.x - center.x) + sin(rotation) * (uv.y - center.y) + center.x,
cos(rotation) * (uv.y - center.y) - sin(rotation) * (uv.x - center.x) + center.y
};

uv = v;
return v;
}

static void RotateVertices(CVector2D* rect, float x, float y, float angle) {
float xold, yold;
//angle /= 57.2957795;
Expand All @@ -64,7 +61,7 @@ static void DrawSpriteWithRotation(CSprite2d* sprite, float x, float y, float w,
CVector2D posn[4];
posn[1].x = x - (w * 0.5f); posn[1].y = y - (h * 0.5f); posn[0].x = x + (w * 0.5f); posn[0].y = y - (h * 0.5f);
posn[3].x = x - (w * 0.5f); posn[3].y = y + (h * 0.5f); posn[2].x = x + (w * 0.5f); posn[2].y = y + (h * 0.5f);

RotateVertices(posn, x, y, angle);

if (sprite)
Expand All @@ -87,19 +84,27 @@ static void DrawTriangle(float x, float y, float scale, float angle, CRGBA const
Draw2DPolygon(posn[0].x, posn[0].y, posn[1].x, posn[1].y, posn[2].x, posn[2].y, posn[3].x, posn[3].y, CRGBA(col));
}

static void DrawUnfilledRect(float x, float y, float scale, CRGBA const& col) {
float line = Scale(2.0f);
static void DrawUnfilledRect(float x, float y, float thinkness, float w, float h, CRGBA const& col) {
float line = thinkness;

x -= (w) / 2;
y -= (h) / 2;
CSprite2d::DrawRect(CRect(x, y, x + (w), y + line), col);
CSprite2d::DrawRect(CRect(x + (w), y, x + (w)-line, y + (h)), col);
CSprite2d::DrawRect(CRect(x, y + (h), x + (w), y + (h)-line), col);
CSprite2d::DrawRect(CRect(x, y, x + line, y + (h)), col);
}

x -= (scale) / 2;
y -= (scale) / 2;
CSprite2d::DrawRect(CRect(x, y, x + (scale), y + line), col);
CSprite2d::DrawRect(CRect(x + (scale), y, x + (scale)-line, y + (scale)), col);
CSprite2d::DrawRect(CRect(x, y + (scale), x + (scale), y + (scale)-line), col);
CSprite2d::DrawRect(CRect(x, y, x + line, y + (scale)), col);
static void DrawWayPoint(float x, float y, float w, float h) {
DrawUnfilledRect(x, y, ScaleY(3.0f), w, h, CRGBA(0, 0, 0, 255));
DrawUnfilledRect(x, y, ScaleY(1.0f), w * 0.85f, h * 0.85f, CRGBA(255, 0, 0, 255));
}

static void DrawWayPoint(float x, float y) {
DrawUnfilledRect(x, y, Scale(20.0f), CRGBA(0, 0, 0, 255));
DrawUnfilledRect(x, y, Scale(18.0f), CRGBA(255, 0, 0, 255));
DrawUnfilledRect(x, y, Scale(17.0f), CRGBA(0, 0, 0, 255));
static void DrawLevel(float x, float y, float w, float h, int type, CRGBA const& col) {
switch (type) {
default:
CSprite2d::DrawRect(CRect(x - (w * 0.65f), y - (h * 0.65f), x + (w * 0.65f), y + (h * 0.65f)), CRGBA(0, 0, 0, 255));
CSprite2d::DrawRect(CRect(x - (w * 0.5f), y - (h * 0.5f), x + (w * 0.5f), y + (h * 0.5f)), col);
break;
}
}

0 comments on commit e31f7a0

Please sign in to comment.