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

Commit

Permalink
fix: add a desc picutre.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 7, 2023
1 parent 2e1acf9 commit 1eb3705
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 85 deletions.
21 changes: 21 additions & 0 deletions RotationSolver/Attributes/LinkDescAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using ImGuiScene;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Attributes;

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
internal class LinkDescAttribute : Attribute
{
public TextureWrap Texture { get; }
public string Path { get; }
public LinkDescAttribute(string path)
{
Path = path;
Texture = Service.DataManager.GetImGuiTexture(path);
}
}
6 changes: 0 additions & 6 deletions RotationSolver/Attributes/RotationDescAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using Dalamud.Interface.Colors;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Actions;
using RotationSolver.Actions.BaseAction;
using RotationSolver.Commands;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Rotations.CustomRotation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Attributes;

Expand Down
20 changes: 20 additions & 0 deletions RotationSolver/Helpers/ImguiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using ImGuiNET;
using RotationSolver.Attributes;
using RotationSolver.Data;
using RotationSolver.Localization;
using System;
Expand All @@ -15,6 +16,25 @@ namespace RotationSolver.Helpers;

internal static class ImGuiHelper
{
const ImGuiWindowFlags TOOLTIP_FLAG =
ImGuiWindowFlags.Tooltip |
ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoSavedSettings |
ImGuiWindowFlags.NoBringToFrontOnFocus |
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.NoInputs |
ImGuiWindowFlags.AlwaysAutoResize;

public static void DrawTooltip(Action act, string id)
{
if (act == null) return;
ImGui.SetWindowPos(id, ImGui.GetIO().MousePos);
if (ImGui.Begin(id, TOOLTIP_FLAG))
{
act();
ImGui.End();
}
}
public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action selected,
Action<string> showToolTip = null, Action<Action<string>> additonalHeader = null,
Action otherThing = null) where T : class, ITexture
Expand Down
164 changes: 85 additions & 79 deletions RotationSolver/Rotations/CustomRotation/CustomRotation_Display.cs
Original file line number Diff line number Diff line change
@@ -1,115 +1,121 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Utility;
using ImGuiNET;
using RotationSolver.Attributes;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Timeline;
using RotationSolver.Windows.RotationConfigWindow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Reflection;

namespace RotationSolver.Rotations.CustomRotation
namespace RotationSolver.Rotations.CustomRotation;

