mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Penumbra attachment made semi-optional and restartable.
This commit is contained in:
parent
dbccddcc39
commit
cd1a39ffe4
4 changed files with 78 additions and 45 deletions
|
|
@ -10,9 +10,10 @@ namespace Glamourer
|
||||||
public const uint DefaultStateColor = 0xFF00C0C0;
|
public const uint DefaultStateColor = 0xFF00C0C0;
|
||||||
public const uint DefaultEquipmentColor = 0xFF00C000;
|
public const uint DefaultEquipmentColor = 0xFF00C000;
|
||||||
|
|
||||||
public bool FoldersFirst { get; set; } = false;
|
public bool FoldersFirst { get; set; } = false;
|
||||||
public bool ColorDesigns { get; set; } = true;
|
public bool ColorDesigns { get; set; } = true;
|
||||||
public bool ShowLocks { get; set; } = true;
|
public bool ShowLocks { get; set; } = true;
|
||||||
|
public bool AttachToPenumbra { get; set; } = true;
|
||||||
|
|
||||||
public uint CustomizationColor { get; set; } = DefaultCustomizationColor;
|
public uint CustomizationColor { get; set; } = DefaultCustomizationColor;
|
||||||
public uint StateColor { get; set; } = DefaultStateColor;
|
public uint StateColor { get; set; } = DefaultStateColor;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,27 @@ namespace Glamourer.Gui
|
||||||
ImGui.SetTooltip(tooltip);
|
ImGui.SetTooltip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawRestorePenumbraButton()
|
||||||
|
{
|
||||||
|
const string buttonLabel = "Re-Register Penumbra";
|
||||||
|
if (!Glamourer.Config.AttachToPenumbra)
|
||||||
|
{
|
||||||
|
using var raii = new ImGuiRaii().PushStyle(ImGuiStyleVar.Alpha, 0.5f);
|
||||||
|
ImGui.Button(buttonLabel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.Button(buttonLabel) && _plugin.GetPenumbra())
|
||||||
|
{
|
||||||
|
_plugin.UnregisterFunctions();
|
||||||
|
_plugin.RegisterFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
ImGui.SetTooltip(
|
||||||
|
"If Penumbra did not register the functions for some reason, pressing this button might help restore functionality.");
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawConfigTab()
|
private void DrawConfigTab()
|
||||||
{
|
{
|
||||||
using var raii = new ImGuiRaii();
|
using var raii = new ImGuiRaii();
|
||||||
|
|
@ -59,6 +80,24 @@ namespace Glamourer.Gui
|
||||||
v => cfg.ColorDesigns = v);
|
v => cfg.ColorDesigns = v);
|
||||||
DrawConfigCheckMark("Show Locks", "Write-protected Designs show a lock besides their name in the selector.", cfg.ShowLocks,
|
DrawConfigCheckMark("Show Locks", "Write-protected Designs show a lock besides their name in the selector.", cfg.ShowLocks,
|
||||||
v => cfg.ShowLocks = v);
|
v => cfg.ShowLocks = v);
|
||||||
|
DrawConfigCheckMark("Attach to Penumbra",
|
||||||
|
"Allows you to right-click items in the Changed Items tab of a mod in Penumbra to apply them to your player character.",
|
||||||
|
cfg.AttachToPenumbra,
|
||||||
|
v =>
|
||||||
|
{
|
||||||
|
cfg.AttachToPenumbra = v;
|
||||||
|
if (v)
|
||||||
|
{
|
||||||
|
if (_plugin.GetPenumbra())
|
||||||
|
_plugin.RegisterFunctions();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_plugin.UnregisterFunctions();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ImGui.SameLine();
|
||||||
|
DrawRestorePenumbraButton();
|
||||||
|
|
||||||
ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeightWithSpacing() / 2);
|
ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeightWithSpacing() / 2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Glamourer.Gui
|
||||||
if (InputInt($"##text_{id}", ref current, 1, count))
|
if (InputInt($"##text_{id}", ref current, 1, count))
|
||||||
{
|
{
|
||||||
customization[id] = set.Data(id, current - 1).Value;
|
customization[id] = set.Data(id, current - 1).Value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Glamourer.Gui
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
customization[id] = newCustom.Value;
|
customization[id] = newCustom.Value;
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ namespace Glamourer.Gui
|
||||||
if (ImGui.Selectable($"{set.Option(id)} #{i + 1}##combo", i == current) && i != current)
|
if (ImGui.Selectable($"{set.Option(id)} #{i + 1}##combo", i == current) && i != current)
|
||||||
{
|
{
|
||||||
customization[id] = (byte) i;
|
customization[id] = (byte) i;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ namespace Glamourer.Gui
|
||||||
if (InputInt($"##text_{id}", ref current, 1, count))
|
if (InputInt($"##text_{id}", ref current, 1, count))
|
||||||
{
|
{
|
||||||
customization[id] = set.Data(id, current).Value;
|
customization[id] = set.Data(id, current).Value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -198,7 +198,7 @@ namespace Glamourer.Gui
|
||||||
if (InputInt($"##{CustomizationId.FacialFeaturesTattoos}", ref value, 1, 256))
|
if (InputInt($"##{CustomizationId.FacialFeaturesTattoos}", ref value, 1, 256))
|
||||||
{
|
{
|
||||||
customization[CustomizationId.FacialFeaturesTattoos] = (byte) value;
|
customization[CustomizationId.FacialFeaturesTattoos] = (byte) value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Text(set.Option(CustomizationId.FacialFeaturesTattoos));
|
ImGui.Text(set.Option(CustomizationId.FacialFeaturesTattoos));
|
||||||
|
|
@ -273,13 +273,13 @@ namespace Glamourer.Gui
|
||||||
if (InputInt($"##text_{id}", ref current, 1, count))
|
if (InputInt($"##text_{id}", ref current, 1, count))
|
||||||
{
|
{
|
||||||
customization[id] = set.Data(id, current).Value;
|
customization[id] = set.Data(id, current).Value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DrawIconPickerPopup(popupName, set, id, out var newCustom))
|
if (DrawIconPickerPopup(popupName, set, id, out var newCustom))
|
||||||
{
|
{
|
||||||
customization[id] = newCustom.Value;
|
customization[id] = newCustom.Value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Text(label);
|
ImGui.Text(label);
|
||||||
|
|
@ -301,7 +301,7 @@ namespace Glamourer.Gui
|
||||||
if (ImGui.SliderInt($"##slider_{id}", ref value, 0, count - 1, "") && value != customization[id])
|
if (ImGui.SliderInt($"##slider_{id}", ref value, 0, count - 1, "") && value != customization[id])
|
||||||
{
|
{
|
||||||
customization[id] = (byte) value;
|
customization[id] = (byte) value;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -309,7 +309,7 @@ namespace Glamourer.Gui
|
||||||
if (InputInt($"##input_{id}", ref value, 0, count - 1))
|
if (InputInt($"##input_{id}", ref value, 0, count - 1))
|
||||||
{
|
{
|
||||||
customization[id] = (byte) (value + 1);
|
customization[id] = (byte) (value + 1);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -323,15 +323,15 @@ namespace Glamourer.Gui
|
||||||
private bool DrawRaceSelector(ref ActorCustomization customization)
|
private bool DrawRaceSelector(ref ActorCustomization customization)
|
||||||
{
|
{
|
||||||
using var group = ImGuiRaii.NewGroup();
|
using var group = ImGuiRaii.NewGroup();
|
||||||
var ret = false;
|
var ret = false;
|
||||||
ImGui.SetNextItemWidth(_raceSelectorWidth);
|
ImGui.SetNextItemWidth(_raceSelectorWidth);
|
||||||
if (ImGui.BeginCombo("##subRaceCombo", ClanName(customization.Clan, customization.Gender)))
|
if (ImGui.BeginCombo("##subRaceCombo", ClanName(customization.Clan, customization.Gender)))
|
||||||
{
|
{
|
||||||
for (var i = 0; i < (int)SubRace.Veena; ++i)
|
for (var i = 0; i < (int) SubRace.Veena; ++i)
|
||||||
{
|
{
|
||||||
if (ImGui.Selectable(ClanName((SubRace)i + 1, customization.Gender), (int)customization.Clan == i + 1))
|
if (ImGui.Selectable(ClanName((SubRace) i + 1, customization.Gender), (int) customization.Clan == i + 1))
|
||||||
{
|
{
|
||||||
var race = (SubRace)i + 1;
|
var race = (SubRace) i + 1;
|
||||||
ret |= ChangeRace(ref customization, race);
|
ret |= ChangeRace(ref customization, race);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -349,18 +349,18 @@ namespace Glamourer.Gui
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
ImGui.PushFont(UiBuilder.IconFont);
|
ImGui.PushFont(UiBuilder.IconFont);
|
||||||
var icon = customization.Gender == Gender.Male ? FontAwesomeIcon.Mars : FontAwesomeIcon.Venus;
|
var icon = customization.Gender == Gender.Male ? FontAwesomeIcon.Mars : FontAwesomeIcon.Venus;
|
||||||
var restricted = false;
|
var restricted = false;
|
||||||
if (customization.Race == Race.Viera)
|
if (customization.Race == Race.Viera)
|
||||||
{
|
{
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
|
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
|
||||||
icon = FontAwesomeIcon.VenusDouble;
|
icon = FontAwesomeIcon.VenusDouble;
|
||||||
restricted = true;
|
restricted = true;
|
||||||
}
|
}
|
||||||
else if (customization.Race == Race.Hrothgar)
|
else if (customization.Race == Race.Hrothgar)
|
||||||
{
|
{
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
|
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
|
||||||
icon = FontAwesomeIcon.MarsDouble;
|
icon = FontAwesomeIcon.MarsDouble;
|
||||||
restricted = true;
|
restricted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,17 +383,19 @@ namespace Glamourer.Gui
|
||||||
|
|
||||||
switch (set.Type(id))
|
switch (set.Type(id))
|
||||||
{
|
{
|
||||||
case CharaMakeParams.MenuType.ColorPicker: return DrawColorPicker(set.OptionName[(int)id], "", ref customization, id, set);
|
case CharaMakeParams.MenuType.ColorPicker: return DrawColorPicker(set.OptionName[(int) id], "", ref customization, id, set);
|
||||||
case CharaMakeParams.MenuType.ListSelector: return DrawListSelector(set.OptionName[(int)id], "", ref customization, id, set);
|
case CharaMakeParams.MenuType.ListSelector: return DrawListSelector(set.OptionName[(int) id], "", ref customization, id, set);
|
||||||
case CharaMakeParams.MenuType.IconSelector: return DrawIconSelector(set.OptionName[(int)id], "", ref customization, id, set);
|
case CharaMakeParams.MenuType.IconSelector: return DrawIconSelector(set.OptionName[(int) id], "", ref customization, id, set);
|
||||||
case CharaMakeParams.MenuType.MultiIconSelector: return DrawMultiSelector(ref customization, set);
|
case CharaMakeParams.MenuType.MultiIconSelector: return DrawMultiSelector(ref customization, set);
|
||||||
case CharaMakeParams.MenuType.Percentage: return DrawPercentageSelector(set.OptionName[(int)id], "", ref customization, id, set);
|
case CharaMakeParams.MenuType.Percentage:
|
||||||
|
return DrawPercentageSelector(set.OptionName[(int) id], "", ref customization, id, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly CustomizationId[] AllCustomizations = (CustomizationId[])Enum.GetValues(typeof(CustomizationId));
|
private static readonly CustomizationId[] AllCustomizations = (CustomizationId[]) Enum.GetValues(typeof(CustomizationId));
|
||||||
|
|
||||||
private bool DrawCustomization(ref ActorCustomization custom)
|
private bool DrawCustomization(ref ActorCustomization custom)
|
||||||
{
|
{
|
||||||
if (!ImGui.CollapsingHeader("Character Customization"))
|
if (!ImGui.CollapsingHeader("Character Customization"))
|
||||||
|
|
@ -441,7 +443,7 @@ namespace Glamourer.Gui
|
||||||
if (ImGui.Checkbox(set.Option(CustomizationId.HighlightsOnFlag), ref tmp) && tmp != custom.HighlightsOn)
|
if (ImGui.Checkbox(set.Option(CustomizationId.HighlightsOnFlag), ref tmp) && tmp != custom.HighlightsOn)
|
||||||
{
|
{
|
||||||
custom.HighlightsOn = tmp;
|
custom.HighlightsOn = tmp;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var xPos = _inputIntSize + _actualIconSize.X + 3 * ImGui.GetStyle().ItemSpacing.X;
|
var xPos = _inputIntSize + _actualIconSize.X + 3 * ImGui.GetStyle().ItemSpacing.X;
|
||||||
|
|
@ -451,7 +453,7 @@ namespace Glamourer.Gui
|
||||||
&& tmp != custom.FacePaintReversed)
|
&& tmp != custom.FacePaintReversed)
|
||||||
{
|
{
|
||||||
custom.FacePaintReversed = tmp;
|
custom.FacePaintReversed = tmp;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = custom.SmallIris;
|
tmp = custom.SmallIris;
|
||||||
|
|
@ -460,7 +462,7 @@ namespace Glamourer.Gui
|
||||||
&& tmp != custom.SmallIris)
|
&& tmp != custom.SmallIris)
|
||||||
{
|
{
|
||||||
custom.SmallIris = tmp;
|
custom.SmallIris = tmp;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom.Race != Race.Hrothgar)
|
if (custom.Race != Race.Hrothgar)
|
||||||
|
|
@ -470,7 +472,7 @@ namespace Glamourer.Gui
|
||||||
if (ImGui.Checkbox(set.Option(CustomizationId.LipColor), ref tmp) && tmp != custom.Lipstick)
|
if (ImGui.Checkbox(set.Option(CustomizationId.LipColor), ref tmp) && tmp != custom.Lipstick)
|
||||||
{
|
{
|
||||||
custom.Lipstick = tmp;
|
custom.Lipstick = tmp;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Glamourer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterFunctions()
|
public void RegisterFunctions()
|
||||||
{
|
{
|
||||||
if (Penumbra == null || !Penumbra.Valid)
|
if (Penumbra == null || !Penumbra.Valid)
|
||||||
return;
|
return;
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Glamourer
|
||||||
Penumbra!.ChangedItemClicked += PenumbraRightClick;
|
Penumbra!.ChangedItemClicked += PenumbraRightClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnregisterFunctions()
|
public void UnregisterFunctions()
|
||||||
{
|
{
|
||||||
if (Penumbra == null || !Penumbra.Valid)
|
if (Penumbra == null || !Penumbra.Valid)
|
||||||
return;
|
return;
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Glamourer
|
||||||
_plugins = pluginsList ?? throw new Exception("Could not obtain Dalamud.");
|
_plugins = pluginsList ?? throw new Exception("Could not obtain Dalamud.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool GetPenumbra()
|
public bool GetPenumbra()
|
||||||
{
|
{
|
||||||
if (Penumbra?.Valid ?? false)
|
if (Penumbra?.Valid ?? false)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -123,14 +123,9 @@ namespace Glamourer
|
||||||
var penumbra = (IPenumbraApiBase?) plugin?.GetType().GetProperty("Api", BindingFlags.Instance | BindingFlags.Public)
|
var penumbra = (IPenumbraApiBase?) plugin?.GetType().GetProperty("Api", BindingFlags.Instance | BindingFlags.Public)
|
||||||
?.GetValue(plugin);
|
?.GetValue(plugin);
|
||||||
if (penumbra != null && penumbra.Valid && penumbra.ApiVersion >= RequiredPenumbraShareVersion)
|
if (penumbra != null && penumbra.Valid && penumbra.ApiVersion >= RequiredPenumbraShareVersion)
|
||||||
{
|
|
||||||
Penumbra = (IPenumbraApi) penumbra!;
|
Penumbra = (IPenumbraApi) penumbra!;
|
||||||
RegisterFunctions();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Penumbra = null;
|
Penumbra = null;
|
||||||
}
|
|
||||||
|
|
||||||
return Penumbra != null;
|
return Penumbra != null;
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +139,8 @@ namespace Glamourer
|
||||||
SetDalamud(PluginInterface);
|
SetDalamud(PluginInterface);
|
||||||
SetPlugins(PluginInterface);
|
SetPlugins(PluginInterface);
|
||||||
Designs = new DesignManager(PluginInterface);
|
Designs = new DesignManager(PluginInterface);
|
||||||
GetPenumbra();
|
if (GetPenumbra() && Config.AttachToPenumbra)
|
||||||
|
RegisterFunctions();
|
||||||
PlayerWatcher = PlayerWatchFactory.Create(PluginInterface);
|
PlayerWatcher = PlayerWatchFactory.Create(PluginInterface);
|
||||||
|
|
||||||
PluginInterface.CommandManager.AddHandler("/glamourer", new CommandInfo(OnGlamourer)
|
PluginInterface.CommandManager.AddHandler("/glamourer", new CommandInfo(OnGlamourer)
|
||||||
|
|
@ -181,7 +177,6 @@ namespace Glamourer
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CopyToClipboard(Actor actor)
|
public void CopyToClipboard(Actor actor)
|
||||||
{
|
{
|
||||||
var save = new CharacterSave();
|
var save = new CharacterSave();
|
||||||
|
|
@ -193,7 +188,6 @@ namespace Glamourer
|
||||||
{
|
{
|
||||||
CharacterSave? save = null;
|
CharacterSave? save = null;
|
||||||
if (target.ToLowerInvariant() == "clipboard")
|
if (target.ToLowerInvariant() == "clipboard")
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
save = CharacterSave.FromString(Clipboard.GetText());
|
save = CharacterSave.FromString(Clipboard.GetText());
|
||||||
|
|
@ -202,15 +196,10 @@ namespace Glamourer
|
||||||
{
|
{
|
||||||
PluginInterface.Framework.Gui.Chat.PrintError("Clipboard does not contain a valid customization string.");
|
PluginInterface.Framework.Gui.Chat.PrintError("Clipboard does not contain a valid customization string.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (!Designs.FileSystem.Find(target, out var child) || child is not Design d)
|
else if (!Designs.FileSystem.Find(target, out var child) || child is not Design d)
|
||||||
{
|
|
||||||
PluginInterface.Framework.Gui.Chat.PrintError("The given path to a saved design does not exist or does not point to a design.");
|
PluginInterface.Framework.Gui.Chat.PrintError("The given path to a saved design does not exist or does not point to a design.");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
save = d.Data;
|
save = d.Data;
|
||||||
}
|
|
||||||
|
|
||||||
save?.Apply(actor);
|
save?.Apply(actor);
|
||||||
UpdateActors(actor);
|
UpdateActors(actor);
|
||||||
|
|
@ -280,8 +269,9 @@ namespace Glamourer
|
||||||
PluginInterface.Framework.Gui.Chat.Print("Applying requires a name for the save to be applied or 'clipboard'.");
|
PluginInterface.Framework.Gui.Chat.Print("Applying requires a name for the save to be applied or 'clipboard'.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyCommand(actor, split[2]);
|
ApplyCommand(actor, split[2]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "save":
|
case "save":
|
||||||
|
|
@ -291,6 +281,7 @@ namespace Glamourer
|
||||||
PluginInterface.Framework.Gui.Chat.Print("Saving requires a name for the save.");
|
PluginInterface.Framework.Gui.Chat.Print("Saving requires a name for the save.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveCommand(actor, split[2]);
|
SaveCommand(actor, split[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue