mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
feat: make Windows 11 immersive mode configurable
This commit is contained in:
parent
9c321b2c05
commit
1e40cabdc6
7 changed files with 97 additions and 20 deletions
|
|
@ -435,6 +435,23 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle Windows 11 immersive mode on the game window.
|
||||
/// </summary>
|
||||
/// <param name="enabled">Value.</param>
|
||||
internal void SetImmersiveMode(bool enabled)
|
||||
{
|
||||
if (this.GameWindowHandle == nint.Zero)
|
||||
return;
|
||||
|
||||
int value = enabled ? 1 : 0;
|
||||
var hr = NativeFunctions.DwmSetWindowAttribute(
|
||||
this.GameWindowHandle,
|
||||
NativeFunctions.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
ref value,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
private static void ShowFontError(string path)
|
||||
{
|
||||
Util.Fatal($"One or more files required by XIVLauncher were not found.\nPlease restart and report this error if it occurs again.\n\n{path}", "Error");
|
||||
|
|
@ -974,6 +991,16 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (Service<DalamudConfiguration>.Get().WindowIsImmersive)
|
||||
this.SetImmersiveMode(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not enable immersive mode");
|
||||
}
|
||||
|
||||
this.presentHook = Hook<PresentDelegate>.FromAddress(this.address.Present, this.PresentDetour);
|
||||
this.resizeBuffersHook = Hook<ResizeBuffersDelegate>.FromAddress(this.address.ResizeBuffers, this.ResizeBuffersDetour);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||
|
||||
|
|
@ -18,13 +21,6 @@ public class SettingsTabLook : SettingsTab
|
|||
{
|
||||
new GapSettingsEntry(5),
|
||||
|
||||
new ButtonSettingsEntry(
|
||||
Loc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
|
||||
Loc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
|
||||
() => Service<DalamudInterface>.Get().OpenStyleEditor()),
|
||||
|
||||
new GapSettingsEntry(5),
|
||||
|
||||
new SettingsEntry<bool>(
|
||||
Loc.Localize("DalamudSettingToggleAxisFonts", "Use AXIS fonts as default Dalamud font"),
|
||||
Loc.Localize("DalamudSettingToggleUiAxisFontsHint", "Use AXIS fonts (the game's main UI fonts) as default Dalamud font."),
|
||||
|
|
@ -39,6 +35,31 @@ public class SettingsTabLook : SettingsTab
|
|||
|
||||
new GapSettingsEntry(5, true),
|
||||
|
||||
new ButtonSettingsEntry(
|
||||
Loc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
|
||||
Loc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
|
||||
() => Service<DalamudInterface>.Get().OpenStyleEditor()),
|
||||
|
||||
new SettingsEntry<bool>(
|
||||
Loc.Localize("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
|
||||
Loc.Localize("DalamudSettingsUseDarkModeHint", "This will cause the FFXIV window title bar to follow your preferred Windows color settings, and switch to dark mode if enabled."),
|
||||
c => c.WindowIsImmersive,
|
||||
(v, c) => c.WindowIsImmersive = v,
|
||||
b =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Service<InterfaceManager>.GetNullable()?.SetImmersiveMode(b);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not toggle immersive mode");
|
||||
}
|
||||
},
|
||||
visibility: Util.IsWindows11),
|
||||
|
||||
new GapSettingsEntry(5, true),
|
||||
|
||||
new HintSettingsEntry(Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")),
|
||||
new GapSettingsEntry(3),
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
|
||||
private object? valueBacking;
|
||||
|
||||
public SettingsEntry(string name, string description, LoadSettingDelegate load, SaveSettingDelegate save, Action<T?>? change = null, Func<T?, string?>? warning = null, Func<T?, string?>? validity = null)
|
||||
public SettingsEntry(string name, string description, LoadSettingDelegate load, SaveSettingDelegate save, Action<T?>? change = null, Func<T?, string?>? warning = null, Func<T?, string?>? validity = null, Func<bool>? visibility = null)
|
||||
{
|
||||
this.load = load;
|
||||
this.save = save;
|
||||
|
|
@ -30,6 +30,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
this.Description = description;
|
||||
this.CheckWarning = warning;
|
||||
this.CheckValidity = validity;
|
||||
this.CheckVisibility = visibility;
|
||||
}
|
||||
|
||||
public delegate T? LoadSettingDelegate(DalamudConfiguration config);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue