preliminary api10 update

This commit is contained in:
Stanley Dimant
2024-07-17 00:35:28 +02:00
parent 8c56c91374
commit b9cf7eb6fa
34 changed files with 163 additions and 137 deletions

View File

@@ -2,6 +2,7 @@
using Dalamud.Plugin.Services;
using MareSynchronos.FileCache;
using MareSynchronos.MareConfiguration;
using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Services.ServerConfiguration;
using MareSynchronos.UI;
@@ -63,7 +64,7 @@ public sealed class CommandManagerService : IDisposable
if (_apiController.ServerState == WebAPI.SignalR.Utils.ServerState.Disconnecting)
{
_mediator.Publish(new NotificationMessage("Mare disconnecting", "Cannot use /toggle while Mare Synchronos is still disconnecting",
Dalamud.Interface.Internal.Notifications.NotificationType.Error));
NotificationType.Error));
}
if (_serverConfigurationManager.CurrentServer == null) return;

View File

@@ -53,7 +53,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
_performanceCollector = performanceCollector;
WorldData = new(() =>
{
return gameData.GetExcelSheet<Lumina.Excel.GeneratedSheets.World>(Dalamud.ClientLanguage.English)!
return gameData.GetExcelSheet<Lumina.Excel.GeneratedSheets.World>(Dalamud.Game.ClientLanguage.English)!
.Where(w => !w.Name.RawData.IsEmpty && w.DataCenter.Row != 0 && (w.IsPublic || char.IsUpper((char)w.Name.RawData[0])))
.ToDictionary(w => (ushort)w.RowId, w => w.Name.ToString());
});
@@ -74,7 +74,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
public bool IsWine { get; init; }
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.IGameObject? GposeTargetGameObject => GposeTarget == null ? null : _objectTable[GposeTarget->ObjectIndex];
public bool IsAnythingDrawing { get; private set; } = false;
public bool IsInCutscene { get; private set; } = false;
public bool IsInGpose { get; private set; } = false;
@@ -88,13 +88,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
public MareMediator Mediator { get; }
public Dalamud.Game.ClientState.Objects.Types.GameObject? CreateGameObject(IntPtr reference)
public Dalamud.Game.ClientState.Objects.Types.IGameObject? CreateGameObject(IntPtr reference)
{
EnsureIsOnFramework();
return _objectTable.CreateObjectReference(reference);
}
public async Task<Dalamud.Game.ClientState.Objects.Types.GameObject?> CreateGameObjectAsync(IntPtr reference)
public async Task<Dalamud.Game.ClientState.Objects.Types.IGameObject?> CreateGameObjectAsync(IntPtr reference)
{
return await RunOnFrameworkThread(() => _objectTable.CreateObjectReference(reference)).ConfigureAwait(false);
}
@@ -104,12 +104,12 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
if (!_framework.IsInFrameworkUpdateThread) throw new InvalidOperationException("Can only be run on Framework");
}
public Dalamud.Game.ClientState.Objects.Types.Character? GetCharacterFromObjectTableByIndex(int index)
public Dalamud.Game.ClientState.Objects.Types.ICharacter? GetCharacterFromObjectTableByIndex(int index)
{
EnsureIsOnFramework();
var objTableObj = _objectTable[index];
if (objTableObj!.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player) return null;
return (Dalamud.Game.ClientState.Objects.Types.Character)objTableObj;
return (Dalamud.Game.ClientState.Objects.Types.ICharacter)objTableObj;
}
public unsafe IntPtr GetCompanion(IntPtr? playerPointer = null)
@@ -126,10 +126,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
return await RunOnFrameworkThread(() => GetCompanion(playerPointer)).ConfigureAwait(false);
}
public Dalamud.Game.ClientState.Objects.Types.Character? GetGposeCharacterFromObjectTableByName(string name, bool onlyGposeCharacters = false)
public Dalamud.Game.ClientState.Objects.Types.ICharacter? GetGposeCharacterFromObjectTableByName(string name, bool onlyGposeCharacters = false)
{
EnsureIsOnFramework();
return (Dalamud.Game.ClientState.Objects.Types.Character?)_objectTable
return (Dalamud.Game.ClientState.Objects.Types.ICharacter?)_objectTable
.FirstOrDefault(i => (!onlyGposeCharacters || i.ObjectIndex >= 200) && string.Equals(i.Name.ToString(), name, StringComparison.Ordinal));
}
@@ -172,7 +172,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
return await RunOnFrameworkThread(() => GetPet(playerPointer)).ConfigureAwait(false);
}
public PlayerCharacter GetPlayerCharacter()
public IPlayerCharacter GetPlayerCharacter()
{
EnsureIsOnFramework();
return _clientState.LocalPlayer!;
@@ -238,13 +238,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
return _objectTable.Any(f => f.Address == key);
}
public bool IsObjectPresent(Dalamud.Game.ClientState.Objects.Types.GameObject? obj)
public bool IsObjectPresent(Dalamud.Game.ClientState.Objects.Types.IGameObject? obj)
{
EnsureIsOnFramework();
return obj != null && obj.IsValid();
}
public async Task<bool> IsObjectPresentAsync(Dalamud.Game.ClientState.Objects.Types.GameObject? obj)
public async Task<bool> IsObjectPresentAsync(Dalamud.Game.ClientState.Objects.Types.IGameObject? obj)
{
return await RunOnFrameworkThread(() => IsObjectPresent(obj)).ConfigureAwait(false);
}
@@ -358,7 +358,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
Thread.Sleep(tick * 2);
}
public Vector2 WorldToScreen(Dalamud.Game.ClientState.Objects.Types.GameObject? obj)
public Vector2 WorldToScreen(Dalamud.Game.ClientState.Objects.Types.IGameObject? obj)
{
if (obj == null) return Vector2.Zero;
return _gameGui.WorldToScreen(obj.Position, out var screenPos) ? screenPos : Vector2.Zero;
@@ -452,7 +452,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
if (chara == null || chara.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player)
continue;
MemoryHelper.ReadStringNullTerminated((nint)((GameObject*)chara.Address)->Name, out string charaName);
var charaName = ((GameObject*)chara.Address)->NameString;
var hash = (charaName, ((BattleChara*)chara.Address)->Character.HomeWorld).GetHash256();
if (!IsAnythingDrawing)
CheckCharacterForDrawing(chara.Address, charaName);

View File

@@ -1,8 +1,8 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Interface.Internal.Notifications;
using MareSynchronos.API.Data;
using MareSynchronos.API.Dto;
using MareSynchronos.API.Dto.Group;
using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.PlayerData.Handlers;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.Services.Events;
@@ -83,7 +83,7 @@ public record CombatOrPerformanceStartMessage : MessageBase;
public record CombatOrPerformanceEndMessage : MessageBase;
public record EventMessage(Event Event) : MessageBase;
public record PenumbraDirectoryChangedMessage(string? ModDirectory) : MessageBase;
public record PenumbraRedrawCharacterMessage(Character Character) : SameThreadMessage;
public record PenumbraRedrawCharacterMessage(ICharacter Character) : SameThreadMessage;
public record GameObjectHandlerCreatedMessage(GameObjectHandler GameObjectHandler, bool OwnedObject) : MessageBase;
public record GameObjectHandlerDestroyedMessage(GameObjectHandler GameObjectHandler, bool OwnedObject) : MessageBase;
#pragma warning restore S2094

View File

@@ -1,11 +1,11 @@
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Plugin.Services;
using MareSynchronos.MareConfiguration;
using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.Services.Mediator;
using Microsoft.Extensions.Logging;
using NotificationType = MareSynchronos.MareConfiguration.Models.NotificationType;
namespace MareSynchronos.Services;
@@ -15,7 +15,8 @@ public class NotificationService : DisposableMediatorSubscriberBase
private readonly IChatGui _chatGui;
private readonly MareConfigService _configurationService;
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator, INotificationManager notificationManager, IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator, INotificationManager notificationManager,
IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
{
_notificationManager = notificationManager;
_chatGui = chatGui;
@@ -47,8 +48,6 @@ public class NotificationService : DisposableMediatorSubscriberBase
switch (msg.Type)
{
case NotificationType.Info:
case NotificationType.Success:
case NotificationType.None:
PrintInfoChat(msg.Message);
break;
@@ -69,8 +68,6 @@ public class NotificationService : DisposableMediatorSubscriberBase
switch (msg.Type)
{
case NotificationType.Info:
case NotificationType.Success:
case NotificationType.None:
ShowNotificationLocationBased(msg, _configurationService.Current.InfoNotification);
break;
@@ -108,11 +105,19 @@ public class NotificationService : DisposableMediatorSubscriberBase
private void ShowToast(NotificationMessage msg)
{
_notificationManager.AddNotification(new Dalamud.Interface.ImGuiNotification.Notification()
Dalamud.Interface.ImGuiNotification.NotificationType dalamudType = msg.Type switch
{
MareConfiguration.Models.NotificationType.Error => Dalamud.Interface.ImGuiNotification.NotificationType.Error,
MareConfiguration.Models.NotificationType.Warning => Dalamud.Interface.ImGuiNotification.NotificationType.Warning,
MareConfiguration.Models.NotificationType.Info => Dalamud.Interface.ImGuiNotification.NotificationType.Info,
_ => Dalamud.Interface.ImGuiNotification.NotificationType.Info
};
_notificationManager.AddNotification(new Notification()
{
Content = msg.Message ?? string.Empty,
Title = msg.Title,
Type = msg.Type,
Type = dalamudType,
Minimized = false,
InitialDuration = msg.TimeShownOnScreen ?? TimeSpan.FromSeconds(3)
});

View File

@@ -1,8 +1,8 @@
using Dalamud.Interface.Internal.Notifications;
using MareSynchronos.API.Data;
using MareSynchronos.API.Data;
using MareSynchronos.API.Data.Comparer;
using MareSynchronos.Interop.Ipc;
using MareSynchronos.MareConfiguration;
using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.Services.Mediator;
using System.Collections.Concurrent;

View File

@@ -12,14 +12,14 @@ namespace MareSynchronos.Services;
public sealed class UiService : DisposableMediatorSubscriberBase
{
private readonly List<WindowMediatorSubscriberBase> _createdWindows = [];
private readonly UiBuilder _uiBuilder;
private readonly IUiBuilder _uiBuilder;
private readonly FileDialogManager _fileDialogManager;
private readonly ILogger<UiService> _logger;
private readonly MareConfigService _mareConfigService;
private readonly WindowSystem _windowSystem;
private readonly UiFactory _uiFactory;
public UiService(ILogger<UiService> logger, UiBuilder uiBuilder,
public UiService(ILogger<UiService> logger, IUiBuilder uiBuilder,
MareConfigService mareConfigService, WindowSystem windowSystem,
IEnumerable<WindowMediatorSubscriberBase> windows,
UiFactory uiFactory, FileDialogManager fileDialogManager,

View File

@@ -1,7 +1,9 @@
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using FFXIVClientStructs.Havok;
using FFXIVClientStructs.Havok.Animation;
using FFXIVClientStructs.Havok.Common.Base.Types;
using FFXIVClientStructs.Havok.Common.Serialize.Util;
using Lumina;
using Lumina.Data.Files;
using MareSynchronos.FileCache;