public override void Draw(SpriteBatch spriteBatch, float maxWidth)
        {
            Color color = Hooking.GetRarityColor(Item);

            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, Text, Position, color, 0f, Vector2.Zero, Vector2.One);

            if (Item.favorited && Config.FavoriteUseIcon)
            {
                Main.spriteBatch.Draw(Main.cursorTextures[3], new Vector2(Position.X + maxWidth - 8f, Position.Y + GetSize().Y * 0.5f - 4f), null, Color.White, 0f, Main.cursorTextures[3].Size() * 0.5f, 1f, SpriteEffects.None, 0f);
            }
        }
        public static void hook(object parameter)
        {
            string exeName   = (string)parameter;
            Int32  TargetPID = 0;

            addresses[0] = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.EndScene);
            addresses[1] = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.SetStreamSource);
            addresses[2] = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.DrawIndexedPrimitive);
            addresses[3] = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.BeginScene);
            addresses[4] = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.Reset);

            if (addresses[0] == null || addresses[1] == null)
            {
                return;
            }

            TargetPID = Convert.ToInt32(d3d9Util.LookUpObject.FindProcessId(exeName));

            RemoteHooking.IpcCreateServer <D3DLoggerInterface>(ref ChannelName, WellKnownObjectMode.SingleCall, _interface);

            Hooking.hook(TargetPID, "Whatever descriptor", "D3DTextureLoggerClient.exe", "D3DTextureLogger.dll",
                         "D3DTextureLogger.dll", ChannelName, addresses);
        }
Example #3
0
        public override void UpdateInventory(Player player)
        {
            if (!active)
            {
                return;
            }

            for (int i = 0; i < Main.item.Length; i++)
            {
                ref Item it = ref Main.item[i];

                var item1 = it;
                if (it == null || it.IsAir || Vector2.Distance(it.Center, player.Center) > maxRange || player.Inventory().OfType <BaseBag>().All(bag => !bag.Handler.HasSpace(item1)))
                {
                    if (it != null && PSItem.BlackHoleData.ContainsKey(i))
                    {
                        PSItem.BlackHoleData.Remove(i);
                    }
                    continue;
                }

                if (!PSItem.BlackHoleData.ContainsKey(i))
                {
                    PSItem.BlackHoleData.Add(i, (1, 0));
                }

                if (PSItem.BlackHoleData[i].scale <= 0f)
                {
                    if (!ItemLoader.OnPickup(it, player))
                    {
                        it = new Item();
                    }
                    else if (ItemID.Sets.NebulaPickup[it.type])
                    {
                        int buffType = it.buffType;
                        it = new Item();

                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData(MessageID.NebulaLevelupRequest, -1, -1, null, player.whoAmI, buffType, player.Center.X, player.Center.Y);
                        }
                        else
                        {
                            player.NebulaLevelup(buffType);
                        }
                    }
                    else if (it.type == 58 || it.type == 1734 || it.type == 1867)
                    {
                        player.statLife += 20;
                        if (Main.myPlayer == player.whoAmI)
                        {
                            player.HealEffect(20);
                        }
                        if (player.statLife > player.statLifeMax2)
                        {
                            player.statLife = player.statLifeMax2;
                        }

                        it = new Item();
                    }
                    else if (it.type == 184 || it.type == 1735 || it.type == 1868)
                    {
                        player.statMana += 100;
                        if (Main.myPlayer == player.whoAmI)
                        {
                            player.ManaEffect(100);
                        }
                        if (player.statMana > player.statManaMax2)
                        {
                            player.statMana = player.statManaMax2;
                        }

                        it = new Item();
                    }
                    else
                    {
                        foreach (BaseBag bag in player.inventory.OfType <BaseBag>().OrderBy(bag => !bag.GetType().IsSubclassOf(typeof(BaseNormalBag))))
                        {
                            if (bag.Handler.HasSpace(it))
                            {
                                Item temp = it.Clone();

                                bag.Handler.InsertItem(ref it);

                                Hooking.BagItemText(bag.item, temp, temp.stack - it.stack, false, false);

                                if (it.IsAir || !it.active)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.SendData(MessageID.SyncItem, -1, -1, null, i);
                    }
                }
            }
Example #4
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            spriteBatch.DrawSlot(Dimensions, Color.White, backgroundTexture);

            float scale = Math.Min(Dimensions.Width / backgroundTexture.Width, Dimensions.Height / backgroundTexture.Height);

            if (!Item.IsAir)
            {
                Texture2D itemTexture = Main.itemTexture[Item.type];
                Rectangle rect        = Main.itemAnimations[Item.type] != null ? Main.itemAnimations[Item.type].GetFrame(itemTexture) : itemTexture.Frame();
                Color     newColor    = Color.White;
                float     pulseScale  = 1f;
                ItemSlot.GetItemLight(ref newColor, ref pulseScale, Item);
                int   height    = rect.Height;
                int   width     = rect.Width;
                float drawScale = 1f;

                float availableWidth = InnerDimensions.Width;
                if (width > availableWidth || height > availableWidth)
                {
                    if (width > height)
                    {
                        drawScale = availableWidth / width;
                    }
                    else
                    {
                        drawScale = availableWidth / height;
                    }
                }

                drawScale *= scale;
                Vector2 vector    = backgroundTexture.Size() * scale;
                Vector2 position2 = Dimensions.Position() + vector / 2f - rect.Size() * drawScale / 2f;
                Vector2 origin    = rect.Size() * (pulseScale / 2f - 0.5f);

                if (ItemLoader.PreDrawInInventory(Item, spriteBatch, position2, rect, Item.GetAlpha(newColor), Item.GetColor(Color.White), origin, drawScale * pulseScale))
                {
                    spriteBatch.Draw(itemTexture, position2, rect, Item.GetAlpha(newColor), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
                    if (Item.color != Color.Transparent)
                    {
                        spriteBatch.Draw(itemTexture, position2, rect, Item.GetColor(Color.White), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
                    }
                }

                ItemLoader.PostDrawInInventory(Item, spriteBatch, position2, rect, Item.GetAlpha(newColor), Item.GetColor(Color.White), origin, drawScale * pulseScale);
                if (ItemID.Sets.TrapSigned[Item.type])
                {
                    spriteBatch.Draw(Main.wireTexture, Dimensions.Position() + new Vector2(40f, 40f) * scale, new Rectangle(4, 58, 8, 8), Color.White, 0f, new Vector2(4f), 1f, SpriteEffects.None, 0f);
                }
                if (Stack > 1)
                {
                    ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, Stack < 1000 ? Stack.ToString() : Stack.ToSI("N0"), Dimensions.Position() + new Vector2(10f, 26f) * scale, Color.White, 0f, Vector2.Zero, new Vector2(scale), -1f, scale);
                }

                if (IsMouseHovering)
                {
                    Main.LocalPlayer.showItemIcon = false;
                    Main.ItemIconCacheUpdate(0);
                    Main.HoverItem       = Item.Clone();
                    Main.HoverItem.stack = Stack;
                    Main.hoverItemName   = Main.HoverItem.Name;

                    if (ItemSlot.ShiftInUse)
                    {
                        Hooking.SetCursor("Terraria/UI/Cursor_7");
                    }
                }
            }
        }
        internal static void OnSettingsUI(UIHelperBase helper)
        {
            int updateInterval = 0;

            if (Loader.IsActive)
            {
                updateInterval = TransferInfo.Data.DataShared.Data.updateInterval;
            }
            updateIntervalDropDown = (UIDropDown)helper.AddDropdown("Update interval", updateIntervalLabels, updateInterval, state =>
            {
                TransferInfo.Data.DataShared.Data.updateInterval = state;
            });
            var cleanGroup = helper.AddGroup("Before deleting this mod push \"Clean data\" button,\n" +
                                             "save the game, exit and unsubscribe from \"Transfer Info\"");

            cleanupButton = (UIButton)cleanGroup.AddButton("Clean data", () => { Serialization.CleanData(); Hooking.Cleanup(); });

            updateIntervalDropDown.isEnabled = Loader.IsActive;
            cleanupButton.isEnabled          = Loader.IsActive;

            helper.AddSpace(5);
            var globalGroup = helper.AddGroup("Global options");

            globalGroup.AddCheckbox("Enable debug logging", Options.debugEnabled, state => Options.debugEnabled.value = state);
        }