mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 23:37:44 +01:00
merge
This commit is contained in:
commit
badce7b47a
29 changed files with 2264 additions and 190 deletions
|
|
@ -16,6 +16,7 @@ using Dalamud.Game.Gui.Internal;
|
|||
using Dalamud.Game.Internal.DXGI;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Hooking.Internal;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.Internal.ManagedAsserts;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Interface.Internal.Windows.StyleEditor;
|
||||
|
|
@ -56,6 +57,8 @@ namespace Dalamud.Interface.Internal
|
|||
private readonly SwapChainVtableResolver address;
|
||||
private RawDX11Scene? scene;
|
||||
|
||||
private GameFontHandle? axisFontHandle;
|
||||
|
||||
// can't access imgui IO before first present call
|
||||
private bool lastWantCapture = false;
|
||||
private bool isRebuildingFonts = false;
|
||||
|
|
@ -128,10 +131,15 @@ namespace Dalamud.Interface.Internal
|
|||
public event Action ResizeBuffers;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an action that is executed when fonts are rebuilt.
|
||||
/// Gets or sets an action that is executed right before fonts are rebuilt.
|
||||
/// </summary>
|
||||
public event Action BuildFonts;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an action that is executed right after fonts are rebuilt.
|
||||
/// </summary>
|
||||
public event Action AfterBuildFonts;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default ImGui font.
|
||||
/// </summary>
|
||||
|
|
@ -304,6 +312,7 @@ namespace Dalamud.Interface.Internal
|
|||
if (!this.isRebuildingFonts)
|
||||
{
|
||||
Log.Verbose("[FONT] RebuildFonts() trigger");
|
||||
this.SetAxisFonts();
|
||||
|
||||
this.isRebuildingFonts = true;
|
||||
this.scene.OnNewRenderFrame += this.RebuildFontsInternal;
|
||||
|
|
@ -323,6 +332,26 @@ namespace Dalamud.Interface.Internal
|
|||
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");
|
||||
}
|
||||
|
||||
private void SetAxisFonts()
|
||||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
if (configuration.UseAxisFontsFromGame)
|
||||
{
|
||||
var currentFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, this.axisFontHandle?.Style.Size ?? 0f);
|
||||
var expectedFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, 12 * ImGui.GetIO().FontGlobalScale);
|
||||
if (currentFamilyAndSize == expectedFamilyAndSize)
|
||||
return;
|
||||
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = Service<GameFontManager>.Get().NewFontRef(new(expectedFamilyAndSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE(goat): When hooking ReShade DXGISwapChain::runtime_present, this is missing the syncInterval arg.
|
||||
* Seems to work fine regardless, I guess, so whatever.
|
||||
|
|
@ -384,6 +413,8 @@ namespace Dalamud.Interface.Internal
|
|||
this.scene.OnBuildUI += this.Display;
|
||||
this.scene.OnNewInputFrame += this.OnNewInputFrame;
|
||||
|
||||
this.SetAxisFonts();
|
||||
|
||||
this.SetupFonts();
|
||||
|
||||
StyleModel.TransferOldModels();
|
||||
|
|
@ -496,7 +527,6 @@ namespace Dalamud.Interface.Internal
|
|||
ImGui.GetIO().Fonts.Clear();
|
||||
|
||||
ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
|
||||
fontConfig.MergeMode = true;
|
||||
fontConfig.PixelSnapH = true;
|
||||
|
||||
var fontPathJp = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf");
|
||||
|
|
@ -522,7 +552,9 @@ namespace Dalamud.Interface.Internal
|
|||
},
|
||||
GCHandleType.Pinned);
|
||||
|
||||
fontConfig.MergeMode = false;
|
||||
ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, gameRangeHandle.AddrOfPinnedObject());
|
||||
fontConfig.MergeMode = true;
|
||||
|
||||
var fontPathIcon = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");
|
||||
|
||||
|
|
@ -546,6 +578,9 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
MonoFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathMono, 16.0f);
|
||||
|
||||
var gameFontManager = Service<GameFontManager>.Get();
|
||||
gameFontManager.BuildFonts();
|
||||
|
||||
Log.Verbose("[FONT] Invoke OnBuildFonts");
|
||||
this.BuildFonts?.Invoke();
|
||||
Log.Verbose("[FONT] OnBuildFonts OK!");
|
||||
|
|
@ -557,6 +592,13 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
ImGui.GetIO().Fonts.Build();
|
||||
|
||||
gameFontManager.AfterBuildFonts();
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, DefaultFont, false, true);
|
||||
|
||||
Log.Verbose("[FONT] Invoke OnAfterBuildFonts");
|
||||
this.AfterBuildFonts?.Invoke();
|
||||
Log.Verbose("[FONT] OnAfterBuildFonts OK!");
|
||||
|
||||
Log.Verbose("[FONT] Fonts built!");
|
||||
|
||||
this.fontBuildSignal.Set();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
|
|
@ -80,21 +81,6 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
framework.Update += this.FrameworkOnUpdate;
|
||||
}
|
||||
|
||||
private void FrameworkOnUpdate(Framework framework)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!this.loadQueue.TryTake(out var loadAction, 0, this.downloadToken.Token))
|
||||
return;
|
||||
|
||||
loadAction.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "An unhandled exception occurred in image loader framework dispatcher");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default plugin icon.
|
||||
/// </summary>
|
||||
|
|
@ -231,6 +217,21 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
return false;
|
||||
}
|
||||
|
||||
private void FrameworkOnUpdate(Framework framework)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!this.loadQueue.TryTake(out var loadAction, 0, this.downloadToken.Token))
|
||||
return;
|
||||
|
||||
loadAction.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "An unhandled exception occurred in image loader framework dispatcher");
|
||||
}
|
||||
}
|
||||
|
||||
private async void DownloadTask()
|
||||
{
|
||||
while (!this.downloadToken.Token.IsCancellationRequested)
|
||||
|
|
@ -482,12 +483,9 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
var bytes = await data.Content.ReadAsByteArrayAsync();
|
||||
imageBytes[i] = bytes;
|
||||
|
||||
|
||||
|
||||
Log.Verbose($"Plugin image{i + 1} for {manifest.InternalName} downloaded");
|
||||
|
||||
didAny = true;
|
||||
|
||||
}
|
||||
|
||||
if (didAny)
|
||||
|
|
|
|||
|
|
@ -399,11 +399,11 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
|
||||
if (ImGui.BeginPopupModal(modalTitle, ref this.feedbackModalDrawing, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar))
|
||||
{
|
||||
ImGui.Text(Locs.FeedbackModal_Text(this.feedbackPlugin.Name));
|
||||
ImGui.TextUnformatted(Locs.FeedbackModal_Text(this.feedbackPlugin.Name));
|
||||
|
||||
if (this.feedbackPlugin?.FeedbackMessage != null)
|
||||
{
|
||||
ImGui.TextWrapped(this.feedbackPlugin.FeedbackMessage);
|
||||
ImGuiHelpers.SafeTextWrapped(this.feedbackPlugin.FeedbackMessage);
|
||||
}
|
||||
|
||||
if (this.pluginListUpdatable.Any(
|
||||
|
|
@ -1133,7 +1133,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
var cursor = ImGui.GetCursorPos();
|
||||
|
||||
// Name
|
||||
ImGui.Text(label);
|
||||
ImGui.TextUnformatted(label);
|
||||
|
||||
// Download count
|
||||
var downloadCountText = manifest.DownloadCount > 0
|
||||
|
|
@ -1164,9 +1164,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
if (plugin is { IsBanned: true })
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
ImGui.TextWrapped(plugin.BanReason.IsNullOrEmpty()
|
||||
? Locs.PluginBody_Banned
|
||||
: Locs.PluginBody_BannedReason(plugin.BanReason));
|
||||
ImGuiHelpers.SafeTextWrapped(plugin.BanReason.IsNullOrEmpty()
|
||||
? Locs.PluginBody_Banned
|
||||
: Locs.PluginBody_BannedReason(plugin.BanReason));
|
||||
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
|
@ -1176,16 +1176,16 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
{
|
||||
if (!string.IsNullOrWhiteSpace(manifest.Punchline))
|
||||
{
|
||||
ImGui.TextWrapped(manifest.Punchline);
|
||||
ImGuiHelpers.SafeTextWrapped(manifest.Punchline);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(manifest.Description))
|
||||
{
|
||||
const int punchlineLen = 200;
|
||||
var firstLine = manifest.Description.Split(new[] { '\r', '\n' })[0];
|
||||
|
||||
ImGui.TextWrapped(firstLine.Length < punchlineLen
|
||||
? firstLine
|
||||
: firstLine[..punchlineLen]);
|
||||
ImGuiHelpers.SafeTextWrapped(firstLine.Length < punchlineLen
|
||||
? firstLine
|
||||
: firstLine[..punchlineLen]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1225,7 +1225,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
|
||||
ImGui.SameLine();
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
ImGui.Text(log.Title);
|
||||
ImGui.TextUnformatted(log.Title);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{log.Version}");
|
||||
|
|
@ -1233,7 +1233,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
cursor.Y += ImGui.GetTextLineHeightWithSpacing();
|
||||
ImGui.SetCursorPos(cursor);
|
||||
|
||||
ImGui.TextWrapped(log.Text);
|
||||
ImGuiHelpers.SafeTextWrapped(log.Text);
|
||||
|
||||
var endCursor = ImGui.GetCursorPos();
|
||||
|
||||
|
|
@ -1294,7 +1294,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
// Description
|
||||
if (!string.IsNullOrWhiteSpace(manifest.Description))
|
||||
{
|
||||
ImGui.TextWrapped(manifest.Description);
|
||||
ImGuiHelpers.SafeTextWrapped(manifest.Description);
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
|
@ -1503,7 +1503,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
ImGui.Indent();
|
||||
|
||||
// Name
|
||||
ImGui.Text(manifest.Name);
|
||||
ImGui.TextUnformatted(manifest.Name);
|
||||
|
||||
// Download count
|
||||
var downloadText = plugin.IsDev
|
||||
|
|
@ -1533,7 +1533,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
// Description
|
||||
if (!string.IsNullOrWhiteSpace(manifest.Description))
|
||||
{
|
||||
ImGui.TextWrapped(manifest.Description);
|
||||
ImGuiHelpers.SafeTextWrapped(manifest.Description);
|
||||
}
|
||||
|
||||
// Available commands (if loaded)
|
||||
|
|
@ -1548,7 +1548,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(10f, 10f));
|
||||
foreach (var command in commands)
|
||||
{
|
||||
ImGui.TextWrapped($"{command.Key} → {command.Value.HelpMessage}");
|
||||
ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1617,7 +1617,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
{
|
||||
ImGui.Text("Changelog:");
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
ImGui.TextWrapped(manifest.Changelog);
|
||||
ImGuiHelpers.SafeTextWrapped(manifest.Changelog);
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using Dalamud.Game.Gui.Dtr;
|
|||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
|
|
@ -37,6 +38,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
private bool doCfChatMessage;
|
||||
|
||||
private float globalUiScale;
|
||||
private bool doUseAxisFontsFromGame;
|
||||
private bool doToggleUiHide;
|
||||
private bool doToggleUiHideDuringCutscenes;
|
||||
private bool doToggleUiHideDuringGpose;
|
||||
|
|
@ -49,6 +51,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
private List<string>? dtrOrder;
|
||||
private List<string>? dtrIgnore;
|
||||
private int dtrSpacing;
|
||||
private bool dtrSwapDirection;
|
||||
|
||||
private List<ThirdPartyRepoSettings> thirdRepoList;
|
||||
private bool thirdRepoListChanged;
|
||||
|
|
@ -88,6 +91,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.doCfChatMessage = configuration.DutyFinderChatMessage;
|
||||
|
||||
this.globalUiScale = configuration.GlobalUiScale;
|
||||
this.doUseAxisFontsFromGame = configuration.UseAxisFontsFromGame;
|
||||
this.doToggleUiHide = configuration.ToggleUiHide;
|
||||
this.doToggleUiHideDuringCutscenes = configuration.ToggleUiHideDuringCutscenes;
|
||||
this.doToggleUiHideDuringGpose = configuration.ToggleUiHideDuringGpose;
|
||||
|
|
@ -99,6 +103,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.doTsm = configuration.ShowTsm;
|
||||
|
||||
this.dtrSpacing = configuration.DtrSpacing;
|
||||
this.dtrSwapDirection = configuration.DtrSwapDirection;
|
||||
|
||||
this.doPluginTest = configuration.DoPluginTest;
|
||||
this.thirdRepoList = configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
|
||||
|
|
@ -275,10 +280,14 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
{
|
||||
this.globalUiScale = 1.0f;
|
||||
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
|
||||
Service<InterfaceManager>.Get().RebuildFonts();
|
||||
}
|
||||
|
||||
if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f"))
|
||||
{
|
||||
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
|
||||
Service<InterfaceManager>.Get().RebuildFonts();
|
||||
}
|
||||
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays."));
|
||||
|
||||
|
|
@ -295,6 +304,9 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below."));
|
||||
|
||||
ImGui.Checkbox(Loc.Localize("DalamudSettingToggleAxisFonts", "Use AXIS fonts as default Dalamud font"), ref this.doUseAxisFontsFromGame);
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiAxisFontsHint", "Use AXIS fonts (the game's main UI fonts) as default Dalamud font."));
|
||||
|
||||
ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"), ref this.doToggleUiHide);
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."));
|
||||
|
||||
|
|
@ -416,6 +428,10 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
ImGui.Text(Loc.Localize("DalamudSettingServerInfoBarSpacing", "Server Info Bar spacing"));
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarSpacingHint", "Configure the amount of space between entries in the server info bar here."));
|
||||
ImGui.SliderInt("Spacing", ref this.dtrSpacing, 0, 40);
|
||||
|
||||
ImGui.Text(Loc.Localize("DalamudSettingServerInfoBarDirection", "Server Info Bar direction"));
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarDirectionHint", "If checked, the Server Info Bar elements will expand to the right instead of the left."));
|
||||
ImGui.Checkbox("Swap Direction", ref this.dtrSwapDirection);
|
||||
}
|
||||
|
||||
private void DrawExperimentalTab()
|
||||
|
|
@ -794,6 +810,8 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
configuration.IsFocusManagementEnabled = this.doFocus;
|
||||
configuration.ShowTsm = this.doTsm;
|
||||
|
||||
configuration.UseAxisFontsFromGame = this.doUseAxisFontsFromGame;
|
||||
|
||||
// This is applied every frame in InterfaceManager::CheckViewportState()
|
||||
configuration.IsDisableViewport = !this.doViewport;
|
||||
|
||||
|
|
@ -823,6 +841,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.dtrIgnore = configuration.DtrIgnore;
|
||||
|
||||
configuration.DtrSpacing = this.dtrSpacing;
|
||||
configuration.DtrSwapDirection = this.dtrSwapDirection;
|
||||
|
||||
configuration.DoPluginTest = this.doPluginTest;
|
||||
configuration.ThirdRepoList = this.thirdRepoList.Select(x => x.Clone()).ToList();
|
||||
|
|
@ -836,6 +855,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
configuration.Save();
|
||||
|
||||
_ = Service<PluginManager>.Get().ReloadPluginMastersAsync();
|
||||
Service<InterfaceManager>.Get().RebuildFonts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
|
|
@ -8,6 +8,7 @@ using Dalamud.Game;
|
|||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Interface.Animation.EasingFunctions;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using ImGuiScene;
|
||||
|
|
@ -19,6 +20,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
/// </summary>
|
||||
internal class TitleScreenMenuWindow : Window, IDisposable
|
||||
{
|
||||
private const float TargetFontSize = 16.2f;
|
||||
private readonly TextureWrap shadeTexture;
|
||||
|
||||
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
|
||||
|
|
@ -27,6 +29,8 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
private InOutCubic? fadeOutEasing;
|
||||
|
||||
private GameFontHandle? axisFontHandle;
|
||||
|
||||
private State state = State.Hide;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -67,14 +71,19 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
/// <inheritdoc/>
|
||||
public override void PreDraw()
|
||||
{
|
||||
this.SetAxisFonts();
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
|
||||
if (this.axisFontHandle?.Available ?? false)
|
||||
ImGui.PushFont(this.axisFontHandle.ImFont);
|
||||
base.PreDraw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void PostDraw()
|
||||
{
|
||||
if (this.axisFontHandle?.Available ?? false)
|
||||
ImGui.PopFont();
|
||||
ImGui.PopStyleVar(2);
|
||||
base.PostDraw();
|
||||
}
|
||||
|
|
@ -90,128 +99,143 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
/// <inheritdoc/>
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.SetWindowFontScale(1.3f);
|
||||
ImGui.SetWindowFontScale(TargetFontSize / ImGui.GetFont().FontSize * 4 / 3);
|
||||
|
||||
var tsm = Service<TitleScreenMenu>.Get();
|
||||
|
||||
switch (this.state)
|
||||
{
|
||||
case State.Show:
|
||||
{
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
{
|
||||
var entry = tsm.Entries[i];
|
||||
|
||||
if (!this.moveEasings.TryGetValue(entry.Id, out var moveEasing))
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
{
|
||||
moveEasing = new InOutQuint(TimeSpan.FromMilliseconds(400));
|
||||
this.moveEasings.Add(entry.Id, moveEasing);
|
||||
var entry = tsm.Entries[i];
|
||||
|
||||
if (!this.moveEasings.TryGetValue(entry.Id, out var moveEasing))
|
||||
{
|
||||
moveEasing = new InOutQuint(TimeSpan.FromMilliseconds(400));
|
||||
this.moveEasings.Add(entry.Id, moveEasing);
|
||||
}
|
||||
|
||||
if (!moveEasing.IsRunning && !moveEasing.IsDone)
|
||||
{
|
||||
moveEasing.Restart();
|
||||
}
|
||||
|
||||
if (moveEasing.IsDone)
|
||||
{
|
||||
moveEasing.Stop();
|
||||
}
|
||||
|
||||
moveEasing.Update();
|
||||
|
||||
var finalPos = (i + 1) * this.shadeTexture.Height;
|
||||
var pos = moveEasing.Value * finalPos;
|
||||
|
||||
// FIXME(goat): Sometimes, easings can overshoot and bring things out of alignment.
|
||||
if (moveEasing.IsDone)
|
||||
{
|
||||
pos = finalPos;
|
||||
}
|
||||
|
||||
this.DrawEntry(entry, moveEasing.IsRunning && i != 0, true, i == 0, true);
|
||||
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
cursor.Y = (float)pos;
|
||||
ImGui.SetCursorPos(cursor);
|
||||
}
|
||||
|
||||
if (!moveEasing.IsRunning && !moveEasing.IsDone)
|
||||
if (!ImGui.IsWindowHovered(ImGuiHoveredFlags.RootAndChildWindows |
|
||||
ImGuiHoveredFlags.AllowWhenOverlapped |
|
||||
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem))
|
||||
{
|
||||
moveEasing.Restart();
|
||||
this.state = State.FadeOut;
|
||||
}
|
||||
|
||||
if (moveEasing.IsDone)
|
||||
{
|
||||
moveEasing.Stop();
|
||||
}
|
||||
|
||||
moveEasing.Update();
|
||||
|
||||
var finalPos = (i + 1) * this.shadeTexture.Height;
|
||||
var pos = moveEasing.Value * finalPos;
|
||||
|
||||
// FIXME(goat): Sometimes, easings can overshoot and bring things out of alignment.
|
||||
if (moveEasing.IsDone)
|
||||
{
|
||||
pos = finalPos;
|
||||
}
|
||||
|
||||
this.DrawEntry(entry, moveEasing.IsRunning && i != 0, true, i == 0, true);
|
||||
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
cursor.Y = (float)pos;
|
||||
ImGui.SetCursorPos(cursor);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ImGui.IsWindowHovered(ImGuiHoveredFlags.RootAndChildWindows |
|
||||
ImGuiHoveredFlags.AllowWhenOverlapped |
|
||||
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem))
|
||||
{
|
||||
this.state = State.FadeOut;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case State.FadeOut:
|
||||
{
|
||||
this.fadeOutEasing ??= new InOutCubic(TimeSpan.FromMilliseconds(400))
|
||||
{
|
||||
IsInverse = true,
|
||||
};
|
||||
this.fadeOutEasing ??= new InOutCubic(TimeSpan.FromMilliseconds(400))
|
||||
{
|
||||
IsInverse = true,
|
||||
};
|
||||
|
||||
if (!this.fadeOutEasing.IsRunning && !this.fadeOutEasing.IsDone)
|
||||
{
|
||||
this.fadeOutEasing.Restart();
|
||||
if (!this.fadeOutEasing.IsRunning && !this.fadeOutEasing.IsDone)
|
||||
{
|
||||
this.fadeOutEasing.Restart();
|
||||
}
|
||||
|
||||
if (this.fadeOutEasing.IsDone)
|
||||
{
|
||||
this.fadeOutEasing.Stop();
|
||||
}
|
||||
|
||||
this.fadeOutEasing.Update();
|
||||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value);
|
||||
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
{
|
||||
var entry = tsm.Entries[i];
|
||||
|
||||
var finalPos = (i + 1) * this.shadeTexture.Height;
|
||||
|
||||
this.DrawEntry(entry, i != 0, true, i == 0, false);
|
||||
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
cursor.Y = finalPos;
|
||||
ImGui.SetCursorPos(cursor);
|
||||
}
|
||||
|
||||
ImGui.PopStyleVar();
|
||||
|
||||
var isHover = ImGui.IsWindowHovered(ImGuiHoveredFlags.RootAndChildWindows |
|
||||
ImGuiHoveredFlags.AllowWhenOverlapped |
|
||||
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
||||
|
||||
if (!isHover && this.fadeOutEasing!.IsDone)
|
||||
{
|
||||
this.state = State.Hide;
|
||||
this.fadeOutEasing = null;
|
||||
}
|
||||
else if (isHover)
|
||||
{
|
||||
this.state = State.Show;
|
||||
this.fadeOutEasing = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.fadeOutEasing.IsDone)
|
||||
{
|
||||
this.fadeOutEasing.Stop();
|
||||
}
|
||||
|
||||
this.fadeOutEasing.Update();
|
||||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value);
|
||||
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
{
|
||||
var entry = tsm.Entries[i];
|
||||
|
||||
var finalPos = (i + 1) * this.shadeTexture.Height;
|
||||
|
||||
this.DrawEntry(entry, i != 0, true, i == 0, false);
|
||||
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
cursor.Y = finalPos;
|
||||
ImGui.SetCursorPos(cursor);
|
||||
}
|
||||
|
||||
ImGui.PopStyleVar();
|
||||
|
||||
var isHover = ImGui.IsWindowHovered(ImGuiHoveredFlags.RootAndChildWindows |
|
||||
ImGuiHoveredFlags.AllowWhenOverlapped |
|
||||
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
||||
|
||||
if (!isHover && this.fadeOutEasing!.IsDone)
|
||||
{
|
||||
this.state = State.Hide;
|
||||
this.fadeOutEasing = null;
|
||||
}
|
||||
else if (isHover)
|
||||
{
|
||||
this.state = State.Show;
|
||||
this.fadeOutEasing = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case State.Hide:
|
||||
{
|
||||
if (this.DrawEntry(tsm.Entries[0], true, false, true, true))
|
||||
{
|
||||
this.state = State.Show;
|
||||
}
|
||||
if (this.DrawEntry(tsm.Entries[0], true, false, true, true))
|
||||
{
|
||||
this.state = State.Show;
|
||||
}
|
||||
|
||||
this.moveEasings.Clear();
|
||||
this.logoEasings.Clear();
|
||||
this.shadeEasings.Clear();
|
||||
break;
|
||||
}
|
||||
this.moveEasings.Clear();
|
||||
this.logoEasings.Clear();
|
||||
this.shadeEasings.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAxisFonts()
|
||||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
if (configuration.UseAxisFontsFromGame)
|
||||
{
|
||||
if (this.axisFontHandle == null)
|
||||
this.axisFontHandle = Service<GameFontManager>.Get().NewFontRef(new(GameFontFamily.Axis, TargetFontSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue