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 info panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 11, 2023
1 parent b1371d0 commit 86c7369
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 55 deletions.
12 changes: 9 additions & 3 deletions RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics;
using System.Runtime.Loader;
using System.Text;
using System.Xml.Linq;

namespace RotationSolver;

Expand Down Expand Up @@ -113,11 +114,16 @@ public static bool IsAllowed(this ICustomRotation rotation, out string name)
return false;
}
var assembly = rotation.GetType().Assembly;
name = assembly.GetName().Name;

if(_assemblyInfos.TryGetValue(assembly, out var info))
return assembly.IsAllowed();
}

public static bool IsAllowed(this Assembly assembly)
{
if (_assemblyInfos.TryGetValue(assembly, out var info))
{
name = info.Name;
return _allowedAssembly.Contains(name + " - " + info.Author);
return _allowedAssembly.Contains(info.Name + " - " + info.Author);
}
return false;
}
Expand Down
51 changes: 50 additions & 1 deletion RotationSolver/UI/RotationConfigWindow_Rotation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Interface.Colors;
using RotationSolver.Localization;
using RotationSolver.Updaters;
using System.Diagnostics;

namespace RotationSolver.UI;
internal partial class RotationConfigWindow
Expand Down Expand Up @@ -37,6 +38,16 @@ private static void DrawRoleItems()
ImGui.EndTabItem();
}
}

if (ImGui.BeginTabItem("Info"))
{
if (ImGui.BeginChild("Third-party Libs", new Vector2(0f, -1f), true))
{
DrawInfos();
ImGui.EndChild();
}
ImGui.EndTabItem();
}
}

private static void DrawRotations(RotationUpdater.CustomRotationGroup[] rotations)
Expand All @@ -55,7 +66,7 @@ private static void DrawRotations(RotationUpdater.CustomRotationGroup[] rotation
}
}

internal static void DrawRotationRole(ICustomRotation rotation)
private static void DrawRotationRole(ICustomRotation rotation)
{
DrawTargetHostileTYpe(rotation);
DrawSpecialRoleSettings(rotation.Job.GetJobRole(), rotation.JobIDs[0]);
Expand Down Expand Up @@ -145,4 +156,42 @@ private static void DrawDragFloat(ClassJobID job, string desc, Func<float> getVa
Service.Config.Save();
}
}

private static void DrawInfos()
{
var assemblyGrps = RotationUpdater.CustomRotationsDict
.SelectMany(d => d.Value)
.SelectMany(g => g.rotations)
.GroupBy(r => r.GetType().Assembly);

if (ImGui.BeginTable("AssemblyTable", 3))
{
foreach (var grp in assemblyGrps)
{
ImGui.TableNextRow();


var assembly = grp.Key;
var isAllowed = assembly.IsAllowed();
if (isAllowed) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DPSRed);

var info = assembly.GetInfo();

if (ImGui.Button(info.Name + assembly.GetName().Version))
{
Process.Start("explorer.exe", info.Path);
}

ImGui.TableNextColumn();
ImGui.Text(info.Author);

ImGui.TableNextColumn();

ImGui.Text(string.Join('\n', grp));

if (isAllowed) ImGui.PopStyleColor();
}
ImGui.EndTable();
}
}
}
51 changes: 0 additions & 51 deletions RotationSolver/UI/RotationConfigWindow_RotationDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ private void DrawRotationDevTab()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InDebug,
ref Service.Config.InDebug, Service.Default.InDebug);

ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f));

if (ImGui.BeginTabBar("Rotation Devs"))
{
if (ImGui.BeginTabItem("Libs"))
{
DrawThridLibs();
ImGui.EndTabItem();
}

if (ImGui.BeginTabItem("Infos"))
{
DrawAssemblyInfos();
ImGui.EndTabItem();
}

ImGui.EndTabBar();
}
ImGui.PopStyleVar();
}

private void DrawThridLibs()
{

if (ImGui.BeginChild("Third-party Libs", new Vector2(0f, -1f), true))
{
if (ImGui.Button("AddOne"))
Expand Down Expand Up @@ -84,31 +60,4 @@ private void DrawThridLibs()
ImGui.EndChild();
}
}
private void DrawAssemblyInfos()
{
var assemblies = RotationUpdater.CustomRotationsDict
.SelectMany(d => d.Value)
.SelectMany(g => g.rotations)
.Select(r => r.GetType().Assembly)
.ToHashSet();

//if(ImGui.BeginTable("AssemblyTable", 2))
//{
// foreach (var assembly in assemblies)
// {
// ImGui.TableNextRow();
// if (ImGui.Button(assembly.GetName().Name + assembly.GetName().Version))
// {
// if (!RotationHelper.AssemblyInfos.TryGetValue(assembly.GetName().Name, out var path))
// path = assembly.Location;

// Process.Start("explorer.exe", path);
// }

// ImGui.TableNextColumn();
// ImGui.Text(assembly.GetAuthor());
// }
// ImGui.EndTable();
//}
}
}

0 comments on commit 86c7369

Please sign in to comment.