Skip to content

Commit

Permalink
fixes (#107)
Browse files Browse the repository at this point in the history
* added clicklib as submodule

* added dtrbar support

* redundant dtr setting removal & tooltip fix

* add ipc

* added punishlib

* disabled the about tab, kawaii pls fix
  • Loading branch information
Jaksuhn authored Nov 4, 2023
1 parent 8df7bfe commit 0b86595
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "ECommons"]
path = ECommons
url = https://github.com/NightmareXIV/ECommons
[submodule "PunishLib"]
path = PunishLib
url = https://github.com/PunishXIV/PunishLib.git
1 change: 1 addition & 0 deletions PunishLib
Submodule PunishLib added at e4274a
12 changes: 12 additions & 0 deletions YesAlready.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClickLib", "ClickLib\ClickL
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YesAlready", "YesAlready\YesAlready.csproj", "{DAA660F8-DB97-4FC2-8453-8B36E9F0D6A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{BAE99E1B-3AD1-493F-A005-1411B57809BD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PunishLib", "PunishLib\PunishLib\PunishLib.csproj", "{3A6D49AE-7CEA-402F-8C86-F00E9F1106C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -21,6 +25,14 @@ Global
{DAA660F8-DB97-4FC2-8453-8B36E9F0D6A7}.Debug|x64.Build.0 = Debug|x64
{DAA660F8-DB97-4FC2-8453-8B36E9F0D6A7}.Release|x64.ActiveCfg = Release|x64
{DAA660F8-DB97-4FC2-8453-8B36E9F0D6A7}.Release|x64.Build.0 = Release|x64
{BAE99E1B-3AD1-493F-A005-1411B57809BD}.Debug|x64.ActiveCfg = Debug|x64
{BAE99E1B-3AD1-493F-A005-1411B57809BD}.Debug|x64.Build.0 = Debug|x64
{BAE99E1B-3AD1-493F-A005-1411B57809BD}.Release|x64.ActiveCfg = Release|x64
{BAE99E1B-3AD1-493F-A005-1411B57809BD}.Release|x64.Build.0 = Release|x64
{3A6D49AE-7CEA-402F-8C86-F00E9F1106C9}.Debug|x64.ActiveCfg = Debug|x64
{3A6D49AE-7CEA-402F-8C86-F00E9F1106C9}.Debug|x64.Build.0 = Debug|x64
{3A6D49AE-7CEA-402F-8C86-F00E9F1106C9}.Release|x64.ActiveCfg = Release|x64
{3A6D49AE-7CEA-402F-8C86-F00E9F1106C9}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 0 additions & 2 deletions YesAlready/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public partial class Configuration() : IPluginConfiguration
public bool FallGuysRegisterConfirm { get; set; } = false;
public bool FallGuysExitConfirm { get; set; } = false;

public bool DTRSupport { get; set; } = true;

public static Configuration Load(DirectoryInfo configDirectory)
{
var pluginConfigPath = new FileInfo(Path.Combine(configDirectory.Parent!.FullName, "YesAlready.json"));
Expand Down
2 changes: 1 addition & 1 deletion YesAlready/Features/AddonItemInspectionResultFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
Svc.Log.Info(nameText.ToString());
}

this.itemInspectionCount++;
itemInspectionCount++;
var rateLimiter = P.Config.ItemInspectionResultRateLimiter;
if (rateLimiter != 0 && itemInspectionCount % rateLimiter == 0)
{
Expand Down
26 changes: 26 additions & 0 deletions YesAlready/IPC/YesAlreadyIPC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using ECommons.DalamudServices;

namespace YesAlready.IPC
{
internal static class YesAlreadyIPC
{
internal static void Init()
{
Svc.PluginInterface.GetIpcProvider<bool, object>("YesAlready.SetPluginEnabled").RegisterAction(SetPluginEnabled);
}

internal static void Dispose()
{
Svc.PluginInterface.GetIpcProvider<bool, object>("YesAlready.SetPluginEnabled").UnregisterAction();

}

private static void SetPluginEnabled(bool state)
{
if (state)
P.Config.Enabled = true;
else
P.Config.Enabled = false;
}
}
}
90 changes: 31 additions & 59 deletions YesAlready/UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ECommons.DalamudServices;
using ClickLib.Exceptions;
using System.Linq;
using PunishLib.ImGuiMethods;

namespace YesAlready.UI;

Expand Down Expand Up @@ -74,7 +75,12 @@ public override void Draw()
DisplayListOptions();
DisplayTalkOptions();
DisplayBotherOptions();
DisplaySettings();

//if (ImGui.BeginTabItem("About"))
//{
// AboutTab.Draw("YesAlready");
// ImGui.EndTabItem();
//}

ImGui.EndTabBar();
}
Expand Down Expand Up @@ -451,41 +457,6 @@ static void IndentedTextColored(Vector4 color, string text)
ImGui.EndTabItem();
}

private void DisplaySettings()
{
if (!ImGui.BeginTabItem("Settings"))
return;

static void IndentedTextColored(Vector4 color, string text)
{
var indent = 27f * ImGuiHelpers.GlobalScale;
ImGui.Indent(indent);
ImGui.PushStyleColor(ImGuiCol.Text, color);
ImGui.TextWrapped(text);
ImGui.PopStyleColor();
ImGui.Unindent(indent);
}

ImGui.PushID("Settings");

#region Enable DTR

var dtrSupport = P.Config.DTRSupport;
if (ImGui.Checkbox("DTR Support", ref dtrSupport))
{
P.Config.DTRSupport = dtrSupport;
P.Config.Save();
}

IndentedTextColored(this.shadedColor, "Shows the status of YesAlready in the DTR bar, with the ability to quick toggle the plugin.");

#endregion

ImGui.PopID();

ImGui.EndTabItem();
}

// ====================================================================================================

private static void DisplayTextButtons()
Expand All @@ -494,15 +465,15 @@ private static void DisplayTextButtons()
var newStyle = new Vector2(style.ItemSpacing.X / 2, style.ItemSpacing.Y);
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newStyle);

if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
{
var newNode = new TextEntryNode { Enabled = false, Text = "Your text goes here" };
RootFolder.Children.Add(newNode);
P.Config.Save();
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last seen as new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last seen as new entry"))
{
var io = ImGui.GetIO();
var zoneRestricted = io.KeyCtrl;
Expand All @@ -514,7 +485,7 @@ private static void DisplayTextButtons()
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
{
var newNode = new TextFolderNode { Name = "Untitled folder" };
RootFolder.Children.Add(newNode);
Expand Down Expand Up @@ -545,7 +516,8 @@ private static void DisplayTextButtons()
sb.AppendLine(" - SelectYesNo");

ImGui.SameLine();
ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());
Utils.ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());
if (ImGui.IsItemHovered()) ImGui.SetTooltip(sb.ToString());

ImGui.PopStyleVar(); // ItemSpacing
}
Expand Down Expand Up @@ -575,23 +547,23 @@ private static void DisplayListButtons()
var newStyle = new Vector2(style.ItemSpacing.X / 2, style.ItemSpacing.Y);
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newStyle);

if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
{
var newNode = new ListEntryNode { Enabled = false, Text = "Your text goes here" };
ListRootFolder.Children.Add(newNode);
P.Config.Save();
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last selected as new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last selected as new entry"))
{
var newNode = new ListEntryNode { Enabled = true, Text = P.LastSeenListSelection, TargetRestricted = true, TargetText = P.LastSeenListTarget };
ListRootFolder.Children.Add(newNode);
P.Config.Save();
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
{
var newNode = new TextFolderNode { Name = "Untitled folder" };
ListRootFolder.Children.Add(newNode);
Expand All @@ -616,7 +588,7 @@ private static void DisplayListButtons()
sb.AppendLine(" - SelectIconString");

ImGui.SameLine();
ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());
Utils.ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());

ImGui.PopStyleVar(); // ItemSpacing
}
Expand Down Expand Up @@ -646,15 +618,15 @@ private static void DisplayTalkButtons()
var newStyle = new Vector2(style.ItemSpacing.X / 2, style.ItemSpacing.Y);
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newStyle);

if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry"))
{
var newNode = new TalkEntryNode { Enabled = false, TargetText = "Your text goes here" };
TalkRootFolder.Children.Add(newNode);
P.Config.Save();
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add current target as a new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add current target as a new entry"))
{
var target = Svc.Targets.Target;
var targetName = P.LastSeenTalkTarget = target != null
Expand All @@ -667,7 +639,7 @@ private static void DisplayTalkButtons()
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
{
var newNode = new TextFolderNode { Name = "Untitled folder" };
TalkRootFolder.Children.Add(newNode);
Expand All @@ -691,7 +663,7 @@ private static void DisplayTalkButtons()
sb.AppendLine(" - Talk");

ImGui.SameLine();
ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());
Utils.ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString());

ImGui.PopStyleVar(); // ItemSpacing
}
Expand Down Expand Up @@ -971,7 +943,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var trashAltWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.TrashAlt);

ImGui.SameLine(ImGui.GetContentRegionMax().X - trashAltWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
{
if (P.Config.TryFindParent(node, out var parentNode))
{
Expand All @@ -998,13 +970,13 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var searchPlusWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.SearchPlus);

ImGui.SameLine(ImGui.GetContentRegionMax().X - searchWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.Search, "Zone List"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Search, "Zone List"))
{
P.OpenZoneListUi();
}

ImGui.SameLine(ImGui.GetContentRegionMax().X - searchWidth - searchPlusWidth - newItemSpacing.X);
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current zone"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current zone"))
{
var currentID = Svc.ClientState.TerritoryType;
if (P.TerritoryNames.TryGetValue(currentID, out var zoneName))
Expand Down Expand Up @@ -1043,7 +1015,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var trashAltWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.TrashAlt);

ImGui.SameLine(ImGui.GetContentRegionMax().X - trashAltWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
{
if (P.Config.TryFindParent(node, out var parentNode))
{
Expand All @@ -1069,7 +1041,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var searchPlusWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.SearchPlus);

ImGui.SameLine(ImGui.GetContentRegionMax().X - searchPlusWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current target"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current target"))
{
var target = Svc.Targets.Target;
var name = target?.Name?.TextValue ?? string.Empty;
Expand Down Expand Up @@ -1110,7 +1082,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var trashAltWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.TrashAlt);

ImGui.SameLine(ImGui.GetContentRegionMax().X - trashAltWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
{
if (P.Config.TryFindParent(node, out var parentNode))
{
Expand All @@ -1122,7 +1094,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
var searchPlusWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.SearchPlus);

ImGui.SameLine(ImGui.GetContentRegionMax().X - searchPlusWidth - trashAltWidth - newItemSpacing.X);
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current target"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Fill with current target"))
{
var target = Svc.Targets.Target;
var name = target?.Name?.TextValue ?? string.Empty;
Expand Down Expand Up @@ -1153,7 +1125,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newItemSpacing);

if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add entry"))
{
if (root == RootFolder)
{
Expand All @@ -1170,7 +1142,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last seen as new entry"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last seen as new entry"))
{
if (root == RootFolder)
{
Expand All @@ -1197,7 +1169,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder"))
{
var newNode = new TextFolderNode { Name = "Untitled folder" };
folderNode.Children.Add(newNode);
Expand All @@ -1206,7 +1178,7 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null)

var trashWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.TrashAlt);
ImGui.SameLine(ImGui.GetContentRegionMax().X - trashWidth);
if (ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete"))
{
if (P.Config.TryFindParent(node, out var parentNode))
{
Expand Down
Loading

0 comments on commit 0b86595

Please sign in to comment.