Skip to content

Commit

Permalink
Make ToolbarWindow toggleable via command
Browse files Browse the repository at this point in the history
  • Loading branch information
Fayti1703 committed Dec 17, 2022
1 parent 6260440 commit d6e19a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Ktisis/Interface/Windows/ConfigGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Dalamud.Interface.Components;
using Dalamud.Game.ClientState.Keys;

using Ktisis.Interface.Windows.Toolbar;
using Ktisis.Util;
using Ktisis.Overlay;
using Ktisis.Localization;
Expand Down Expand Up @@ -149,8 +150,10 @@ public static void DrawInterfaceTab(Configuration cfg) {
cfg.TransformTableDisplayMultiplierInputs = displayMultiplierInputs;

var showToolbar = cfg.ShowToolbar;
if (ImGui.Checkbox("Show Experimental Toolbar", ref showToolbar))
if (ImGui.Checkbox("Show Experimental Toolbar", ref showToolbar)) {
cfg.ShowToolbar = showToolbar;
ToolbarWindow.Visible = showToolbar;
}
ImGui.PopItemWidth();

ImGui.EndTabItem();
Expand Down
21 changes: 19 additions & 2 deletions Ktisis/Interface/Windows/Toolbar/ToolbarWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using ImGuiNET;

using Ktisis.Events;
using Ktisis.Interface.Components.Toolbar;
using Ktisis.Interface.Windows.ActorEdit;
using Ktisis.Interop.Hooks;
Expand All @@ -10,14 +11,30 @@

namespace Ktisis.Interface.Windows.Toolbar {
public static class ToolbarWindow {
private static bool Visible = true;
internal static bool Visible = false;

// Toggle visibility
public static void Toggle() => Visible = !Visible;

public static void Init() {
EventManager.OnGPoseChange += OnGPoseStateChange;
}

public static void Dispose() {
EventManager.OnGPoseChange -= OnGPoseStateChange;
}

public static void OnGPoseStateChange(bool isInGPose) {
if (isInGPose) {
if (Ktisis.Configuration.ShowToolbar)
Visible = true;
} else
Visible = false;
}

// Draw window
public static void Draw() {
if (!Visible || !Ktisis.IsInGPose || !Ktisis.Configuration.ShowToolbar)
if (!Visible)
return;

AdvancedWindow.Draw();
Expand Down
10 changes: 10 additions & 0 deletions Ktisis/Ktisis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Ktisis.Structs.Actor;
using Ktisis.History;
using Ktisis.Events;
using Ktisis.Interface.Windows.Toolbar;
using Ktisis.Overlay;

namespace Ktisis {
Expand Down Expand Up @@ -68,6 +69,7 @@ public Ktisis(DalamudPluginInterface pluginInterface) {

Input.Init();
ActorStateWatcher.Init();
ToolbarWindow.Init();

// Register command

Expand Down Expand Up @@ -112,6 +114,7 @@ public void Dispose() {

Input.Dispose();
HistoryManager.Dispose();
ToolbarWindow.Dispose();

foreach (var (_, texture) in References.Textures) {
texture.Dispose();
Expand All @@ -131,6 +134,13 @@ private void OnCommand(string command, string arguments) {
case "configuration":
ConfigGui.Toggle();
break;
case "toolbar":
if (IsInGPose) {
ToolbarWindow.Toggle();
} else {
/* TODO: Throw a warning up? */
}
break;
default:
Workspace.Toggle();
break;
Expand Down

0 comments on commit d6e19a4

Please sign in to comment.