Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed pulse error.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 2, 2023
1 parent d9eee33 commit 2a3037a
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 28 deletions.
10 changes: 4 additions & 6 deletions RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,17 @@ public static unsafe uint GetAdjustedActionId(uint id)
public static ChatGui ChatGui { get; private set; }

[PluginService]
static GameGui GameGui { get; set; }
public static GameGui GameGui { get; set; }

public static bool WorldToScreen(Vector3 worldPos, out Vector2 screenPos) => GameGui.WorldToScreen(worldPos, out screenPos);

public unsafe static T[] GetAddon<T>() where T : struct
public unsafe static IEnumerable<IntPtr> GetAddon<T>() where T : struct
{
if(typeof(T).GetCustomAttribute<Addon>() is not Addon on) return new T[0];
if(typeof(T).GetCustomAttribute<Addon>() is not Addon on) return new IntPtr[0];

return on.AddonIdentifiers
.Select(str => GameGui.GetAddonByName(str, 1))
.Where(ptr => ptr != IntPtr.Zero)
.Select(ptr => *(T*)ptr)
.ToArray();
.Where(ptr => ptr != IntPtr.Zero);
}

public static PlayerCharacter Player => ClientState.LocalPlayer;
Expand Down
7 changes: 5 additions & 2 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ConfigWindow_Param_WeakenDelay": "Set the range of random delay for esuna weakens in second.",
"ConfigWindow_Param_HealDelay": "Set the range of random delay for healing people in second.",
"ConfigWindow_Param_NotInCombatDelay": "Set the range of random delay for Not In Combat in second.",
"ConfigWindow_Param_StopCastingDelay": "Set the range of random delay for stoping casting when target is no need to cast in second.",
"ConfigWindow_Param_StopCastingDelay": "Set the range of random delay for stopping casting when target is no need to cast in second.",
"ConfigWindow_Param_Display": "Display",
"ConfigWindow_Param_Advanced": "Advanced",
"ConfigWindow_Param_PoslockCasting": "Lock the movement when casting.",
Expand All @@ -91,6 +91,8 @@
"ConfigWindow_Param_TargetColor": "Target color",
"ConfigWindow_Param_SubTargetColor": "Sub-target color",
"ConfigWindow_Param_KeyBoardNoise": "Simulate the effect of pressing",
"ConfigWindow_Param_KeyBoardNoiseTimes": "Effect times",
"ConfigWindow_Param_KeyBoardNoiseTime": "Effect interval",
"ConfigWindow_Param_VoiceVolume": "Voice volume",
"ConfigWindow_Param_VoiceName": "Voice Name",
"ConfigWindow_Param_FlytextPositional": "Hint positional anticipation by flytext",
Expand Down Expand Up @@ -178,7 +180,8 @@
"ConfigWindow_Control_UseKeyboardCommand": "Use Keyboard Command",
"ConfigWindow_Control_UseGamepadCommand": "Use GamePad Command",
"ConfigWindow_Control_ShowCooldownWindow": "Show Cooldown Window",
"ConfigWindow_Control_IsWindowLock": "Lock",
"ConfigWindow_Control_IsInfoWindowNoInputs": "No Inputs",
"ConfigWindow_Control_IsInfoWindowNoMove": "No Move",
"ConfigWindow_Control_ShowItemsCooldown": "Show Items' Cooldown",
"ConfigWindow_Control_UseOriginalCooldown": "Show Original Cooldown",
"ConfigWindow_Control_CooldownActionOneLine": "The count of cooldown actions in one line.",
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.Game.Gauge;
using Newtonsoft.Json;
using RotationSolver.Basic;
using RotationSolver.Basic.Configuration;
Expand Down
17 changes: 11 additions & 6 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Basic;
using RotationSolver.Basic.Actions;
using RotationSolver.Basic.Data;
Expand Down Expand Up @@ -405,10 +403,17 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co
internal static void DrawIAction(IAction action, float width, float percent)
{
DrawIAction(GetTexture(action).ImGuiHandle, width, action == null ? -1 : percent);
if(ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
if (action != null) ImGuiHelper.HoveredString(action.Name, () =>
{
DataCenter.AddCommandAction(action, 5);
}
if (DataCenter.StateType == StateCommandType.Cancel)
{
action.Use();
}
else
{
DataCenter.AddCommandAction(action, 5);
}
});
}

static void DrawIAction(nint handle, float width, float percent)
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action
if (ImGui.IsItemHovered())
{
showToolTip(desc);
if (ImGui.IsMouseDown(ImGuiMouseButton.Left))
if (ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
selected?.Invoke();
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public static void HoveredString(string text, Action selected = null)
if (ImGui.IsItemHovered())
{
if (!string.IsNullOrEmpty(text)) ImGui.SetTooltip(text);
if (ImGui.IsMouseDown(ImGuiMouseButton.Left))
if (ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
selected?.Invoke();
}
Expand Down Expand Up @@ -334,7 +334,7 @@ internal static void DisplayCommandHelp<T>(this T command, string extraCommand =
{
ImGui.SetTooltip($"{LocalizationManager.RightLang.ConfigWindow_Helper_RunCommand}: {cmdStr}\n{LocalizationManager.RightLang.ConfigWindow_Helper_CopyCommand}: {cmdStr}");

if (ImGui.IsMouseDown(ImGuiMouseButton.Right))
if (ImGui.IsMouseClicked(ImGuiMouseButton.Right))
{
ImGui.SetClipboardText(cmdStr);
}
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/UI/InfoWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public override void PreDraw()
}
//ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
base.PreDraw();
}

public override void PostDraw()
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/UI/NextActionWindow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using RotationSolver.Basic;
Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Dalamud.Game;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.UI;
using RotationSolver.Basic;
using RotationSolver.Commands;
using System.Collections.Generic;

namespace RotationSolver.Updaters;

Expand Down Expand Up @@ -68,6 +70,7 @@ private static void FrameworkUpdate(Framework framework)
UpdateWork();
}
}
static bool first = false;

public static void Enable()
{
Expand Down
16 changes: 9 additions & 7 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static unsafe void UpdateCastBar()
if (!castBars.Any()) return;
var castBar = castBars.FirstOrDefault();

AtkResNode* progressBar = castBar.AtkUnitBase.UldManager.NodeList[5];
AtkResNode* progressBar = ((AtkUnitBase*)castBar)->UldManager.NodeList[5];

progressBar->AddRed = c.R;
progressBar->AddGreen = c.G;
Expand Down Expand Up @@ -143,14 +143,16 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething)
{
var index = 0;
var hotBarIndex = 0;
foreach (var actionBar in Service.GetAddon<AddonActionBar>().Select(i => i.AddonActionBarX.AddonActionBarBase)
.Union(Service.GetAddon<AddonActionBarX>().Select(i => i.AddonActionBarBase))
.Union(Service.GetAddon<AddonActionCross>().Select(i => i.ActionBarBase))
.Union(Service.GetAddon<AddonActionDoubleCrossBase>().Where(i => i.ShowDPadSlots > 0).Select(i => i.ActionBarBase)))
foreach (var intPtr in Service.GetAddon<AddonActionBar>()
.Union(Service.GetAddon<AddonActionBarX>())
.Union(Service.GetAddon<AddonActionCross>())
.Union(Service.GetAddon<AddonActionDoubleCrossBase>()))
{
if (intPtr == IntPtr.Zero) continue;
var actionBar = (AddonActionBarBase*)intPtr;
var hotbar = Framework.Instance()->GetUiModule()->GetRaptureHotbarModule()->HotBar[hotBarIndex];
var slotIndex = 0;
foreach (var slot in actionBar.Slot)
foreach (var slot in actionBar->Slot)
{
var hotBarSlot = hotbar->Slot[slotIndex];
var highLightId = 0x53550000 + index;
Expand All @@ -159,7 +161,7 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething)
{
var iconAddon = slot.Icon;
if (!iconAddon->AtkResNode.IsVisible) continue;
actionBar.PulseActionBarSlot(slotIndex);
actionBar->PulseActionBarSlot(slotIndex);
UIModule.PlaySound(12, 0, 0, 0);
}
slotIndex++;
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ private static unsafe uint[] GetEnemies()

if(!addons.Any()) return new uint[0];
var addon = addons.FirstOrDefault();
var enemy = (AddonEnemyList*)addon;

var numArray = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->GetUiModule()->GetRaptureAtkModule()->AtkModule.AtkArrayDataHolder.NumberArrays[19];
List<uint> list = new List<uint>(addon.EnemyCount);
for (var i = 0; i < addon.EnemyCount; i++)
List<uint> list = new List<uint>(enemy->EnemyCount);
for (var i = 0; i < enemy->EnemyCount; i++)
{
list.Add((uint)numArray->IntArray[8 + i * 6]);
}
Expand Down

0 comments on commit 2a3037a

Please sign in to comment.