cache result of IsWine
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using MareSynchronos.MareConfiguration;
|
using MareSynchronos.MareConfiguration;
|
||||||
|
using MareSynchronos.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -15,12 +16,14 @@ public sealed class FileCompactor
|
|||||||
private readonly ILogger<FileCompactor> _logger;
|
private readonly ILogger<FileCompactor> _logger;
|
||||||
|
|
||||||
private readonly MareConfigService _mareConfigService;
|
private readonly MareConfigService _mareConfigService;
|
||||||
|
private readonly DalamudUtilService _dalamudUtilService;
|
||||||
|
|
||||||
public FileCompactor(ILogger<FileCompactor> logger, MareConfigService mareConfigService)
|
public FileCompactor(ILogger<FileCompactor> logger, MareConfigService mareConfigService, DalamudUtilService dalamudUtilService)
|
||||||
{
|
{
|
||||||
_clusterSizes = new(StringComparer.Ordinal);
|
_clusterSizes = new(StringComparer.Ordinal);
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_mareConfigService = mareConfigService;
|
_mareConfigService = mareConfigService;
|
||||||
|
_dalamudUtilService = dalamudUtilService;
|
||||||
_efInfo = new WOF_FILE_COMPRESSION_INFO_V1
|
_efInfo = new WOF_FILE_COMPRESSION_INFO_V1
|
||||||
{
|
{
|
||||||
Algorithm = CompressionAlgorithm.XPRESS8K,
|
Algorithm = CompressionAlgorithm.XPRESS8K,
|
||||||
@@ -66,7 +69,7 @@ public sealed class FileCompactor
|
|||||||
{
|
{
|
||||||
bool ntfs = isNTFS ?? string.Equals(new DriveInfo(new FileInfo(filePath).Directory!.Root.FullName).DriveFormat, "NTFS", StringComparison.OrdinalIgnoreCase);
|
bool ntfs = isNTFS ?? string.Equals(new DriveInfo(new FileInfo(filePath).Directory!.Root.FullName).DriveFormat, "NTFS", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (Dalamud.Utility.Util.IsWine() || !ntfs) return new FileInfo(filePath).Length;
|
if (_dalamudUtilService.IsWine.Value || !ntfs) return new FileInfo(filePath).Length;
|
||||||
|
|
||||||
var clusterSize = GetClusterSize(filePath);
|
var clusterSize = GetClusterSize(filePath);
|
||||||
if (clusterSize == -1) return new FileInfo(filePath).Length;
|
if (clusterSize == -1) return new FileInfo(filePath).Length;
|
||||||
@@ -79,7 +82,7 @@ public sealed class FileCompactor
|
|||||||
{
|
{
|
||||||
await File.WriteAllBytesAsync(filePath, decompressedFile, token).ConfigureAwait(false);
|
await File.WriteAllBytesAsync(filePath, decompressedFile, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (Dalamud.Utility.Util.IsWine() || !_mareConfigService.Current.UseCompactor)
|
if (_dalamudUtilService.IsWine.Value || !_mareConfigService.Current.UseCompactor)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Dalamud.Game.ClientState.Objects;
|
|||||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
|
using Dalamud.Utility;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||||
@@ -68,8 +69,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
targetManager.Target = CreateGameObject(addr);
|
targetManager.Target = CreateGameObject(addr);
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
IsWine = Util.IsWine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsWine { get; init; }
|
||||||
public unsafe GameObject* GposeTarget => TargetSystem.Instance()->GPoseTarget;
|
public unsafe GameObject* GposeTarget => TargetSystem.Instance()->GPoseTarget;
|
||||||
public unsafe Dalamud.Game.ClientState.Objects.Types.GameObject? GposeTargetGameObject => GposeTarget == null ? null : _objectTable[GposeTarget->ObjectIndex];
|
public unsafe Dalamud.Game.ClientState.Objects.Types.GameObject? GposeTargetGameObject => GposeTarget == null ? null : _objectTable[GposeTarget->ObjectIndex];
|
||||||
public bool IsAnythingDrawing { get; private set; } = false;
|
public bool IsAnythingDrawing { get; private set; } = false;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class IntroUi : WindowMediatorSubscriberBase
|
|||||||
private readonly CacheMonitor _cacheMonitor;
|
private readonly CacheMonitor _cacheMonitor;
|
||||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
||||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||||
|
private readonly DalamudUtilService _dalamudUtilService;
|
||||||
private readonly UiSharedService _uiShared;
|
private readonly UiSharedService _uiShared;
|
||||||
private int _currentLanguage;
|
private int _currentLanguage;
|
||||||
private bool _readFirstPage;
|
private bool _readFirstPage;
|
||||||
@@ -31,13 +32,13 @@ public class IntroUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, MareConfigService configService,
|
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, MareConfigService configService,
|
||||||
CacheMonitor fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator,
|
CacheMonitor fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator,
|
||||||
PerformanceCollectorService performanceCollectorService) : base(logger, mareMediator, "Mare Synchronos Setup", performanceCollectorService)
|
PerformanceCollectorService performanceCollectorService, DalamudUtilService dalamudUtilService) : base(logger, mareMediator, "Mare Synchronos Setup", performanceCollectorService)
|
||||||
{
|
{
|
||||||
_uiShared = uiShared;
|
_uiShared = uiShared;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_cacheMonitor = fileCacheManager;
|
_cacheMonitor = fileCacheManager;
|
||||||
_serverConfigurationManager = serverConfigurationManager;
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
|
_dalamudUtilService = dalamudUtilService;
|
||||||
IsOpen = false;
|
IsOpen = false;
|
||||||
ShowCloseButton = false;
|
ShowCloseButton = false;
|
||||||
RespectCloseHotkey = false;
|
RespectCloseHotkey = false;
|
||||||
@@ -53,7 +54,7 @@ public class IntroUi : WindowMediatorSubscriberBase
|
|||||||
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
||||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) =>
|
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) =>
|
||||||
{
|
{
|
||||||
_configService.Current.UseCompactor = !Util.IsWine();
|
_configService.Current.UseCompactor = !dalamudUtilService.IsWine;
|
||||||
IsOpen = true;
|
IsOpen = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ public class IntroUi : WindowMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
_uiShared.DrawFileScanState();
|
_uiShared.DrawFileScanState();
|
||||||
}
|
}
|
||||||
if (!Util.IsWine())
|
if (!_dalamudUtilService.IsWine)
|
||||||
{
|
{
|
||||||
var useFileCompactor = _configService.Current.UseCompactor;
|
var useFileCompactor = _configService.Current.UseCompactor;
|
||||||
if (ImGui.Checkbox("Use File Compactor", ref useFileCompactor))
|
if (ImGui.Checkbox("Use File Compactor", ref useFileCompactor))
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
private readonly ApiController _apiController;
|
private readonly ApiController _apiController;
|
||||||
private readonly IpcManager _ipcManager;
|
private readonly IpcManager _ipcManager;
|
||||||
private readonly CacheMonitor _cacheMonitor;
|
private readonly CacheMonitor _cacheMonitor;
|
||||||
|
private readonly DalamudUtilService _dalamudUtilService;
|
||||||
private readonly MareConfigService _configService;
|
private readonly MareConfigService _configService;
|
||||||
private readonly ConcurrentDictionary<GameObjectHandler, Dictionary<string, FileDownloadStatus>> _currentDownloads = new();
|
private readonly ConcurrentDictionary<GameObjectHandler, Dictionary<string, FileDownloadStatus>> _currentDownloads = new();
|
||||||
private readonly FileCompactor _fileCompactor;
|
private readonly FileCompactor _fileCompactor;
|
||||||
@@ -68,7 +69,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
FileTransferOrchestrator fileTransferOrchestrator,
|
FileTransferOrchestrator fileTransferOrchestrator,
|
||||||
FileCacheManager fileCacheManager,
|
FileCacheManager fileCacheManager,
|
||||||
FileCompactor fileCompactor, ApiController apiController,
|
FileCompactor fileCompactor, ApiController apiController,
|
||||||
IpcManager ipcManager, CacheMonitor cacheMonitor) : base(logger, mediator, "Mare Synchronos Settings", performanceCollector)
|
IpcManager ipcManager, CacheMonitor cacheMonitor,
|
||||||
|
DalamudUtilService dalamudUtilService) : base(logger, mediator, "Mare Synchronos Settings", performanceCollector)
|
||||||
{
|
{
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_mareCharaFileManager = mareCharaFileManager;
|
_mareCharaFileManager = mareCharaFileManager;
|
||||||
@@ -81,6 +83,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
_apiController = apiController;
|
_apiController = apiController;
|
||||||
_ipcManager = ipcManager;
|
_ipcManager = ipcManager;
|
||||||
_cacheMonitor = cacheMonitor;
|
_cacheMonitor = cacheMonitor;
|
||||||
|
_dalamudUtilService = dalamudUtilService;
|
||||||
_fileCompactor = fileCompactor;
|
_fileCompactor = fileCompactor;
|
||||||
_uiShared = uiShared;
|
_uiShared = uiShared;
|
||||||
AllowClickthrough = false;
|
AllowClickthrough = false;
|
||||||
@@ -543,7 +546,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
ImGui.TextUnformatted($"Currently utilized local storage: Calculating...");
|
ImGui.TextUnformatted($"Currently utilized local storage: Calculating...");
|
||||||
ImGui.TextUnformatted($"Remaining space free on drive: {UiSharedService.ByteToString(_cacheMonitor.FileCacheDriveFree)}");
|
ImGui.TextUnformatted($"Remaining space free on drive: {UiSharedService.ByteToString(_cacheMonitor.FileCacheDriveFree)}");
|
||||||
bool useFileCompactor = _configService.Current.UseCompactor;
|
bool useFileCompactor = _configService.Current.UseCompactor;
|
||||||
bool isLinux = Util.IsWine();
|
bool isLinux = _dalamudUtilService.IsWine;
|
||||||
if (!useFileCompactor && !isLinux)
|
if (!useFileCompactor && !isLinux)
|
||||||
{
|
{
|
||||||
UiSharedService.ColorTextWrapped("Hint: To free up space when using Mare consider enabling the File Compactor", ImGuiColors.DalamudYellow);
|
UiSharedService.ColorTextWrapped("Hint: To free up space when using Mare consider enabling the File Compactor", ImGuiColors.DalamudYellow);
|
||||||
|
|||||||
Reference in New Issue
Block a user