Skip to content

Commit

Permalink
Revert legacy tattoo changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Jul 16, 2024
1 parent c75315f commit a5f35db
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
29 changes: 19 additions & 10 deletions Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Glamourer.GameData;
using Dalamud.Interface.Textures.TextureWraps;
using Glamourer.GameData;
using Glamourer.Unlocks;
using ImGuiNET;
using OtterGui;
Expand Down Expand Up @@ -197,16 +198,24 @@ private void DrawMultiIcons()
var face = _set.DataByValue(CustomizeIndex.Face, _customize.Face, out _, _customize.Face) < 0 ? _set.Faces[0].Value : _customize.Face;
foreach (var (featureIdx, idx) in options.WithIndex())
{
using var id = SetId(featureIdx);
var enabled = _customize.Get(featureIdx) != CustomizeValue.Zero;
var feature = _set.Data(featureIdx, 0, face);
var icon = featureIdx == CustomizeIndex.LegacyTattoo
? _legacyTattoo ?? _service.Manager.GetIcon(feature.IconId)
: _service.Manager.GetIcon(feature.IconId);
var hasIcon = icon.TryGetWrap(out var wrap, out _);
using var id = SetId(featureIdx);
var enabled = _customize.Get(featureIdx) != CustomizeValue.Zero;
var feature = _set.Data(featureIdx, 0, face);
bool hasIcon;
IDalamudTextureWrap? wrap;
var icon = _service.Manager.GetIcon(feature.IconId);
if (featureIdx is CustomizeIndex.LegacyTattoo)
{
wrap = _legacyTattoo;
hasIcon = wrap != null;
}
else
{
hasIcon = icon.TryGetWrap(out wrap, out _);
}

if (ImGui.ImageButton(wrap?.ImGuiHandle ?? icon.GetWrapOrEmpty().ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One,
(int)ImGui.GetStyle().FramePadding.X,
Vector4.Zero, enabled ? Vector4.One : _redTint))
(int)ImGui.GetStyle().FramePadding.X, Vector4.Zero, enabled ? Vector4.One : _redTint))
{
_customize.Set(featureIdx, enabled ? CustomizeValue.Zero : CustomizeValue.Max);
Changed |= _currentFlag;
Expand Down
29 changes: 21 additions & 8 deletions Glamourer/Gui/Customization/CustomizationDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Glamourer.GameData;
using Glamourer.Services;
using Glamourer.Unlocks;
using ImGuiNET;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;

namespace Glamourer.Gui.Customization;

public partial class CustomizationDrawer(
TextureCache textureCache,
ITextureProvider textures,
CustomizeService _service,
CodeService _codes,
Configuration _config,
FavoriteManager _favorites,
HeightService _heightService)
: IDisposable
{
private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f);
private readonly ISharedImmediateTexture? _legacyTattoo = GetLegacyTattooIcon(textureCache);
private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f);
private readonly IDalamudTextureWrap? _legacyTattoo = GetLegacyTattooIcon(textures);

private Exception? _terminate;

Expand All @@ -49,6 +49,9 @@ public CustomizeArray Customize
private float _raceSelectorWidth;
private bool _withApply;

public void Dispose()
=> _legacyTattoo?.Dispose();

public bool Draw(CustomizeArray current, bool locked, bool lockedRedraw)
{
_withApply = false;
Expand Down Expand Up @@ -189,6 +192,16 @@ private void UpdateSizes()
_raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X;
}

private static ISharedImmediateTexture? GetLegacyTattooIcon(TextureCache icons)
=> icons.TextureProvider.GetFromManifestResource(Assembly.GetExecutingAssembly(), "Glamourer.LegacyTattoo.raw");
private static IDalamudTextureWrap? GetLegacyTattooIcon(ITextureProvider textures)
{
using var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Glamourer.LegacyTattoo.raw");
if (resource == null)
return null;

var rawImage = new byte[resource.Length];
var length = resource.Read(rawImage, 0, (int)resource.Length);
return length == resource.Length
? textures.CreateFromRaw(RawImageSpecification.Rgba32(192, 192), rawImage, "Glamourer.LegacyTattoo")
: null;
}
}

0 comments on commit a5f35db

Please sign in to comment.