diff --git a/ItemChecklist.cs b/ItemChecklist.cs index d614b35..85f2445 100644 --- a/ItemChecklist.cs +++ b/ItemChecklist.cs @@ -22,18 +22,9 @@ namespace ItemChecklist internal ItemChecklistUI ItemChecklistUI; internal event Action OnNewItem; - public ItemChecklist() - { - } - public override void Load() { // Latest uses ItemID.Sets.IsAMaterial, added 0.10.1.5 - if (BuildInfo.tMLVersion < new Version(0, 10, 1, 5)) - { - throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n"); - } - instance = this; ToggleChecklistHotKey = KeybindLoader.RegisterKeybind(this, "Toggle Item Checklist", "I"); MagicStorageIntegration.Load(); @@ -61,7 +52,7 @@ namespace ItemChecklist UIElements.UIHorizontalGrid.moreRightTexture = null; } - public override void AddRecipes() + public void SetupUI() { if (!Main.dedServ) { @@ -69,6 +60,7 @@ namespace ItemChecklist //ItemChecklistUI.Activate(); ItemChecklistInterface = new UserInterface(); ItemChecklistInterface.SetState(ItemChecklistUI); + ItemChecklistUI.Visible = false; } } @@ -113,6 +105,10 @@ namespace ItemChecklist public class ItemChecklistSystem : ModSystem { + public override void AddRecipes() { + ItemChecklist.instance.SetupUI(); + } + public override void UpdateUI(GameTime gameTime) { ItemChecklist.ItemChecklistInterface?.Update(gameTime); diff --git a/ItemChecklist.sln b/ItemChecklist.sln deleted file mode 100644 index 55973a4..0000000 --- a/ItemChecklist.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30114.105 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ItemChecklist", "ItemChecklist.csproj", "{08602B6C-8E82-4BB4-A76A-606DF190C754}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {08602B6C-8E82-4BB4-A76A-606DF190C754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08602B6C-8E82-4BB4-A76A-606DF190C754}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08602B6C-8E82-4BB4-A76A-606DF190C754}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08602B6C-8E82-4BB4-A76A-606DF190C754}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/ItemChecklistPlayer.cs b/ItemChecklistPlayer.cs index 6a99d23..9835804 100644 --- a/ItemChecklistPlayer.cs +++ b/ItemChecklistPlayer.cs @@ -74,7 +74,7 @@ namespace ItemChecklist findableItems = new bool[ItemLoader.ItemCount]; for (int i = 0; i < ItemLoader.ItemCount; i++) { - if (i > 0 && !ItemID.Sets.Deprecated[i] && i != ItemID.Count && ItemChecklistUI.vanillaIDsInSortOrder != null && ItemChecklistUI.vanillaIDsInSortOrder[i] != -1) // TODO, is this guaranteed? + if (i > 0 && !ItemID.Sets.Deprecated[i] && ItemLoader.GetItem(i) is not Terraria.ModLoader.Default.UnloadedItem && ItemChecklistUI.vanillaIDsInSortOrder != null && ItemChecklistUI.vanillaIDsInSortOrder[i] != -1) // TODO, is this guaranteed? { totalItemsToFind++; findableItems[i] = true; diff --git a/ItemChecklistUI.cs b/ItemChecklistUI.cs index c232379..f7b7bfe 100644 --- a/ItemChecklistUI.cs +++ b/ItemChecklistUI.cs @@ -16,6 +16,8 @@ using Terraria.ModLoader; using Terraria.UI; using UIItemSlot = ItemChecklist.UIElements.UIItemSlot; +using Steamworks; +using System.Runtime.CompilerServices; namespace ItemChecklist { @@ -206,9 +208,8 @@ namespace ItemChecklist Item[] itemSlotItems = new Item[ItemLoader.ItemCount]; for (int i = 0; i < ItemLoader.ItemCount; i++) { - Item item = new Item(); - item.SetDefaults(i, false); // 300 ms vs 30 ms - if (item.type == 0) + Item item = ContentSamples.ItemsByType[i]; + if (item.type == ItemID.None) continue; itemSlots[i] = new UIItemSlot(item, i); itemSlotItems[i] = item; @@ -233,6 +234,23 @@ namespace ItemChecklist vanillaIDsInSortOrder[i] = Array.FindIndex(vanillaIDsInSortOrderTemp, x => x == i); } + List list = ContentSamples.ItemsByType.Values.ToList(); + IOrderedEnumerable> orderedEnumerable = from x in list + select new ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup(x) into x + group x by x.Group into @group + orderby (int)@group.Key + select @group; + int order = 0; + foreach (IGrouping item2 in orderedEnumerable) { + foreach (ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup item3 in item2) { + //vanillaIDsInSortOrder[order] = item3.ItemType; + // TODO...rename? + vanillaIDsInSortOrder[item3.ItemType] = order; + order++; + } + } + + modnames = new List() { "All", "Vanilla" }; modnames.AddRange(ModLoader.Mods.Where(mod => mod.GetContent().Any()).Select(x => x.Name)/*.Where(x => x != "ModLoader")*/); @@ -323,10 +341,13 @@ namespace ItemChecklist if (buttonsHaveDummyTextures) { - Texture2D foundFilterTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request("Images/filterFound"), 32, 32); + Main.instance.LoadItem(ItemID.Megaphone); + Main.instance.LoadItem(ItemID.Book); + + Texture2D foundFilterTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request("Images/filterFound", AssetRequestMode.ImmediateLoad), 32, 32); Texture2D muteButtonTexture = Utilities.ResizeImage(TextureAssets.Item[ItemID.Megaphone], 32, 32); //Texture2D sortButtonTexture = Utilities.ResizeImage(Main.itemTexture[ItemID.ToxicFlask], 32, 32); - Texture2D modFilterButtonTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request("Images/filterMod"), 32, 32); + Texture2D modFilterButtonTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request("Images/filterMod", AssetRequestMode.ImmediateLoad), 32, 32); Texture2D collectChestItemsButtonTexture = Utilities.ResizeImage(TextureAssets.Cursors[8], 32, 32); Texture2D showBadgeButtonTexture = Utilities.ResizeImage(TextureAssets.Item[ItemID.Book], 32, 32); // Main.extraTexture[58] @@ -451,6 +472,12 @@ namespace ItemChecklist updateNeeded = true; } + public override void Draw(SpriteBatch spriteBatch) { + if (buttonsHaveDummyTextures) + return; + base.Draw(spriteBatch); + } + protected override void DrawSelf(SpriteBatch spriteBatch) { ItemChecklistUI.hoverText = ""; diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..8da89ff --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,16 @@ +{ + "profiles": { + "Terraria": { + "commandName": "Executable", + "executablePath": "dotnet", + "commandLineArgs": "$(tMLPath)", + "workingDirectory": "$(tMLSteamPath)" + }, + "TerrariaServer": { + "commandName": "Executable", + "executablePath": "dotnet", + "commandLineArgs": "$(tMLServerPath)", + "workingDirectory": "$(tMLSteamPath)" + } + } +} \ No newline at end of file diff --git a/SharedUI.cs b/SharedUI.cs index 4137fa3..404e229 100644 --- a/SharedUI.cs +++ b/SharedUI.cs @@ -286,7 +286,7 @@ namespace ItemChecklist foreach (int type in itemTexturePreload) Main.instance.LoadItem(type); - //Texture2D terrariaSort = ResizeImage(Main.inventorySortTexture[1], 24, 24); + Texture2D terrariaSort = ResizeImage(TextureAssets.InventorySort[0], 24, 24); Texture2D rarity = ResizeImage(TextureAssets.Item[ItemID.MetalDetector], 24, 24); // TODO: Implement Badge text as used in Item Checklist. @@ -296,7 +296,7 @@ namespace ItemChecklist 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, (x,y)=> -ItemChecklistUI.vanillaIDsInSortOrder[x.type].CompareTo(ItemChecklistUI.vanillaIDsInSortOrder[y.type]), x=>ItemChecklistUI.vanillaIDsInSortOrder[x.type].ToString()), + new Sort("Terraria Sort", terrariaSort, ByCreativeSortingId, ByCreativeSortingIdBadgeText), }; Texture2D materialsIcon = Utilities.StackResizeImage(new[] { TextureAssets.Item[ItemID.SpellTome] }, 24, 24); @@ -590,6 +590,22 @@ namespace ItemChecklist SelectedCategory = categories[0]; } + private string ByCreativeSortingIdBadgeText(Item x) { + return ItemChecklistUI.vanillaIDsInSortOrder[x.type].ToString(); + } + + private int ByCreativeSortingId(Item x, Item y) { + return ItemChecklistUI.vanillaIDsInSortOrder[x.type].CompareTo(ItemChecklistUI.vanillaIDsInSortOrder[y.type]); + + ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup itemGroupAndOrderInGroup = ContentSamples.ItemCreativeSortingId[x.type]; + ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup itemGroupAndOrderInGroup2 = ContentSamples.ItemCreativeSortingId[y.type]; + int num = itemGroupAndOrderInGroup.Group.CompareTo(itemGroupAndOrderInGroup2.Group); + if (num == 0) + num = itemGroupAndOrderInGroup.OrderInGroup.CompareTo(itemGroupAndOrderInGroup2.OrderInGroup); + + return num; + } + // TODO: Update with new 1.4 values. Dictionary vanillaGrappleRanges = new Dictionary() { [13] = 300f, diff --git a/build.txt b/build.txt index fee0848..c027f95 100644 --- a/build.txt +++ b/build.txt @@ -1,12 +1,11 @@ author = jopojelly -version = 0.5.2 +version = 0.6 displayName = Item Checklist homepage = https://forums.terraria.org/index.php?threads/item-checklist-in-game-100-item-collection-checklist.52786/ hideCode = false hideResources = false includeSource = true -languageVersion = 6 includePDB = true notworkingside = Client buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, lib\*, .gitignore, .git\* -weakReferences = MagicStorage@0.4.3.1 +weakReferences = MagicStorage@0.5.7.4 diff --git a/icon_workshop.png b/icon_workshop.png new file mode 100644 index 0000000..cb4337d Binary files /dev/null and b/icon_workshop.png differ diff --git a/lib/MagicStorage_v0.4.3.1.dll b/lib/MagicStorage_v0.4.3.1.dll deleted file mode 100644 index cda4161..0000000 Binary files a/lib/MagicStorage_v0.4.3.1.dll and /dev/null differ diff --git a/lib/MagicStorage_v0.5.7.4.dll b/lib/MagicStorage_v0.5.7.4.dll new file mode 100644 index 0000000..6ad438d Binary files /dev/null and b/lib/MagicStorage_v0.5.7.4.dll differ