Skip to content

Commit

Permalink
0.2.2 release, updated to tModLoader 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Jun 13, 2017
1 parent bc23141 commit 39a7dd6
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ script:
- echo "Mod Browser version is $version"
- export gitVersion=`git describe --abbrev=0 --tags`
- echo "git version is $gitVersion"
- if [[ "$version" = "$gitVersion" ]]; then echo "Version does match, no need to push release"; Deploy=no; else echo "Version does not match, need to push release"; git config --global user.email "[email protected]"; git config --global user.name "Travis CI"; git tag $version -a -m "TravisCI Autogenerated Release"; git push --quiet https://[email protected]/JavidPack/BossChecklist $version > /dev/null 2>&1; Deploy=yes; fi
- if [[ "$version" = "$gitVersion" ]]; then echo "Version does match, no need to push release"; Deploy=no; else echo "Version does not match, need to push release"; git config --global user.email "[email protected]"; git config --global user.name "Travis CI"; git tag $version -a -m "TravisCI Autogenerated Release"; Deploy=yes; fi
- echo $Deploy

before_deploy:
Expand Down
6 changes: 3 additions & 3 deletions ItemChecklist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ internal void NewItem(int type)

int lastSeenScreenWidth;
int lastSeenScreenHeight;
public override void ModifyInterfaceLayers(List<MethodSequenceListItem> layers)
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
int MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
if (MouseTextIndex != -1)
{
layers.Insert(MouseTextIndex, new MethodSequenceListItem(
layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
"ItemChecklist: Item Checklist",
delegate
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public override void ModifyInterfaceLayers(List<MethodSequenceListItem> layers)
}
return true;
},
null)
InterfaceScaleType.UI)
);
}
}
Expand Down
14 changes: 10 additions & 4 deletions ItemChecklist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<Reference Include="Microsoft.Xna.Framework.Xact">
<HintPath>..\..\solutiondlls\Microsoft.Xna.Framework.Xact.dll</HintPath>
</Reference>
<Reference Include="ReLogic">
<HintPath>..\..\..\Modding\tModLoader\references\ReLogic.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -59,9 +62,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="tModLoader">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Terraria\tModLoader.exe</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ItemChecklist.cs" />
Expand All @@ -81,9 +81,15 @@
<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\tModLoaderDebug.exe" -build "$(ProjectDir)\" -eac "$(TargetPath)"</PostBuildEvent>
<PostBuildEvent>"C:\Program Files (x86)\Steam\steamapps\common\Terraria\tModLoaderDebug.exe" -build "$(ProjectDir)\" -eac "$(TargetPath)"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion ItemChecklistGlobalItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal void ItemReceived(Item item)
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($"You found your first {item.Name}. {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind} {(100f*itemChecklistPlayer.totalItemsFound/itemChecklistPlayer.totalItemsToFind).ToString("0.00")}%");
}
ItemChecklist.instance.NewItem(item.type);
}
Expand Down
10 changes: 5 additions & 5 deletions ItemChecklistPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public override void Initialize()
if (!Main.dedServ)
{
foundItems = new List<Item>();
foundItem = new bool[Main.itemName.Length];
findableItems = new bool[Main.itemName.Length];
for (int i = 0; i < Main.itemName.Length; i++)
foundItem = new bool[ItemLoader.ItemCount];
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[i] != -1) // TODO, is this guaranteed?
{
Expand All @@ -71,7 +71,7 @@ public override void Initialize()
}
}

announcePreference = true;
announcePreference = false;
sortModePreference = SortModes.TerrariaSort;
showCompletedPreference = 0;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public override void Load(TagCompound tag)

foreach (var item in foundItems)
{
if (item.name != "Unloaded Item")
if (item.Name != "Unloaded Item")
{
foundItem[item.type] = true;
totalItemsFound++;
Expand Down
64 changes: 29 additions & 35 deletions ItemChecklistUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public override void OnInitialize()
checklistPanel.BackgroundColor = new Color(73, 94, 171);

foundFilterButton = new UIHoverImageButton(Main.itemTexture[ItemID.Book], "Cycle Found Filter: ??");
foundFilterButton.OnClick += ToggleFoundFilterButtonClicked;
foundFilterButton.OnClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true);
foundFilterButton.OnRightClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, false);
checklistPanel.Append(foundFilterButton);

