Skip to content

Commit

Permalink
Add plugin lock feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Nov 5, 2023
1 parent ce7f1a2 commit d073e37
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 21 deletions.
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonContentsFinderConfirmFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.ContentsFinderConfirmEnabled)
if (!P.Active || !P.Config.ContentsFinderConfirmEnabled)
return;

ClickContentsFinderConfirm.Using((nint)addon).Commence();
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonFGSEnterDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.FallGuysRegisterConfirm)
if (!P.Active || !P.Config.FallGuysRegisterConfirm)
return;

Callback.Fire(addon, true, 0);
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonFGSExitDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.FallGuysExitConfirm)
if (!P.Active || !P.Config.FallGuysExitConfirm)
return;

Callback.Fire(addon, true, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.GrandCompanySupplyReward)
if (!P.Active || !P.Config.GrandCompanySupplyReward)
return;

ClickGrandCompanySupplyReward.Using((IntPtr)addon).Deliver();
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonGuildLeveDifficultyFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.GuildLeveDifficultyConfirm)
if (!P.Active || !P.Config.GuildLeveDifficultyConfirm)
return;

Callback.Fire(addon, true, 0, addon->AtkValues[1].Int);
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonInclusionShopFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.InclusionShopRememberEnabled)
if (!P.Active || !P.Config.InclusionShopRememberEnabled)
return;

Svc.Log.Debug($"Firing 12,{P.Config.InclusionShopRememberCategory}");
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonItemInspectionResultFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.ItemInspectionResultEnabled)
if (!P.Active || !P.Config.ItemInspectionResultEnabled)
return;

var addonPtr = (AddonItemInspectionResult*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonJournalResultFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.JournalResultCompleteEnabled)
if (!P.Active || !P.Config.JournalResultCompleteEnabled)
return;

var addonPtr = (AddonJournalResult*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonMateriaRetrieveDialogFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.MateriaRetrieveDialogEnabled)
if (!P.Active || !P.Config.MateriaRetrieveDialogEnabled)
return;

ClickMateriaRetrieveDialog.Using((nint)addon).Begin();
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonMaterializeDialogFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.MaterializeDialogEnabled)
if (!P.Active || !P.Config.MaterializeDialogEnabled)
return;

ClickMaterializeDialog.Using((nint)addon).Materialize();
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonRetainerTaskAskFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInf
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.RetainerTaskAskEnabled)
if (!P.Active || !P.Config.RetainerTaskAskEnabled)
return;

ClickRetainerTaskAsk.Using((nint)addon).Assign();
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonRetainerTaskResultFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.RetainerTaskResultEnabled)
if (!P.Active || !P.Config.RetainerTaskResultEnabled)
return;

var addonPtr = (AddonRetainerTaskResult*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonSalvageDialogFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled)
if (!P.Active)
return;

if (P.Config.DesynthBulkDialogEnabled)
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonSelectIconStringFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled)
if (!P.Active)
return;

var addonPtr = (AddonSelectIconString*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonSelectStringFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled)
if (!P.Active)
return;

var addonPtr = (AddonSelectString*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonSelectYesNoFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled)
if (!P.Active)
return;

var dataPtr = (AddonSelectYesNoOnSetupData*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonShopCardDialogFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.ShopCardDialog)
if (!P.Active || !P.Config.ShopCardDialog)
return;

var addonPtr = (AddonShopCardDialog*)addon;
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonShopExchangeItemDialogFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled || !P.Config.ShopExchangeItemDialogEnabled)
if (!P.Active || !P.Config.ShopExchangeItemDialogEnabled)
return;

Callback.Fire(addon, true, 0);
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonTalkFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
{
var addon = (AtkUnitBase*)addonInfo.Addon;

if (!P.Config.Enabled)
if (!P.Active)
return;

var addonPtr = (AddonTalk*)addon;
Expand Down
22 changes: 22 additions & 0 deletions YesAlready/IPC/BlockListHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using ECommons.DalamudServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YesAlready.IPC
{
internal class BlockListHandler
{
internal const string BlockListNamespace = "YesAlready.StopRequests";
internal HashSet<string> BlockList;
internal bool Locked => BlockList.Count != 0;

internal BlockListHandler()
{
BlockList = Svc.PluginInterface.GetOrCreateData<HashSet<string>>(BlockListNamespace, () => []);
BlockList.Clear();
}
}
}
11 changes: 11 additions & 0 deletions YesAlready/UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using ClickLib.Exceptions;
using System.Linq;
using PunishLib.ImGuiMethods;
using Dalamud.Interface.Colors;
using ECommons;

namespace YesAlready.UI;

Expand Down Expand Up @@ -62,6 +64,15 @@ public override void Draw()
if (ImGui.Button("Disable Features")) EnableFeatures(false);
#endif

if (P.BlockListHandler.Locked)
{
ImGuiEx.Text(ImGuiColors.DalamudRed, $"Yes Already function is paused because following plugins have requested it: {P.BlockListHandler.BlockList.Print()}");
if(ImGui.Button("Force unlock"))
{
P.BlockListHandler.BlockList.Clear();
}
}

var enabled = P.Config.Enabled;
if (ImGui.Checkbox("Enabled", ref enabled))
{
Expand Down
7 changes: 6 additions & 1 deletion YesAlready/YesAlready.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.IoC;
using Dalamud.Plugin.Services;
using YesAlready.IPC;
namespace YesAlready;

public class YesAlready : IDalamudPlugin
Expand All @@ -37,6 +38,9 @@ public class YesAlready : IDalamudPlugin
internal static DalamudPluginInterface pi;

private readonly DtrBarEntry dtrEntry;
internal BlockListHandler BlockListHandler;

internal bool Active => Config.Enabled && !BlockListHandler.Locked;

public YesAlready(DalamudPluginInterface pluginInterface)
{
Expand All @@ -46,6 +50,7 @@ public YesAlready(DalamudPluginInterface pluginInterface)
Ws = new();
MainWindow = new();
Ws.AddWindow(MainWindow);
BlockListHandler = new();

Config = pi.GetPluginConfig() as Configuration ?? new Configuration();
Configuration.Initialize(Svc.PluginInterface);
Expand Down Expand Up @@ -183,7 +188,7 @@ private void FrameworkUpdate(object framework)

if (dtrEntry.Shown)
{
dtrEntry.Text = new SeString(new TextPayload($"{Name}: {(P.Config.Enabled ? "On" : "Off")}"));
dtrEntry.Text = new SeString(new TextPayload($"{Name}: {(P.Config.Enabled ? (P.BlockListHandler.Locked?"Paused":"On") : "Off")}"));
dtrEntry.OnClick = () => P.Config.Enabled ^= true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/YesAlready.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>daemitus, croizat</Authors>
<Version>1.4.0.0</Version>
<Version>1.4.0.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit d073e37

Please sign in to comment.