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

Commit

Permalink
fix: update rotation attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 12, 2023
1 parent 9c4ed80 commit 6980efd
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>ArchiTed</Authors>
<Version>3.1.4</Version>
<Version>3.1.4.1</Version>
<PlatformTarget>x64</PlatformTarget>
<Platforms>AnyCPU</Platforms>

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Attributes/AssemblyLinkAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AssemblyLinkAttribute : Attribute
/// <param name="helpLink"></param>
/// <param name="changeLog"></param>
/// <param name="donate"><see cref="Donate"/></param>
[Obsolete("Never use it anymore, it'll be deleted in a month!")]
[Obsolete("Never use it anymore, it'll be deleted in a month!", true)]
public AssemblyLinkAttribute(string supportLink = null, string helpLink = null,
string changeLog = null, string donate = null)
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Attributes/AuthorHashAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AuthorHashAttribute : Attribute
/// Constructer
/// </summary>
/// <param name="hash"><see cref="Hash"/></param>
[Obsolete]
[Obsolete("This method will be deleted in one month.", true)]
public AuthorHashAttribute(string hash)
{
Hash = hash;
Expand Down
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Attributes/LinkDescriptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class LinkDescriptionAttribute : Attribute
/// <summary>
/// Constructer.
/// </summary>
/// <param name="path"></param>
/// <param name="url"></param>
/// <param name="description"></param>
public LinkDescriptionAttribute(string path, string description = "")
public LinkDescriptionAttribute(string url, string description = "")
{
LinkDescription = new() { Path = path, Description = description };
LinkDescription = new() { Url = url, Description = description };
}
}

Expand All @@ -35,5 +35,5 @@ public struct LinkDescription
/// <summary>
/// Url.
/// </summary>
public string Path { get; init; }
public string Url { get; init; }
}
10 changes: 5 additions & 5 deletions RotationSolver.Basic/Attributes/SourceCodeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ public class SourceCodeAttribute : Attribute
/// <summary>
/// The link to the source code.
/// </summary>
public string Url { get; set; }
public string Path { get; set; }

/// <summary>
/// Constructer.
/// </summary>
/// <param name="url"></param>
[Obsolete]
public SourceCodeAttribute(string url)
/// <param name="path"></param>
[Obsolete("This method will be deleted in several months.", true)]
public SourceCodeAttribute(string path)
{
Url = url;
Path = path;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static string ToCommandStr(object obj)
{
new LinkDescription()
{
Path = "https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/HowAndWhenToClick.svg",
Url = "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.",
},
},
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,9 @@
"ConfigWindow_Rotations_Loaded": "Loaded",
"ConfigWindow_Rotations_GitHub": "GitHub",
"ConfigWindow_Rotations_Libraries": "Libraries",
"ConfigWindow_Rotations_AutoLoadCustomRotations": "Auto load rotations"
"ConfigWindow_Rotations_AutoLoadCustomRotations": "Auto load rotations",
"ConfigWindow_Rotations_UserName": "User Name",
"ConfigWindow_Rotations_Repository": "Repository",
"ConfigWindow_Rotations_FileName": "File Name",
"ConfigWindow_Rotations_Library": "The folder contains rotation libs or the download url about rotation lib."
}
7 changes: 7 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,11 @@ internal partial class Strings
public string ConfigWindow_Rotations_GitHub { get; set; } = "GitHub";
public string ConfigWindow_Rotations_Libraries { get; set; } = "Libraries";
public string ConfigWindow_Rotations_AutoLoadCustomRotations { get; set; } = "Auto load rotations";

public string ConfigWindow_Rotations_UserName { get; set; } = "User Name";
public string ConfigWindow_Rotations_Repository { get; set; } = "Repository";

public string ConfigWindow_Rotations_FileName { get; set; } = "File Name";

