1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +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 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 AideDeJeuLib;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
@ -24,7 +25,7 @@ namespace AideDeJeu.ViewModels
PersonalityIdeals = new NotifyTaskCompletion<List<string>>(null);
PersonalityLinks = 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
@ -192,7 +193,7 @@ namespace AideDeJeu.ViewModels
PersonalityIdeals = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityIdealsAsync(SelectedPlayerCharacter.Background)));
PersonalityLinks = new NotifyTaskCompletion<List<string>>(Task.Run(() => LoadPersonalityLinksAsync(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));
SelectedPlayerCharacter.SubBackground = null;
SelectedPlayerCharacter.PersonalityTrait = null;
@ -249,7 +250,7 @@ namespace AideDeJeu.ViewModels
}
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));
}
}
@ -302,8 +303,8 @@ namespace AideDeJeu.ViewModels
SetProperty(ref _PersonalityDefects, value);
}
}
private NotifyTaskCompletion<List<string>> _BackgroundSpecialties = null;
public NotifyTaskCompletion<List<string>> BackgroundSpecialties
private NotifyTaskCompletion<BackgroundSpecialtyItem> _BackgroundSpecialties = null;
public NotifyTaskCompletion<BackgroundSpecialtyItem> BackgroundSpecialties
{
get
{
@ -315,8 +316,8 @@ namespace AideDeJeu.ViewModels
OnPropertyChanged(nameof(SelectedBackgroundSpecialties));
}
}
private NotifyTaskCompletion<List<string>> _SubBackgroundSpecialties = null;
public NotifyTaskCompletion<List<string>> SubBackgroundSpecialties
private NotifyTaskCompletion<BackgroundSpecialtyItem> _SubBackgroundSpecialties = null;
public NotifyTaskCompletion<BackgroundSpecialtyItem> SubBackgroundSpecialties
{
get
{
@ -328,7 +329,7 @@ namespace AideDeJeu.ViewModels
OnPropertyChanged(nameof(SelectedBackgroundSpecialties));
}
}
public NotifyTaskCompletion<List<string>> SelectedBackgroundSpecialties
public NotifyTaskCompletion<BackgroundSpecialtyItem> SelectedBackgroundSpecialties
{
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)
{
@ -433,7 +434,7 @@ namespace AideDeJeu.ViewModels
{
var list = await context.BackgroundSpecialties.Where(it => it.ParentLink == background.Id).ToListAsync().ConfigureAwait(false);
var item = list.FirstOrDefault();
return item == null ? null : ExtractSimpleTable(item.Table);
return item;
}
}
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.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}"-->
<!--<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}" />