diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 1fa130a5..cd630194 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -85,4 +85,4 @@ jobs: git checkout main git add PetNicknames.json git commit -m "[CI] Updating PetNicknames.json for ${{ github.ref_name }}" || true - git push origin main + git push origin main \ No newline at end of file diff --git a/PetNicknames.json b/PetNicknames.json index 92ead7a6..338729f2 100644 --- a/PetNicknames.json +++ b/PetNicknames.json @@ -1,31 +1,31 @@ -[ - { - "Author": "Glyceri", - "Name": "Pet Nicknames", - "InternalName": "PetNicknames", - "AssemblyVersion": "2.0.0.0", - "TestingAssemblyVersion": "2.0.0.0", - "Description": "Give your minions, Carbuncles and Faeries cute nicknames\nand share them with your friends.", - "ApplicableVersion": "any", - "RepoUrl": "https://github.com/Glyceri/FFXIVPetRenamer", - "Tags": [ - "Pet", - "plugin", - "Rename", - "Nickname", - "Name", - "Minion" - ], - "DalamudApiLevel": 10, - "LoadRequiredState": 0, - "LoadSync": false, - "CanUnloadAsync": false, - "LoadPriority": 0, - "IconUrl": "https://github.com/Glyceri/FFXIVPetRenamer/raw/main/icon.png", - "Punchline": "Give your minions, Carbuncles and Faeries cute nicknames\nand share them with your friends.", - "AcceptsFeedback": true, - "DownloadLinkInstall": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip", - "DownloadLinkUpdate": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip", - "DownloadLinkTesting": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip" - } -] +[ + { + "Author": "Glyceri", + "Name": "Pet Nicknames", + "InternalName": "PetNicknames", + "AssemblyVersion": "2.0.0.0", + "TestingAssemblyVersion": "2.0.0.0", + "Description": "Give your minions, Carbuncles and Faeries cute nicknames\nand share them with your friends.", + "ApplicableVersion": "any", + "RepoUrl": "https://github.com/Glyceri/FFXIVPetRenamer", + "Tags": [ + "Pet", + "plugin", + "Rename", + "Nickname", + "Name", + "Minion" + ], + "DalamudApiLevel": 10, + "LoadRequiredState": 0, + "LoadSync": false, + "CanUnloadAsync": false, + "LoadPriority": 0, + "IconUrl": "https://github.com/Glyceri/FFXIVPetRenamer/raw/main/icon.png", + "Punchline": "Give your minions, Carbuncles and Faeries cute nicknames\nand share them with your friends.", + "AcceptsFeedback": true, + "DownloadLinkInstall": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip", + "DownloadLinkUpdate": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip", + "DownloadLinkTesting": "https://github.com/Glyceri/FFXIVPetRenamer/releases/download/2.0.0.0/PetNicknames.zip" + } +] diff --git a/PetNicknames/PetNicknames/Hooking/HookElements/NamePlateHook.cs b/PetNicknames/PetNicknames/Hooking/HookElements/NamePlateHook.cs index 6fba2fb9..43048924 100644 --- a/PetNicknames/PetNicknames/Hooking/HookElements/NamePlateHook.cs +++ b/PetNicknames/PetNicknames/Hooking/HookElements/NamePlateHook.cs @@ -14,10 +14,12 @@ public NamePlateHook(DalamudServices services, IPetServices petServices, IPettab public override void Init() { DalamudServices.NameplateGUI.OnNamePlateUpdate += OnPlateUpdate; + Refresh(); } protected override void OnDispose() { + Refresh(); DalamudServices.NameplateGUI.OnNamePlateUpdate -= OnPlateUpdate; } diff --git a/PetNicknames/PetNicknames/IPC/SharingDictionary.cs b/PetNicknames/PetNicknames/IPC/SharingDictionary.cs index b97189d6..247be233 100644 --- a/PetNicknames/PetNicknames/IPC/SharingDictionary.cs +++ b/PetNicknames/PetNicknames/IPC/SharingDictionary.cs @@ -10,19 +10,23 @@ internal class SharingDictionary : ISharingDictionary readonly DalamudServices DalamudServices; // Data Sharing - readonly Dictionary PetNicknameDict = new Dictionary(); + readonly Dictionary PetNicknameDict = new Dictionary(); public SharingDictionary(in DalamudServices dalamudServices) { DalamudServices = dalamudServices; - // Data sharing - PetNicknameDict = DalamudServices.PetNicknamesPlugin.GetOrCreateData($"PetRenamer.GameObjectRenameDict", () => new Dictionary()); + try + { + // Data sharing + PetNicknameDict = DalamudServices.PetNicknamesPlugin.GetOrCreateData($"PetRenamer.GameObjectRenameDict", () => new Dictionary()); + } + catch { } } public void Set(GameObjectId gameObjectID, string customName) { - PetNicknameDict.Add(gameObjectID.ObjectId, customName); + PetNicknameDict.Add(gameObjectID, customName); } public void Clear() diff --git a/PetNicknames/PetNicknames/PettableDatabase/Interfaces/IPettableDatabase.cs b/PetNicknames/PetNicknames/PettableDatabase/Interfaces/IPettableDatabase.cs index 1bdbcbc4..4e554004 100644 --- a/PetNicknames/PetNicknames/PettableDatabase/Interfaces/IPettableDatabase.cs +++ b/PetNicknames/PetNicknames/PettableDatabase/Interfaces/IPettableDatabase.cs @@ -12,7 +12,7 @@ internal interface IPettableDatabase /// /// Player Name /// The Data Base Entry - IPettableDatabaseEntry GetEntry(string name, ushort homeworld); + IPettableDatabaseEntry? GetEntry(string name, ushort homeworld, bool create); /// /// Get's the database entry if it exists. In the case it doesn't it creates a new one! /// diff --git a/PetNicknames/PetNicknames/PettableDatabase/LegacyPettableDatabase.cs b/PetNicknames/PetNicknames/PettableDatabase/LegacyPettableDatabase.cs index 1d1df6a1..a2b03376 100644 --- a/PetNicknames/PetNicknames/PettableDatabase/LegacyPettableDatabase.cs +++ b/PetNicknames/PetNicknames/PettableDatabase/LegacyPettableDatabase.cs @@ -28,7 +28,9 @@ public LegacyPettableDatabase(in IPetServices PetServices, in IPettableDirtyCall public void ApplyParseResult(IBaseParseResult parseResult, bool isFromIPC) { - IPettableDatabaseEntry entry = GetEntry(parseResult.UserName, parseResult.Homeworld); + IPettableDatabaseEntry? entry = GetEntry(parseResult.UserName, parseResult.Homeworld, true); + if (entry == null) return; + entry.UpdateEntryBase(parseResult, isFromIPC); SetDirty(); } diff --git a/PetNicknames/PetNicknames/PettableDatabase/PettableDatabase.cs b/PetNicknames/PetNicknames/PettableDatabase/PettableDatabase.cs index 90a50a4b..72069c79 100644 --- a/PetNicknames/PetNicknames/PettableDatabase/PettableDatabase.cs +++ b/PetNicknames/PetNicknames/PettableDatabase/PettableDatabase.cs @@ -54,7 +54,7 @@ public PettableDatabase(in IPetServices petServices, in IPettableDirtyCaller dir _entries = newEntries; } - public IPettableDatabaseEntry GetEntry(string name, ushort homeworld) + public IPettableDatabaseEntry? GetEntry(string name, ushort homeworld, bool create) { int entriesCount = _entries.Count; for (int i = 0; i < entriesCount; i++) @@ -64,6 +64,11 @@ public IPettableDatabaseEntry GetEntry(string name, ushort homeworld) return entry; } + if (!create) + { + return null; + } + IPettableDatabaseEntry newEntry = new PettableDataBaseEntry(in PetServices, in DirtyCaller, 0, name, homeworld, [], [], PluginConstants.BaseSkeletons, DateTime.Now.ToString("yyyyMMdd"), PetRenamerPlugin.PuginVersion.ToString(), false); _entries.Add(newEntry); return newEntry; diff --git a/PetNicknames/PetNicknames/PettableUsers/PettableUser.cs b/PetNicknames/PetNicknames/PettableUsers/PettableUser.cs index ca9c5720..74bcb682 100644 --- a/PetNicknames/PetNicknames/PettableUsers/PettableUser.cs +++ b/PetNicknames/PetNicknames/PettableUsers/PettableUser.cs @@ -2,6 +2,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Object; using FFXIVClientStructs.Interop; using PetRenamer.PetNicknames.IPC.Interfaces; +using PetRenamer.PetNicknames.PettableDatabase; using PetRenamer.PetNicknames.PettableDatabase.Interfaces; using PetRenamer.PetNicknames.PettableUsers.Interfaces; using PetRenamer.PetNicknames.Services.Interface; @@ -35,7 +36,7 @@ internal unsafe class PettableUser : IPettableUser readonly IPettableDirtyListener DirtyListener; readonly ISharingDictionary SharingDictionary; - public PettableUser(in ISharingDictionary sharingDictionary, in IPettableDatabase dataBase, in IPetServices petServices, in IPettableDirtyListener dirtyListener, Pointer battleChara) + public PettableUser(in ISharingDictionary sharingDictionary, in IPettableDatabase dataBase, in ILegacyDatabase legacyDatabase, in IPetServices petServices, in IPettableDirtyListener dirtyListener, Pointer battleChara) { DirtyListener = dirtyListener; SharingDictionary = sharingDictionary; @@ -53,6 +54,15 @@ public PettableUser(in ISharingDictionary sharingDictionary, in IPettableDatabas ObjectID = BattleChara->GetGameObjectId(); ShortObjectID = BattleChara->GetGameObjectId().ObjectId; + + IPettableDatabaseEntry? legacyEntry = legacyDatabase.GetEntry(Name, Homeworld, false); + if (legacyEntry != null) + { + legacyEntry.UpdateContentID(ContentID, true); + legacyDatabase.RemoveEntry(legacyEntry); + legacyEntry.MoveToDataBase(dataBase); + } + DataBaseEntry = dataBase.GetEntry(ContentID); DataBaseEntry.UpdateEntry(this); PetServices = petServices; diff --git a/PetNicknames/PetNicknames/Services/PetServices.cs b/PetNicknames/PetNicknames/Services/PetServices.cs index 3e55b61c..96372696 100644 --- a/PetNicknames/PetNicknames/Services/PetServices.cs +++ b/PetNicknames/PetNicknames/Services/PetServices.cs @@ -1,7 +1,10 @@ -using PetRenamer.Legacy.LegacyStepper; +using Dalamud.Utility; +using PetRenamer.Legacy.LegacyStepper; using PetRenamer.PetNicknames.Services.Interface; using PetRenamer.PetNicknames.Services.ServiceWrappers; using PetRenamer.PetNicknames.Services.ServiceWrappers.Interfaces; +using System; +using System.IO; namespace PetRenamer.PetNicknames.Services; @@ -13,9 +16,14 @@ internal class PetServices : IPetServices public IStringHelper StringHelper { get; init; } public IPetCastHelper PetCastHelper { get; init; } + readonly DalamudServices DalamudServices; + public PetServices(DalamudServices services) { + DalamudServices = services; + PetLog = new PetLogWrapper(services.PluginLog); + MoveOldConfig(); Configuration = services.PetNicknamesPlugin.GetPluginConfig() as Configuration ?? new Configuration(); StringHelper = new StringHelperWrapper(); PetSheets = new SheetsWrapper(ref services, StringHelper); @@ -29,4 +37,21 @@ void CheckConfigFailure() if (Configuration.currentSaveFileVersion == Configuration.Version) return; _ = new LegacyStepper(Configuration, this); } + + void MoveOldConfig() + { + DirectoryInfo directory = DalamudServices.PetNicknamesPlugin.ConfigDirectory; + if (directory == null) return; + + try + { + string? path = directory.Parent!.FullName; + if (path.IsNullOrWhitespace()) return; + + string oldPath = path + "\\PetRenamer.json"; + string newPath = path + "\\PetNicknames.json"; + + File.Move(oldPath, newPath); + } catch { } + } } diff --git a/PetNicknames/PetNicknames/Update/Updatables/LegacyDatabaseHelper.cs b/PetNicknames/PetNicknames/Update/Updatables/LegacyDatabaseHelper.cs deleted file mode 100644 index 7d70029d..00000000 --- a/PetNicknames/PetNicknames/Update/Updatables/LegacyDatabaseHelper.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Dalamud.Plugin.Services; -using PetRenamer.PetNicknames.PettableDatabase.Interfaces; -using PetRenamer.PetNicknames.Services.ServiceWrappers.Interfaces; -using PetRenamer.PetNicknames.Services; -using PetRenamer.PetNicknames.Update.Interfaces; -using FFXIVClientStructs.FFXIV.Client.Game.Character; -using PetRenamer.PetNicknames.Services.Interface; -using PetRenamer.PetNicknames.PettableUsers.Interfaces; - -namespace PetRenamer.PetNicknames.Update.Updatables; - -internal class LegacyDatabaseHelper : IUpdatable -{ - const double secondsPerCheck = 1; - - public bool Enabled { get; set; } = true; - - readonly DalamudServices DalamudServices; - readonly IPetServices PetServices; - readonly IPetLog PetLog; - readonly IPettableDatabase PettableDatabase; - readonly IPettableDatabase LegacyPettableDatabase; - readonly IPettableUserList UserList; - - int offset = 0; - - IPettableUser? lastUser; - - public LegacyDatabaseHelper(in DalamudServices dalamudServices, in IPettableDatabase legacyPettableDatabase, in IPettableDatabase pettableDatabase, in IPetServices petServices, in IPettableUserList userList) - { - DalamudServices = dalamudServices; - PetServices = petServices; - PetLog = PetServices.PetLog; - PettableDatabase = pettableDatabase; - LegacyPettableDatabase = legacyPettableDatabase; - UserList = userList; - - offset = LegacyPettableDatabase.DatabaseEntries.Length - 1; - } - - - double timer = secondsPerCheck; - - public void OnUpdate(IFramework framework) - { - double elapsedSeconds = framework.UpdateDelta.TotalSeconds; - timer += elapsedSeconds; - - if (timer >= secondsPerCheck) - { - timer = 0; - HandleLegacyDatabase(); - } - } - - void HandleLegacyDatabase() - { - IPettableDatabaseEntry[] entries = LegacyPettableDatabase.DatabaseEntries; - - int entriesLength = entries.Length; - if (entriesLength == 0) return; - - IPettableUser? localPlayer = UserList.LocalPlayer; - if (localPlayer == null) - { - lastUser = null; - return; - } - - if (lastUser == null) - { - lastUser = localPlayer; - HandleAsNull(in localPlayer, in entries, entriesLength); - return; - } - - int max = entriesLength - 1; - - if (offset > max) offset = max; - if (offset < 0) offset = max; - - IPettableDatabaseEntry entry = entries[offset]; - FindCharacter(entry); - offset--; - } - - void HandleAsNull(in IPettableUser localPlayer, in IPettableDatabaseEntry[] entries, int entriesLength) - { - for (int i = 0; i < entriesLength; i++) - { - IPettableDatabaseEntry currentEntry = entries[i]; - if (currentEntry.Homeworld != localPlayer.Homeworld) continue; - if (currentEntry.Name != localPlayer.Name) continue; - - FindCharacter(currentEntry); - break; - } - } - - unsafe void FindCharacter(IPettableDatabaseEntry entry) - { - BattleChara* character = CharacterManager.Instance()->LookupBattleCharaByName(entry.Name, true, (short)entry.Homeworld); - if (character != null) - { - entry.UpdateContentID(character->ContentId, true); - LegacyPettableDatabase.RemoveEntry(entry); - entry.MoveToDataBase(PettableDatabase); - } - } -} diff --git a/PetNicknames/PetNicknames/Update/Updatables/PettableUserHandler.cs b/PetNicknames/PetNicknames/Update/Updatables/PettableUserHandler.cs index af76c9fa..643c9314 100644 --- a/PetNicknames/PetNicknames/Update/Updatables/PettableUserHandler.cs +++ b/PetNicknames/PetNicknames/Update/Updatables/PettableUserHandler.cs @@ -25,9 +25,10 @@ internal unsafe class PettableUserHandler : IUpdatable readonly IPettableUserList PettableUserList; readonly IPetLog PetLog; readonly IPettableDatabase PettableDatabase; + readonly ILegacyDatabase LegacyDatabase; readonly IPettableDirtyListener DirtyListener; - public PettableUserHandler(in DalamudServices dalamudServices, in ISharingDictionary sharingDictionary, in IPettableUserList pettableUserList, in IPettableDatabase pettableDatabase, in IPetServices petServices, in IPettableDirtyListener dirtyListener) + public PettableUserHandler(in DalamudServices dalamudServices, in ISharingDictionary sharingDictionary, in IPettableUserList pettableUserList, in IPettableDatabase pettableDatabase, in ILegacyDatabase legacyDatabase, in IPetServices petServices, in IPettableDirtyListener dirtyListener) { DalamudServices = dalamudServices; SharingDictionary = sharingDictionary; @@ -35,6 +36,7 @@ public PettableUserHandler(in DalamudServices dalamudServices, in ISharingDictio PettableUserList = pettableUserList; PetLog = PetServices.PetLog; PettableDatabase = pettableDatabase; + LegacyDatabase = legacyDatabase; DirtyListener = dirtyListener; } @@ -74,7 +76,7 @@ public void OnUpdate(IFramework framework) if (pettableUser == null && battleChara != null && currentObjectKind == ObjectKind.Pc) { // Create a user - IPettableUser newUser = new PettableUser(in SharingDictionary, in PettableDatabase, in PetServices, in DirtyListener, battleChara); + IPettableUser newUser = new PettableUser(in SharingDictionary, in PettableDatabase, in LegacyDatabase, in PetServices, in DirtyListener, battleChara); PettableUserList.PettableUsers[i] = newUser; continue; } diff --git a/PetNicknames/PetNicknames/Update/UpdateHandler.cs b/PetNicknames/PetNicknames/Update/UpdateHandler.cs index 637df988..74500ca2 100644 --- a/PetNicknames/PetNicknames/Update/UpdateHandler.cs +++ b/PetNicknames/PetNicknames/Update/UpdateHandler.cs @@ -21,13 +21,13 @@ internal class UpdateHandler : IDisposable readonly IPetServices PetServices; readonly IPettableUserList PettableUserList; readonly IPettableDatabase PettableDatabase; - readonly IPettableDatabase LegacyPettableDatabase; + readonly ILegacyDatabase LegacyPettableDatabase; readonly IPettableDirtyListener DirtyListener; readonly IImageDatabase ImageDatabase; readonly LodestoneNetworker LodestoneNetworker; readonly List _updatables = new List(); - public UpdateHandler(in DalamudServices dalamudServices, in ISharingDictionary sharingDictionary, in IPettableUserList pettableUserList, in IPettableDatabase legacyDatabase, in IPettableDatabase pettableDatabase, in IPetServices petServices, in LodestoneNetworker lodestoneNetworker, in IImageDatabase imageDatabase, in IPettableDirtyListener dirtyListener) + public UpdateHandler(in DalamudServices dalamudServices, in ISharingDictionary sharingDictionary, in IPettableUserList pettableUserList, in ILegacyDatabase legacyDatabase, in IPettableDatabase pettableDatabase, in IPetServices petServices, in LodestoneNetworker lodestoneNetworker, in IImageDatabase imageDatabase, in IPettableDirtyListener dirtyListener) { DalamudServices = dalamudServices; SharingDictionary = sharingDictionary; @@ -45,8 +45,7 @@ public UpdateHandler(in DalamudServices dalamudServices, in ISharingDictionary s void Setup() { - _updatables.Add(new LegacyDatabaseHelper(in DalamudServices, in LegacyPettableDatabase, in PettableDatabase, in PetServices, in PettableUserList)); - _updatables.Add(new PettableUserHandler(in DalamudServices, in SharingDictionary, in PettableUserList, in PettableDatabase, in PetServices, in DirtyListener)); + _updatables.Add(new PettableUserHandler(in DalamudServices, in SharingDictionary, in PettableUserList, in PettableDatabase, in LegacyPettableDatabase, in PetServices, in DirtyListener)); _updatables.Add(new LodestoneQueueHelper(in LodestoneNetworker, in ImageDatabase)); } diff --git a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/GoldenCircleImageNode.cs b/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/GoldenCircleImageNode.cs deleted file mode 100644 index 69c2b2b3..00000000 --- a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/GoldenCircleImageNode.cs +++ /dev/null @@ -1,11 +0,0 @@ - -using PetRenamer.PetNicknames.Services; - -namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Images; - -internal class GoldenCircleImageNode : RotatableUVImage -{ - public GoldenCircleImageNode(in DalamudServices dalamudServices, in Configuration configuration) : base(dalamudServices, configuration, 195714, 0, 0.2f, 1, 0.82f) - { - } -} diff --git a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/RotatableUVImage.cs b/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/RotatableUVImage.cs deleted file mode 100644 index 0f0c0234..00000000 --- a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/RotatableUVImage.cs +++ /dev/null @@ -1,108 +0,0 @@ -using Dalamud.Interface.Textures.TextureWraps; -using Dalamud.Interface.Textures; -using ImGuiNET; -using PetRenamer.PetNicknames.Services; -using System; -using Una.Drawing; -using System.Numerics; - -namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Images; - -internal class RotatableUVImage : Node -{ - ISharedImmediateTexture Texture; - - float topLeftX = 0.128f; - float topLeftY = 0.58f; - - float botRightX = 0.328f; - float botRightY = 0.937f; - - float Rotation { get; set; } = 0; - - public float RoationSpeed { get; set; } = 0; - public float Opacity { get; set; } = 1; - - DateTime StartTime; - - public Color Color { get; set; } = new Color("FlareImageColour"); - - readonly Configuration Configuration; - - public RotatableUVImage(in DalamudServices dalamudServices, in Configuration configuration, uint icon, float topLeftX, float topLeftY, float botRightX, float botRightY) - { - Configuration = configuration; - - Texture = dalamudServices.TextureProvider.GetFromGameIcon(icon); - StartTime = DateTime.Now; - - this.topLeftX = topLeftX; - this.topLeftY = topLeftY; - this.botRightX = botRightX; - this.botRightY = botRightY; - } - - public RotatableUVImage(in DalamudServices dalamudServices, in Configuration configuration, uint icon, Vector2 topLeft, Vector2 botRight) : this (in dalamudServices, in configuration, icon, topLeft.X, topLeft.Y, botRight.X, botRight.Y) - { - - } - - protected override void OnDraw(ImDrawListPtr drawList) - { - if (!Configuration.uiFlare) return; - - DateTime now = DateTime.Now; - TimeSpan time = StartTime - now; - StartTime = now; - float elapsed = (float)time.TotalSeconds; - - Rotation += RoationSpeed * elapsed; - IDalamudTextureWrap wrap = Texture.GetWrapOrEmpty(); - - float invertedResolution; - Vector2 resolution; - - if (wrap.Width > wrap.Height) - { - invertedResolution = wrap.Width / (float)wrap.Height; - resolution = new Vector2(invertedResolution, 1); - } - else - { - invertedResolution = wrap.Height / (float)wrap.Width; - resolution = new Vector2(1, invertedResolution); - } - - - Rect contentRect = Bounds.ContentRect; - - Vector2 topLeft = new Vector2(topLeftX, topLeftY); - Vector2 topRight = new Vector2(botRightX, topLeftY); - Vector2 botRight = new Vector2(botRightX, botRightY); - Vector2 botLeft = new Vector2(topLeftX, botRightY); - Vector2 centre = (topLeft + (botRight - topLeft) * 0.5f) * resolution; - - Vector2 uv = topLeft * resolution; - Vector2 uv2 = topRight * resolution; - Vector2 uv3 = botRight * resolution; - Vector2 uv4 = botLeft * resolution; - - uv = RotateAroundPoint(uv, centre) / resolution; - uv2 = RotateAroundPoint(uv2, centre) / resolution; - uv3 = RotateAroundPoint(uv3, centre) / resolution; - uv4 = RotateAroundPoint(uv4, centre) / resolution; - - drawList.AddImageQuad(wrap.ImGuiHandle, contentRect.TopLeft, contentRect.TopRight, contentRect.BottomRight, contentRect.BottomLeft, uv, uv2, uv3, uv4, new Color((byte)Color.R, (byte)Color.G, (byte)Color.B, Opacity).ToUInt()); - } - - Vector2 RotateAroundPoint(Vector2 point, Vector2 centre) - { - float angleInrad = Rotation * (MathF.PI / 180.0f); - float cos = MathF.Cos(angleInrad); - float sin = MathF.Sin(angleInrad); - - return new Vector2((cos * (point.X - centre.X) - sin * (point.Y - centre.Y) + centre.X), - sin * (point.X - centre.X) + cos * (point.Y - centre.Y) + centre.Y); - } - -} diff --git a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/TechnoCircleImageNode.cs b/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/TechnoCircleImageNode.cs deleted file mode 100644 index fd20f3d3..00000000 --- a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/Images/TechnoCircleImageNode.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PetRenamer.PetNicknames.Services; - -namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Images; - -internal class TechnoCircleImageNode : RotatableUVImage -{ - const float topLeftX = 0.128f; - const float topLeftY = 0.58f; - - const float botRightX = 0.328f; - const float botRightY = 0.937f; - - public TechnoCircleImageNode(in DalamudServices dalamudServices, in Configuration configuration) : base(in dalamudServices, in configuration, 195007, topLeftX, topLeftY, botRightX, botRightY) - { - - } -} diff --git a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/WindowNodes/PetRenameNode.cs b/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/WindowNodes/PetRenameNode.cs index 1f01c890..4dc5355d 100644 --- a/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/WindowNodes/PetRenameNode.cs +++ b/PetNicknames/PetNicknames/Windowing/Componenents/PetNicknames/WindowNodes/PetRenameNode.cs @@ -21,8 +21,6 @@ internal class PetRenameNode : Node public Action? OnSave; - readonly TechnoCircleImageNode CircleImageNode; - readonly RenameTitleNode SpeciesNode; readonly RenameTitleNode RaceNode; readonly RenameTitleNode BehaviourNode; @@ -92,21 +90,7 @@ public PetRenameNode(string? customName, in IPetSheetData? activePet, in Dalamud IconId = ActivePet?.Icon ?? 66310, BorderColor = new BorderColor(new Color("Outline")), BorderWidth = new EdgeSize(4), - //BorderRadius = 8, }, - ChildNodes = - [ - CircleImageNode = new TechnoCircleImageNode(in services, in configuration) - { - Opacity = 0.3f, - RoationSpeed = 12, - Style = new Style() - { - Anchor = Anchor.MiddleCenter, - Size = new Size(130, 130), - } - } - ] }, ]; @@ -123,8 +107,6 @@ public void Setup(string? customName, in IPetSheetData? activePet) BehaviourNode.SetText(activePet?.BehaviourName ?? Translator.GetLine("...")); IDNode.SetText(ActivePet?.Model.ToString() ?? Translator.GetLine("...")); NicknameNode.SetPet(customName, activePet); - - CircleImageNode.Style.IsVisible = activePet != null; } protected override void OnDraw(ImDrawListPtr drawList) diff --git a/icon.png b/icon.png index f8bd8db5..1d63553a 100644 Binary files a/icon.png and b/icon.png differ