Skip to content

Commit 9abb69f

Browse files
authored
Merge pull request #21 from DekuDesu/development
added config support, added automated release building
2 parents 18f8704 + 18bf150 commit 9abb69f

8 files changed

Lines changed: 98 additions & 9 deletions

File tree

MiniMapLibrary/Interactible/InteractableKind.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public enum InteractableKind
1919
Drone = 1 << 7,
2020
Barrel = 1 << 8,
2121
Enemy = 1 << 9,
22-
All = 0b_1111_1
22+
Printer = 1 << 10,
23+
All = 0b_1111_11
2324
}
2425
}

MiniMapLibrary/Settings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void AddSize(InteractableKind type, float width = -1, float height = -1, Color A
6262
AddSize(InteractableKind.Special, 7, 7);
6363
AddSize(InteractableKind.Enemy, 3, 3, ActiveColor: Color.red);
6464
AddSize(InteractableKind.Utility);
65+
AddSize(InteractableKind.Printer, 10, 10);
6566
}
6667

6768
public static InteractibleSetting GetSetting(InteractableKind type)
@@ -100,5 +101,18 @@ public static Dimension2D GetInteractableSize(InteractableKind type)
100101

101102
return DefaultUIElementSize;
102103
}
104+
105+
public static void UpdateSetting(InteractableKind type, float width, float height, Color active, Color inactive)
106+
{
107+
if (InteractibleSettings.ContainsKey(type))
108+
{
109+
var setting = InteractibleSettings[type];
110+
111+
setting.ActiveColor = active;
112+
setting.InactiveColor = inactive;
113+
setting.Dimensions.Height = height;
114+
setting.Dimensions.Width = width;
115+
}
116+
}
103117
}
104118
}

MiniMapLibrary/SpriteManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void Add(InteractableKind type, string ResourcePath)
3838
Add(InteractableKind.Barrel, "Textures/MiscIcons/texBarrelIcon");
3939
Add(InteractableKind.Enemy, "Textures/MiscIcons/texBarrelIcon");
4040
Add(InteractableKind.Player, "Textures/MiscIcons/texBarrelIcon");
41+
Add(InteractableKind.Printer, "Textures/MiscIcons/texInventoryIconOutlined");
4142
Add(InteractableKind.All, DefaultResourcePath);
4243
}
4344

MiniMapMod.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metadata", "Metadata", "{3A
1313
EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniMapLibrary", "MiniMapLibrary\MiniMapLibrary.csproj", "{82C1D748-9C54-4120-B0E5-1A0B494B3082}"
1515
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AD35E87D-139A-4C74-8352-9C77323F4FB0}"
17+
ProjectSection(SolutionItems) = preProject
18+
manifest.json = manifest.json
19+
README.md = README.md
20+
EndProjectSection
21+
EndProject
1622
Global
1723
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1824
Debug|Any CPU = Debug|Any CPU

MiniMapMod/MiniMapPlugin.cs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System;
8+
using BepInEx.Configuration;
89

910
namespace MiniMapMod
1011
{
11-
[BepInPlugin("MiniMap", "Mini Map Mod", "3.0.1")]
12+
[BepInPlugin("MiniMap", "Mini Map Mod", "3.1.0")]
1213
public class MiniMapPlugin : BaseUnityPlugin
1314
{
1415
private readonly ISpriteManager SpriteManager = new SpriteManager();
@@ -23,10 +24,29 @@ public class MiniMapPlugin : BaseUnityPlugin
2324

2425
private bool ScannedStaticObjects = false;
2526

27+
private readonly Dictionary<InteractableKind, ConfigEntry<bool>> ScanOptions = new();
28+
2629
public void Awake()
2730
{
2831
Log.Init(Logger);
2932

33+
// bind options
34+
InteractableKind[] kinds = Enum.GetValues(typeof(InteractableKind)).Cast<InteractableKind>().ToArray();
35+
36+
for (int i = 0; i < kinds.Length; i++)
37+
{
38+
InteractableKind kind = kinds[i];
39+
40+
ScanOptions.Add(kind, Config.Bind<bool>($"Icon.{kind}", "enabled", true, $"Whether or or {kind} should be shown on the minimap"));
41+
42+
ConfigEntry<Color> activeColor = Config.Bind<Color>($"Icon.{kind}", "activeColor", Settings.GetColor(kind, true), "The color the icon should be when it has not been interacted with");
43+
ConfigEntry<Color> inactiveColor = Config.Bind<Color>($"Icon.{kind}", "inactiveColor", Settings.GetColor(kind, false), "The color the icon should be when it has used/bought");
44+
ConfigEntry<float> iconWidth = Config.Bind<float>($"Icon.{kind}", "width", Settings.GetInteractableSize(kind).Width, "Width of the icon");
45+
ConfigEntry<float> iconHeight = Config.Bind<float>($"Icon.{kind}", "height", Settings.GetInteractableSize(kind).Height, "Width of the icon");
46+
47+
Settings.UpdateSetting(kind, iconWidth.Value, iconHeight.Value, activeColor.Value, inactiveColor.Value);
48+
}
49+
3050
Log.LogInfo("MINIMAP: Creating scene scan hooks");
3151

3252
GlobalEventManager.onCharacterDeathGlobal += (x) => ScanScene();
@@ -181,7 +201,11 @@ private void ScanStaticTypes()
181201

182202
RegisterMonobehaviorType<ShrineRestackBehavior>(InteractableKind.Shrine, dynamicObject: false);
183203

184-
RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Chest, dynamicObject: false);
204+
// normal shops
205+
RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Chest, dynamicObject: false, selector: shop => shop.GetComponent<PurchaseInteraction>().contextToken != "DUPLICATOR_CONTEXT");
206+
207+
// duplicators
208+
RegisterMonobehaviorType<ShopTerminalBehavior>(InteractableKind.Printer, dynamicObject: false, selector: shop => shop.GetComponent<PurchaseInteraction>().contextToken == "DUPLICATOR_CONTEXT");
185209

186210
RegisterMonobehaviorType<BarrelInteraction>(InteractableKind.Barrel, barrel => !barrel.Networkopened, dynamicObject: false);
187211

@@ -220,9 +244,17 @@ private void ClearDynamicTrackedObjects()
220244
}
221245
}
222246

