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 show list feature for download rotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 24, 2023
1 parent 0d71ade commit 0cfb63a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)
#endif
ChangeUITranslation();

RotationUpdater.GetAllCustomRotations(true, false);
RotationUpdater.GetAllCustomRotations(RotationUpdater.DownloadOption.Donwload);
RotationHelper.LoadList();

LinkPayload = pluginInterface.AddChatLinkHandler(0, (id, str) =>
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow_Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private static void DrawInfos()
{
if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotationsButton))
{
RotationUpdater.GetAllCustomRotations(true, true);
RotationUpdater.GetAllCustomRotations( RotationUpdater.DownloadOption.MustDownload | RotationUpdater.DownloadOption.ShowList);
}

ImGui.SameLine();
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_RotationDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ private void DrawRotationDevTab()

if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Rotation_DownloadRotationsButton))
{
RotationUpdater.GetAllCustomRotations(true, true);
RotationUpdater.GetAllCustomRotations(RotationUpdater.DownloadOption.MustDownload | RotationUpdater.DownloadOption.ShowList);
}

ImGui.SameLine();

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

ImGui.SameLine();
Expand Down
26 changes: 23 additions & 3 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Dalamud.Logging;
using RotationSolver.Localization;
using System;
using System.Text;

namespace RotationSolver.Updaters;
Expand All @@ -14,14 +13,35 @@ 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(bool download, bool mustDownload)
[Flags]
public enum DownloadOption : byte
{
Local = 0,
Donwload = 1 << 0,
MustDownload = Donwload | 1 << 1,
ShowList = 1 << 2,
}

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

LoadRotationsFromLocal(relayFolder);

if(download && Service.Config.DownloadRotations)await DownloadRotationsAsync(relayFolder, mustDownload);
if (option.HasFlag(DownloadOption.Donwload) && Service.Config.DownloadRotations)
await DownloadRotationsAsync(relayFolder, option.HasFlag(DownloadOption.MustDownload));

if (option.HasFlag(DownloadOption.ShowList))
{
foreach (var item in CustomRotationsDict
.SelectMany(d => d.Value)
.SelectMany(g => g.rotations)
.Select(r => r.GetType().Assembly.FullName).ToHashSet())
{
Service.ChatGui.Print("Loaded: " + item);
}
}
}

static bool _isDownloading = false;
Expand Down

0 comments on commit 0cfb63a

Please sign in to comment.