1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 23:16:09 +00:00

Presque...

This commit is contained in:
Yan Maniez 2019-04-12 01:01:08 +02:00
parent b1f7fc9de2
commit 73bc6f8a02
3 changed files with 39 additions and 12 deletions

View file

@ -1,8 +1,33 @@
namespace AideDeJeuLib using System.Collections.Generic;
using System.Linq;
namespace AideDeJeuLib
{ {
public class BackgroundSpecialtyItem : Item, TableProperty public class BackgroundSpecialtyItem : Item, TableProperty
{ {
public string Table { get; set; } 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;
}
} }
} }

View file

@ -1,6 +1,7 @@
using AideDeJeu.Tools; using AideDeJeu.Tools;
using AideDeJeuLib; using AideDeJeuLib;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -24,7 +25,7 @@ namespace AideDeJeu.ViewModels
PersonalityIdeals = new NotifyTaskCompletion<List<string>>(null); PersonalityIdeals = new NotifyTaskCompletion<List<string>>(null);
PersonalityLinks = new NotifyTaskCompletion<List<string>>(null); PersonalityLinks = new NotifyTaskCompletion<List<string>>(null);
PersonalityDefects = new NotifyTaskCompletion<List<string>>(null); PersonalityDefects = new NotifyTaskCompletion<List<string>>(null);
BackgroundSpecialties = new NotifyTaskCompletion<List<string>>(null); BackgroundSpecialties = new NotifyTaskCompletion<BackgroundSpecialtyItem>(null);
} }
#region Selected PC #region Selected PC
@ -192,7 +193,7 @@ namespace AideDeJeu.ViewModels
PersonalityIdeals = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityIdealsAsync(SelectedPlayerCharacter.Background))); PersonalityIdeals = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityIdealsAsync(SelectedPlayerCharacter.Background)));
PersonalityLinks = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityLinksAsync(SelectedPlayerCharacter.Background))); PersonalityLinks = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityLinksAsync(SelectedPlayerCharacter.Background)));
PersonalityDefects = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityDefectsAsync(SelectedPlayerCharacter.Background))); PersonalityDefects = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityDefectsAsync(SelectedPlayerCharacter.Background)));
BackgroundSpecialties = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadBackgroundsSpecialtiesAsync(SelectedPlayerCharacter.Background))); BackgroundSpecialties = new NotifyTaskCompletion<BackgroundSpecialtyItem>(Task.Run(() => LoadBackgroundsSpecialtiesAsync(SelectedPlayerCharacter.Background)));
Task.Run(async () => SelectedPlayerCharacter.BackgroundSkill = await LoadSkillAsync(SelectedPlayerCharacter.Background)); Task.Run(async () => SelectedPlayerCharacter.BackgroundSkill = await LoadSkillAsync(SelectedPlayerCharacter.Background));
SelectedPlayerCharacter.SubBackground = null; SelectedPlayerCharacter.SubBackground = null;
SelectedPlayerCharacter.PersonalityTrait = null; SelectedPlayerCharacter.PersonalityTrait = null;
@ -249,7 +250,7 @@ namespace AideDeJeu.ViewModels
} }
else else
{ {
SubBackgroundSpecialties = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadBackgroundsSpecialtiesAsync(SelectedPlayerCharacter.SubBackground))); SubBackgroundSpecialties = new NotifyTaskCompletion<BackgroundSpecialtyItem>(Task.Run(() => LoadBackgroundsSpecialtiesAsync(SelectedPlayerCharacter.SubBackground)));
Task.Run(async () => SelectedPlayerCharacter.SubBackgroundSkill = await LoadSkillAsync(SelectedPlayerCharacter.SubBackground)); Task.Run(async () => SelectedPlayerCharacter.SubBackgroundSkill = await LoadSkillAsync(SelectedPlayerCharacter.SubBackground));
} }
} }
@ -302,8 +303,8 @@ namespace AideDeJeu.ViewModels
SetProperty(ref _PersonalityDefects, value); SetProperty(ref _PersonalityDefects, value);
} }
} }
private NotifyTaskCompletion<List<string>> _BackgroundSpecialties = null; private NotifyTaskCompletion<BackgroundSpecialtyItem> _BackgroundSpecialties = null;
public NotifyTaskCompletion<List<string>> BackgroundSpecialties public NotifyTaskCompletion<BackgroundSpecialtyItem> BackgroundSpecialties
{ {
get get
{ {
@ -315,8 +316,8 @@ namespace AideDeJeu.ViewModels
OnPropertyChanged(nameof(SelectedBackgroundSpecialties)); OnPropertyChanged(nameof(SelectedBackgroundSpecialties));
} }
} }
private NotifyTaskCompletion<List<string>> _SubBackgroundSpecialties = null; private NotifyTaskCompletion<BackgroundSpecialtyItem> _SubBackgroundSpecialties = null;
public NotifyTaskCompletion<List<string>> SubBackgroundSpecialties public NotifyTaskCompletion<BackgroundSpecialtyItem> SubBackgroundSpecialties
{ {
get get
{ {
@ -328,7 +329,7 @@ namespace AideDeJeu.ViewModels
OnPropertyChanged(nameof(SelectedBackgroundSpecialties)); OnPropertyChanged(nameof(SelectedBackgroundSpecialties));
} }
} }
public NotifyTaskCompletion<List<string>> SelectedBackgroundSpecialties public NotifyTaskCompletion<BackgroundSpecialtyItem> SelectedBackgroundSpecialties
{ {
get get
{ {
@ -425,7 +426,7 @@ namespace AideDeJeu.ViewModels
} }
} }
public async Task<List<string>> LoadBackgroundsSpecialtiesAsync(BackgroundItem background) public async Task<BackgroundSpecialtyItem> LoadBackgroundsSpecialtiesAsync(BackgroundItem background)
{ {
if (background != null) if (background != null)
{ {
@ -433,7 +434,7 @@ namespace AideDeJeu.ViewModels
{ {
var list = await context.BackgroundSpecialties.Where(it => it.ParentLink == background.Id).ToListAsync().ConfigureAwait(false); var list = await context.BackgroundSpecialties.Where(it => it.ParentLink == background.Id).ToListAsync().ConfigureAwait(false);
var item = list.FirstOrDefault(); var item = list.FirstOrDefault();
return item == null ? null : ExtractSimpleTable(item.Table); return item;
} }
} }
else else

View file

@ -59,7 +59,8 @@
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.SelectedBackgroundSkill.Name, StringFormat='# {0}'}" /> <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.SelectedBackgroundSkill.Name, StringFormat='# {0}'}" />
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.SelectedBackgroundSkill.Description}" /> <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.SelectedBackgroundSkill.Description}" />
<views:StringPickerView BindingContext="{Binding}" Title="{Binding SelectedPlayerCharacter.SelectedBackgroundSpecialty}" ItemsSource="{Binding SelectedBackgroundSpecialties.Result}" /> <views:StringPickerView BindingContext="{Binding}" Title="{Binding SelectedBackgroundSpecialties.Result.Name}" ItemsSource="{Binding SelectedBackgroundSpecialties.Result.BindableTable}" />
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedBackgroundSpecialties.Result.Description}" />
<!--SelectedItem="{Binding SelectedPlayerCharacter.SelectedBackgroundSpecialty, Mode=TwoWay}"--> <!--SelectedItem="{Binding SelectedPlayerCharacter.SelectedBackgroundSpecialty, Mode=TwoWay}"-->
<!--<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" IsVisible="{Binding PersonalityTraits.IsSuccessfullyCompleted}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.PersonalityTrait}" /> <!--<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" IsVisible="{Binding PersonalityTraits.IsSuccessfullyCompleted}" HorizontalOptions="FillAndExpand" Markdown="{Binding SelectedPlayerCharacter.PersonalityTrait}" />
<Button Visual="Material" IsVisible="{Binding SelectedBackgroundSpecialties.IsSuccessfullyCompleted}" Text="Spécialité" Command="{Binding BackgroundSpecialtyPickerCommand}" CommandParameter="{Binding SelectedBackgroundSpecialties.Result}" /> <Button Visual="Material" IsVisible="{Binding SelectedBackgroundSpecialties.IsSuccessfullyCompleted}" Text="Spécialité" Command="{Binding BackgroundSpecialtyPickerCommand}" CommandParameter="{Binding SelectedBackgroundSpecialties.Result}" />