From 123d03926392d6976bbb11971a06fca522b3dfa5 Mon Sep 17 00:00:00 2001 From: k0t9i Date: Thu, 9 Feb 2023 23:07:57 +0400 Subject: [PATCH] feat: add highlighting for target in creature list --- .../ViewModels/CreatureListViewModel.cs | 11 +++++ Client/Application/Views/MainWindow.xaml | 45 +++++++++++-------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Client/Application/ViewModels/CreatureListViewModel.cs b/Client/Application/ViewModels/CreatureListViewModel.cs index 589d603..01d4715 100644 --- a/Client/Application/ViewModels/CreatureListViewModel.cs +++ b/Client/Application/ViewModels/CreatureListViewModel.cs @@ -24,6 +24,8 @@ namespace Client.Application.ViewModels public float DeltaZ => creature.DeltaZ(hero); + public bool IsTarget => Id == hero.TargetId; + public ICommand MouseLeftClickCommand { get; } public ICommand MouseLeftDoubleClickCommand { get; } public ICommand MouseRightClickCommand { get; } @@ -47,6 +49,7 @@ namespace Client.Application.ViewModels creature.PropertyChanged += Creature_PropertyChanged; creature.Transform.Position.PropertyChanged += Position_PropertyChanged; hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged; + hero.PropertyChanged += Hero_PropertyChanged; MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick); MouseLeftDoubleClickCommand = new RelayCommand(OnMouseLeftDoubleClick); 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 Hero hero; private readonly WorldHandler worldHandler; diff --git a/Client/Application/Views/MainWindow.xaml b/Client/Application/Views/MainWindow.xaml index d292bff..816d0c9 100644 --- a/Client/Application/Views/MainWindow.xaml +++ b/Client/Application/Views/MainWindow.xaml @@ -49,30 +49,37 @@ - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - +