mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-16 15:19:56 +00:00
Class vm
This commit is contained in:
parent
cc0f0ef161
commit
9bdd734df3
9 changed files with 216 additions and 54 deletions
|
|
@ -50,6 +50,9 @@
|
||||||
<Compile Update="Views\AboutPage.xaml.cs">
|
<Compile Update="Views\AboutPage.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Views\ItemView.xaml.cs">
|
||||||
|
<DependentUpon>ItemView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Views\Library\ItemDetailPage.xaml.cs">
|
<Compile Update="Views\Library\ItemDetailPage.xaml.cs">
|
||||||
<DependentUpon>ItemDetailPage.xaml</DependentUpon>
|
<DependentUpon>ItemDetailPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,33 @@
|
||||||
namespace AideDeJeuLib
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
public class ClassEvolutionItem : Item
|
public class ClassEvolutionItem : Item
|
||||||
{
|
{
|
||||||
|
public string Table { get; set; }
|
||||||
|
public List<string> BindableTable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ExtractSimpleTable(Table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<string> ExtractSimpleTable(string table)
|
||||||
|
{
|
||||||
|
var lines = table.Split('\n');
|
||||||
|
var result = new List<string>();
|
||||||
|
foreach (var line in lines.Skip(2))
|
||||||
|
{
|
||||||
|
if (line.StartsWith("|"))
|
||||||
|
{
|
||||||
|
var cols = line.Split('|');
|
||||||
|
var text = cols[2].Replace("<!--br-->", " ").Replace(" ", " ");
|
||||||
|
result.Add(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,66 @@
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace AideDeJeu.ViewModels.PlayerCharacter
|
namespace AideDeJeu.ViewModels.PlayerCharacter
|
||||||
{
|
{
|
||||||
public class ClassViewModel : BaseViewModel
|
public class ClassViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
public ClassItem Class { get; set; }
|
private ClassItem _Class = null;
|
||||||
public SubClassItem SubClass { get; set; }
|
public ClassItem Class { get { return _Class; } set { SetProperty(ref _Class, value); } }
|
||||||
public ClassHitPointsItem HitPoints { get; set; }
|
|
||||||
public ClassProficienciesItem Proficiencies { get; set; }
|
private SubClassItem _SubClass = null;
|
||||||
public ClassEquipmentItem Equipment { get; set; }
|
public SubClassItem SubClass { get { return _SubClass; } set { SetProperty(ref _SubClass, value); } }
|
||||||
public ClassEvolutionItem Evolution { get; set; }
|
|
||||||
public List<ClassFeatureItem> Features { get; set; }
|
private ClassHitPointsItem _HitPoints = null;
|
||||||
|
public ClassHitPointsItem HitPoints { get { return _HitPoints; } set { SetProperty(ref _HitPoints, value); } }
|
||||||
|
|
||||||
|
public ClassProficienciesItem _Proficiencies = null;
|
||||||
|
public ClassProficienciesItem Proficiencies { get { return _Proficiencies; } set { SetProperty(ref _Proficiencies, value); } }
|
||||||
|
|
||||||
|
public ClassEquipmentItem _Equipment = null;
|
||||||
|
public ClassEquipmentItem Equipment { get { return _Equipment; } set { SetProperty(ref _Equipment, value); } }
|
||||||
|
|
||||||
|
public ClassEvolutionItem _Evolution = null;
|
||||||
|
public ClassEvolutionItem Evolution { get { return _Evolution; } set { SetProperty(ref _Evolution, value); } }
|
||||||
|
|
||||||
|
public List<ClassFeatureItem> _Features = null;
|
||||||
|
public List<ClassFeatureItem> Features { get { return _Features; } set { SetProperty(ref _Features, value); } }
|
||||||
|
|
||||||
public string Name { get { return Class?.Name; } }
|
public string Name { get { return Class?.Name; } }
|
||||||
public string Description { get { return Class?.Description; } }
|
public string Description { get { return Class?.Description; } }
|
||||||
public string Markdown { get { return Class?.Markdown; } }
|
public string Markdown { get { return Class?.Markdown; } }
|
||||||
|
|
||||||
|
public List<ClassFeatureItem> LeveledFeatures
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var table = Evolution.ExtractSimpleTable(Evolution.Table);
|
||||||
|
var feats = table[1];
|
||||||
|
var leveledFeats = new List<ClassFeatureItem>();
|
||||||
|
foreach(var feature in Features)
|
||||||
|
{
|
||||||
|
if(feats.Contains(feature.Name))
|
||||||
|
{
|
||||||
|
leveledFeats.Add(feature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return leveledFeats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadDetailsAsync()
|
||||||
|
{
|
||||||
|
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||||
|
{
|
||||||
|
HitPoints = await context.ClassHitPoints.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
|
||||||
|
Proficiencies = await context.ClassProficiencies.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
|
||||||
|
Equipment = await context.ClassEquipments.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
|
||||||
|
Evolution = await context.ClassEvolutions.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
|
||||||
|
Features = await context.ClassFeatures.Where(c => c.ParentLink == Class.Id).ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,20 +151,6 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
||||||
#region Race
|
#region Race
|
||||||
public NotifyTaskCompletion<List<RaceViewModel>> Races { get; private set; }
|
public NotifyTaskCompletion<List<RaceViewModel>> Races { get; private set; }
|
||||||
|
|
||||||
//private RaceViewModel _SelectedRace = null;
|
|
||||||
//public RaceViewModel SelectedRace
|
|
||||||
//{
|
|
||||||
// get
|
|
||||||
// {
|
|
||||||
// return _SelectedRace;
|
|
||||||
// }
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// SetProperty(ref _SelectedRace, value);
|
|
||||||
// //SelectedPlayerCharacter.Race = _SelectedRace;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public async Task<List<RaceViewModel>> LoadRacesAsync()
|
public async Task<List<RaceViewModel>> LoadRacesAsync()
|
||||||
{
|
{
|
||||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||||
|
|
@ -195,33 +181,6 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
||||||
#region Class
|
#region Class
|
||||||
public NotifyTaskCompletion<List<ClassViewModel>> Classes { get; private set; }
|
public NotifyTaskCompletion<List<ClassViewModel>> Classes { get; private set; }
|
||||||
|
|
||||||
//private int _ClassSelectedIndex = -1;
|
|
||||||
//public int ClassSelectedIndex
|
|
||||||
//{
|
|
||||||
// get
|
|
||||||
// {
|
|
||||||
// return _ClassSelectedIndex;
|
|
||||||
// }
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// SetProperty(ref _ClassSelectedIndex, value);
|
|
||||||
// SelectedClass = Classes.Result[_ClassSelectedIndex];
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//private ClassViewModel _SelectedClass = null;
|
|
||||||
//public ClassViewModel SelectedClass
|
|
||||||
//{
|
|
||||||
// get
|
|
||||||
// {
|
|
||||||
// return _SelectedClass;
|
|
||||||
// }
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// SetProperty(ref _SelectedClass, value);
|
|
||||||
// //SelectedPlayerCharacter.Class = _SelectedClass;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public async Task<List<ClassViewModel>> LoadClassesAsync()
|
public async Task<List<ClassViewModel>> LoadClassesAsync()
|
||||||
{
|
{
|
||||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
SetProperty(ref _Class, value);
|
SetProperty(ref _Class, value);
|
||||||
|
_Class.LoadDetailsAsync().ConfigureAwait(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -610,14 +610,21 @@ namespace AideDeJeu.ViewModels
|
||||||
public DbSet<MagicItem> MagicItems { get; set; }
|
public DbSet<MagicItem> MagicItems { get; set; }
|
||||||
public DbSet<SpellItem> Spells { get; set; }
|
public DbSet<SpellItem> Spells { get; set; }
|
||||||
public DbSet<MonsterItem> Monsters { get; set; }
|
public DbSet<MonsterItem> Monsters { get; set; }
|
||||||
//public DbSet<Spell> Spells { get; set; }
|
|
||||||
//public DbSet<MonsterHD> MonstersHD { get; set; }
|
|
||||||
//public DbSet<SpellVO> SpellsVO { get; set; }
|
|
||||||
//public DbSet<MonsterVO> MonstersVO { get; set; }
|
|
||||||
public DbSet<RaceItem> Races { get; set; }
|
public DbSet<RaceItem> Races { get; set; }
|
||||||
public DbSet<ClassItem> Classes { get; set; }
|
|
||||||
public DbSet<SubRaceItem> SubRaces { get; set; }
|
public DbSet<SubRaceItem> SubRaces { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public DbSet<ClassItem> Classes { get; set; }
|
||||||
public DbSet<SubClassItem> SubClasses { get; set; }
|
public DbSet<SubClassItem> SubClasses { get; set; }
|
||||||
|
public DbSet<ClassHitPointsItem> ClassHitPoints { get; set; }
|
||||||
|
public DbSet<ClassProficienciesItem> ClassProficiencies { get; set; }
|
||||||
|
public DbSet<ClassEquipmentItem> ClassEquipments { get; set; }
|
||||||
|
public DbSet<ClassEvolutionItem> ClassEvolutions { get; set; }
|
||||||
|
public DbSet<ClassFeatureItem> ClassFeatures { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DbSet<BackgroundItem> Backgrounds { get; set; }
|
public DbSet<BackgroundItem> Backgrounds { get; set; }
|
||||||
public DbSet<SubBackgroundItem> SubBackgrounds { get; set; }
|
public DbSet<SubBackgroundItem> SubBackgrounds { get; set; }
|
||||||
public DbSet<PersonalityTraitItem> PersonalityTraits { get; set; }
|
public DbSet<PersonalityTraitItem> PersonalityTraits { get; set; }
|
||||||
|
|
@ -626,6 +633,8 @@ namespace AideDeJeu.ViewModels
|
||||||
public DbSet<PersonalityDefectItem> PersonalityDefects { get; set; }
|
public DbSet<PersonalityDefectItem> PersonalityDefects { get; set; }
|
||||||
public DbSet<SkillItem> Skills { get; set; }
|
public DbSet<SkillItem> Skills { get; set; }
|
||||||
public DbSet<BackgroundSpecialtyItem> BackgroundSpecialties { get; set; }
|
public DbSet<BackgroundSpecialtyItem> BackgroundSpecialties { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DbSet<AlignmentItem> Alignments { get; set; }
|
public DbSet<AlignmentItem> Alignments { get; set; }
|
||||||
|
|
||||||
public AideDeJeuContext(string dbPath)
|
public AideDeJeuContext(string dbPath)
|
||||||
|
|
|
||||||
19
AideDeJeu/AideDeJeu/Views/ItemView.xaml
Normal file
19
AideDeJeu/AideDeJeu/Views/ItemView.xaml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<StackLayout
|
||||||
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||||
|
xmlns:mdview="clr-namespace:Xam.Forms.Markdown"
|
||||||
|
x:Class="AideDeJeu.Views.ItemView"
|
||||||
|
x:Name="this"
|
||||||
|
>
|
||||||
|
<!--IsVisible="{Binding Description, Converter={x:StaticResource NullToFalseConverter}}"-->
|
||||||
|
<StackLayout.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
|
||||||
|
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</StackLayout.Resources>
|
||||||
|
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Name, Source={x:Reference this}}" />
|
||||||
|
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Description, Source={x:Reference this}}" />
|
||||||
|
</StackLayout>
|
||||||
82
AideDeJeu/AideDeJeu/Views/ItemView.xaml.cs
Normal file
82
AideDeJeu/AideDeJeu/Views/ItemView.xaml.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
using AideDeJeu.ViewModels;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace AideDeJeu.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class ItemView : StackLayout
|
||||||
|
{
|
||||||
|
public MainViewModel Main
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DependencyService.Get<MainViewModel>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ItemView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BindingContext = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(NameProperty); }
|
||||||
|
set { SetValue(NameProperty, value); }
|
||||||
|
}
|
||||||
|
public static readonly BindableProperty NameProperty = BindableProperty.Create(
|
||||||
|
nameof(Name),
|
||||||
|
typeof(string),
|
||||||
|
typeof(ItemView),
|
||||||
|
defaultValue: default(string));
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(DescriptionProperty); }
|
||||||
|
set { SetValue(DescriptionProperty, value); }
|
||||||
|
}
|
||||||
|
public static readonly BindableProperty DescriptionProperty = BindableProperty.Create(
|
||||||
|
nameof(Description),
|
||||||
|
typeof(string),
|
||||||
|
typeof(ItemView),
|
||||||
|
defaultValue: default(string));
|
||||||
|
|
||||||
|
public object SelectedItem
|
||||||
|
{
|
||||||
|
get { return (object)GetValue(SelectedItemProperty); }
|
||||||
|
set { SetValue(SelectedItemProperty, value); }
|
||||||
|
}
|
||||||
|
public static readonly BindableProperty SelectedItemProperty = BindableProperty.Create(
|
||||||
|
nameof(SelectedItem),
|
||||||
|
typeof(object),
|
||||||
|
typeof(ItemView),
|
||||||
|
defaultValue: default(object),
|
||||||
|
defaultBindingMode: BindingMode.TwoWay);
|
||||||
|
|
||||||
|
public System.Collections.IEnumerable ItemsSource
|
||||||
|
{
|
||||||
|
get { return (System.Collections.IEnumerable)GetValue(ItemsSourceProperty); }
|
||||||
|
set { SetValue(ItemsSourceProperty, value); }
|
||||||
|
}
|
||||||
|
//public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(
|
||||||
|
// nameof(ItemsSource),
|
||||||
|
// typeof(System.Collections.IList),
|
||||||
|
// typeof(StringPickerView),
|
||||||
|
// defaultValue: new List<string>());
|
||||||
|
public static readonly BindableProperty ItemsSourceProperty =
|
||||||
|
BindableProperty.Create(
|
||||||
|
nameof(ItemsSource),
|
||||||
|
typeof(System.Collections.IEnumerable),
|
||||||
|
typeof(ItemView),
|
||||||
|
default(System.Collections.IEnumerable));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -71,6 +71,22 @@
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<views:ItemPickerView BindingContext="{Binding}" Title="Classe" ItemsSource="{Binding Classes.Result}" SelectedItem="{Binding SelectedPlayerCharacter.Class, Mode=TwoWay}" />
|
<views:ItemPickerView BindingContext="{Binding}" Title="Classe" ItemsSource="{Binding Classes.Result}" SelectedItem="{Binding SelectedPlayerCharacter.Class, Mode=TwoWay}" />
|
||||||
<!--<Picker Title="Classe" HorizontalOptions="FillAndExpand" IsEnabled="{Binding Classes.IsSuccessfullyCompleted}" ItemsSource="{Binding Classes.Result}" ItemDisplayBinding="{Binding Name}" SelectedIndex="{Binding ClassSelectedIndex, Mode=TwoWay}" />-->
|
<!--<Picker Title="Classe" HorizontalOptions="FillAndExpand" IsEnabled="{Binding Classes.IsSuccessfullyCompleted}" ItemsSource="{Binding Classes.Result}" ItemDisplayBinding="{Binding Name}" SelectedIndex="{Binding ClassSelectedIndex, Mode=TwoWay}" />-->
|
||||||
|
|
||||||
|
<Frame BorderColor="Black" Padding="2" Margin="10" IsVisible="{Binding SelectedPlayerCharacter.Class, Converter={StaticResource NullToFalseConverter}, FallbackValue=False}" >
|
||||||
|
<StackLayout Padding="0">
|
||||||
|
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Dés de vie" Description="{Binding SelectedPlayerCharacter.Class.HitPoints.HitDice}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Points de vie au niveau 1" Description="{Binding SelectedPlayerCharacter.Class.HitPoints.HitPointsAt1stLevel}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Points de vie aux niveaux supérieurs" Description="{Binding SelectedPlayerCharacter.Class.HitPoints.HitPointsAtHigherLevels}" />
|
||||||
|
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Armures" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.Armor}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Armes" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.Weapons}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Outils" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.Tools}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Jets de sauvegarde" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.SavingThrows}" />
|
||||||
|
<views:ItemView BindingContext="{Binding}" Name="#### Compétences" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.Skills}" />
|
||||||
|
|
||||||
|
</StackLayout>
|
||||||
|
</Frame>
|
||||||
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding SelectedPlayerCharacter.Class.Markdown}" />
|
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding SelectedPlayerCharacter.Class.Markdown}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue