Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add config for show toast about do ation. add an test window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 26, 2023
1 parent 9e8564f commit 38de866
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 40 deletions.
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public class PluginConfiguration : IPluginConfiguration
public bool TargetHuntingRelicLevePriority = true;
public bool TargetQuestPriority = true;

public bool ShowToastsAboutDoAction = true;

public void Save()
{
Svc.PluginInterface.SavePluginConfig(this);
Expand Down
13 changes: 8 additions & 5 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ private static void DoActionCommand(string str)
{
DataCenter.AddCommandAction(iAct, time);

Svc.Toasts.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = iAct.IconID,
});
if (Service.Config.ShowToastsAboutDoAction)
{
Svc.Toasts.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = iAct.IconID,
});
}

return;
}
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"ConfigWindow_Param_SayOutStateChanged": "Saying the state changes out",
"ConfigWindow_Param_ShowInfoOnDtr": "Display plugin state on server info",
"ConfigWindow_Param_ShowInfoOnToast": "Display plugin state on toast",
"ConfigWindow_Param_ShowToastsAboutDoAction": "Display do action feedback on toast",
"ConfigWindow_Param_NamePlateIconId": "Player's name plate icon id when state is on. Recommend 61435, 61437",
"ConfigWindow_Param_Action": "Action",
"ConfigWindow_Param_UseAOEAction": "Use AOE actions",
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ internal partial class Strings
public string ConfigWindow_Param_SayOutStateChanged { get; set; } = "Saying the state changes out";
public string ConfigWindow_Param_ShowInfoOnDtr { get; set; } = "Display plugin state on server info";
public string ConfigWindow_Param_ShowInfoOnToast { get; set; } = "Display plugin state on toast";
public string ConfigWindow_Param_ShowToastsAboutDoAction { get; set; } = "Display do action feedback on toast";
public string ConfigWindow_Param_NamePlateIconId { get; set; } = "Player's name plate icon id when state is on. Recommend 61435, 61437";
public string ConfigWindow_Param_Action { get; set; } = "Action";
public string ConfigWindow_Param_UseAOEAction { get; set; } = "Use AOE actions";
Expand Down
8 changes: 8 additions & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable
private readonly WindowSystem windowSystem;

static RotationConfigWindow _comboConfigWindow;
static RotationConfigWindowNew _rotationConfigWindow;
static ControlWindow _controlWindow;
static NextActionWindow _nextActionWindow;
static CooldownWindow _cooldownWindow;
Expand Down Expand Up @@ -52,12 +53,14 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
}

_comboConfigWindow = new();
_rotationConfigWindow = new();
_controlWindow = new();
_nextActionWindow = new();
_cooldownWindow = new();

windowSystem = new WindowSystem(Name);
windowSystem.AddWindow(_comboConfigWindow);
windowSystem.AddWindow(_rotationConfigWindow);
windowSystem.AddWindow(_controlWindow);
windowSystem.AddWindow(_nextActionWindow);
windowSystem.AddWindow(_cooldownWindow);
Expand Down Expand Up @@ -121,6 +124,11 @@ internal static void OpenConfigWindow()
_comboConfigWindow.Toggle();
}

internal static void ToggleConfigWindow()
{
_rotationConfigWindow.Toggle();
}

static RandomDelay validDelay = new(() => (0.2f, 0.2f));

internal static void UpdateDisplayWindow()
Expand Down
41 changes: 9 additions & 32 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,17 @@
using ECommons.DalamudServices;
using F23.StringSimilarity;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.Havok;
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration;
using RotationSolver.Commands;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Updaters;
using System.ComponentModel;
using System.Xml.Linq;

namespace RotationSolver.UI;

internal static class ImGuiHelper
{
const ImGuiWindowFlags TOOLTIP_FLAG =
ImGuiWindowFlags.Tooltip |
ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoSavedSettings |
ImGuiWindowFlags.NoBringToFrontOnFocus |
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.NoInputs |
ImGuiWindowFlags.AlwaysAutoResize;

public static void DrawTooltip(Action act, string id)
{
if (act == null) return;
ImGui.SetWindowPos(id, ImGui.GetIO().MousePos);
if (ImGui.Begin(id, TOOLTIP_FLAG))
{
act();
ImGui.End();
}
}
public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action selected,
Action<T> showToolTip = null, Action<Action<T>> additionalHeader = null,
Action otherThing = null) where T : class, ITexture
Expand Down Expand Up @@ -197,11 +175,11 @@ public static void HoveredString(string text, Action selected = null)
}
}

