Dalamud API10
This commit is contained in:
@@ -116,12 +116,12 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
if (!_apiController.IsCurrentVersion)
|
||||
{
|
||||
var ver = _apiController.CurrentClientVersion;
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
var unsupported = "UNSUPPORTED VERSION";
|
||||
var uidTextSize = ImGui.CalcTextSize(unsupported);
|
||||
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 - uidTextSize.X / 2);
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, unsupported);
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
UiSharedService.ColorTextWrapped($"Your Loporrit installation is out of date, the current version is {ver.Major}.{ver.Minor}.{ver.Build}. " +
|
||||
$"It is highly recommended to keep Loporrit up to date. Open /xlplugins and update the plugin.", ImGuiColors.DalamudRed);
|
||||
}
|
||||
@@ -510,9 +510,9 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
var uidText = GetUidText();
|
||||
var buttonSizeX = 0f;
|
||||
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
var uidTextSize = ImGui.CalcTextSize(uidText);
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
|
||||
var originalPos = ImGui.GetCursorPos();
|
||||
ImGui.SetWindowFontScale(1.5f);
|
||||
@@ -544,9 +544,9 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.SetCursorPosY(originalPos.Y + buttonSize.Y / 2 - uidTextSize.Y / 2 - ImGui.GetStyle().ItemSpacing.Y / 2);
|
||||
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 + buttonSizeX - uidTextSize.X / 2);
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
ImGui.TextColored(GetUidColor(), uidText);
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
|
||||
if (_apiController.ServerState is not ServerState.Connected)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ internal class ReportPopupHandler : IPopupHandler
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
UiSharedService.TextWrapped("Report " + _reportedPair!.UserData.AliasOrUID + " Profile");
|
||||
|
||||
ImGui.InputTextMultiline("##reportReason", ref _reportReason, 500, new Vector2(500 - ImGui.GetStyle().ItemSpacing.X * 2, 200));
|
||||
|
||||
@@ -187,7 +187,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
|
||||
try
|
||||
{
|
||||
if (_uiShared.UidFontBuilt && _configService.Current.ShowUploadingBigText) ImGui.PushFont(_uiShared.UidFont);
|
||||
if (_configService.Current.ShowUploadingBigText) _uiShared.UidFont.Push();
|
||||
var uploadText = "Uploading";
|
||||
|
||||
var textSize = ImGui.CalcTextSize(uploadText);
|
||||
@@ -204,7 +204,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_uiShared.UidFontBuilt && _configService.Current.ShowUploadingBigText) ImGui.PopFont();
|
||||
if (_configService.Current.ShowUploadingBigText) _uiShared.UidFont.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
private readonly CancellationTokenSource _cancellationTokenSource = new();
|
||||
private readonly ConfigurationServiceBase<MareConfig> _configService;
|
||||
private readonly IDtrBar _dtrBar;
|
||||
private readonly Lazy<DtrBarEntry> _entry;
|
||||
private readonly Lazy<IDtrBarEntry> _entry;
|
||||
private readonly ILogger<DtrEntry> _logger;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly PairManager _pairManager;
|
||||
@@ -56,7 +56,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
{
|
||||
_logger.LogDebug("Disposing DtrEntry");
|
||||
Clear();
|
||||
_entry.Value.Dispose();
|
||||
_entry.Value.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
_entry.Value.Shown = false;
|
||||
}
|
||||
|
||||
private DtrBarEntry CreateEntry()
|
||||
private IDtrBarEntry CreateEntry()
|
||||
{
|
||||
_logger.LogTrace("Creating new DtrBar entry");
|
||||
var entry = _dtrBar.Get("Loporrit");
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Data;
|
||||
@@ -12,6 +11,8 @@ using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
private readonly ApiController _apiController;
|
||||
private readonly FileDialogManager _fileDialogManager;
|
||||
private readonly MareProfileManager _mareProfileManager;
|
||||
private readonly UiBuilder _uiBuilder;
|
||||
private readonly IUiBuilder _uiBuilder;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private bool _adjustedForScollBarsLocalProfile = false;
|
||||
@@ -33,7 +34,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
private bool _wasOpen;
|
||||
|
||||
public EditProfileUi(ILogger<EditProfileUi> logger, MareMediator mediator,
|
||||
ApiController apiController, UiBuilder uiBuilder, UiSharedService uiSharedService,
|
||||
ApiController apiController, IUiBuilder uiBuilder, UiSharedService uiSharedService,
|
||||
FileDialogManager fileDialogManager, ServerConfigurationManager serverConfigurationManager,
|
||||
MareProfileManager mareProfileManager) : base(logger, mediator, "Loporrit Edit Profile###LoporritSyncEditProfileUI")
|
||||
{
|
||||
@@ -79,7 +80,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
_profileImage = profile.ImageData.Value;
|
||||
_pfpTextureWrap?.Dispose();
|
||||
_pfpTextureWrap = _uiBuilder.LoadImage(_profileImage);
|
||||
_pfpTextureWrap = _uiSharedService.LoadImage(_profileImage);
|
||||
}
|
||||
|
||||
if (!string.Equals(_profileDescription, profile.Description, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -95,7 +96,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
|
||||
ImGui.PushFont(_uiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Axis12)).ImFont);
|
||||
_uiSharedService.GameFont.Push();
|
||||
var descriptionTextSize = ImGui.CalcTextSize(profile.Description, 256f);
|
||||
var childFrame = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 256);
|
||||
if (descriptionTextSize.Y > childFrame.Y)
|
||||
@@ -115,7 +116,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
UiSharedService.TextWrapped(profile.Description);
|
||||
}
|
||||
ImGui.EndChildFrame();
|
||||
ImGui.PopFont();
|
||||
_uiSharedService.GameFont.Pop();
|
||||
|
||||
var nsfw = profile.IsNSFW;
|
||||
ImGui.BeginDisabled();
|
||||
@@ -191,13 +192,12 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
ImGui.SetCursorPosX(posX);
|
||||
ImGuiHelpers.ScaledRelativeSameLine(widthTextBox, ImGui.GetStyle().ItemSpacing.X);
|
||||
ImGui.TextUnformatted("Preview (approximate)");
|
||||
ImGui.PushFont(_uiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Axis12)).ImFont);
|
||||
ImGui.InputTextMultiline("##description", ref _descriptionText, 1500, ImGuiHelpers.ScaledVector2(widthTextBox, 200));
|
||||
ImGui.PopFont();
|
||||
using (_uiSharedService.GameFont.Push())
|
||||
ImGui.InputTextMultiline("##description", ref _descriptionText, 1500, ImGuiHelpers.ScaledVector2(widthTextBox, 200));
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
ImGui.PushFont(_uiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Axis12)).ImFont);
|
||||
_uiSharedService.GameFont.Push();
|
||||
var descriptionTextSizeLocal = ImGui.CalcTextSize(_descriptionText, 256f);
|
||||
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
|
||||
if (descriptionTextSizeLocal.Y > childFrameLocal.Y)
|
||||
@@ -217,7 +217,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
UiSharedService.TextWrapped(_descriptionText);
|
||||
}
|
||||
ImGui.EndChildFrame();
|
||||
ImGui.PopFont();
|
||||
_uiSharedService.GameFont.Pop();
|
||||
|
||||
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Save, "Save Description"))
|
||||
{
|
||||
|
||||
@@ -101,10 +101,10 @@ public class IntroUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
else if (!_configService.Current.AcceptedAgreement && _readFirstPage)
|
||||
{
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
|
||||
ImGui.SameLine();
|
||||
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
@@ -155,9 +155,9 @@ public class IntroUi : WindowMediatorSubscriberBase
|
||||
|| !_configService.Current.InitialScanComplete
|
||||
|| !Directory.Exists(_configService.Current.CacheFolder)))
|
||||
{
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
ImGui.TextUnformatted("File Storage Setup");
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
ImGui.Separator();
|
||||
|
||||
if (!_uiShared.HasValidPenumbraModPath)
|
||||
@@ -201,9 +201,9 @@ public class IntroUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
else if (!_uiShared.ApiController.ServerAlive)
|
||||
{
|
||||
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
|
||||
_uiShared.UidFont.Push();
|
||||
ImGui.TextUnformatted("Service Registration");
|
||||
if (_uiShared.UidFontBuilt) ImGui.PopFont();
|
||||
_uiShared.UidFont.Pop();
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped("To be able to use Loporrit you will have to register an account.");
|
||||
UiSharedService.TextWrapped("Refer to the instructions at the location you obtained this plugin for more information or support.");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Internal;
|
||||
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
@@ -29,11 +28,11 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
private IDalamudTextureWrap? _supporterTextureWrap;
|
||||
private IDalamudTextureWrap? _textureWrap;
|
||||
|
||||
public PopoutProfileUi(ILogger<PopoutProfileUi> logger, MareMediator mediator, UiSharedService uiBuilder,
|
||||
public PopoutProfileUi(ILogger<PopoutProfileUi> logger, MareMediator mediator, UiSharedService uiSharedService,
|
||||
ServerConfigurationManager serverManager, MareConfigService mareConfigService,
|
||||
MareProfileManager mareProfileManager, PairManager pairManager) : base(logger, mediator, "###LoporritSyncPopoutProfileUI")
|
||||
{
|
||||
_uiSharedService = uiBuilder;
|
||||
_uiSharedService = uiSharedService;
|
||||
_serverManager = serverManager;
|
||||
_mareProfileManager = mareProfileManager;
|
||||
_pairManager = pairManager;
|
||||
@@ -111,7 +110,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
var rectMin = drawList.GetClipRectMin();
|
||||
var rectMax = drawList.GetClipRectMax();
|
||||
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont, _uiSharedService.UidFontBuilt))
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
UiSharedService.ColorText(_pair.UserData.AliasOrUID, UiSharedService.AccentColor);
|
||||
|
||||
ImGuiHelpers.ScaledDummy(spacing.Y, spacing.Y);
|
||||
@@ -158,7 +157,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.PushFont(_uiSharedService.GetGameFontHandle());
|
||||
_uiSharedService.GameFont.Push();
|
||||
var remaining = ImGui.GetWindowContentRegionMax().Y - ImGui.GetCursorPosY();
|
||||
var descText = mareProfile.Description;
|
||||
var textSize = ImGui.CalcTextSize(descText, 256f * ImGuiHelpers.GlobalScale);
|
||||
@@ -169,7 +168,8 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
textSize = ImGui.CalcTextSize(descText + $"...{Environment.NewLine}[Open Full Profile for complete description]", 256f * ImGuiHelpers.GlobalScale);
|
||||
}
|
||||
UiSharedService.TextWrapped(trimmed ? descText + $"...{Environment.NewLine}[Open Full Profile for complete description]" : mareProfile.Description);
|
||||
ImGui.PopFont();
|
||||
|
||||
_uiSharedService.GameFont.Pop();
|
||||
|
||||
var padding = ImGui.GetStyle().WindowPadding.X / 2;
|
||||
bool tallerThanWide = _textureWrap.Height >= _textureWrap.Width;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Internal;
|
||||
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
@@ -77,7 +76,7 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
var rectMax = drawList.GetClipRectMax();
|
||||
var headerSize = ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y;
|
||||
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont, _uiSharedService.UidFontBuilt))
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
UiSharedService.ColorText(Pair.UserData.AliasOrUID, UiSharedService.AccentColor);
|
||||
|
||||
ImGuiHelpers.ScaledDummy(new Vector2(spacing.Y, spacing.Y));
|
||||
@@ -107,9 +106,8 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
};
|
||||
if (ImGui.BeginChildFrame(1000, childFrame))
|
||||
{
|
||||
ImGui.PushFont(_uiSharedService.GetGameFontHandle());
|
||||
ImGui.TextWrapped(mareProfile.Description);
|
||||
ImGui.PopFont();
|
||||
using (_uiSharedService.GameFont.Push())
|
||||
ImGui.TextWrapped(mareProfile.Description);
|
||||
}
|
||||
ImGui.EndChildFrame();
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
|
||||
using var id = ImRaii.PushId("syncshell_admin_" + GroupFullInfo.GID);
|
||||
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
ImGui.TextUnformatted(GroupFullInfo.GroupAliasOrGID + " Administrative Panel");
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.ManagedFontAtlas;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.FileCache;
|
||||
@@ -48,7 +50,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly Dalamud.Localization _localization;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly ITextureProvider _textureProvider;
|
||||
private readonly Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal);
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private bool _cacheDirectoryHasOtherFilesThanCache = false;
|
||||
@@ -76,7 +79,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
public UiSharedService(ILogger<UiSharedService> logger, IpcManager ipcManager, ApiController apiController,
|
||||
PeriodicFileScanner cacheScanner, FileDialogManager fileDialogManager,
|
||||
MareConfigService configService, DalamudUtilService dalamudUtil, DalamudPluginInterface pluginInterface, Dalamud.Localization localization,
|
||||
MareConfigService configService, DalamudUtilService dalamudUtil, IDalamudPluginInterface pluginInterface,
|
||||
ITextureProvider textureProvider, Dalamud.Localization localization,
|
||||
ServerConfigurationManager serverManager, MareMediator mediator) : base(logger, mediator)
|
||||
{
|
||||
_ipcManager = ipcManager;
|
||||
@@ -86,6 +90,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
_configService = configService;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_pluginInterface = pluginInterface;
|
||||
_textureProvider = textureProvider;
|
||||
_localization = localization;
|
||||
_serverConfigurationManager = serverManager;
|
||||
|
||||
@@ -93,8 +98,14 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
_isDirectoryWritable = IsDirectoryWritable(_configService.Current.CacheFolder);
|
||||
|
||||
_pluginInterface.UiBuilder.BuildFonts += BuildFont;
|
||||
_pluginInterface.UiBuilder.RebuildFonts();
|
||||
UidFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e =>
|
||||
{
|
||||
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
|
||||
{
|
||||
SizePx = 35
|
||||
}));
|
||||
});
|
||||
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
|
||||
|
||||
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) =>
|
||||
{
|
||||
@@ -118,9 +129,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
public string PlayerName => _dalamudUtil.GetPlayerName();
|
||||
|
||||
public ImFontPtr UidFont { get; private set; }
|
||||
|
||||
public bool UidFontBuilt { get; private set; }
|
||||
public IFontHandle UidFont { get; init; }
|
||||
public IFontHandle GameFont { get; init; }
|
||||
|
||||
public Dictionary<ushort, string> WorldData => _dalamudUtil.WorldData.Value;
|
||||
|
||||
@@ -287,6 +297,13 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
public static void FontText(string text, IFontHandle font, Vector4? color = null)
|
||||
{
|
||||
using var pushedFont = font.Push();
|
||||
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, Color(color ?? new Vector4(1, 1, 1, 1)), color != null);
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
public static Vector4 GetBoolColor(bool input) => input ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
|
||||
|
||||
public static Vector2 GetIconButtonSize(FontAwesomeIcon icon)
|
||||
@@ -563,7 +580,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
public void BigText(string text)
|
||||
{
|
||||
using var font = ImRaii.PushFont(UidFont, UidFontBuilt);
|
||||
using var font = UidFont.Push();
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
@@ -903,21 +920,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
[LibraryImport("user32")]
|
||||
internal static partial short GetKeyState(int nVirtKey);
|
||||
|
||||
internal ImFontPtr GetGameFontHandle()
|
||||
{
|
||||
return _pluginInterface.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Axis12)).ImFont;
|
||||
}
|
||||
|
||||
internal IDalamudTextureWrap LoadImage(byte[] imageData)
|
||||
{
|
||||
return _pluginInterface.UiBuilder.LoadImage(imageData);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_pluginInterface.UiBuilder.BuildFonts -= BuildFont;
|
||||
return _textureProvider.CreateFromImageAsync(imageData).Result;
|
||||
}
|
||||
|
||||
private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)
|
||||
@@ -930,27 +935,4 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
[GeneratedRegex(@"^(?:[a-zA-Z]:\\[\w\s\-\\]+?|\/(?:[\w\s\-\/])+?)$", RegexOptions.ECMAScript)]
|
||||
#pragma warning restore MA0009 // Add regex evaluation timeout
|
||||
private static partial Regex PathRegex();
|
||||
|
||||
private void BuildFont()
|
||||
{
|
||||
var fontFile = Path.Combine(_pluginInterface.DalamudAssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf");
|
||||
UidFontBuilt = false;
|
||||
|
||||
if (File.Exists(fontFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
UidFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontFile, 35);
|
||||
UidFontBuilt = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Font failed to load. {fontFile}", fontFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogDebug("Font doesn't exist. {fontFile}", fontFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user