-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPluginConfig.cs
44 lines (35 loc) · 1.63 KB
/
PluginConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections.Generic;
using Dalamud.Configuration;
namespace Honorific;
public class PluginConfig : IPluginConfiguration {
public int Version { get; set; } = 1;
public Dictionary<uint, Dictionary<string, CharacterConfig>> WorldCharacterDictionary = new();
public bool ShowColoredTitles = true;
public bool DebugOpenOnStatup = true;
public bool HideKofi = false;
public bool ApplyToInspect = true;
public bool DisplayPreviewInConfigWindow = true;
public bool HideVanillaSelf;
public bool HideVanillaParty;
public bool HideVanillaAlliance;
public bool HideVanillaFriends;
public bool HideVanillaOther;
public bool TryGetCharacterConfig(string name, uint world, out CharacterConfig? characterConfig) {
characterConfig = null;
if (!WorldCharacterDictionary.TryGetValue(world, out var w)) return false;
return w.TryGetValue(name, out characterConfig);
}
public bool TryAddCharacter(string name, uint homeWorld) {
if (!WorldCharacterDictionary.ContainsKey(homeWorld)) WorldCharacterDictionary.Add(homeWorld, new Dictionary<string, CharacterConfig>());
if (WorldCharacterDictionary.TryGetValue(homeWorld, out var world)) {
return world.TryAdd(name, new CharacterConfig());
}
return false;
}
public bool TryGetOrAddCharacter(string name, uint world, out CharacterConfig? characterConfig) {
if (TryGetCharacterConfig(name, world, out characterConfig)) {
return true;
}
return TryAddCharacter(name, world) && TryGetCharacterConfig(name, world, out characterConfig);
}
}