This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e1acf9
commit 1eb3705
Showing
5 changed files
with
127 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 85 additions & 79 deletions
164
RotationSolver/Rotations/CustomRotation/CustomRotation_Display.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters