From 86ae136636fd81e6d899c0cce1432c96c74e705e Mon Sep 17 00:00:00 2001 From: JavidPack Date: Thu, 12 Jul 2018 01:22:55 -0600 Subject: [PATCH] 0.2.1, snoop now lets you take and place items. Icon. Right click textbox to clear. Fix tab for login. --- HEROsModNetwork/GeneralMessages.cs | 9 +++- HEROsModNetwork/Network.cs | 1 + HEROsModServices/PlayerList.cs | 81 +++++++++++++++++++++++++---- UIKit/UITextbox.cs | 1 + build.txt | 2 +- icon.png | Bin 0 -> 3489 bytes 6 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 icon.png diff --git a/HEROsModNetwork/GeneralMessages.cs b/HEROsModNetwork/GeneralMessages.cs index 384eed7..7a9285c 100644 --- a/HEROsModNetwork/GeneralMessages.cs +++ b/HEROsModNetwork/GeneralMessages.cs @@ -209,6 +209,10 @@ public static void ProcessData(ref BinaryReader reader, int playerNumber) case MessageType.RequestTeleport: ProcessRequestTeleport(ref reader, playerNumber); break; + + case MessageType.SyncItemNonOwner: + HEROsModServices.SnoopWindow.ProcessSyncItemNonOwner(ref reader, playerNumber); + break; } } @@ -1222,7 +1226,7 @@ public static void RequestTeleport(Vector2 destination) Network.SendDataToServer(); } - private enum MessageType : byte + internal enum MessageType : byte { UsingHEROsMod, RequestTimeChange, @@ -1267,7 +1271,8 @@ private enum MessageType : byte RequestBanPlayer, RequestTeleport, RequestForcedSundial, - CurrentToggles + CurrentToggles, + SyncItemNonOwner } public enum TimeChangeType diff --git a/HEROsModNetwork/Network.cs b/HEROsModNetwork/Network.cs index 42f977d..0daf42f 100644 --- a/HEROsModNetwork/Network.cs +++ b/HEROsModNetwork/Network.cs @@ -991,6 +991,7 @@ public enum MessageType { GeneralMessage, LoginMessage, + SnoopMessage, CTFMessage } diff --git a/HEROsModServices/PlayerList.cs b/HEROsModServices/PlayerList.cs index 70527ec..2e12b00 100644 --- a/HEROsModServices/PlayerList.cs +++ b/HEROsModServices/PlayerList.cs @@ -1,8 +1,10 @@ using HEROsMod.UIKit; using HEROsMod.UIKit.UIComponents; using System; +using System.IO; using System.Linq; using Terraria; +using HEROsMod.HEROsModNetwork; namespace HEROsMod.HEROsModServices { @@ -416,7 +418,7 @@ private void dropdown_selectedChanged(object sender, EventArgs e) } else { - //send new group to servera + //send new group to server HEROsModNetwork.Group playersNewGroup = HEROsModNetwork.Network.GetGroupByName(dropdown.GetItem(dropdown.SelectedItem)); HEROsModNetwork.LoginService.RequestSetPlayerGroup(playerIndex, playersNewGroup); } @@ -453,8 +455,10 @@ public SnoopWindow() //itemsView.Y = spacing; for (int i = 0; i < 50; i++) { - Slot slot = new Slot(0, true); - slot.ItemChanged += ItemSlot_ItemChanged; + Slot slot = new Slot(0, false); + slot.functionalSlot = true; + int index = i; + slot.ItemChanged += (a, b) => ItemSlot_ItemChanged(slot, index); slot.X = 8 + i % 10 * slot.Width; slot.Y = 8 + i / 10 * slot.Height; @@ -465,20 +469,28 @@ public SnoopWindow() for (int i = 50; i < 58; i++) { int index = i - 50; - Slot slot = new Slot(0, true); + Slot slot = new Slot(0, false); + slot.functionalSlot = true; + int idx = i; + slot.ItemChanged += (a, b) => ItemSlot_ItemChanged(slot, idx); slot.Scale = .6f; slot.X = 8 + index % 2 * slot.Width; slot.Y = yPos + index / 2 * slot.Height; itemsView.AddChild(slot); } - Slot mouseSlot = new Slot(0, true); + Slot mouseSlot = new Slot(0, false); + mouseSlot.functionalSlot = true; + mouseSlot.ItemChanged += (a, b) => ItemSlot_ItemChanged(mouseSlot, 58); mouseSlot.X = itemsView.GetLastChild().X + itemsView.GetLastChild().Width + 4; mouseSlot.Y = itemsView.GetLastChild().Y + itemsView.GetLastChild().Height - mouseSlot.Height; itemsView.AddChild(mouseSlot); float xPos = mouseSlot.X + mouseSlot.Width + 4; for (int i = 0; i < 16; i++) { - Slot slot = new Slot(0, true); + Slot slot = new Slot(0, false); + slot.functionalSlot = true; + int index = i; + slot.ItemChanged += (a, b) => ItemSlot_ItemChanged(slot, index, true); slot.Scale = .7f; slot.X = xPos + i % 8 * slot.Width; slot.Y = yPos + i / 8 * slot.Height; @@ -498,10 +510,10 @@ public SnoopWindow() itemsView.AddChild(label); } - private void ItemSlot_ItemChanged(object sender, EventArgs e) + private void ItemSlot_ItemChanged(Slot slot, int index, bool armor = false) { - Slot slot = (Slot)sender; - + Main.playerInventory = true; + RequestSyncItemNonOwner(player, slot.item, index + (armor ? 59 : 0)); //ErrorLogger.Log("Slot " + slot.item.type); } @@ -527,5 +539,56 @@ public void SetPlayer(Player player) { this.player = player; } + + internal static void RequestSyncItemNonOwner(Player player, Item item, int index) + { + var packet = HEROsMod.instance.GetPacket(); + packet.Write((byte)Network.MessageType.GeneralMessage); + packet.Write((byte)GeneralMessages.MessageType.SyncItemNonOwner); + packet.Write((byte)player.whoAmI); + packet.Write((byte)index); + Terraria.ModLoader.IO.ItemIO.Send(item, packet, true); + packet.Send(); + } + + internal static void ProcessSyncItemNonOwner(ref BinaryReader reader, int playerNumber) + { + if (Main.netMode == Terraria.ID.NetmodeID.Server) + { + if (Network.Players[playerNumber].Group.HasPermission("Snoop")) + { + byte player = reader.ReadByte(); + int inventoryindex = reader.ReadByte(); + Item item = Terraria.ModLoader.IO.ItemIO.Receive(reader, true); + + var packet = HEROsMod.instance.GetPacket(); + packet.Write((byte)Network.MessageType.GeneralMessage); + packet.Write((byte)GeneralMessages.MessageType.SyncItemNonOwner); + packet.Write((byte)player); + packet.Write((byte)inventoryindex); + Terraria.ModLoader.IO.ItemIO.Send(item, packet, true); + packet.Send(player); + } + } + else + { + byte player = reader.ReadByte(); + int inventoryindex = reader.ReadByte(); + Item item = Terraria.ModLoader.IO.ItemIO.Receive(reader, true); + + if (player == Main.myPlayer) + { + if (inventoryindex < 59) + Main.LocalPlayer.inventory[inventoryindex] = item; + else + Main.LocalPlayer.armor[inventoryindex - 59] = item; + // send 5 or just let clientClone take care of it? + } + else + { + // Bug + } + } + } } } \ No newline at end of file diff --git a/UIKit/UITextbox.cs b/UIKit/UITextbox.cs index 1995497..ca72377 100644 --- a/UIKit/UITextbox.cs +++ b/UIKit/UITextbox.cs @@ -91,6 +91,7 @@ private string passwordString public UITextbox() { this.onLeftClick += new EventHandler(UITextbox_onLeftClick); + this.onRightClick += (a, b) => Text = ""; label.ForegroundColor = Color.Black; label.Scale = Height / label.Height; label.TextOutline = false; diff --git a/build.txt b/build.txt index 0395c7d..7c5ed61 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = HERO, jopojelly -version = 0.2.0.4 +version = 0.2.1 displayName = HERO's Mod homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/ buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4f414bc7eba33a9ac484b3c949d6dd783ce92c84 GIT binary patch literal 3489 zcmV;S4PNqzP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH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