Skip to content

Commit

Permalink
v0.8.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Aug 8, 2019
1 parent 3cc70fe commit 7a36425
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 46 deletions.
2 changes: 1 addition & 1 deletion BestiaryUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private bool PassNPCFilters(UINPCSlot slot)
}
}

if (RecipeBrowserUI.modIndex != RecipeBrowserUI.instance.mods.Length - 1)
if (RecipeBrowserUI.modIndex != 0)
{
if (slot.npc.modNPC == null)
{
Expand Down
2 changes: 1 addition & 1 deletion ItemCatalogueUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ internal void SetItem(UIItemCatalogueItemSlot slot)

private bool PassItemFilters(UIItemCatalogueItemSlot slot)
{
if (RecipeBrowserUI.modIndex != RecipeBrowserUI.instance.mods.Length - 1)
if (RecipeBrowserUI.modIndex != 0)
{
if (slot.item.modItem == null)
{
Expand Down
2 changes: 1 addition & 1 deletion Localization/en-US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RecipeCatalogueUI.EmptyQuerySlotHint=Place item here

CraftUI.EmptyQuerySlotHint=Place item here
CraftUI.Calc=Calc
CraftUI.CalcTooltip=Toggles Preemptive Extended Craft Calculation in Recipes
CraftUI.CalcTooltip=Toggles Preemptive Extended Craft Calculation in Recipes\nCan cause lag
CraftUI.Loot=Loot
CraftUI.LootTooltip=Allow Farming in Craft Path (Only works for Enemies with Banners)
CraftUI.Shop=Shop
Expand Down
10 changes: 6 additions & 4 deletions Patches.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Harmony;
using System;
using System;
using System.Diagnostics;
using System.Linq;
using Terraria;
Expand All @@ -8,7 +7,7 @@ namespace RecipeBrowser
{
public static class Patches
{

private static bool AdjTilesActive = false;
public static void Apply()
{
// Patches are automatically unapplied on unload by TerrariaHooks. -ade
Expand All @@ -18,7 +17,8 @@ public static void Apply()
{
orig();

if (!new StackTrace().GetFrames().Any(x => x.GetMethod().Name.StartsWith("AdjTiles")))
if(!AdjTilesActive)
//if (!new StackTrace().GetFrames().Any(x => x.GetMethod().Name.StartsWith("AdjTiles")))
{
RecipeCatalogueUI.instance.InvalidateExtendedCraft();
//Main.NewText("FindRecipes postfix: InvalidateExtendedCraft");
Expand All @@ -31,6 +31,7 @@ public static void Apply()

// This patch will call FindRecipes even if the player inventory is closed, keeping Craft tool buttons accurate.
On.Terraria.Player.AdjTiles += (orig, player) => {
AdjTilesActive = true;
orig(player);

// AdjTiles does the opposite. This way recipes will be calculated
Expand All @@ -56,6 +57,7 @@ public static void Apply()
Recipe.FindRecipes();
}
}
AdjTilesActive = false;
};
}

Expand Down
3 changes: 1 addition & 2 deletions RecipeBrowser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Harmony;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Newtonsoft.Json;
using System;
Expand Down
6 changes: 3 additions & 3 deletions RecipeBrowserUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void PostSetupContent()
FieldInfo loadModsField = type.GetField("items", BindingFlags.Instance | BindingFlags.NonPublic);

mods = ModLoader.Mods.Where(mod => ((Dictionary<string, ModItem>)loadModsField.GetValue(mod)).Count > 0).Select(mod => mod.Name).ToArray();
modIndex = mods.Length - 1;
modIndex = 0;
}

public override void OnInitialize()
Expand Down Expand Up @@ -313,7 +313,7 @@ private void ModFilterButton_OnRightClick(UIMouseEvent evt, UIElement listeningE
private void ModFilterButton_OnMiddleClick(UIMouseEvent evt, UIElement listeningElement)
{
UIHoverImageButtonMod button = (evt.Target as UIHoverImageButtonMod);
modIndex = mods.Length - 1;
modIndex = 0;
button.hoverText = RBText("ModFilter") + ": " + RBText("All");
UpdateModHoverImage(button);
AllUpdateNeeded();
Expand All @@ -336,7 +336,7 @@ private void UpdateModHoverImage(UIHoverImageButtonMod button)
private string GetModFilterTooltip(bool increment)
{
modIndex = increment ? (modIndex + 1) % mods.Length : (mods.Length + modIndex - 1) % mods.Length;
return modIndex == mods.Length - 1 ? RBText("All") : mods[modIndex];
return modIndex == 0 ? RBText("All") : mods[modIndex];
}

internal void AllUpdateNeeded()
Expand Down
2 changes: 1 addition & 1 deletion RecipeCatalogueUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private int ItemGridSort(UIElement x, UIElement y)
private bool PassRecipeFilters(UIRecipeSlot recipeSlot, Recipe recipe, List<int> groups)
{
// TODO: Option to filter by source of Recipe rather than by createItem maybe?
if (RecipeBrowserUI.modIndex != RecipeBrowserUI.instance.mods.Length - 1)
if (RecipeBrowserUI.modIndex != 0)
{
if (recipe.createItem.modItem == null)
{
Expand Down
32 changes: 18 additions & 14 deletions RecipePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace RecipeBrowser
internal class RecipePathTester
{
//internal static IdDictionary Search;
internal static bool print = true;
internal static bool printResults = true;
internal static bool print = false;
internal static bool printResults = false;
//internal static bool printResultCounts = true;
//internal static bool calculateAll = false;
//internal static int calculateAllRepeat = 1;
Expand Down Expand Up @@ -272,11 +272,12 @@ private static void FindCraftPaths(List<CraftPath> paths, CraftPath inProgress,
if (token.IsCancellationRequested)
return;
// Some notion of limiting depth of tree might help.
//int count = inProgress.root.GetAllChildrenPreOrder().Count(); //.OfType<CraftPath.RecipeNode>()
//if (count > 20)
//{
// return;
//}
// TODO
// Limit by Total steps (TODO: steps only, not HAves)
int count = inProgress.root.GetAllChildrenPreOrder().Count(); //.OfType<CraftPath.RecipeNode>()
if (count > 20) {
return;
}

// Current will always be an unfulfilled
CraftPath.UnfulfilledNode current = inProgress.GetCurrent();
Expand Down Expand Up @@ -378,13 +379,16 @@ private static void FindCraftPaths(List<CraftPath> paths, CraftPath inProgress,
{
bool encountered = false;

int npc = loots[lootable.First()].First(); // Only checks 1 item in Group, and first NPC that drops it. Fix later.

int bannerID = Item.NPCtoBanner(npc);
if (bannerID > 0)
{
if (NPC.killCount[bannerID] > 0)
encountered = true;
// Only checks 1 item in Group. Fix later.
var npcs = loots[lootable.First()];
foreach (var npc in npcs) {
int bannerID = Item.NPCtoBanner(npc);
if (bannerID > 0) {
if (NPC.killCount[bannerID] > 0) {
encountered = true;
break;
}
}
}

if (encountered)
Expand Down
21 changes: 2 additions & 19 deletions UIElements/UIRecipeInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecipeBrowser.UIElements;
using System.Collections.Generic;
using System.Text;
using Terraria;
using Terraria.GameContent.UI.Elements;
using Terraria.ID;
using Terraria.Map;
using System.Text;
using Terraria;
using Terraria.GameContent.UI.Elements;
Expand Down Expand Up @@ -94,22 +88,11 @@ protected override void DrawSelf(SpriteBatch spriteBatch)
{
row++;
int tileID = selectedRecipe.requiredTile[tileIndex];
string tileName = Lang.GetMapObjectName(MapHelper.TileToLookup(tileID, 0));
if (tileName == "")
{
if (tileID < TileID.Count)
tileName = $"Tile {tileID}";
else
tileName = Terraria.ModLoader.TileLoader.GetTile(tileID).Name + " (err no entry)";
}
sb.Append($"{(comma ? ", " : "")}[c/{(Main.LocalPlayer.adjTile[tileID] ? yesColor : noColor).Hex3()}:{tileName}]");
sbTiles.Append($"{(comma ? ", " : "")}[c/{(Main.LocalPlayer.adjTile[tileID] ? yesColor : noColor).Hex3()}:{tileName}]");
//Terraria.UI.Chat.ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, tileName, new Vector2(positionX, positionY + num63), Main.LocalPlayer.adjTile[tileID] ? yesColor : noColor, 0f, Vector2.Zero, Vector2.One, -1f, 2f);
/* TODO: figure out if this code is still correct.
string tileName = Utilities.GetTileName(tileID);
//Terraria.UI.Chat.ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, tileName, new Vector2(positionX, positionY + num63), Main.LocalPlayer.adjTile[tileID] ? yesColor : noColor, 0f, Vector2.Zero, Vector2.One, -1f, 2f);
DoChatTag(sb, comma, Main.LocalPlayer.adjTile[tileID], tileName);
DoChatTag(sbTiles, comma, Main.LocalPlayer.adjTile[tileID], tileName);
*/

tileIndex++;
comma = true;
}
Expand Down

0 comments on commit 7a36425

Please sign in to comment.