mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-15 22:59:39 +00:00
Test tables
This commit is contained in:
parent
b386d44103
commit
e5f244df36
4 changed files with 104 additions and 31 deletions
|
|
@ -55,6 +55,7 @@ namespace AideDeJeu.UWP
|
|||
Rg.Plugins.Popup.Popup.Init();
|
||||
|
||||
//Xamarin.Forms.Forms.Init(e);
|
||||
//Xamarin.Forms.SetFlags("CollectionView_Experimental");
|
||||
//Xamarin.Forms.SetFlags("Shell_Experimental");
|
||||
Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies());
|
||||
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());
|
||||
|
|
|
|||
|
|
@ -15,10 +15,28 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
Races = new NotifyTaskCompletion<List<RaceItem>>(Task.Run(() => LoadRacesAsync()));
|
||||
Classes = new NotifyTaskCompletion<List<ClassItem>>(Task.Run(() => LoadClassesAsync()));
|
||||
|
||||
Backgrounds = new NotifyTaskCompletion<List<BackgroundItem>>(Task.Run(() => LoadBackgroundsAsync()));
|
||||
SubBackgrounds = new NotifyTaskCompletion<List<SubBackgroundItem>>(null);
|
||||
PersonalityTraits = new NotifyTaskCompletion<List<string>>(null);
|
||||
}
|
||||
|
||||
#region Selected PC
|
||||
private PlayerCharacterViewModel _SelectedPlayerCharacter = new PlayerCharacterViewModel();
|
||||
public PlayerCharacterViewModel SelectedPlayerCharacter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SelectedPlayerCharacter;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _SelectedPlayerCharacter, value);
|
||||
}
|
||||
}
|
||||
#endregion Selected PC
|
||||
|
||||
#region Race
|
||||
public NotifyTaskCompletion<List<RaceItem>> Races { get; private set; }
|
||||
private int _RaceSelectedIndex = 0;
|
||||
public int RaceSelectedIndex
|
||||
|
|
@ -36,6 +54,17 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<RaceItem>> LoadRacesAsync()
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
return await context.Races.Where(r => !r.HasSubRaces).OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
#endregion Race
|
||||
|
||||
#region Class
|
||||
public NotifyTaskCompletion<List<ClassItem>> Classes { get; private set; }
|
||||
|
||||
private int _ClassSelectedIndex = 0;
|
||||
|
|
@ -52,6 +81,16 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<ClassItem>> LoadClassesAsync()
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
return await context.Classes.Where(c => !(c is SubClassItem)).OrderBy(c => Tools.Helpers.RemoveDiacritics(c.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
#endregion Class
|
||||
|
||||
#region Background
|
||||
public NotifyTaskCompletion<List<BackgroundItem>> Backgrounds { get; private set; }
|
||||
|
||||
private int _BackgroundSelectedIndex = 0;
|
||||
|
|
@ -66,6 +105,7 @@ namespace AideDeJeu.ViewModels
|
|||
SetProperty(ref _BackgroundSelectedIndex, value);
|
||||
SelectedPlayerCharacter.Background = Backgrounds.Result[_BackgroundSelectedIndex];
|
||||
SubBackgrounds = new NotifyTaskCompletion<List<SubBackgroundItem>>(Task.Run(() => LoadSubBackgroundsAsync(SelectedPlayerCharacter.Background)));
|
||||
PersonalityTraits = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityTraitsAsync(SelectedPlayerCharacter.Background)));
|
||||
SelectedPlayerCharacter.SubBackground = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,47 +145,53 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private PlayerCharacterViewModel _SelectedPlayerCharacter = new PlayerCharacterViewModel();
|
||||
public PlayerCharacterViewModel SelectedPlayerCharacter
|
||||
private NotifyTaskCompletion<List<string>> _PersonalityTraits = null;
|
||||
public NotifyTaskCompletion<List<string>> PersonalityTraits
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SelectedPlayerCharacter;
|
||||
return _PersonalityTraits;
|
||||
}
|
||||
set
|
||||
private set
|
||||
{
|
||||
SetProperty(ref _SelectedPlayerCharacter, value);
|
||||
SetProperty(ref _PersonalityTraits, value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Abilities { get; set; } = new List<string>()
|
||||
{
|
||||
"2 (-4)", "3 (-4)", "4 (-3)", "5 (-3)", "6 (-2)", "7 (-2)", "8 (-1)", "9 (-1)", "10 (+0)", "11 (+0)", "12 (+1)", "13 (+1)", "14 (+2)", "15 (+2)", "16 (+3)", "17 (+3)", "18 (+4)", "19 (+4)", "20 (+5)", "21 (+5)"
|
||||
};
|
||||
public List<string> Levels { get; set; } = new List<string>()
|
||||
{
|
||||
"1", //"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"
|
||||
};
|
||||
|
||||
public async Task<List<RaceItem>> LoadRacesAsync()
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
return await context.Races.Where(r => !r.HasSubRaces).OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public async Task<List<ClassItem>> LoadClassesAsync()
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
return await context.Classes.Where(c => !(c is SubClassItem)).OrderBy(c => Tools.Helpers.RemoveDiacritics(c.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public async Task<List<BackgroundItem>> LoadBackgroundsAsync()
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
return await context.Backgrounds.Where(b => b.GetType() == typeof(BackgroundItem)).OrderBy(b => Tools.Helpers.RemoveDiacritics(b.Name)).ToListAsync().ConfigureAwait(false);
|
||||
var list = await context.Backgrounds.Where(b => b.GetType() == typeof(BackgroundItem)).OrderBy(b => Tools.Helpers.RemoveDiacritics(b.Name)).ToListAsync().ConfigureAwait(false);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> LoadPersonalityTraitsAsync(BackgroundItem background)
|
||||
{
|
||||
if (background != null)
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
var list = await context.PersonalityTraits.Where(it => it.ParentLink.StartsWith(background.RootId)).OrderBy(b => Tools.Helpers.RemoveDiacritics(b.Name)).ToListAsync().ConfigureAwait(false);
|
||||
var item = list.FirstOrDefault();
|
||||
var table = item.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('|');
|
||||
result.Add(cols[2]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,5 +211,21 @@ namespace AideDeJeu.ViewModels
|
|||
return new List<SubBackgroundItem>();
|
||||
}
|
||||
}
|
||||
#endregion Background
|
||||
|
||||
#region Abilities
|
||||
public List<string> Abilities { get; set; } = new List<string>()
|
||||
{
|
||||
"2 (-4)", "3 (-4)", "4 (-3)", "5 (-3)", "6 (-2)", "7 (-2)", "8 (-1)", "9 (-1)", "10 (+0)", "11 (+0)", "12 (+1)", "13 (+1)", "14 (+2)", "15 (+2)", "16 (+3)", "17 (+3)", "18 (+4)", "19 (+4)", "20 (+5)", "21 (+5)"
|
||||
};
|
||||
#endregion Abilities
|
||||
|
||||
#region Level
|
||||
public List<string> Levels { get; set; } = new List<string>()
|
||||
{
|
||||
"1", //"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"
|
||||
};
|
||||
#endregion Level
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -560,6 +560,7 @@ namespace AideDeJeu.ViewModels
|
|||
public DbSet<SubClassItem> SubClasses { get; set; }
|
||||
public DbSet<BackgroundItem> Backgrounds { get; set; }
|
||||
public DbSet<SubBackgroundItem> SubBackgrounds { get; set; }
|
||||
public DbSet<PersonalityTraitItem> PersonalityTraits { get; set; }
|
||||
|
||||
public AideDeJeuContext(string dbPath)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,10 +54,19 @@
|
|||
<StackLayout>
|
||||
<Picker Title="Historique" HorizontalOptions="FillAndExpand" IsEnabled="{Binding Backgrounds.IsSuccessfullyCompleted}" ItemsSource="{Binding Backgrounds.Result}" ItemDisplayBinding="{Binding Name}" SelectedIndex="{Binding BackgroundSelectedIndex, Mode=TwoWay}" />
|
||||
<Picker Title="Variante" HorizontalOptions="FillAndExpand" IsEnabled="{Binding SubBackgrounds.IsSuccessfullyCompleted}" ItemsSource="{Binding SubBackgrounds.Result}" ItemDisplayBinding="{Binding Name}" SelectedIndex="{Binding SubBackgroundSelectedIndex, Mode=TwoWay}" />
|
||||
<ScrollView Orientation="Vertical">
|
||||
<StackLayout>
|
||||
<ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" >
|
||||
<StackLayout HorizontalOptions="FillAndExpand" >
|
||||
<mdview:MarkdownView Markdown="{Binding SelectedPlayerCharacter.Background.Description}" />
|
||||
<mdview:MarkdownView Markdown="{Binding SelectedPlayerCharacter.SubBackground.Description}" />
|
||||
<ListView HorizontalOptions="FillAndExpand" ItemsSource="{Binding PersonalityTraits.Result}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<mdview:MarkdownView HorizontalOptions="FillAndExpand" Markdown="{Binding}" />
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<mdview:MarkdownView Markdown="{Binding SelectedPlayerCharacter.Background.Markdown}" />
|
||||
<mdview:MarkdownView Markdown="{Binding SelectedPlayerCharacter.SubBackground.Markdown}" />
|
||||
</StackLayout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue