diff --git a/README.md b/README.md index 66691e3..d2849e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# aradar v1.0 +# aradar v1.2 ## Description @@ -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 @@ -84,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 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. | diff --git a/cvarinfo.txt b/cvarinfo.txt index 61e96ed..242aaaf 100644 --- a/cvarinfo.txt +++ b/cvarinfo.txt @@ -6,14 +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_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 ebdf5cd..e2d3122 100644 --- a/menudef.txt +++ b/menudef.txt @@ -37,6 +37,17 @@ 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" + Option "Friendlies", "aradar_blip_friend", "OnOff", "aradar_anchor" + Option "Collectibles", "aradar_blip_count", "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 "" + SubMenu "Customize blip colors", "CustomizeColors" StaticText "" Option "Show blip altitude", "aradar_altitude", "NoYes", "aradar_anchor" Option "Show respawned items", "aradar_respawn", "NoYes", "aradar_anchor" @@ -45,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, 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 4084912..360416f 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) { @@ -142,8 +148,12 @@ 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: case ARADAR_BLIP_GREEN: case ARADAR_BLIP_YELLOW: { break; @@ -156,9 +166,12 @@ struct ARadarData { Actor mo = self.blips[i].mo; - if (mo == null) { - continue; - } + if (ARadarBlip.DeduceType(self.blips[i].mo) < 0) { + --self.counts[self.blips[i].type]; + self.blips.Delete(i); + --i; + continue; + } switch (self.blips[i].type) { case ARADAR_BLIP_RED: { @@ -170,6 +183,7 @@ struct ARadarData { break; } + case ARADAR_BLIP_MAGENTA: case ARADAR_BLIP_GREEN: case ARADAR_BLIP_YELLOW: { let item = Inventory(mo); @@ -185,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; @@ -239,15 +262,20 @@ struct ARadarData { } bool RemoveBlip(Actor mo) { - for (uint i = 0; i < self.blips.Size(); ++i) { - if (self.blips[i].mo != mo) { - continue; - } + if (ARadarBlip.DeduceType(mo) >= 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 d78ad97..1d202e8 100644 --- a/zscript/arookas/radar/manager.txt +++ b/zscript/arookas/radar/manager.txt @@ -68,7 +68,7 @@ class ARadarManager : EventHandler { if (mDefunct) { return; } - + mData.RemoveBlip(e.Thing); } diff --git a/zscript/arookas/radar/renderer.txt b/zscript/arookas/radar/renderer.txt index d554a0d..d818d44 100644 --- a/zscript/arookas/radar/renderer.txt +++ b/zscript/arookas/radar/renderer.txt @@ -267,29 +267,25 @@ 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 - }; - 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; private transient CVar mRadarOrder; + private transient CVar mRadarShowType[6]; 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; @@ -298,14 +294,27 @@ 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'); + 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; @@ -357,6 +366,8 @@ struct ARadarRenderer { mAnmScanFade.addKeyLinear(1.5, 0.15); mAnmScanFade.addKeyLinear(2.0, 0.00); } + + radar_alpha = 1.0; return true; } @@ -466,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; @@ -561,18 +578,20 @@ struct ARadarRenderer { private ui void RenderRadar( in ARadarDrawData draw ) const { + 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); 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, @@ -592,7 +611,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( @@ -604,7 +624,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( @@ -613,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 ); Screen.DrawTexture( @@ -622,7 +644,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 ); } @@ -630,13 +653,24 @@ struct ARadarRenderer { in ARadarDrawData draw, in ARadarData radar ) const { - bool hide_respawn = false; + 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]) { + break; + } + if ((radar.blips[i].flags & ARADAR_BLIPF_VISIBLE) == 0) { continue; } @@ -646,7 +680,11 @@ struct ARadarRenderer { continue; } } - + + if (!draw_types[radar.blips[i].type]) { + continue; + } + vector3 pos = draw.CalcRadarPos( draw.CalcWorldPos(radar.blips[i].mo) ); @@ -659,9 +697,8 @@ 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 blip_color = Color(mRadarBlipColors[radar.blips[i].type].GetInt() | 0xFF000000); + Screen.DrawTexture( mTex[blip_tex], false, (draw.center.X + pos.X), @@ -671,7 +708,8 @@ struct ARadarRenderer { 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) { @@ -680,7 +718,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) ); } } @@ -714,7 +753,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) { @@ -723,7 +763,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) ); } @@ -751,7 +792,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 ); } } @@ -777,7 +819,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), - 0xFFFF0000 + Color(255, 0, 0), + int(radar_alpha * 255) ); } } @@ -802,7 +845,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 ); } }