feat: add highlighting for target in creature list
This commit is contained in:
@@ -24,6 +24,8 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
public float DeltaZ => creature.DeltaZ(hero);
|
public float DeltaZ => creature.DeltaZ(hero);
|
||||||
|
|
||||||
|
public bool IsTarget => Id == hero.TargetId;
|
||||||
|
|
||||||
public ICommand MouseLeftClickCommand { get; }
|
public ICommand MouseLeftClickCommand { get; }
|
||||||
public ICommand MouseLeftDoubleClickCommand { get; }
|
public ICommand MouseLeftDoubleClickCommand { get; }
|
||||||
public ICommand MouseRightClickCommand { get; }
|
public ICommand MouseRightClickCommand { get; }
|
||||||
@@ -47,6 +49,7 @@ namespace Client.Application.ViewModels
|
|||||||
creature.PropertyChanged += Creature_PropertyChanged;
|
creature.PropertyChanged += Creature_PropertyChanged;
|
||||||
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
||||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||||
|
hero.PropertyChanged += Hero_PropertyChanged;
|
||||||
MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick);
|
MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick);
|
||||||
MouseLeftDoubleClickCommand = new RelayCommand(OnMouseLeftDoubleClick);
|
MouseLeftDoubleClickCommand = new RelayCommand(OnMouseLeftDoubleClick);
|
||||||
MouseRightClickCommand = new RelayCommand(OnMouseRightClick);
|
MouseRightClickCommand = new RelayCommand(OnMouseRightClick);
|
||||||
@@ -80,6 +83,14 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Hero_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == "TargetId")
|
||||||
|
{
|
||||||
|
OnPropertyChanged("IsTarget");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly CreatureInterface creature;
|
private readonly CreatureInterface creature;
|
||||||
private readonly Hero hero;
|
private readonly Hero hero;
|
||||||
private readonly WorldHandler worldHandler;
|
private readonly WorldHandler worldHandler;
|
||||||
|
@@ -49,9 +49,10 @@
|
|||||||
<RowDefinition Height="2*"></RowDefinition>
|
<RowDefinition Height="2*"></RowDefinition>
|
||||||
<RowDefinition Height="1*"></RowDefinition>
|
<RowDefinition Height="1*"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListBox ItemsSource="{Binding Source={StaticResource SortedCreatures}, Mode=OneWay}" Grid.Row="0">
|
<ListBox ItemsSource="{Binding Source={StaticResource SortedCreatures}, Mode=OneWay}" HorizontalContentAlignment="Stretch">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
<Grid x:Name="Item">
|
||||||
<StackPanel Margin="5">
|
<StackPanel Margin="5">
|
||||||
<StackPanel.InputBindings>
|
<StackPanel.InputBindings>
|
||||||
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" />
|
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" />
|
||||||
@@ -69,10 +70,16 @@
|
|||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
<DataTemplate.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsTarget,Mode=OneWay}" Value="True">
|
||||||
|
<Setter TargetName="Item" Property="Background" Value="#110000ff" />
|
||||||
|
</DataTrigger>
|
||||||
|
</DataTemplate.Triggers>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<ListBox ItemsSource="{Binding Source={StaticResource SortedDrops}, Mode=OneWay}" Grid.Row="1">
|
<ListBox ItemsSource="{Binding Source={StaticResource SortedDrops}, Mode=OneWay}" Grid.Row="1" HorizontalContentAlignment="Stretch">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
|
Reference in New Issue
Block a user