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

Commit

Permalink
fix: dalamud icon getting bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 19, 2024
1 parent 4365fc8 commit daeefdd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 63570,
"SayingHelloCount": 41,
"ClickingCount": 63571,
"SayingHelloCount": 52,
"SaidUsers": []
}
3 changes: 1 addition & 2 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class BaseAction : IBaseAction

public bool IsCoolingDown => Cooldown.IsCoolingDown;


public uint IconID => Info.IconID;
public uint IconID => ID == 3 ? 104 : Info.IconID;

public string Name => Info.Name;

Expand Down
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public const string
private static readonly bool _showMoveTarget = true;

[ConditionBool, UI("Show Target",
Parent =UiOverlay)]
Filter = UiOverlay)]
private static readonly bool _showTarget = true;

[ConditionBool, UI("Show the target's time to kill.",
Expand Down Expand Up @@ -450,9 +450,9 @@ public const string
[Range(0, 1, ConfigUnitType.Percent, 0.002f)]
public float HealWhenNothingTodoBelow { get; set; } = 0.8f;

[UI("The size of the next ability that will be used icon.",
Parent =nameof(ShowTarget))]
[Range(0, 1, ConfigUnitType.Pixels, 0.002f)]
[UI("The target icon size multiply.",
Parent = nameof(ShowTarget))]
[Range(0, 1, ConfigUnitType.Percent, 0.002f)]
public float TargetIconSize { get; set; } = 0.6f;

[UI("How likely is it that RS will click the wrong action.",
Expand Down
41 changes: 19 additions & 22 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static bool GetTexture(string path, out IDalamudTextureWrap texture, bool
|| loadingIcon && ThreadLoadImageHandler.TryGetTextureWrap("ui/uld/image2.tex", out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out texture); // loading pics.

private static readonly Dictionary<uint, uint> _actionIcons = new();
private static readonly Dictionary<ActionID, uint> _actionIcons = [];

/// <summary>
///
Expand All @@ -141,41 +141,38 @@ public static bool GetTexture(string path, out IDalamudTextureWrap texture, bool
/// <returns></returns>
public static bool GetTexture(this IAction? action, out IDalamudTextureWrap texture, bool isAdjust = true)
{
uint iconId = 0;
if (action != null)
if (isAdjust)
{
var id = isAdjust ? action.AdjustedID : action.ID;

if (!_actionIcons.TryGetValue(id, out iconId))
{
iconId = id == action.ID ? action.IconID : action is IBaseAction
? Service.GetSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(id)!.Icon
: Service.GetSheet<Item>().GetRow(id)!.Icon;

_actionIcons[id] = iconId;
}
return GetTexture((ActionID)(action?.AdjustedID ?? 0), out texture);
}
else
{
return GetTexture(action?.IconID ?? 0, out texture, 0);
}
return GetTexture(iconId, out texture);
}

/// <summary>
///
/// </summary>
/// <param name="actionID"></param>
/// <param name="texture"></param>
/// <param name="isAction"></param>
/// <returns></returns>
public static bool GetTexture(this ActionID actionID, out IDalamudTextureWrap texture, bool isAction = true)
public static bool GetTexture(this ActionID actionID, out IDalamudTextureWrap texture)
{
var id = (uint)actionID;
if (actionID == ActionID.None)
{
return GetTexture(0, out texture, 0);
}
if(actionID == ActionID.SprintPvE)
{
return GetTexture(104, out texture, 0);
}

if (!_actionIcons.TryGetValue(id, out var iconId))
if (!_actionIcons.TryGetValue(actionID, out var iconId))
{
iconId = isAction
? Service.GetSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(id)!.Icon
: Service.GetSheet<Item>().GetRow(id)!.Icon;
iconId = Service.GetSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow((uint)actionID)?.Icon ?? 0;

_actionIcons[id] = iconId;
_actionIcons[actionID] = iconId;
}
return GetTexture(iconId, out texture);
}
Expand Down
24 changes: 1 addition & 23 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,5 @@
"RotationSolver.Basic.Data.TargetHostileType.TargetsHaveTarget": "Previously engaged targets (engages on countdown timer)",
"RotationSolver.Data.UiString.ActionAbility": "Ability",
"RotationSolver.Data.UiString.ActionAttack": "Attack",
"RotationSolver.Data.UiString.ActionFriendly": "Friendly",
"RotationSolver.Data.UiString.ConfigWindow_About_Punchline": "Analyses PvE combat information in every frame and finds the best action.",
"RotationSolver.Data.UiString.ConfigWindow_About_Clicking100k": "Well, you must be a lazy player!",
"RotationSolver.Data.UiString.ConfigWindow_About_Clicking500k": "You're tiring RS out, give it a break!",
"RotationSolver.Data.UiString.ConfigWindow_Helper_GameVersion": "Game",
"RotationSolver.Data.UiString.ConfigWindow_Helper_SwitchRotation": "Click to switch rotations",
"RotationSolver.Data.UiString.ConfigWindow_ConditionSetDesc": "The condition set you chose, click to modify.",
"RotationSolver.Data.UiString.ConfigWindow_Searching": "Search... ",
"RotationSolver.Data.UiString.ConfigWindow_About_Description": "This means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\n\nThen, it will highlight the best action on the hot bar, or help you to click on it.",
"RotationSolver.Data.UiString.ConfigWindow_About_Warning": "It is designed for GENERAL COMBAT, not for savage or ultimate. Use it carefully.",
"RotationSolver.Data.UiString.ConfigWindow_About_ClickingCount": "Rotation Solver helped you by clicking actions {0:N0} times.",
"RotationSolver.Data.UiString.ConfigWindow_About_SayHelloCount": "You have said hello to other users {0:N0} times!",
"RotationSolver.Data.UiString.ConfigWindow_About_Macros": "Macro",
"RotationSolver.Data.UiString.ConfigWindow_About_Compatibility": "Compatibility",
"RotationSolver.Data.UiString.ConfigWindow_About_Supporters": "Supporters",
"RotationSolver.Data.UiString.ConfigWindow_About_Links": "Links",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_Description": "Description",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_Status": "Status",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_Configuration": "Configuration",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_Rating": "Rating",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_Information": "Information",
"RotationSolver.Data.UiString.ConfigWindow_Rotation_InvalidRotation": "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!",
"RotationSolver.UI.RotationConfigWindowTab.Actions": "The abilities and custom conditions that your selected job has."
"RotationSolver.Data.UiString.ActionFriendly": "Friendly"
}
5 changes: 4 additions & 1 deletion RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
using RotationSolver.Basic.Configuration;
using RotationSolver.Updaters;
using XIVPainter;
using XIVPainter.Element3D;
using XIVPainter.ElementSpecial;
using static Dalamud.Interface.Utility.Raii.ImRaii;

namespace RotationSolver.UI;

Expand Down Expand Up @@ -125,7 +127,8 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter)
}

if (canDraw && DateTime.Now - _time > TimeSpan.FromSeconds(5))
// why crashing? why? the handle of the texture is fine.
// why crashing? why? the handle of the texture is not valid in the dalamud get icon.
//TODO: want to remove this.
{
_targetImage.Position = act.Target?.Position ?? Player.Object.Position;
if (act.GetTexture(out var texture, true))
Expand Down

0 comments on commit daeefdd

Please sign in to comment.