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

Commit

Permalink
fix: fixed icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 11, 2023
1 parent 7a647ef commit 4cd7ff5
Show file tree
Hide file tree
Showing 189 changed files with 542 additions and 74 deletions.
439 changes: 439 additions & 0 deletions Images/HowAndWhenToClick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions RotationSolver.Basic/Attributes/LinkDescriptionAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Dalamud.Utility;
using ECommons.ImGuiMethods;
using ImGuiScene;
using static System.Windows.Forms.LinkLabel;

namespace RotationSolver.Basic.Attributes;
namespace RotationSolver.Basic.Attributes;

/// <summary>
/// The link to a image or web about your rotation.
Expand All @@ -30,7 +25,7 @@ public LinkDescriptionAttribute(string path, string description = "")
/// <summary>
/// Link description itself.
/// </summary>
public class LinkDescription
public struct LinkDescription
{
/// <summary>
/// Description.
Expand Down
11 changes: 11 additions & 0 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ private static string ToCommandStr(object obj)

public static LinkDescription[] ToAction(this PluginConfigFloat config) => config switch
{
PluginConfigFloat.ActionAhead => new LinkDescription[]
{
new LinkDescription()
{
Path = "https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/HowAndWhenToClick.svg",
Description = "This plugin helps you to use the right action during the combat. Here is a guide about the different options.",
},
},
//PluginConfigFloat.MinLastAbilityAdvanced => new LinkDescription[]
//{
//},
_ => null,
};

Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Commands_ChangeSettingsValue": "Modify {0} to {1}",
"Commands_ChangeRotationConfig": "Modify {0} to {1}",
"Commands_CannotFindRotationConfig": "Failed to find the config in this rotation, please check it.",
"Commands_CannotFindConfig": "Failed to find the config, please check it.",
"Commands_InsertAction": "Will use it within {0}s",
"Commands_InsertActionFailure": "Can not find the action, please check the action name.",
"ConfigWindow_Header": "Rotation Solver Settings v",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 2 additions & 1 deletion RotationSolver/RotationSolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj" />
<ProjectReference Include="..\XIVPainter\XIVPainter\XIVPainter.csproj" />
<EmbeddedResource Include="Localization\*.json" Exclude="Localization\Localization.json" />

<EmbeddedResource Include="Logos\*.png" />

<Using Include="Dalamud.Game.ClientState.Objects.Types" />

<Using Include="RotationSolver.Basic" />
Expand Down
13 changes: 7 additions & 6 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,21 @@ internal static void ToggleConfigWindow()
internal static void UpdateDisplayWindow()
{
var isValid = validDelay.Delay(MajorUpdater.IsValid
&& (!Service.Config.OnlyShowWithHostileOrInDuty
|| Svc.Condition[ConditionFlag.BoundByDuty]
|| DataCenter.AllHostileTargets.Any(o => o.DistanceToPlayer() <= 25))
&& RotationUpdater.RightNowRotation != null
&& !Svc.Condition[ConditionFlag.OccupiedInCutSceneEvent]
&& !Svc.Condition[ConditionFlag.Occupied38] //Treasure hunt.
&& !Svc.Condition[ConditionFlag.BetweenAreas]
&& !Svc.Condition[ConditionFlag.BetweenAreas51]
&& !Svc.Condition[ConditionFlag.WaitingForDuty]
&& (!Svc.Condition[ConditionFlag.UsingParasol] || Player.Object.StatusFlags.HasFlag(Dalamud.Game.ClientState.Objects.Enums.StatusFlags.WeaponOut))
&& !Svc.Condition[ConditionFlag.OccupiedInQuestEvent]);

_nextActionWindow.IsOpen = isValid && Service.Config.ShowNextActionWindow;

isValid &= !Service.Config.OnlyShowWithHostileOrInDuty
|| Svc.Condition[ConditionFlag.BoundByDuty]
|| DataCenter.AllHostileTargets.Any(o => o.DistanceToPlayer() <= 25);

_controlWindow.IsOpen = isValid && Service.Config.ShowControlWindow;
_nextActionWindow.IsOpen = Service.Config.ShowNextActionWindow;
_cooldownWindow.IsOpen = isValid && Service.Config.ShowCooldownWindow;

}
}
94 changes: 47 additions & 47 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
//}

