mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
tmp
This commit is contained in:
parent
a40b710d25
commit
89f2e78690
7 changed files with 43 additions and 24 deletions
|
|
@ -64,10 +64,10 @@ public class EquipmentDrawer
|
|||
_iconSize = new Vector2(2 * ImGui.GetFrameHeight() + ImGui.GetStyle().ItemSpacing.Y);
|
||||
_comboLength = DefaultWidth * ImGuiHelpers.GlobalScale;
|
||||
if (_requiredComboWidthUnscaled == 0)
|
||||
{
|
||||
_requiredComboWidthUnscaled = _items.ItemService.AwaitedService.AllItems(true).Concat(_items.ItemService.AwaitedService.AllItems(false))
|
||||
.Max(i => ImGui.CalcTextSize($"{i.Item2.Name} ({i.Item2.ModelString})").X) / ImGuiHelpers.GlobalScale;
|
||||
}
|
||||
_requiredComboWidthUnscaled = _items.ItemService.AwaitedService.AllItems(true)
|
||||
.Concat(_items.ItemService.AwaitedService.AllItems(false))
|
||||
.Max(i => ImGui.CalcTextSize($"{i.Item2.Name} ({i.Item2.ModelString})").X)
|
||||
/ ImGuiHelpers.GlobalScale;
|
||||
|
||||
_requiredComboWidth = _requiredComboWidthUnscaled * ImGuiHelpers.GlobalScale;
|
||||
}
|
||||
|
|
@ -107,14 +107,15 @@ public class EquipmentDrawer
|
|||
}
|
||||
|
||||
public DataChange DrawWeapons(in DesignData designData, out EquipItem rMainhand, out EquipItem rOffhand, out StainId rMainhandStain,
|
||||
out StainId rOffhandStain, EquipFlag? cApply, out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand,
|
||||
out bool rApplyOffhandStain, bool locked)
|
||||
out StainId rOffhandStain, EquipFlag? cApply, bool allWeapons, out bool rApplyMainhand, out bool rApplyMainhandStain,
|
||||
out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked)
|
||||
=> DrawWeapons(designData.Item(EquipSlot.MainHand), out rMainhand, designData.Item(EquipSlot.OffHand), out rOffhand,
|
||||
designData.Stain(EquipSlot.MainHand), out rMainhandStain, designData.Stain(EquipSlot.OffHand), out rOffhandStain, cApply,
|
||||
out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked);
|
||||
designData.Stain(EquipSlot.MainHand), out rMainhandStain, designData.Stain(EquipSlot.OffHand), out rOffhandStain, cApply,
|
||||
allWeapons, out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked);
|
||||
|
||||
public DataChange DrawWeapons(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand,
|
||||
StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply,
|
||||
bool allWeapons,
|
||||
out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked)
|
||||
{
|
||||
if (cMainhand.ModelId.Value == 0)
|
||||
|
|
@ -130,7 +131,6 @@ public class EquipmentDrawer
|
|||
return DataChange.None;
|
||||
}
|
||||
|
||||
var allWeapons = cApply.HasValue;
|
||||
if (_config.HideApplyCheckmarks)
|
||||
cApply = null;
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public class EquipmentDrawer
|
|||
|
||||
label = combo.Label;
|
||||
using var disabled = ImRaii.Disabled(locked);
|
||||
var change = combo.Draw(weapon.Name, weapon.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
||||
var change = combo.Draw(weapon.Name, weapon.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
||||
if (change)
|
||||
weapon = combo.CurrentSelection;
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ public class EquipmentDrawer
|
|||
label = combo.Label;
|
||||
armor = current;
|
||||
using var disabled = ImRaii.Disabled(locked);
|
||||
var change = combo.Draw(armor.Name, armor.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
||||
var change = combo.Draw(armor.Name, armor.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
||||
if (change)
|
||||
armor = combo.CurrentSelection;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using Glamourer.Automation;
|
||||
using Glamourer.Customization;
|
||||
using Glamourer.Designs;
|
||||
|
|
@ -157,9 +159,8 @@ public class ActorPanel
|
|||
}
|
||||
}
|
||||
|
||||
var weaponChanges = _equipmentDrawer.DrawWeapons(_state!.ModelData, out var newMainhand, out var newOffhand,
|
||||
out var newMainhandStain,
|
||||
out var newOffhandStain, null, out _, out _, out _, out _, _state.IsLocked);
|
||||
var weaponChanges = _equipmentDrawer.DrawWeapons(_state!.ModelData, out var newMainhand, out var newOffhand, out var newMainhandStain,
|
||||
out var newOffhandStain, null, GameMain.IsInGPose(), out _, out _, out _, out _, _state.IsLocked);
|
||||
|
||||
if (weaponChanges.HasFlag(DataChange.Item))
|
||||
if (weaponChanges.HasFlag(DataChange.Stain))
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class DesignPanel
|
|||
}
|
||||
|
||||
var weaponChanges = _equipmentDrawer.DrawWeapons(_selector.Selected!.DesignData, out var newMainhand, out var newOffhand,
|
||||
out var newMainhandStain, out var newOffhandStain, _selector.Selected.ApplyEquip, out var applyMain, out var applyMainStain,
|
||||
out var newMainhandStain, out var newOffhandStain, _selector.Selected.ApplyEquip, true, out var applyMain, out var applyMainStain,
|
||||
out var applyOff, out var applyOffStain, _selector.Selected!.WriteProtected());
|
||||
|
||||
if (weaponChanges.HasFlag(DataChange.Item))
|
||||
|
|
@ -264,7 +264,7 @@ public class DesignPanel
|
|||
|
||||
ImGui.NewLine();
|
||||
ApplyEquip("Dyes", AutoDesign.StainFlags, true,
|
||||
EquipSlotExtensions.EqdpSlots.Prepend(EquipSlot.MainHand).Prepend(EquipSlot.OffHand));
|
||||
EquipSlotExtensions.FullSlots);
|
||||
|
||||
ImGui.NewLine();
|
||||
const uint all = 0x0Fu;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Glamourer.Interop.Penumbra;
|
|||
using Glamourer.Interop.Structs;
|
||||
using Glamourer.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData.Actors;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
|
|
@ -69,9 +70,7 @@ public class StateApplier
|
|||
|
||||
var flags = Customize.Compare(mdl.GetCustomize(), customize);
|
||||
if (!flags.RequiresRedraw() || !mdl.IsHuman)
|
||||
{
|
||||
_changeCustomize.UpdateCustomize(mdl, customize.Data);
|
||||
}
|
||||
else
|
||||
_penumbra.RedrawObject(actor, RedrawType.Redraw);
|
||||
}
|
||||
|
|
@ -165,11 +164,15 @@ public class StateApplier
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="ChangeWeapon(ActorData,EquipSlot,EquipItem,StainId)"/>
|
||||
public ActorData ChangeWeapon(ActorState state, EquipSlot slot, bool apply)
|
||||
public ActorData ChangeWeapon(ActorState state, EquipSlot slot, bool apply, bool onlyGPose)
|
||||
{
|
||||
var data = GetData(state);
|
||||
if (apply)
|
||||
{
|
||||
if (onlyGPose)
|
||||
data.Objects.RemoveAll(a => a.Index is < (int)ScreenActor.GPosePlayer or >= (int)ScreenActor.CutsceneEnd);
|
||||
ChangeWeapon(data, slot, state.ModelData.Item(slot), state.ModelData.Stain(slot));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -185,11 +188,15 @@ public class StateApplier
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="ChangeMainhand(ActorData,EquipItem,StainId)"/>
|
||||
public ActorData ChangeMainhand(ActorState state, bool apply)
|
||||
public ActorData ChangeMainhand(ActorState state, bool apply, bool onlyGPose)
|
||||
{
|
||||
var data = GetData(state);
|
||||
if (apply)
|
||||
{
|
||||
if (onlyGPose)
|
||||
data.Objects.RemoveAll(a => a.Index is < (int)ScreenActor.GPosePlayer or >= (int)ScreenActor.CutsceneEnd);
|
||||
ChangeMainhand(data, state.ModelData.Item(EquipSlot.MainHand), state.ModelData.Stain(EquipSlot.MainHand));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -203,11 +210,16 @@ public class StateApplier
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="ChangeOffhand(ActorData,EquipItem,StainId)"/>
|
||||
public ActorData ChangeOffhand(ActorState state, bool apply)
|
||||
public ActorData ChangeOffhand(ActorState state, bool apply, bool onlyGPose)
|
||||
{
|
||||
var data = GetData(state);
|
||||
if (apply)
|
||||
{
|
||||
if (onlyGPose)
|
||||
data.Objects.RemoveAll(a => a.Index is < (int)ScreenActor.GPosePlayer or >= (int)ScreenActor.CutsceneEnd);
|
||||
ChangeOffhand(data, state.ModelData.Item(EquipSlot.OffHand), state.ModelData.Stain(EquipSlot.OffHand));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,11 @@ public class StateEditor
|
|||
if (!state.CanUnlock(key))
|
||||
return false;
|
||||
|
||||
// Can not change weapon type from expected type in state.
|
||||
if (slot is EquipSlot.MainHand && item.Type != state.BaseData.MainhandType
|
||||
|| slot is EquipSlot.OffHand && item.Type != state.BaseData.MainhandType.ValidOffhand())
|
||||
return false;
|
||||
|
||||
state.ModelData.SetItem(slot, item);
|
||||
state[slot, false] = source;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ public class StateListener : IDisposable
|
|||
return false;
|
||||
|
||||
var offhand = actor.GetOffhand();
|
||||
return offhand.Variant == 0 && armor.Set.Value == offhand.Set.Value;
|
||||
return offhand.Variant == 0 && offhand.Set.Value != 0 && armor.Set.Value == offhand.Set.Value;
|
||||
}
|
||||
|
||||
var actorArmor = actor.GetArmor(slot);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Penumbra.GameData.Actors;
|
|||
using Penumbra.GameData.Data;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
using Penumbra.String;
|
||||
|
||||
namespace Glamourer.State;
|
||||
|
||||
|
|
@ -257,7 +258,7 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
|
|||
var type = slot.ToIndex() < 10 ? StateChanged.Type.Equip : StateChanged.Type.Weapon;
|
||||
var actors = type is StateChanged.Type.Equip
|
||||
? _applier.ChangeArmor(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc)
|
||||
: _applier.ChangeWeapon(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc);
|
||||
: _applier.ChangeWeapon(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc, item.Type != old.Type);
|
||||
Glamourer.Log.Verbose(
|
||||
$"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}). [Affecting {actors.ToLazyString("nothing")}.]");
|
||||
_event.Invoke(type, source, state, actors, (old, item, slot));
|
||||
|
|
@ -272,7 +273,7 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
|
|||
var type = slot.ToIndex() < 10 ? StateChanged.Type.Equip : StateChanged.Type.Weapon;
|
||||
var actors = type is StateChanged.Type.Equip
|
||||
? _applier.ChangeArmor(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc)
|
||||
: _applier.ChangeWeapon(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc);
|
||||
: _applier.ChangeWeapon(state, slot, source is StateChanged.Source.Manual or StateChanged.Source.Ipc, item.Type != old.Type);
|
||||
Glamourer.Log.Verbose(
|
||||
$"Set {slot.ToName()} in state {state.Identifier.Incognito(null)} from {old.Name} ({old.ItemId}) to {item.Name} ({item.ItemId}) and its stain from {oldStain.Value} to {stain.Value}. [Affecting {actors.ToLazyString("nothing")}.]");
|
||||
_event.Invoke(type, source, state, actors, (old, item, slot));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue