diff --git a/ItemChecklist.cs b/ItemChecklist.cs index 85f2445..0fcbec0 100644 --- a/ItemChecklist.cs +++ b/ItemChecklist.cs @@ -26,7 +26,7 @@ namespace ItemChecklist { // Latest uses ItemID.Sets.IsAMaterial, added 0.10.1.5 instance = this; - ToggleChecklistHotKey = KeybindLoader.RegisterKeybind(this, "Toggle Item Checklist", "I"); + ToggleChecklistHotKey = KeybindLoader.RegisterKeybind(this, "ToggleItemChecklist", "I"); MagicStorageIntegration.Load(); if (!Main.dedServ) diff --git a/ItemChecklistClientConfig.cs b/ItemChecklistClientConfig.cs index d16f163..1cde92a 100644 --- a/ItemChecklistClientConfig.cs +++ b/ItemChecklistClientConfig.cs @@ -11,23 +11,17 @@ namespace ItemChecklist public override ConfigScope Mode => ConfigScope.ClientSide; [DefaultValue(true)] - [Label("Show Item Mod Source")] - [Tooltip("Show which mod adds which item in the recipe catalog. Disable for immersion.")] public bool ShowItemModSource { get; set; } - [Header("Automatic Settings")] + [Header("AutomaticSettings")] // non-player specific stuff: [DefaultValue(typeof(Vector2), "475, 370")] [Range(0f, 1920f)] - [Label("Item Checklist Size")] - [Tooltip("Size of the Item Checklist UI. This will automatically save, no need to adjust")] public Vector2 ItemChecklistSize { get; set; } [DefaultValue(typeof(Vector2), "400, 400")] [Range(0f, 1920f)] - [Label("Item Checklist Poisition")] - [Tooltip("Position of the Item Checklist UI. This will automatically save, no need to adjust")] public Vector2 ItemChecklistPosition { get; set; } internal static void SaveConfig() { diff --git a/ItemChecklistGlobalItem.cs b/ItemChecklistGlobalItem.cs index 462e9b4..4004a9a 100644 --- a/ItemChecklistGlobalItem.cs +++ b/ItemChecklistGlobalItem.cs @@ -1,11 +1,21 @@ using Terraria; using Terraria.DataStructures; +using Terraria.Localization; using Terraria.ModLoader; namespace ItemChecklist { class ItemChecklistGlobalItem : GlobalItem { + + const string LOCALIZATION_KEY = "Mods.ItemChecklist.GlobalItem."; + private static LocalizedText ItemChecklistAnnounceText; + + public override void SetStaticDefaults() + { + ItemChecklistAnnounceText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ItemChecklistAnnounceText) ); + } + // OnPIckup only called on LocalPlayer: I think public override void OnCreated(Item item, ItemCreationContext context) { @@ -35,7 +45,10 @@ namespace ItemChecklist ItemChecklist.instance.ItemChecklistUI.UpdateNeeded(item.type); if (ItemChecklistUI.announce) { - Main.NewText($"You found your first {item.Name}. {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind} {(100f*itemChecklistPlayer.totalItemsFound/itemChecklistPlayer.totalItemsToFind).ToString("0.00")}%"); + Main.NewText( ItemChecklistAnnounceText.Format( 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 68849cf..c2e8ce9 100644 --- a/ItemChecklistUI.cs +++ b/ItemChecklistUI.cs @@ -20,6 +20,9 @@ using Steamworks; using System.Runtime.CompilerServices; using System.ComponentModel; +using Terraria.Localization; + + namespace ItemChecklist { class ItemChecklistUI : UIState @@ -59,11 +62,42 @@ namespace ItemChecklist internal List modnames; internal int currentMod = 0; - public string[] foundFilterStrings = { "All", "Unfound", "Found" }; + public string[] foundFilterStrings; + + const string LOCALIZATION_KEY = "Mods.ItemChecklist.Ui."; + public static LocalizedText ToggleCollectChestItemsText; + public static LocalizedText ToggleMessagesText; + public static LocalizedText ShowSortValueTextText; + public static LocalizedText FilterByNameText; + public static LocalizedText FilterByTooltipText; + public static LocalizedText CycleModFilterText; + public static LocalizedText CycleFoundFilterText; + public static LocalizedText ModnamesAllText; + public static LocalizedText FoundFilterAllText; + public static LocalizedText FoundFilterUnfoundText; + public static LocalizedText FoundFilterFoundText; + public static LocalizedText ModnamesVanillaText; public ItemChecklistUI() { instance = this; + + + FilterByTooltipText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FilterByTooltipText) ); + FilterByNameText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FilterByNameText) ); + ToggleCollectChestItemsText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ToggleCollectChestItemsText) ); + ToggleMessagesText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ToggleMessagesText) ); + ShowSortValueTextText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ShowSortValueTextText) ); + CycleModFilterText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(CycleModFilterText) ); + CycleFoundFilterText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(CycleFoundFilterText) ); + ModnamesAllText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ModnamesAllText) ); + FoundFilterAllText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterAllText) ); + FoundFilterUnfoundText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterUnfoundText) ); + FoundFilterFoundText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterFoundText) ); + ModnamesVanillaText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ModnamesVanillaText) ); + + + foundFilterStrings = new [] { FoundFilterAllText.Value , FoundFilterUnfoundText.Value , FoundFilterFoundText.Value }; } public override void OnInitialize() @@ -108,7 +142,7 @@ namespace ItemChecklist // Because OnInitialize Happens during load and because we need it to happen for OnEnterWorld, use dummy sprite. buttonsHaveDummyTextures = true; - foundFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, "Cycle Found Filter: ??"); + foundFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, CycleFoundFilterText.Format("??")); foundFilterButton.OnLeftClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true); foundFilterButton.OnRightClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, false); foundFilterButton.Top.Pixels = top; @@ -122,7 +156,7 @@ namespace ItemChecklist //sortButton.Top.Pixels = top; //checklistPanel.Append(sortButton); - modFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, "Cycle Mod Filter: ??"); + modFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, CycleModFilterText.Format( "??" )); modFilterButton.OnLeftClick += (a, b) => ToggleModFilterButtonClicked(a, b, true); modFilterButton.OnRightClick += (a, b) => ToggleModFilterButtonClicked(a, b, false); modFilterButton.Left.Pixels = left; @@ -130,21 +164,21 @@ namespace ItemChecklist checklistPanel.Append(modFilterButton); left += (int)spacing * 2 + 28; - muteButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Toggle Messages", announce); + muteButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ToggleMessagesText.Value, announce); muteButton.OnLeftClick += ToggleMuteButtonClicked; muteButton.Left.Pixels = left; muteButton.Top.Pixels = top; checklistPanel.Append(muteButton); left += (int)spacing * 2 + 28; - collectChestItemsButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Toggle Collect Chest Items", collectChestItems); + collectChestItemsButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ToggleCollectChestItemsText.Value, collectChestItems); collectChestItemsButton.OnLeftClick += ToggleFindChestItemsButtonClicked; collectChestItemsButton.Left.Pixels = left; collectChestItemsButton.Top.Pixels = top; checklistPanel.Append(collectChestItemsButton); left += (int)spacing * 2 + 28; - showBadgeButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Show Sort Value Text", showBadge); + showBadgeButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ShowSortValueTextText.Value, showBadge); showBadgeButton.OnLeftClick += ToggleShowBadgeButtonClicked; showBadgeButton.Left.Pixels = left; showBadgeButton.Top.Pixels = top; @@ -153,7 +187,7 @@ namespace ItemChecklist top += 34; - itemNameFilter = new NewUITextBox("Filter by Name"); + itemNameFilter = new NewUITextBox(FilterByNameText.Value); itemNameFilter.OnTextChanged += () => { ValidateItemFilter(); updateNeeded = true; }; itemNameFilter.OnTabPressed += () => { itemDescriptionFilter.Focus(); }; itemNameFilter.Top.Pixels = top; @@ -164,7 +198,7 @@ namespace ItemChecklist top += 30; - itemDescriptionFilter = new NewUITextBox("Filter by tooltip"); + itemDescriptionFilter = new NewUITextBox(FilterByTooltipText.Value); itemDescriptionFilter.OnTextChanged += () => { ValidateItemDescription(); updateNeeded = true; }; itemDescriptionFilter.OnTabPressed += () => { itemNameFilter.Focus(); }; itemDescriptionFilter.Top.Pixels = top; @@ -260,7 +294,7 @@ namespace ItemChecklist } - modnames = new List() { "All", "Vanilla" }; + modnames = new List() { ModnamesAllText.Value, ModnamesVanillaText.Value }; modnames.AddRange(ModLoader.Mods.Where(mod => mod.GetContent().Any()).Select(x => x.Name)/*.Where(x => x != "ModLoader")*/); updateNeeded = true; @@ -279,7 +313,7 @@ namespace ItemChecklist { SoundEngine.PlaySound(SoundID.MenuTick); showCompleted = (3 + showCompleted + (left ? 1 : -1)) % 3; - foundFilterButton.hoverText = "Cycle Found Filter: " + foundFilterStrings[showCompleted]; + foundFilterButton.hoverText = CycleFoundFilterText.Format( foundFilterStrings[showCompleted]); UpdateNeeded(); } @@ -302,7 +336,7 @@ namespace ItemChecklist { SoundEngine.PlaySound(SoundID.MenuTick); currentMod = (modnames.Count + currentMod + (left ? 1 : -1)) % modnames.Count; - modFilterButton.hoverText = "Cycle Mod Filter: " + modnames[currentMod]; + modFilterButton.hoverText = CycleModFilterText.Format( modnames[currentMod]); UpdateNeeded(); } @@ -322,9 +356,9 @@ namespace ItemChecklist internal void RefreshPreferences() { - foundFilterButton.hoverText = "Cycle Found Filter: " + foundFilterStrings[showCompleted]; + foundFilterButton.hoverText = CycleFoundFilterText.Format( foundFilterStrings[showCompleted]); //sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString(); - modFilterButton.hoverText = "Cycle Mod Filter: " + modnames[currentMod]; + modFilterButton.hoverText = CycleModFilterText.Format( modnames[currentMod]); muteButton.SetEnabled(announce); collectChestItemsButton.SetEnabled(collectChestItems); UpdateNeeded(); diff --git a/Localization/en-US.hjson b/Localization/en-US.hjson new file mode 100644 index 0000000..0dae7a3 --- /dev/null +++ b/Localization/en-US.hjson @@ -0,0 +1,43 @@ +Mods: { + ItemChecklist: { + Configs: { + ItemChecklistClientConfig: { + ShowItemModSource: { + Label: Show Item Mod Source + Tooltip: Show which mod adds which item in the recipe catalog. Disable for immersion. + } + + DisplayName: Item Checklist Client Config + Headers.AutomaticSettings: Automatic Settings + + ItemChecklistSize: { + Label: Item Checklist Size + Tooltip: Size of the Item Checklist UI. This will automatically save, no need to adjust + } + + ItemChecklistPosition: { + Label: Item Checklist Position + Tooltip: Position of the Item Checklist UI. This will automatically save, no need to adjust + } + } + } + + Keybinds.ToggleItemChecklist.DisplayName: Toggle Item Checklist + GlobalItem.ItemChecklistAnnounceText: You found your first {0}. {1}/{2} {3}% + + Ui: { + FilterByTooltipText: Filter by tooltip + FilterByNameText: Filter by Name + ToggleCollectChestItemsText: Toggle Collect Chest Items + ToggleMessagesText: Toggle Messages + ShowSortValueTextText: Show Sort Value Text + CycleModFilterText: Cycle Mod Filter: {0} + CycleFoundFilterText: Cycle Found Filter: {0} + ModnamesAllText: All + FoundFilterAllText: All + FoundFilterUnfoundText: Unfound + FoundFilterFoundText: Found + ModnamesVanillaText: Vanilla + } + } +} \ No newline at end of file