muteButton = new UIToggleHoverImageButton(Main.itemTexture[ItemID.Megaphone], ItemChecklist.instance.GetTexture("closeButton"), "Toggle Messages", announce);
Expand All @@ -62,13 +63,15 @@ public override void OnInitialize()
checklistPanel.Append(muteButton);

sortButton = new UIHoverImageButton(Main.itemTexture[ItemID.ToxicFlask], "Cycle Sort Method: ??");
sortButton.OnClick += ToggleSortButtonClicked;
sortButton.OnClick += (a, b) => ToggleSortButtonClicked(a, b, true);
sortButton.OnRightClick += (a, b) => ToggleSortButtonClicked(a, b, false);
sortButton.Left.Pixels = spacing * 4 + 28 * 2;
sortButton.Top.Pixels = 4;
checklistPanel.Append(sortButton);

modFilterButton = new UIHoverImageButton(ItemChecklist.instance.GetTexture("filterMod"), "Cycle Mod Filter: ??");
modFilterButton.OnClick += ToggleModFilterButtonClicked;
modFilterButton.OnClick += (a, b) => ToggleModFilterButtonClicked(a, b, true);
modFilterButton.OnRightClick += (a, b) => ToggleModFilterButtonClicked(a, b, false);
modFilterButton.Left.Pixels = spacing * 6 + 28 * 3;
modFilterButton.Top.Pixels = 4;
checklistPanel.Append(modFilterButton);
Expand All @@ -93,9 +96,9 @@ public override void OnInitialize()
Append(checklistPanel);

// load time impact, do this on first show?
itemSlots = new ItemSlot[Main.itemName.Length];
Item[] itemSlotItems = new Item[Main.itemName.Length];
for (int i = 0; i < Main.itemName.Length; i++)
itemSlots = new ItemSlot[ItemLoader.ItemCount];
Item[] itemSlotItems = new Item[ItemLoader.ItemCount];
for (int i = 0; i < ItemLoader.ItemCount; i++)
{
itemSlots[i] = new ItemSlot(i);
itemSlotItems[i] = itemSlots[i].item;
Expand All @@ -107,15 +110,15 @@ public override void OnInitialize()
MethodInfo SortMethod = typeof(ItemSorting).GetMethod("Sort", BindingFlags.Static | BindingFlags.NonPublic);
object[] parametersArray = new object[] { itemSlotItems, new int[0] };

inventoryGlowHue.SetValue(null, new float[Main.itemName.Length]);
inventoryGlowTime.SetValue(null, new int[Main.itemName.Length]);
inventoryGlowHue.SetValue(null, new float[ItemLoader.ItemCount]);
inventoryGlowTime.SetValue(null, new int[ItemLoader.ItemCount]);
SortMethod.Invoke(null, parametersArray);
inventoryGlowHue.SetValue(null, new float[58]);
inventoryGlowTime.SetValue(null, new int[58]);

int[] vanillaIDsInSortOrderTemp = itemSlotItems.Select((x) => x.type).ToArray();
vanillaIDsInSortOrder = new int[Main.itemName.Length];
for (int i = 0; i < Main.itemName.Length; i++)
vanillaIDsInSortOrder = new int[ItemLoader.ItemCount];
for (int i = 0; i < ItemLoader.ItemCount; i++)
{
vanillaIDsInSortOrder[i] = Array.FindIndex(vanillaIDsInSortOrderTemp, x => x == i);
}
Expand All @@ -126,10 +129,10 @@ public override void OnInitialize()
updateneeded = true;
}

private void ToggleFoundFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement)
private void ToggleFoundFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
{
Main.PlaySound(SoundID.MenuTick);
showCompleted = ++showCompleted % 3;
showCompleted = (3 + showCompleted + (left ? 1 : -1)) % 3;
foundFilterButton.hoverText = "Cycle Found Filter: " + foundFilterStrings[showCompleted];
UpdateNeeded();
}
Expand All @@ -141,18 +144,18 @@ private void ToggleMuteButtonClicked(UIMouseEvent evt, UIElement listeningElemen
muteButton.SetEnabled(announce);
}

private void ToggleSortButtonClicked(UIMouseEvent evt, UIElement listeningElement)
private void ToggleSortButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
{
Main.PlaySound(SoundID.MenuTick);
sortMode = sortMode.Next();
sortMode = left ? sortMode.NextEnum() : sortMode.PreviousEnum();
sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString();
UpdateNeeded();
}

