From ea6778a3bd99a553c7b9b37c5840605a4fc6e35d Mon Sep 17 00:00:00 2001 From: k0t9i Date: Tue, 31 Jan 2023 01:12:02 +0400 Subject: [PATCH] feat: cleanup in summary info --- .../Converters/NullToVisibilityConverter.cs | 24 +++++++ .../ViewModels/HeroSummaryInfoViewModel.cs | 64 ++++++++++--------- Client/Application/Views/MainWindow.xaml | 63 +++++++++--------- Client/Domain/ValueObjects/InventoryInfo.cs | 22 ++++--- 4 files changed, 104 insertions(+), 69 deletions(-) create mode 100644 Client/Application/Converters/NullToVisibilityConverter.cs diff --git a/Client/Application/Converters/NullToVisibilityConverter.cs b/Client/Application/Converters/NullToVisibilityConverter.cs new file mode 100644 index 0000000..eb69ab8 --- /dev/null +++ b/Client/Application/Converters/NullToVisibilityConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Client.Application.Converters +{ + public class NullToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value == null ? Visibility.Hidden : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs b/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs index 5a4a875..47f0d9b 100644 --- a/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs +++ b/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs @@ -11,34 +11,31 @@ namespace Client.Application.ViewModels { public class HeroSummaryInfoViewModel : NotifyPropertyChanged { - public string Fullname - { + public bool IsVisible { get { - return hero.FullName.Nickname; + return true; } } - public string Race + public FullName Fullname { get { - //todo race string - return hero.Phenotype.Race.ToString(); + return hero.FullName; } } - public string Class + public Phenotype Phenotype { get { - //todo class string - return hero.Phenotype.Class.ToString(); + return hero.Phenotype; } } - public Vector3 Position + public Transform Transform { get { - return hero.Transform.Position; + return hero.Transform; } } public ExperienceInfo Experience @@ -55,6 +52,20 @@ namespace Client.Application.ViewModels return hero.VitalStats; } } + public InventoryInfo InventoryInfo + { + get + { + return hero.InventoryInfo; + } + } + public ulong Money + { + get + { + return 0; + } + } public HeroSummaryInfoViewModel(Hero hero) { this.hero = hero; @@ -62,8 +73,14 @@ namespace Client.Application.ViewModels hero.FullName.PropertyChanged += FullName_PropertyChanged; hero.Phenotype.PropertyChanged += Phenotype_PropertyChanged; hero.ExperienceInfo.PropertyChanged += ExperienceInfo_PropertyChanged; - hero.Transform.Position.PropertyChanged += Position_PropertyChanged; + hero.Transform.PropertyChanged += Transform_PropertyChanged; hero.VitalStats.PropertyChanged += VitalStats_PropertyChanged; + hero.InventoryInfo.PropertyChanged += InventoryInfo_PropertyChanged; + } + + private void InventoryInfo_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) + { + OnPropertyChanged("InventoryInfo"); } private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -71,37 +88,24 @@ namespace Client.Application.ViewModels OnPropertyChanged("VitalStats"); } - private void Position_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) + private void Transform_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { - OnPropertyChanged("Position"); + OnPropertyChanged("Transform"); } private void Phenotype_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName == "Class") - { - OnPropertyChanged("Class"); - } - if (e.PropertyName == "Race") - { - OnPropertyChanged("Race"); - } + OnPropertyChanged("Phenotype"); } private void ExperienceInfo_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName == "Exp" || e.PropertyName == "ExpToLevel" || e.PropertyName == "ExpToPrevLevel" || e.PropertyName == "Level") - { - OnPropertyChanged("Experience"); - } + OnPropertyChanged("Experience"); } private void FullName_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName == "Nickname") - { - OnPropertyChanged("Fullname"); - } + OnPropertyChanged("Fullname"); } private readonly Hero hero; diff --git a/Client/Application/Views/MainWindow.xaml b/Client/Application/Views/MainWindow.xaml index f688740..504db6f 100644 --- a/Client/Application/Views/MainWindow.xaml +++ b/Client/Application/Views/MainWindow.xaml @@ -8,18 +8,19 @@ xmlns:converters="clr-namespace:Client.Application.Converters" xmlns:components="clr-namespace:Client.Application.Components" mc:Ignorable="d" - Title="MainWindow" Height="600" Width="1024"> + Title="L2Bot 2.0 Client" Height="600" Width="1024"> - + - + + @@ -46,17 +47,17 @@ - + - + - - - + + + @@ -64,26 +65,26 @@ - + - + - - + + - - - + + + @@ -96,20 +97,20 @@ - - + + - - - + + + - + Position: @@ -122,34 +123,34 @@ - - - + + + - - + + - - + + - + - - + + diff --git a/Client/Domain/ValueObjects/InventoryInfo.cs b/Client/Domain/ValueObjects/InventoryInfo.cs index 0b8f2a4..a8a9d8c 100644 --- a/Client/Domain/ValueObjects/InventoryInfo.cs +++ b/Client/Domain/ValueObjects/InventoryInfo.cs @@ -1,16 +1,22 @@ -namespace Client.Domain.ValueObjects +using Client.Domain.Common; + +namespace Client.Domain.ValueObjects { - public class InventoryInfo + public class InventoryInfo : NotifyPropertyChanged { - public uint MaxWeight { get; set; } - public uint Weight { get; set; } - public uint Slots { get; set; } + private uint maxWeight; + private uint weight; + private uint slots; + + public uint MaxWeight { get => maxWeight; set { if (value != maxWeight) { maxWeight = value; OnPropertyChanged("MaxWeight"); } } } + public uint Weight { get => weight; set { if (value != weight) { weight = value; OnPropertyChanged("Weight"); } } } + public uint Slots { get => slots; set { if (value != slots) { slots = value; OnPropertyChanged("Slots"); } } } public InventoryInfo(uint maxWeight, uint weight, uint slots) { - MaxWeight = maxWeight; - Weight = weight; - Slots = slots; + this.maxWeight = maxWeight; + this.weight = weight; + this.slots = slots; } } }