Skip to content

Commit 633c342

Browse files
authored
Merge pull request #1140 from erdelf/master
Plugin installer in the info tab + LootConfig updated
2 parents bec55a3 + cf27bc3 commit 633c342

File tree

6 files changed

+126
-21
lines changed

6 files changed

+126
-21
lines changed

AutoDuty/Data/Enums.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ public enum PrivateHousingMarker : uint
356356

357357
public enum ExternalPlugin
358358
{
359+
None,
359360
vnav,
360361
BossMod,
361362
Avarice,
@@ -365,7 +366,8 @@ public enum ExternalPlugin
365366
Gearsetter,
366367
Stylist,
367368
Lifestream,
368-
AntiAFK
369+
AntiAFK,
370+
Pandora
369371
}
370372

371373
public static bool HasAnyFlag<T>(this T instance, params T[] parameter) where T : Enum

AutoDuty/Data/Extensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public static (string url, string name) GetExternalPluginData(this ExternalPlugi
156156
ExternalPlugin.Stylist => (@"https://raw.githubusercontent.com/NightmareXIV/MyDalamudPlugins/main/pluginmaster.json", "Stylist"),
157157
ExternalPlugin.Lifestream => (@"https://raw.githubusercontent.com/NightmareXIV/MyDalamudPlugins/main/pluginmaster.json", "Lifestream"),
158158
ExternalPlugin.AntiAFK => (@"https://raw.githubusercontent.com/NightmareXIV/MyDalamudPlugins/main/pluginmaster.json", "AntiAfkKick-Dalamud"),
159+
ExternalPlugin.Pandora => (@"https://love.puni.sh/ment.json", "PandorasBox"),
159160
_ => throw new ArgumentOutOfRangeException(nameof(plugin), plugin, null)
160161
};
161162

@@ -172,6 +173,7 @@ public static string GetExternalPluginName(this ExternalPlugin plugin) =>
172173
ExternalPlugin.Stylist => "Stylist",
173174
ExternalPlugin.Lifestream => "Lifestream",
174175
ExternalPlugin.AntiAFK => "Anti-AfkKick",
176+
ExternalPlugin.Pandora => "Pandora's Box",
175177
_ => throw new ArgumentOutOfRangeException(nameof(plugin), plugin, null)
176178
};
177179
}

AutoDuty/Helpers/ImGuiHelper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ internal static void DrawIcon(FontAwesomeIcon icon)
132132