public static void ShowTooltip(string text)
{
if (!Service.Config.ShowTooltips) return;
if (!string.IsNullOrEmpty(text)) ImGui.SetTooltip(text);
}
public static void ShowTooltip(string text) => ImguiTooltips.ShowTooltip(text);
//{
// if (!Service.Config.ShowTooltips) return;
// if (!string.IsNullOrEmpty(text)) ImGui.SetTooltip(text);
//}

//public static bool HoveredStringReset(string text)
//{
Expand Down Expand Up @@ -453,8 +431,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
=> rotation.DrawEnableTexture(canAddButton, null,
text =>
{
ImGui.SetNextWindowSizeConstraints(new Vector2(0, 0), new Vector2(1000, 1500));
DrawTooltip(() =>
ImguiTooltips.ShowTooltip(() =>
{
var t = IconSet.GetTexture(IconSet.GetJobIcon(rotation, IconType.Framed));
ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height));
Expand Down Expand Up @@ -493,7 +470,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
}
ImGui.Text(ex.StackTrace);
}
}, "Popup" + text.GetHashCode().ToString());
});
},
showToolTip =>
{
Expand Down Expand Up @@ -610,7 +587,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
}
if (ImGui.IsItemHovered() && (hasTexture || !string.IsNullOrEmpty( texture.Description)))
{
DrawTooltip(() =>
ImguiTooltips.ShowTooltip(() =>
{
if(hasTexture)
{
Expand All @@ -624,7 +601,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
ImGui.Text(texture.Description);
}

}, "PictureDescription" + texture.GetHashCode().ToString());
});
}
}
}
Expand Down
43 changes: 43 additions & 0 deletions RotationSolver/UI/ImguiTooltips.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Dalamud.Interface.Colors;

namespace RotationSolver.UI;

internal static class ImguiTooltips
{
const ImGuiWindowFlags TOOLTIP_FLAG =
ImGuiWindowFlags.Tooltip |
ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoSavedSettings |
ImGuiWindowFlags.NoBringToFrontOnFocus |
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.NoInputs |
ImGuiWindowFlags.AlwaysAutoResize;

const string TOOLTIP_ID = "RotationSolver Tooltips";

public static void ShowTooltip(string text)
{
if(string.IsNullOrEmpty(text)) return;
ShowTooltip(() => ImGui.Text(text));
}

public static void ShowTooltip(Action act)
{
if (act == null) return;
if (!Service.Config.ShowTooltips) return;

ImGui.SetNextWindowBgAlpha(1);
ImGui.PushStyleColor(ImGuiCol.BorderShadow, ImGuiColors.DalamudWhite);

//ImGui.SetNextWindowSizeConstraints(new Vector2(0, 0), new Vector2(800, 1500));
ImGui.SetWindowPos(TOOLTIP_ID, ImGui.GetIO().MousePos);

if (ImGui.Begin(TOOLTIP_ID, TOOLTIP_FLAG))
{
act();
ImGui.End();
}

ImGui.PopStyleColor();
}
}
18 changes: 18 additions & 0 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Dalamud.Interface.Windowing;

namespace RotationSolver.UI;

public class RotationConfigWindowNew : Window
{
public RotationConfigWindowNew()
: base(nameof(RotationConfigWindowNew), 0, false)
{
SizeCondition = ImGuiCond.FirstUseEver;
Size = new Vector2(740f, 490f);
RespectCloseHotkey = true;
}

public override void Draw()
{
}
}
9 changes: 8 additions & 1 deletion RotationSolver/UI/RotationConfigWindow_Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ internal partial class RotationConfigWindow
{
private static void DrawHelpTab()
{
if(ImGuiHelper.IconButton(FontAwesomeIcon.Code, "Github"))
if(ImGui.Button("New Config Window (Test)"))
{
RotationSolverPlugin.ToggleConfigWindow();
}

ImGui.SameLine();

if (ImGuiHelper.IconButton(FontAwesomeIcon.Code, "Github"))
{
Util.OpenLink("https://github.com/ArchiDog1998/RotationSolver");
}
Expand Down
2 changes: 0 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Major.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Newtonsoft.Json.Linq;
using RotationSolver.Localization;
using System.Xml.Linq;

namespace RotationSolver.UI;
internal partial class RotationConfigWindow : Window
Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ private void DrawParamDisplay()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowInfoOnToast,
ref Service.Config.ShowInfoOnToast, Service.Default.ShowInfoOnToast);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowToastsAboutDoAction,
ref Service.Config.ShowToastsAboutDoAction, Service.Default.ShowToastsAboutDoAction);

DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_NamePlateIconId,
ref Service.Config.NamePlateIconId, Service.Default.NamePlateIconId, 5, 0, 150000, otherThing: RSCommands.UpdateStateNamePlate);

Expand Down

0 comments on commit 38de866

Please sign in to comment.