From 022b80d24256a6e6e4e018da2949b7a4b5da2519 Mon Sep 17 00:00:00 2001 From: Forevener Date: Wed, 14 Sep 2022 10:46:36 +0500 Subject: [PATCH 01/10] Blip type options, separate collectibles --- cvarinfo.txt | 24 ++++++++++++------- menudef.txt | 8 +++++++ zscript/arookas/radar/data.txt | 10 ++++++-- zscript/arookas/radar/renderer.txt | 38 ++++++++++++++++++++++-------- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/cvarinfo.txt b/cvarinfo.txt index 61e96ed..0326144 100644 --- a/cvarinfo.txt +++ b/cvarinfo.txt @@ -6,14 +6,20 @@ // -------------------------------------------------------------------------- // -nosave int aradar_anchor = 1; -nosave int aradar_order = 0; -nosave int aradar_offset_x = 30; -nosave int aradar_offset_y = 30; -nosave float aradar_scale = 0.70; -nosave bool aradar_altitude = false; -nosave bool aradar_respawn = false; -nosave float aradar_volume = 1.0; -server cheat bool aradar_deathmatch = false; +nosave int aradar_anchor = 1; +nosave int aradar_order = 0; +nosave int aradar_offset_x = 30; +nosave int aradar_offset_y = 30; +nosave float aradar_scale = 0.70; +nosave bool aradar_blip_monster = true; +nosave bool aradar_blip_friend = true; +nosave bool aradar_blip_count = true; +nosave bool aradar_blip_key = true; +nosave bool aradar_blip_other = true; +nosave bool aradar_blip_deco = true; +nosave bool aradar_altitude = false; +nosave bool aradar_respawn = false; +nosave float aradar_volume = 1.0; +server cheat bool aradar_deathmatch = false; // -------------------------------------------------------------------------- // diff --git a/menudef.txt b/menudef.txt index ebdf5cd..6abe939 100644 --- a/menudef.txt +++ b/menudef.txt @@ -38,6 +38,14 @@ OptionMenu "ARadarOptions" { Slider "Radar X offset", "aradar_offset_x", -200, 200, 5, 0, "aradar_anchor" Slider "Radar Y offset", "aradar_offset_y", -200, 200, 5, 0, "aradar_anchor" StaticText "" + StaticText "Show blips for:" + Option "Monsters", "aradar_blip_monster", "OnOff", "aradar_anchor" + Option "Friendlies", "aradar_blip_friend", "OnOff", "aradar_anchor" + Option "Collectibles", "aradar_blip_count", "OnOff", "aradar_anchor" + Option "Keys and special items", "aradar_blip_key", "OnOff", "aradar_anchor" + Option "Other items", "aradar_blip_other", "OnOff", "aradar_anchor" + Option "Objects", "aradar_blip_deco", "OnOff", "aradar_anchor" + StaticText "" Option "Show blip altitude", "aradar_altitude", "NoYes", "aradar_anchor" Option "Show respawned items", "aradar_respawn", "NoYes", "aradar_anchor" StaticText "" diff --git a/zscript/arookas/radar/data.txt b/zscript/arookas/radar/data.txt index 4084912..2c32b57 100644 --- a/zscript/arookas/radar/data.txt +++ b/zscript/arookas/radar/data.txt @@ -14,6 +14,7 @@ enum ARadarBlipType { ARADAR_BLIP_YELLOW, ARADAR_BLIP_BLUE, ARADAR_BLIP_RED, + ARADAR_BLIP_MAGENTA, ARADAR_NUM_BLIPS @@ -56,8 +57,13 @@ class ARadarBlip { return ARADAR_BLIP_YELLOW; } - if ((mo is 'Inventory') || mo.bCOUNTITEM) { - return ARADAR_BLIP_GREEN; + if (mo is 'Inventory') + { + if (mo.bCOUNTITEM) { + return ARADAR_BLIP_MAGENTA; + } else { + return ARADAR_BLIP_GREEN; + } } if (mo.bFRIENDLY) { diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index d554a0d..533dc0a 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -272,7 +272,8 @@ struct ARadarRenderer { Color(255, 2, 252, 5), // green Color(255, 245, 247, 26), // yellow Color(255, 0, 193, 247), // blue - Color(255, 250, 7, 3) // red + Color(255, 250, 7, 3), // red + Color(255, 245, 7, 247) // magenta }; static const Color BLOT_COLORS[] = { @@ -287,6 +288,7 @@ struct ARadarRenderer { private transient CVar mScreenBlocks; private transient CVar mRadarAnchor; private transient CVar mRadarOrder; + private transient CVar mRadarShowType[6]; private transient CVar mRadarAltitude; private transient CVar mRadarRespawn; private transient CVar mRadarScale; @@ -298,14 +300,20 @@ struct ARadarRenderer { private vector3 mBoxVertex[4]; bool InitCVar() { - mScreenBlocks = CVar.GetCVar('screenblocks'); - mRadarAnchor = CVar.GetCVar('aradar_anchor'); - mRadarOrder = CVar.GetCVar('aradar_order'); - mRadarAltitude = CVar.GetCVar('aradar_altitude'); - mRadarRespawn = CVar.GetCVar('aradar_respawn'); - mRadarOffsetX = CVar.GetCVar('aradar_offset_x'); - mRadarOffsetY = CVar.GetCVar('aradar_offset_y'); - mRadarScale = CVar.GetCVar('aradar_scale'); + mScreenBlocks = CVar.GetCVar('screenblocks'); + mRadarAnchor = CVar.GetCVar('aradar_anchor'); + mRadarOrder = CVar.GetCVar('aradar_order'); + mRadarShowType[0] = CVar.GetCVar('aradar_blip_deco'); + mRadarShowType[1] = CVar.GetCVar('aradar_blip_other'); + mRadarShowType[2] = CVar.GetCVar('aradar_blip_key'); + mRadarShowType[3] = CVar.GetCVar('aradar_blip_friend'); + mRadarShowType[4] = CVar.GetCVar('aradar_blip_monster'); + mRadarShowType[5] = CVar.GetCVar('aradar_blip_count'); + mRadarAltitude = CVar.GetCVar('aradar_altitude'); + mRadarRespawn = CVar.GetCVar('aradar_respawn'); + mRadarOffsetX = CVar.GetCVar('aradar_offset_x'); + mRadarOffsetY = CVar.GetCVar('aradar_offset_y'); + mRadarScale = CVar.GetCVar('aradar_scale'); for (uint i = 0; i < MAXPLAYERS; ++i) { mPlayerName[i] = -1; @@ -631,10 +639,16 @@ struct ARadarRenderer { in ARadarData radar ) const { bool hide_respawn = false; + bool draw_types[6]; if (mRadarRespawn != null) { hide_respawn = mRadarRespawn.GetBool(); } + if (mRadarShowType.Size() > 0) { + for (int i = 0; i < draw_types.Size(); i++) { + draw_types[i] = mRadarShowType[i].GetBool(); + } + } for (uint i = 0; i < radar.blips.Size(); ++i) { if ((radar.blips[i].flags & ARADAR_BLIPF_VISIBLE) == 0) { @@ -646,7 +660,11 @@ struct ARadarRenderer { continue; } } - + + if (!draw_types[radar.blips[i].type]) { + continue; + } + vector3 pos = draw.CalcRadarPos( draw.CalcWorldPos(radar.blips[i].mo) ); From d5668b8f159ae646701aa65a3f3cfbbb8337c6e6 Mon Sep 17 00:00:00 2001 From: Forevener Date: Wed, 14 Sep 2022 17:51:35 +0500 Subject: [PATCH 02/10] Settings for colors and transparency --- README.md | 7 +- cvarinfo.txt | 44 +++++++---- menudef.txt | 15 ++++ zscript/arookas/radar/renderer.txt | 121 +++++++++++++++++++---------- 4 files changed, 126 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 66691e3..14b7f2e 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,13 @@ If a _blip_ is beyond the visible distance of the radar, it will change into a p The table below describes the various colors of _blips_: -| Color | Target | Technical | +| Default Color | Target | Technical | |-------:|:-------|-----------| | Red | Living monsters | Has `ISMONSTER` and `COUNTKILL` flags. | | Blue | Living allies | Has `FRIENDLY` and `SHOOTABLE` flags. | -| Yellow | Key items / interactive objects | Derived from `Powerup` or `Key`, or has `USEPSECIAL` or `BUMPSECIAL` flags. | -| Green | Regular items | Derived from `Inventory` or has `COUNTITEM` flag. | +| Yellow | Key items / interactive objects | Derived from `Powerup` or `Key`, or has `USESPECIAL` or `BUMPSECIAL` flags. | +| Green | Regular items | Derived from `Inventory` and has no `COUNTITEM` flag. | +| Magenta | Collectible items | Derived from `Inventory` and has `COUNTITEM` flag. | | White | Objects | Has either `SHOOTABLE` or `FRIENDLY` flag (but not both). | ### Pips diff --git a/cvarinfo.txt b/cvarinfo.txt index 0326144..242aaaf 100644 --- a/cvarinfo.txt +++ b/cvarinfo.txt @@ -6,20 +6,34 @@ // -------------------------------------------------------------------------- // -nosave int aradar_anchor = 1; -nosave int aradar_order = 0; -nosave int aradar_offset_x = 30; -nosave int aradar_offset_y = 30; -nosave float aradar_scale = 0.70; -nosave bool aradar_blip_monster = true; -nosave bool aradar_blip_friend = true; -nosave bool aradar_blip_count = true; -nosave bool aradar_blip_key = true; -nosave bool aradar_blip_other = true; -nosave bool aradar_blip_deco = true; -nosave bool aradar_altitude = false; -nosave bool aradar_respawn = false; -nosave float aradar_volume = 1.0; -server cheat bool aradar_deathmatch = false; +nosave int aradar_anchor = 1; +nosave int aradar_order = 0; +nosave int aradar_offset_x = 30; +nosave int aradar_offset_y = 30; +nosave float aradar_scale = 0.70; +nosave float aradar_alpha = 1.0; +nosave bool aradar_blip_monster = true; +nosave bool aradar_blip_friend = true; +nosave bool aradar_blip_count = true; +nosave bool aradar_blip_key = true; +nosave bool aradar_blip_other = true; +nosave bool aradar_blip_deco = true; +nosave color aradar_blip_monster_color = "FA 07 03"; +nosave color aradar_blip_friend_color = "00 C1 F7"; +nosave color aradar_blip_count_color = "F5 07 F7"; +nosave color aradar_blip_key_color = "F5 F7 1A"; +nosave color aradar_blip_other_color = "02 FC 05"; +nosave color aradar_blip_deco_color = "FF FF FF"; +nosave bool aradar_altitude = false; +nosave bool aradar_respawn = false; +nosave float aradar_volume = 1.0; +server cheat bool aradar_deathmatch = false; // -------------------------------------------------------------------------- // + + + + + + + \ No newline at end of file diff --git a/menudef.txt b/menudef.txt index 6abe939..f30b97d 100644 --- a/menudef.txt +++ b/menudef.txt @@ -37,6 +37,7 @@ OptionMenu "ARadarOptions" { Slider "Radar scale", "aradar_scale", 0.25, 2.0, 0.05, 2, "aradar_anchor" Slider "Radar X offset", "aradar_offset_x", -200, 200, 5, 0, "aradar_anchor" Slider "Radar Y offset", "aradar_offset_y", -200, 200, 5, 0, "aradar_anchor" + Slider "Radar transparency", "aradar_alpha", 0, 1, 0.01, 2, "aradar_anchor" StaticText "" StaticText "Show blips for:" Option "Monsters", "aradar_blip_monster", "OnOff", "aradar_anchor" @@ -46,6 +47,8 @@ OptionMenu "ARadarOptions" { Option "Other items", "aradar_blip_other", "OnOff", "aradar_anchor" Option "Objects", "aradar_blip_deco", "OnOff", "aradar_anchor" StaticText "" + SubMenu "Customize blip colors", "CustomizeColors" + StaticText "" Option "Show blip altitude", "aradar_altitude", "NoYes", "aradar_anchor" Option "Show respawned items", "aradar_respawn", "NoYes", "aradar_anchor" StaticText "" @@ -53,5 +56,17 @@ OptionMenu "ARadarOptions" { } +OptionMenu "CustomizeColors" { + + StaticText "Blip colors:" + ColorPicker "Monsters", "aradar_blip_monster_color" + ColorPicker "Friendlies", "aradar_blip_friend_color" + ColorPicker "Collectibles", "aradar_blip_count_color" + ColorPicker "Keys and special items", "aradar_blip_key_color" + ColorPicker "Other items", "aradar_blip_other_color" + ColorPicker "Objects", "aradar_blip_deco_color" + +} + // -------------------------------------------------------------------------- // diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index 533dc0a..adc8862 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -267,24 +267,10 @@ struct ARadarRenderer { } - static const Color BLIP_COLORS[] = { - Color(255, 255, 255, 255), // white - Color(255, 2, 252, 5), // green - Color(255, 245, 247, 26), // yellow - Color(255, 0, 193, 247), // blue - Color(255, 250, 7, 3), // red - Color(255, 245, 7, 247) // magenta - }; - - static const Color BLOT_COLORS[] = { - Color(255, 255, 64, 72), // red - Color(255, 0, 255, 255), // blue - Color(255, 245, 247, 26) // yellow - }; - private TextureID mTex[TEX_NUM]; private int mPlayerName[MAXPLAYERS]; private int mTextSrcWidth; + private transient CVar mRadarBlipColors[6]; private transient CVar mScreenBlocks; private transient CVar mRadarAnchor; private transient CVar mRadarOrder; @@ -292,6 +278,7 @@ struct ARadarRenderer { private transient CVar mRadarAltitude; private transient CVar mRadarRespawn; private transient CVar mRadarScale; + private transient CVar mRadarAlpha; private transient CVar mRadarOffsetX; private transient CVar mRadarOffsetY; private ARadarAnm mAnmScanScale; @@ -300,20 +287,27 @@ struct ARadarRenderer { private vector3 mBoxVertex[4]; bool InitCVar() { - mScreenBlocks = CVar.GetCVar('screenblocks'); - mRadarAnchor = CVar.GetCVar('aradar_anchor'); - mRadarOrder = CVar.GetCVar('aradar_order'); - mRadarShowType[0] = CVar.GetCVar('aradar_blip_deco'); - mRadarShowType[1] = CVar.GetCVar('aradar_blip_other'); - mRadarShowType[2] = CVar.GetCVar('aradar_blip_key'); - mRadarShowType[3] = CVar.GetCVar('aradar_blip_friend'); - mRadarShowType[4] = CVar.GetCVar('aradar_blip_monster'); - mRadarShowType[5] = CVar.GetCVar('aradar_blip_count'); - mRadarAltitude = CVar.GetCVar('aradar_altitude'); - mRadarRespawn = CVar.GetCVar('aradar_respawn'); - mRadarOffsetX = CVar.GetCVar('aradar_offset_x'); - mRadarOffsetY = CVar.GetCVar('aradar_offset_y'); - mRadarScale = CVar.GetCVar('aradar_scale'); + mScreenBlocks = CVar.GetCVar('screenblocks'); + mRadarAnchor = CVar.GetCVar('aradar_anchor'); + mRadarOrder = CVar.GetCVar('aradar_order'); + mRadarShowType[0] = CVar.GetCVar('aradar_blip_deco'); + mRadarShowType[1] = CVar.GetCVar('aradar_blip_other'); + mRadarShowType[2] = CVar.GetCVar('aradar_blip_key'); + mRadarShowType[3] = CVar.GetCVar('aradar_blip_friend'); + mRadarShowType[4] = CVar.GetCVar('aradar_blip_monster'); + mRadarShowType[5] = CVar.GetCVar('aradar_blip_count'); + mRadarBlipColors[0] = CVar.GetCVar('aradar_blip_deco_color'); + mRadarBlipColors[1] = CVar.GetCVar('aradar_blip_other_color'); + mRadarBlipColors[2] = CVar.GetCVar('aradar_blip_key_color'); + mRadarBlipColors[3] = CVar.GetCVar('aradar_blip_friend_color'); + mRadarBlipColors[4] = CVar.GetCVar('aradar_blip_monster_color'); + mRadarBlipColors[5] = CVar.GetCVar('aradar_blip_count_color'); + mRadarAltitude = CVar.GetCVar('aradar_altitude'); + mRadarRespawn = CVar.GetCVar('aradar_respawn'); + mRadarOffsetX = CVar.GetCVar('aradar_offset_x'); + mRadarOffsetY = CVar.GetCVar('aradar_offset_y'); + mRadarScale = CVar.GetCVar('aradar_scale'); + mRadarAlpha = CVar.GetCVar('aradar_alpha'); for (uint i = 0; i < MAXPLAYERS; ++i) { mPlayerName[i] = -1; @@ -569,13 +563,20 @@ struct ARadarRenderer { private ui void RenderRadar( in ARadarDrawData draw ) const { + float radar_alpha = 1; + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } + Screen.DrawTexture( mTex[TEX_RADAR_BACK], false, draw.center.X, draw.center.Y, DTA_CenterOffset, true, DTA_DestHeightF, draw.radar_size, - DTA_DestWidthF, draw.radar_size + DTA_DestWidthF, draw.radar_size, + DTA_Alpha, radar_alpha ); double time = (draw.timer % 2.0); @@ -600,7 +601,8 @@ struct ARadarRenderer { DTA_ClipLeft, int(draw.center.X), DTA_DestHeightF, draw.radar_size, DTA_DestWidthF, draw.radar_size, - DTA_Rotate, -draw.fov + DTA_Rotate, -draw.fov, + DTA_Alpha, radar_alpha ); Screen.DrawTexture( @@ -612,7 +614,8 @@ struct ARadarRenderer { DTA_DestHeightF, draw.radar_size, DTA_DestWidthF, draw.radar_size, DTA_FlipX, true, - DTA_Rotate, draw.fov + DTA_Rotate, draw.fov, + DTA_Alpha, radar_alpha ); Screen.DrawTexture( @@ -621,7 +624,8 @@ struct ARadarRenderer { DTA_CenterOffset, true, DTA_DestHeightF, draw.radar_size, - DTA_DestWidthF, draw.radar_size + DTA_DestWidthF, draw.radar_size, + DTA_Alpha, radar_alpha ); Screen.DrawTexture( @@ -630,7 +634,8 @@ struct ARadarRenderer { DTA_CenterOffset, true, DTA_DestHeightF, draw.radar_size, - DTA_DestWidthF, draw.radar_size + DTA_DestWidthF, draw.radar_size, + DTA_Alpha, radar_alpha ); } @@ -638,12 +643,18 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { - bool hide_respawn = false; - bool draw_types[6]; + bool hide_respawn = false; + bool draw_types[6]; + float radar_alpha = 1; if (mRadarRespawn != null) { hide_respawn = mRadarRespawn.GetBool(); } + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } + if (mRadarShowType.Size() > 0) { for (int i = 0; i < draw_types.Size(); i++) { draw_types[i] = mRadarShowType[i].GetBool(); @@ -677,16 +688,16 @@ struct ARadarRenderer { blip_angle = -(VectorAngle(pos.X, pos.Y) + 90); } - ARadarBlipType blip_type = radar.blips[i].type; - Color blip_color = BLIP_COLORS[blip_type]; - + Color c = Color(mRadarBlipColors[radar.blips[i].type].GetString()); + Color blip_color = Color(int(radar_alpha * 255), c.r, c.g, c.b); + Screen.DrawTexture( mTex[blip_tex], false, (draw.center.X + pos.X), (draw.center.Y + pos.Y - pos.Z), DTA_CenterOffset, true, - DTA_Color, int(blip_color), + DTA_Color, blip_color, DTA_DestHeightF, draw.blip_size, DTA_DestWidthF, draw.blip_size, DTA_Rotate, blip_angle @@ -698,7 +709,8 @@ struct ARadarRenderer { (draw.center.Y + pos.Y), (draw.center.X + pos.X + 1), (draw.center.Y + pos.Y - pos.Z), - blip_color + blip_color, + int(radar_alpha * 255) ); } } @@ -708,6 +720,12 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { + float radar_alpha = 1; + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } + for (uint i = 0; i < MAXPLAYERS; ++i) { if (i == consoleplayer || !playeringame[i]) { continue; @@ -722,7 +740,8 @@ struct ARadarRenderer { vector3 pos = draw.CalcRadarPos(draw.CalcWorldPos(mo)); draw.ClampRadarPos(pos.X, pos.Y, pos.Z); - Color color = (players[i].GetColor() | 0xFF000000); + Color c = players[i].GetColor(); + Color color = Color(int(radar_alpha * 255), c.r, c.g, c.b); Screen.DrawTexture( mTex[TEX_PIP_BASE], false, @@ -780,6 +799,11 @@ struct ARadarRenderer { ) const { ARadarLine line; vector3 p0, p1; + float radar_alpha = 1; + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } for (uint i = 0; i < 4; ++i) { p0 = draw.CalcRadarPos(mBoxVertex[i]); @@ -795,7 +819,7 @@ struct ARadarRenderer { Screen.DrawLine( int(draw.center.X + line.a.X), int(draw.center.Y + line.a.Y), int(draw.center.X + line.b.X), int(draw.center.Y + line.b.Y), - 0xFFFF0000 + Color(int(radar_alpha * 255), 255, 0, 0) ); } } @@ -804,6 +828,17 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { + float radar_alpha = 1; + Color BLOT_COLORS[3]; + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } + + BLOT_COLORS[0] = Color(int(radar_alpha * 255), 255, 64, 72); // red + BLOT_COLORS[1] = Color(int(radar_alpha * 255), 0, 255, 255); // blue + BLOT_COLORS[2] = Color(int(radar_alpha * 255), 245, 247, 26); // yellow + for (uint i = 0; i < radar.blots.Size(); ++i) { vector3 pos = draw.CalcRadarPos(radar.blots[i].pos); From d5b7f58fee9b16a51b6dc36a256e2383aba9b7b9 Mon Sep 17 00:00:00 2001 From: Forevener Date: Thu, 15 Sep 2022 10:12:37 +0500 Subject: [PATCH 03/10] Small optimisations and fixes for transparency --- zscript/arookas/radar/renderer.txt | 75 ++++++++++++------------------ 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index adc8862..4f8ca04 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -267,9 +267,16 @@ struct ARadarRenderer { } + static const Color BLOT_COLORS[] = { + Color(255, 255, 64, 72), // red + Color(255, 0, 255, 255), // blue + Color(255, 245, 247, 26) // yellow + }; + private TextureID mTex[TEX_NUM]; private int mPlayerName[MAXPLAYERS]; private int mTextSrcWidth; + private float radar_alpha; private transient CVar mRadarBlipColors[6]; private transient CVar mScreenBlocks; private transient CVar mRadarAnchor; @@ -359,6 +366,8 @@ struct ARadarRenderer { mAnmScanFade.addKeyLinear(1.5, 0.15); mAnmScanFade.addKeyLinear(2.0, 0.00); } + + radar_alpha = 1.0; return true; } @@ -468,7 +477,13 @@ struct ARadarRenderer { if (mScreenBlocks != null && mScreenBlocks.GetInt() > 11) { return; } + + if (mRadarAlpha != null) { + radar_alpha = mRadarAlpha.GetFloat(); + } + + ARadarDrawData draw; draw.camera = e.Camera; @@ -563,11 +578,6 @@ struct ARadarRenderer { private ui void RenderRadar( in ARadarDrawData draw ) const { - float radar_alpha = 1; - - if (mRadarAlpha != null) { - radar_alpha = mRadarAlpha.GetFloat(); - } Screen.DrawTexture( mTex[TEX_RADAR_BACK], false, @@ -581,7 +591,7 @@ struct ARadarRenderer { double time = (draw.timer % 2.0); double scan_size = mAnmScanScale.eval(time); - double scan_fade = mAnmScanFade.eval(time); + double scan_fade = mAnmScanFade.eval(time) * radar_alpha; Screen.DrawTexture( mTex[TEX_RADAR_SCAN], false, @@ -645,16 +655,11 @@ struct ARadarRenderer { ) const { bool hide_respawn = false; bool draw_types[6]; - float radar_alpha = 1; if (mRadarRespawn != null) { hide_respawn = mRadarRespawn.GetBool(); } - if (mRadarAlpha != null) { - radar_alpha = mRadarAlpha.GetFloat(); - } - if (mRadarShowType.Size() > 0) { for (int i = 0; i < draw_types.Size(); i++) { draw_types[i] = mRadarShowType[i].GetBool(); @@ -688,8 +693,7 @@ struct ARadarRenderer { blip_angle = -(VectorAngle(pos.X, pos.Y) + 90); } - Color c = Color(mRadarBlipColors[radar.blips[i].type].GetString()); - Color blip_color = Color(int(radar_alpha * 255), c.r, c.g, c.b); + Color blip_color = Color(mRadarBlipColors[radar.blips[i].type].GetInt() | 0xFF000000); Screen.DrawTexture( mTex[blip_tex], false, @@ -697,10 +701,11 @@ struct ARadarRenderer { (draw.center.Y + pos.Y - pos.Z), DTA_CenterOffset, true, - DTA_Color, blip_color, + DTA_Color, int(blip_color), DTA_DestHeightF, draw.blip_size, DTA_DestWidthF, draw.blip_size, - DTA_Rotate, blip_angle + DTA_Rotate, blip_angle, + DTA_Alpha, radar_alpha ); if (abs(pos.Z) > 1) { @@ -720,12 +725,6 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { - float radar_alpha = 1; - - if (mRadarAlpha != null) { - radar_alpha = mRadarAlpha.GetFloat(); - } - for (uint i = 0; i < MAXPLAYERS; ++i) { if (i == consoleplayer || !playeringame[i]) { continue; @@ -740,8 +739,7 @@ struct ARadarRenderer { vector3 pos = draw.CalcRadarPos(draw.CalcWorldPos(mo)); draw.ClampRadarPos(pos.X, pos.Y, pos.Z); - Color c = players[i].GetColor(); - Color color = Color(int(radar_alpha * 255), c.r, c.g, c.b); + Color color = players[i].GetColor(); Screen.DrawTexture( mTex[TEX_PIP_BASE], false, @@ -751,7 +749,8 @@ struct ARadarRenderer { DTA_CenterOffset, true, DTA_Color, int(color), DTA_DestHeightF, draw.pip_size, - DTA_DestWidthF, draw.pip_size + DTA_DestWidthF, draw.pip_size, + DTA_Alpha, radar_alpha ); if (abs(pos.Z) > 1) { @@ -760,7 +759,8 @@ struct ARadarRenderer { (draw.center.Y + pos.Y), (draw.center.X + pos.X + 1), (draw.center.Y + pos.Y - pos.Z), - color + color, + int(radar_alpha * 255) ); } @@ -788,7 +788,8 @@ struct ARadarRenderer { DTA_DestHeightF, draw.pip_size, DTA_DestWidthF, draw.pip_size, DTA_SrcWidth, double(mTextSrcWidth), - DTA_SrcX, double(mTextSrcWidth * cell) + DTA_SrcX, double(mTextSrcWidth * cell), + DTA_Alpha, radar_alpha ); } } @@ -799,11 +800,6 @@ struct ARadarRenderer { ) const { ARadarLine line; vector3 p0, p1; - float radar_alpha = 1; - - if (mRadarAlpha != null) { - radar_alpha = mRadarAlpha.GetFloat(); - } for (uint i = 0; i < 4; ++i) { p0 = draw.CalcRadarPos(mBoxVertex[i]); @@ -819,7 +815,8 @@ struct ARadarRenderer { Screen.DrawLine( int(draw.center.X + line.a.X), int(draw.center.Y + line.a.Y), int(draw.center.X + line.b.X), int(draw.center.Y + line.b.Y), - Color(int(radar_alpha * 255), 255, 0, 0) + Color(255, 0, 0), + int(radar_alpha * 255) ); } } @@ -828,17 +825,6 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { - float radar_alpha = 1; - Color BLOT_COLORS[3]; - - if (mRadarAlpha != null) { - radar_alpha = mRadarAlpha.GetFloat(); - } - - BLOT_COLORS[0] = Color(int(radar_alpha * 255), 255, 64, 72); // red - BLOT_COLORS[1] = Color(int(radar_alpha * 255), 0, 255, 255); // blue - BLOT_COLORS[2] = Color(int(radar_alpha * 255), 245, 247, 26); // yellow - for (uint i = 0; i < radar.blots.Size(); ++i) { vector3 pos = draw.CalcRadarPos(radar.blots[i].pos); @@ -855,7 +841,8 @@ struct ARadarRenderer { DTA_CenterOffset, true, DTA_Color, int(blot_color), DTA_DestHeightF, draw.blot_size, - DTA_DestWidthF, draw.blot_size + DTA_DestWidthF, draw.blot_size, + DTA_Alpha, radar_alpha ); } } From 886118cdd090a7c7701fe0c119711b02854a4e73 Mon Sep 17 00:00:00 2001 From: Forevener <47249088+Forevener@users.noreply.github.com> Date: Thu, 15 Sep 2022 10:16:59 +0500 Subject: [PATCH 04/10] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14b7f2e..d7a4219 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# aradar v1.0 +# aradar v1.2 ## Description @@ -85,8 +85,11 @@ You can turn the radar on/off, change the appearance, and control specific featu | _Enable in deathmatch_ | Enables players to see the radar even in deathmatch. This is a host setting and cheats must be enabled to turn this on. | | _Draw under HUD_ | Whether the radar displays under or over existing HUD elements. | | _Radar scale_ | Global display scale of the radar and indicators. | +| _Radar transparency_ | Radar's transparency (alpha channel) to tune its intrusiveness. | | _Radar X offset_ | Horizontal offset of the radar display, in screen pixels. Positive values move radar towards the center of the screen. | | _Radar Y offset_ | Vertical offset of the radar display, in screen pixels. Positive values move radar towards the center of the screen. | +| _Blip Y types_ | Enables/disables specific radar blip types. | +| _Blip Y colors_ | Allow the user to customize colors for each blip type. | | _Show blip altitude_ | Turn this off to hide [altitude indicators](#altitude). This is useful for smaller screens. | | _Show respawned items_ | If `sv_itemrespawn` is enabled, items are allowed to reappear on the radar after respawning. Turning this off will keep the item's _blip_ hidden after being picked up the first time. This option can help clean up the radar for larger maps with lots of items. | | _Alert volume_ | Changes the volume of the [alert sound](#alert). Set to zero to turn the feature off entirely. | From 296f3e5f03a1b1ffc9fdbdc4c16630f02368e3c3 Mon Sep 17 00:00:00 2001 From: Forevener <47249088+Forevener@users.noreply.github.com> Date: Thu, 15 Sep 2022 10:17:37 +0500 Subject: [PATCH 05/10] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d7a4219..d2849e2 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,8 @@ You can turn the radar on/off, change the appearance, and control specific featu | _Radar transparency_ | Radar's transparency (alpha channel) to tune its intrusiveness. | | _Radar X offset_ | Horizontal offset of the radar display, in screen pixels. Positive values move radar towards the center of the screen. | | _Radar Y offset_ | Vertical offset of the radar display, in screen pixels. Positive values move radar towards the center of the screen. | -| _Blip Y types_ | Enables/disables specific radar blip types. | -| _Blip Y colors_ | Allow the user to customize colors for each blip type. | +| _Blip types_ | Enables/disables specific radar blip types. | +| _Blip colors_ | Allow the user to customize colors for each blip type. | | _Show blip altitude_ | Turn this off to hide [altitude indicators](#altitude). This is useful for smaller screens. | | _Show respawned items_ | If `sv_itemrespawn` is enabled, items are allowed to reappear on the radar after respawning. Turning this off will keep the item's _blip_ hidden after being picked up the first time. This option can help clean up the radar for larger maps with lots of items. | | _Alert volume_ | Changes the volume of the [alert sound](#alert). Set to zero to turn the feature off entirely. | From 25c768bba5e5f2c559865005d1a7dce0a06a4d26 Mon Sep 17 00:00:00 2001 From: Forevener Date: Fri, 16 Sep 2022 16:31:43 +0500 Subject: [PATCH 06/10] Small fixes 1) Blips for collectibles not disappearing 2) Blips staying on radar despite their actors changed type --- menudef.txt | 4 ++-- zscript/arookas/radar/data.txt | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/menudef.txt b/menudef.txt index f30b97d..e2d3122 100644 --- a/menudef.txt +++ b/menudef.txt @@ -43,7 +43,7 @@ OptionMenu "ARadarOptions" { Option "Monsters", "aradar_blip_monster", "OnOff", "aradar_anchor" Option "Friendlies", "aradar_blip_friend", "OnOff", "aradar_anchor" Option "Collectibles", "aradar_blip_count", "OnOff", "aradar_anchor" - Option "Keys and special items", "aradar_blip_key", "OnOff", "aradar_anchor" + Option "Keys, powerups and special items", "aradar_blip_key", "OnOff", "aradar_anchor" Option "Other items", "aradar_blip_other", "OnOff", "aradar_anchor" Option "Objects", "aradar_blip_deco", "OnOff", "aradar_anchor" StaticText "" @@ -62,7 +62,7 @@ OptionMenu "CustomizeColors" { ColorPicker "Monsters", "aradar_blip_monster_color" ColorPicker "Friendlies", "aradar_blip_friend_color" ColorPicker "Collectibles", "aradar_blip_count_color" - ColorPicker "Keys and special items", "aradar_blip_key_color" + ColorPicker "Keys, powerups and special items", "aradar_blip_key_color" ColorPicker "Other items", "aradar_blip_other_color" ColorPicker "Objects", "aradar_blip_deco_color" diff --git a/zscript/arookas/radar/data.txt b/zscript/arookas/radar/data.txt index 2c32b57..272e905 100644 --- a/zscript/arookas/radar/data.txt +++ b/zscript/arookas/radar/data.txt @@ -150,6 +150,7 @@ struct ARadarData { for (uint i = 0; i < self.blips.Size(); ++i) { if ((self.blips[i].flags & ARADAR_BLIPF_VISIBLE) != 0) { switch (self.blips[i].type) { + case ARADAR_BLIP_MAGENTA: case ARADAR_BLIP_GREEN: case ARADAR_BLIP_YELLOW: { break; @@ -164,7 +165,11 @@ struct ARadarData { if (mo == null) { continue; - } + } else if (ARadarBlip.DeduceType(self.blips[i].mo) < 0) { + self.blips.Delete(i); + i--; + continue; + } switch (self.blips[i].type) { case ARADAR_BLIP_RED: { @@ -176,6 +181,7 @@ struct ARadarData { break; } + case ARADAR_BLIP_MAGENTA: case ARADAR_BLIP_GREEN: case ARADAR_BLIP_YELLOW: { let item = Inventory(mo); From 937c3ebe1924d0006c15da3f64e0e73ad4109211 Mon Sep 17 00:00:00 2001 From: Forevener Date: Fri, 16 Sep 2022 23:05:53 +0500 Subject: [PATCH 07/10] Small fix for pips --- zscript/arookas/radar/renderer.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index 4f8ca04..60925bf 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -739,7 +739,7 @@ struct ARadarRenderer { vector3 pos = draw.CalcRadarPos(draw.CalcWorldPos(mo)); draw.ClampRadarPos(pos.X, pos.Y, pos.Z); - Color color = players[i].GetColor(); + Color color = (players[i].GetColor() | 0xFF000000); Screen.DrawTexture( mTex[TEX_PIP_BASE], false, From 0147ac6dab2556c5fd5b282ede50a9679faf48e0 Mon Sep 17 00:00:00 2001 From: Forevener Date: Sun, 18 Sep 2022 20:35:39 +0500 Subject: [PATCH 08/10] Crash fix --- zscript/arookas/radar/data.txt | 10 +++++++--- zscript/arookas/radar/manager.txt | 10 ++++++---- zscript/arookas/radar/renderer.txt | 4 ++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/zscript/arookas/radar/data.txt b/zscript/arookas/radar/data.txt index 272e905..0e8a422 100644 --- a/zscript/arookas/radar/data.txt +++ b/zscript/arookas/radar/data.txt @@ -148,6 +148,9 @@ struct ARadarData { int notices = 0; for (uint i = 0; i < self.blips.Size(); ++i) { + if (!self.blips[i]) { + break; + } if ((self.blips[i].flags & ARADAR_BLIPF_VISIBLE) != 0) { switch (self.blips[i].type) { case ARADAR_BLIP_MAGENTA: @@ -163,9 +166,7 @@ struct ARadarData { Actor mo = self.blips[i].mo; - if (mo == null) { - continue; - } else if (ARadarBlip.DeduceType(self.blips[i].mo) < 0) { + if (mo == null || ARadarBlip.DeduceType(self.blips[i].mo) < 0) { self.blips.Delete(i); i--; continue; @@ -252,6 +253,9 @@ struct ARadarData { bool RemoveBlip(Actor mo) { for (uint i = 0; i < self.blips.Size(); ++i) { + if (!self.blips[i]) { + return false; + } if (self.blips[i].mo != mo) { continue; } diff --git a/zscript/arookas/radar/manager.txt b/zscript/arookas/radar/manager.txt index d78ad97..a68762e 100644 --- a/zscript/arookas/radar/manager.txt +++ b/zscript/arookas/radar/manager.txt @@ -68,16 +68,18 @@ class ARadarManager : EventHandler { if (mDefunct) { return; } - - mData.RemoveBlip(e.Thing); + if (ARadarBlip.DeduceType(e.Thing) >= 0) { + mData.RemoveBlip(e.Thing); + } } override void WorldThingDestroyed(WorldEvent e) { if (mDefunct) { return; } - - mData.RemoveBlip(e.Thing); + if (ARadarBlip.DeduceType(e.Thing) >= 0) { + mData.RemoveBlip(e.Thing); + } } override void PlayerDied(PlayerEvent e) { diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index 60925bf..d818d44 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -667,6 +667,10 @@ struct ARadarRenderer { } for (uint i = 0; i < radar.blips.Size(); ++i) { + if (!radar.blips[i]) { + break; + } + if ((radar.blips[i].flags & ARADAR_BLIPF_VISIBLE) == 0) { continue; } From 2f92c60b02eec552f4ef418f1feda4cd13f64fe5 Mon Sep 17 00:00:00 2001 From: Forevener Date: Sun, 18 Sep 2022 22:42:58 +0500 Subject: [PATCH 09/10] Small refactoring --- zscript/arookas/radar/data.txt | 22 ++++++++++++---------- zscript/arookas/radar/manager.txt | 10 ++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/zscript/arookas/radar/data.txt b/zscript/arookas/radar/data.txt index 0e8a422..8f6ac65 100644 --- a/zscript/arookas/radar/data.txt +++ b/zscript/arookas/radar/data.txt @@ -252,18 +252,20 @@ struct ARadarData { } bool RemoveBlip(Actor mo) { - for (uint i = 0; i < self.blips.Size(); ++i) { - if (!self.blips[i]) { - return false; - } - if (self.blips[i].mo != mo) { - continue; - } + if (ARadarBlip.DeduceType(e.Thing) >= 0) { + for (uint i = 0; i < self.blips.Size(); ++i) { + if (!self.blips[i]) { + return false; + } + if (self.blips[i].mo != mo) { + continue; + } - --self.counts[self.blips[i].type]; - self.blips.Delete(i); + --self.counts[self.blips[i].type]; + self.blips.Delete(i); - return true; + return true; + } } return false; diff --git a/zscript/arookas/radar/manager.txt b/zscript/arookas/radar/manager.txt index a68762e..1d202e8 100644 --- a/zscript/arookas/radar/manager.txt +++ b/zscript/arookas/radar/manager.txt @@ -68,18 +68,16 @@ class ARadarManager : EventHandler { if (mDefunct) { return; } - if (ARadarBlip.DeduceType(e.Thing) >= 0) { - mData.RemoveBlip(e.Thing); - } + + mData.RemoveBlip(e.Thing); } override void WorldThingDestroyed(WorldEvent e) { if (mDefunct) { return; } - if (ARadarBlip.DeduceType(e.Thing) >= 0) { - mData.RemoveBlip(e.Thing); - } + + mData.RemoveBlip(e.Thing); } override void PlayerDied(PlayerEvent e) { From 7183f911af98af88d54e0d20fbd1d2f2b396b7b3 Mon Sep 17 00:00:00 2001 From: Forevener Date: Mon, 19 Sep 2022 11:03:04 +0500 Subject: [PATCH 10/10] Hide obtained key blips in multiplayer --- zscript/arookas/radar/data.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zscript/arookas/radar/data.txt b/zscript/arookas/radar/data.txt index 8f6ac65..360416f 100644 --- a/zscript/arookas/radar/data.txt +++ b/zscript/arookas/radar/data.txt @@ -166,9 +166,10 @@ struct ARadarData { Actor mo = self.blips[i].mo; - if (mo == null || ARadarBlip.DeduceType(self.blips[i].mo) < 0) { + if (ARadarBlip.DeduceType(self.blips[i].mo) < 0) { + --self.counts[self.blips[i].type]; self.blips.Delete(i); - i--; + --i; continue; } @@ -198,6 +199,15 @@ struct ARadarData { self.blips[i].flags |= ARADAR_BLIPF_RESPAWNED; continue; } + + if (multiplayer && mo is 'Key') { + if (players[consoleplayer].mo.CountInv(mo.GetClassName()) > 0) { + if ((self.blips[i].flags & ARADAR_BLIPF_VISIBLE) == 1) { + self.blips[i].flags &= ~ARADAR_BLIPF_VISIBLE; + } + continue; + } + } } break; @@ -252,7 +262,7 @@ struct ARadarData { } bool RemoveBlip(Actor mo) { - if (ARadarBlip.DeduceType(e.Thing) >= 0) { + if (ARadarBlip.DeduceType(mo) >= 0) { for (uint i = 0; i < self.blips.Size(); ++i) { if (!self.blips[i]) { return false;