133133
internal static ImRaii.IEndObject RequiresPlugin(ExternalPlugin plugin, string id, string? message = null, bool inline = false, bool write = true)
134134
{
135+
if (plugin == ExternalPlugin.None)
136+
return new EndUnconditionally();
137+
135138
if (IPCSubscriber_Common.IsReady(plugin.GetExternalPluginData().name))
136139
{
137140
return new EndUnconditionally(() =>
@@ -187,7 +190,7 @@ public void Dispose()
187190
if (this.Disposed)
188191
return;
189192

190-
this.EndAction();
193+
this.EndAction?.Invoke();
191194
this.Disposed = true;
192195
}
193196
}

AutoDuty/Windows/Config.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,12 +1958,12 @@ public static void Draw()
19581958
ImGui.Indent();
19591959
ImGui.Text("Select Method: ");
19601960
ImGui.SameLine(0, 5);
1961-
ImGui.PushItemWidth(150 * ImGuiHelpers.GlobalScale);
1961+
ImGui.PushItemWidth(200 * ImGuiHelpers.GlobalScale);
19621962
if (ImGui.BeginCombo("##ConfigLootMethod", Configuration.LootMethodEnum.ToCustomString()))
19631963
{
19641964
foreach (LootMethod lootMethod in Enum.GetValues(typeof(LootMethod)))
19651965
{
1966-
using (ImRaii.Disabled((lootMethod == LootMethod.Pandora && !PandorasBox_IPCSubscriber.IsEnabled)))
1966+
using (lootMethod == LootMethod.Pandora ? ImGuiHelper.RequiresPlugin(ExternalPlugin.Pandora, $"{lootMethod}_Looting", inline: true) : _)
19671967
{
19681968
if (ImGui.Selectable(lootMethod.ToCustomString(), Configuration.LootMethodEnum == lootMethod))
19691969
{

AutoDuty/Windows/InfoTab.cs

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
using ECommons.ImGuiMethods;
1+
using AutoDuty.Helpers;
22
using Dalamud.Bindings.ImGui;
3+
using ECommons.ImGuiMethods;
34
using System.Diagnostics;
45

56
namespace AutoDuty.Windows
67
{
8+
using Dalamud.Interface.Utility.Raii;
9+
using global::AutoDuty.IPC;
10+
using static Dalamud.Interface.Utility.Raii.ImRaii;
11+
712
internal static class InfoTab
813
{
914
static string infoUrl = "https://docs.google.com/spreadsheets/d/151RlpqRcCpiD_VbQn6Duf-u-S71EP7d0mx3j1PDNoNA";
1015
static string gitIssueUrl = "https://github.com/ffxivcode/AutoDuty/issues";
1116
static string punishDiscordUrl = "https://discord.com/channels/1001823907193552978/1236757595738476725";
12-
static string ffxivcodeDiscordUrl = "https://discord.com/channels/1241050921732014090/1273374407653462017";
17+
1318
private static Configuration Configuration = Plugin.Configuration;
1419

1520
public static void Draw()
@@ -34,9 +39,77 @@ public static void Draw()
3439
ImGui.SetCursorPosX((ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Punish Discord").X) / 2);
3540
if (ImGui.Button("Punish Discord"))
3641
Process.Start("explorer.exe", punishDiscordUrl);
37-
ImGui.SetCursorPosX((ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("FFXIVCode Discord").X) / 2);
38-
if (ImGui.Button("FFXIVCode Discord"))
39-
Process.Start("explorer.exe", ffxivcodeDiscordUrl);
42+
43+
ImGui.NewLine();
44+
45+
int id = 0;
46+
47+
void PluginInstallLine(ExternalPlugin plugin, string message)
48+
{
49+
bool isReady = plugin == ExternalPlugin.BossMod ?
50+
BossMod_IPCSubscriber.IsEnabled :
51+
IPCSubscriber_Common.IsReady(plugin.GetExternalPluginData().name);
52+
53+
if(!isReady)
54+
if (ImGui.Button($"Install##InstallExternalPlugin_{plugin}_{id++}"))
55+
PluginInstaller.InstallPlugin(plugin);
56+
57+
ImGui.NextColumn();
58+
ImGui.AlignTextToFramePadding();
59+
ImGui.TextColored(isReady ? EzColor.Green : EzColor.Red, plugin.GetExternalPluginName());
60+
61+
ImGui.NextColumn();
62+
ImGui.AlignTextToFramePadding();
63+
ImGui.Text(message);
64+
ImGui.NextColumn();
65+
}
66+
67+
ImGui.SetCursorPosX((ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Required Plugins").X) / 2);
68+
ImGui.Text("Required Plugins");
69+
70+
ImGui.Columns(3, "PluginInstallerRequired", false);
71+
ImGui.SetColumnWidth(0, 60);
72+
ImGui.SetColumnWidth(1, 100);
73+
74+
PluginInstallLine(ExternalPlugin.BossMod, "handles boss fights for you");
75+
PluginInstallLine(ExternalPlugin.vnav, "can move you around");
76+
77+
ImGui.Columns(1);
78+
ImGui.NewLine();
79+
ImGui.SetCursorPosX((ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Combat Plugins").X) / 2);
80+
ImGui.Text("Combat Plugins");
81+
82+
ImGui.Indent(65f);
83+
ImGui.TextColored(EzColor.Cyan, "Hotly debated, pick your favorite. You can configure it in the config");
84+
ImGui.Unindent(65f);
85+
86+
ImGui.Columns(3, "PluginInstallerCombat", false);
87+
ImGui.SetColumnWidth(0, 60);
88+
ImGui.SetColumnWidth(1, 100);
89+
90+
PluginInstallLine(ExternalPlugin.BossMod, "has integrated rotations");
91+
PluginInstallLine(ExternalPlugin.WrathCombo, "Puni.sh's dedicated rotation plugin");
92+
PluginInstallLine(ExternalPlugin.RotationSolverReborn, "Reborn's rotation plugin");
93+
94+
ImGui.Columns(1);
95+
ImGui.NewLine();
96+
ImGui.SetCursorPosX((ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Recommended Plugins").X) / 2);
97+
ImGui.Text("Recommended Plugins");
98+
ImGui.NewLine();
99+
ImGui.Columns(3, "PluginInstallerRecommended", false);
100+
ImGui.SetColumnWidth(0, 60);
101+
ImGui.SetColumnWidth(1, 100);
102+
103+
PluginInstallLine(ExternalPlugin.AntiAFK, "keeps you from being marked as afk");
104+
PluginInstallLine(ExternalPlugin.AutoRetainer, "can be triggered, does GC delivery and discarding");
105+
PluginInstallLine(ExternalPlugin.Avarice, "is read for positionals");
106+
PluginInstallLine(ExternalPlugin.Lifestream, "incredibly extensive teleporting");
107+
PluginInstallLine(ExternalPlugin.Pandora, "chest looting + tankstance");
108+
PluginInstallLine(ExternalPlugin.Gearsetter, "recommend items to equip");
109+
PluginInstallLine(ExternalPlugin.Stylist, "recommend items to equip");
110+
111+
112+
ImGui.Columns(1);
40113
}
41114
}
42115
}

AutoDuty/Windows/MainWindow.cs

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,42 +422,67 @@ static uint ColorNormal
422422
return data[0];
423423
}
424424
}
425+
425426
public static void EzTabBar(string id, string? KoFiTransparent, string openTabName, ImGuiTabBarFlags flags, params (string name, Action function, Vector4? color, bool child)[] tabs)
426427
{
427428
ImGui.BeginTabBar(id, flags);
428-
foreach (var x in tabs)
429+
430+
431+
bool valid = (BossMod_IPCSubscriber.IsEnabled || Plugin.Configuration.UsingAlternativeBossPlugin) &&
432+
(VNavmesh_IPCSubscriber.IsEnabled || Plugin.Configuration.UsingAlternativeMovementPlugin) &&
433+
(BossMod_IPCSubscriber.IsEnabled || Plugin.Configuration.UsingAlternativeRotationPlugin);
434+
435+
if (!valid)
436+
openTabName = "Info";
437+
438+
foreach ((string name, Action function, Vector4? color, bool child) x in tabs)
429439
{
430-
if (x.name == null) continue;
431-
if (x.color != null)
432-
{
440+
if (x.name.IsNullOrEmpty())
441+
continue;
442+
if (x.color != null)
433443
ImGui.PushStyleColor(ImGuiCol.Tab, x.color.Value);
434-
}
435-
if (ImGui.BeginTabItem(x.name, openTabName == x.name ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None))
444+
445+
if ((valid || x.name == "Info") && ImGui.BeginTabItem(x.name, openTabName == x.name ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None))
436446
{
437447
if (x.color != null)
438448
ImGui.PopStyleColor();
439449
if (x.child)
440450
ImGui.BeginChild(x.name + "child");
451+
452+
if(!valid)
453+
{
454+
ImGui.NewLine();
455+
ImGui.TextColored(EzColor.Red, "You need to do the basic setup below. Enjoy");
456+
}
457+
441458
x.function();
459+
442460
if (x.child)
443461
ImGui.EndChild();
444462
ImGui.EndTabItem();
445463
}
446464
else
447465
{
448-
if (x.color != null)
449-
{
466+
if (x.color != null)
450467
ImGui.PopStyleColor();
451-
}
452468
}
453469
}
454-
if (KoFiTransparent != null) PatreonBanner.RightTransparentTab();
470+
if (KoFiTransparent != null)
471+
PatreonBanner.RightTransparentTab();
472+
455473
ImGui.EndTabBar();
456474
}
457475

458476
private static readonly List<(string, Action, Vector4?, bool)> tabList =
459-
[("Main", MainTab.Draw, null, false), ("Build", BuildTab.Draw, null, false), ("Paths", PathsTab.Draw, null, false), ("Config", ConfigTab.Draw, null, false), ("Info", InfoTab.Draw, null, false), ("Logs", LogTab.Draw, null, false),("Support AutoDuty", KofiLink, ImGui.ColorConvertU32ToFloat4(ColorNormal), false)
460-
];
477+
[
478+
("Main", MainTab.Draw, null, false),
479+
("Build", BuildTab.Draw, null, false),
480+
("Paths", PathsTab.Draw, null, false),
481+
("Config", ConfigTab.Draw, null, false),
482+
("Info", InfoTab.Draw, null, false),
483+
("Logs", LogTab.Draw, null, false),
484+
("Support AutoDuty", KofiLink, ImGui.ColorConvertU32ToFloat4(ColorNormal), false)
485+
];
461486

462487
public override void Draw()
463488
{

0 commit comments

Comments
 (0)