public string ConfigWindow_Rotations_Library { get; set; } = "The folder contains rotation libs or the download url about rotation lib.";
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
{
try
{
Util.OpenLink(link.Url);
Util.OpenLink(link.Path);
}
catch
{
Expand Down
67 changes: 36 additions & 31 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ private static void DrawItemMiddle(System.Action drawAction, float wholeWidth, f
drawAction();
}

private static float BodyMargin => 8 * _scale;
private void DrawBody()
{
var margin = 8 * _scale;
var margin = BodyMargin;
ImGui.SetCursorPos(ImGui.GetCursorPos() + Vector2.One * margin);
if (ImGui.BeginChild("Rotation Solver Body", Vector2.One * -margin))
{
Expand Down Expand Up @@ -695,20 +696,20 @@ private static void DrawRotationDescription()

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

if (hasTexture && TextureButton(texture, wholeWidth, wholeWidth))
{
Util.OpenLink(link.Path);
Util.OpenLink(link.Url);
}

ImGui.TextWrapped(link.Description);

if (drawQuestion && !hasTexture && !string.IsNullOrEmpty(link.Path))
if (drawQuestion && !hasTexture && !string.IsNullOrEmpty(link.Url))
{
if (ImGuiEx.IconButton(FontAwesomeIcon.Question, link.Description))
{
Util.OpenLink(link.Path);
Util.OpenLink(link.Url);
}
}
}
Expand Down Expand Up @@ -738,25 +739,13 @@ private static void DrawRotationInformation()
{
var rotation = RotationUpdater.RightNowRotation;
if (rotation == null) return;
var wholeWidth = ImGui.GetWindowWidth();

var link = rotation.GetType().GetCustomAttribute<SourceCodeAttribute>();

if (link != null)
{
if (IconSet.GetTexture("https://GitHub.GitHubassets.com/images/modules/logos_page/GitHub-Logo.png", out var icon) && TextureButton(icon, wholeWidth, 200 * _scale))
{
Util.OpenLink(link.Url);
}
}

var assembly = rotation.GetType().Assembly;
var info = assembly.GetInfo();

if (info != null )
if (info != null)
{
ImGui.Text("Assembly Name: ");
ImGui.SameLine();
ImGui.BeginGroup();
if (ImGui.Button(info.Name))
{
Process.Start("explorer.exe", "/select, \"" + info.FilePath + "\"");
Expand All @@ -765,10 +754,20 @@ private static void DrawRotationInformation()
var version = assembly.GetName().Version;
if (version != null)
{
ImGui.Text("Assembly Version: " + version.ToString());
ImGui.Text("v " + version.ToString());
}

ImGui.Text("Assembly Author: " + info.Author);
ImGui.Text("- " + info.Author);
ImGui.EndGroup();

var link = rotation.GetType().GetCustomAttribute<SourceCodeAttribute>();
if(link != null)
{
ImGui.SameLine();
var userName = info.GitHubUserName;
var repository = info.GitHubRepository;
DrawGitHubBadge(userName, repository, $"https://github.com/{userName}/{repository}/blob/{link.Path}");
}
}
}
#endregion
Expand Down Expand Up @@ -1014,13 +1013,13 @@ private static void DrawRotationsLoaded()
}
}

private static void DrawGitHubBadge(string userName, string repository, string id = "")
private static void DrawGitHubBadge(string userName, string repository, string id = "", string link = "")
{
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(repository)
&& IconSet.GetTexture($"https://GitHub-readme-stats.vercel.app/api/pin/?username={userName}&repo={repository}&theme=dark", out var icon)
&& NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(icon.Width, icon.Height),id))
&& NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(icon.Width, icon.Height), id))
{
Util.OpenLink($"https://GitHub.com/{userName}/{repository}");
Util.OpenLink(string.IsNullOrEmpty(link) ? $"https://GitHub.com/{userName}/{repository}" : link);
}
}

Expand All @@ -1045,16 +1044,19 @@ private static void DrawRotationsGitHub()

var changed = false;

ImGui.SetNextItemWidth(120 * _scale);
changed |= ImGui.InputText($"##GitHubLib{i}UserName", ref userName, 1024);
var width = ImGui.GetWindowWidth() - ImGuiEx.CalcIconSize(FontAwesomeIcon.Ban).X - ImGui.GetStyle().ItemSpacing.X * 3 - BodyMargin;
width /= 3;

ImGui.SetNextItemWidth(width);
changed |= ImGui.InputTextWithHint($"##GitHubLib{i}UserName", LocalizationManager.RightLang.ConfigWindow_Rotations_UserName, ref userName, 1024);
ImGui.SameLine();

ImGui.SetNextItemWidth(120 * _scale);
changed |= ImGui.InputText($"##GitHubLib{i}Repository", ref repository, 1024);
ImGui.SetNextItemWidth(width);
changed |= ImGui.InputTextWithHint($"##GitHubLib{i}Repository", LocalizationManager.RightLang.ConfigWindow_Rotations_Repository, ref repository, 1024);
ImGui.SameLine();

ImGui.SetNextItemWidth(120 * _scale);
changed |= ImGui.InputText($"##GitHubLib{i}FileName", ref fileName, 1024);
ImGui.SetNextItemWidth(width);
changed |= ImGui.InputTextWithHint($"##GitHubLib{i}FileName", LocalizationManager.RightLang.ConfigWindow_Rotations_FileName, ref fileName, 1024);
ImGui.SameLine();

if(changed)
Expand Down Expand Up @@ -1084,10 +1086,13 @@ private static void DrawRotationsLibraries()

ImGui.Spacing();

var width = ImGui.GetWindowWidth() - ImGuiEx.CalcIconSize(FontAwesomeIcon.Ban).X - ImGui.GetStyle().ItemSpacing.X - BodyMargin;

int removeIndex = -1;
for (int i = 0; i < Service.ConfigNew.GlobalConfig.OtherLibs.Length; i++)
{
ImGui.InputText($"##Rotation Solver OtherLib{i}", ref Service.ConfigNew.GlobalConfig.OtherLibs[i], 1024);
ImGui.SetNextItemWidth(width);
ImGui.InputTextWithHint($"##Rotation Solver OtherLib{i}", LocalizationManager.RightLang.ConfigWindow_Rotations_Library, ref Service.ConfigNew.GlobalConfig.OtherLibs[i], 1024);
ImGui.SameLine();

if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove OtherLibs{i}"))
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using ECommons.Automation;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
Expand Down

0 comments on commit 6980efd

Please sign in to comment.