From 1b534ccd70e510b39ae0688f882e4984b92afd39 Mon Sep 17 00:00:00 2001 From: Kiloku Date: Mon, 10 Feb 2025 21:40:30 -0300 Subject: [PATCH] Option to add outlines to ships in radar (#156) * Add outlines to ships in radar * Move Outline feature to hooks * Missing semicolon --- src/engine/fox_hud.c | 18 +++++---- src/port/hooks/list/EngineEvent.h | 2 + src/port/mods/PortEnhancements.c | 63 +++++++++++++++++++++++++++++++ src/port/ui/ImguiUI.cpp | 4 ++ 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index 051ec0b6..7bb51bff 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -1790,7 +1790,7 @@ void HUD_RadarMark_Arwing_Draw(s32 colorIdx) { RCP_SetupDL(&gMasterDisp, SETUPDL_62); gDPSetPrimColor(gMasterDisp++, 0, 0, arwingMarkColor[colorIdx][0], arwingMarkColor[colorIdx][1], - arwingMarkColor[colorIdx][2], arwingMarkColor[colorIdx][3]); + arwingMarkColor[colorIdx][2], arwingMarkColor[colorIdx][3]); Matrix_Scale(gGfxMatrix, var_fv1, var_fv2, 1.0f, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, aRadarMarkArwingDL); @@ -1801,7 +1801,7 @@ void HUD_RadarMark_StarWolf_Draw(void) { gDPSetPrimColor(gMasterDisp++, 0, 0, 0, 0, 0, 255); Matrix_Scale(gGfxMatrix, 54.0f, 54.0f, 1.0f, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - gSPDisplayList(gMasterDisp++, aStarWolfRadarMarkDL); + gSPDisplayList(gMasterDisp++, aStarWolfRadarMarkDL); } void HUD_RadarMark_Katt_Draw(void) { @@ -1885,17 +1885,21 @@ void HUD_RadarMark_Draw(s32 type) { } else { arwingMarkColor = arwingMarkColor * 2; } - - HUD_RadarMark_Arwing_Draw(arwingMarkColor); + CALL_CANCELLABLE_EVENT(DrawRadarMarkArwingEvent, arwingMarkColor) { + HUD_RadarMark_Arwing_Draw(arwingMarkColor); + } break; case RADARMARK_WOLF: case RADARMARK_LEON: case RADARMARK_PIGMA: case RADARMARK_ANDREW: - HUD_RadarMark_StarWolf_Draw(); - break; - + { //This won't compile without braces, for some reason. + CALL_CANCELLABLE_EVENT(DrawRadarMarkWolfenEvent) { + HUD_RadarMark_StarWolf_Draw(); + } + break; + } case RADARMARK_KATT: HUD_RadarMark_Katt_Draw(); break; diff --git a/src/port/hooks/list/EngineEvent.h b/src/port/hooks/list/EngineEvent.h index 93535dae..df4115cd 100644 --- a/src/port/hooks/list/EngineEvent.h +++ b/src/port/hooks/list/EngineEvent.h @@ -15,6 +15,8 @@ DEFINE_EVENT(PlayerPreUpdateEvent, Player* player;); DEFINE_EVENT(PlayerPostUpdateEvent, Player* player;); DEFINE_EVENT(DrawRadarHUDEvent); +DEFINE_EVENT(DrawRadarMarkArwingEvent, s32 colorIdx;); +DEFINE_EVENT(DrawRadarMarkWolfenEvent); DEFINE_EVENT(DrawBoostGaugeHUDEvent); DEFINE_EVENT(DrawBombCounterHUDEvent); DEFINE_EVENT(DrawIncomingMsgHUDEvent); diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index abc9d0f2..641ad55f 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -3,6 +3,7 @@ #include "hit64.h" #include "mods.h" #include "hud.h" +#include "assets/ast_star_wolf.h" #define INIT_EVENT_IDS #include "port/hooks/Events.h" @@ -318,6 +319,64 @@ void OnPreSetupRadioMsgEvent(PreSetupRadioMsgEvent* ev){ } } +void OnRadarMarkArwingDraw(DrawRadarMarkArwingEvent* ev){ + bool outlines = CVarGetInteger("gFighterOutlines", 0); + if (!outlines){ + return; + } + + ev->event.cancelled = true; + + s32 arwingMarkColor[][4] = { + { 177, 242, 12, 255 }, { 89, 121, 6, 128 }, { 90, 90, 255, 255 }, { 45, 45, 128, 128 }, + { 0, 179, 67, 255 }, { 0, 90, 34, 128 }, { 255, 30, 0, 255 }, { 128, 15, 0, 128 }, + }; + f32 var_fv1; + f32 var_fv2; + + if (gCamCount != 1) { + var_fv1 = 38.0f; + var_fv2 = 38.0f; + } else { + var_fv1 = 54.0f; + var_fv2 = 54.0f; + } + + RCP_SetupDL(&gMasterDisp, SETUPDL_62); + gDPSetPrimColor(gMasterDisp++, 0, 0,0,0,0,255); + Matrix_Scale(gGfxMatrix, var_fv1, var_fv2, 1.0f, MTXF_APPLY); + Matrix_SetGfxMtx(&gMasterDisp); + gSPDisplayList(gMasterDisp++, aRadarMarkArwingDL); + + gDPSetPrimColor(gMasterDisp++, 0, 0, arwingMarkColor[ev->colorIdx][0], arwingMarkColor[ev->colorIdx][1], + arwingMarkColor[ev->colorIdx][2], arwingMarkColor[ev->colorIdx][3]); + Matrix_Translate(gGfxMatrix, 0.0f, 1.0f, 0.0f, MTXF_APPLY); + Matrix_Scale(gGfxMatrix, 0.8f, 0.7f, 1.0f, MTXF_APPLY); + Matrix_SetGfxMtx(&gMasterDisp); + gSPDisplayList(gMasterDisp++, aRadarMarkArwingDL); + + +} + +void OnRadarMarkWolfenDraw(IEvent* ev) { + bool outlines = CVarGetInteger("gFighterOutlines", 0); + if (!outlines){ + return; + } + ev->cancelled = true; + + gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); + Matrix_Scale(gGfxMatrix, 54.0f, 54.0f, 1.0f, MTXF_APPLY); + Matrix_SetGfxMtx(&gMasterDisp); + gSPDisplayList(gMasterDisp++, aStarWolfRadarMarkDL); + + gDPSetPrimColor(gMasterDisp++, 0, 0, 0, 0, 0, 255); + Matrix_Translate(gGfxMatrix, 0.0f, -1.2f, 0.0f, MTXF_APPLY); + Matrix_Scale(gGfxMatrix, 0.9f, 0.8f, 1.0f, MTXF_APPLY); + Matrix_SetGfxMtx(&gMasterDisp); + gSPDisplayList(gMasterDisp++, aStarWolfRadarMarkDL); +} + void OnLivesCounterDraw(IEvent* ev){ bool restore = CVarGetInteger("gRestoreBetaBoostGauge", 0) == 1; if(!restore){ @@ -347,6 +406,8 @@ void PortEnhancements_Init() { REGISTER_LISTENER(DrawLivesCounterHUDEvent, OnLivesCounterDraw, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(DrawBombCounterHUDEvent, OnBombCounterDraw, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(PreSetupRadioMsgEvent, OnPreSetupRadioMsgEvent, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(DrawRadarMarkArwingEvent, OnRadarMarkArwingDraw, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(DrawRadarMarkWolfenEvent, OnRadarMarkWolfenDraw, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(ObjectUpdateEvent, OnItemGoldRingUpdate, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(ObjectDrawPostSetupEvent, OnItemGoldRingDraw, EVENT_PRIORITY_NORMAL); @@ -375,6 +436,8 @@ void PortEnhancements_Register() { REGISTER_EVENT(PlayerPostUpdateEvent); REGISTER_EVENT(DrawRadarHUDEvent); + REGISTER_EVENT(DrawRadarMarkArwingEvent); + REGISTER_EVENT(DrawRadarMarkWolfenEvent); REGISTER_EVENT(DrawBoostGaugeHUDEvent); REGISTER_EVENT(DrawBombCounterHUDEvent); REGISTER_EVENT(DrawIncomingMsgHUDEvent); diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 937751ad..71c294be 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -567,6 +567,10 @@ void DrawEnhancementsMenu() { .tooltip = "Gorgon flashes the screen repeatedly when firing its beam or when teleporting, which causes eye pain for some players and may be harmful to those with photosensitivity.", .defaultValue = false }); + UIWidgets::CVarCheckbox("Add outline to Arwing and Wolfen in radar", "gFighterOutlines", { + .tooltip = "Increases visibility of ships in the radar.", + .defaultValue = false + }); ImGui::EndMenu(); }