diff --git a/ItemChecklist.cs b/ItemChecklist.cs index 4367156..57f786e 100644 --- a/ItemChecklist.cs +++ b/ItemChecklist.cs @@ -5,6 +5,7 @@ using Terraria.UI; using Terraria.DataStructures; using ItemChecklist.UI; using Microsoft.Xna.Framework; +using System; namespace ItemChecklist { @@ -14,6 +15,7 @@ namespace ItemChecklist internal static ModHotKey ToggleChecklistHotKey; internal static UserInterface ItemChecklistInterface; internal ItemChecklistUI ItemChecklistUI; + internal event Action OnNewItem; public ItemChecklist() { @@ -40,6 +42,42 @@ namespace ItemChecklist } } + public override object Call(params object[] args) + { + try + { + string message = args[0] as string; + if (message == "RequestFoundItems") + { + if (Main.gameMenu) + { + return "NotInGame"; + } + return Main.LocalPlayer.GetModPlayer(this).foundItem; + } + else if (message == "RegisterForNewItem") + { + Action callback = args[1] as Action; + OnNewItem += callback; + return "RegisterSuccess"; + } + else + { + ErrorLogger.Log("ItemChecklist Call Error: Unknown Message: " + message); + } + } + catch (Exception e) + { + ErrorLogger.Log("ItemChecklist Call Error: " + e.StackTrace + e.Message); + } + return "Failure"; + } + + internal void NewItem(int type) + { + OnNewItem?.Invoke(type); + } + int lastSeenScreenWidth; int lastSeenScreenHeight; public override void ModifyInterfaceLayers(List layers) diff --git a/ItemChecklistGlobalItem.cs b/ItemChecklistGlobalItem.cs index a33b49d..34ee2d6 100644 --- a/ItemChecklistGlobalItem.cs +++ b/ItemChecklistGlobalItem.cs @@ -33,8 +33,9 @@ namespace ItemChecklist ItemChecklist.instance.ItemChecklistUI.UpdateNeeded(item.type); if (ItemChecklistUI.announce) { - Main.NewText($"You obtained your first {item.name}. {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind} {(100f*itemChecklistPlayer.totalItemsFound/itemChecklistPlayer.totalItemsToFind).ToString("0.00")}%"); + Main.NewText($"You found your first {item.name}. {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind} {(100f*itemChecklistPlayer.totalItemsFound/itemChecklistPlayer.totalItemsToFind).ToString("0.00")}%"); } + ItemChecklist.instance.NewItem(item.type); } } } diff --git a/ItemChecklistUI.cs b/ItemChecklistUI.cs index 875b233..9a6ed3b 100644 --- a/ItemChecklistUI.cs +++ b/ItemChecklistUI.cs @@ -40,7 +40,7 @@ namespace ItemChecklist.UI { // Is initialize called? (Yes it is called on reload) I want to reset nicely with new character or new loaded mods: visible = false; - announce = true; // overwritten by modplayer + announce = false; // overwritten by modplayer checklistPanel = new UIPanel(); checklistPanel.SetPadding(10); diff --git a/build.txt b/build.txt index 55a0aee..b65c76b 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly -version = 0.2.0.2 +version = 0.2.1 displayName = Item Checklist homepage = https://forums.terraria.org/index.php?threads/item-checklist-in-game-100-item-collection-checklist.52786/ hideCode = false