Skip to content

Commit 677270f

Browse files
authored
Merge pull request #39 from DekuDesu/development
fixed compatibility issues with other mods, addec comprehensive debug…
2 parents cdee97b + ef21d0d commit 677270f

7 files changed

Lines changed: 175 additions & 61 deletions

File tree

MiniMapLibrary/Settings.cs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
namespace MiniMapLibrary
1111
{
12+
public enum LogLevel {
13+
none,
14+
info,
15+
debug,
16+
all
17+
}
18+
1219
public static class Settings
1320
{
1421
public static Dimension2D MinimapSize { get; set; } = new Dimension2D(100, 100);
@@ -27,14 +34,18 @@ public static class Settings
2734

2835
public const string DefaultResourcePath = "Textures/MiscIcons/texMysteryIcon";
2936

37+
public static LogLevel LogLevel => _logLevel.Value;
38+
39+
private static IConfigEntry<LogLevel> _logLevel;
40+
3041
static Settings()
3142
{
3243
InitializeDefaultSettings();
3344
}
3445

3546
private static void InitializeDefaultSettings()
3647
{
37-
static void AddSize(InteractableKind type,
48+
static void Add(InteractableKind type,
3849
float width = -1,
3950
float height = -1,
4051
Color ActiveColor = default,
@@ -65,52 +76,52 @@ static void AddSize(InteractableKind type,
6576
InteractibleSettings.Add(type, setting);
6677
}
6778

68-
AddSize(InteractableKind.Chest, 10, 8,
79+
Add(InteractableKind.Chest, 10, 8,
6980
description: "Chests, including shops",
7081
path: "Textures/MiscIcons/texInventoryIconOutlined");
7182

72-
AddSize(InteractableKind.Shrine,
83+
Add(InteractableKind.Shrine,
7384
description: "All shrines (excluding Newt)",
7485
path: "Textures/MiscIcons/texShrineIconOutlined");
7586

76-
AddSize(InteractableKind.Teleporter, 15, 15,
87+
Add(InteractableKind.Teleporter, 15, 15,
7788
ActiveColor: Color.white,
7889
InactiveColor: Color.green,
7990
description: "Boss teleporters",
8091
path: "Textures/MiscIcons/texTeleporterIconOutlined");
8192

82-
AddSize(InteractableKind.Player, 8, 8,
93+
Add(InteractableKind.Player, 8, 8,
8394
ActiveColor: PlayerIconColor,
8495
InactiveColor: PlayerIconColor,
8596
description: "",
8697
path: "Textures/MiscIcons/texBarrelIcon");
8798

88-
AddSize(InteractableKind.Barrel, 5, 5,
99+
Add(InteractableKind.Barrel, 5, 5,
89100
description: "Barrels",
90101
path: "Textures/MiscIcons/texBarrelIcon");
91102

92-
AddSize(InteractableKind.Drone, 7, 7,
103+
Add(InteractableKind.Drone, 7, 7,
93104
description: "Drones",
94105
path: "Textures/MiscIcons/texDroneIconOutlined");
95106

96-
AddSize(InteractableKind.Special, 7, 7,
107+
Add(InteractableKind.Special, 7, 7,
97108
description: "Special interactibles such as the landing pod and fans",
98109
path: DefaultResourcePath);
99110

100-
AddSize(InteractableKind.Enemy, 3, 3,
111+
Add(InteractableKind.Enemy, 3, 3,
101112
ActiveColor: Color.red,
102113
description: "Enemies",
103114
path: "Textures/MiscIcons/texBarrelIcon");
104115

105-
AddSize(InteractableKind.Utility,
116+
Add(InteractableKind.Utility,
106117
description: "Scrappers",
107118
path: "Textures/MiscIcons/texLootIconOutlined");
108119

109-
AddSize(InteractableKind.Printer, 10, 8,
120+
Add(InteractableKind.Printer, 10, 8,
110121
description: "Printers",
111122
path: "Textures/MiscIcons/texInventoryIconOutlined");
112123

113-
AddSize(InteractableKind.LunarPod, 7, 7,
124+
Add(InteractableKind.LunarPod, 7, 7,
114125
description: "Lunar pods (chests)",
115126
path: "Textures/MiscIcons/texLootIconOutlined");
116127
}
@@ -126,7 +137,9 @@ public static InteractibleSetting GetSetting(InteractableKind type)
126137
{
127138
Dimensions = DefaultUIElementSize,
128139
ActiveColor = DefaultActiveColor,
129-
InactiveColor = DefaultInactiveColor
140+
InactiveColor = DefaultInactiveColor,
141+
Description = "NO_DESCRIPTION",
142+
IconPath = DefaultResourcePath
130143
};
131144
}
132145

@@ -152,6 +165,11 @@ public static Dimension2D GetInteractableSize(InteractableKind type)
152165
return DefaultUIElementSize;
153166
}
154167

168+
public static void LoadApplicationSettings(IConfig config)
169+
{
170+
_logLevel = config.Bind<LogLevel>($"Settings.General", "LogLevel", LogLevel.info, "The amount of information that the minimap mod should output to the console during runtime");
171+
}
172+
155173
public static void LoadConfigEntries(InteractableKind type, IConfig config)
156174
{
157175
InteractibleSetting setting = InteractibleSettings[type];
@@ -171,18 +189,5 @@ public static void LoadConfigEntries(InteractableKind type, IConfig config)
171189
setting.Dimensions.Width = width.Value;
172190
setting.IconPath = path.Value;
173191
}
174-
175-
public static void UpdateSetting(InteractableKind type, float width, float height, Color active, Color inactive)
176-
{
177-
if (InteractibleSettings.ContainsKey(type))
178-
{
179-
var setting = InteractibleSettings[type];
180-
181-
setting.ActiveColor = active;
182-
setting.InactiveColor = inactive;
183-
setting.Dimensions.Height = height;
184-
setting.Dimensions.Width = width;
185-
}
186-
}
187192
}
188193
}

MiniMapLibrary/SpriteManager.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ public void Dispose()
2929
if (path != null)
3030
{
3131
return GetOrCache(path);
32-
33-
throw new Exception($"MissingTextureException: Interactible.{type} does not have a registered texture path to load.");
3432
}
3533

36-
throw new Exception($"MissingTextureException: Interactible.{type} does not have a registered texture path to load.");
34+
throw new MissingComponentException($"MissingTextureException: Interactible.{type} does not have a registered texture path to load.");
3735
}
3836

3937
private Sprite? GetOrCache(string Path)
@@ -49,6 +47,10 @@ public void Dispose()
4947
{
5048
SpriteCache.Add(Path, loaded);
5149
}
50+
else
51+
{
52+
throw new MissingComponentException($"MissingTextureException: {Path} does not exist within the streaming assets");
53+
}
5254

5355
return loaded;
5456
}

MiniMapMod/Log.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BepInEx.Logging;
2+
using MiniMapLibrary;
23

34
namespace MiniMapMod
45
{
@@ -11,10 +12,10 @@ internal static void Init(ManualLogSource logSource)
1112
_logSource = logSource;
1213
}
1314

14-
internal static void LogDebug(object data) => _logSource.LogDebug(data);
15+
internal static void LogDebug(object data){ if(Settings.LogLevel > MiniMapLibrary.LogLevel.info) _logSource.LogDebug(data); }
1516
internal static void LogError(object data) => _logSource.LogError(data);
1617
internal static void LogFatal(object data) => _logSource.LogFatal(data);
17-
internal static void LogInfo(object data) => _logSource.LogInfo(data);
18+
internal static void LogInfo(object data) { if (Settings.LogLevel > MiniMapLibrary.LogLevel.none) _logSource.LogDebug(data); }
1819
internal static void LogMessage(object data) => _logSource.LogMessage(data);
1920
internal static void LogWarning(object data) => _logSource.LogWarning(data);
2021
}

0 commit comments

Comments
 (0)