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

Commit

Permalink
fix: add rotations panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 12, 2023
1 parent 39eb951 commit 23335ad
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 230 deletions.
7 changes: 6 additions & 1 deletion Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,10 @@
12615,
27754,
27481,
26206
26206,
32054,
32112,
32114,
31727,
33018
]
12 changes: 6 additions & 6 deletions Resources/downloadList.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
"https://github.com/ArchiDog1998/FFXIVRotations/releases/latest/download/DefaultRotations.dll",
"https://github.com/ArchiDog1998/FFXIVRotations/releases/latest/download/ExtraRotations.dll",
"https://github.com/RiotNOR/CustomRotations/releases/download/latest/RiotsRotations.dll",
"https://github.com/IncognitoWater/IncognitoWaterRotations/releases/latest/download/IcWaRotations.dll",
"https://github.com/BrakusTapus/KirboRotations/releases/latest/download/KirboRotations.dll",
"https://github.com/thunderebolt/BoltsRotations/releases/latest/download/BoltsRotations.dll"
"ArchiDog1998|FFXIVRotations|DefaultRotations",
"ArchiDog1998|FFXIVRotations|ExtraRotations",
"RiotNOR|CustomRotations|RiotsRotations",
"IncognitoWater|IncognitoWaterRotations|IcWaRotations",
"BrakusTapus|KirboRotations|KirboRotations",
"thunderebolt|BoltsRotations|BoltsRotations"
]
24 changes: 0 additions & 24 deletions RotationSolver.Basic/Attributes/AssemblyGithubAttribute.cs

This file was deleted.

11 changes: 7 additions & 4 deletions RotationSolver.Basic/Attributes/AssemblyLinkAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ public class AssemblyLinkAttribute : Attribute
public string Donate { get; set; }

/// <summary>
/// A link for changelog.
/// A link for your user name in GitHub.
/// </summary>
public string ChangeLog { get; set; }
public string UserName { get; set; }

/// <summary>
/// A link for the repo in your GitHub.
/// </summary>
public string Repository { get; set; }
/// <summary>
/// Constructer.
/// </summary>
/// <param name="supportLink"></param>
/// <param name="helpLink"></param>
/// <param name="changeLog"></param>
/// <param name="donate"><see cref="Donate"/></param>
[Obsolete()]
[Obsolete("Never use it anymore, it'll be deleted in a month!")]
public AssemblyLinkAttribute(string supportLink = null, string helpLink = null,
string changeLog = null, string donate = null)
{
Donate = donate;
ChangeLog = changeLog;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ [Serializable] public class GlobalConfig

public string[] OtherLibs = Array.Empty<string>();

public string[] GithubLibs = Array.Empty<string>();
public string[] GitHubLibs = Array.Empty<string>();
public List<TargetingType> TargetingTypes { get; set; } = new List<TargetingType>();

public MacroInfo DutyStart { get; set; } = new MacroInfo();
Expand Down
29 changes: 28 additions & 1 deletion RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Lumina.Data.Parsing;
using Lumina.Excel.GeneratedSheets;
using Svg;
using System.Collections.Generic;
using System.Drawing.Imaging;

namespace RotationSolver.Basic.Data;
Expand Down Expand Up @@ -131,8 +132,34 @@ public static bool GetTexture(uint id, out TextureWrap texture)
public static TextureWrap GetTexture(string path)
=> GetTexture(path, out var texture) ? texture : null;

/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <param name="texture"></param>
/// <returns></returns>
public static bool GetTexture(string path, out TextureWrap texture)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture);
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture)
|| (path.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || path.StartsWith("https:", StringComparison.OrdinalIgnoreCase))
&& GetLocalImage("loading", out texture); // loading pics.

private static readonly SortedList<string, TextureWrap> _textureWrapList = new();

private static bool GetLocalImage(string name, out TextureWrap texture)
{
var url = $"RotationSolver.Basic.Images.{name}.png";
if (_textureWrapList.TryGetValue(name, out texture)) return true;

using var stream = typeof(IconSet).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;
}

static readonly Dictionary<uint, uint> _actionIcons = new();

Expand Down
Binary file added RotationSolver.Basic/Images/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion RotationSolver.Basic/RotationSolver.Basic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>


<EmbeddedResource Include="Images\*.png" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class Service : IDisposable
{
public const string Command = "/rotation";

// From https://github.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L85-L87
// From https://GitHub.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L85-L87
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C6 0F 8A", ScanType = ScanType.StaticAddress, Fallibility = Fallibility.Infallible)]
static IntPtr forceDisableMovementPtr = IntPtr.Zero;
private static unsafe ref int ForceDisableMovement => ref *(int*)(forceDisableMovementPtr + 4);
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/Data/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ internal record AssemblyInfo(
string Author,
string FilePath,
string DonateLink,
string ChangeLogLink,
string GithubUserName,
string GithubRepository,
string GitHubUserName,
string GitHubRepository,
DateTime LoadTime);
}
8 changes: 3 additions & 5 deletions RotationSolver/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static AssemblyInfo GetInfo(this Assembly assembly)
var location = assembly.Location;
var company = assembly.GetCustomAttribute<AssemblyCompanyAttribute>()?.Company;

var assemblyInfo = new AssemblyInfo(name, company, location, string.Empty, string.Empty, company, name, DateTime.Now);
var assemblyInfo = new AssemblyInfo(name, company, location, string.Empty, company, name, DateTime.Now);

_assemblyInfos[assembly] = assemblyInfo;

Expand Down Expand Up @@ -59,15 +59,13 @@ public static Assembly LoadCustomRotationAssembly(string filePath)
var author = GetAuthor(filePath, assemblyName);

var link = assembly.GetCustomAttribute<AssemblyLinkAttribute>();
var github = assembly.GetCustomAttribute<AssemblyGithubAttribute>();
var assemblyInfo = new AssemblyInfo(
assemblyName,
author,
filePath,
link?.Donate,
link?.ChangeLog,
github?.UserName,
github?.Repository,
link?.UserName,
link?.Repository,
DateTime.Now);

var existingAssembly = GetAssemblyFromPath(filePath);
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ internal static class ConfigTranslation
PluginConfigBool.ShowTooltips => LocalizationManager.RightLang.ConfigWindow_Param_ShowTooltips,
PluginConfigBool.InDebug => LocalizationManager.RightLang.ConfigWindow_Param_InDebug,

//Rotations
PluginConfigBool.DownloadRotations => LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotations,
PluginConfigBool.AutoUpdateRotations => LocalizationManager.RightLang.ConfigWindow_Rotation_AutoUpdateRotations,
PluginConfigBool.AutoLoadCustomRotations => LocalizationManager.RightLang.ConfigWindow_Rotations_AutoLoadCustomRotations,
_ => string.Empty,
};

Expand Down
12 changes: 9 additions & 3 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
"ConfigWindow_Control_ResetButtonOrKeyCommand": "Right click to reset the gamepad button or key board key.\nHold Left Ctrl and middle click to clear the key setting.",
"ConfigWindow_Control_ClickToUse": "Click to use it!",
"ConfigWindow_Rotation_BetaRotation": "Beta Rotation!",
"ConfigWindow_Rotation_DownloadRotations": "Download Rotations.",
"ConfigWindow_Rotation_AutoUpdateRotations": "Auto Update Rotations.",
"ConfigWindow_Rotation_DownloadRotations": "Auto Download Rotations",
"ConfigWindow_Rotation_AutoUpdateRotations": "Auto Update Rotations",
"ConfigWindow_Rotation_InvalidRotation": "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!",
"ConfigWindow_Rotation_ResetToDefault": "Click to reset the rotation configuration to default!",
"ConfigWindow_List_Description": "In this window, you can set the parameters about some list things.",
Expand Down Expand Up @@ -440,5 +440,11 @@
"ConfigWindow_Actions_DisabledConditionSet": "Disabled Condition",
"ConfigWindow_Actions_DisabledConditionSet_Description": "Conditions when automatic use of action is disabled.",
"ConfigWindow_Actions_ShowOnCDWindow": "Show on CD window",
"ConfigWindow_Actions_InsertCommand": "Insert \"{0}\" first in {1}s"
"ConfigWindow_Actions_InsertCommand": "Insert \"{0}\" first in {1}s",
"ConfigWindow_Configs_JobConfigTip": "This config is binding with the job, different job gets different value.",
"ConfigWindow_Rotations_Settings": "Settings",
"ConfigWindow_Rotations_Loaded": "Loaded",
"ConfigWindow_Rotations_GitHub": "GitHub",
"ConfigWindow_Rotations_Libraries": "Libraries",
"ConfigWindow_Rotations_AutoLoadCustomRotations": "Auto load rotations"
}
11 changes: 9 additions & 2 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ internal partial class Strings
public string ConfigWindow_Control_ClickToUse { get; set; } = "Click to use it!";
public string ConfigWindow_Rotation_BetaRotation { get; set; } = "Beta Rotation!";

public string ConfigWindow_Rotation_DownloadRotations { get; set; } = "Download Rotations.";
public string ConfigWindow_Rotation_AutoUpdateRotations { get; set; } = "Auto Update Rotations.";
public string ConfigWindow_Rotation_DownloadRotations { get; set; } = "Auto Download Rotations";
public string ConfigWindow_Rotation_AutoUpdateRotations { get; set; } = "Auto Update Rotations";

public string ConfigWindow_Rotation_InvalidRotation { get; set; } = "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!";
public string ConfigWindow_Rotation_ResetToDefault { get; set; } = "Click to reset the rotation configuration to default!";
Expand Down Expand Up @@ -642,4 +642,11 @@ internal partial class Strings

public string ConfigWindow_Actions_InsertCommand { get; set; } = "Insert \"{0}\" first in {1}s";

public string ConfigWindow_Configs_JobConfigTip { get; set; } = "This config is binding with the job, different job gets different value.";

public string ConfigWindow_Rotations_Settings { get; set; } = "Settings";
public string ConfigWindow_Rotations_Loaded { get; set; } = "Loaded";
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";
}
Loading

0 comments on commit 23335ad

Please sign in to comment.