From e8fe98b227f6668d5f43ab0292b0074a1c858a05 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Sat, 11 May 2019 12:00:46 +0200 Subject: [PATCH] Refonte Background suite --- .../PlayerCharacter/BackgroundViewModel.cs | 68 +++++++-------- .../PlayerCharacterEditorViewModel.cs | 84 ++++++++++--------- .../Views/PlayerCharacter/BackgroundView.xaml | 37 +++++--- 3 files changed, 96 insertions(+), 93 deletions(-) diff --git a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/BackgroundViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/BackgroundViewModel.cs index fd4de02c..9ea68922 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/BackgroundViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/BackgroundViewModel.cs @@ -8,10 +8,33 @@ namespace AideDeJeu.ViewModels.PlayerCharacter public class BackgroundViewModel : BaseViewModel { private BackgroundItem _Background = null; - public BackgroundItem Background { get { return _Background; } set { SubBackground = null; SetProperty(ref _Background, value); OnPropertyChanged(nameof(BackgroundOrSubBackground)); } } + public BackgroundItem Background + { + get + { + return _Background; + } + set + { + SubBackground = null; + SetProperty(ref _Background, value); + OnPropertyChanged(nameof(BackgroundOrSubBackground)); + } + } private SubBackgroundItem _SubBackground = null; - public SubBackgroundItem SubBackground { get { return _SubBackground; } set { SetProperty(ref _SubBackground, value); OnPropertyChanged(nameof(BackgroundOrSubBackground)); } } + public SubBackgroundItem SubBackground + { + get + { + return _SubBackground; + } + set + { + SetProperty(ref _SubBackground, value); + OnPropertyChanged(nameof(BackgroundOrSubBackground)); + } + } public BackgroundItem BackgroundOrSubBackground { @@ -78,43 +101,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter set { SetProperty(ref _BackgroundSpecialty, value); - OnPropertyChanged(nameof(SelectedBackgroundSpecialty)); } } - private string _SubBackgroundSpecialty = null; - public string SubBackgroundSpecialty - { - get - { - return _SubBackgroundSpecialty; - } - set - { - SetProperty(ref _SubBackgroundSpecialty, value); - OnPropertyChanged(nameof(SelectedBackgroundSpecialty)); - } - } - public string SelectedBackgroundSpecialty - { - get - { - return _SubBackgroundSpecialty ?? _BackgroundSpecialty; - } - } - - private string _PickedBackgroundSpecialty = null; - public string PickedBackgroundSpecialty - { - get - { - return _PickedBackgroundSpecialty; - } - set - { - SetProperty(ref _PickedBackgroundSpecialty, value); - } - } - private SkillItem _BackgroundSkill = null; public SkillItem BackgroundSkill { @@ -125,7 +113,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter set { SetProperty(ref _BackgroundSkill, value); - OnPropertyChanged(nameof(SelectedBackgroundSkill)); + OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); } } private SkillItem _SubBackgroundSkill = null; @@ -138,10 +126,10 @@ namespace AideDeJeu.ViewModels.PlayerCharacter set { SetProperty(ref _SubBackgroundSkill, value); - OnPropertyChanged(nameof(SelectedBackgroundSkill)); + OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); } } - public SkillItem SelectedBackgroundSkill + public SkillItem BackgroundOrSubBackgroundSkill { get { diff --git a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/PlayerCharacterEditorViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/PlayerCharacterEditorViewModel.cs index 0757a849..89cbeffd 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/PlayerCharacterEditorViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacter/PlayerCharacterEditorViewModel.cs @@ -60,8 +60,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter BackgroundSpecialties = null; SubBackgroundSpecialties = null; //BackgroundSpecialty = null; - BackgroundSkill = null; - SubBackgroundSkill = null; + SelectedPlayerCharacter.Background.BackgroundSkill = null; + SelectedPlayerCharacter.Background.SubBackgroundSkill = null; } private async void Background_PropertyChanged(object sender, PropertyChangedEventArgs e) @@ -72,6 +72,10 @@ namespace AideDeJeu.ViewModels.PlayerCharacter await LoadBackgroundAsync(SelectedPlayerCharacter.Background.Background); //SubBackgrounds = await LoadSubBackgroundsAsync(SelectedPlayerCharacter.Background.Background); break; + case nameof(SelectedPlayerCharacter.Background.SubBackground): + await LoadSubBackgroundAsync(SelectedPlayerCharacter.Background.SubBackground); + //SubBackgrounds = await LoadSubBackgroundsAsync(SelectedPlayerCharacter.Background.Background); + break; } } @@ -353,7 +357,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter BackgroundSpecialties = await LoadBackgroundsSpecialtiesAsync(background); //BackgroundSpecialty = null; //SubBackgroundSpecialties = null; - BackgroundSkill = await LoadSkillAsync(background); + SelectedPlayerCharacter.Background.BackgroundSkill = await LoadSkillAsync(background); //SubBackgroundSkill = null; ResetAlignments(); } @@ -429,13 +433,13 @@ namespace AideDeJeu.ViewModels.PlayerCharacter if (subbackground == null) { SubBackgroundSpecialties = null; - SubBackgroundSkill = null; + SelectedPlayerCharacter.Background.SubBackgroundSkill = null; //SubBackgroundSpecialty = null; } else { SubBackgroundSpecialties = await LoadBackgroundsSpecialtiesAsync(subbackground); - SubBackgroundSkill = await LoadSkillAsync(subbackground); + SelectedPlayerCharacter.Background.SubBackgroundSkill = await LoadSkillAsync(subbackground); } return subbackground; } @@ -622,41 +626,41 @@ namespace AideDeJeu.ViewModels.PlayerCharacter // } //} - private SkillItem _BackgroundSkill = null; - public SkillItem BackgroundSkill - { - get - { - return _BackgroundSkill; - } - set - { - SetProperty(ref _BackgroundSkill, value); - OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); - //OnPropertyChanged(nameof(HasBackgroundSkill)); - } - } - private SkillItem _SubBackgroundSkill = null; - public SkillItem SubBackgroundSkill - { - get - { - return _SubBackgroundSkill; - } - set - { - SetProperty(ref _SubBackgroundSkill, value); - OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); - //OnPropertyChanged(nameof(HasBackgroundSkill)); - } - } - public SkillItem BackgroundOrSubBackgroundSkill - { - get - { - return _SubBackgroundSkill ?? _BackgroundSkill; - } - } + //private SkillItem _BackgroundSkill = null; + //public SkillItem BackgroundSkill + //{ + // get + // { + // return _BackgroundSkill; + // } + // set + // { + // SetProperty(ref _BackgroundSkill, value); + // OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); + // //OnPropertyChanged(nameof(HasBackgroundSkill)); + // } + //} + //private SkillItem _SubBackgroundSkill = null; + //public SkillItem SubBackgroundSkill + //{ + // get + // { + // return _SubBackgroundSkill; + // } + // set + // { + // SetProperty(ref _SubBackgroundSkill, value); + // OnPropertyChanged(nameof(BackgroundOrSubBackgroundSkill)); + // //OnPropertyChanged(nameof(HasBackgroundSkill)); + // } + //} + //public SkillItem BackgroundOrSubBackgroundSkill + //{ + // get + // { + // return _SubBackgroundSkill ?? _BackgroundSkill; + // } + //} //public bool HasBackgroundSkill //{ // get diff --git a/AideDeJeu/AideDeJeu/Views/PlayerCharacter/BackgroundView.xaml b/AideDeJeu/AideDeJeu/Views/PlayerCharacter/BackgroundView.xaml index 0301f087..b6c02617 100644 --- a/AideDeJeu/AideDeJeu/Views/PlayerCharacter/BackgroundView.xaml +++ b/AideDeJeu/AideDeJeu/Views/PlayerCharacter/BackgroundView.xaml @@ -23,6 +23,27 @@ + + + + + + + + + + @@ -50,23 +71,13 @@ - + - - + + - - - - - - - - - -