Skip to content

Commit

Permalink
v0.5, amazing sorts and categories, no longer ugly. 💃
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Aug 7, 2018
1 parent 5661e04 commit a56055c
Show file tree
Hide file tree
Showing 42 changed files with 2,055 additions and 234 deletions.
Binary file added Images/filterFound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Images/sortAZ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortAmmo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortAxe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortBait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortDamage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortDefense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortFish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortHammer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortItemID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortPick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/sortValue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 30 additions & 14 deletions ItemChecklist.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using Terraria.UI;
using Terraria.DataStructures;
using ItemChecklist.UI;
using Microsoft.Xna.Framework;
using System;

namespace ItemChecklist
{
// TODO: is ItemChecklistPlayer.foundItems a waste of memory? investigate and trim it down if needed.
// TODO: World Checklist? MP shared checklist?
// Has this item ever been seen on this world? - easy. Maintain separate bool array, on change, notify server, relay to clients.
// send bool array as byte array?
// query magic storage?
// WHY? I want to know everything we can craft yet
public class ItemChecklist : Mod
{
Expand All @@ -25,17 +22,27 @@ public class ItemChecklist : Mod

public ItemChecklist()
{
Properties = new ModProperties()
{
Autoload = true,
};
}

public override void Load()
{
// Latest uses ItemID.Sets.IsAMaterial, added 0.10.1.5
if (ModLoader.version < 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 = RegisterHotKey("Toggle Item Checklist", "I");
MagicStorageIntegration.Load();

if (!Main.dedServ)
{
UIElements.UICheckbox.checkboxTexture = GetTexture("UIElements/checkBox");
UIElements.UICheckbox.checkmarkTexture = GetTexture("UIElements/checkMark");
UIElements.UIHorizontalGrid.moreLeftTexture = GetTexture("UIElements/MoreLeft");
UIElements.UIHorizontalGrid.moreRightTexture = GetTexture("UIElements/MoreRight");
}
}

public override void Unload()
Expand All @@ -45,14 +52,19 @@ public override void Unload()
ToggleChecklistHotKey = null;
ItemChecklistInterface = null;
MagicStorageIntegration.Unload();

UIElements.UICheckbox.checkboxTexture = null;
UIElements.UICheckbox.checkmarkTexture = null;
UIElements.UIHorizontalGrid.moreLeftTexture = null;
UIElements.UIHorizontalGrid.moreRightTexture = null;
}

public override void AddRecipes()
{
if (!Main.dedServ)
{
ItemChecklistUI = new ItemChecklistUI();
ItemChecklistUI.Activate();
//ItemChecklistUI.Activate();
ItemChecklistInterface = new UserInterface();
ItemChecklistInterface.SetState(ItemChecklistUI);
}
Expand Down Expand Up @@ -96,6 +108,11 @@ internal void NewItem(int type)
OnNewItem?.Invoke(type);
}

public override void UpdateUI(GameTime gameTime)
{
ItemChecklistInterface?.Update(gameTime);
}

int lastSeenScreenWidth;
int lastSeenScreenHeight;
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
Expand All @@ -115,8 +132,7 @@ public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
lastSeenScreenWidth = Main.screenWidth;
lastSeenScreenHeight = Main.screenHeight;
}

ItemChecklistInterface.Update(Main._drawInterfaceGameTime);

ItemChecklistUI.Draw(Main.spriteBatch);

if (ItemChecklistUI.hoverText != "")
Expand Down
26 changes: 15 additions & 11 deletions ItemChecklist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,28 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Terraria, Version=1.3.5.1, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Terraria\Terraria.exe</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ItemChecklist.cs" />
<Compile Include="ItemChecklistGlobalItem.cs" />
<Compile Include="ItemChecklistPlayer.cs" />
<Compile Include="ItemChecklistUI.cs" />
<Compile Include="ItemSlot.cs" />
<Compile Include="MagicStorageIntegration.cs" />
<Compile Include="UICheckbox.cs" />
<Compile Include="UIGrid.cs" />
<Compile Include="UIHoverImageButton.cs" />
<Compile Include="UIToggleHoverImageButton.cs" />
<Compile Include="SharedUI.cs" />
<Compile Include="UIElements\NewUITextBox.cs" />
<Compile Include="UIElements\UICheckbox.cs" />
<Compile Include="UIElements\UIGrid.cs" />
<Compile Include="UIElements\UIHorizontalGrid.cs" />
<Compile Include="UIElements\UIHorizontalScrollbar.cs" />
<Compile Include="UIElements\UIHoverImageButton.cs" />
<Compile Include="UIElements\UIItemSlot.cs" />
<Compile Include="UIElements\UISilentImageButton.cs" />
<Compile Include="UIElements\UIToggleHoverImageButton.cs" />
<Compile Include="Utilities.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="build.txt" />
Expand All @@ -85,12 +95,6 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Modding\tModLoader\src\tModLoader\Terraria.csproj">
<Project>{3996d5fa-6e59-4fe4-9f2b-40eeef9645d5}</Project>
<Name>Terraria</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>"C:\Program Files (x86)\Steam\steamapps\common\Terraria\tModLoaderServer.exe" -build "$(ProjectDir)\" -eac "$(TargetPath)"</PostBuildEvent>
Expand Down
3 changes: 1 addition & 2 deletions ItemChecklistGlobalItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ItemChecklist.UI;
using Terraria;
using Terraria;
using Terraria.ModLoader;

namespace ItemChecklist
Expand Down
23 changes: 14 additions & 9 deletions ItemChecklistPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using ItemChecklist.UI;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.ModLoader;
Expand All @@ -30,7 +27,7 @@ class ItemChecklistPlayer : ModPlayer
internal int totalItemsFound; // eh, property? dunno.

// Because of save, these values inherit the last used setting while loading
internal SortModes sortModePreference = SortModes.TerrariaSort;
//internal SortModes sortModePreference = SortModes.TerrariaSort;
internal bool announcePreference;
internal bool findChestItemsPreference = true;
internal int showCompletedPreference;
Expand All @@ -44,6 +41,14 @@ public override void ProcessTriggers(TriggersSet triggersSet)
ItemChecklist.instance.ItemChecklistUI.UpdateNeeded();
}
ItemChecklistUI.visible = !ItemChecklistUI.visible;
// Debug assistance, allows for reinitializing RecipeBrowserUI
//if (!ItemChecklistUI.visible)
//{
// ItemChecklistUI.instance.RemoveAllChildren();
// var isInitializedFieldInfo = typeof(Terraria.UI.UIElement).GetField("_isInitialized", BindingFlags.Instance | BindingFlags.NonPublic);
// isInitializedFieldInfo.SetValue(ItemChecklistUI.instance, false);
// ItemChecklistUI.instance.Activate();
//}
}
}

Expand All @@ -53,7 +58,7 @@ public override void OnEnterWorld(Player player)
ItemChecklistUI.visible = false;
ItemChecklistUI.announce = announcePreference;
ItemChecklistUI.collectChestItems = findChestItemsPreference;
ItemChecklistUI.sortMode = sortModePreference;
//ItemChecklistUI.sortMode = sortModePreference;
ItemChecklistUI.showCompleted = showCompletedPreference;
ItemChecklist.instance.ItemChecklistUI.RefreshPreferences();
ItemChecklist.instance.ItemChecklistUI.UpdateNeeded();
Expand All @@ -78,7 +83,7 @@ public override void Initialize()

announcePreference = false;
findChestItemsPreference = true;
sortModePreference = SortModes.TerrariaSort;
//sortModePreference = SortModes.TerrariaSort;
showCompletedPreference = 0;
}
}
Expand Down Expand Up @@ -135,7 +140,7 @@ public override TagCompound Save()
return new TagCompound
{
["FoundItems"] = foundItems.Select(ItemIO.Save).ToList(),
["SortMode"] = (int)ItemChecklistUI.sortMode,
//["SortMode"] = (int)ItemChecklistUI.sortMode,
["Announce"] = ItemChecklistUI.announce, // Not saving default, saving last used....good thing?
["CollectChestItems"] = ItemChecklistUI.collectChestItems,
["ShowCompleted"] = ItemChecklistUI.showCompleted,
Expand All @@ -145,7 +150,7 @@ public override TagCompound Save()
public override void Load(TagCompound tag)
{
foundItems = tag.GetList<TagCompound>("FoundItems").Select(ItemIO.Load).ToList();
sortModePreference = (SortModes)tag.GetInt("SortMode");
//sortModePreference = (SortModes)tag.GetInt("SortMode");
announcePreference = tag.GetBool("Announce");
if (tag.ContainsKey("CollectChestItems")) // Missing tags get defaultvalue, which would be false, which isn't what we want.
findChestItemsPreference = tag.GetBool("CollectChestItems");
Expand Down
Loading

0 comments on commit a56055c

Please sign in to comment.