Skip to content

Commit

Permalink
v2.2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RealAgrair committed Mar 10, 2019
1 parent 816f86b commit 987bef0
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 132 deletions.
157 changes: 108 additions & 49 deletions InvTweaks.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI;

namespace InvTweaks
{
/* TODO LIST
* Somehow make UI work
*/
public class InvTweaks : Mod
{
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
Expand All @@ -20,60 +14,125 @@ public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
if (index != -1)
{
layers.Insert(index + 1,
new LegacyGameInterfaceLayer("Inventory Tweaks : Hotbar",
delegate
new LegacyGameInterfaceLayer("Inventory Tweaks : Hotbar", DrawExtraHotbarSlot,
InterfaceScaleType.UI));
}
}

private bool DrawExtraHotbarSlot()
{
if (!Main.gameMenu)
{
float oldScale = Main.inventoryScale;
Main.inventoryScale = .75f;
// FixMouse();
if (Main.playerInventory)
{
Main.inventoryScale = .85f;
int num = 20 + ((int)(Main.inventoryBackTexture.Width * Main.inventoryScale) + 4) * 10;
if (Main.mouseX > num
&& Main.mouseX < num + Main.inventoryBackTexture.Width * Main.inventoryScale
&& Main.mouseY > 20
&& Main.mouseY < 20 + Main.inventoryBackTexture.Width * Main.inventoryScale
&& IsAccessory(Main.mouseItem))
{
if (!Main.gameMenu)
Main.instance.MouseText(LMPlayer().extraSlotItem.HoverName, LMPlayer().extraSlotItem.rare);

// ItemSlot.Handle(ref LMPlayer().extraSlotItem, 0);
if (Main.mouseLeft && Main.mouseLeftRelease)
{
float oldScale = Main.inventoryScale;
Main.inventoryScale = .75f;
if (Main.playerInventory)
{
Main.inventoryScale = .85f;
int num = 20 + ((int)(Main.inventoryBackTexture.Width * Main.inventoryScale) + 4) * 10;
if (Main.mouseX > num
&& Main.mouseX < num + Main.inventoryBackTexture.Width * Main.inventoryScale
&& Main.mouseY > 20
&& Main.mouseY < 20 + Main.inventoryBackTexture.Width * Main.inventoryScale
&& ValidItem(Main.mouseItem))
{
ItemSlot.Handle(ref LMPlayer().extraSlotItem, 0);
}
ItemSlot.Draw(Main.spriteBatch, ref LMPlayer().extraSlotItem,
ItemSlot.Context.EquipAccessory, new Vector2(num, 20));
}
else
{
int num = 20;
for (int i = 0; i < Main.hotbarScale.Length; i++)
{
num += (int)(Main.inventoryBackTexture.Width * Main.hotbarScale[i]) + 4;
}
if (Main.mouseX > num
&& Main.mouseX < num + (int)(Main.inventoryBackTexture.Width * .75f)
&& Main.mouseY > 20
&& Main.mouseY < 20 + (int)(Main.inventoryBackTexture.Width * .75f)
&& ValidItem(Main.mouseItem))
{
ItemSlot.Handle(ref LMPlayer().extraSlotItem, 0);
}
ItemSlot.Draw(Main.spriteBatch, ref LMPlayer().extraSlotItem,
ItemSlot.Context.EquipAccessory, new Vector2(num, 25));
}
Main.inventoryScale = oldScale;
Swap(ref Main.mouseItem, ref LMPlayer().extraSlotItem);
}
return true;
},
InterfaceScaleType.UI));
else if (Main.mouseRight && Main.mouseRightRelease)
{
ItemSlot.SwapEquip(ref LMPlayer().extraSlotItem);
}
}
ItemSlot.Draw(Main.spriteBatch, ref LMPlayer().extraSlotItem,
ItemSlot.Context.EquipAccessory, new Vector2(num, 20));
}
else
{
int num = 20;
for (int i = 0; i < Main.hotbarScale.Length; i++)
{
num += (int)(Main.inventoryBackTexture.Width * Main.hotbarScale[i]) + 4;
}
if (Main.mouseX > num
&& Main.mouseX < num + (int)(Main.inventoryBackTexture.Width * .75f)
&& Main.mouseY > 20
&& Main.mouseY < 20 + (int)(Main.inventoryBackTexture.Width * .75f)
&& IsAccessory(Main.mouseItem))
{
Main.instance.MouseText(LMPlayer().extraSlotItem.HoverName, LMPlayer().extraSlotItem.rare);

// ItemSlot.Handle(ref LMPlayer().extraSlotItem, 0);
if (Main.mouseLeft && Main.mouseLeftRelease)
{
Swap(ref Main.mouseItem, ref LMPlayer().extraSlotItem);
}
else if (Main.mouseRight && Main.mouseRightRelease)
{
ItemSlot.SwapEquip(ref LMPlayer().extraSlotItem);
}
}
ItemSlot.Draw(Main.spriteBatch, ref LMPlayer().extraSlotItem,
ItemSlot.Context.EquipAccessory, new Vector2(num, 25));
}
// FixMouse(false);
Main.inventoryScale = oldScale;
}
return true;
}

#region Code given by direwolf, doesn't work in this situation anymore though
/*
int lastMouseXbak;
int lastMouseYbak;
int mouseXbak;
int mouseYbak;
int lastscreenWidthbak;
int lastscreenHeightbak;
private void FixMouse(bool fix = true)
{
if (fix)
{
lastMouseXbak = Main.lastMouseX;
lastMouseYbak = Main.lastMouseY;
mouseXbak = Main.mouseX;
mouseYbak = Main.mouseY;
lastscreenWidthbak = Main.screenWidth;
lastscreenHeightbak = Main.screenHeight;
PlayerInput.SetZoom_Unscaled();
PlayerInput.SetZoom_MouseInWorld();
}
else
{
Main.lastMouseX = lastMouseXbak;
Main.lastMouseY = lastMouseYbak;
Main.mouseX = mouseXbak;
Main.mouseY = mouseYbak;
Main.screenWidth = lastscreenWidthbak;
Main.screenHeight = lastscreenHeightbak;
}
}
*/
#endregion

private void Swap(ref Item f, ref Item s)
{
var temp = f;
f = s;
s = temp;
}

private InvTweaksPlayer LMPlayer()
{
return Main.player[Main.myPlayer].GetModPlayer(this, "InvTweaksPlayer") as InvTweaksPlayer;
}

