diff --git a/MiniMapLibrary/Interactible/InteractableKind.cs b/MiniMapLibrary/Interactible/InteractableKind.cs index c31267e..2c2d095 100644 --- a/MiniMapLibrary/Interactible/InteractableKind.cs +++ b/MiniMapLibrary/Interactible/InteractableKind.cs @@ -19,6 +19,7 @@ public enum InteractableKind Drone = 1 << 7, Barrel = 1 << 8, Enemy = 1 << 9, - All = 0b_1111_1 + Printer = 1 << 10, + All = 0b_1111_11 } } diff --git a/MiniMapLibrary/Settings.cs b/MiniMapLibrary/Settings.cs index e77a1c1..93004fc 100644 --- a/MiniMapLibrary/Settings.cs +++ b/MiniMapLibrary/Settings.cs @@ -62,6 +62,7 @@ void AddSize(InteractableKind type, float width = -1, float height = -1, Color A AddSize(InteractableKind.Special, 7, 7); AddSize(InteractableKind.Enemy, 3, 3, ActiveColor: Color.red); AddSize(InteractableKind.Utility); + AddSize(InteractableKind.Printer, 10, 10); } public static InteractibleSetting GetSetting(InteractableKind type) @@ -100,5 +101,18 @@ public static Dimension2D GetInteractableSize(InteractableKind type) return DefaultUIElementSize; } + + public static void UpdateSetting(InteractableKind type, float width, float height, Color active, Color inactive) + { + if (InteractibleSettings.ContainsKey(type)) + { + var setting = InteractibleSettings[type]; + + setting.ActiveColor = active; + setting.InactiveColor = inactive; + setting.Dimensions.Height = height; + setting.Dimensions.Width = width; + } + } } } diff --git a/MiniMapLibrary/SpriteManager.cs b/MiniMapLibrary/SpriteManager.cs index d909456..fbcab0f 100644 --- a/MiniMapLibrary/SpriteManager.cs +++ b/MiniMapLibrary/SpriteManager.cs @@ -38,6 +38,7 @@ static void Add(InteractableKind type, string ResourcePath) Add(InteractableKind.Barrel, "Textures/MiscIcons/texBarrelIcon"); Add(InteractableKind.Enemy, "Textures/MiscIcons/texBarrelIcon"); Add(InteractableKind.Player, "Textures/MiscIcons/texBarrelIcon"); + Add(InteractableKind.Printer, "Textures/MiscIcons/texInventoryIconOutlined"); Add(InteractableKind.All, DefaultResourcePath); } diff --git a/MiniMapMod.sln b/MiniMapMod.sln index c66a7f8..eb974c2 100644 --- a/MiniMapMod.sln +++ b/MiniMapMod.sln @@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metadata", "Metadata", "{3A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniMapLibrary", "MiniMapLibrary\MiniMapLibrary.csproj", "{82C1D748-9C54-4120-B0E5-1A0B494B3082}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AD35E87D-139A-4C74-8352-9C77323F4FB0}" + ProjectSection(SolutionItems) = preProject + manifest.json = manifest.json + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/MiniMapMod/MiniMapPlugin.cs b/MiniMapMod/MiniMapPlugin.cs index b914d6a..c464853 100644 --- a/MiniMapMod/MiniMapPlugin.cs +++ b/MiniMapMod/MiniMapPlugin.cs @@ -5,10 +5,11 @@ using System.Collections.Generic; using System.Linq; using System; +using BepInEx.Configuration; namespace MiniMapMod { - [BepInPlugin("MiniMap", "Mini Map Mod", "3.0.1")] + [BepInPlugin("MiniMap", "Mini Map Mod", "3.1.0")] public class MiniMapPlugin : BaseUnityPlugin { private readonly ISpriteManager SpriteManager = new SpriteManager(); @@ -23,10 +24,29 @@ public class MiniMapPlugin : BaseUnityPlugin private bool ScannedStaticObjects = false; + private readonly Dictionary> ScanOptions = new(); + public void Awake() { Log.Init(Logger); + // bind options + InteractableKind[] kinds = Enum.GetValues(typeof(InteractableKind)).Cast().ToArray(); + + for (int i = 0; i < kinds.Length; i++) + { + InteractableKind kind = kinds[i]; + + ScanOptions.Add(kind, Config.Bind($"Icon.{kind}", "enabled", true, $"Whether or or {kind} should be shown on the minimap")); + + ConfigEntry activeColor = Config.Bind($"Icon.{kind}", "activeColor", Settings.GetColor(kind, true), "The color the icon should be when it has not been interacted with"); + ConfigEntry inactiveColor = Config.Bind($"Icon.{kind}", "inactiveColor", Settings.GetColor(kind, false), "The color the icon should be when it has used/bought"); + ConfigEntry iconWidth = Config.Bind($"Icon.{kind}", "width", Settings.GetInteractableSize(kind).Width, "Width of the icon"); + ConfigEntry iconHeight = Config.Bind($"Icon.{kind}", "height", Settings.GetInteractableSize(kind).Height, "Width of the icon"); + + Settings.UpdateSetting(kind, iconWidth.Value, iconHeight.Value, activeColor.Value, inactiveColor.Value); + } + Log.LogInfo("MINIMAP: Creating scene scan hooks"); GlobalEventManager.onCharacterDeathGlobal += (x) => ScanScene(); @@ -181,7 +201,11 @@ private void ScanStaticTypes() RegisterMonobehaviorType(InteractableKind.Shrine, dynamicObject: false); - RegisterMonobehaviorType(InteractableKind.Chest, dynamicObject: false); + // normal shops + RegisterMonobehaviorType(InteractableKind.Chest, dynamicObject: false, selector: shop => shop.GetComponent().contextToken != "DUPLICATOR_CONTEXT"); + + // duplicators + RegisterMonobehaviorType(InteractableKind.Printer, dynamicObject: false, selector: shop => shop.GetComponent().contextToken == "DUPLICATOR_CONTEXT"); RegisterMonobehaviorType(InteractableKind.Barrel, barrel => !barrel.Networkopened, dynamicObject: false); @@ -220,9 +244,17 @@ private void ClearDynamicTrackedObjects() } } - private void RegisterMonobehaviorType(InteractableKind kind, Func ActiveChecker = null, bool dynamicObject = true) where T : MonoBehaviour + private void RegisterMonobehaviorType(InteractableKind kind, Func ActiveChecker = null, bool dynamicObject = true, Func selector = null) where T : MonoBehaviour { - IEnumerable found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x); + // check to see if it's enabled in the config + if (ScanOptions[kind].Value == false) + { + return; + } + + selector ??= (x) => true; + + IEnumerable found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x).Where(selector); RegisterMonobehaviours(found, kind, ActiveChecker, dynamicObject); } diff --git a/README.md b/README.md index d689f47..1a9696c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Adds a contemporary Minimap to the game. - Implements a Mini Map In-Game. - Show interactable items, shrines, teleporters, enemies and more. - Single and Multiplayer Compatible. -- Plays Nice with 95% of Most Downloaded Mods. +- Every icon is configurable for color, size and can be toggled on/off. ### Showcase @@ -26,7 +26,12 @@ Adds a contemporary Minimap to the game. - Toggle 'M' to hide and show minimap to force a refresh and/or a re-draw if something wonky is happening on the minimap. ### Config -No config applicable at this time +BepInEx Config. Each icon is individually configurable. +- Enabled / Disabled +- Active Color +- Inactive Color +- Icon Width +- Icon Height ### Upcoming Changes None - Final Release @@ -38,6 +43,11 @@ https://www.autism.org/donate-autism-research-institute/ If you have an issue, discover a bug, or have a recommendation please file an issue on my github page. ### Change Log +Major 3.1 +- Added config toggle to enable or disable each individual icon +- Added config option to choose color for each individual icon +- Added config option to choose icon height and width for each individual icon + Minor 3.0.1 - un-spammed console diff --git a/manifest.json b/manifest.json index 1eb3190..59010ca 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "name": "MiniMapMod", - "version_number": "3.0.1", + "version_number": "3.1", "website_url": "https://github.com/DekuDesu", - "description": "Adds a MiniMap to your game v3.0", + "description": "Adds a MiniMap to your game v3.1", "dependencies": [ "bbepis-BepInExPack-5.4.9", "RiskofThunder-HookGenPatcher-1.2.1" diff --git a/post_build.ps1 b/post_build.ps1 new file mode 100644 index 0000000..72111d2 --- /dev/null +++ b/post_build.ps1 @@ -0,0 +1,25 @@ +param([string]$version="NO_VERSION") + +$destination = ".\Releases\$version" +$pluginDestination = "C:\Users\user\AppData\Roaming\r2modmanPlus-local\RiskOfRain2\profiles\Modding\BepInEx\plugins\$version" + +if(Test-Path $destination) +{ + Remove-Item $destination -Recurse +} +if(Test-Path $pluginDestination) +{ + Remove-Item $pluginDestination -Recurse +} + +New-Item -Path $destination -ItemType Directory + +Copy-Item -Path ".\MiniMapMod\obj\Release\netstandard2.1\MiniMapMod.dll" -Destination $destination +Copy-Item -Path ".\MiniMapLibrary\obj\Release\netstandard2.1\MiniMapLibrary.dll" -Destination $destination +Copy-Item -Path ".\README.md" -Destination $destination +Copy-Item -Path ".\icon.png" -Destination $destination +Copy-Item -Path ".\manifest.json" -Destination $destination + +Copy-Item -Path $destination $pluginDestination -Recurse + +Compress-Archive -Path "$destination\*.*" -DestinationPath "$destination\$version.zip"