internal abstract partial class CustomRotation
{
internal abstract partial class CustomRotation
public unsafe void Display(ICustomRotation[] rotations, bool canAddButton)
=> this.DrawEnableTexture(canAddButton, null,
text =>
{
const ImGuiWindowFlags flags =
ImGuiWindowFlags.Tooltip |
ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoSavedSettings |
ImGuiWindowFlags.NoBringToFrontOnFocus |
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.NoInputs|
ImGuiWindowFlags.AlwaysAutoResize;

public unsafe void Display(ICustomRotation[] rotations, bool canAddButton)
=> this.DrawEnableTexture(canAddButton, null,
text =>
ImGui.SetNextWindowSizeConstraints(new Vector2(0, 0), new Vector2(1000, 1500));
ImGuiHelper.DrawTooltip(() =>
{
var id = "Popup" + GetHashCode().ToString();
var t = IconSet.GetTexture(IconSet.GetJobIcon(this, IconType.Framed));
ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height));

ImGui.SetWindowPos(id, ImGui.GetIO().MousePos);
ImGui.SetNextWindowSizeConstraints(new Vector2(0, 0), new Vector2(1000, 1500));
if (ImGui.Begin(id, flags))
if (!string.IsNullOrEmpty(text))
{
var t = IconSet. GetTexture(IconSet.GetJobIcon(this, IconType.Framed));
ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height));

if (!string.IsNullOrEmpty(text))
{
ImGui.SameLine();
ImGui.Text(" ");
ImGui.SameLine();
ImGui.Text(text);
}
ImGui.SameLine();
ImGui.Text(" ");
ImGui.SameLine();
ImGui.Text(text);
}

var type = GetType();
var type = GetType();

var attrs = new List<RotationDescAttribute> { RotationDescAttribute.MergeToOne(type.GetCustomAttributes<RotationDescAttribute>()) };
var attrs = new List<RotationDescAttribute> { RotationDescAttribute.MergeToOne(type.GetCustomAttributes<RotationDescAttribute>()) };

foreach (var m in type.GetAllMethodInfo())
{
attrs.Add(RotationDescAttribute.MergeToOne(m.GetCustomAttributes<RotationDescAttribute>()));
}

foreach (var a in RotationDescAttribute.Merge(attrs))
{
RotationDescAttribute.MergeToOne(a)?.Display(this);
}

ImGui.End();
foreach (var m in type.GetAllMethodInfo())
{
attrs.Add(RotationDescAttribute.MergeToOne(m.GetCustomAttributes<RotationDescAttribute>()));
}

}, showToolTip =>
foreach (var a in RotationDescAttribute.Merge(attrs))
{
RotationDescAttribute.MergeToOne(a)?.Display(this);
}
}, "Popup" + GetHashCode().ToString());
},
showToolTip =>
{
if (!string.IsNullOrEmpty(RotationName) && rotations != null)
{
if (!string.IsNullOrEmpty(RotationName) && rotations != null)
ImGui.SameLine();
ImGui.TextDisabled(" - ");
ImGui.SameLine();
ImGui.SetNextItemWidth(ImGui.CalcTextSize(RotationName).X + 30);
if (ImGui.BeginCombo("##RotationName:" + Name, RotationName))
{
ImGui.SameLine();
ImGui.TextDisabled(" - ");
ImGui.SameLine();
ImGui.SetNextItemWidth(ImGui.CalcTextSize(RotationName).X + 30);
if (ImGui.BeginCombo("##RotationName:" + Name, RotationName))
foreach (var r in rotations)
{
foreach (var r in rotations)
if (ImGui.Selectable(r.RotationName))
{
Service.Configuration.RotationChoices[Job.RowId] = r.RotationName;
Service.Configuration.Save();
}
if (ImGui.IsItemHovered())
{
if (ImGui.Selectable(r.RotationName))
{
Service.Configuration.RotationChoices[Job.RowId] = r.RotationName;
Service.Configuration.Save();
}
if (ImGui.IsItemHovered())
{
showToolTip?.Invoke(r.Description);
}
showToolTip?.Invoke(r.Description);
}
ImGui.EndCombo();
}
ImGuiHelper.HoveredString(LocalizationManager.RightLang.Configwindow_Helper_SwitchRotation);
ImGui.EndCombo();
}
ImGuiHelper.HoveredString(LocalizationManager.RightLang.Configwindow_Helper_SwitchRotation);
}

ImGui.SameLine();
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.SameLine();
ImGui.Text(GameVersion);
ImGui.SameLine();
ImGuiHelper.Spacing();
ImGui.SameLine();
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.SameLine();
ImGui.Text(GameVersion);
ImGui.SameLine();
ImGuiHelper.Spacing();

if (ImGuiHelper.IconButton(FontAwesomeIcon.Globe, GetHashCode().ToString()))
{
var url = @"https://github.com/ArchiDog1998/RotationSolver/blob/main/" + GetType().FullName.Replace(".", @"/") + ".cs";
if (ImGuiHelper.IconButton(FontAwesomeIcon.Globe, GetHashCode().ToString()))
{
var url = @"https://github.com/ArchiDog1998/RotationSolver/blob/main/" + GetType().FullName.Replace(".", @"/") + ".cs";

Util.OpenLink(url);
}
ImGuiHelper.HoveredString(LocalizationManager.RightLang.Configwindow_Helper_OpenSource);
}, () =>
Util.OpenLink(url);
}
ImGuiHelper.HoveredString(LocalizationManager.RightLang.Configwindow_Helper_OpenSource);

ImGui.SameLine();
ImGuiHelper.Spacing();

foreach (var texture in GetType().GetCustomAttributes<LinkDescAttribute>())
{
RotationConfigWindow.DrawRotationRole(this);
if (ImGuiHelper.IconButton(FontAwesomeIcon.HandsHelping,
"Button" + texture.GetHashCode().ToString()))
{
Util.OpenLink(texture.Path);
}
if (ImGui.IsItemHovered() && texture.Texture != null)
{
ImGuiHelper.DrawTooltip(() =>
{
var ratio = Math.Min(1, 1000f / texture.Texture.Width);
var size = new Vector2(texture.Texture.Width * ratio,
texture.Texture.Height * ratio);
ImGui.Image(texture.Texture.ImGuiHandle, size);
}, "Picture" + texture.GetHashCode().ToString());
}
}
}, () =>
{
RotationConfigWindow.DrawRotationRole(this);

Configs.Draw(canAddButton);
});
}
Configs.Draw(canAddButton);
});
}
1 change: 1 addition & 0 deletions RotationSolver/Rotations/Tank/PLD/PLD_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace RotationSolver.Rotations.Tank.PLD;

[RotationDesc("The whole rotation's burst\nis base on:")]
[LinkDesc("https://xiv.sleepyshiba.com/pld/img/63-60stentative2.png")]
[RotationDesc(ActionID.FightorFlight)]
internal class PLD_Default : PLD_Base
{
Expand Down

0 comments on commit 1eb3705

Please sign in to comment.