private bool ValidItem(Item item)
private bool IsAccessory(Item item)
{
return item.IsAir || (!item.IsAir && (item.vanity
|| item.accessory
Expand Down
74 changes: 0 additions & 74 deletions InvTweaks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvTweaks", "InvTweaks.csproj", "{8298EAB6-0586-4BDA-9483-83624B66B13A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terraria", "D:\repos\tModLoader\src\tModLoader\Terraria.csproj", "{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleMod", "D:\repos\tModLoader\ExampleMod\ExampleMod.csproj", "{7773BDD8-037E-46DB-B842-B0EE41E74873}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -73,76 +69,6 @@ Global
{8298EAB6-0586-4BDA-9483-83624B66B13A}.WindowsServerRelease|Any CPU.Build.0 = Release|Any CPU
{8298EAB6-0586-4BDA-9483-83624B66B13A}.WindowsServerRelease|x86.ActiveCfg = Release|Any CPU
{8298EAB6-0586-4BDA-9483-83624B66B13A}.WindowsServerRelease|x86.Build.0 = Release|Any CPU
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|Any CPU.ActiveCfg = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|Any CPU.Build.0 = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|x86.ActiveCfg = WindowsServerDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|x86.Build.0 = WindowsServerDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxRelease|Any CPU.ActiveCfg = LinuxRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxRelease|x86.ActiveCfg = LinuxRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxRelease|x86.Build.0 = LinuxRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxServerRelease|Any CPU.ActiveCfg = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxServerRelease|x86.ActiveCfg = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.LinuxServerRelease|x86.Build.0 = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacRelease|Any CPU.ActiveCfg = MacRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacRelease|x86.ActiveCfg = MacRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacRelease|x86.Build.0 = MacRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacServerRelease|Any CPU.ActiveCfg = MacServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacServerRelease|x86.ActiveCfg = MacServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.MacServerRelease|x86.Build.0 = MacServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|Any CPU.ActiveCfg = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|Any CPU.Build.0 = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|x86.ActiveCfg = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|x86.Build.0 = LinuxServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsDebug|Any CPU.ActiveCfg = WindowsDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsDebug|x86.ActiveCfg = WindowsDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsDebug|x86.Build.0 = WindowsDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsRelease|Any CPU.ActiveCfg = WindowsRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsRelease|x86.ActiveCfg = WindowsRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsRelease|x86.Build.0 = WindowsRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerDebug|Any CPU.ActiveCfg = WindowsServerDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerDebug|x86.ActiveCfg = WindowsServerDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerDebug|x86.Build.0 = WindowsServerDebug|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerRelease|Any CPU.ActiveCfg = WindowsServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerRelease|x86.ActiveCfg = WindowsServerRelease|x86
{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.WindowsServerRelease|x86.Build.0 = WindowsServerRelease|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Debug|Any CPU.ActiveCfg = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Debug|x86.ActiveCfg = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Debug|x86.Build.0 = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxRelease|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxServerRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxServerRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxServerRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.LinuxServerRelease|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacRelease|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacServerRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacServerRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacServerRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.MacServerRelease|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Release|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Release|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.Release|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsDebug|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsDebug|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsDebug|x86.ActiveCfg = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsDebug|x86.Build.0 = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsRelease|x86.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerDebug|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerDebug|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerDebug|x86.ActiveCfg = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerDebug|x86.Build.0 = Debug|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerRelease|Any CPU.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerRelease|Any CPU.Build.0 = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerRelease|x86.ActiveCfg = Release|x86
{7773BDD8-037E-46DB-B842-B0EE41E74873}.WindowsServerRelease|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 5 additions & 3 deletions InvTweaksPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public override TagCompound Save()
};
}

// TODO: MAKE THIS SHIT WORK
#region TODO: MAKE THIS SHIT WORK
/*
public override bool ShiftClickSlot(Item[] inventory, int context, int slot)
{
if (!inventory[slot].IsAir)
{
if (context == ItemSlot.Context.ShopItem)
{
bool flag;
var num = Utils.CoinsCount(out flag, player.bank.item);
var num = Utils.CoinsCount(out bool flag, player.bank.item);
var num2 = Utils.CoinsCount(out flag, player.bank2.item);
var num3 = Utils.CoinsCount(out flag, player.bank3.item);
var num4 = Utils.CoinsCount(out flag, player.inventory);
Expand Down Expand Up @@ -75,5 +75,7 @@ public override bool ShiftClickSlot(Item[] inventory, int context, int slot)
}
return false;
}
*/
#endregion
}
}
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = Agrair
version = 2.2
version = 2.2.0.1
displayName = Inventory Tweaks
buildIgnore = .vs/, .csproj, bin/, obj/, LICENSE, .gitignore, .git, .sln, .user
includePDB = true
Expand Down
9 changes: 4 additions & 5 deletions description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

[i:109] Features:
[i:97] When you consume an item, and the same kind of item is in your inventory, it'll automatically go into your hand after use.
[i:97] A new inventory slot for your Spectre Hood/Helment, right click it to swap them out.
[i:97] Shift clicking shop slots will automatically buy as much of that item as you can. (WIP)
[i:97] A new hotbar slot for your Spectre Hood/Helment, right click it to swap them out.
[i:97] Shift clicking shop slots will automatically buy as much of that item as you can. (Unimplemented)

[i:75] Changelog for 1.2
[i:97] Removed shift clicking until it's fixed
[i:97] Fixed yet another bug with the extra accessory slot
[i:75] Changelog for 2.2.0.1
[i:97] Extra hotbar slot is faster by a couple milliseconds, cleaned up the code.

Report any issues through GitHub (homepage) or on Discord (Agrair#7746)

0 comments on commit 987bef0

Please sign in to comment.