From 968a1f87ffbe416760a2a9a5f50434c0df9afb2f Mon Sep 17 00:00:00 2001 From: Midnight295 <143055111+Midnight295@users.noreply.github.com> Date: Tue, 3 Feb 2026 19:56:16 -0800 Subject: [PATCH] feat: Made custom drawing for Smart Cursor highlights more accurate. --- Tiles/BaseTiles/BaseMonolith.cs | 15 ++++++--------- Tiles/DraedonStructures/PowerCellFactory.cs | 13 +++++-------- Tiles/DraedonSummoner/CodebreakerTile.cs | 15 ++++++--------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Tiles/BaseTiles/BaseMonolith.cs b/Tiles/BaseTiles/BaseMonolith.cs index 50111964b9..e2f6da7c53 100644 --- a/Tiles/BaseTiles/BaseMonolith.cs +++ b/Tiles/BaseTiles/BaseMonolith.cs @@ -143,20 +143,17 @@ namespace CalamityMod.Tiles.BaseTiles // 02FEB2025: Ozzatron: code lifted from https://github.com/CalamityTeam/CalamityModPublic/pull/77 // transplanted into base monolith as part of manual cherry pick merge // - // Draws the Smart Cursor Highlight. Not 100% accurate, but its close enough + // Draws the Smart Cursor Highlight. Color highlightColor; var highlight = TextureAssets.HighlightMask[Type]; if (highlight != null && highlight.IsLoaded && Main.InSmartCursorHighlightArea(i, j, out var actuallySelected)) { - if (actuallySelected) - { - highlightColor = new Color(252, 252, 84); + int avgBrightness = (drawColor.R + drawColor.G + drawColor.B) / 3; + if (avgBrightness > 10) + { + highlightColor = Colors.GetSelectionGlowColor(actuallySelected, avgBrightness); + Main.spriteBatch.Draw(highlight.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, rect, highlightColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } - else - { - highlightColor = new Color(125, 125, 125); - } - Main.spriteBatch.Draw(highlight.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animateFrameOffset, 16, height), highlightColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); ; } return false; diff --git a/Tiles/DraedonStructures/PowerCellFactory.cs b/Tiles/DraedonStructures/PowerCellFactory.cs index 121125919f..0a700bb8aa 100644 --- a/Tiles/DraedonStructures/PowerCellFactory.cs +++ b/Tiles/DraedonStructures/PowerCellFactory.cs @@ -145,19 +145,16 @@ namespace CalamityMod.Tiles.DraedonStructures else if (t.IsHalfBlock) spriteBatch.Draw(tex, drawOffset + Vector2.UnitY * 8f, new Rectangle(frameXPos, frameYPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - // Draws the Smart Cursor Highlight. Not 100% accurate, but its close enough + // Draws the Smart Cursor Highlight. Color highlightColor; if (TileID.Sets.HasOutlines[Type] && Main.InSmartCursorHighlightArea(i, j, out var actuallySelected)) { - if (actuallySelected) + int avgBrightness = (drawColor.R + drawColor.G + drawColor.B) / 3; + if (avgBrightness > 10) { - highlightColor = new Color(252, 252, 84); + highlightColor = Colors.GetSelectionGlowColor(actuallySelected, avgBrightness); + spriteBatch.Draw(TextureAssets.HighlightMask[Type].Value, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), highlightColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - else - { - highlightColor = new Color(125, 125, 125); - } - spriteBatch.Draw(TextureAssets.HighlightMask[Type].Value, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), highlightColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } diff --git a/Tiles/DraedonSummoner/CodebreakerTile.cs b/Tiles/DraedonSummoner/CodebreakerTile.cs index 0daeccde33..989f02a7a6 100644 --- a/Tiles/DraedonSummoner/CodebreakerTile.cs +++ b/Tiles/DraedonSummoner/CodebreakerTile.cs @@ -234,19 +234,16 @@ namespace CalamityMod.Tiles.DraedonSummoner if (codebreakerTileEntity.ContainsDecryptionComputer && codebreakerTileEntity.ContainsSensorArray && !codebreakerTileEntity.ContainsAdvancedDisplay && codebreakerTileEntity.ContainsVoltageRegulationSystem) return false; - bool actuallySelected; + // Draws the appropriate Smart Cursor highlight sprite selected from above. Color highlightColor; - if (Main.InSmartCursorHighlightArea(i, j, out actuallySelected) && codebreakerTileEntity.ContainsDecryptionComputer) + if (Main.InSmartCursorHighlightArea(i, j, out var actuallySelected) && codebreakerTileEntity.ContainsDecryptionComputer) { - if (actuallySelected) + int avgBrightness = (drawColor.R + drawColor.G + drawColor.B) / 3; + if (avgBrightness > 10) { - highlightColor = new Color(252, 252, 84); + highlightColor = Colors.GetSelectionGlowColor(actuallySelected, avgBrightness); + spriteBatch.Draw(HighlightToUse, drawPosition, frame, highlightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } - else - { - highlightColor = new Color(125, 125, 125); - } - spriteBatch.Draw(HighlightToUse, drawPosition, frame, highlightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } }