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

Commit

Permalink
fix: changed the Rotation download window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 16, 2023
1 parent 12c6562 commit 96935a6
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 21 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public class PluginConfiguration : IPluginConfiguration
public MacroInfo DutyStart { get; set; } = new MacroInfo();
public MacroInfo DutyEnd { get; set; } = new MacroInfo();

public bool DownloadRotations = true;
public bool AutoUpdateRotations = true;

public bool ToggleManual = false;
Expand Down
18 changes: 13 additions & 5 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Commands_Rotation": "Open config window.",
"Commands_ChangeAutoBurst": "Modify automatic burst to {0}",
"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_InsertAction": "Will use it within {0}s",
Expand Down Expand Up @@ -30,12 +30,12 @@
"ConfigWindow_HelpItem_MoveBack": "Open a window to move back.",
"ConfigWindow_HelpItem_EndSpecial": "Close special window.",
"ConfigWindow_Helper_SwitchRotation": "Click to switch authors",
"ConfigWindow_Helper_HighEndWarning": "This `{0}` rotation is not allowed to be used in High-end Duty!",
"ConfigWindow_Helper_HighEndWarning": "This <{0}> rotation is not allowed to be used in High-end Duty!",
"ConfigWindow_Helper_GameVersion": "Game Version",
"ConfigWindow_Helper_OpenSource": "Open the source code URL",
"ConfigWindow_Helper_RunCommand": "Click to execute the command",
"ConfigWindow_Helper_CopyCommand": "Right-click to copy command",
"ConfigWindow_Helper_InsertCommand": "Insert \"{0}\" first in 5s",
"ConfigWindow_Helper_InsertCommand": "Insert \"{0}\" first in {1}s",
"ConfigWindow_Rotation_Description": "You can enable the function for each job you want and configure the setting about how to use actions.",
"ConfigWindow_RotationDev_Description": "You can get some extra rotation development information here.",
"ConfigWindow_Rotation_KeyName": "The key name is",
Expand All @@ -62,6 +62,7 @@
"ConfigWindow_Param_AutoOffCutScene": "Turn off during cut scene.",
"ConfigWindow_Param_AutoOffWhenDead": "Turn off when dead.",
"ConfigWindow_Param_UseWorkTask": "Use work task for acceleration.",
"ConfigWindow_Param_ToggleManual": "Make Manual Command as toggle.",
"ConfigWindow_Param_Delay": "Delay",
"ConfigWindow_Param_WeaponDelay": "Set the range of random delay for GCD in second.",
"ConfigWindow_Param_DeathDelay": "Set the range of random delay for raising deaths in second.",
Expand Down Expand Up @@ -93,7 +94,6 @@
"ConfigWindow_Param_KeyBoardNoiseTimes": "Effect times",
"ConfigWindow_Param_KeyBoardNoiseTime": "Effect interval",
"ConfigWindow_Param_VoiceVolume": "Voice volume",
"ConfigWindow_Param_VoiceName": "Voice Name",
"ConfigWindow_Param_FlytextPositional": "Hint positional anticipation by flytext",
"ConfigWindow_Param_SayPositional": "Hint positional anticipation by shouting",
"ConfigWindow_Param_PositionalFeedback": "Positional error feedback",
Expand Down Expand Up @@ -135,13 +135,15 @@
"ConfigWindow_Param_EsunaAll": "Esuna All Statuses.",
"ConfigWindow_Param_InterruptibleMoreCheck": "Interrupt the action with action type check.",
"ConfigWindow_Param_HealOutOfCombat": "Heal party members outside of combat.",
"ConfigWindow_Param_OnlyHotOnTanks": "Only use hot actions on tank rols.",
"ConfigWindow_Param_BeneficialAreaOnTarget": "Use Beneficial Area abilities on target.",
"ConfigWindow_Param_HealthDifference": "Set the HP standard deviation threshold for using AOE heal (ability & spell)",
"ConfigWindow_Param_HealthAreaAbility": "Set the HP threshold for using AOE healing ability",
"ConfigWindow_Param_HealthAreaSpell": "Set the HP threshold for using AOE healing spell",
"ConfigWindow_Param_HealingOfTimeSubtractArea": "Set the HP threshold reduce with hot effect(AOE)",
"ConfigWindow_Param_HealthSingleAbility": "Set the HP threshold for using single healing ability",
"ConfigWindow_Param_HealthSingleSpell": "Set the HP threshold for using single healing spell",
"ConfigWindow_Param_HealthTankRatio": "Heal tank first it tank's HP threshold is lower than this.",
"ConfigWindow_Param_HealthTankHealerRatio": "Heal healer or tank first if its HP threshold is lower than this.",
"ConfigWindow_Param_HealingOfTimeSubtractSingle": "Set the HP threshold reduce with hot effect(single)",
"ConfigWindow_Param_HealthForDyingTank": "Set the HP threshold for tank to use invincibility",
"ConfigWindow_Param_MeleeRangeOffset": "Melee Range action using offset",
Expand Down Expand Up @@ -176,6 +178,7 @@
"ConfigWindow_Param_ConditionDown": "Down",
"ConfigWindow_Param_ConditionDelete": "Delete",
"ConfigWindow_Param_ResetToDefault": "Press left ctrl + shift and press right mouse button to reset this value",
"ConfigWindow_Action_ShowOnCDWindow": "Show on CD window",
"ConfigWindow_Control_OnlyShowWithHostileOrInDuty": "Only shown if there are enemies in or in duty",
"ConfigWindow_Control_ShowNextActionWindow": "Show Next Action Window",
"ConfigWindow_Control_ShowControlWindow": "Show Control Window",
Expand All @@ -193,11 +196,16 @@
"ConfigWindow_Control_InfoWindowBg": "Info Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
"ConfigWindow_Control_ControlWindow0GCDSize": "0GCD icon size",
"ConfigWindow_Control_CooldownWindowIconSize": "Cooldown icon size",
"ConfigWindow_Control_ControlWindowNextSizeRatio": "Next Action Size Ratio",
"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_NeedToEnable": " (Need to enable)",
"ConfigWindow_Control_ClickToUse": "Click to use it!",
"ConfigWindow_Rotation_BetaRotation": "Beta Rotation!",
"ConfigWindow_Rotation_DownloadRotationsButton": "Download Rotations",
"ConfigWindow_Rotation_DownloadRotations": "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!",
"Timeline_DragdropDescription": "Drag&drop to move,Ctrl+Alt+RightClick to delete.",
"Timeline_SearchBar": "Search Bar",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/LocalizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void SetLanguage(string lang)
#if DEBUG
public void ExportLocalization()
{
var directory = @"D:\OneDrive - stu.zafu.edu.cn\PartTime\FFXIV\RotationSolver\RotationSolver\Localization";
var directory = @"E:\OneDrive - stu.zafu.edu.cn\PartTime\FFXIV\RotationSolver\RotationSolver\Localization";
if (!Directory.Exists(directory)) return;

//Default values.
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ internal partial class Strings
public string ConfigWindow_Param_UseStopCasting { get; set; } = "Use stopping casting when target is dead.";
public string ConfigWindow_Param_ShowActionFlag { get; set; } = "Show action flag.";
public string ConfigWindow_Param_InDebug { get; set; } = "Debug Mode";
public string ConfigWindow_Param_AutoUpdateRotations { get; set; } = "Auto Update Rotaions.";

public string ConfigWindow_Param_ShowHealthRatio { get; set; } = "Show the health ratio for the check of Boss, Dying, Dot.";

Expand Down Expand Up @@ -275,6 +274,11 @@ internal partial class Strings
public string ConfigWindow_Control_NeedToEnable { get; set; } = " (Need to enable)";
public string ConfigWindow_Control_ClickToUse { get; set; } = "Click to use it!";
public string ConfigWindow_Rotation_BetaRotation { get; set; } = "Beta Rotation!";
public string ConfigWindow_Rotation_DownloadRotationsButton { get; set; } = "Download Rotations";

public string ConfigWindow_Rotation_DownloadRotations { get; set; } = "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!";
#endregion
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)
#endif
ChangeUITranslation();

RotationUpdater.GetAllCustomRotations();
RotationUpdater.GetAllCustomRotations(true);
RotationHelper.LoadList();

LinkPayload = pluginInterface.AddChatLinkHandler(0, (id, str) =>
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq;
using RotationSolver.Commands;
using RotationSolver.Commands;
using RotationSolver.Localization;

namespace RotationSolver.UI;
Expand Down
20 changes: 20 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ private static void DrawDragFloat(ClassJobID job, string desc, Func<float> getVa

private static void DrawInfos()
{
if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotationsButton))
{
RotationUpdater.GetAllCustomRotations(true);
}

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

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotations,
ref Service.Config.DownloadRotations, Service.Default.DownloadRotations);

if (Service.Config.DownloadRotations)
{
ImGui.SameLine();
ImGuiHelper.Spacing();

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Rotation_AutoUpdateRotations,
ref Service.Config.AutoUpdateRotations, Service.Default.AutoUpdateRotations);
}

var assemblyGrps = RotationUpdater.CustomRotationsDict
.SelectMany(d => d.Value)
.SelectMany(g => g.rotations)
Expand Down
16 changes: 9 additions & 7 deletions RotationSolver/UI/RotationConfigWindow_RotationDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ private void DrawRotationDevTab()
{
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_RotationDev_Description);

if (ImGui.Button("Load Rotations"))
if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotationsButton))
{
RotationUpdater.GetAllCustomRotations();
RotationUpdater.GetAllCustomRotations(true);
}

ImGui.SameLine();

if (ImGui.Button("Load Rotations Local"))
{
RotationUpdater.GetAllCustomRotations(false);
}

ImGui.SameLine();
Expand All @@ -25,11 +32,6 @@ private void DrawRotationDevTab()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InDebug,
ref Service.Config.InDebug, Service.Default.InDebug);

ImGui.SameLine();

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoUpdateRotations,
ref Service.Config.AutoUpdateRotations, Service.Default.AutoUpdateRotations);

if (ImGui.BeginChild("Third-party Libs", new Vector2(0f, -1f), true))
{
if (ImGui.Button("AddOne"))
Expand Down
15 changes: 11 additions & 4 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ public record CustomRotationGroup(ClassJobID jobId, ClassJobID[] classJobIds, IC
internal static SortedList<string, string> AuthorHashes { get; private set; } = new SortedList<string, string>();
static CustomRotationGroup[] _customRotations { get; set; } = new CustomRotationGroup[0];

public static async void GetAllCustomRotations()
public static async void GetAllCustomRotations(bool download)
{
var relayFolder = Service.Interface.ConfigDirectory.FullName;
if (!Directory.Exists(relayFolder)) Directory.CreateDirectory(relayFolder);

LoadRotationsFromLocal(relayFolder);

if(download && Service.Config.DownloadRotations)await DownloadRotationsAsync(relayFolder);
}

static bool _isDownloading = false;
private static async Task DownloadRotationsAsync(string relayFolder)
{
if (_isDownloading) return;
_isDownloading= true;
bool hasDownload = false;
using (var client = new HttpClient())
{
Expand All @@ -40,11 +48,10 @@ public static async void GetAllCustomRotations()
hasDownload |= await DownloadOneUrlAsync(url, relayFolder, client);
var pdbUrl = Path.ChangeExtension(url, ".pdb");
await DownloadOneUrlAsync(pdbUrl, relayFolder, client);

}
}

if (hasDownload) LoadRotationsFromLocal(relayFolder);
_isDownloading = false;
}

private static async Task<bool> DownloadOneUrlAsync(string url, string relayFolder, HttpClient client)
Expand Down Expand Up @@ -117,7 +124,7 @@ private static void LoadRotationsFromLocal(string relayFolder)
.Where(Directory.Exists)
//.Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location))
#if DEBUG
//.Append(relayFolder)
.Append(relayFolder)
#else
.Append(relayFolder)
#endif
Expand Down

0 comments on commit 96935a6

Please sign in to comment.