diff --git a/resources/MenuMapIII.ini b/resources/MenuMapIII.ini new file mode 100644 index 0000000..e5cb66e --- /dev/null +++ b/resources/MenuMapIII.ini @@ -0,0 +1,6 @@ +[MenuMap] +; Set colors for drawing the menu map page. +RadarMapColor = 255 255 255 255 +BackgroundColor = 0 0 0 255 +CrosshairColor = 234 171 54 155 +ZoneNameColor = 255 255 255 255 diff --git a/source/Main.cpp b/source/Main.cpp index a4f8809..badde7e 100644 --- a/source/Main.cpp +++ b/source/Main.cpp @@ -9,6 +9,7 @@ using namespace plugin; class MenuMap { public: MenuMap() { +#ifdef GTA3 const CMenuScreen pauseMenuPage = { "FET_PAU", 1, -1, -1, 0, 0, MENUACTION_RESUME, "FEM_RES", 0, MENUPAGE_NONE, @@ -21,24 +22,21 @@ class MenuMap { }; plugin::patch::Set(0x611930 + sizeof(CMenuScreen) * MENUPAGE_PAUSE_MENU, pauseMenuPage); - const CMenuScreen mapMenuPage = { "", 1, MENUPAGE_PAUSE_MENU, MENUPAGE_PAUSE_MENU, 2, 2, }; plugin::patch::Set(0x611930 + sizeof(CMenuScreen) * MENUPAGE_MAP, mapMenuPage); +#endif plugin::Events::initRwEvent += [] { - CMenuManager* m = &FrontEndMenuManager; - if (m) { - MenuNew = std::make_shared(); - MenuNew->menuManager = m; - } + MenuNew = std::make_shared(); }; +#ifdef GTA3 ThiscallEvent , PRIORITY_AFTER, ArgPickN, void(CMenuManager*)> onDrawingMenuManager; onDrawingMenuManager += [](CMenuManager* menuManager) { - if (!MenuNew) + if (!MenuNew || !MenuNew->menuManager) return; switch (MenuNew->menuManager->m_nCurrentMenuScreen) { @@ -52,9 +50,11 @@ class MenuMap { break; } }; +#else +#endif plugin::Events::drawBlipsEvent += [] { - if (!MenuNew) + if (!MenuNew || !MenuNew->menuManager) return; if (MenuNew->targetBlipIndex) { diff --git a/source/MenuNew.cpp b/source/MenuNew.cpp index c6f8e88..3e7c4df 100644 --- a/source/MenuNew.cpp +++ b/source/MenuNew.cpp @@ -17,13 +17,14 @@ using namespace plugin; std::shared_ptr MenuNew; CMenuNew::CMenuNew() { - menuManager = NULL; + menuManager = &FrontEndMenuManager; m_fMapZoom = MAP_ZOOM_MIN; m_vMapBase = {}; m_vCrosshair = {}; targetBlipIndex = 0; targetBlipWorldPos = {}; clearInput = false; + settings.Read(); } CMenuNew::~CMenuNew() { @@ -31,6 +32,9 @@ CMenuNew::~CMenuNew() { } void CMenuNew::DrawMap() { + if (!menuManager) + return; + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast(FALSE)); RwRenderStateSet(rwRENDERSTATESRCBLEND, reinterpret_cast(rwBLENDSRCALPHA)); RwRenderStateSet(rwRENDERSTATEDESTBLEND, reinterpret_cast(rwBLENDINVSRCALPHA)); @@ -39,10 +43,11 @@ void CMenuNew::DrawMap() { RwRenderStateSet(rwRENDERSTATEZTESTENABLE, reinterpret_cast(FALSE)); CSprite2d::DrawRect(CRect(-5.0f, -5.0f, SCREEN_WIDTH + 5.0f, SCREEN_HEIGHT + 5.0f), CRGBA(0, 0, 0, 255)); + CSprite2d::DrawRect(CRect(-5.0f, -5.0f, SCREEN_WIDTH + 5.0f, SCREEN_HEIGHT + 5.0f), CRGBA(settings.backgroundColor.r, settings.backgroundColor.g, settings.backgroundColor.b, settings.backgroundColor.a)); const float mapHalfSize = GetMenuMapWholeSize() / 2; CRect rect; - CRGBA col = { 255, 255, 255, static_cast(menuManager->FadeIn(255)) }; + CRGBA col = { settings.radarMapColor.r, settings.radarMapColor.g, settings.radarMapColor.b, static_cast(menuManager->FadeIn(settings.radarMapColor.a)) }; float mapZoom = GetMenuMapTileSize() * m_fMapZoom; rect.left = m_vMapBase.x; @@ -74,7 +79,7 @@ void CMenuNew::DrawMap() { void CMenuNew::DrawCrosshair(float x, float y) { float lineSize = ScaleY(2.0f); - CRGBA lineCol = CRGBA(234, 171, 54, menuManager->FadeIn(155)); + CRGBA lineCol = CRGBA(settings.crosshairColor.r, settings.crosshairColor.g, settings.crosshairColor.b, menuManager->FadeIn(settings.crosshairColor.a)); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast(TRUE)); @@ -88,7 +93,7 @@ void CMenuNew::DrawCrosshair(float x, float y) { void CMenuNew::DrawZone() { RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast(FALSE)); - CSprite2d::DrawRect(CRect(-5.0f, SCREEN_HEIGHT + 5.0f, SCREEN_WIDTH + 5.0f, SCREEN_HEIGHT - ScaleY(42.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, menuManager->FadeIn(255))); CVector pos = MapToWorld(CVector2D(m_vCrosshair.x, m_vCrosshair.y)); CZone* zoneType0 = CTheZones::FindSmallestZonePositionType(pos, 0); @@ -111,7 +116,7 @@ void CMenuNew::DrawZone() { CFont::SetDropShadowPosition(0); CFont::SetWrapx(SCREEN_WIDTH); CFont::SetFontStyle(0); - CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::SetColor(CRGBA(settings.zoneNameColor.r, settings.zoneNameColor.g, settings.zoneNameColor.b, menuManager->FadeIn(settings.zoneNameColor.a))); CFont::SetScale(ScaleX(0.54f), ScaleY(1.12f)); CFont::PrintString(ScaleX(16.0f), SCREEN_HEIGHT - ScaleY(34.0f), str); } @@ -201,7 +206,7 @@ void CMenuNew::DrawBlips() { CSprite2d* sprite = pRadarSprites[RADAR_SPRITE_CENTRE]; if (sprite && flashItem(1000, 200)) - DrawSpriteWithRotation(sprite, pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE), ScaleY(RADAR_BLIPS_SCALE), angle, CRGBA(255, 255, 255, menuManager->FadeIn(255))); + DrawSpriteWithRotation(sprite, pos.x, pos.y, ScaleX(RADAR_BLIPS_SCALE - 1.0f), ScaleY(RADAR_BLIPS_SCALE - 1.0f), angle, CRGBA(255, 255, 255, menuManager->FadeIn(255))); } } @@ -253,6 +258,9 @@ void CMenuNew::StreamRadarSections() { } void CMenuNew::MapInput() { + if (!menuManager) + return; + CPad* pad = CPad::GetPad(0); if (clearInput) { @@ -378,6 +386,7 @@ void CMenuNew::DrawRadarSectionMap(int x, int y, CRect const& rect, CRGBA const& if (texture) { RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(texture)); CSprite2d::SetVertices(rect, col, col, col, col, 0); + RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } } diff --git a/source/MenuNew.h b/source/MenuNew.h index 6a42c58..fd7d538 100644 --- a/source/MenuNew.h +++ b/source/MenuNew.h @@ -9,9 +9,12 @@ #include "plugin.h" #include "CMenuManager.h" #include "CRadar.h" +#include "Settings.h" enum { +#ifdef GTA3 MENUPAGE_MAP = MENUPAGE_NO_MEMORY_CARD, +#endif }; class CMenuNew { @@ -23,6 +26,7 @@ class CMenuNew { int targetBlipIndex; CVector targetBlipWorldPos; bool clearInput; + Settings settings; public: CMenuNew(); diff --git a/source/Settings.cpp b/source/Settings.cpp new file mode 100644 index 0000000..b9bda9d --- /dev/null +++ b/source/Settings.cpp @@ -0,0 +1,16 @@ +#include "plugin.h" +#include "Settings.h" + +void Settings::Read() { +#ifdef GTA3 + plugin::config_file config(PLUGIN_PATH("MenuMapIII.ini")); +#else + plugin::config_file config(PLUGIN_PATH("MenuMapVC.ini")); +#endif + + radarMapColor = config["RadarMapColor"].asRGBA(CRGBA(255, 255, 255, 255)); + backgroundColor = config["BackgroundColor"].asRGBA(CRGBA(0, 0, 0, 255)); + crosshairColor = config["CrosshairColor"].asRGBA(CRGBA(234, 171, 54, 255)); + zoneNameColor = config["ZoneNameColor"].asRGBA(CRGBA(255, 255, 255, 255)); + +} diff --git a/source/Settings.h b/source/Settings.h new file mode 100644 index 0000000..163d1f4 --- /dev/null +++ b/source/Settings.h @@ -0,0 +1,13 @@ +#pragma once + +class Settings { +public: + CRGBA radarMapColor; + CRGBA backgroundColor; + CRGBA crosshairColor; + CRGBA zoneNameColor; + +public: + void Read(); +}; +