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

Commit

Permalink
fix: update the submodule.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 10, 2024
1 parent 4ab8bfc commit d50856b
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 126 deletions.
55 changes: 3 additions & 52 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using ECommons.ExcelServices;
using ECommons.ImGuiMethods;
using Lumina.Excel.GeneratedSheets;
using Svg;
using System.Drawing.Imaging;
using XIVConfigUI;

namespace RotationSolver.Basic.Data;
Expand Down Expand Up @@ -80,60 +78,13 @@ public enum IconType : byte
/// </summary>
public static class IconSet
{
/// <summary>
/// Init for svg rendering.
/// </summary>
public static void InIt()
{
ThreadLoadImageHandler.AddConversionToBitmap(SvgToPng);
}

private static byte[] SvgToPng(byte[] data)
{
using var stream = new MemoryStream(data);
using var outStream = new MemoryStream();
var svgDocument = SvgDocument.Open<SvgDocument>(stream);
using var bitmap = svgDocument.Draw();
bitmap.Save(outStream, ImageFormat.Png);
return outStream.ToArray();
}

/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <param name="texture"></param>
/// <returns></returns>
public static bool GetTexture(this ITexture text, out IDalamudTextureWrap texture) => GetTexture(text?.IconID ?? 0, out texture);


/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="texture"></param>
/// <param name="default"></param>
/// <returns></returns>
public static bool GetTexture(uint id, out IDalamudTextureWrap texture, uint @default = 0)
=> ThreadLoadImageHandler.TryGetIconTextureWrap(id, true, out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(id, false, out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(@default, true, out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(@default, false, out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(0, true, out texture);

/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <param name="texture"></param>
/// <param name="loadingIcon"></param>
/// <returns></returns>
public static bool GetTexture(string path, out IDalamudTextureWrap texture, bool loadingIcon = false)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture)
|| loadingIcon && ThreadLoadImageHandler.TryGetTextureWrap("ui/uld/image2.tex", out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out texture); // loading pics.

private static readonly Dictionary<ActionID, uint> _actionIcons = [];
public static bool GetTexture(this ITexture text, out IDalamudTextureWrap texture) => ImageLoader.GetTexture(text?.IconID ?? 0, out texture);

/// <summary>
///
Expand All @@ -150,7 +101,7 @@ public static bool GetTexture(this IAction? action, out IDalamudTextureWrap text
}
else
{
return GetTexture(action?.IconID ?? 0, out texture, 0);
return ImageLoader.GetTexture(action?.IconID ?? 0, out texture, 0);
}
}

Expand All @@ -160,7 +111,7 @@ public static bool GetTexture(this IAction? action, out IDalamudTextureWrap text
/// <param name="actionID"></param>
/// <param name="texture"></param>
/// <returns></returns>
public static bool GetTexture(this ActionID actionID, out IDalamudTextureWrap texture) => XIVConfigUIMain.GetTextureAction((uint)actionID, out texture);
public static bool GetTexture(this ActionID actionID, out IDalamudTextureWrap texture) => ImageLoader.GetTextureAction((uint)actionID, out texture);


private static readonly Dictionary<IconType, uint[]> _icons = new()
Expand Down
6 changes: 0 additions & 6 deletions RotationSolver.Basic/Data/UiString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ internal enum UiString
[Description("Load From folder.")]
ActionSequencer_Load,

[Description("Analyses PvE combat information in every frame and finds the best action.")]
ConfigWindow_About_Punchline,

[Description("Game")]
ConfigWindow_Helper_GameVersion,

Expand All @@ -37,9 +34,6 @@ internal enum UiString
[Description("You're tiring RS out, give it a break!")]
ConfigWindow_About_Clicking500k,

[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.")]
ConfigWindow_About_Description,

[Description("It is designed for GENERAL COMBAT, not for savage or ultimate. Use it carefully.")]
ConfigWindow_About_Warning,

Expand Down
4 changes: 0 additions & 4 deletions RotationSolver.Basic/RotationSolver.Basic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@

<ProjectReference Include="..\XIVDrawer\XIVDrawer\XIVDrawer.csproj" />

<PackageReference Include="Svg" Version="3.4.7" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<None Include="..\Images\Logo.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
Expand Down
2 changes: 0 additions & 2 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
"RotationSolver.Data.UiString.ActionAttack": "Attack",
"RotationSolver.Data.UiString.ActionAbility": "Ability",
"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!",
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
{
ECommonsMain.Init(pluginInterface, this, ECommons.Module.DalamudReflector, ECommons.Module.ObjectFunctions);
ThreadLoadImageHandler.TryGetIconTextureWrap(0, true, out _);
IconSet.InIt();

_dis.Add(new Service());
try
Expand Down
22 changes: 11 additions & 11 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static void DrawCondition(bool? tag, string id, ref bool isNot)
float size = IconSize * (1 + 8 / 82);
if (!tag.HasValue)
{
if (IconSet.GetTexture("ui/uld/image2.tex", out var texture, true) || IconSet.GetTexture(0u, out texture))
if (ImageLoader.GetTexture("ui/uld/image2.tex", out var texture) || IconSet.GetTexture(0u, out texture))
{
if (ImGuiHelper.SilenceImageButton(texture.ImGuiHandle, Vector2.One * size, false, id))
{
Expand All @@ -46,7 +46,7 @@ internal static void DrawCondition(bool? tag, string id, ref bool isNot)
}
else
{
if (IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture, true))
if (ImageLoader.GetTexture("ui/uld/readycheck_hr1.tex", out var texture))
{
if (ImGuiHelper.SilenceImageButton(texture.ImGuiHandle, Vector2.One * size,
new Vector2(tag.Value ? 0 : 0.5f, 0),
Expand All @@ -65,14 +65,14 @@ internal static void DrawCondition(bool? tag)

if (!tag.HasValue)
{
if (IconSet.GetTexture("ui/uld/image2.tex", out var texture, true) || IconSet.GetTexture(0u, out texture))
if (ImageLoader.GetTexture("ui/uld/image2.tex", out var texture) || IconSet.GetTexture(0u, out texture))
{
ImGui.Image(texture.ImGuiHandle, Vector2.One * size);
}
}
else
{
if (IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture, true))
if (ImageLoader.GetTexture("ui/uld/readycheck_hr1.tex", out var texture))
{
ImGui.Image(texture.ImGuiHandle, Vector2.One * size,
new Vector2(tag.Value ? 0 : 0.5f, 0),
Expand Down Expand Up @@ -360,7 +360,7 @@ private static void DrawAfter(this TraitCondition traitCondition, ICustomRotatio
}
}

if (traitCondition._trait?.GetTexture(out var icon) ?? false || IconSet.GetTexture(4, out icon))
if (traitCondition._trait?.GetTexture(out var icon) ?? false || ImageLoader.GetTexture(4, out icon))
{
var cursor = ImGui.GetCursorPos();
if (ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, Vector2.One * IconSize, traitCondition.GetHashCode().ToString()))
Expand Down Expand Up @@ -394,7 +394,7 @@ private static void DrawAfter(this ActionCondition actionCondition, ICustomRotat

ActionSelectorPopUp(popUpKey, _actionsList, rotation, item => actionCondition.ID = (ActionID)item.ID);

if ((actionCondition._action?.GetTexture(out var icon) ?? false) || IconSet.GetTexture(4, out icon))
if ((actionCondition._action?.GetTexture(out var icon) ?? false) || ImageLoader.GetTexture(4, out icon))
{
var cursor = ImGui.GetCursorPos();
if (ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, Vector2.One * IconSize, actionCondition.GetHashCode().ToString()))
Expand Down Expand Up @@ -645,7 +645,7 @@ private static void DrawAfter(this RotationCondition rotationCondition, ICustomR

ActionSelectorPopUp(popUpKey, _actionsList, rotation, item => rotationCondition.ID = (ActionID)item.ID);

if (rotationCondition._action?.GetTexture(out var icon) ?? false || IconSet.GetTexture(4, out icon))
if (rotationCondition._action?.GetTexture(out var icon) ?? false || ImageLoader.GetTexture(4, out icon))
{
var cursor = ImGui.GetCursorPos();
if (ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, Vector2.One * IconSize, rotationCondition.GetHashCode().ToString()))
Expand Down Expand Up @@ -705,8 +705,8 @@ private static void DrawAfter(this TargetCondition targetCondition, ICustomRotat
}
});

if (targetCondition._action != null ? targetCondition._action.GetTexture(out var icon) || IconSet.GetTexture(4, out icon)
: IconSet.GetTexture(targetCondition.TargetType switch
if (targetCondition._action != null ? targetCondition._action.GetTexture(out var icon) || ImageLoader.GetTexture(4, out icon)
: ImageLoader.GetTexture(targetCondition.TargetType switch
{
TargetType.Target => 16u,
TargetType.HostileTarget => 15u,
Expand Down Expand Up @@ -739,8 +739,8 @@ private static void DrawAfter(this TargetCondition targetCondition, ICustomRotat

void DrawStatusIcon()
{
if (IconSet.GetTexture(targetCondition.Status?.Icon ?? 16220, out var icon)
|| IconSet.GetTexture(16220, out icon))
if (ImageLoader.GetTexture(targetCondition.Status?.Icon ?? 16220, out var icon)
|| ImageLoader.GetTexture(16220, out icon))
{
if (ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(IconSize * 3 / 4, IconSize) * ImGuiHelpers.GlobalScale, targetCondition.GetHashCode().ToString()))
{
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static void DrawCommandAction(IAction? ability, SpecialCommandType command, Vect

static void DrawCommandAction(uint iconId, SpecialCommandType command, Vector4 color)
{
if (IconSet.GetTexture(iconId, out var texture)) DrawCommandAction(texture, command, color);
if (ImageLoader.GetTexture(iconId, out var texture)) DrawCommandAction(texture, command, color);
}

static void DrawCommandAction(IDalamudTextureWrap texture, SpecialCommandType command, Vector4 color, string helpAddition = "")
Expand Down Expand Up @@ -375,12 +375,11 @@ static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 col
var help = command.Local();
string baseId = "ImgButton" + command.ToString();

if (IconSet.GetTexture(iconId, out var texture))
if (ImageLoader.GetTexture(iconId, out var texture))
{
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2));
DrawIAction(texture.ImGuiHandle, baseId, abilityW, command, help);
}

}
}

Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ECommons.GameHelpers;
using RotationSolver.Basic.Configuration;
using RotationSolver.Updaters;
using XIVConfigUI;
using XIVDrawer;
using XIVDrawer.Element3D;
using XIVDrawer.ElementSpecial;
Expand Down Expand Up @@ -127,7 +128,7 @@ public static void Init()

if (DataCenter.State && Service.Config.ShowStateIcon)
{
if (IconSet.GetTexture(61516, out var texture))
if (ImageLoader.GetTexture(61516, out var texture))
{
_stateImage.Image = texture;
_stateImage.Size = Service.Config.StateIconSize;
Expand Down Expand Up @@ -227,7 +228,7 @@ private static unsafe void UpdateHostileIcons()
return;
}

if (!IconSet.GetTexture(61510, out var hostileIcon)) return;
if (!ImageLoader.GetTexture(61510, out var hostileIcon)) return;

for (int i = 0; i < Math.Min(TargetsDrawings.Length, DataCenter.AllHostileTargets.Length); i++)
{
Expand Down
Loading

0 comments on commit d50856b

Please sign in to comment.