mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-23 00:49:17 +01:00
220 lines
10 KiB
C#
220 lines
10 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Text;
|
|
|
|
using CheapLoc;
|
|
using Dalamud.Configuration.Internal;
|
|
using Dalamud.Interface.Colors;
|
|
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
|
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
|
using Dalamud.Interface.Utility;
|
|
using Dalamud.Utility;
|
|
using ImGuiNET;
|
|
using Serilog;
|
|
|
|
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
|
|
|
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
|
|
public class SettingsTabLook : SettingsTab
|
|
{
|
|
private static readonly (string, float)[] GlobalUiScalePresets =
|
|
{
|
|
("9.6pt##DalamudSettingsGlobalUiScaleReset96", 9.6f / InterfaceManager.DefaultFontSizePt),
|
|
("12pt##DalamudSettingsGlobalUiScaleReset12", 12f / InterfaceManager.DefaultFontSizePt),
|
|
("14pt##DalamudSettingsGlobalUiScaleReset14", 14f / InterfaceManager.DefaultFontSizePt),
|
|
("18pt##DalamudSettingsGlobalUiScaleReset18", 18f / InterfaceManager.DefaultFontSizePt),
|
|
("24pt##DalamudSettingsGlobalUiScaleReset24", 24f / InterfaceManager.DefaultFontSizePt),
|
|
("36pt##DalamudSettingsGlobalUiScaleReset36", 36f / InterfaceManager.DefaultFontSizePt),
|
|
};
|
|
|
|
private float globalUiScale;
|
|
|
|
public override SettingsEntry[] Entries { get; } =
|
|
{
|
|
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."),
|
|
c => c.UseAxisFontsFromGame,
|
|
(v, c) => c.UseAxisFontsFromGame = v,
|
|
v =>
|
|
{
|
|
Service<FontAtlasFactory>.Get().UseAxisOverride = v;
|
|
Service<InterfaceManager>.Get().RebuildFonts();
|
|
}),
|
|
|
|
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),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
|
|
Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."),
|
|
c => c.ToggleUiHide,
|
|
(v, c) => c.ToggleUiHide = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
|
|
Loc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."),
|
|
c => c.ToggleUiHideDuringCutscenes,
|
|
(v, c) => c.ToggleUiHideDuringCutscenes = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
|
|
Loc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."),
|
|
c => c.ToggleUiHideDuringGpose,
|
|
(v, c) => c.ToggleUiHideDuringGpose = v),
|
|
|
|
new GapSettingsEntry(5, true),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
|
|
Loc.Localize("DalamudSettingToggleFocusManagementHint", "This will cause Dalamud windows to behave like in-game windows when pressing escape.\nThey will close one after another until all are closed. May not work for all plugins."),
|
|
c => c.IsFocusManagementEnabled,
|
|
(v, c) => c.IsFocusManagementEnabled = v),
|
|
|
|
// This is applied every frame in InterfaceManager::CheckViewportState()
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
|
|
Loc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."),
|
|
c => !c.IsDisableViewport,
|
|
(v, c) => c.IsDisableViewport = !v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"),
|
|
Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
|
|
c => c.IsDocking,
|
|
(v, c) => c.IsDocking = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
|
|
Loc.Localize("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
|
|
c => c.EnablePluginUISoundEffects,
|
|
(v, c) => c.EnablePluginUISoundEffects = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
|
|
Loc.Localize("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and plugin navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."),
|
|
c => c.IsGamepadNavigationEnabled,
|
|
(v, c) => c.IsGamepadNavigationEnabled = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
|
|
Loc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen."),
|
|
c => c.ShowTsm,
|
|
(v, c) => c.ShowTsm = v),
|
|
|
|
new SettingsEntry<bool>(
|
|
Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
|
|
Loc.Localize("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
|
|
c => c.PluginInstallerOpen == PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins,
|
|
(v, c) => c.PluginInstallerOpen = v ? PluginInstallerWindow.PluginInstallerOpenKind.InstalledPlugins : PluginInstallerWindow.PluginInstallerOpenKind.AllPlugins),
|
|
};
|
|
|
|
public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");
|
|
|
|
public override void Draw()
|
|
{
|
|
var interfaceManager = Service<InterfaceManager>.Get();
|
|
var fontBuildTask = interfaceManager.FontBuildTask;
|
|
|
|
ImGui.AlignTextToFramePadding();
|
|
ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global Font Scale"));
|
|
|
|
var buttonSize =
|
|
GlobalUiScalePresets
|
|
.Select(x => ImGui.CalcTextSize(x.Item1, 0, x.Item1.IndexOf('#')))
|
|
.Aggregate(Vector2.Zero, Vector2.Max)
|
|
+ (ImGui.GetStyle().FramePadding * 2);
|
|
foreach (var (buttonLabel, scale) in GlobalUiScalePresets)
|
|
{
|
|
ImGui.SameLine();
|
|
if (ImGui.Button(buttonLabel, buttonSize) && Math.Abs(this.globalUiScale - scale) > float.Epsilon)
|
|
{
|
|
ImGui.GetIO().FontGlobalScale = this.globalUiScale = scale;
|
|
interfaceManager.RebuildFonts();
|
|
}
|
|
}
|
|
|
|
if (!fontBuildTask.IsCompleted)
|
|
{
|
|
ImGui.SameLine();
|
|
var buildingFonts = Loc.Localize("DalamudSettingsFontBuildInProgressWithEndingThreeDots", "Building fonts...");
|
|
unsafe
|
|
{
|
|
var len = Encoding.UTF8.GetByteCount(buildingFonts);
|
|
var p = stackalloc byte[len];
|
|
Encoding.UTF8.GetBytes(buildingFonts, new(p, len));
|
|
ImGuiNative.igTextUnformatted(p, (p + len + ((Environment.TickCount / 200) % 3)) - 2);
|
|
}
|
|
}
|
|
|
|
var globalUiScaleInPt = 12f * this.globalUiScale;
|
|
if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref globalUiScaleInPt, 0.1f, 9.6f, 36f, "%.1fpt", ImGuiSliderFlags.AlwaysClamp))
|
|
{
|
|
this.globalUiScale = globalUiScaleInPt / 12f;
|
|
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
|
|
interfaceManager.RebuildFonts();
|
|
}
|
|
|
|
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale text in all XIVLauncher UI elements - this is useful for 4K displays."));
|
|
|
|
if (fontBuildTask.IsFaulted || fontBuildTask.IsCanceled)
|
|
{
|
|
ImGui.TextColored(
|
|
ImGuiColors.DalamudRed,
|
|
Loc.Localize("DalamudSettingsFontBuildFaulted", "Failed to load fonts as requested."));
|
|
if (fontBuildTask.Exception is not null
|
|
&& ImGui.CollapsingHeader("##DalamudSetingsFontBuildFaultReason"))
|
|
{
|
|
foreach (var e in fontBuildTask.Exception.InnerExceptions)
|
|
ImGui.TextUnformatted(e.ToString());
|
|
}
|
|
}
|
|
|
|
base.Draw();
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
this.globalUiScale = Service<DalamudConfiguration>.Get().GlobalUiScale;
|
|
|
|
base.Load();
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
Service<DalamudConfiguration>.Get().GlobalUiScale = this.globalUiScale;
|
|
|
|
base.Save();
|
|
}
|
|
}
|