feat: Draw a main-viewport-big notifier on screen whenever in gamepad mode

This notifier is a light grey-ish background and some text in the upper
left corner of the main viewport.
This commit is contained in:
Chivalrik 2021-05-02 11:43:31 +02:00
parent 2a2419883b
commit 66d42a7cfd
3 changed files with 54 additions and 0 deletions

View file

@ -35,6 +35,7 @@ namespace Dalamud.Interface
private readonly ComponentDemoWindow componentDemoWindow;
private readonly ColorDemoWindow colorDemoWindow;
private readonly ScratchpadWindow scratchpadWindow;
private readonly GamepadModeNotifierWindow gamepadModeNotifierWindow;
private readonly WindowSystem windowSystem = new WindowSystem("DalamudCore");
@ -116,6 +117,9 @@ namespace Dalamud.Interface
};
this.windowSystem.AddWindow(this.scratchpadWindow);
this.gamepadModeNotifierWindow = new GamepadModeNotifierWindow();
this.windowSystem.AddWindow(this.gamepadModeNotifierWindow);
Log.Information("[DUI] Windows added");
if (dalamud.Configuration.LogOpenAtStartup)
@ -553,5 +557,13 @@ namespace Dalamud.Interface
{
this.scratchpadWindow.IsOpen ^= true;
}
/// <summary>
/// Toggle the gamepad notifier window window.
/// </summary>
internal void ToggleGamePadNotifierWindow()
{
this.gamepadModeNotifierWindow.IsOpen ^= true;
}
}
}

View file

@ -0,0 +1,41 @@
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace Dalamud.Interface
{
/// <summary>
/// Class responsible for drawing a notifier on screen that gamepad mode is active.
/// </summary>
internal class GamepadModeNotifierWindow : Window
{
/// <summary>
/// Initializes a new instance of the <see cref="GamepadModeNotifierWindow"/> class.
/// </summary>
public GamepadModeNotifierWindow()
: base(
"###DalamudGamepadModeNotifier",
ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoMouseInputs
| ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoNav
| ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings,
true)
{
this.Size = Vector2.Zero;
this.SizeCondition = ImGuiCond.Always;
this.IsOpen = false;
}
/// <summary>
/// Draws a light grey-ish, main-viewport-big filled rect in the background draw list alongside a text indicating gamepad mode.
/// </summary>
public override void Draw()
{
var drawList = ImGui.GetBackgroundDrawList();
drawList.PushClipRectFullScreen();
drawList.AddRectFilled(Vector2.Zero, ImGuiHelpers.MainViewport.Size, 0x661A1A1A);
drawList.AddText(Vector2.One, 0xFFFFFFFF, "Gamepad mode is ON. Press R1+L3 to deactivate, press R3 to toggle PluginInstaller.");
drawList.PopClipRect();
}
}
}

View file

@ -488,6 +488,7 @@ namespace Dalamud.Interface
{
ImGui.GetIO().ConfigFlags ^= ImGuiConfigFlags.NavEnableGamepad;
this.dalamud.ClientState.GamepadState.NavEnableGamepad ^= true;
this.dalamud.DalamudUi.ToggleGamePadNotifierWindow();
}
if (gamepadEnabled