-
Notifications
You must be signed in to change notification settings - Fork 23
/
Configs.cs
414 lines (337 loc) · 13.5 KB
/
Configs.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
namespace BossChecklist
{
[BackgroundColor(30, 60, 30, 200)]
public class BossLogConfiguration : ModConfig {
public override ConfigScope Mode => ConfigScope.ClientSide;
public override void OnLoaded() => BossChecklist.BossLogConfig = this;
[Header("BossLogUI")]
[BackgroundColor(250, 235, 215)]
[SliderColor(87, 181, 92)]
[DefaultValue(typeof(Color), "87, 181, 92, 255"), ColorNoAlpha]
public Color BossLogColor { get; set; }
[BackgroundColor(250, 235, 215)]
[SliderColor(87, 181, 92)]
[DefaultValue(typeof(Vector2), "-270, -50")]
[Range(-1920f, 0f)]
public Vector2 BossLogPos { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(true)]
public bool ShowInteractionTooltips { get; set; }
[Expand(false)]
[BackgroundColor(100, 70, 60)]
public DebugTools Debug { get; set; } = new DebugTools();
public class DebugTools {
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool ModCallLogVerbose { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool DisableAutoLocalization { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool AccessInternalNames { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool ShowProgressionValue { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool ShowCollectionType { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool EnabledResetOptions { get; set; }
/*
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool InactiveBossCheck { get; set; }
*/
public override int GetHashCode() {
return new { ModCallLogVerbose, ShowProgressionValue, AccessInternalNames, ShowCollectionType, DisableAutoLocalization }.GetHashCode();
}
}
[Header("BossLogChecklist")]
[BackgroundColor(255, 99, 71)]
[DefaultValue(true)]
public bool AutomaticChecklist { get; set; }
[BackgroundColor(255, 99, 71)]
[DefaultValue(false)]
public bool ProgressiveChecklist { get; set; }
[BackgroundColor(255, 99, 71)]
[DefaultValue(false)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.ProgressionPrompt.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.ProgressionPrompt.Tooltip")]
public bool PromptDisabled { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(true)]
public bool HideUnavailable { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool HideUnsupported { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.OnlyBosses.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.OnlyBosses.Tooltip")]
public bool OnlyShowBossContent { get; set; }
internal const string Option_Show = "Show";
internal const string Option_Hide = "Hide";
internal const string Option_HideWhenCompleted = "Hide When Completed";
[SliderColor(87, 181, 92)]
[BackgroundColor(200, 188, 172)]
[DrawTicks]
[OptionStrings(new string[] { Option_Show, Option_HideWhenCompleted })]
[DefaultValue(Option_Show)]
public string FilterBosses { get; set; }
[SliderColor(87, 181, 92)]
[BackgroundColor(200, 188, 172)]
[DrawTicks]
[OptionStrings(new string[] { Option_Show, Option_HideWhenCompleted, Option_Hide })]
[DefaultValue(Option_Show)]
public string FilterMiniBosses { get; set; }
[SliderColor(87, 181, 92)]
[BackgroundColor(200, 188, 172)]
[DrawTicks]
[OptionStrings(new string[] { Option_Show, Option_HideWhenCompleted, Option_Hide })]
[DefaultValue(Option_Show)]
public string FilterEvents { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(true)]
public bool ColoredBossText { get; set; }
[SliderColor(87, 181, 92)]
[BackgroundColor(250, 235, 215)]
[DrawTicks]
[OptionStrings(new string[] { CheckType_CheckAndEmpty, CheckType_CheckAndX, CheckType_XAndEmpty, CheckType_StrikeThrough })]
[DefaultValue(CheckType_CheckAndEmpty)]
public string SelectedCheckmarkType { get; set; }
public const string CheckType_CheckAndEmpty = "✓ ☐";
public const string CheckType_CheckAndX = "✓ X";
public const string CheckType_XAndEmpty = "X ☐";
public const string CheckType_StrikeThrough = "Strike-through";
[BackgroundColor(200, 188, 172)]
[DefaultValue(true)]
public bool DrawNextMark { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(true)]
public bool ShowProgressBars { get; set; }
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.LootChecklist.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.LootChecklist.Tooltip")]
public bool LootCheckVisibility { get; set; }
[BackgroundColor(200, 188, 172)]
[DefaultValue(false)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.CheckDroppedLoot.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.CheckDroppedLoot.Tooltip")]
public bool OnlyCheckDroppedLoot { get; set; }
/*
[Header("BlindMode")]
[BackgroundColor(255, 99, 71)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.EnableProgressionMode.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.EnableProgressionMode.Tooltip")]
public bool ProgressionModeEnable {
get => MaskTextures && MaskNames && MaskBossLoot && MaskHardMode;
set {
if (value) {
MaskTextures = true;
MaskNames = true;
MaskBossLoot = true;
MaskHardMode = true;
}
}
}
[BackgroundColor(255, 99, 71)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.DisableProgressionMode.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.DisableProgressionMode.Tooltip")]
public bool ProgressionModeDisable {
get => !MaskTextures && !MaskNames && !MaskBossLoot && !MaskHardMode;
set {
if (value) {
MaskTextures = false;
MaskNames = false;
UnmaskNextBoss = false; // UnmaskNextBoss is unnecessary if MaskNames is disabled, so disable it too.
MaskBossLoot = false;
MaskHardMode = false;
}
}
}
[BackgroundColor(178, 34, 34)]
[DefaultValue(false)]
public bool MaskTextures { get; set; }
[BackgroundColor(178, 34, 34)]
[DefaultValue(false)]
public bool MaskNames { get; set; }
[BackgroundColor(178, 34, 34)]
[DefaultValue(false)]
[LabelKey("$Mods.BossChecklist.Configs.BossLogConfiguration.UnmaskNextCheck.Label")]
[TooltipKey("$Mods.BossChecklist.Configs.BossLogConfiguration.UnmaskNextCheck.Tooltip")]
public bool UnmaskNextBoss { get; set; }
[BackgroundColor(178, 34, 34)]
[DefaultValue(false)]
public bool MaskBossLoot { get; set; }
[BackgroundColor(178, 34, 34)]
[DefaultValue(false)]
public bool MaskHardMode { get; set; }
*/
public void UpdateIndicators() {
BossLogUI Log = BossUISystem.Instance.BossLog;
string LangIndicator = "Mods.BossChecklist.Log.Indicator";
string LangCommon = "Mods.BossChecklist.Log.Common";
Log.Indicators[0].Color = OnlyShowBossContent ? Color.White : Color.DarkGray;
Log.Indicators[0].hoverText = OnlyShowBossContent ? $"{LangIndicator}.OnlyBossContentEnabled" : $"{LangIndicator}.OnlyBossContentDisabled";
Log.Indicators[1].Color = AutomaticChecklist ? Color.LightGreen : Color.DarkGray;
Log.Indicators[1].hoverText = AutomaticChecklist ? $"{LangIndicator}.AutomaticChecklist" : $"{LangIndicator}.ManualChecklist";
Log.Indicators[2].Color = ProgressiveChecklist ? Color.Tomato : Color.DarkGray;
Log.Indicators[2].hoverText = Language.GetTextValue($"{LangIndicator}.ProgressionMode", Language.GetTextValue($"{LangCommon}." + (ProgressiveChecklist ? "Enabled" : "Disabled"))); // PartiallyEnabled no longer available
BossChecklist.instance.Logger.Info(Log.Indicators[2].hoverText);
Log.BossTab.Anchor = BossLogUI.FindNextEntry(EntryType.Boss); // update the Next entry/boss tab based on Indicator selections
if (Log.PageNum == BossLogUI.Page_TableOfContents)
Log.RefreshPageContent();
}
public override void OnChanged() {
if (BossChecklist.instance == null)
return;
if (Debug.EnabledResetOptions)
ShowInteractionTooltips = true; // The Reset Options require the Interaction Toolip tab to function
UpdateIndicators();
}
}
public class FeatureConfiguration : ModConfig {
public override ConfigScope Mode => ConfigScope.ClientSide;
public override void OnLoaded() => BossChecklist.FeatureConfig = this;
private bool TrackingEnabled;
private bool NewRecordsEnabled;
private string interferingNPC = "";
private string badConfig = "";
[Header("BossRecords")]
[DefaultValue(true)]
public bool RecordTrackingEnabled {
get => TrackingEnabled;
set {
if (!Main.gameMenu) {
foreach (NPC npc in Main.ActiveNPCs) {
if (BossChecklist.bossTracker.FindBossEntryByNPC(npc.type, out int _) is EntryInfo entry) {
interferingNPC = entry.DisplayName;
badConfig = Language.GetTextValue("Mods.BossChecklist.Configs.FeatureConfiguration.RecordTrackingEnabled.Label");
return; // If a boss is active, debug features are disabled until all bosses are inactive
}
}
}
TrackingEnabled = value;
if (value is false)
NewRecordsEnabled = false;
}
}
[DefaultValue(true)]
public bool AllowNewRecords {
get => RecordTrackingEnabled && NewRecordsEnabled;
set {
if (!Main.gameMenu) {
foreach (NPC npc in Main.ActiveNPCs) {
if (BossChecklist.bossTracker.FindBossEntryByNPC(npc.type, out int _) is EntryInfo entry) {
interferingNPC = entry.DisplayName;
badConfig = Language.GetTextValue("Mods.BossChecklist.Configs.FeatureConfiguration.AllowNewRecords.Label");
return; // If a boss is active, debug features are disabled until all bosses are inactive
}
}
}
if (TrackingEnabled)
NewRecordsEnabled = value;
}
}
[DefaultValue(true)]
public bool NewRecordLogGlow { get; set; }
[DrawTicks]
[OptionStrings(new string[] { "Standard", "Simple" })]
[DefaultValue("Standard")]
public string TimeValueFormat { get; set; }
public NPCDefinition DisplayRecordTracking { get; set; } = new NPCDefinition();
[Header("ChatMessages")]
[DrawTicks]
[OptionStrings(new string[] { "Disabled", "Generic", "Unique" })]
[DefaultValue("Generic")]
public string DespawnMessageType { get; set; }
[DrawTicks]
[OptionStrings(new string[] { "Disabled", "Generic", "Unique" })]
[DefaultValue("Generic")]
public string LimbMessages { get; set; }
[DrawTicks]
[OptionStrings(new string[] { "Disabled", "Generic", "Unique" })]
[DefaultValue("Generic")]
public string MoonMessages { get; set; }
[DefaultValue(true)]
public bool TimerSounds { get; set; }
[Header("ItemMapDetection")]
[DefaultValue(true)]
public bool TreasureBagsOnMap { get; set; }
[DefaultValue(true)]
public bool FragmentsOnMap { get; set; }
[DefaultValue(false)]
public bool ScalesOnMap { get; set; }
internal bool ItemMapDrawingEnabled => TreasureBagsOnMap || FragmentsOnMap || ScalesOnMap;
[Header("BossRadar")]
[DefaultValue(true)]
public bool EnableBossRadar { get; set; }
[DefaultValue(false)]
public bool RadarMiniBosses { get; set; }
public const float OpacityFloatMin = 0.35f;
public const float OpacityFloatMax = 0.85f;
[Range(OpacityFloatMin, OpacityFloatMax)]
[DefaultValue(0.75f)]
public float RadarOpacity { get; set; }
public List<NPCDefinition> RadarBlacklist { get; set; } = new List<NPCDefinition>();
[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context) {
//Range attribute doesn't enforce it onto the value, it's a limit for the UI only, so we have to clamp it here again if user decides to edit it through the json
//If this isn't in here, OpacityFloat can get negative for example, which will lead to a crash later
RadarOpacity = Utils.Clamp(RadarOpacity, OpacityFloatMin, OpacityFloatMax);
}
public override void OnChanged() {
BossRadarUI.blacklistChanged = true;
if (!Main.gameMenu) {
if (string.IsNullOrEmpty(interferingNPC)) {
if (Main.netMode == NetmodeID.MultiplayerClient) {
ModPacket packet = BossChecklist.instance.GetPacket();
packet.Write((byte)PacketMessageType.UpdateAllowTracking);
packet.Write(RecordTrackingEnabled);
packet.Write(AllowNewRecords);
packet.Send();
}
}
else {
Main.NewText(Language.GetText("Mods.BossChecklist.Configs.Common.InvalidChange").Format(badConfig, interferingNPC), Color.Orange);
interferingNPC = "";
badConfig = "";
}
}
}
}
/*
// Code created by Jopojelly, taken from CheatSheet
private bool IsPlayerLocalServerOwner(Player player) {
if (Main.netMode == NetmodeID.MultiplayerClient) {
return Netplay.Connection.Socket.GetRemoteAddress().IsLocalHost();
}
for (int plr = 0; plr < Main.maxPlayers; plr++) {
RemoteClient NetPlayer = Netplay.Clients[plr];
if (NetPlayer.State == 10 && Main.player[plr] == player && NetPlayer.Socket.GetRemoteAddress().IsLocalHost()) {
return true;
}
}
return false;
}
public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref NetworkText message) {
if (!IsPlayerLocalServerOwner(Main.player[whoAmI])) {
message = NetworkText.FromKey("Mods.BossChecklist.Configs.Notice.HostChange");
return false;
}
return true;
}
*/
}