Skip to content
48 changes: 48 additions & 0 deletions BossChecklist.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using BossChecklist.Systems;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Terraria;
using Terraria.Chat;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
Expand Down Expand Up @@ -446,6 +448,52 @@ public override void HandlePacket(BinaryReader reader, int whoAmI) {
recordIndex = reader.ReadInt32();
Main.LocalPlayer.GetModPlayer<RecordModPlayer>().RecordsForWorld?[recordIndex].StartTracking();
break;
case PacketMessageType.RequestBossStateToggle:
if (Main.netMode == NetmodeID.Server) {
string bossKey1 = reader.ReadString();
bool downed1 = reader.ReadBoolean();
EntryInfo entry = BossChecklist.bossTracker.FindEntryFromKey(bossKey1);

if (!Networking.TryApplyBossStateToggle(bossKey1, downed1)) {
ChatHelper.BroadcastChatMessage(
instance.GetLocalization("Configs.DebugTools.Failed").ToNetworkText(entry.name),
Color.Red
);
break;
}

NetMessage.SendData(MessageID.WorldData);

// show text to let other player know which boss's defeat state toggled
ChatHelper.BroadcastChatMessage(
instance.GetLocalization("Configs.DebugTools.Successed")
.ToNetworkText(
entry.name,
downed1
? instance.GetLocalization("Configs.DebugTools.Defeated")
: instance.GetLocalization("Configs.DebugTools.Alive")
),
Color.LightGreen
);

// in case some mod's data can not be sent
ModPacket packet1 = GetPacket();
packet1.Write((byte)PacketMessageType.SyncBossState);
packet1.Write(bossKey1);
packet1.Write(downed1);
packet1.Send(); // Server --> All Clients
}
break;

case PacketMessageType.SyncBossState:
if (Main.netMode == NetmodeID.MultiplayerClient) {
string bossKey2 = reader.ReadString();
bool downed2 = reader.ReadBoolean();

if (Networking.TryApplyBossStateToggle(bossKey2, downed2))
BossLogSystem.Instance?.BossLog?.RefreshPageContent();
}
break;
default:
Logger.Error($"Unknown Message type: {msgType}");
break;
Expand Down
123 changes: 83 additions & 40 deletions BossTracker.cs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class BossLogConfiguration : ModConfig {
[Expand(false)]
[BackgroundColor(100, 70, 60)]
public DebugTools Debug { get; set; } = new DebugTools();
public class DebugTools {
public class DebugTools
{
[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool ModCallLogVerbose { get; set; }
Expand All @@ -56,6 +57,10 @@ public class DebugTools {
[DefaultValue(false)]
public bool ShowCollectionType { get; set; }

[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool EnableBossStateToggle { get; set; }

[BackgroundColor(250, 235, 215)]
[DefaultValue(false)]
public bool EnabledResetOptions { get; set; }
Expand Down
18 changes: 15 additions & 3 deletions EntryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal class EntryInfo {
internal Dictionary<int, LocalizedText> npcLimbs;
internal float progression;
internal Func<bool> downed;
internal Action<bool> setDowned;
internal Func<bool> available;
internal bool hidden;
internal Func<NPC, LocalizedText> customDespawnMessages;
Expand Down Expand Up @@ -330,6 +331,14 @@ internal EntryInfo(EntryType entryType, string modSource, string internalName, o
if (icons.Count > 0)
headIconTextures = () => icons;
}

if (extraData?.ContainsKey("setDowned") == true) {
// toggle whether boss is defeated
object setDowned = extraData["setDowned"];
if (setDowned is Action<bool>) {
this.setDowned = setDowned as Action<bool>;
}
}
}

// Workaround for vanilla events with illogical translation keys.
Expand Down Expand Up @@ -381,7 +390,7 @@ internal EntryInfo WithCustomHeadIcon(List<string> texturePaths) {
return this;
}

internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key, int npcID, Func<bool> downed) {
internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key, int npcID, Func<bool> downed, Action<bool> setDowned) {
string nameKey = key.Substring(key.LastIndexOf(".") + 1);

// BossChecklist only has despawn messages for vanilla Bosses
Expand Down Expand Up @@ -422,11 +431,12 @@ internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key,
{ "spawnItems", BossTracker.EntrySpawnItems.GetValueOrDefault($"Terraria {nameKey}") },
{ "collectibles", BossTracker.EntryCollectibles.GetValueOrDefault($"Terraria {nameKey}") },
{ "despawnMessage", customMessages },
{ "setDowned", setDowned },
}
);
}

internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key, List<int> ids, Func<bool> downed) {
internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key, List<int> ids, Func<bool> downed, Action<bool> setDowned) {
string nameKey = key.Substring(key.LastIndexOf(".") + 1).Replace(" ", "").Replace("'", "");
if (nameKey.EndsWith("Head"))
nameKey = nameKey.Substring(0, nameKey.Length - 4);
Expand Down Expand Up @@ -467,11 +477,12 @@ internal static EntryInfo MakeVanillaBoss(EntryType type, float val, string key,
{ "spawnItems", BossTracker.EntrySpawnItems.GetValueOrDefault($"Terraria {nameKey}") },
{ "collectibles", BossTracker.EntryCollectibles.GetValueOrDefault($"Terraria {nameKey}") },
{ "despawnMessage", customMessages },
{ "setDowned", setDowned },
}
);
}

internal static EntryInfo MakeVanillaEvent(float val, string key, Func<bool> downed) {
internal static EntryInfo MakeVanillaEvent(float val, string key, Func<bool> downed, Action<bool> setDowned) {
string nameKey = key.Substring(key.LastIndexOf(".") + 1).Replace(" ", "").Replace("'", "");
return new EntryInfo(
entryType: EntryType.Event,
Expand All @@ -486,6 +497,7 @@ internal static EntryInfo MakeVanillaEvent(float val, string key, Func<bool> dow
{ "spawnInfo", BossChecklist.instance.GetLocalization($"BossSpawnInfo.{nameKey}") },
{ "spawnItems", BossTracker.EntrySpawnItems.GetValueOrDefault($"Terraria {nameKey}") },
{ "collectibles", BossTracker.EntryCollectibles.GetValueOrDefault($"Terraria {nameKey}") },
{ "setDowned", setDowned },
}
);
}
Expand Down
18 changes: 9 additions & 9 deletions Localization/TranslationsNeeded.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
en-US, 336/336, 100%, missing 0
de-DE, 319/336, 95%, missing 17
it-IT, 3/336, 1%, missing 333
fr-FR, 316/336, 94%, missing 20
es-ES, 79/336, 24%, missing 257
ru-RU, 317/336, 94%, missing 19
zh-Hans, 336/336, 100%, missing 0
pt-BR, 64/336, 19%, missing 272
pl-PL, 3/336, 1%, missing 333
en-US, 342/342, 100%, missing 0
de-DE, 319/342, 93%, missing 23
it-IT, 3/342, 1%, missing 339
fr-FR, 316/342, 92%, missing 26
es-ES, 79/342, 23%, missing 263
ru-RU, 317/342, 93%, missing 25
zh-Hans, 342/342, 100%, missing 0
pt-BR, 64/342, 19%, missing 278
pl-PL, 3/342, 1%, missing 339
14 changes: 14 additions & 0 deletions Localization/de-DE.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,20 @@ Mods: {
Diese Nachrichten sollten erscheinen, wenn ein Boss besiegt wurde oder ein Boss despawnt ist.
'''
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
16 changes: 15 additions & 1 deletion Localization/en-US.hjson
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Mods: {
Mods: {
BossChecklist: {
Log: {
Common: {
Expand Down Expand Up @@ -583,6 +583,20 @@ Mods: {
These messages should appear when a boss has been defeated or a boss has despawned, respectively.
'''
}

EnableBossStateToggle: {
Label: Enable Boss defeated State Toggle
Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
'''
}

Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
Successed: Toggled [{0}] -> [{1}] !
Defeated: Defeated
Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/es-ES.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,20 @@ Mods: {
These messages should appear when a boss has been defeated or a boss has despawned, respectively.
''' */
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/fr-FR.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,20 @@ Mods: {
Ces messages devraient apparaître lorsqu'un boss a été vaincu ou lorsqu'un boss a disparu, respectivement.
'''
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/it-IT.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ Mods: {
These messages should appear when a boss has been defeated or a boss has despawned, respectively.
''' */
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/pl-PL.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ Mods: {
These messages should appear when a boss has been defeated or a boss has despawned, respectively.
''' */
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/pt-BR.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ Mods: {
These messages should appear when a boss has been defeated or a boss has despawned, respectively.
''' */
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
14 changes: 14 additions & 0 deletions Localization/ru-RU.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,20 @@ Mods: {
Эти сообщения должны появляться при победе над боссом или при его исчезновении, соответственно.
'''
}

EnableBossStateToggle: {
// Label: Enable Boss defeated State Toggle
/* Tooltip:
'''
While enabled,Shift + Right Click a boss in the Boss Log UI toggles its real defeated state
rather than merely marking it as defeated.
''' */
}

// Failed: Failed to toggle defeat state of [{0}]! This entry does not currently support this feature!
// Successed: Toggled [{0}] -> [{1}] !
// Defeated: Defeated
// Alive: Alive
}

FeatureConfiguration: {
Expand Down
16 changes: 15 additions & 1 deletion Localization/zh-Hans.hjson
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Mods: {
Mods: {
BossChecklist: {
Log: {
Common: {
Expand Down Expand Up @@ -583,6 +583,20 @@ Mods: {
这些信息应该分别在Boss被击败或Boss消失时出现.
'''
}

EnableBossStateToggle: {
Label: 启用Boss击败状态切换功能
Tooltip:
'''
启用后,如果在Boss日志UI中 Shift + 右键 Boss可以切换其真实击败状态
而非仅仅标记为击败
'''
}

Failed: 切换 [{0}] 击败状态失败!该Boss暂未支持该功能!
Successed: 成功切换:[{0}] -> [{1}]
Defeated: 已击败
Alive: 未击败
}

FeatureConfiguration: {
Expand Down
Loading