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 66cc430..677a393 100644 --- a/ItemChecklistGlobalItem.cs +++ b/ItemChecklistGlobalItem.cs @@ -1,14 +1,25 @@ using Terraria; +using Terraria.DataStructures; +using Terraria.Localization; using Terraria.ModLoader; namespace ItemChecklist { class ItemChecklistGlobalItem : GlobalItem { - // OnPIckup only called on LocalPlayer: I think - public override void OnCreate(Item item, ItemCreationContext context) + + const string LOCALIZATION_KEY = "Mods.ItemChecklist.GlobalItem."; + private static LocalizedText ItemChecklistAnnounceText; + + public override void SetStaticDefaults() { - if (context is RecipeCreationContext rContext) { + ItemChecklistAnnounceText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ItemChecklistAnnounceText) ); + } + + // OnPIckup only called on LocalPlayer: I think + public override void OnCreated(Item item, ItemCreationContext context) + { + if (context is RecipeItemCreationContext rContext) { ItemReceived(item); } } @@ -34,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/ItemChecklistPlayer.cs b/ItemChecklistPlayer.cs index 9835804..55773c6 100644 --- a/ItemChecklistPlayer.cs +++ b/ItemChecklistPlayer.cs @@ -52,7 +52,7 @@ namespace ItemChecklist } } - public override void OnEnterWorld(Player player) + public override void OnEnterWorld() { var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer(); ItemChecklistUI.Visible = false; diff --git a/ItemChecklistUI.cs b/ItemChecklistUI.cs index f3223b8..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,8 +142,8 @@ 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.OnClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true); + 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; checklistPanel.Append(foundFilterButton); @@ -122,30 +156,30 @@ namespace ItemChecklist //sortButton.Top.Pixels = top; //checklistPanel.Append(sortButton); - modFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, "Cycle Mod Filter: ??"); - modFilterButton.OnClick += (a, b) => ToggleModFilterButtonClicked(a, b, true); + 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; modFilterButton.Top.Pixels = top; 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.OnClick += ToggleMuteButtonClicked; + 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.OnClick += ToggleFindChestItemsButtonClicked; + 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.OnClick += ToggleShowBadgeButtonClicked; + 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; checklistPanel.Append(showBadgeButton); @@ -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(); @@ -541,11 +575,11 @@ namespace ItemChecklist UserInterface.ActiveInstance = temp; } - public override void MouseDown(UIMouseEvent evt) + public override void LeftMouseDown(UIMouseEvent evt) { UserInterface temp = UserInterface.ActiveInstance; UserInterface.ActiveInstance = ItemChecklist.ItemChecklistInterface; - base.MouseDown(evt); + base.LeftMouseDown(evt); UserInterface.ActiveInstance = temp; } } diff --git a/Localization/en-US.hjson b/Localization/en-US.hjson new file mode 100644 index 0000000..febf5d2 --- /dev/null +++ b/Localization/en-US.hjson @@ -0,0 +1,127 @@ +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}% + + UICollectionBar: { + collectionTotalText: Total: {0}/{1} ({2}% Collected) + collectionTerrariaText: Terraria: {0}/{1} ({2}% Collected) + collectionModText: "{0}: {1}/{2} ({3}% Collected)" + } + + 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 + } + + SharedUI: { + mutuallyExclusiveFilterVanityText: Vanity + mutuallyExclusiveFilterArmorText: Armor + cycleAmmoTypesText: Cycle Ammo Types + cycleUsedAmmoTypesText: Cycle Used Ammo Types + categoryAllText: All + categoryMeleeText: Melee + categoryYoyoText: Yoyo + categoryMagicText: Magic + categoryRangedText: Ranged + sortUseAmmoTypeText: Use Ammo Type + categoryThrowingText: Throwing + categorySummonText: Summon + categorySentryText: Sentry + sortDamageText: Damage + categoryToolsText: Tools + categoryPickaxesText: Pickaxes + categoryAxesText: Axes + categoryHammersText: Hammers + categoryArmorText: Armor + categoryWeaponsText: Weapons + sortValueText: Value + sortAlphabeticalText: Alphabetical + sortRarityText: Rarity + sortTerrariaSortText: Terraria Sort + filterMaterialsText: Materials + sortPickPower: Pick Power + sortAxePower: Axe Power + sortHammerPower: Hammer Power + categoryHead: Head + categoryBody: Body + categoryLegs: Legs + sortDefense: Defense + categoryTiles: Tiles + categoryContainersText: Containers + categoryWiringText: Wiring + categoryStatuesText: Statues + categoryDoorsText: Doors + categoryChairsText: Chairs + categoryTablesText: Tables + categoryLightSourcesText: Light Sources + categoryTorchesText: Torches + categoryWallsText: Walls + categoryAccessoriesText: Accessories + categoryWingsText: Wings + categoryAmmoText: Ammo + categoryPotionsText: Potions + categoryHealthPotionsText: Health Potions + categoryManaPotionsText: Mana Potions + categoryBuffPotionsText: Buff Potions + categoryExpertText: Expert + categoryPetsText: Pets + categoryLightPetsText: Light Pets + categoryMountsText: Mounts + categoryCartsText: Carts + categoryHooksText: Hooks + categoryDyesText: Dyes + categoryHairDyesText: Hair Dyes + categoryBossSummonsText: Boss Summons + categoryConsumablesText: Consumables + categoryCapturedNPCText: Captured NPC + categoryFishingText: Fishing + categoryPolesText: Poles + categoryBaitText: Bait + categoryQuestFishText: Quest Fish + categoryExtractinatorText: Extractinator + categoryOtherText: Other + sortItemIdText: ItemID + sortPlaceTileText: Place Tile + sortAmmoTypeText: Ammo Type + sortHealLifeText: Heal Life + sortHealManaText: Heal Mana + sortGrappleRangeText: Grapple Range + sortProgressionOrderText: Progression Order + sortPolePowerText: Pole Power + sortBaitPowerText: Bait Power + } + } +} \ No newline at end of file diff --git a/SharedUI.cs b/SharedUI.cs index 404e229..631391c 100644 --- a/SharedUI.cs +++ b/SharedUI.cs @@ -10,8 +10,11 @@ using Terraria.GameContent; using Terraria.GameContent.UI.Elements; using Terraria.GameContent.UI.States; using Terraria.ID; +using Terraria.Localization; + using static ItemChecklist.Utilities; using Terraria.ModLoader; +using Terraria.WorldBuilding; // Copied from my Recipe Browser mod. namespace ItemChecklist @@ -55,8 +58,163 @@ namespace ItemChecklist } } + private const string LocalizationKey = "Mods.ItemChecklist.SharedUI."; + private static LocalizedText cycleAmmoTypesText; + private static LocalizedText cycleUsedAmmoTypesText; + private static LocalizedText mutuallyExclusiveFilterVanityText; + private static LocalizedText mutuallyExclusiveFilterArmorText; + private static LocalizedText categoryAllText; + private static LocalizedText categoryMeleeText; + private static LocalizedText categoryYoyoText; + private static LocalizedText categoryMagicText; + private static LocalizedText categoryRangedText; + private static LocalizedText sortUseAmmoTypeText; + private static LocalizedText categoryThrowingText; + private static LocalizedText categorySummonText; + private static LocalizedText categorySentryText; + private static LocalizedText sortDamageText; + private static LocalizedText categoryToolsText; + private static LocalizedText categoryPickaxesText; + private static LocalizedText categoryAxesText; + private static LocalizedText categoryHammersText; + private static LocalizedText categoryArmorText; + private static LocalizedText categoryWeaponsText; + private static LocalizedText sortItemIdText; + private static LocalizedText sortValueText; + private static LocalizedText sortAlphabeticalText; + private static LocalizedText sortRarityText; + private static LocalizedText sortTerrariaSortText; + private static LocalizedText filterMaterialsText; + private static LocalizedText sortPickPower; + private static LocalizedText sortAxePower; + private static LocalizedText sortHammerPower; + private static LocalizedText categoryHead; + private static LocalizedText categoryBody; + private static LocalizedText categoryLegs; + private static LocalizedText sortDefense; + private static LocalizedText categoryTiles; + private static LocalizedText categoryContainersText; + private static LocalizedText categoryWiringText; + private static LocalizedText categoryStatuesText; + private static LocalizedText categoryDoorsText; + private static LocalizedText categoryChairsText; + private static LocalizedText categoryTablesText; + private static LocalizedText categoryLightSourcesText; + private static LocalizedText categoryTorchesText; + private static LocalizedText categoryWallsText; + private static LocalizedText categoryAccessoriesText; + private static LocalizedText categoryWingsText; + private static LocalizedText categoryAmmoText; + private static LocalizedText categoryPotionsText; + private static LocalizedText categoryHealthPotionsText; + private static LocalizedText categoryManaPotionsText; + private static LocalizedText categoryBuffPotionsText; + private static LocalizedText categoryExpertText; + private static LocalizedText categoryPetsText; + private static LocalizedText categoryLightPetsText; + private static LocalizedText categoryMountsText; + private static LocalizedText categoryCartsText; + private static LocalizedText categoryHooksText; + private static LocalizedText categoryDyesText; + private static LocalizedText categoryHairDyesText; + private static LocalizedText categoryBossSummonsText; + private static LocalizedText categoryConsumablesText; + private static LocalizedText categoryCapturedNPCText; + private static LocalizedText categoryFishingText; + private static LocalizedText categoryPolesText; + private static LocalizedText categoryBaitText; + private static LocalizedText categoryQuestFishText; + private static LocalizedText categoryExtractinatorText; + private static LocalizedText categoryOtherText; + private static LocalizedText sortPlaceTileText; + private static LocalizedText sortAmmoTypeText; + private static LocalizedText sortHealLifeText; + private static LocalizedText sortHealManaText; + private static LocalizedText sortGrappleRangeText; + private static LocalizedText sortProgressionOrderText; + private static LocalizedText sortPolePowerText; + private static LocalizedText sortBaitPowerText; + public SharedUI() { instance = this; + + mutuallyExclusiveFilterVanityText = Language.GetOrRegister( LocalizationKey + nameof(mutuallyExclusiveFilterVanityText) ); + mutuallyExclusiveFilterArmorText = Language.GetOrRegister( LocalizationKey + nameof(mutuallyExclusiveFilterArmorText) ); + cycleAmmoTypesText = Language.GetOrRegister( LocalizationKey + nameof(cycleAmmoTypesText) ); + cycleUsedAmmoTypesText = Language.GetOrRegister( LocalizationKey + nameof(cycleUsedAmmoTypesText) ); + categoryAllText = Language.GetOrRegister( LocalizationKey + nameof(categoryAllText) ); + categoryMeleeText = Language.GetOrRegister( LocalizationKey + nameof(categoryMeleeText) ); + categoryYoyoText = Language.GetOrRegister( LocalizationKey + nameof(categoryYoyoText) ); + categoryMagicText = Language.GetOrRegister( LocalizationKey + nameof(categoryMagicText) ); + categoryRangedText = Language.GetOrRegister( LocalizationKey + nameof(categoryRangedText) ); + sortUseAmmoTypeText = Language.GetOrRegister( LocalizationKey + nameof(sortUseAmmoTypeText) ); + categoryThrowingText = Language.GetOrRegister( LocalizationKey + nameof(categoryThrowingText) ); + categorySummonText = Language.GetOrRegister( LocalizationKey + nameof(categorySummonText) ); + categorySentryText = Language.GetOrRegister( LocalizationKey + nameof(categorySentryText) ); + sortDamageText = Language.GetOrRegister( LocalizationKey + nameof(sortDamageText) ); + categoryToolsText = Language.GetOrRegister( LocalizationKey + nameof(categoryToolsText) ); + categoryPickaxesText = Language.GetOrRegister( LocalizationKey + nameof(categoryPickaxesText) ); + categoryAxesText = Language.GetOrRegister( LocalizationKey + nameof(categoryAxesText) ); + categoryHammersText = Language.GetOrRegister( LocalizationKey + nameof(categoryHammersText) ); + categoryArmorText = Language.GetOrRegister( LocalizationKey + nameof(categoryArmorText) ); + categoryWeaponsText = Language.GetOrRegister( LocalizationKey + nameof(categoryWeaponsText) ); + sortValueText = Language.GetOrRegister( LocalizationKey + nameof(sortValueText) ); + sortAlphabeticalText = Language.GetOrRegister( LocalizationKey + nameof(sortAlphabeticalText) ); + sortRarityText = Language.GetOrRegister( LocalizationKey + nameof(sortRarityText) ); + sortTerrariaSortText = Language.GetOrRegister( LocalizationKey + nameof(sortTerrariaSortText) ); + filterMaterialsText = Language.GetOrRegister( LocalizationKey + nameof(filterMaterialsText) ); + sortPickPower = Language.GetOrRegister( LocalizationKey + nameof(sortPickPower) ); + sortAxePower = Language.GetOrRegister( LocalizationKey + nameof(sortAxePower) ); + sortHammerPower = Language.GetOrRegister( LocalizationKey + nameof(sortHammerPower) ); + categoryHead = Language.GetOrRegister( LocalizationKey + nameof(categoryHead) ); + categoryBody = Language.GetOrRegister( LocalizationKey + nameof(categoryBody) ); + categoryLegs = Language.GetOrRegister( LocalizationKey + nameof(categoryLegs) ); + sortDefense = Language.GetOrRegister( LocalizationKey + nameof(sortDefense) ); + categoryTiles = Language.GetOrRegister( LocalizationKey + nameof(categoryTiles) ); + categoryContainersText = Language.GetOrRegister( LocalizationKey + nameof(categoryContainersText) ); + categoryWiringText = Language.GetOrRegister( LocalizationKey + nameof(categoryWiringText) ); + categoryStatuesText = Language.GetOrRegister( LocalizationKey + nameof(categoryStatuesText) ); + categoryDoorsText = Language.GetOrRegister( LocalizationKey + nameof(categoryDoorsText) ); + categoryChairsText = Language.GetOrRegister( LocalizationKey + nameof(categoryChairsText) ); + categoryTablesText = Language.GetOrRegister( LocalizationKey + nameof(categoryTablesText) ); + categoryLightSourcesText = Language.GetOrRegister( LocalizationKey + nameof(categoryLightSourcesText) ); + categoryTorchesText = Language.GetOrRegister( LocalizationKey + nameof(categoryTorchesText) ); + categoryWallsText = Language.GetOrRegister( LocalizationKey + nameof(categoryWallsText) ); + categoryAccessoriesText = Language.GetOrRegister( LocalizationKey + nameof(categoryAccessoriesText) ); + categoryWingsText = Language.GetOrRegister( LocalizationKey + nameof(categoryWingsText) ); + categoryAmmoText = Language.GetOrRegister( LocalizationKey + nameof(categoryAmmoText) ); + categoryPotionsText = Language.GetOrRegister( LocalizationKey + nameof(categoryPotionsText) ); + categoryHealthPotionsText = Language.GetOrRegister( LocalizationKey + nameof(categoryHealthPotionsText) ); + categoryManaPotionsText = Language.GetOrRegister( LocalizationKey + nameof(categoryManaPotionsText) ); + categoryBuffPotionsText = Language.GetOrRegister( LocalizationKey + nameof(categoryBuffPotionsText) ); + categoryExpertText = Language.GetOrRegister( LocalizationKey + nameof(categoryExpertText) ); + categoryPetsText = Language.GetOrRegister( LocalizationKey + nameof(categoryPetsText) ); + categoryPetsText = Language.GetOrRegister( LocalizationKey + nameof(categoryPetsText) ); + categoryLightPetsText = Language.GetOrRegister( LocalizationKey + nameof(categoryLightPetsText) ); + categoryMountsText = Language.GetOrRegister( LocalizationKey + nameof(categoryMountsText) ); + categoryCartsText = Language.GetOrRegister( LocalizationKey + nameof(categoryCartsText) ); + categoryHooksText = Language.GetOrRegister( LocalizationKey + nameof(categoryHooksText) ); + categoryDyesText = Language.GetOrRegister( LocalizationKey + nameof(categoryDyesText) ); + categoryDyesText = Language.GetOrRegister( LocalizationKey + nameof(categoryDyesText) ); + categoryHairDyesText = Language.GetOrRegister( LocalizationKey + nameof(categoryHairDyesText) ); + categoryBossSummonsText = Language.GetOrRegister( LocalizationKey + nameof(categoryBossSummonsText) ); + categoryConsumablesText = Language.GetOrRegister( LocalizationKey + nameof(categoryConsumablesText) ); + categoryCapturedNPCText = Language.GetOrRegister( LocalizationKey + nameof(categoryCapturedNPCText) ); + categoryFishingText = Language.GetOrRegister( LocalizationKey + nameof(categoryFishingText) ); + categoryPolesText = Language.GetOrRegister( LocalizationKey + nameof(categoryPolesText) ); + categoryBaitText = Language.GetOrRegister( LocalizationKey + nameof(categoryBaitText) ); + categoryQuestFishText = Language.GetOrRegister( LocalizationKey + nameof(categoryQuestFishText) ); + categoryExtractinatorText = Language.GetOrRegister( LocalizationKey + nameof(categoryExtractinatorText) ); + categoryOtherText = Language.GetOrRegister( LocalizationKey + nameof(categoryOtherText) ); + sortItemIdText = Language.GetOrRegister( LocalizationKey + nameof(sortItemIdText) ); + sortPlaceTileText = Language.GetOrRegister( LocalizationKey + nameof(sortPlaceTileText) ); + sortAmmoTypeText = Language.GetOrRegister( LocalizationKey + nameof(sortAmmoTypeText) ); + sortHealLifeText = Language.GetOrRegister( LocalizationKey + nameof(sortHealLifeText) ); + sortHealManaText = Language.GetOrRegister( LocalizationKey + nameof(sortHealManaText) ); + sortGrappleRangeText = Language.GetOrRegister( LocalizationKey + nameof(sortGrappleRangeText) ); + sortProgressionOrderText = Language.GetOrRegister( LocalizationKey + nameof(sortProgressionOrderText) ); + sortPolePowerText = Language.GetOrRegister( LocalizationKey + nameof(sortPolePowerText) ); + sortBaitPowerText = Language.GetOrRegister( LocalizationKey + nameof(sortBaitPowerText) ); } internal void Initialize() { @@ -292,17 +450,17 @@ namespace ItemChecklist // TODO: Implement Badge text as used in Item Checklist. sorts = new List() { - new Sort("ItemID", "Images/sortItemID", (x,y)=>x.type.CompareTo(y.type), x=>x.type.ToString()), - new Sort("Value", "Images/sortValue", (x,y)=>x.value.CompareTo(y.value), x=>x.value.ToString()), - new Sort("Alphabetical", "Images/sortAZ", (x,y)=>x.Name.CompareTo(y.Name), x=>x.Name.ToString()), - new Sort("Rarity", rarity, (x,y)=> x.rare==y.rare ? x.value.CompareTo(y.value) : Math.Abs(x.rare).CompareTo(Math.Abs(y.rare)), x=>x.rare.ToString()), - new Sort("Terraria Sort", terrariaSort, ByCreativeSortingId, ByCreativeSortingIdBadgeText), + new Sort(sortItemIdText.Value, "Images/sortItemID", (x,y)=>x.type.CompareTo(y.type), x=>x.type.ToString()), + new Sort(sortValueText.Value, "Images/sortValue", (x,y)=>x.value.CompareTo(y.value), x=>x.value.ToString()), + new Sort(sortAlphabeticalText.Value, "Images/sortAZ", (x,y)=>x.Name.CompareTo(y.Name), x=>x.Name.ToString()), + new Sort(sortRarityText.Value, rarity, (x,y)=> x.rare==y.rare ? x.value.CompareTo(y.value) : Math.Abs(x.rare).CompareTo(Math.Abs(y.rare)), x=>x.rare.ToString()), + new Sort(sortTerrariaSortText.Value, terrariaSort, ByCreativeSortingId, ByCreativeSortingIdBadgeText), }; Texture2D materialsIcon = Utilities.StackResizeImage(new[] { TextureAssets.Item[ItemID.SpellTome] }, 24, 24); filters = new List() { - new Filter("Materials", x=>ItemID.Sets.IsAMaterial[x.type], materialsIcon), + new Filter(filterMaterialsText.Value, x=>ItemID.Sets.IsAMaterial[x.type], materialsIcon), }; // TODOS: Vanity armor, grapple, cart, potions buffs @@ -343,8 +501,8 @@ namespace ItemChecklist var ammoFilters = sortedAmmoTypes.Select(ammoType => new Filter(Lang.GetItemNameValue(ammoType), x => x.ammo == ammoType, ResizeImage(TextureAssets.Item[ammoType], 24, 24))).ToList(); var useAmmoFilters = sortedUseAmmoTypes.Select(ammoType => new Filter(Lang.GetItemNameValue(ammoType), x => x.useAmmo == ammoType, ResizeImage(TextureAssets.Item[ammoType], 24, 24))).ToList(); - var ammoFilter = new CycleFilter("Cycle Ammo Types", "Images/sortAmmo", ammoFilters); - var useAmmoFilter = new CycleFilter("Cycle Used Ammo Types", "Images/sortAmmo", useAmmoFilters); + var ammoFilter = new CycleFilter(cycleAmmoTypesText.Value, "Images/sortAmmo", ammoFilters); + var useAmmoFilter = new CycleFilter(cycleUsedAmmoTypesText.Value, "Images/sortAmmo", useAmmoFilters); Texture2D smallMelee = ResizeImage(TextureAssets.Item[ItemID.GoldBroadsword], 24, 24); Texture2D smallYoyo = ResizeImage(TextureAssets.Item[Main.rand.Next(yoyos)], 24, 24); //Main.rand.Next(ItemID.Sets.Yoyo) ItemID.Yelets @@ -403,47 +561,47 @@ namespace ItemChecklist // Potions, other? // should inherit children? // should have other category? - if (WorldGen.statueList == null) + if (GenVars.statueList == null) WorldGen.SetupStatueList(); - var vanity = new MutuallyExclusiveFilter("Vanity", x => x.vanity, smallVanity); - var armor = new MutuallyExclusiveFilter("Armor", x => !x.vanity, smallNonVanity); + var vanity = new MutuallyExclusiveFilter(mutuallyExclusiveFilterVanityText.Value, x => x.vanity, smallVanity); + var armor = new MutuallyExclusiveFilter(mutuallyExclusiveFilterArmorText.Value, x => !x.vanity, smallNonVanity); vanity.SetExclusions(new List() { vanity, armor }); armor.SetExclusions(new List() { vanity, armor }); categories = new List() { - new Category("All", x=> true, smallAll), + new Category(categoryAllText.Value, x=> true, smallAll), // TODO: Filter out tools from weapons. Separate belongs and doesn't belong predicates? How does inheriting work again? Other? - new Category("Weapons"/*, x=>x.damage>0*/, x=> false, smallWeapons) { //"Images/sortDamage" + new Category(categoryWeaponsText.Value/*, x=>x.damage>0*/, x=> false, smallWeapons) { //"Images/sortDamage" subCategories = new List() { - new Category("Melee", x=>x.CountsAsClass(DamageClass.Melee) && !(x.pick>0 || x.axe>0 || x.hammer>0), smallMelee), - new Category("Yoyo", x=>ItemID.Sets.Yoyo[x.type], smallYoyo), - new Category("Magic", x=>x.CountsAsClass(DamageClass.Magic), smallMagic), - new Category("Ranged", x=>x.CountsAsClass(DamageClass.Ranged) && x.ammo == 0, smallRanged) // TODO and ammo no + new Category(categoryMeleeText.Value, x=>x.CountsAsClass(DamageClass.Melee) && !(x.pick>0 || x.axe>0 || x.hammer>0), smallMelee), + new Category(categoryYoyoText.Value, x=>ItemID.Sets.Yoyo[x.type], smallYoyo), + new Category(categoryMagicText.Value, x=>x.CountsAsClass(DamageClass.Magic), smallMagic), + new Category(categoryRangedText.Value, x=>x.CountsAsClass(DamageClass.Ranged) && x.ammo == 0, smallRanged) // TODO and ammo no { - sorts = new List() { new Sort("Use Ammo Type", "Images/sortAmmo", (x,y)=>x.useAmmo.CompareTo(y.useAmmo), x => x.useAmmo.ToString()), }, + sorts = new List() { new Sort(sortUseAmmoTypeText.Value, "Images/sortAmmo", (x,y)=>x.useAmmo.CompareTo(y.useAmmo), x => x.useAmmo.ToString()), }, filters = new List { useAmmoFilter } }, - new Category("Throwing", x=>x.CountsAsClass(DamageClass.Throwing), smallThrown), - new Category("Summon", x=>x.CountsAsClass(DamageClass.Summon) && !x.sentry, smallSummon), - new Category("Sentry", x=>x.CountsAsClass(DamageClass.Summon) && x.sentry, smallSentry), + new Category(categoryThrowingText.Value, x=>x.CountsAsClass(DamageClass.Throwing), smallThrown), + new Category(categorySummonText.Value, x=>x.CountsAsClass(DamageClass.Summon) && !x.sentry, smallSummon), + new Category(categorySentryText.Value, x=>x.CountsAsClass(DamageClass.Summon) && x.sentry, smallSentry), }, - sorts = new List() { new Sort("Damage", "Images/sortDamage", (x,y)=>x.damage.CompareTo(y.damage), x => x.damage.ToString()), }, + sorts = new List() { new Sort(sortDamageText.Value, "Images/sortDamage", (x,y)=>x.damage.CompareTo(y.damage), x => x.damage.ToString()), }, }, - new Category("Tools"/*,x=>x.pick>0||x.axe>0||x.hammer>0*/, x=>false, smallTools) { + new Category(categoryToolsText.Value/*,x=>x.pick>0||x.axe>0||x.hammer>0*/, x=>false, smallTools) { subCategories = new List() { - new Category("Pickaxes", x=>x.pick>0, "Images/sortPick") { sorts = new List() { new Sort("Pick Power", "Images/sortPick", (x,y)=>x.pick.CompareTo(y.pick), x => x.pick.ToString()), } }, - new Category("Axes", x=>x.axe>0, "Images/sortAxe"){ sorts = new List() { new Sort("Axe Power", "Images/sortAxe", (x,y)=>x.axe.CompareTo(y.axe), x => (x.axe*5).ToString()), } }, - new Category("Hammers", x=>x.hammer>0, "Images/sortHammer"){ sorts = new List() { new Sort("Hammer Power", "Images/sortHammer", (x,y)=>x.hammer.CompareTo(y.hammer), x => x.hammer.ToString()), } }, + new Category(categoryPickaxesText.Value, x=>x.pick>0, "Images/sortPick") { sorts = new List() { new Sort(sortPickPower.Value, "Images/sortPick", (x,y)=>x.pick.CompareTo(y.pick), x => x.pick.ToString()), } }, + new Category(categoryAxesText.Value, x=>x.axe>0, "Images/sortAxe"){ sorts = new List() { new Sort(sortAxePower.Value, "Images/sortAxe", (x,y)=>x.axe.CompareTo(y.axe), x => (x.axe*5).ToString()), } }, + new Category(categoryHammersText.Value, x=>x.hammer>0, "Images/sortHammer"){ sorts = new List() { new Sort(sortHammerPower.Value, "Images/sortHammer", (x,y)=>x.hammer.CompareTo(y.hammer), x => x.hammer.ToString()), } }, }, }, - new Category("Armor"/*, x=>x.headSlot!=-1||x.bodySlot!=-1||x.legSlot!=-1*/, x => false, smallArmor) { + new Category(categoryArmorText.Value/*, x=>x.headSlot!=-1||x.bodySlot!=-1||x.legSlot!=-1*/, x => false, smallArmor) { subCategories = new List() { - new Category("Head", x=>x.headSlot!=-1, smallHead), - new Category("Body", x=>x.bodySlot!=-1, smallBody), - new Category("Legs", x=>x.legSlot!=-1, smallLegs), + new Category(categoryHead.Value, x=>x.headSlot!=-1, smallHead), + new Category(categoryBody.Value, x=>x.bodySlot!=-1, smallBody), + new Category(categoryLegs.Value, x=>x.legSlot!=-1, smallLegs), }, - sorts = new List() { new Sort("Defense", "Images/sortDefense", (x,y)=>x.defense.CompareTo(y.defense), x => x.defense.ToString()), }, + sorts = new List() { new Sort(sortDefense.Value, "Images/sortDefense", (x,y)=>x.defense.CompareTo(y.defense), x => x.defense.ToString()), }, filters = new List { //new Filter("Vanity", x=>x.vanity, RecipeBrowser.instance.Assets.Request("Images/sortDefense")), // Prefer MutuallyExclusiveFilter for this, rather than CycleFilter since there are only 2 options. @@ -455,18 +613,18 @@ namespace ItemChecklist //new DoubleFilter("Vanity", "Armor", smallVanity2, x=>x.vanity), } }, - new Category("Tiles", x=>x.createTile!=-1, smallTiles) + new Category(categoryTiles.Value, x=>x.createTile!=-1, smallTiles) { subCategories = new List() { - new Category("Containers", x=>x.createTile!=-1 && Main.tileContainer[x.createTile], smallContainer), - new Category("Wiring", x=>ItemID.Sets.SortingPriorityWiring[x.type] > -1, smallWiring), - new Category("Statues", x=>WorldGen.statueList.Any(point => point.X == x.createTile && point.Y == x.placeStyle), smallStatue), - new Category("Doors", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsDoor.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenDoor])), - new Category("Chairs", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsChair.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenChair])), - new Category("Tables", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsTable.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.PalmWoodTable])), - new Category("Light Sources", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsTorch.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.ChineseLantern])), - new Category("Torches", x=> x.createTile > 0 && TileID.Sets.Torch[x.createTile], ResizeImage2424(TextureAssets.Item[ItemID.RainbowTorch])), + new Category(categoryContainersText.Value, x=>x.createTile!=-1 && Main.tileContainer[x.createTile], smallContainer), + new Category(categoryWiringText.Value, x=>ItemID.Sets.SortingPriorityWiring[x.type] > -1, smallWiring), + new Category(categoryStatuesText.Value, x=>GenVars.statueList.Any(point => point.X == x.createTile && point.Y == x.placeStyle), smallStatue), + new Category(categoryDoorsText.Value, x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsDoor.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenDoor])), + new Category(categoryChairsText.Value, x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsChair.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenChair])), + new Category(categoryTablesText.Value, x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsTable.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.PalmWoodTable])), + new Category(categoryLightSourcesText.Value, x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsTorch.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.ChineseLantern])), + new Category(categoryTorchesText.Value, x=> x.createTile > 0 && TileID.Sets.Torch[x.createTile], ResizeImage2424(TextureAssets.Item[ItemID.RainbowTorch])), // Banners => Banner Bonanza mod integration //TextureAssets.Item[Main.rand.Next(TileID.Sets.RoomNeeds.CountsAsTable)] doesn't work since those are tilesids. yoyo approach? // todo: music box @@ -481,80 +639,80 @@ namespace ItemChecklist //} , smallContainer), }, sorts = new List() { - new Sort("Place Tile", smallSortTiles, (x,y)=> x.createTile == y.createTile ? x.placeStyle.CompareTo(y.placeStyle) : x.createTile.CompareTo(y.createTile), x=>$"{x.createTile},{x.placeStyle}"), + new Sort(sortPlaceTileText.Value, smallSortTiles, (x,y)=> x.createTile == y.createTile ? x.placeStyle.CompareTo(y.placeStyle) : x.createTile.CompareTo(y.createTile), x=>$"{x.createTile},{x.placeStyle}"), } }, - new Category("Walls", x=>x.createWall!=-1, smallWalls), - new Category("Accessories", x=>x.accessory, smallAccessories) + new Category(categoryWallsText.Value, x=>x.createWall!=-1, smallWalls), + new Category(categoryAccessoriesText.Value, x=>x.accessory, smallAccessories) { subCategories = new List() { - new Category("Wings", x=>x.wingSlot > 0, smallWings) + new Category(categoryWingsText.Value, x=>x.wingSlot > 0, smallWings) } }, - new Category("Ammo", x=>x.ammo!=0, "Images/sortAmmo") + new Category(categoryAmmoText.Value, x=>x.ammo!=0, "Images/sortAmmo") { sorts = new List() { - new Sort("Ammo Type", "Images/sortAmmo", (x,y)=>x.ammo.CompareTo(y.ammo), x => $"{x.ammo}"), - new Sort("Damage", "Images/sortDamage", (x,y)=>x.damage.CompareTo(y.damage), x => $"{x.damage}"), + new Sort(sortAmmoTypeText.Value, "Images/sortAmmo", (x,y)=>x.ammo.CompareTo(y.ammo), x => $"{x.ammo}"), + new Sort(sortDamageText.Value, "Images/sortDamage", (x,y)=>x.damage.CompareTo(y.damage), x => $"{x.damage}"), }, filters = new List { ammoFilter } // TODO: Filters/Subcategories for all ammo types? // each click cycles? }, - new Category("Potions", x=> (x.UseSound?.IsTheSameAs(SoundID.Item3) == true), smallPotions) + new Category(categoryPotionsText.Value, x=> (x.UseSound?.IsTheSameAs(SoundID.Item3) == true), smallPotions) { subCategories = new List() { - new Category("Health Potions", x=>x.healLife > 0, smallHealth) { sorts = new List() { new Sort("Heal Life", smallHealth, (x,y)=>x.healLife.CompareTo(y.healLife), x => $"{x.healLife}"), } }, - new Category("Mana Potions", x=>x.healMana > 0, smallMana) { sorts = new List() { new Sort("Heal Mana", smallMana, (x,y)=>x.healMana.CompareTo(y.healMana), x => $"{x.healMana}"), }}, - new Category("Buff Potions", x=>(x.UseSound?.IsTheSameAs(SoundID.Item3) == true) && x.buffType > 0, smallBuff), + new Category(categoryHealthPotionsText.Value, x=>x.healLife > 0, smallHealth) { sorts = new List() { new Sort(sortHealLifeText.Value, smallHealth, (x,y)=>x.healLife.CompareTo(y.healLife), x => $"{x.healLife}"), } }, + new Category(categoryManaPotionsText.Value, x=>x.healMana > 0, smallMana) { sorts = new List() { new Sort(sortHealManaText.Value, smallMana, (x,y)=>x.healMana.CompareTo(y.healMana), x => $"{x.healMana}"), }}, + new Category(categoryBuffPotionsText.Value, x=>(x.UseSound?.IsTheSameAs(SoundID.Item3) == true) && x.buffType > 0, smallBuff), // Todo: Automatic other category? } }, - new Category("Expert", x=>x.expert, smallExpert), - new Category("Pets"/*, x=> x.buffType > 0 && (Main.vanityPet[x.buffType] || Main.lightPet[x.buffType])*/, x=>false, smallPetsLightPets){ + new Category(categoryExpertText.Value, x=>x.expert, smallExpert), + new Category(categoryPetsText.Value/*, x=> x.buffType > 0 && (Main.vanityPet[x.buffType] || Main.lightPet[x.buffType])*/, x=>false, smallPetsLightPets){ subCategories = new List() { - new Category("Pets", x=>Main.vanityPet[x.buffType], smallPets), - new Category("Light Pets", x=>Main.lightPet[x.buffType], smallLightPets), + new Category(categoryPetsText.Value, x=>Main.vanityPet[x.buffType], smallPets), + new Category(categoryLightPetsText.Value, x=>Main.lightPet[x.buffType], smallLightPets), } }, - new Category("Mounts", x=>x.mountType != -1, smallMounts) + new Category(categoryMountsText.Value, x=>x.mountType != -1, smallMounts) { subCategories = new List() { - new Category("Carts", x=>x.mountType != -1 && MountID.Sets.Cart[x.mountType], smallCarts) // TODO: need mountType check? inherited parent logic or parent unions children? + new Category(categoryCartsText.Value, x=>x.mountType != -1 && MountID.Sets.Cart[x.mountType], smallCarts) // TODO: need mountType check? inherited parent logic or parent unions children? } }, - new Category("Hooks", x=> Main.projHook[x.shoot], smallHooks){ + new Category(categoryHooksText.Value, x=> Main.projHook[x.shoot], smallHooks){ sorts = new List() { - new Sort("Grapple Range", smallHooks, (x,y)=> GrappleRange(x.shoot).CompareTo(GrappleRange(y.shoot)), x => $"{GrappleRange(x.shoot)}"), + new Sort(sortGrappleRangeText.Value, smallHooks, (x,y)=> GrappleRange(x.shoot).CompareTo(GrappleRange(y.shoot)), x => $"{GrappleRange(x.shoot)}"), }, }, - new Category("Dyes", x=>false, smallBothDyes) + new Category(categoryDyesText.Value, x=>false, smallBothDyes) { subCategories = new List() { - new Category("Dyes", x=>x.dye != 0, smallDyes), - new Category("Hair Dyes", x=>x.hairDye != -1, smallHairDye), + new Category(categoryDyesText.Value, x=>x.dye != 0, smallDyes), + new Category(categoryHairDyesText.Value, x=>x.hairDye != -1, smallHairDye), } }, - new Category("Boss Summons", x=>ItemID.Sets.SortingPriorityBossSpawns[x.type] != -1 && x.type != ItemID.LifeCrystal && x.type != ItemID.ManaCrystal && x.type != ItemID.CellPhone && x.type != ItemID.IceMirror && x.type != ItemID.MagicMirror && x.type != ItemID.LifeFruit && x.netID != ItemID.TreasureMap || x.netID == ItemID.PirateMap, smallBossSummon) { // vanilla bug. - sorts = new List() { new Sort("Progression Order", "Images/sortDamage", (x,y)=>ItemID.Sets.SortingPriorityBossSpawns[x.type].CompareTo(ItemID.Sets.SortingPriorityBossSpawns[y.type]), x => $"{ItemID.Sets.SortingPriorityBossSpawns[x.type]}"), } + new Category(categoryBossSummonsText.Value, x=>ItemID.Sets.SortingPriorityBossSpawns[x.type] != -1 && x.type != ItemID.LifeCrystal && x.type != ItemID.ManaCrystal && x.type != ItemID.CellPhone && x.type != ItemID.IceMirror && x.type != ItemID.MagicMirror && x.type != ItemID.LifeFruit && x.netID != ItemID.TreasureMap || x.netID == ItemID.PirateMap, smallBossSummon) { // vanilla bug. + sorts = new List() { new Sort(sortProgressionOrderText.Value, "Images/sortDamage", (x,y)=>ItemID.Sets.SortingPriorityBossSpawns[x.type].CompareTo(ItemID.Sets.SortingPriorityBossSpawns[y.type]), x => $"{ItemID.Sets.SortingPriorityBossSpawns[x.type]}"), } }, - new Category("Consumables", x=> !(x.createWall > 0 || x.createTile > -1) && !(x.ammo > 0 && !x.notAmmo) && x.consumable, smallConsumables){ + new Category(categoryConsumablesText.Value, x=> !(x.createWall > 0 || x.createTile > -1) && !(x.ammo > 0 && !x.notAmmo) && x.consumable, smallConsumables){ subCategories = new List() { - new Category("Captured NPC", x=>x.makeNPC != 0, ResizeImage2424(TextureAssets.Item[ItemID.GoldBunny])), + new Category(categoryCapturedNPCText.Value, x=>x.makeNPC != 0, ResizeImage2424(TextureAssets.Item[ItemID.GoldBunny])), } }, - new Category("Fishing"/*, x=> x.fishingPole > 0 || x.bait>0|| x.questItem*/, x=>false, smallFishing){ + new Category(categoryFishingText.Value/*, x=> x.fishingPole > 0 || x.bait>0|| x.questItem*/, x=>false, smallFishing){ subCategories = new List() { - new Category("Poles", x=>x.fishingPole > 0, "Images/sortFish") {sorts = new List() { new Sort("Pole Power", "Images/sortFish", (x,y)=>x.fishingPole.CompareTo(y.fishingPole), x => $"{x.fishingPole}"), } }, - new Category("Bait", x=>x.bait>0, "Images/sortBait") {sorts = new List() { new Sort("Bait Power", "Images/sortBait", (x,y)=>x.bait.CompareTo(y.bait), x => $"{x.bait}"), } }, - new Category("Quest Fish", x=>x.questItem, smallQuestFish), + new Category(categoryPolesText.Value, x=>x.fishingPole > 0, "Images/sortFish") {sorts = new List() { new Sort(sortPolePowerText.Value, "Images/sortFish", (x,y)=>x.fishingPole.CompareTo(y.fishingPole), x => $"{x.fishingPole}"), } }, + new Category(categoryBaitText.Value, x=>x.bait>0, "Images/sortBait") {sorts = new List() { new Sort(sortBaitPowerText.Value, "Images/sortBait", (x,y)=>x.bait.CompareTo(y.bait), x => $"{x.bait}"), } }, + new Category(categoryQuestFishText.Value, x=>x.questItem, smallQuestFish), } }, - new Category("Extractinator", x=>ItemID.Sets.ExtractinatorMode[x.type] > -1, smallExtractinator), + new Category(categoryExtractinatorText.Value, x=>ItemID.Sets.ExtractinatorMode[x.type] > -1, smallExtractinator), //modCategory, - new Category("Other", x=>BelongsInOther(x), smallOther), + new Category(categoryOtherText.Value, x=>BelongsInOther(x), smallOther), }; /* Think about this one. @@ -675,7 +833,7 @@ namespace ItemChecklist this.belongs = belongs; this.button = new UISilentImageButton(texture, name); - button.OnClick += (a, b) => { + button.OnLeftClick += (a, b) => { button.selected = !button.selected; ItemChecklistUI.instance.UpdateNeeded(); //Main.NewText("clicked on " + button.hoverText); @@ -688,7 +846,7 @@ namespace ItemChecklist List exclusives; public MutuallyExclusiveFilter(string name, Predicate belongs, Texture2D texture) : base(name, belongs, texture) { - button.OnClick += (a, b) => { + button.OnLeftClick += (a, b) => { if (button.selected) { foreach (var item in exclusives) { if (item != this) @@ -714,7 +872,7 @@ namespace ItemChecklist return belongs(item) ^ right; }; button = new UIBadgedSilentImageButton(texture, name + " (RMB)"); - button.OnClick += (a, b) => { + button.OnLeftClick += (a, b) => { button.selected = !button.selected; ItemChecklistUI.instance.UpdateNeeded(); //Main.NewText("clicked on " + button.hoverText); @@ -746,14 +904,14 @@ namespace ItemChecklist //CycleFilter needs SharedUI.instance.updateNeeded to update image, since each filter acts independently. var firstButton = new UISilentImageButton(texture, name); - firstButton.OnClick += (a, b) => ButtonBehavior(true); + firstButton.OnLeftClick += (a, b) => ButtonBehavior(true); firstButton.OnRightClick += (a, b) => ButtonBehavior(false); buttons.Add(firstButton); for (int i = 0; i < filters.Count; i++) { var buttonOption = new UISilentImageButton(filters[i].texture, filters[i].name); - buttonOption.OnClick += (a, b) => ButtonBehavior(true); + buttonOption.OnLeftClick += (a, b) => ButtonBehavior(true); buttonOption.OnRightClick += (a, b) => ButtonBehavior(false); buttonOption.OnMiddleClick += (a, b) => ButtonBehavior(false, true); buttons.Add(buttonOption); @@ -784,7 +942,7 @@ namespace ItemChecklist this.sort = sort; this.badge = badge; button = new UISilentImageButton(texture, hoverText); - button.OnClick += (a, b) => { + button.OnLeftClick += (a, b) => { SharedUI.instance.SelectedSort = this; }; } @@ -832,7 +990,7 @@ namespace ItemChecklist this.belongs = belongs; this.button = new UISilentImageButton(texture, name); - button.OnClick += (a, b) => { + button.OnLeftClick += (a, b) => { //Main.NewText("clicked on " + button.hoverText); SharedUI.instance.SelectedCategory = this; }; diff --git a/UIElements/NewUITextBox.cs b/UIElements/NewUITextBox.cs index 7bb7d60..c128909 100644 --- a/UIElements/NewUITextBox.cs +++ b/UIElements/NewUITextBox.cs @@ -51,7 +51,7 @@ namespace ItemChecklist.UIElements Texture2D texture = ItemChecklist.instance.Assets.Request("UIElements/closeButtonSmallWhite", AssetRequestMode.ImmediateLoad).Value; var closeButton = new UIHoverImageButton(texture, ""); - closeButton.OnClick += (a, b) => SetText(""); + closeButton.OnLeftClick += (a, b) => SetText(""); closeButton.Left.Set(-20f, 1f); //closeButton.Top.Set(0f, .5f); closeButton.VAlign = 0.5f; @@ -59,10 +59,10 @@ namespace ItemChecklist.UIElements Append(closeButton); } - public override void Click(UIMouseEvent evt) + public override void LeftClick(UIMouseEvent evt) { Focus(); - base.Click(evt); + base.LeftClick(evt); } public override void RightClick(UIMouseEvent evt) diff --git a/UIElements/UICheckbox.cs b/UIElements/UICheckbox.cs index d5e0c66..4e53394 100644 --- a/UIElements/UICheckbox.cs +++ b/UIElements/UICheckbox.cs @@ -39,7 +39,7 @@ namespace ItemChecklist.UIElements text = " " + text; this.hoverText = hoverText; SetText(text); - OnClick += UICheckbox_onLeftClick; + OnLeftClick += UICheckbox_onLeftClick; Recalculate(); } diff --git a/UIElements/UICollectionBar.cs b/UIElements/UICollectionBar.cs index 877ac30..ffa0bad 100644 --- a/UIElements/UICollectionBar.cs +++ b/UIElements/UICollectionBar.cs @@ -8,6 +8,8 @@ using Terraria.GameContent; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using Terraria.Localization; + namespace ItemChecklist.UIElements { @@ -31,9 +33,18 @@ namespace ItemChecklist.UIElements private List collectionBarItems; + private const string LocalizationKey = "Mods.ItemChecklist.UICollectionBar."; + private LocalizedText collectionTotalText; + private LocalizedText collectionTerrariaText; + private LocalizedText collectionModText; + public UICollectionBar() { collectionBarItems = new List(); + collectionTotalText = Language.GetOrRegister(LocalizationKey + nameof(collectionTotalText)); + collectionTerrariaText = Language.GetOrRegister(LocalizationKey + nameof(collectionTerrariaText)); + collectionModText = Language.GetOrRegister(LocalizationKey + nameof(collectionModText)); + RecalculateBars(); } @@ -56,7 +67,7 @@ namespace ItemChecklist.UIElements //Add the bestiary total to the bar int total = ItemChecklistPlayer.totalItemsToFind; int totalCollected = ItemChecklistPlayer.totalItemsFound; - collectionBarItems.Add(new UICollectionBarItem($"Total: {totalCollected}/{total} ({(float)totalCollected / total * 100f:N2}% Collected)", total, totalCollected, Main.OurFavoriteColor)); + collectionBarItems.Add(new UICollectionBarItem(collectionTotalText.Format(totalCollected,total,$"{(float)totalCollected / total * 100f:N2}"), total, totalCollected, Main.OurFavoriteColor)); var data = ItemChecklistPlayer.foundItem.Zip(ContentSamples.ItemsByType.Values); //.GroupBy(x=>x.Second.ModItem?.Mod.Name ?? "Terraria").ToDictionary(y=>y., x=>x); @@ -64,7 +75,7 @@ namespace ItemChecklist.UIElements //Add Terraria's item entries int collected = items.Count(x => x.First); - collectionBarItems.Add(new UICollectionBarItem($"Terraria: {collected}/{items.Count} ({(float)collected / items.Count * 100f:N2}% Collected)", items.Count, collected, _colors[0])); + collectionBarItems.Add(new UICollectionBarItem(collectionTerrariaText.Format( collected,items.Count,$"{(float)collected / items.Count * 100f:N2})"), items.Count, collected, _colors[0])); //Add the mod's item entries for (int i = 0; i < ModLoader.Mods.Length; i++) { @@ -72,7 +83,7 @@ namespace ItemChecklist.UIElements if (!items.Any()) // No Items added by mod. continue; collected = items.Count(x => x.First); - collectionBarItems.Add(new UICollectionBarItem($"{ModLoader.Mods[i].DisplayName}: {collected}/{items.Count} ({(float)collected / items.Count * 100f:N2}% Collected)", items.Count, collected, _colors[i % _colors.Length])); + collectionBarItems.Add(new UICollectionBarItem(collectionModText.Format( ModLoader.Mods[i].DisplayName,collected,items.Count,$"{(float)collected / items.Count * 100f:N2}"), items.Count, collected, _colors[i % _colors.Length])); } } diff --git a/UIElements/UIDragableElement.cs b/UIElements/UIDragableElement.cs index 4c7fb3d..adf7290 100644 --- a/UIElements/UIDragableElement.cs +++ b/UIElements/UIDragableElement.cs @@ -53,16 +53,16 @@ namespace ItemChecklist // this.maxY = max; //} - public override void MouseDown(UIMouseEvent evt) + public override void LeftMouseDown(UIMouseEvent evt) { DragStart(evt); - base.MouseDown(evt); + base.LeftMouseDown(evt); } - public override void MouseUp(UIMouseEvent evt) + public override void LeftMouseUp(UIMouseEvent evt) { DragEnd(evt); - base.MouseUp(evt); + base.LeftMouseUp(evt); } private void DragStart(UIMouseEvent evt) diff --git a/UIElements/UIHorizontalScrollbar.cs b/UIElements/UIHorizontalScrollbar.cs index 4817c8e..510d420 100644 --- a/UIElements/UIHorizontalScrollbar.cs +++ b/UIElements/UIHorizontalScrollbar.cs @@ -97,9 +97,9 @@ namespace ItemChecklist.UIElements this.DrawBar(spriteBatch, this._innerTexture, handleRectangle, Color.White * ((this._isDragging || this._isHoveringOverHandle) ? 1f : 0.85f)); } - public override void MouseDown(UIMouseEvent evt) + public override void LeftMouseDown(UIMouseEvent evt) { - base.MouseDown(evt); + base.LeftMouseDown(evt); if (evt.Target == this) { Rectangle handleRectangle = this.GetHandleRectangle(); @@ -115,9 +115,9 @@ namespace ItemChecklist.UIElements } } - public override void MouseUp(UIMouseEvent evt) + public override void LeftMouseUp(UIMouseEvent evt) { - base.MouseUp(evt); + base.LeftMouseUp(evt); this._isDragging = false; } } @@ -139,11 +139,11 @@ namespace ItemChecklist.UIElements UserInterface.ActiveInstance = temp; } - public override void MouseDown(UIMouseEvent evt) + public override void LeftMouseDown(UIMouseEvent evt) { UserInterface temp = UserInterface.ActiveInstance; UserInterface.ActiveInstance = userInterface; - base.MouseDown(evt); + base.LeftMouseDown(evt); UserInterface.ActiveInstance = temp; } } @@ -162,11 +162,11 @@ namespace ItemChecklist.UIElements UserInterface.ActiveInstance = temp; } - public override void MouseDown(UIMouseEvent evt) + public override void LeftMouseDown(UIMouseEvent evt) { UserInterface temp = UserInterface.ActiveInstance; UserInterface.ActiveInstance = userInterface; - base.MouseDown(evt); + base.LeftMouseDown(evt); UserInterface.ActiveInstance = temp; } }