summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-08-02 13:45:37 +0200
committerSergeanur <s.anureev@yandex.ua>2021-08-09 17:07:42 +0200
commit8ea411e4c5c7191b0e67f0c569a32733b99a81bc (patch)
tree1430b1ca3c3fa3876c2e6377f7c9ec63e26702d9
parentsmall fix (diff)
downloadre3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar.gz
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar.bz2
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar.lz
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar.xz
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.tar.zst
re3-8ea411e4c5c7191b0e67f0c569a32733b99a81bc.zip
-rw-r--r--src/core/Radar.cpp59
-rw-r--r--src/core/Radar.h4
-rw-r--r--src/fakerw/fake.cpp4
-rw-r--r--src/fakerw/rwcore.h8
4 files changed, 68 insertions, 7 deletions
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index cccf1d2e..011c8464 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -45,6 +45,9 @@ CSprite2d CRadar::SaveSprite;
CSprite2d CRadar::SpraySprite;
CSprite2d CRadar::TonySprite;
CSprite2d CRadar::WeaponSprite;
+#ifdef MENU_MAP
+CSprite2d CRadar::WaypointSprite;
+#endif
CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
nil,
@@ -67,7 +70,10 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
&SaveSprite,
&SpraySprite,
&TonySprite,
- &WeaponSprite
+ &WeaponSprite,
+#ifdef MENU_MAP
+ &WaypointSprite
+#endif
};
// Why this doesn't coincide with world coordinates i don't know
@@ -917,6 +923,9 @@ void CRadar::DrawRadarSection(int32 x, int32 y)
void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha)
{
+#ifdef MENU_MAP
+ if(sprite == RADAR_SPRITE_WAYPOINT) alpha = 255;
+#endif
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));
}
@@ -1094,6 +1103,43 @@ CRadar::LoadTextures()
SpraySprite.SetTexture("radar_spray");
TonySprite.SetTexture("radar_tony");
WeaponSprite.SetTexture("radar_weapon");
+#ifdef MENU_MAP
+ WaypointSprite.SetTexture("radar_waypoint");
+ if(!WaypointSprite.m_pTexture) {
+ // create the texture if it's missing in TXD
+#define WAYPOINT_R (255)
+#define WAYPOINT_G (72)
+#define WAYPOINT_B (77)
+
+ RwRaster *raster = RwRasterCreate(16, 16, 0, rwRASTERTYPETEXTURE | rwRASTERFORMAT8888);
+
+ RwUInt32 *pixels = (RwUInt32 *)RwRasterLock(raster, 0, rwRASTERLOCKWRITE);
+ for(int x = 0; x < 16; x++)
+ for(int y = 0; y < 16; y++)
+ {
+ int x2 = x < 8 ? x : 7 - (x & 7);
+ int y2 = y < 8 ? y : 7 - (y & 7);
+ if ((y2 >= 4 && x2 >= 4) // square in the center is transparent
+ || (x2 < 2 && y2 == 0) // two pixels on each side of first/last line are transparent
+ || (x2 < 1 && y2 == 1)) // one pixel on each side of second to first/last line is transparent
+ pixels[x + y * 16] = 0;
+ else if((x2 == 2 && y2 >= 2)|| (y2 == 2 && x2 >= 2) )// colored square inside
+#ifdef RW_GL3
+ pixels[x + y * 16] = WAYPOINT_R | (WAYPOINT_G << 8) | (WAYPOINT_B << 16) | (255 << 24);
+#else
+ pixels[x + y * 16] = WAYPOINT_B | (WAYPOINT_G << 8) | (WAYPOINT_R << 16) | (255 << 24);
+#endif
+ else
+ pixels[x + y * 16] = 0xFF000000; // black
+ }
+ RwRasterUnlock(raster);
+ WaypointSprite.m_pTexture = RwTextureCreate(raster);
+ RwTextureSetFilterMode(WaypointSprite.m_pTexture, rwFILTERLINEAR);
+#undef WAYPOINT_R
+#undef WAYPOINT_G
+#undef WAYPOINT_B
+ }
+#endif
CTxdStore::PopCurrentTxd();
}
@@ -1293,6 +1339,9 @@ void CRadar::Shutdown()
SpraySprite.Delete();
TonySprite.Delete();
WeaponSprite.Delete();
+#ifdef MENU_MAP
+ WaypointSprite.Delete();
+#endif
RemoveRadarSections();
}
@@ -1488,12 +1537,12 @@ CRadar::ToggleTargetMarker(float x, float y)
{
if (TargetMarkerId == -1) {
int nextBlip;
- for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) {
+ for (nextBlip = NUMRADARBLIPS-1; nextBlip >= 0; nextBlip--) {
if (!ms_RadarTrace[nextBlip].m_bInUse)
break;
}
#ifdef FIX_BUGS
- if (nextBlip == NUMRADARBLIPS)
+ if (nextBlip == 0)
return;
#endif
ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD;
@@ -1501,14 +1550,14 @@ CRadar::ToggleTargetMarker(float x, float y)
ms_RadarTrace[nextBlip].m_bDim = 0;
ms_RadarTrace[nextBlip].m_bInUse = 1;
ms_RadarTrace[nextBlip].m_Radius = 1.0f;
- CVector pos(x, y, CWorld::FindGroundZForCoord(x,y));
+ CVector pos(x, y, 0.0f/*CWorld::FindGroundZForCoord(x,y)*/);
TargetMarkerPos = pos;
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;
+ ms_RadarTrace[nextBlip].m_eRadarSprite = RADAR_SPRITE_WAYPOINT;
TargetMarkerId = CRadar::GetNewUniqueBlipIndex(nextBlip);
} else {
ClearBlip(TargetMarkerId);
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 5b38d350..ae87d0fa 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -47,6 +47,9 @@ enum eRadarSprite
RADAR_SPRITE_SPRAY,
RADAR_SPRITE_TONY,
RADAR_SPRITE_WEAPON,
+#ifdef MENU_MAP
+ RADAR_SPRITE_WAYPOINT,
+#endif
RADAR_SPRITE_COUNT
};
@@ -144,6 +147,7 @@ public:
static float cachedCos;
static float cachedSin;
#ifdef MENU_MAP
+ static CSprite2d WaypointSprite;
static int TargetMarkerId;
static CVector TargetMarkerPos;
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index 1d4c881f..6dfebb39 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -235,8 +235,8 @@ RwRaster *RwRasterGetCurrentContext(void) { return Raster::getCurrentContext(
RwBool RwRasterClear(RwInt32 pixelValue);
RwBool RwRasterClearRect(RwRect * rpRect, RwInt32 pixelValue);
RwRaster *RwRasterShowRaster(RwRaster * raster, void *dev, RwUInt32 flags);
-RwUInt8 *RwRasterLock(RwRaster * raster, RwUInt8 level, RwInt32 lockMode);
-RwRaster *RwRasterUnlock(RwRaster * raster);
+RwUInt8 *RwRasterLock(RwRaster * raster, RwUInt8 level, RwInt32 lockMode) { return raster->lock(level, lockMode); }
+RwRaster *RwRasterUnlock(RwRaster * raster) { raster->unlock(0); return raster; }
RwUInt8 *RwRasterLockPalette(RwRaster * raster, RwInt32 lockMode);
RwRaster *RwRasterUnlockPalette(RwRaster * raster);
RwInt32 RwRasterRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor constructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB);
diff --git a/src/fakerw/rwcore.h b/src/fakerw/rwcore.h
index e5d21865..ab0a719f 100644
--- a/src/fakerw/rwcore.h
+++ b/src/fakerw/rwcore.h
@@ -104,6 +104,14 @@ enum RwRasterFormat
rwRASTERFORMATMASK = 0xff00
};
+enum RwRasterLockMode
+{
+ rwRASTERLOCKWRITE = rw::Raster::LOCKWRITE,
+ rwRASTERLOCKREAD = rw::Raster::LOCKREAD,
+ rwRASTERLOCKNOFETCH = rw::Raster::LOCKNOFETCH,
+ rwRASTERLOCKRAW = rw::Raster::LOCKRAW,
+};
+
enum RwRasterFlipMode
{
rwRASTERFLIPDONTWAIT = 0,