public static bool WaitForPanel(this Player client, InterfacePanel panel, TimeSpan timeout) { var startTime = DateTime.Now; while (true) { client.Update(PlayerFieldFlags.GameClient); var activePanel = client.GameClient.ActivePanel; if (activePanel.IsSameAs(panel)) { return(true); } var delaTime = DateTime.Now - startTime; if (timeout != TimeSpan.Zero && delaTime >= timeout) { break; } Thread.Sleep(1); } return(false); }
public static bool IsSharedPanel(this InterfacePanel panel, InterfacePanel target) { if (panel == InterfacePanel.TemuairSkills && target == InterfacePanel.MedeniaSkills) return true; if (panel == InterfacePanel.MedeniaSkills && target == InterfacePanel.TemuairSkills) return true; if (panel == InterfacePanel.TemuairSpells && target == InterfacePanel.MedeniaSpells) return true; if (panel == InterfacePanel.MedeniaSpells && target == InterfacePanel.TemuairSpells) return true; if (panel == InterfacePanel.Chat && target == InterfacePanel.ChatHistory) return true; if (panel == InterfacePanel.ChatHistory && target == InterfacePanel.Chat) return true; if (panel == InterfacePanel.Stats && target == InterfacePanel.Modifiers) return true; if (panel == InterfacePanel.Modifiers && target == InterfacePanel.Stats) return true; return false; }
public static Point ToSlotPoint(this InterfacePanel panel, int slot, bool isExpandedInventory = false, int iconWidth = 35, int iconHeight = 35) { Point pt; if (isExpandedInventory) { pt = new Point(110, 285); } else { pt = new Point(110, 350); } slot = slot % (Inventory.InventoryCount + 1); var rowSize = panel.IsWorldPanel() ? 6 : 12; var rowOffset = 0; var columnOffset = (panel == InterfacePanel.WorldSpells) ? 6 : 0; var row = ((slot - 1) / rowSize) + rowOffset; var column = ((slot - 1) % rowSize) + columnOffset; pt.Offset(column * iconWidth, row * iconHeight); return(pt); }
private void Compile(string path, InterfacePanel res) { Writer.Write((int)Type.Panel); var cpanel = new CPanel(); cpanel.Base = new CElement(res); cpanel.Image = Compile(path, res.Image); cpanel.Write(Writer); }
public static void ClickSlot(this Player client, InterfacePanel panel, int slot, bool isExpandedInventory = false) { slot = panel.GetRelativeSlot(slot); var pt = panel.ToSlotPoint(slot, isExpandedInventory); pt = pt.ScalePoint(client.Process.WindowScaleX, client.Process.WindowScaleY); WindowAutomator.SendMouseClick(client.Process.WindowHandle, MouseButton.Left, (int)pt.X, (int)pt.Y); }
public static Point ToPoint(this InterfacePanel panel) { var pt = new Point(545, 0); switch (panel) { case InterfacePanel.Inventory: pt.Y = 340; break; case InterfacePanel.TemuairSkills: pt.Y = 360; break; case InterfacePanel.MedeniaSkills: goto case InterfacePanel.TemuairSkills; case InterfacePanel.TemuairSpells: pt.Y = 390; break; case InterfacePanel.MedeniaSpells: goto case InterfacePanel.TemuairSpells; case InterfacePanel.Chat: pt.Y = 410; break; case InterfacePanel.ChatHistory: goto case InterfacePanel.Chat; case InterfacePanel.Stats: pt.Y = 435; break; case InterfacePanel.Modifiers: goto case InterfacePanel.Stats; case InterfacePanel.WorldSkills: pt.Y = 460; break; case InterfacePanel.WorldSpells: goto case InterfacePanel.WorldSkills; default: pt = new Point(-1, -1); break; } return(pt); }
static int GetRelativeSlot(this InterfacePanel panel, int slot) { int maxSlotCount = 36; if (panel == InterfacePanel.Inventory) { maxSlotCount = 60; } if (panel.IsWorldPanel()) { maxSlotCount = 18; } return(slot % maxSlotCount); }
public static bool IsSharedPanel(this InterfacePanel panel, InterfacePanel target) { if (panel == InterfacePanel.TemuairSkills && target == InterfacePanel.MedeniaSkills) { return(true); } if (panel == InterfacePanel.MedeniaSkills && target == InterfacePanel.TemuairSkills) { return(true); } if (panel == InterfacePanel.TemuairSpells && target == InterfacePanel.MedeniaSpells) { return(true); } if (panel == InterfacePanel.MedeniaSpells && target == InterfacePanel.TemuairSpells) { return(true); } if (panel == InterfacePanel.Chat && target == InterfacePanel.ChatHistory) { return(true); } if (panel == InterfacePanel.ChatHistory && target == InterfacePanel.Chat) { return(true); } if (panel == InterfacePanel.Stats && target == InterfacePanel.Modifiers) { return(true); } if (panel == InterfacePanel.Modifiers && target == InterfacePanel.Stats) { return(true); } return(false); }
public static bool IsTemuairToMedenia(this InterfacePanel panel, InterfacePanel target) { return (panel == InterfacePanel.TemuairSkills && target == InterfacePanel.MedeniaSkills) || (panel == InterfacePanel.TemuairSpells && target == InterfacePanel.MedeniaSpells); }
public static bool SwitchToPanelAndWait(this Player client, InterfacePanel panel, out bool didRequireSwitch, bool useShiftKey = true) { return(SwitchToPanelAndWait(client, panel, TimeSpan.Zero, out didRequireSwitch, useShiftKey)); }
public static bool IsSameAs(this InterfacePanel panel, InterfacePanel target) { return panel == target || (panel.IsWorldPanel() && target.IsWorldPanel()); }
public static bool SwitchToPanelAndWait(this Player client, InterfacePanel panel, TimeSpan timeout, out bool didRequireSwitch, bool useShiftKey = true) { SwitchToPanel(client, panel, out didRequireSwitch, useShiftKey); return(WaitForPanel(client, panel, timeout)); }
public static bool IsSpellPanel(this InterfacePanel panel) { return(panel == InterfacePanel.TemuairSpells || panel == InterfacePanel.MedeniaSpells || panel == InterfacePanel.WorldSpells); }
public static bool IsWorldPanel(this InterfacePanel panel) { return(panel == InterfacePanel.WorldSkills || panel == InterfacePanel.WorldSpells); }
public static bool IsMedeniaPanel(this InterfacePanel panel) { return(panel == InterfacePanel.MedeniaSkills || panel == InterfacePanel.MedeniaSpells); }
public static bool IsTemuairPanel(this InterfacePanel panel) { return(!IsMedeniaPanel(panel) && !IsWorldPanel(panel)); }
public static bool IsSameAs(this InterfacePanel panel, InterfacePanel target) { return(panel == target || (panel.IsWorldPanel() && target.IsWorldPanel())); }
public static void SwitchToPanel(this Player client, InterfacePanel panel, out bool didRequireSwitch, bool useShiftKey = true) { didRequireSwitch = false; var pt = panel.ToPoint(); pt = pt.ScalePoint(client.Process.WindowScaleX, client.Process.WindowScaleY); var x = (int)pt.X; var y = (int)pt.Y; var hwnd = client.Process.WindowHandle; client.Update(PlayerFieldFlags.GameClient); var currentPanel = client.GameClient.ActivePanel; if (currentPanel.IsSameAs(panel)) { return; } didRequireSwitch = true; // Tem Skills/Spells to Medenia if (currentPanel.IsTemuairToMedenia(panel)) { if (useShiftKey) { WindowAutomator.SendShiftKeyDown(hwnd); } WindowAutomator.SendMouseClick(hwnd, MouseButton.Left, x, y); if (useShiftKey) { WindowAutomator.SendShiftKeyUp(hwnd); } } // Med Skills/Spells to Temuair else if (currentPanel.IsMedeniaToTemuair(panel)) { WindowAutomator.SendMouseClick(hwnd, MouseButton.Left, x, y); } // Switching to Medenia from non-Temuair else if (panel.IsMedeniaPanel()) { if (useShiftKey) { WindowAutomator.SendShiftKeyDown(hwnd); } WindowAutomator.SendMouseClick(hwnd, MouseButton.Left, x, y); if (!useShiftKey) { WindowAutomator.SendMouseClick(hwnd, MouseButton.Left, x, y); } if (useShiftKey) { WindowAutomator.SendShiftKeyUp(hwnd); } } // Switching to Temauir from non-Medenia else { WindowAutomator.SendMouseClick(hwnd, MouseButton.Left, x, y); } }
public static bool IsMedeniaToTemuair(this InterfacePanel panel, InterfacePanel target) { return((panel == InterfacePanel.MedeniaSkills && target == InterfacePanel.TemuairSkills) || (panel == InterfacePanel.MedeniaSpells && target == InterfacePanel.TemuairSpells)); }
protected override void MacroLoop(object argument) { client.Update(PlayerFieldFlags.GameClient); if (client.GameClient.IsUserChatting) { SetPlayerStatus(PlayerMacroStatus.ChatIsUp); return; } var didUseSkill = false; var didCastSpell = false; var didFlower = false; var preserveUserPanel = UserSettingsManager.Instance.Settings.PreserveUserPanel; InterfacePanel currentPanel = InterfacePanel.Stats; if (preserveUserPanel) { client.Update(PlayerFieldFlags.GameClient); currentPanel = client.GameClient.ActivePanel; } if (UserSettingsManager.Instance.Settings.FlowerBeforeSpellMacros) { didFlower = DoFlowerMacro(); didCastSpell = DoSpellMacro(); } else { didFlower = DoSpellMacro(); didFlower = DoFlowerMacro(); } bool didAssail = false; didUseSkill = DoSkillMacro(out didAssail); if (!this.IsSpellCasting) { client.Spellbook.ActiveSpell = null; } bool didRequireSwitch; if (preserveUserPanel) { client.SwitchToPanel(currentPanel, out didRequireSwitch); } if (this.Status == MacroStatus.Running) { if (this.IsSpellCasting) { var spellName = client.Spellbook.ActiveSpell; if (string.Equals(Spell.FasSpioradKey, spellName, StringComparison.OrdinalIgnoreCase)) { SetPlayerStatus(PlayerMacroStatus.FasSpiorad); } else if (string.Equals(Spell.LyliacPlantKey, spellName, StringComparison.OrdinalIgnoreCase)) { SetPlayerStatus(PlayerMacroStatus.Flowering); } else if (string.Equals(Spell.LyliacVineyardKey, spellName, StringComparison.OrdinalIgnoreCase)) { SetPlayerStatus(PlayerMacroStatus.Vineyarding); } else { SetPlayerStatus(PlayerMacroStatus.Casting); } } else if (this.IsWaitingOnMana) { SetPlayerStatus(PlayerMacroStatus.WaitingForMana); } else if (this.FlowerAlternateCharacters) { SetPlayerStatus(PlayerMacroStatus.ReadyToFlower); } else if (this.UseLyliacVineyard) { SetPlayerStatus(PlayerMacroStatus.WaitingOnVineyard); } else if (didUseSkill) { SetPlayerStatus(PlayerMacroStatus.UsingSkills); } else if (didAssail) { SetPlayerStatus(PlayerMacroStatus.Assailing); } else { if (this.flowerQueue.Count > 0) { SetPlayerStatus(PlayerMacroStatus.ReadyToFlower); } else if (client.Skillbook.ActiveSkills.Count() > 0) { SetPlayerStatus(PlayerMacroStatus.Waiting); } else { SetPlayerStatus(PlayerMacroStatus.Idle); } } } }
public static void WaitForPanel(this Player client, InterfacePanel panel) { WaitForPanel(client, panel, TimeSpan.Zero); }