Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Windows;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace Turbo.Plugins.Ez
- {
- public class CloseDialogPlugin : BasePlugin, IAfterCollectHandler
- {
- public bool DebugOn { get; set; } = false;
- public static IntPtr D3Hwnd = IntPtr.Zero;
- [DllImport("USER32.DLL")]
- private static extern IntPtr FindWindow(string ClassName, string WindowText);
- [DllImport("USER32.DLL")]
- private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- [DllImport("user32.dll")]
- private static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- protected IUiElement GreaterRifts_VictoryScreen;
- protected IUiElement GreaterRifts_VictoryScreen_Exit;
- protected IUiElement rift_join_party_main;
- protected IUiElement ConversationMain;
- protected IUiElement BountyRewardMain;
- protected IUiElement QuestrewardMain;
- protected IUiElement ChatUI;
- protected IUiElement uiSkilllist;
- protected IUiElement uiProfile;
- protected IUiElement uiLeaderboard;
- protected IUiElement uiAchievements;
- protected IUiElement uiGamemenu;
- protected IUiElement uiGuild;
- protected IUiElement uiStore;
- protected IUiElement lore_player_dlg;
- protected IUiElement lore_player_close;
- protected IUiElement lore_notify_dlg;
- protected IUiElement follower_swap;
- protected IUiElement follower_swap_ButtonOk;
- protected IUiElement tutorial_dialog_background;
- protected IUiElement tutorial_dialog_background_close;
- protected IUiElement SocialFlyoutButton;
- private const long intervalAction = 250;
- private long msLapseAction { get; set; } = 0;
- private long msPauseAction { get; set; } = 0;
- private long msPauseClose { get; set; } = 0;
- public Keys keyCloseDialog { get; set; }
- public bool keepVictoryScreenInTown { get; set; }
- private static IntPtr MakeLParam(int x, int y)
- {
- return (IntPtr)(y << 16 | (x & 65535));
- }
- public static void PostPressKey(Keys key)
- {
- PostMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero); PostMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
- }
- public void mouseLClickUiE(IUiElement uie, float dx = 0.5f, float dy = 0.5f)
- {
- IntPtr lParam = MakeLParam((int) (uie.Rectangle.X + uie.Rectangle.Width * dx), (int) (uie.Rectangle.Y + uie.Rectangle.Height * dy));
- PostMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
- PostMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
- }
- private bool UIEgoClick { get; set; } = false;
- private IUiElement UIEforDelay { get; set; } = null;
- private IUiElement UIEforClick { get; set; } = null;
- public CloseDialogPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- keepVictoryScreenInTown = false;
- keyCloseDialog = Keys.Space; // Close
- GreaterRifts_VictoryScreen = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot", null, null);
- GreaterRifts_VictoryScreen_Exit = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot.Primary_Frame.button_exit", null, null);
- rift_join_party_main = Hud.Render.RegisterUiElement("Root.NormalLayer.rift_join_party_main.LayoutRoot", null, null);
- ConversationMain = Hud.Render.RegisterUiElement("Root.NormalLayer.conversation_dialog_main", null, null);
- BountyRewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.BountyReward_main", null, null);
- QuestrewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.questreward_dialog", null, null);
- ChatUI = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline", null, null);
- uiSkilllist = Hud.Render.RegisterUiElement("Root.NormalLayer.SkillPane_main.LayoutRoot.SkillsList", null, null);
- uiProfile = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetProfile_main.LayoutRoot.OverlayContainer", null, null);
- uiLeaderboard = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetLeaderboard_main.LayoutRoot.OverlayContainer", null, null);
- uiAchievements = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetAchievements_main.LayoutRoot.OverlayContainer", null, null);
- uiGamemenu = Hud.Render.RegisterUiElement("Root.NormalLayer.gamemenu_dialog.gamemenu_bkgrnd.button_resumeGame", null, null);
- uiGuild = Hud.Render.RegisterUiElement("Root.NormalLayer.Guild_main.LayoutRoot.OverlayContainer", null, null);
- uiStore = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetStore_main.LayoutRoot.OverlayContainer", null, null);
- lore_player_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg", null, null);
- lore_player_close = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg.button_close", null, null);
- lore_notify_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_notify_dlg", null, null);
- follower_swap = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap", null, null);
- follower_swap_ButtonOk = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap.subdlg.button_ok", null, null);
- tutorial_dialog_background = Hud.Render.RegisterUiElement("Root.NormalLayer.tutorial_dialog_background.tutorial.anchored", null, null);
- tutorial_dialog_background_close = Hud.Render.RegisterUiElement("Root.NormalLayer.tutorial_dialog_background.tutorial.anchored.stack.wrapper.button_close", null, null);
- SocialFlyoutButton = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetFooter_main.LayoutRoot.ButtonContainer.SocialFlyoutButton", null, null);
- D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame) return;
- if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + intervalAction;
- if (Hud.Game.Me.AnimationState == AcdAnimationState.Transform) return;
- if (!Hud.Window.IsForeground || Hud.Game.IsPaused || ChatUI.Visible || Hud.Inventory.InventoryMainUiElement.Visible || Hud.Game.MapMode != MapMode.Minimap) return;
- if (uiSkilllist.Visible || uiProfile.Visible || uiLeaderboard.Visible || uiAchievements.Visible || uiGamemenu.Visible || uiGuild.Visible || uiStore.Visible) return;
- UIEgoClick = false;
- if (!SocialFlyoutButton.Visible) // Video
- {
- if (Hud.Game.CurrentRealTimeMilliseconds > msPauseAction)
- {
- msPauseAction = Hud.Game.CurrentRealTimeMilliseconds + 1000;
- PostPressKey(keyCloseDialog);
- if (DebugOn) Hud.Sound.Speak("Video");
- }
- }
- else if (ConversationMain.Visible || BountyRewardMain.Visible || QuestrewardMain.Visible)
- {
- PostPressKey(keyCloseDialog);
- }
- else if (lore_notify_dlg.Visible)
- {
- UIEforClick = lore_notify_dlg;
- UIEgoClick = true;
- }
- else if (lore_player_dlg.Visible)
- {
- if (lore_player_close.Visible)
- {
- UIEforClick = lore_player_close;
- UIEgoClick = true;
- }
- }
- else if (follower_swap.Visible)
- {
- if (follower_swap_ButtonOk.Visible)
- {
- UIEforClick = follower_swap_ButtonOk;
- UIEgoClick = true;
- }
- }
- else if (tutorial_dialog_background.Visible)
- {
- if (tutorial_dialog_background_close.Visible)
- {
- UIEforClick = tutorial_dialog_background_close;
- UIEgoClick = true;
- }
- }
- else if (GreaterRifts_VictoryScreen.Visible)
- {
- if (!Hud.Game.IsInTown || !keepVictoryScreenInTown)
- {
- if (!rift_join_party_main.Visible && GreaterRifts_VictoryScreen_Exit.Visible)
- {
- //UIEforClick = GreaterRifts_VictoryScreen_Exit;
- //UIEgoClick = true;
- PostPressKey(keyCloseDialog);
- }
- }
- }
- if (UIEgoClick)
- {
- UIEforClick.Refresh();
- if (UIEforClick.Visible)
- {
- if (UIEforDelay != UIEforClick) // Delay
- {
- UIEforDelay = UIEforClick;
- }
- else
- {
- UIEforDelay = null;
- mouseLClickUiE(UIEforClick);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment