Skip to content

Commit

Permalink
Resolved identified XAML binding errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ergoxiv committed Sep 3, 2024
1 parent 3138983 commit e8d799e
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 50 deletions.
29 changes: 29 additions & 0 deletions Anamnesis/Actor/Converters/ExtendedWeaponToSubModelConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// © Anamnesis.
// Licensed under the MIT license.

namespace Anamnesis.Actor.Converters;

using Anamnesis.Memory;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

[ValueConversion(typeof(ExtendedWeaponMemory), typeof(WeaponSubModelMemory))]
public class ExtendedWeaponToSubModelConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ExtendedWeaponMemory extendedWeaponMemory)
{
return extendedWeaponMemory.SubModel;
}

return DependencyProperty.UnsetValue;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
8 changes: 3 additions & 5 deletions Anamnesis/Actor/Pages/ActionPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</Grid>


<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Click="OnBlendAnimation" IsEnabled="{Binding AnimationService.BlendLocked, Converter={StaticResource NotConverter}}" Style="{StaticResource TransparentButton}">
<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Click="OnBlendAnimation" IsEnabled="{Binding Actor.Animation.BlendLocked, Converter={StaticResource NotConverter}}" Style="{StaticResource TransparentButton}">
<XivToolsWpf:TextBlock Key="Character_Action_AnimationBlend"/>
</Button>

Expand Down Expand Up @@ -409,8 +409,7 @@
Grid.Column="0"
Style="{StaticResource Label}" />

<ToggleButton Grid.Row="0" Grid.Column="1" Height="20" Style="{StaticResource TransparentIconToggleButton}" IsEnabled="{Binding GposeService.IsGpose}" IsChecked="{Binding PoseService.FreezeWorldPosition}" BorderThickness="1" Padding="0" Margin="0"
Visibility="{Binding IsValidWeapon, Converter={StaticResource B2V}}">
<ToggleButton Grid.Row="0" Grid.Column="1" Height="20" Style="{StaticResource TransparentIconToggleButton}" IsEnabled="{Binding GposeService.IsGpose}" IsChecked="{Binding PoseService.FreezeWorldPosition}" BorderThickness="1" Padding="0" Margin="0">

<ToggleButton.ToolTip>
<XivToolsWpf:TextBlock Key="Character_Action_GlobalFreezeWorldPositionsTooltip"/>
Expand All @@ -424,8 +423,7 @@
Grid.Column="0"
Style="{StaticResource Label}" />

<ToggleButton Grid.Row="1" Grid.Column="1" Height="20" Style="{StaticResource TransparentIconToggleButton}" IsEnabled="{Binding GposeService.IsGpose}" IsChecked="{Binding AnimationService.SpeedControlEnabled}" BorderThickness="1" Padding="0" Margin="0"
Visibility="{Binding IsValidWeapon, Converter={StaticResource B2V}}">
<ToggleButton Grid.Row="1" Grid.Column="1" Height="20" Style="{StaticResource TransparentIconToggleButton}" IsEnabled="{Binding GposeService.IsGpose}" IsChecked="{Binding AnimationService.SpeedControlEnabled}" BorderThickness="1" Padding="0" Margin="0">
<fa:IconBlock Icon="Stopwatch" FontSize="10"/>
</ToggleButton>

Expand Down
3 changes: 1 addition & 2 deletions Anamnesis/Actor/Pages/PosePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@

<CheckBox Margin="3,0,6,0"
IsEnabled="{Binding GposeService.IsGpose}"
IsChecked="{Binding PoseService.FreezeWorldPosition}"
Visibility="{Binding IsValidWeapon, Converter={StaticResource B2V}}">
IsChecked="{Binding PoseService.FreezeWorldPosition}">

<ToggleButton.ToolTip>
<XivToolsWpf:TextBlock Key="Character_Action_GlobalFreezeWorldPositionsTooltip"/>
Expand Down
25 changes: 5 additions & 20 deletions Anamnesis/Actor/Posing/Views/PoseMatrixView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,7 @@
ItemsSource="{Binding HairBones}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

Expand Down Expand Up @@ -943,10 +940,7 @@
ItemsSource="{Binding MetBones}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

Expand All @@ -968,10 +962,7 @@
<ItemsControl Grid.Column="1" ItemsSource="{Binding TopBones}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

Expand Down Expand Up @@ -1014,10 +1005,7 @@
ItemsSource="{Binding MainHandBones}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

Expand All @@ -1039,10 +1027,7 @@
<ItemsControl Grid.Column="1" ItemsSource="{Binding OffHandBones}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

Expand Down
7 changes: 6 additions & 1 deletion Anamnesis/Actor/Views/EquipmentEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Anamnesis.Actor.Views"
xmlns:converters="clr-namespace:Anamnesis.Actor.Converters"
mc:Ignorable="d"
d:DesignHeight="600">

<UserControl.Resources>
<converters:ExtendedWeaponToSubModelConverter x:Key="ExtendedWeaponToSubModelConverter"/>
</UserControl.Resources>

<Grid x:Name="ContentArea">
<Grid.ColumnDefinitions>
<ColumnDefinition />
Expand All @@ -22,7 +27,7 @@
<RowDefinition/>
</Grid.RowDefinitions>

<local:ItemView Grid.Row="0" Grid.Column="0" ItemModel="{Binding MainHand}" ExtendedViewModel="{Binding ModelObject.Weapons}" Slot="MainHand" IsEnabled="{Binding IsChocobo, Converter={StaticResource !B}}"/>
<local:ItemView Grid.Row="0" Grid.Column="0" ItemModel="{Binding MainHand}" ExtendedViewModel="{Binding ModelObject.Weapons, Converter={StaticResource ExtendedWeaponToSubModelConverter}}" Slot="MainHand" IsEnabled="{Binding IsChocobo, Converter={StaticResource !B}}"/>
<local:ItemView Grid.Row="0" Grid.Column="1" ItemModel="{Binding OffHand}" ExtendedViewModel="{Binding ModelObject.Weapons.SubModel}" Slot="OffHand" IsEnabled="{Binding IsChocobo, Converter={StaticResource !B}}"/>
<local:ItemView Grid.Row="1" Grid.Column="0" ItemModel="{Binding Equipment.Head}" Slot="Head"/>
<local:ItemView Grid.Row="2" Grid.Column="0" ItemModel="{Binding Equipment.Chest}" Slot="Body" />
Expand Down
12 changes: 10 additions & 2 deletions Anamnesis/Actor/Views/EquipmentSelector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
mc:Ignorable="d"
d:DesignHeight="450">

<UserControl.Resources>
<Style x:Key="SelectorItemStyle" TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource MaterialDesignListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
</Style>
</UserControl.Resources>

<Grid x:Name="ContentArea">

<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -178,11 +185,12 @@
<xivToolsWpfSelectors:Selector
Grid.Column="1"
Grid.Row="2"
Width="300">
Width="300"
ListBoxItemStyle="{StaticResource SelectorItemStyle}">

<xivToolsWpfSelectors:Selector.ItemTemplate>
<DataTemplate>
<Grid Height="32" Margin="0, -2">
<Grid Height="32">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
Expand Down
2 changes: 2 additions & 0 deletions Anamnesis/Actor/Views/FacialFeaturesControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<Setter Property="IsSelected" Value="{Binding Selected}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
Expand Down
6 changes: 3 additions & 3 deletions Anamnesis/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
Click="OnTargetActorClicked"
Header="Target" />

<MenuItem Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=SettingsService.Settings.UseExternalRefreshBrio, Converter={StaticResource B2V}}"
<MenuItem Visibility="{Binding DataContext.SettingsService.Settings.UseExternalRefreshBrio, Source={x:Reference PinnedActorList}, Converter={StaticResource B2V}}"
IsEnabled="{Binding IsGPoseActor}"
Click="OnDespawnActorClicked"
Header="Despawn" />
</ContextMenu>
</ContextMenu>
</ToggleButton.ContextMenu>

<Grid Margin="6,0">
Expand Down Expand Up @@ -147,7 +147,7 @@
<ScaleTransform x:Name="WindowScale" ScaleX="0.5" ScaleY="0.5" />
</Grid.LayoutTransform>

<Grid IsEnabled="{Binding GposeService.IsNotChangingState}" Margin="3,0,3,3">
<Grid IsEnabled="{Binding GposeService.Initialized}" Margin="3,0,3,3">

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
Expand Down
14 changes: 5 additions & 9 deletions Anamnesis/Services/GposeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@

namespace Anamnesis.Services;

using System;
using System.Threading.Tasks;
using Anamnesis.Core.Memory;
using Anamnesis.Memory;
using PropertyChanged;
using System;
using System.Threading.Tasks;

public delegate void GposeEvent(bool newState);

[AddINotifyPropertyChangedInterface]
public class GposeService : ServiceBase<GposeService>
{
private bool initialized = false;

public static event GposeEvent? GposeStateChanged;

public bool Initialized { get; private set; } = false;
public bool IsGpose { get; private set; }

[DependsOn(nameof(IsGpose))]
public bool IsOverworld => !this.IsGpose;

public static bool GetIsGPose()
{
if (AddressService.GposeCheck == IntPtr.Zero)
Expand Down Expand Up @@ -50,9 +46,9 @@ private async Task CheckThread()
{
bool newGpose = GetIsGPose();

if (!this.initialized)
if (!this.Initialized)
{
this.initialized = true;
this.Initialized = true;
this.IsGpose = newGpose;
continue;
}
Expand Down
10 changes: 5 additions & 5 deletions Anamnesis/Services/PinnedActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace Anamnesis;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using Anamnesis.Actor;
using Anamnesis.Files;
using Anamnesis.Memory;
Expand All @@ -15,6 +11,10 @@ namespace Anamnesis;
using FontAwesome.Sharp;
using PropertyChanged;
using Serilog;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using XivToolsWpf.Extensions;

[AddINotifyPropertyChangedInterface]
Expand Down Expand Up @@ -146,7 +146,7 @@ public void Tick()
return;
}

if (this.IsGPoseActor && GposeService.Instance.IsOverworld)
if (this.IsGPoseActor && !GposeService.Instance.IsGpose)
{
Log.Information($"Actor: {this} was a gpose actor and we are now in the overworld");
this.Retarget();
Expand Down
4 changes: 2 additions & 2 deletions Anamnesis/Views/Gallery.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<Grid>
<Rectangle Fill="White" Margin="-3"/>
<TextBlock Text="Oops! No Image!" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" Margin="0, 0, 0, 20"/>
<Image Source="{Binding Image1Path}" x:Name="Image1" Margin="0, 0, 0, 20"/>
<Image Source="{Binding Image1Path, TargetNullValue={x:Null}}" x:Name="Image1" Margin="0, 0, 0, 20"/>
<TextBlock Text="{Binding Image1Author}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="Black" Margin="2, 4, 2, 0"/>
</Grid>
</Border>
Expand All @@ -65,7 +65,7 @@
<Grid>
<Rectangle Fill="White" Margin="-3"/>
<TextBlock Text="Oops! No Image!" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" Margin="0, 0, 0, 20"/>
<Image Source="{Binding Image2Path}" x:Name="Image2" Margin="0, 0, 0, 20"/>
<Image Source="{Binding Image2Path, TargetNullValue={x:Null}}" x:Name="Image2" Margin="0, 0, 0, 20"/>
<TextBlock Text="{Binding Image2Author}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="Black" Margin="2, 4, 2, 0"/>
</Grid>
</Border>
Expand Down
2 changes: 1 addition & 1 deletion Lib/XivToolsWpf

0 comments on commit e8d799e

Please sign in to comment.