var link = rotation.GetType().GetCustomAttribute<SourceCodeAttribute>();
if(link != null)
if (link != null)
{
ImGui.SameLine();
Spacing();
Expand All @@ -558,53 +558,53 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation

HoveredString(LocalizationManager.RightLang.ConfigWindow_Helper_OpenSource);

var attrs = rotation.GetType().GetCustomAttributes<LinkDescriptionAttribute>();
if (attrs.Any())
{
var display = ImGui.GetIO().DisplaySize * 0.7f;
//var attrs = rotation.GetType().GetCustomAttributes<LinkDescriptionAttribute>();
//if (attrs.Any())
//{
// var display = ImGui.GetIO().DisplaySize * 0.7f;

bool isFirst = true;
foreach (var texture in attrs)
{
ImGui.SameLine();
if(isFirst)
{
isFirst = false;
Spacing();
}
//var hasTexture = texture.Texture != null;

//if (IconButton(hasTexture ? FontAwesomeIcon.Image : FontAwesomeIcon.Question,
// "Button" + rotation.GetHashCode().ToString() + texture.GetHashCode().ToString()))
//{
// try
// {
// Util.OpenLink(texture.Path);
// }
// catch
// {
// }
//}
//if (ImGui.IsItemHovered() && (hasTexture || !string.IsNullOrEmpty( texture.Description)))
//{
// ImguiTooltips.ShowTooltip(() =>
// {
// if(hasTexture)
// {
// var ratio = Math.Min(1, Math.Min(display.X / texture.Texture.Width, display.Y / texture.Texture.Height));
// var size = new Vector2(texture.Texture.Width * ratio,
// texture.Texture.Height * ratio);
// ImGui.Image(texture.Texture.ImGuiHandle, size);
// }
// if (!string.IsNullOrEmpty(texture.Description))
// {
// ImGui.Text(texture.Description);
// }

// });
//}
}
}
// bool isFirst = true;
// foreach (var texture in attrs)
// {
// ImGui.SameLine();
// if(isFirst)
// {
// isFirst = false;
// Spacing();
// }
// //var hasTexture = texture.Texture != null;

// //if (IconButton(hasTexture ? FontAwesomeIcon.Image : FontAwesomeIcon.Question,
// // "Button" + rotation.GetHashCode().ToString() + texture.GetHashCode().ToString()))
// //{
// // try
// // {
// // Util.OpenLink(texture.Path);
// // }
// // catch
// // {
// // }
// //}
// //if (ImGui.IsItemHovered() && (hasTexture || !string.IsNullOrEmpty( texture.Description)))
// //{
// // ImguiTooltips.ShowTooltip(() =>
// // {
// // if(hasTexture)
// // {
// // var ratio = Math.Min(1, Math.Min(display.X / texture.Texture.Width, display.Y / texture.Texture.Height));
// // var size = new Vector2(texture.Texture.Width * ratio,
// // texture.Texture.Height * ratio);
// // ImGui.Image(texture.Texture.ImGuiHandle, size);
// // }
// // if (!string.IsNullOrEmpty(texture.Description))
// // {
// // ImGui.Text(texture.Description);
// // }

// // });
// //}
// }
//}
}, () =>
{
RotationConfigWindow.DrawRotationRole(rotation, canAddButton);
Expand Down
44 changes: 32 additions & 12 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
Expand All @@ -12,6 +13,7 @@
using RotationSolver.TextureItems;
using RotationSolver.Updaters;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using GAction = Lumina.Excel.GeneratedSheets.Action;

namespace RotationSolver.UI;
Expand Down Expand Up @@ -172,28 +174,47 @@ private void DrawSideBar()
}
}