private void ToggleModFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement)
private void ToggleModFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
{
Main.PlaySound(SoundID.MenuTick);
currentMod = (currentMod + 1) % modnames.Count;
currentMod = (modnames.Count + currentMod + (left ? 1 : -1)) % modnames.Count;
modFilterButton.hoverText = "Cycle Mod Filter: " + modnames[currentMod];
UpdateNeeded();
}
Expand Down Expand Up @@ -185,7 +188,7 @@ internal void UpdateCheckboxes()
checklistGrid.Clear();

var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer<ItemChecklistPlayer>(ItemChecklist.instance);

var temp = new List<ItemSlot>();
for (int i = 0; i < itemChecklistPlayer.findableItems.Length; i++)
{
if (itemChecklistPlayer.findableItems[i])
Expand All @@ -196,24 +199,24 @@ internal void UpdateCheckboxes()
if (PassModFilter(itemSlots[i]))
{
ItemSlot box = itemSlots[i];

checklistGrid._items.Add(box);
checklistGrid._innerList.Append(box);
temp.Add(box);
}
}
}
}
checklistGrid.UpdateOrder();
checklistGrid._innerList.Recalculate();
checklistGrid.AddRange(temp);

if (lastfoundID > 0)
{
checklistGrid.Recalculate();
checklistGrid.Goto(delegate (UIElement element)
if (showCompleted != 1) // Don't Goto when unfound is the display mode.
{
ItemSlot itemSlot = element as ItemSlot;
return itemSlot != null && itemSlot.id == lastfoundID;
}, true);
checklistGrid.Goto(delegate (UIElement element)
{
ItemSlot itemSlot = element as ItemSlot;
return itemSlot != null && itemSlot.id == lastfoundID;
}, true);
}
lastfoundID = -1;
}
}
Expand Down Expand Up @@ -277,15 +280,6 @@ public override void MouseDown(UIMouseEvent evt)

public static class Extensions
{
public static T Next<T>(this T src) where T : struct
{
if (!typeof(T).IsEnum) throw new ArgumentException(String.Format("Argumnent {0} is not an Enum", typeof(T).FullName));

T[] Arr = (T[])Enum.GetValues(src.GetType());
int j = Array.IndexOf<T>(Arr, src) + 1;
return (Arr.Length == j) ? Arr[0] : Arr[j];
}

public static string ToFriendlyString(this SortModes sortmode)
{
switch (sortmode)
Expand Down
8 changes: 4 additions & 4 deletions ItemSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public override int CompareTo(object obj)
case SortModes.ID:
return id.CompareTo(other.id);
case SortModes.AZ:
return item.name.CompareTo(other.item.name);
return item.Name.CompareTo(other.item.Name);
case SortModes.Value:
result = item.value.CompareTo(other.item.value);
if (result == 0)
result = item.name.CompareTo(other.item.name);
result = item.Name.CompareTo(other.item.Name);
return result;
case SortModes.Rare:
result = item.rare.CompareTo(other.item.rare);
if (result == 0)
result = item.name.CompareTo(other.item.name);
result = item.Name.CompareTo(other.item.Name);
return result;
case SortModes.TerrariaSort:
return ItemChecklistUI.vanillaIDsInSortOrder[id].CompareTo(ItemChecklistUI.vanillaIDsInSortOrder[other.id]);
Expand Down Expand Up @@ -106,7 +106,7 @@ protected override void DrawSelf(SpriteBatch spriteBatch)

if (IsMouseHovering)
{
ItemChecklistUI.hoverText = item.name + (item.modItem != null ? " [" + item.modItem.mod.Name + "]" : "");
ItemChecklistUI.hoverText = item.Name + (item.modItem != null ? " [" + item.modItem.mod.Name + "]" : "");
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions UIGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ public virtual void Add(UIElement item)
this._innerList.Recalculate();
}

public virtual void AddRange(IEnumerable<UIElement> items)
{
this._items.AddRange(items);
foreach (var item in items)
this._innerList.Append(item);
this.UpdateOrder();
this._innerList.Recalculate();
}

public virtual bool Remove(UIElement item)
{
this._innerList.RemoveChild(item);
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = jopojelly
version = 0.2.1
version = 0.2.2
displayName = Item Checklist
homepage = https://forums.terraria.org/index.php?threads/item-checklist-in-game-100-item-collection-checklist.52786/
hideCode = false
Expand Down

0 comments on commit 39a7dd6

Please sign in to comment.