Skip to content

Commit

Permalink
Merge pull request #1414 from ergoxiv/feature/weapons-only-import
Browse files Browse the repository at this point in the history
Added a 'Weapons Only' pose import option
  • Loading branch information
StoiaCode authored Dec 20, 2024
2 parents 64d0af1 + 02cce60 commit 94cdd96
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Anamnesis/Actor/Pages/PosePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@
</MenuItem.ToolTip>
</MenuItem>

<!-- (Import) Weapons Only -->
<MenuItem Header="Pose_WeaponsOnly"
Style="{StaticResource AnaMenuItem}"
Click="OnImportWeaponsClicked">
<MenuItem.ToolTip>
<XivToolsWpf:TextBlock Key="Pose_WeaponsOnlyTooltip" />
</MenuItem.ToolTip>
</MenuItem>

<!-- (Import) Selected Bones -->
<MenuItem Header="Pose_Selected"
Style="{StaticResource AnaMenuItem}"
Expand Down
15 changes: 15 additions & 0 deletions Anamnesis/Actor/Pages/PosePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private enum PoseImportOptions
BodyOnly, // Imports only the body part of the pose.
ExpressionOnly, // Imports only the facial expression part of the pose.
SelectedBones, // Imports only the selected bones.
WeaponsOnly, // Imports only the weapons (main hand and off-hand).
}

public SettingsService SettingsService => SettingsService.Instance;
Expand Down Expand Up @@ -393,6 +394,11 @@ private async void OnImportSelectedBonesClicked(object sender, RoutedEventArgs e
await this.HandleSecondaryOptionImport(PoseImportOptions.SelectedBones);
}

private async void OnImportWeaponsClicked(object sender, RoutedEventArgs e)
{
await this.HandleSecondaryOptionImport(PoseImportOptions.WeaponsOnly);
}

private async Task ImportPose(PoseImportOptions importOption, PoseFile.Mode mode)
{
if (this.Actor == null || this.Skeleton == null)
Expand Down Expand Up @@ -461,6 +467,15 @@ private async Task ImportPose(PoseImportOptions importOption, PoseFile.Mode mode
return;
}

if (importOption == PoseImportOptions.WeaponsOnly)
{
this.Skeleton.SelectWeapons();
var selectedBoneNames = this.Skeleton.SelectedBones.Select(bone => bone.BoneName).ToHashSet();
poseFile.Apply(this.Actor, this.Skeleton, selectedBoneNames, mode, false);
this.Skeleton.ClearSelection();
return;
}

// Backup face bone positions before importing the body pose.
// "Freeze Position" toggle resets them, so restore after import. Relevant only when pose service is enabled.
this.Skeleton.SelectHead();
Expand Down
14 changes: 14 additions & 0 deletions Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,20 @@ public void SelectHead()
this.Select(headBones, SkeletonVisual3d.SelectMode.Add);
}

public void SelectWeapons()
{
this.ClearSelection();
var bonesToSelect = this.mainHandBones.Concat(this.offHandBones).ToList();

if (this.GetBone("n_buki_l") is BoneVisual3d boneLeft)
bonesToSelect.Add(boneLeft);

if (this.GetBone("n_buki_r") is BoneVisual3d boneRight)
bonesToSelect.Add(boneRight);

this.Select(bonesToSelect, SkeletonVisual3d.SelectMode.Add);
}

public void InvertSelection()
{
foreach ((string name, BoneVisual3d bone) in this.Bones)
Expand Down
2 changes: 2 additions & 0 deletions Anamnesis/Languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@
"Pose_SelectedTooltip": "Loads a pose onto the actor's selected bones",
"Pose_Expression": "Expression Only",
"Pose_ExpressionTooltip": "Loads a pose onto the actor's face",
"Pose_WeaponsOnly": "Weapons Only",
"Pose_WeaponsOnlyTooltip": "Loads a pose onto the actor's main hand and off-hand",
"Pose_ScalePack": "Body Scale",
"Pose_Body": "Body Only",
"Pose_BodyTooltip": "Loads a pose onto the entire actor, excluding the face",
Expand Down

0 comments on commit 94cdd96

Please sign in to comment.