private const int FRAME_COUNT = 180;
private static readonly SortedList<string, TextureWrap> _textureWrapList = new (FRAME_COUNT);
private static bool GetLocalImage(string name, out TextureWrap texture)
{
var url = $"RotationSolver.Logos.{name}.png";
if (_textureWrapList.TryGetValue(name, out texture)) return true;

using var stream = typeof(RotationConfigWindowNew).Assembly.GetManifestResourceStream(url);
if (stream == null) return false;

using var memory = new MemoryStream();
stream.CopyTo(memory);
texture = Svc.PluginInterface.UiBuilder.LoadImage(memory.ToArray());
if(texture == null) return false;
_textureWrapList[url] = texture;
return true;
}

private void DrawHeader(float wholeWidth)
{
var size = MathF.Max(MathF.Min(wholeWidth, _scale * 120), _scale * MIN_COLUMN_WIDTH);

int realFrame = 180;
int realFrame = FRAME_COUNT;
if (Service.ConfigNew.GetValue(Basic.Configuration.PluginConfigBool.DrawIconAnimation))
{
var frame = Environment.TickCount / 100; //10fps
realFrame = frame % 60 * 3; // convert to 30 fps.
if (realFrame == 0) realFrame = 180;
var frame = Environment.TickCount / 34; //30
realFrame = frame % FRAME_COUNT;
if (realFrame == 0) realFrame = FRAME_COUNT;
}

if (IconSet.GetTexture($"https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/Logos/{realFrame: D4}.png", out var logo)
|| IconSet.GetTexture(0, out logo))
if (GetLocalImage(realFrame.ToString("0000"), out var logo) && IconSet.GetTexture(0, out var overlay))
{
DrawItemMiddle(() =>
{
if (SilenceImageButton(logo.ImGuiHandle, Vector2.One * size,
var cursor = ImGui.GetCursorPos();
if (SilenceImageButton(overlay.ImGuiHandle, Vector2.One * size,
_activeTab == RotationConfigWindowTab.About))
{
_activeTab = RotationConfigWindowTab.About;
}
ImGui.SetCursorPos(cursor);
ImGui.Image(logo.ImGuiHandle, Vector2.One * size);
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_About_Punchline);
}, wholeWidth, size);

Expand Down Expand Up @@ -254,7 +275,6 @@ private void DrawHeader(float wholeWidth)
ImGui.EndGroup();
}, wholeWidth, horizonalWholeWidth);
}

}
}

Expand Down Expand Up @@ -668,11 +688,11 @@ private static void DrawRotationDescription()

foreach (var link in links)
{
DrawLinkDescription(link.LinkDescription, wholeWidth);
DrawLinkDescription(link.LinkDescription, wholeWidth, true);
}
}

internal static void DrawLinkDescription(LinkDescription link, float wholeWidth)
internal static void DrawLinkDescription(LinkDescription link, float wholeWidth, bool drawQuestion)
{
var hasTexture = IconSet.GetTexture(link.Path, out var texture);

Expand All @@ -683,7 +703,7 @@ internal static void DrawLinkDescription(LinkDescription link, float wholeWidth)

ImGui.TextWrapped(link.Description);

if (!hasTexture && !string.IsNullOrEmpty(link.Path))
if (drawQuestion && !hasTexture && !string.IsNullOrEmpty(link.Path))
{
if (ImGuiEx.IconButton(FontAwesomeIcon.Question, link.Description))
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void ShowTooltip(Job job, bool showHand = true)

foreach (var tooltip in Tooltips)
{
RotationConfigWindowNew.DrawLinkDescription(tooltip, wholeWidth);
RotationConfigWindowNew.DrawLinkDescription(tooltip, wholeWidth, false);
}
});
}
Expand Down

0 comments on commit 4cd7ff5

Please sign in to comment.