private static void DrawFreshInstallNotice(Configuration config, float scale) { ImGui.OpenPopup("Compass Note"); var contentSize = ImGuiHelpers.MainViewport.Size; var modalSize = new Vector2(400 * scale, 175 * scale); var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2); ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always); if (!ImGui.BeginPopupModal("Compass Note")) { return; } ImGui.PushTextWrapPos(ImGui.GetFontSize() * 22f); ImGui.TextWrapped(i18n.fresh_install_note); ImGui.PopTextWrapPos(); ImGui.Spacing(); if (ImGui.Button($"${i18n.fresh_install_note_confirm_button}###Compass_FreshInstallPopUp")) { config.FreshInstall = false; ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); }
private static void DrawFreeCamButton() { ImGuiHelpers.ForceNextWindowMainViewport(); var size = new Vector2(50) * ImGuiHelpers.GlobalScale; ImGui.SetNextWindowSize(size, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(ImGuiHelpers.MainViewport.Size.X - size.X, 0), ImGuiCond.Always); ImGui.Begin("FreeCam Button", ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoFocusOnAppearing); if (ImGui.IsWindowHovered() && ImGui.IsMouseReleased(ImGuiMouseButton.Left)) { FreeCam.Toggle(); } ImGui.End(); }
private static bool DrawRisksWarning(Configuration config, ref bool shouldDrawConfigUi, float scale) { if (config.OnboardingStep == Onboarding.TellAboutRisk) { ImGui.OpenPopup("Warning"); } var contentSize = ImGuiHelpers.MainViewport.Size; var modalSize = new Vector2(500 * scale, 215 * scale); var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2); ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always); if (!ImGui.BeginPopupModal("Warning")) { return(false); } ImGui.Text("This plugin allows you to directly use the motors of your controller."); ImGui.Text("Irresponsible usage has a probability of permanent hardware damage."); ImGui.Text("The author cannot be held liable for any damage caused by e.g. vibration overuse."); ImGui.TextWrapped( "Before using this plugin you have to acknowledge the risks and that you are sole responsible for any damage which might occur."); ImGui.Text("You can cancel and remove the plugin if you do not consent."); ImGui.Text("Responsible usage should come with no risks."); ImGui.Spacing(); var changed = false; if (ImGui.Button("Cancel##Risks")) { shouldDrawConfigUi = false; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button( "I hereby acknowledge the risks")) { config.OnboardingStep = Onboarding.AskAboutExamplePatterns; changed = true; ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); return(changed); }
private static bool DrawOnboarding(Configuration config, IEnumerable <ClassJob> jobs, IEnumerable <FFXIVAction> allActions, float scale) { var contentSize = ImGuiHelpers.MainViewport.Size; var modalSize = new Vector2(300 * scale, 100 * scale); var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2); if (config.OnboardingStep == Onboarding.AskAboutExamplePatterns) { ImGui.OpenPopup("Create Example Patterns"); } var changed = false; ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always); if (ImGui.BeginPopupModal("Create Example Patterns")) { ImGui.Text($"No vibration patterns found." + $"\nCreate some example patterns?"); if (ImGui.Button("No##ExamplePatterns")) { config.OnboardingStep = Onboarding.Done; changed = true; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button( "Yes##ExamplePatterns")) { #region Example Patterns var bothStrong = new VibrationPattern { Steps = new[] { new VibrationPattern.Step(100, 100, 300), }, Cycles = 1, Infinite = false, Name = "Both Strong" }; var lightPulse = new VibrationPattern { Steps = new[] { new VibrationPattern.Step(25, 25, 300), new VibrationPattern.Step(0, 0, 400) }, Infinite = true, Name = "Light pulse" }; var leftStrong = new VibrationPattern { Steps = new[] { new VibrationPattern.Step(100, 0, 300), }, Infinite = false, Cycles = 1, Name = "Left Strong" }; var rightStrong = new VibrationPattern { Steps = new[] { new VibrationPattern.Step(0, 100, 300), }, Infinite = false, Cycles = 1, Name = "Right Strong" }; var simpleRhythmic = new VibrationPattern { Steps = new[] { new VibrationPattern.Step(75, 75, 200), new VibrationPattern.Step(0, 0, 200), }, Infinite = false, Cycles = 3, Name = "Simple Rhythmic" }; config.Patterns.Add(lightPulse); config.Patterns.Add(bothStrong); config.Patterns.Add(leftStrong); config.Patterns.Add(rightStrong); config.Patterns.Add(simpleRhythmic); #endregion config.OnboardingStep = Onboarding.AskAboutExampleCooldownTriggers; changed = true; ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (config.OnboardingStep == Onboarding.AskAboutExampleCooldownTriggers) { ImGui.OpenPopup("Create Example Cooldown Triggers"); } ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always); if (ImGui.BeginPopupModal("Create Example Cooldown Triggers")) { ImGui.Text($"No cooldown triggers found." + $"\nCreate some example triggers (Ninja and Paladin)?"); if (ImGui.Button("No##ExampleTriggers")) { config.OnboardingStep = Onboarding.Done; changed = true; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button( "Yes##ExampleTriggers")) { #region Example Triggers config.CooldownTriggers.Add(new CooldownTrigger( 30, "Dream Within a Dream", 3566, 16, 0, config.Patterns[1])); config.CooldownTriggers.Add(new CooldownTrigger( 30, "Mug", 2248, 18, 2, config.Patterns[3])); config.CooldownTriggers.Add(new CooldownTrigger( 19, "Fight or Flight", 20, 14, 3, config.Patterns[1])); #endregion config.OnboardingStep = Onboarding.AskAboutGCD; changed = true; ImGui.CloseCurrentPopup(); ImGui.OpenPopup("Create GCD Cooldown Triggers"); } ImGui.EndPopup(); } if (config.OnboardingStep == Onboarding.AskAboutGCD) { ImGui.OpenPopup("Create GCD Cooldown Triggers"); } ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always); if (ImGui.BeginPopupModal("Create GCD Cooldown Triggers")) { ImGui.Text($"No GCD cooldown trigger found." + $"\nCreate a GCD trigger for each job?"); if (ImGui.Button("No##ExampleGCD")) { config.OnboardingStep = Onboarding.Done; changed = true; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button( "Yes##ExampleGCD")) { var gcdActionsCollection = allActions.Where(a => a.CooldownGroup == CooldownTrigger.GCDCooldownGroup); var gcdActions = gcdActionsCollection as FFXIVAction[] ?? gcdActionsCollection.ToArray(); foreach (var job in jobs) { var action = gcdActions.First(a => a.ClassJobCategory.Value.HasClass(job.RowId)); var lastTrigger = config.CooldownTriggers.LastOrDefault(); config.CooldownTriggers.Add( new CooldownTrigger( job.RowId, action.Name, action.RowId, action.CooldownGroup, lastTrigger?.Priority + 1 ?? 0, config.Patterns[0] )); } config.OnboardingStep = Onboarding.Done; changed = true; ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } return(changed); }
internal static Vector2 Draw( DrawVariables drawVariables, Pointers pointers, float cameraRotationInRadian, Vector2 playerPosition, Configuration config ) { const ImGuiWindowFlags flags = ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoMouseInputs | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings; ImGuiHelpers.ForceNextWindowMainViewport(); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(config.ImGuiCompassPosition, ImGuiCond.Always); ImGui.Begin("###ImGuiCompassWindow", flags); var cosPlayer = MathF.Cos(cameraRotationInRadian); var sinPlayer = MathF.Sin(cameraRotationInRadian); // NOTE: Interpret game's camera rotation as // 0 => (0,1) (North), PI/2 => (-1,0) (West) in default coordinate system // Games Map coordinate system origin is upper left, with positive Y grow var playerForward = new Vector2(-sinPlayer, cosPlayer); var drawList = ImGui.GetWindowDrawList(); var backgroundDrawList = ImGui.GetBackgroundDrawList(); drawList.PushClipRect(drawVariables.DrawListPMin, drawVariables.DrawListPMax); backgroundDrawList.PushClipRect(drawVariables.BackgroundDrawListPMin, drawVariables.BackgroundDrawListPMax); DrawImGuiCompassBackground( drawVariables.BackgroundPMin, drawVariables.BackgroundPMax, drawVariables.BackgroundLinePMin, drawVariables.BackgroundLinePMax, drawVariables.BackgroundColourUInt32, drawVariables.BackgroundBorderColourUInt32, drawVariables.BackgroundLineColourUInt32, config ); if (config.ShowInterCardinals) { DrawInterCardinals( playerForward, drawVariables.Centre, drawVariables.HalfWidth28, drawVariables.CompassUnit, config.ImGuiCompassCardinalsOffset, pointers.NaviMapTextureD3D11ShaderResourceView ); } if (config.ShowCardinals) { DrawCardinals( playerForward, drawVariables.Centre, drawVariables.HalfWidth40, drawVariables.HalfWidth28, drawVariables.CompassUnit, config.ImGuiCompassCardinalsOffset, pointers.NaviMapTextureD3D11ShaderResourceView ); } if (config.ShowWeatherIcon) { unsafe { DrawWeatherIcon( drawVariables.WeatherIconBorderPMin, drawVariables.WeatherIconBorderPMax, drawVariables.WeatherIconPMin, drawVariables.WeatherIconPMax, pointers.NaviMapTextureD3D11ShaderResourceView, pointers.WeatherIconNode ); } } if (config.ShowDistanceToTarget) { unsafe { DrawDistanceToTarget( config.ImGuiCompassDistanceToTargetMouseOverPrio, pointers.TargetSystem, drawVariables.DistanceToTargetScale, drawVariables.DistanceToTargetColourUInt32, drawVariables.DistanceToTargetPMin, config.DistanceToTargetPrefix, config.DistanceToTargetSuffix ); } } if (!config.ShowOnlyCardinals) { unsafe { playerPosition = DrawIcons( drawVariables.CurrentScaleOffset, drawVariables.ComponentIconLoopStart, drawVariables.ComponentIconLoopEnd, config.ImGuiCompassCentreMarkerOffset, drawVariables.MaxDistance, drawVariables.CompassUnit, drawVariables.Scale, drawVariables.RotationIconHalfWidth, drawVariables.HalfWidth40, drawVariables.MinScaleFactor, config.ImGuiCompassBackgroundRounding, playerForward, playerPosition, drawVariables.Centre, drawVariables.BackgroundPMin, drawVariables.BackgroundPMax, config.UseAreaMapAsSource, config.ImGuiCompassEnableCenterMarker, config.ImGuiCompassFlipCentreMarker, pointers.CurrentSourceBase, pointers.CurrentMapIconsRootComponentNode, config.FilteredIconIds ); } } drawList.PopClipRect(); backgroundDrawList.PopClipRect(); ImGui.End(); return(playerPosition); }
private void DrawWindow() { if (_check) { var tempCastBar = _getUi2ObjByName(Marshal.ReadIntPtr(_getBaseUiObj(), 0x20), "_CastBar", 1); if (tempCastBar != IntPtr.Zero) { _wait = 1000; if (_config) { ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver); ImGui.Begin("SlideCast Config", ref _config); ImGui.InputInt("Time (cs)", ref _slideTime); ImGui.TextWrapped("The time for slidecasting is 50cs (half a second) by default.\n" + "Lower numbers make it later in the cast, higher numbers earlier in the cast.\n" + "Apart from missed packets, 50cs is the exact safe time to slidecast."); ImGui.ColorEdit4("Bar Colour", ref _slideCol, ImGuiColorEditFlags.NoInputs); ImGui.Checkbox("Enable Debug Mode", ref _debug); ImGui.Separator(); if (ImGui.Button("Save and Close Config")) { SaveConfig(); _config = false; } ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF); ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF); if (ImGui.Button("Buy Haplo a Hot Chocolate")) { System.Diagnostics.Process.Start("https://ko-fi.com/haplo"); } ImGui.PopStyleColor(3); ImGui.End(); } if (_enabled) { if (_castBar != tempCastBar) { _castBar = IntPtr.Zero; } if (_castBar != IntPtr.Zero) { _cbCastLast = _cbCastPer; _cbX = Marshal.ReadInt16(_castBar + 0x1BC); _cbY = Marshal.ReadInt16(_castBar + 0x1BE); _cbScale = Marshal.PtrToStructure <float>(_castBar + 0x1AC); _cbCastTime = Marshal.ReadInt16(_castBar + 0x2BC); _cbCastPer = Marshal.PtrToStructure <float>(_castBar + 0x2C0); var plus = 0; _cbSpell = new List <byte>(); while (Marshal.ReadByte(_castBar + 0x242 + plus) != 0) { _cbSpell.Add(Marshal.ReadByte(_castBar + 0x242 + plus)); plus++; } if (_cbCastLast == _cbCastPer) { if (_cbCastSameCount < 5) { _cbCastSameCount++; } } else { _cbCastSameCount = 0; } if (_cbCastPer == 5) { _colS = new Colour(_col1S.R / 255f, _col1S.G / 255f, _col1S.B / 255f); } if (Marshal.ReadByte(_castBar + 0x182).ToString() != "84") { ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY)); ImGui.Begin("SlideCast", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground); ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale)); //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime); float slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime; ImGui.GetWindowDrawList().AddRectFilled( new Num.Vector2( ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale), ImGui.GetWindowPos().Y + (20 * _cbScale)), new Num.Vector2( ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale), ImGui.GetWindowPos().Y + (29 * _cbScale)), ImGui.GetColorU32(_slideCol)); ImGui.End(); } } else { _castBar = tempCastBar; } if (_debug) { ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY)); ImGui.Begin("SlideCast DEBUG", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar); ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale)); //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime); var slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime; ImGui.GetWindowDrawList().AddRectFilled( new Num.Vector2( ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale), ImGui.GetWindowPos().Y + (20 * _cbScale)), new Num.Vector2( ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale), ImGui.GetWindowPos().Y + (29 * _cbScale)), ImGui.GetColorU32(_slideCol)); ImGui.End(); ImGui.Begin("Slidecast Debug Values"); ImGui.Text("cbX: " + _cbX); ImGui.Text("cbY: " + _cbY); ImGui.Text("cbS: " + _cbScale); ImGui.Text("cbCastTime: " + _cbCastTime); ImGui.Text("cbCastPer: " + _cbCastPer); ImGui.Text("Mem Addr: " + _castBar.ToString("X")); ImGui.Text(_colS.Hue.ToString()); ImGui.Text(_colS.Saturation.ToString()); ImGui.Text(_colS.Brightness.ToString()); ImGui.End(); } } } else { _check = false; } } if (_wait > 0) { _wait--; } else { _check = true; } }
private void DrawWindow() { if (_config) { ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver); ImGui.Begin("Pixel Perfect Config", ref _config); ImGui.Checkbox("Hitbox", ref _enabled); ImGui.Checkbox("Outer Ring", ref _circle); ImGui.Checkbox("Combat Only", ref _combat); ImGui.Checkbox("Instance Only", ref _instance); ImGui.ColorEdit4("Colour", ref _col, ImGuiColorEditFlags.NoInputs); ImGui.ColorEdit4("Outer Colour", ref _col2, ImGuiColorEditFlags.NoInputs); ImGui.Separator(); ImGui.Checkbox("Ring", ref _ring); ImGui.DragFloat("Yalms", ref _radius); ImGui.DragFloat("Thickness", ref _thickness); ImGui.DragInt("Smoothness", ref _segments); ImGui.ColorEdit4("Ring Colour", ref _colRing, ImGuiColorEditFlags.NoInputs); if (ImGui.Button("Save and Close Config")) { SaveConfig(); _config = false; } ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF); ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF); if (ImGui.Button("Buy Haplo a Hot Chocolate")) { System.Diagnostics.Process.Start("https://ko-fi.com/haplo"); } ImGui.PopStyleColor(3); ImGui.End(); } if (!_enabled || _pluginInterface.ClientState.LocalPlayer == null) { return; } if (_combat) { if (!_pluginInterface.ClientState.Condition[Dalamud.Game.ClientState.ConditionFlag.InCombat]) { return; } } if (_instance) { if (!_pluginInterface.ClientState.Condition[Dalamud.Game.ClientState.ConditionFlag.BoundByDuty]) { return; } } var actor = _pluginInterface.ClientState.LocalPlayer; if (!_pluginInterface.Framework.Gui.WorldToScreen( new SharpDX.Vector3(actor.Position.X, actor.Position.Z, actor.Position.Y), out var pos)) { return; } ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(pos.X - 10 - ImGuiHelpers.MainViewport.Pos.X, pos.Y - 10 - ImGuiHelpers.MainViewport.Pos.Y)); ImGui.Begin("Pixel Perfect", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground); ImGui.GetWindowDrawList().AddCircleFilled( new Num.Vector2(pos.X, pos.Y), 2f, ImGui.GetColorU32(_col), 100); if (_circle) { ImGui.GetWindowDrawList().AddCircle( new Num.Vector2(pos.X, pos.Y), 2.2f, ImGui.GetColorU32(_col2), 100); } ImGui.End(); if (!_ring) { return; } ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Num.Vector2(0, 0)); ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(0, 0)); ImGui.Begin("Ring", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground); ImGui.SetWindowSize(ImGui.GetIO().DisplaySize); DrawRingWorld(_pluginInterface.ClientState.LocalPlayer, _radius, _segments, _thickness, ImGui.GetColorU32(_colRing)); ImGui.End(); ImGui.PopStyleVar(); }