Skip to content

Commit

Permalink
2.0.0.1 Pre New Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyceri committed Jul 26, 2024
1 parent 68b61f0 commit 54aca4b
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 409 deletions.
1 change: 0 additions & 1 deletion PetNicknames/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ internal class Configuration : IPluginConfiguration
public bool showOnTargetBars = true;
public bool showOnPartyList = true;
// --------------------------- UI SETTINGS ---------------------------
public bool quickButtonsToggle = false;
public bool showKofiButton = true;
public float petNicknamesUIScale = 1.5f;
public bool uiFlare = true;
Expand Down
2 changes: 1 addition & 1 deletion PetNicknames/PetNicknames.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>Glyceri</Authors>
<Company></Company>
<Version>2.0.0.0</Version>
<Version>2.0.0.1</Version>
<Description>A pet nickname plugin.</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Glyceri/FFXIVPetRenamer</PackageProjectUrl>
Expand Down
4 changes: 0 additions & 4 deletions PetNicknames/PetNicknames/Hooking/HookTypes/SimpleTextHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ public virtual void Setup(DalamudServices services, IPettableUserList userList,

void OnName(INamesDatabase nameDatabase)
{
if (lastPettableUser == null) return;
if (lastPettableUser.DataBaseEntry.ActiveDatabase != nameDatabase) return;
SetDirty();
}

void OnEntry(IPettableDatabaseEntry entry)
{
if (lastPettableUser == null) return;
if (lastPettableUser.DataBaseEntry != entry) return;
SetDirty();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PetRenamer.PetNicknames.PettableDatabase.Interfaces;
using PetRenamer.PetNicknames.Services;
using System;

namespace PetRenamer.PetNicknames.PettableDatabase;
Expand All @@ -11,13 +10,6 @@ internal class PettableDirtyHandler : IPettableDirtyListener, IPettableDirtyCall
Action<IPettableDatabaseEntry>? OnClear = _ => { };
Action<INamesDatabase>? OnName = _ => { };

readonly DalamudServices DalamudServices;

public PettableDirtyHandler(DalamudServices dalamudServices)
{
DalamudServices = dalamudServices;
}

public void ClearEntry(in IPettableDatabaseEntry entry)
{
OnClear?.Invoke(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ namespace PetRenamer.PetNicknames.PettableDatabase;

internal class PettableNameDatabase : INamesDatabase
{
public int[] IDs { get; private set; } = new int[0];
public string[] Names { get; private set; } = new string[0];
public int[] IDs { get; private set; } = [];
public string[] Names { get; private set; } = [];
public int Length { get => IDs.Length; }

IPettableDirtyCaller? DirtyCaller = null;
readonly IPettableDirtyCaller? DirtyCaller = null;

public PettableNameDatabase(int[] ids, string[] names, in IPettableDirtyCaller dirtyCaller)
{
Expand Down
5 changes: 1 addition & 4 deletions PetNicknames/PetNicknames/Serialization/SaveHandler.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
using PetRenamer.PetNicknames.IPC.Interfaces;
using PetRenamer.PetNicknames.PettableDatabase.Interfaces;
using PetRenamer.PetNicknames.PettableUsers.Interfaces;
using PetRenamer.PetNicknames.Services;
using System;

namespace PetRenamer.PetNicknames.Serialization;

internal class SaveHandler : IDisposable
{
readonly DalamudServices DalamudServices;
readonly Configuration Configuration;
readonly IPettableUserList UserList;
readonly IIpcProvider IpcProvider;
readonly IPettableDirtyListener DirtyListener;

public SaveHandler(in DalamudServices dalamudServices, in Configuration configuration, in IPettableUserList userList, in IIpcProvider ipcProvider, in IPettableDirtyListener dirtyListener)
public SaveHandler(in Configuration configuration, in IPettableUserList userList, in IIpcProvider ipcProvider, in IPettableDirtyListener dirtyListener)
{
DalamudServices = dalamudServices;
Configuration = configuration;
UserList = userList;
IpcProvider = ipcProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,10 @@ readonly string GermanReplace(string baseString, sbyte pronoun)
try
{
baseString = baseString.Replace("[p]", "", System.StringComparison.InvariantCultureIgnoreCase);
baseString = baseString.Replace("[a]", checked(pronounList[pronoun]), System.StringComparison.InvariantCultureIgnoreCase);
return baseString;
}
catch
{
return baseString;
}
baseString = baseString.Replace("[a]", checked(pronounList[pronoun]), System.StringComparison.InvariantCultureIgnoreCase);
} catch { }

return baseString;
}

readonly string[] pronounList = ["er", "e", "es", "en"];
Expand Down
303 changes: 4 additions & 299 deletions PetNicknames/PetNicknames/TranslatorSystem/Translator.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PetNicknames/PetNicknames/Windowing/Base/PetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected PetWindow(in WindowHandler windowHandler, in DalamudServices dalamudSe
ClassList = ["window--titlebar-text"],
NodeValue = Title,
},
HeaderBar = new HeaderBarButtonNode(in DalamudServices, this, in configuration, in windowHandler, HasExtraButtons),
HeaderBar = new HeaderBarButtonNode(in DalamudServices, this, in windowHandler, HasExtraButtons),
ContentNode = new Node()
{
ClassList = ["window--content"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal static class WindowStyles
new("BackgroundImageColour", new Color(40, 40, 0, 230).ToUInt()),
new("ListElementBackground", new Color(26, 20, 0, 130).ToUInt()),
new("SearchBarBackground", new Color(150, 150, 150, 150).ToUInt()),
new("ModeToggleInactive", new Color(15, 15, 15).ToUInt()),
new("ModeToggleInactive", new Color(100, 0, 0, 0.01f).ToUInt()),
new("Window.TextOutline", new Color(189, 141, 6, 190).ToUInt()),
new("Window.TextOutlineButton", new Color(194, 82, 17, 190).ToUInt()),
new("PetNicknamesButton", new Color(91, 120, 83, 150).ToUInt()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Dalamud.Interface;
using PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar.Helper;
using PetRenamer.PetNicknames.Windowing.Interfaces;
using PetRenamer.PetNicknames.Windowing.Windows.PetShareWindow;

namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Buttons;

internal class KofiButton : WindowOpenerButton<KofiWindow>
{
public KofiButton(in Configuration configuration, in WindowHandler windowHandler) : base(configuration, windowHandler)
public KofiButton(in WindowHandler windowHandler, in IPetWindow petWindow) : base(windowHandler, petWindow)
{
NodeValue = FontAwesomeIcon.Coffee.ToIconString();
Tooltip = "Ko-fi";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using PetRenamer.PetNicknames.Services;
using PetRenamer.PetNicknames.Windowing.Base;
using PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Buttons;
using PetRenamer.PetNicknames.Windowing.Interfaces;
using Una.Drawing;

namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar;

internal class HeaderBarButtonNode : Node
{
public readonly CloseButton CloseButton;
public readonly PetListButton PetListSquare;
public readonly PetRenameButton PetRenameSquare;
public readonly PetShareButton PetShareSquare;
public readonly PetConfigButton PetConfigSquare;

readonly Configuration Configuration;
readonly WindowHandler WindowHandler;
readonly IPetWindow PetWindow;

readonly bool HasExtraButtons;

public HeaderBarButtonNode(in DalamudServices DalamudServices, in PetWindow petWindow, in Configuration configuration, in WindowHandler windowHandler, bool hasExtraButtons)
public HeaderBarButtonNode(in DalamudServices DalamudServices, in PetWindow petWindow, in WindowHandler windowHandler, bool hasExtraButtons)
{
Configuration = configuration;
PetWindow = petWindow;
WindowHandler = windowHandler;

HasExtraButtons = hasExtraButtons;
Expand All @@ -34,16 +34,14 @@ public HeaderBarButtonNode(in DalamudServices DalamudServices, in PetWindow petW

ChildNodes = [
CloseButton = new CloseButton(in DalamudServices, petWindow),
PetRenameSquare = new PetRenameButton(in configuration, in windowHandler),
PetListSquare = new PetListButton(in configuration, in windowHandler),
PetShareSquare = new PetShareButton(in configuration, in windowHandler),
PetConfigSquare = new PetConfigButton(in configuration, in windowHandler),
PetRenameSquare = new PetRenameButton(in windowHandler, petWindow),
PetShareSquare = new PetShareButton(in windowHandler, petWindow),
PetConfigSquare = new PetConfigButton(in windowHandler, petWindow),
];

if (hasExtraButtons) return;

RemoveChild(PetRenameSquare, true);
RemoveChild(PetListSquare, true);
RemoveChild(PetConfigSquare, true);
RemoveChild(PetShareSquare, true);
}
Expand All @@ -58,7 +56,7 @@ public void SetKofiButton(bool value)

kofiMode = value;

if (kofiMode && HasExtraButtons) ChildNodes.Add(kofiButton = new KofiButton(in Configuration, in WindowHandler));
if (kofiMode && HasExtraButtons) ChildNodes.Add(kofiButton = new KofiButton(in WindowHandler, PetWindow));
else
{
if (kofiButton != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using PetRenamer.PetNicknames.Windowing.Base;
using PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.Buttons;
using PetRenamer.PetNicknames.Windowing.Interfaces;
using Una.Drawing;

namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar.Helper;

internal class WindowOpenerButton<T> : QuickSquareButton where T : PetWindow
{
readonly Configuration Configuration;
readonly WindowHandler WindowHandler;

public WindowOpenerButton(in Configuration configuration, in WindowHandler windowHandler)
public WindowOpenerButton(in WindowHandler windowHandler, in IPetWindow petWindow)
{
Configuration = configuration;
WindowHandler = windowHandler;

Style = new Style()
Expand All @@ -22,16 +21,8 @@ public WindowOpenerButton(in Configuration configuration, in WindowHandler windo
Margin = new EdgeSize(6, 0),
};

OnClick = () =>
{
if (Configuration.quickButtonsToggle)
{
WindowHandler.Toggle<T>();
}
else
{
WindowHandler.Open<T>();
}
};
if (typeof(T) == petWindow.GetType()) Style.IsVisible = false;

OnClick = WindowHandler.Open<T>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,44 @@ public void SetActivePetMode(PetWindowMode mode)
{
Anchor = Anchor.MiddleLeft,
Size = new Size(32, 15),
BackgroundColor = new("ModeToggleInactive"),
BackgroundColor = new(0, 0, 0, 120),
}),
new(".ModeToggleUnavailableBattlePet",
new()
{
Anchor = Anchor.MiddleLeft,
Size = new Size(32, 15),
BackgroundColor = new("ModeToggleInactive"),
BackgroundColor = new(0, 0, 0, 120),
}),
new(".BattlePetModeActive",
new()
{
Anchor = Anchor.MiddleLeft,
Size = new Size(32, 15),
StrokeColor = new("Outline"),
StrokeWidth = 1,
BackgroundColor = new("Titlebar.BattlePet"),
}),
new(".BattlePetModeActive:hover",
new()
{
BackgroundColor = new("Titlebar.BattlePet:Dark"),
StrokeWidth = 2,
}),
new(".MinionModeActive",
new()
{
Anchor = Anchor.MiddleLeft,
Flow = Flow.Vertical,
Size = new Size(32, 15),
StrokeColor = new("Outline"),
StrokeWidth = 1,
BackgroundColor = new("Titlebar.Minion"),
}),
new(".MinionModeActive:hover",
new()
{
StrokeWidth = 2,
BackgroundColor = new("Titlebar.Minion:Dark"),
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
using PetRenamer.PetNicknames.Windowing;
using PetRenamer;
using PetRenamer.PetNicknames.TranslatorSystem;
using PetRenamer.PetNicknames.Windowing.Interfaces;

internal class PetConfigButton : WindowOpenerButton<PetConfigWindow>
{
public PetConfigButton(in Configuration configuration, in WindowHandler windowHandler) : base(configuration, windowHandler)
public PetConfigButton(in WindowHandler windowHandler, in IPetWindow petWindow) : base(windowHandler, petWindow)
{
Tooltip = Translator.GetLine("Config.Title");
NodeValue = FontAwesomeIcon.Cogs.ToIconString();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Dalamud.Interface;
using PetRenamer.PetNicknames.TranslatorSystem;
using PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar.Helper;
using PetRenamer.PetNicknames.Windowing.Interfaces;
using PetRenamer.PetNicknames.Windowing.Windows.TempWindow;

namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar;

internal class PetRenameButton : WindowOpenerButton<PetRenameWindow>
{
public PetRenameButton(in Configuration configuration, in WindowHandler windowHandler) : base(configuration, windowHandler)
public PetRenameButton(in WindowHandler windowHandler, in IPetWindow petWindow) : base(windowHandler, petWindow)
{
NodeValue = FontAwesomeIcon.PenSquare.ToIconString();
Tooltip = Translator.GetLine("ContextMenu.Rename");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Dalamud.Interface;
using PetRenamer.PetNicknames.TranslatorSystem;
using PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar.Helper;
using PetRenamer.PetNicknames.Windowing.Interfaces;
using PetRenamer.PetNicknames.Windowing.Windows.PetListWindow;

namespace PetRenamer.PetNicknames.Windowing.Componenents.PetNicknames.HeaderBar;

internal class PetShareButton : WindowOpenerButton<PetListWindow>
{
public PetShareButton(in Configuration configuration, in WindowHandler windowHandler) : base(configuration, windowHandler)
public PetShareButton(in WindowHandler windowHandler, in IPetWindow petWindow) : base(windowHandler, in petWindow)
{
Tooltip = Translator.GetLine("PetList.Sharing");
NodeValue = FontAwesomeIcon.FileExport.ToIconString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public RenameTitleNode(in DalamudServices dalamudServices, string label, string
];
}

public void SetLabel(string text)
{
LabelNode.NodeValue = text;
}

public void SetText(string text)
{
TextNode.NodeValue = text;
Expand Down
Loading

0 comments on commit 54aca4b

Please sign in to comment.