diff --git a/FullRareSetManager.dll b/FullRareSetManager.dll index 497630b..fb85ebe 100644 Binary files a/FullRareSetManager.dll and b/FullRareSetManager.dll differ diff --git a/FullRareSetManager.pdb b/FullRareSetManager.pdb index 2c4e9c3..fbb0104 100644 Binary files a/FullRareSetManager.pdb and b/FullRareSetManager.pdb differ diff --git a/src/FullRareSetManager/Core.cs b/src/FullRareSetManager/Core.cs index d12f381..c687c15 100644 --- a/src/FullRareSetManager/Core.cs +++ b/src/FullRareSetManager/Core.cs @@ -1,75 +1,59 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Windows.Forms; -using FullRareSetManager.SetParts; -using FullRareSetManager.Utilities; -using PoeHUD.Controllers; -using PoeHUD.Framework; -using PoeHUD.Models; -using PoeHUD.Models.Enums; -using PoeHUD.Models.Interfaces; -using PoeHUD.Plugins; -using PoeHUD.Poe.Components; -using PoeHUD.Poe.Elements; -using PoeHUD.Poe.RemoteMemoryObjects; -using SharpDX; -using PoeHUD.Hud.Menu; -using PoeHUD.Poe; -using System.Threading.Tasks; -using System.Diagnostics; -using PoeHUD.Hud.Menu.SettingsDrawers; -using PoeHUD.Hud.Settings; - -namespace FullRareSetManager +namespace FullRareSetManager { + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using System.Windows.Forms; + using FullRareSetManager.SetParts; + using FullRareSetManager.Utilities; + using PoeHUD.Controllers; + using PoeHUD.Framework; + using PoeHUD.Hud.Menu; + using PoeHUD.Hud.Menu.SettingsDrawers; + using PoeHUD.Hud.Settings; + using PoeHUD.Models; + using PoeHUD.Models.Enums; + using PoeHUD.Models.Interfaces; + using PoeHUD.Plugins; + using PoeHUD.Poe; + using PoeHUD.Poe.Components; + using PoeHUD.Poe.Elements; + using PoeHUD.Poe.RemoteMemoryObjects; + using SharpDX; + public class Core : BaseSettingsPlugin { + public ItemDisplayData[] DisplayData; + private const int INPUT_DELAY = 15; private bool _bDropAllItems; - - private Inventory _currentOpenedStashTab; private string _currentOpenedStashTabName; + private string _drawInfoString = string.Empty; + private Inventory _currentOpenedStashTab; private CurrentSetInfo _currentSetData; - private string _drawInfoString = ""; private DropAllToInventory _inventDrop; - private BaseSetPart[] _itemSetTypes; private StashData _sData; - public ItemDisplayData[] DisplayData; - public Core() { - PluginName = "Rare Set Manager"; - } - - private void ExternalUpdateStashes(object[] args) - { - if (!Settings.Enable.Value) return; - Thread.Sleep(70); - UpdateStashes(); - UpdatePlayerInventory(); - UpdateItemsSetsInfo(); + this.PluginName = "Rare Set Manager"; } public override void Initialise() { _sData = StashData.Load(this); - if (_sData == null) { - LogMessage( - "RareSetManager: Can't load cached items from file StashData.json. Creating new config. Open stash tabs for updating info. Tell to developer if this happen often enough.", - 10); + LogMessage("RareSetManager: Can't load cached items from file StashData.json. Creating new config. Open stash tabs for updating info.", 10); _sData = new StashData(); } _inventDrop = new DropAllToInventory(this); - DisplayData = new ItemDisplayData[8]; - for (var i = 0; i <= 7; i++) { DisplayData[i] = new ItemDisplayData(); @@ -77,14 +61,25 @@ public override void Initialise() UpdateItemsSetsInfo(); - Settings.WeaponTypePriority.SetListValues(new List {"Two handed", "One handed"}); - + Settings.WeaponTypePriority.SetListValues(new List { "Two handed", "One handed" }); Settings.CalcByFreeSpace.OnValueChanged += UpdateItemsSetsInfo; GameController.Area.OnAreaChange += OnAreaChange; MenuPlugin.KeyboardMouseEvents.MouseDown += OnMouseEvent; API.SubscribePluginEvent("StashUpdate", ExternalUpdateStashes); } + private void ExternalUpdateStashes(object[] args) + { + if (!Settings.Enable.Value) + { + return; + } + + Thread.Sleep(70); + this.UpdateStashes(); + this.UpdatePlayerInventory(); + this.UpdateItemsSetsInfo(); + } private void OnAreaChange(AreaController area) { @@ -94,7 +89,10 @@ private void OnAreaChange(AreaController area) public override void Render() { - if (!GameController.Game.IngameState.InGame) return; + if (!GameController.Game.IngameState.InGame) + { + return; + } var needUpdate = UpdatePlayerInventory(); var ingameState = GameController.Game.IngameState; @@ -107,7 +105,7 @@ public override void Render() if (needUpdate) { - //Thread.Sleep(100);//Wait until item be placed to player invent. There should be some delay + Thread.Sleep(10); //Wait until item be placed to player invent. There should be some delay UpdateItemsSetsInfo(); } @@ -145,37 +143,81 @@ public override void Render() _bDropAllItems = true; } } - SellSetToVendor(); } } + /* + public void OpenNpcTradewindow(Element merchantMenu) + { + var gameWindow = GameController.Window.GetWindowRectangle().TopLeft; + var sellItemsButton = merchantMenu.Children[0].Children[2].Children[23]; + Mouse.SetCursorPosAndLeftClick(sellItemsButton.GetClientRect().Center + gameWindow, Settings.ExtraDelay); + } + */ public void SellSetToVendor(int callCount = 1) { try { // Sell to vendor. var gameWindow = GameController.Window.GetWindowRectangle().TopLeft; - var latency = (int) GameController.Game.IngameState.CurLatency; - var npcTradingWindow = GameController.Game.IngameState.UIRoot + var latency = (int)GameController.Game.IngameState.CurLatency; + var cursorPosPreMoving = Mouse.GetCursorPosition(); + var npcTradingWindowRoot = GameController.Game.IngameState.UIRoot .Children[1] - .Children[70] - .Children[3]; + .Children[74]; - if (!npcTradingWindow.IsVisible) + if (npcTradingWindowRoot.ChildCount != 4) { + var merchantMenu = GameController.Game.IngameState.UIRoot. + Children[1]. + Children[18]. + Children[6]; // The vendor sell window is not open, but is in memory (it would've went straigth to catch if that wasn't the case). - LogMessage("Error: npcTradingWindow is not visible (opened)!", 5); - } + try + { + if (merchantMenu.IsVisible) + { + var merchantContextMenu = merchantMenu.Children[0].Children[2]; + var SellItemsButton = merchantContextMenu.Children[0]; + for (int i = 2; i < (int)merchantContextMenu.ChildCount; ++i) + { + try + { + if (merchantContextMenu.Children[i].Children[0].Text == "Sell Items") + { + SellItemsButton = merchantContextMenu.Children[i]; + break; + } + } + catch + { + continue; + } + } + //opening + Mouse.SetCursorPosAndLeftClick(SellItemsButton.GetClientRect().Center + gameWindow, extraDelay: Settings.ExtraDelay); + } + } + catch + { + LogMessage("Error: Merchant Window couldn't be opened", 5); + } + } + var npcTradingWindow = GameController.Game.IngameState.UIRoot + .Children[1] + .Children[74] + .Children[3]; var playerOfferItems = npcTradingWindow.Children[0]; const int setItemsCount = 9; const int uiButtonsCount = 2; - LogMessage($"Player has put in {playerOfferItems.ChildCount - uiButtonsCount} in the trading window.", - 3); + + ////LogMessage($"Player has put in {playerOfferItems.ChildCount - uiButtonsCount} in the trading window.",3); + ////LogMessage($"playerOfferItems.Childcount == {playerOfferItems.ChildCount}",3); if (playerOfferItems.ChildCount < setItemsCount + uiButtonsCount) { - for (var i = 0; i < 8; i++) + for (var i = 0; i < setItemsCount - 1; i++) { var itemType = _itemSetTypes[i]; var items = itemType.GetPreparedItems(); @@ -199,7 +241,6 @@ public void SellSetToVendor(int callCount = 1) return; } - Thread.Sleep(INPUT_DELAY); Mouse.SetCursorPosAndLeftClick(foundItem.GetClientRect().Center + gameWindow, Settings.ExtraDelay); @@ -221,9 +262,17 @@ public void SellSetToVendor(int callCount = 1) } var itemName = GameController.Files.BaseItemTypes.Translate(item.Path).BaseName; - if (itemName == "Chaos Orb" || itemName == "Regal Orb") continue; + if (itemName == "Chaos Orb" || itemName == "Regal Orb") + { + continue; + } + LogMessage($"Npc offered '{itemName}'", 3); - if (callCount >= 5) return; + if (callCount >= 5) + { + return; + } + var delay = INPUT_DELAY + Settings.ExtraDelay.Value; LogMessage($"Trying to sell set again in {delay} ms.", 3); Thread.Sleep(delay); @@ -239,6 +288,8 @@ public void SellSetToVendor(int callCount = 1) { Mouse.SetCursorPosAndLeftClick(acceptButton.GetClientRect().Center + gameWindow, Settings.ExtraDelay.Value); + Thread.Sleep(INPUT_DELAY); + Mouse.SetCursorPos(cursorPosPreMoving); } else { @@ -247,10 +298,8 @@ public void SellSetToVendor(int callCount = 1) } catch { - LogMessage("We hit catch!", 3); - Keyboard.KeyUp(Keys.LControlKey); + LogMessage("We hit catch!", 5); Thread.Sleep(INPUT_DELAY); - // We are not talking to a vendor. } } @@ -259,11 +308,11 @@ public void DropAllItems() var stashPanel = GameController.Game.IngameState.ServerData.StashPanel; var stashNames = stashPanel.AllStashNames; var gameWindowPos = GameController.Window.GetWindowRectangle(); - var latency = (int) GameController.Game.IngameState.CurLatency + Settings.ExtraDelay; + var latency = (int)GameController.Game.IngameState.CurLatency + Settings.ExtraDelay; var cursorPosPreMoving = Mouse.GetCursorPosition(); // Iterrate through all the different item types. - for (var i = 0; i < 8; i++) //Check that we have enough items for any set + for (var i = 0; i < 8; i++) // Check that we have enough items for any set { var part = _itemSetTypes[i]; var items = part.GetPreparedItems(); @@ -287,16 +336,16 @@ public void DropAllItems() // Switch to the tab we want to go to. if (!_inventDrop.SwitchToTab(invIndex, Settings)) { - //throw new Exception("Can't switch to tab"); + // throw new Exception("Can't switch to tab"); Keyboard.KeyUp(Keys.LControlKey); return; } Thread.Sleep(latency + Settings.ExtraDelay); + // Get the current visible stash tab. _currentOpenedStashTab = stashPanel.VisibleStash; - var item = curPreparedItem; var foundItem = _currentOpenedStashTab.VisibleInventoryItems.Find( @@ -313,7 +362,7 @@ public void DropAllItems() if (_currentOpenedStashTab.VisibleInventoryItems.Count == curItemsCount) { - //LogError("Item was not dropped?? : " + curPreparedItem.ItemName + ", checking again...", 10); + ////LogError("Item was not dropped?? : " + curPreparedItem.ItemName + ", checking again...", 10); Thread.Sleep(200); if (_currentOpenedStashTab.VisibleInventoryItems.Count == curItemsCount) @@ -330,7 +379,7 @@ public void DropAllItems() $"Inventory Position: ({item.InventPosX},{item.InventPosY})", 5); } - //Thread.Sleep(200); + ////Thread.Sleep(200); if (!UpdateStashes()) { LogError("There was item drop but it don't want to update stash!", 10); @@ -343,7 +392,7 @@ public void DropAllItems() } Keyboard.KeyUp(Keys.LControlKey); - //part.RemovePreparedItems(); + ////part.RemovePreparedItems(); } UpdatePlayerInventory(); @@ -355,7 +404,7 @@ public void DropAllItems() private void DrawSetsInfo() { var stash = GameController.Game.IngameState.ServerData.StashPanel; - var leftPanelOpened = stash.IsVisible; + bool leftPanelOpened = stash.IsVisible; if (leftPanelOpened) { @@ -367,9 +416,9 @@ private void DrawSetsInfo() { var stashTabRect = _currentOpenedStashTab.InventoryUiElement.GetClientRect(); - var setItemsListRect = new RectangleF(stashTabRect.Right, stashTabRect.Bottom, 270, 240); + var setItemsListRect = new RectangleF(stashTabRect.Right, stashTabRect.Bottom + 25, 270, 240); Graphics.DrawBox(setItemsListRect, new Color(0, 0, 0, 200)); - Graphics.DrawFrame(setItemsListRect, 2, Color.White); + Graphics.DrawFrame(setItemsListRect, 1, Color.White); var drawPosX = setItemsListRect.X + 10; var drawPosY = setItemsListRect.Y + 10; @@ -377,7 +426,7 @@ private void DrawSetsInfo() Graphics.DrawText("Current " + (_currentSetData.SetType == 1 ? "Chaos" : "Regal") + " set:", 15, new Vector2(drawPosX, drawPosY)); - drawPosY += 25; + drawPosY += 15; for (var i = 0; i < 8; i++) { @@ -414,8 +463,8 @@ private void DrawSetsInfo() Graphics.DrawText( curPreparedItem.StashName + " (" + curPreparedItem.ItemName + ") " + - (curPreparedItem.LowLvl ? "L" : "H"), 15, new Vector2(drawPosX, drawPosY), color); - drawPosY += 20; + (curPreparedItem.itemlvl < 75 ? "L" : "H"), 15, new Vector2(drawPosX, drawPosY), color); + drawPosY += 15; } } } @@ -445,7 +494,6 @@ private void DrawSetsInfo() Graphics.DrawBox(rect, new Color(0, 0, 0, 200)); Graphics.DrawFrame(rect, 2, Color.White); - posX += 10; posY += 10; Graphics.DrawText(_drawInfoString, 15, new Vector2(posX, posY)); @@ -453,10 +501,12 @@ private void DrawSetsInfo() private void UpdateItemsSetsInfo() { - _currentSetData = new CurrentSetInfo(); + var stashPanel = GameController.Game.IngameState.ServerData.StashPanel; + _currentOpenedStashTab = stashPanel.VisibleStash; + _currentSetData = new CurrentSetInfo(); _itemSetTypes = new BaseSetPart[8]; - _itemSetTypes[0] = new WeaponItemsSetPart("Weapons") {ItemCellsSize = 8}; + _itemSetTypes[0] = new WeaponItemsSetPart("Weapons") {ItemCellsSize = 6}; _itemSetTypes[1] = new SingleItemSetPart("Helmets") {ItemCellsSize = 4}; _itemSetTypes[2] = new SingleItemSetPart("Body Armors") {ItemCellsSize = 6}; _itemSetTypes[3] = new SingleItemSetPart("Gloves") {ItemCellsSize = 4}; @@ -465,15 +515,14 @@ private void UpdateItemsSetsInfo() _itemSetTypes[6] = new SingleItemSetPart("Amulets") {ItemCellsSize = 1}; _itemSetTypes[7] = new RingItemsSetPart("Rings") {ItemCellsSize = 1}; - for (var i = 0; i <= 7; i++) + for (int i = 0; i <= 7; ++i) { DisplayData[i].BaseData = _itemSetTypes[i]; } - foreach (var item in _sData.PlayerInventory.StashTabItems) { - var index = (int) item.ItemType; + var index = (int)item.ItemType; if (index > 7) { @@ -486,14 +535,13 @@ private void UpdateItemsSetsInfo() } const int StashCellsCount = 12 * 12; - + foreach (var stash in _sData.StashTabs) { var stashTabItems = stash.Value.StashTabItems; foreach (var item in stashTabItems) { - var index = (int) item.ItemType; - + var index = (int)item.ItemType; if (index > 7) { index = 0; // Switch One/TwoHanded to 0(weapon) @@ -505,33 +553,35 @@ private void UpdateItemsSetsInfo() setPart.StashTabItemsCount = stashTabItems.Count; } } - - //Calculate sets: + // Calculate sets: _drawInfoString = ""; var chaosSetMaxCount = 0; - var regalSetMaxCount = int.MaxValue; var minItemsCount = int.MaxValue; var maxItemsCount = 0; - - for (var i = 0; i <= 7; i++) //Check that we have enough items for any set + for (var i = 0; i <= 7; i++) // Check that we have enough items for any set { var setPart = _itemSetTypes[i]; - var low = setPart.LowSetsCount(); var high = setPart.HighSetsCount(); var total = setPart.TotalSetsCount(); if (minItemsCount > total) + { minItemsCount = total; - + } + if (maxItemsCount < total) + { maxItemsCount = total; - + } + if (regalSetMaxCount > high) + { regalSetMaxCount = high; - + } + chaosSetMaxCount += low; _drawInfoString += setPart.GetInfoString() + "\r\n"; @@ -548,16 +598,20 @@ private void UpdateItemsSetsInfo() (setPart.StashTabItemsCount + setPart.PlayerInventItemsCount()); if (drawInfo.FreeSpaceCount < 0) + { drawInfo.FreeSpaceCount = 0; + } - drawInfo.PriorityPercent = (float) drawInfo.FreeSpaceCount / totalPossibleStashItemsCount; + drawInfo.PriorityPercent = (float)drawInfo.FreeSpaceCount / totalPossibleStashItemsCount; if (drawInfo.PriorityPercent > 1) + { drawInfo.PriorityPercent = 1; + } + drawInfo.PriorityPercent = 1 - drawInfo.PriorityPercent; } } - if (!Settings.CalcByFreeSpace.Value) { var maxSets = maxItemsCount; @@ -572,13 +626,17 @@ private void UpdateItemsSetsInfo() var drawInfo = DisplayData[i]; if (drawInfo.TotalCount == 0) + { drawInfo.PriorityPercent = 0; + } else { - drawInfo.PriorityPercent = (float) drawInfo.TotalCount / maxSets; + drawInfo.PriorityPercent = (float)drawInfo.TotalCount / maxSets; if (drawInfo.PriorityPercent > 1) + { drawInfo.PriorityPercent = 1; + } } } } @@ -605,7 +663,7 @@ private void UpdateItemsSetsInfo() var replaceIndex = -1; var isLowSet = false; - for (var i = 0; i < 8; i++) //Check that we have enough items for any set + for (var i = 0; i < 8; i++) // Check that we have enough items for any set { var part = _itemSetTypes[i]; var prepareResult = part.PrepareItemForSet(Settings); @@ -632,7 +690,7 @@ private void UpdateItemsSetsInfo() if (maxAvailableReplaceCount == 0) { - //LogMessage("You want to make a regal set anyway? Ok.", 2); + ////LogMessage("You want to make a regal set anyway? Ok.", 2); _currentSetData.BSetIsReady = true; _currentSetData.SetType = 2; return; @@ -685,11 +743,13 @@ public bool UpdateStashes() } var stash = stashPanel.GetStashInventoryByIndex(i); - var visibleInventoryItems = stash?.VisibleInventoryItems; + if (visibleInventoryItems == null) + { continue; - + } + _currentOpenedStashTab = stash; _currentOpenedStashTabName = stashName; @@ -720,7 +780,6 @@ public bool UpdateStashes() continue; } - newStashItem.StashName = stashName; newStashItem.InventPosX = invItem.InventPosX; newStashItem.InventPosY = invItem.InventPosY; @@ -728,7 +787,7 @@ public bool UpdateStashes() curStashData.StashTabItems.Add(newStashItem); } - curStashData.ItemsCount = (int) stash.ItemCount; + curStashData.ItemsCount = (int)stash.ItemCount; if (add && curStashData.ItemsCount > 0) { @@ -742,7 +801,7 @@ public bool UpdateStashes() ? Settings.AllowedStashTabs.Select(x => x.Name).ToList() : stashPanel.AllStashNames; - var keyTabs = _sData.StashTabs.Keys.ToList(); //Delete stashes that doesn't exist + var keyTabs = _sData.StashTabs.Keys.ToList(); // Delete stashes that doesn't exist foreach (var stashNameInUse in keyTabs) { if (!workingTabs.Contains(stashNameInUse)) @@ -777,20 +836,28 @@ private bool UpdatePlayerInventory() var invItems = inventory.VisibleInventoryItems; - if (invItems == null) return true; + if (invItems == null) + { + return true; + } + foreach (var invItem in invItems) { var item = invItem.Item; var newAddedItem = ProcessItem(item); - if (newAddedItem == null) continue; + if (newAddedItem == null) + { + continue; + } + newAddedItem.InventPosX = invItem.InventPosX; newAddedItem.InventPosY = invItem.InventPosY; newAddedItem.BInPlayerInventory = true; _sData.PlayerInventory.StashTabItems.Add(newAddedItem); } - _sData.PlayerInventory.ItemsCount = (int) inventory.ItemCount; + _sData.PlayerInventory.ItemsCount = (int)inventory.ItemCount; return true; } @@ -815,10 +882,15 @@ private void OnMouseEvent(object sender, MouseEventArgs e) var filteredItemResult = ProcessItem(item); - if (filteredItemResult == null) return; + if (filteredItemResult == null) + { + return; + } if (++CurPickItemCount > long.MaxValue) + { CurPickItemCount = 0; + } Task.Factory.StartNew(async () => { @@ -828,18 +900,26 @@ private void OnMouseEvent(object sender, MouseEventArgs e) { await Task.Delay(30); - //We want to prevent the item was added more than once + // We want to prevent the item was added more than once if (curItemPickCount != CurPickItemCount) + { return; + } + + if (sw.ElapsedMilliseconds <= 10000) + { + continue; + } - if (sw.ElapsedMilliseconds <= 10000) continue; sw.Stop(); break; } - //We want to prevent the item was added more than once + // We want to prevent the item was added more than once if (curItemPickCount != CurPickItemCount) + { return; + } if (!item.IsValid) { @@ -863,10 +943,12 @@ private StashItem ProcessItem(IEntity item) { try { - if (item == null) return null; + if (item == null) + { + return null; + } var mods = item?.GetComponent(); - if (mods?.ItemRarity != ItemRarity.Rare) { return null; @@ -886,7 +968,7 @@ private StashItem ProcessItem(IEntity item) var newItem = new StashItem { BIdentified = bIdentified, - LowLvl = mods.ItemLevel < 75 + itemlvl = mods.ItemLevel }; if (string.IsNullOrEmpty(item.Path)) @@ -899,18 +981,20 @@ private StashItem ProcessItem(IEntity item) { var baseComp = item.GetComponent(); if (baseComp.isElder || baseComp.isShaper) + { return null; + } } var bit = GameController.Files.BaseItemTypes.Translate(item.Path); - if (bit == null) + { return null; + } + newItem.ItemClass = bit.ClassName; newItem.ItemName = bit.BaseName; newItem.ItemType = GetStashItemTypeByClassName(newItem.ItemClass); - - if (newItem.ItemType != StashItemType.Undefined) { return newItem; @@ -970,7 +1054,7 @@ public override void InitializeSettingsMenu() AllowedStashTabsRoot = new CheckboxSettingDrawer(Settings.OnlyAllowedStashTabs, "Allowed Stash Tabs", GetUniqDrawerId()); - SettingsDrawers.Add(AllowedStashTabsRoot); //Adding checkbox to settings menu drawers + SettingsDrawers.Add(AllowedStashTabsRoot); // Adding checkbox to settings menu drawers var addTabButton = new ButtonNode(); var addTabButtonDrawer = new ButtonSettingDrawer(addTabButton, "Add Stash Tab", GetUniqDrawerId()); @@ -996,45 +1080,44 @@ private void AddAllowedStashTabNode(StashTabNode node) AllowedStashTabsRoot.Children.Insert(AllowedStashTabsRoot.Children.Count - 1, deleteTabButtonDrawer); var buttonSameLineDrawer = - new SameLineSettingDrawer("", GetUniqDrawerId()); //Delete button and stash node should be on same line + new SameLineSettingDrawer("", GetUniqDrawerId()); // Delete button and stash node should be on same line AllowedStashTabsRoot.Children.Insert(AllowedStashTabsRoot.Children.Count - 1, buttonSameLineDrawer); var stashNodeDrawer = new StashTabNodeSettingDrawer(node, "", GetUniqDrawerId()); AllowedStashTabsRoot.Children.Insert(AllowedStashTabsRoot.Children.Count - 1, - stashNodeDrawer); //AllowedStashTabsRoot.Children.Count - 1, - + stashNodeDrawer); ////AllowedStashTabsRoot.Children.Count - 1, deleteTabButton.OnPressed += delegate { - //Delete stash node related drawers + // Delete stash node related drawers AllowedStashTabsRoot.Children.Remove(deleteTabButtonDrawer); AllowedStashTabsRoot.Children.Remove(buttonSameLineDrawer); AllowedStashTabsRoot.Children.Remove(stashNodeDrawer); Settings.AllowedStashTabs.Remove(stashNodeDrawer.StashNode); StashTabController.UnregisterStashNode(stashNodeDrawer - .StashNode); //No sence to update data in deleted stash node + .StashNode); // No sense to update data in deleted stash node }; StashTabController.RegisterStashNode(node); } - public override void OnPluginDestroyForHotReload() { Settings.AllowedStashTabs.ForEach(x => - StashTabController.UnregisterStashNode(x)); //Unregistering stash tab nodes (hot reload) + StashTabController.UnregisterStashNode(x)); // Unregistering stash tab nodes (hot reload) - //Unsubscribing for hot reload or plugin update + // Unsubscribing for hot reload or plugin update MenuPlugin.KeyboardMouseEvents.MouseDown -= OnMouseEvent; GameController.Area.OnAreaChange -= OnAreaChange; API.UnsubscribePluginEvent("StashUpdate"); } - public override void OnClose() { if (_sData != null) + { StashData.Save(this, _sData); + } } private struct CurrentSetInfo @@ -1042,6 +1125,7 @@ private struct CurrentSetInfo public bool BSetIsReady; public int SetType; // 1 - chaos set, 2 - regal set } + /*Rare set classes: Two Hand Sword @@ -1067,8 +1151,6 @@ Body Armour Boots Gloves */ - - public class ItemDisplayData { public BaseSetPart BaseData; @@ -1084,8 +1166,8 @@ public class ItemDisplayData private readonly Dictionary _currentAlerts = new Dictionary(); - private Dictionary _currentLabels = - new Dictionary(); + private Dictionary _currentLabels = + new Dictionary(); private void RenderLabels() { @@ -1139,10 +1221,12 @@ private void RenderLabels() } var visitResult = ProcessItem(item); + if (visitResult == null) + { + continue; + } - if (visitResult == null) continue; - var index = (int) visitResult.ItemType; - + var index = (int)visitResult.ItemType; if (index > 7) { index = 0; @@ -1171,15 +1255,16 @@ private void RenderLabels() } } - private bool DrawBorder(long entityAddress, ItemDisplayData data) { var ui = GameController.Game.IngameState.IngameUi; - ItemsOnGroundLabelElement entityLabel; var shouldUpdate = false; - if (_currentLabels.TryGetValue(entityAddress, out entityLabel)) + if (_currentLabels.TryGetValue(entityAddress, out var entityLabel)) { - if (!entityLabel.IsVisible) return shouldUpdate; + if (!entityLabel.IsVisible) + { + return shouldUpdate; + } var rect = entityLabel.Label.GetClientRect(); if (ui.OpenLeftPanel.IsVisible && ui.OpenLeftPanel.GetClientRect().Intersects(rect) || @@ -1189,31 +1274,28 @@ private bool DrawBorder(long entityAddress, ItemDisplayData data) } var incrSize = Settings.BorderOversize.Value; - if (Settings.BorderAutoResize.Value) { - incrSize = (int) Lerp(incrSize, 1, data.PriorityPercent); + incrSize = (int)Lerp(incrSize, 1, data.PriorityPercent); } rect.X -= incrSize; rect.Y -= incrSize; - rect.Width += incrSize * 2; rect.Height += incrSize * 2; var borderColor = Color.Lerp(Color.Red, Color.Green, data.PriorityPercent); - - var borderWidth = Settings.BorderWidth.Value; - if (Settings.BorderAutoResize.Value) { - borderWidth = (int) Lerp(borderWidth, 1, data.PriorityPercent); + borderWidth = (int)Lerp(borderWidth, 1, data.PriorityPercent); } Graphics.DrawFrame(rect, borderWidth, borderColor); - - if (Settings.TextSize.Value == 0) return shouldUpdate; + if (Settings.TextSize.Value == 0) + { + return shouldUpdate; + } if (Settings.TextOffsetX < 0) { @@ -1247,13 +1329,11 @@ private bool DrawBorder(long entityAddress, ItemDisplayData data) return shouldUpdate; } - private float Lerp(float a, float b, float f) { return a + f * (b - a); } - public override void EntityAdded(EntityWrapper entity) { if (!Settings.EnableBorders.Value) @@ -1268,9 +1348,7 @@ public override void EntityAdded(EntityWrapper entity) } var item = entity.GetComponent().ItemEntity; - var visitResult = ProcessItem(item); - if (visitResult == null) { return; @@ -1286,15 +1364,13 @@ public override void EntityAdded(EntityWrapper entity) return; } - var index = (int) visitResult.ItemType; - + var index = (int)visitResult.ItemType; if (index > 7) { index = 0; } var displData = DisplayData[index]; - _currentAlerts.Add(entity, displData); } diff --git a/src/FullRareSetManager/DropAllToInventory.cs b/src/FullRareSetManager/DropAllToInventory.cs index 0cef1df..4ba7763 100644 --- a/src/FullRareSetManager/DropAllToInventory.cs +++ b/src/FullRareSetManager/DropAllToInventory.cs @@ -71,7 +71,7 @@ public bool SwitchToTab(int tabIndex, FullRareSetManagerSettings Settings) Thread.Sleep(latency + Settings.ExtraDelay); var brCounter = 0; - while (!dropDownTabElements.IsVisible) + while (1 == 2 && !dropDownTabElements.IsVisible) { Thread.Sleep(WHILE_DELAY); diff --git a/src/FullRareSetManager/FullRareSetManager.csproj b/src/FullRareSetManager/FullRareSetManager.csproj index 2bc1596..580fda4 100644 --- a/src/FullRareSetManager/FullRareSetManager.csproj +++ b/src/FullRareSetManager/FullRareSetManager.csproj @@ -34,28 +34,28 @@ - ..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll + ..\..\..\PoEHUD\Release\Gma.System.MouseKeyHook.dll False False - ..\..\..\ll\Release\Newtonsoft.Json.dll + ..\..\..\PoEHUD\Release\Newtonsoft.Json.dll False - ..\..\..\ll\Release\PoeHUD.exe + ..\..\..\PoEHUD\Release\PoeHUD.exe False - ..\..\..\ll\Release\SharpDX.dll + ..\..\..\PoEHUD\Release\SharpDX.dll False - ..\..\..\ll\Release\SharpDX.Direct3D9.dll + ..\..\..\PoEHUD\Release\SharpDX.Direct3D9.dll False - ..\..\..\ll\Release\SharpDX.Mathematics.dll + ..\..\..\PoEHUD\Release\SharpDX.Mathematics.dll False diff --git a/src/FullRareSetManager/SetParts/RingItemsSetPart.cs b/src/FullRareSetManager/SetParts/RingItemsSetPart.cs index 5c21246..d3ab304 100644 --- a/src/FullRareSetManager/SetParts/RingItemsSetPart.cs +++ b/src/FullRareSetManager/SetParts/RingItemsSetPart.cs @@ -16,7 +16,7 @@ public RingItemsSetPart(string partName) : base(partName) public override void AddItem(StashItem item) { - if (item.LowLvl) + if (item.itemlvl < 75) { LowLvlItems.Add(item); } @@ -311,7 +311,7 @@ public override void RemovePreparedItems() private void RemoveItem(StashItem item) { - if (item.LowLvl) + if (item.itemlvl < 75) { LowLvlItems.Remove(item); } diff --git a/src/FullRareSetManager/SetParts/SingleItemSetPart.cs b/src/FullRareSetManager/SetParts/SingleItemSetPart.cs index 81152bc..2cc8dac 100644 --- a/src/FullRareSetManager/SetParts/SingleItemSetPart.cs +++ b/src/FullRareSetManager/SetParts/SingleItemSetPart.cs @@ -14,7 +14,7 @@ public SingleItemSetPart(string partName) : base(partName) public override void AddItem(StashItem item) { - if (item.LowLvl) + if (item.itemlvl < 75) { LowLvlItems.Add(item); } @@ -149,7 +149,7 @@ public override StashItem[] GetPreparedItems() public override void RemovePreparedItems() { - if (_currentSetItem.LowLvl) + if (_currentSetItem.itemlvl < 75) { LowLvlItems.Remove(_currentSetItem); } diff --git a/src/FullRareSetManager/SetParts/WeaponItemsSetPart.cs b/src/FullRareSetManager/SetParts/WeaponItemsSetPart.cs index 17c5ce3..711d23a 100644 --- a/src/FullRareSetManager/SetParts/WeaponItemsSetPart.cs +++ b/src/FullRareSetManager/SetParts/WeaponItemsSetPart.cs @@ -20,7 +20,7 @@ public override void AddItem(StashItem item) { if (item.ItemType == StashItemType.TwoHanded) { - if (item.LowLvl) + if (item.itemlvl < 75) { TwoHandedLowLvlItems.Add(item); } @@ -31,7 +31,7 @@ public override void AddItem(StashItem item) } else { - if (item.LowLvl) + if (item.itemlvl < 75) { OneHandedLowLvlItems.Add(item); } @@ -415,7 +415,7 @@ public override void RemovePreparedItems() private void RemoveItem(StashItem item) { - if (item.LowLvl) + if (item.itemlvl < 75) { TwoHandedLowLvlItems.Remove(item); OneHandedLowLvlItems.Remove(item); diff --git a/src/FullRareSetManager/StashData.cs b/src/FullRareSetManager/StashData.cs index f5fb6f3..33afbb0 100644 --- a/src/FullRareSetManager/StashData.cs +++ b/src/FullRareSetManager/StashData.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.IO; using Newtonsoft.Json; +using PoeHUD.Poe.Elements; +using PoeHUD.Poe.RemoteMemoryObjects; namespace FullRareSetManager { @@ -57,6 +59,7 @@ public static void Save(Core plugin, StashData data) public class StashTabData { public int ItemsCount; + //public InventoryTypeE Stashtype; public List StashTabItems = new List(); } @@ -66,7 +69,7 @@ public class StashItem public StashItemType ItemType; public string ItemClass; public string ItemName; - public bool LowLvl; + public int itemlvl; public bool BIdentified; public int InventPosX; public int InventPosY;