223-
private void RegisterMonobehaviorType<T>(InteractableKind kind, Func<T, bool> ActiveChecker = null, bool dynamicObject = true) where T : MonoBehaviour
247+
private void RegisterMonobehaviorType<T>(InteractableKind kind, Func<T, bool> ActiveChecker = null, bool dynamicObject = true, Func<T, bool> selector = null) where T : MonoBehaviour
224248
{
225-
IEnumerable<T> found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x);
249+
// check to see if it's enabled in the config
250+
if (ScanOptions[kind].Value == false)
251+
{
252+
return;
253+
}
254+
255+
selector ??= (x) => true;
256+
257+
IEnumerable<T> found = GameObject.FindObjectsOfType(typeof(T)).Select(x => (T)x).Where(selector);
226258

227259
RegisterMonobehaviours(found, kind, ActiveChecker, dynamicObject);
228260
}

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Adds a contemporary Minimap to the game.
66
- Implements a Mini Map In-Game.
77
- Show interactable items, shrines, teleporters, enemies and more.
88
- Single and Multiplayer Compatible.
9-
- Plays Nice with 95% of Most Downloaded Mods.
9+
- Every icon is configurable for color, size and can be toggled on/off.
1010

1111
### Showcase
1212

@@ -26,7 +26,12 @@ Adds a contemporary Minimap to the game.
2626
- Toggle 'M' to hide and show minimap to force a refresh and/or a re-draw if something wonky is happening on the minimap.
2727

2828
### Config
29-
No config applicable at this time
29+
BepInEx Config. Each icon is individually configurable.
30+
- Enabled / Disabled
31+
- Active Color
32+
- Inactive Color
33+
- Icon Width
34+
- Icon Height
3035

3136
### Upcoming Changes
3237
None - Final Release
@@ -38,6 +43,11 @@ https://www.autism.org/donate-autism-research-institute/
3843
If you have an issue, discover a bug, or have a recommendation please file an issue on my github page.
3944

4045
### Change Log
46+
Major 3.1
47+
- Added config toggle to enable or disable each individual icon
48+
- Added config option to choose color for each individual icon
49+
- Added config option to choose icon height and width for each individual icon
50+
4151
Minor 3.0.1
4252
- un-spammed console
4353

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "MiniMapMod",
3-
"version_number": "3.0.1",
3+
"version_number": "3.1",
44
"website_url": "https://github.com/DekuDesu",
5-
"description": "Adds a MiniMap to your game v3.0",
5+
"description": "Adds a MiniMap to your game v3.1",
66
"dependencies": [
77
"bbepis-BepInExPack-5.4.9",
88
"RiskofThunder-HookGenPatcher-1.2.1"

post_build.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
param([string]$version="NO_VERSION")
2+
3+
$destination = ".\Releases\$version"
4+
$pluginDestination = "C:\Users\user\AppData\Roaming\r2modmanPlus-local\RiskOfRain2\profiles\Modding\BepInEx\plugins\$version"
5+
6+
if(Test-Path $destination)
7+
{
8+
Remove-Item $destination -Recurse
9+
}
10+
if(Test-Path $pluginDestination)
11+
{
12+
Remove-Item $pluginDestination -Recurse
13+
}
14+
15+
New-Item -Path $destination -ItemType Directory
16+
17+
Copy-Item -Path ".\MiniMapMod\obj\Release\netstandard2.1\MiniMapMod.dll" -Destination $destination
18+
Copy-Item -Path ".\MiniMapLibrary\obj\Release\netstandard2.1\MiniMapLibrary.dll" -Destination $destination
19+
Copy-Item -Path ".\README.md" -Destination $destination
20+
Copy-Item -Path ".\icon.png" -Destination $destination
21+
Copy-Item -Path ".\manifest.json" -Destination $destination
22+
23+
Copy-Item -Path $destination $pluginDestination -Recurse
24+
25+
Compress-Archive -Path "$destination\*.*" -DestinationPath "$destination\$version.zip"

0 commit comments

Comments
 (0)