mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Parsing et affichage des vo et alt
This commit is contained in:
parent
db7564f2ff
commit
bdeba80797
12 changed files with 62 additions and 15 deletions
|
|
@ -108,6 +108,30 @@ namespace AideDeJeu.Tools
|
|||
}
|
||||
}
|
||||
|
||||
public class ItemTypeConverter<T> : IValueConverter
|
||||
{
|
||||
public T Spells { get; set; }
|
||||
public T Monsters { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var itemType = value as ViewModels.ItemsViewModel.ItemType?;
|
||||
if (itemType == ViewModels.ItemsViewModel.ItemType.Spell)
|
||||
{
|
||||
return Spells;
|
||||
}
|
||||
if (itemType == ViewModels.ItemsViewModel.ItemType.Monster)
|
||||
{
|
||||
return Monsters;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemTypeToStringConverter : ItemTypeConverter<string> { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
Title = "À propos de ...";
|
||||
|
||||
OpenWebCommand = new Command(() => Device.OpenUri(new Uri("https://github.com/Nioux/AideDeJeu")));
|
||||
OpenWebCommand = new Command(() => Device.OpenUri(new Uri("https://nioux.github.io/AideDeJeu/")));
|
||||
}
|
||||
|
||||
public ICommand OpenWebCommand { get; }
|
||||
|
|
|
|||
|
|
@ -56,14 +56,16 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
public Command SwitchToSpells { get; set; }
|
||||
public Command SwitchToMonsters { get; set; }
|
||||
public Command AboutCommand { get; set; }
|
||||
|
||||
public ItemsViewModel()
|
||||
public ItemsViewModel(INavigation navigation)
|
||||
{
|
||||
//Title = "Browse";
|
||||
//Items = new ObservableCollection<Item>();
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||
SwitchToSpells = new Command(() => ItemsType = ItemType.Spell);
|
||||
SwitchToMonsters = new Command(() => ItemsType = ItemType.Monster);
|
||||
AboutCommand = new Command(async() => await navigation.PushAsync(new Views.AboutPage()));
|
||||
}
|
||||
|
||||
async Task ExecuteLoadItemsCommand()
|
||||
|
|
@ -72,7 +74,7 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
await Spells.ExecuteLoadItemsCommand();
|
||||
}
|
||||
if (ItemsType == ItemType.Monster)
|
||||
else if (ItemsType == ItemType.Monster)
|
||||
{
|
||||
await Monsters.ExecuteLoadItemsCommand();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ namespace AideDeJeu.ViewModels
|
|||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
private int _MaxPower = 9;
|
||||
private int _MaxPower = 11;
|
||||
public int MaxPower
|
||||
{
|
||||
get
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<FormattedString.Spans>
|
||||
<Span Text="Aide de Jeu" FontAttributes="Bold" FontSize="22" />
|
||||
<Span Text=" " />
|
||||
<Span Text="1.0" ForegroundColor="{StaticResource LightTextColor}" />
|
||||
<Span Text="1.01" ForegroundColor="{StaticResource LightTextColor}" />
|
||||
</FormattedString.Spans>
|
||||
</FormattedString>
|
||||
</Label.FormattedText>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
x:Class="AideDeJeu.Views.ItemsPage"
|
||||
x:Name="This"
|
||||
IsPresented="False"
|
||||
Title="Liste des sorts"
|
||||
Title="{Binding ItemsType,Converter={StaticResource ItemTypeToStringConverter}}"
|
||||
>
|
||||
<MasterDetailPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
@ -67,6 +67,10 @@
|
|||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ControlTemplate>
|
||||
<tools:ItemTypeToStringConverter
|
||||
x:Key="ItemTypeToStringConverter"
|
||||
Spells="Sorts"
|
||||
Monsters="Monstres" />
|
||||
<tools:ItemsTypeTemplateConverter
|
||||
x:Key="ItemsTypeTemplateConverter"
|
||||
SpellsTemplate="{StaticResource SpellsMasterDataTemplate}"
|
||||
|
|
@ -74,17 +78,17 @@
|
|||
</ResourceDictionary>
|
||||
</MasterDetailPage.Resources>
|
||||
<MasterDetailPage.Master>
|
||||
<ContentPage Title="Liste des sorts">
|
||||
<ContentPage Title="Liste des sorts 3">
|
||||
<ContentView ControlTemplate="{Binding ItemsType, Converter={StaticResource ItemsTypeTemplateConverter}}" BindingContext="{Binding}" />
|
||||
<!--<ContentView ControlTemplate="{StaticResource SpellsMasterDataTemplate}" BindingContext="{Binding}" />-->
|
||||
</ContentPage>
|
||||
</MasterDetailPage.Master>
|
||||
<MasterDetailPage.Detail>
|
||||
<ContentPage Title="Liste des sorts">
|
||||
<ContentPage Title="Liste des sorts 2">
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="spell_book.png" Command="{Binding SwitchToSpells}" />
|
||||
<ToolbarItem Name="Monsters" Text="Monstres" Order="Primary" Icon="dragon_head.png" Command="{Binding SwitchToMonsters}" />
|
||||
<ToolbarItem Name="About" Text="A propos de" Order="Primary" Icon="wooden_sign.png" Command="{Binding SwitchToMonsters}" />
|
||||
<ToolbarItem Name="About" Text="À propos de..." Order="Primary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" />
|
||||
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
||||
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ namespace AideDeJeu.Views
|
|||
{
|
||||
InitializeComponent ();
|
||||
|
||||
BindingContext = viewModel = new ItemsViewModel();
|
||||
BindingContext = viewModel = new ItemsViewModel(Navigation);
|
||||
|
||||
}
|
||||
|
||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||
|
|
@ -54,5 +55,7 @@ namespace AideDeJeu.Views
|
|||
if (viewModel.Items.Count == 0)
|
||||
viewModel.LoadItemsCommand.Execute(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
<skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
|
||||
|
||||
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsection}" />
|
||||
<Label Text="{Binding Item.NameVO}" Style="{StaticResource Key=content}" />
|
||||
<Label Text="{Binding Item.NamePHB}" Style="{StaticResource Key=content}" />
|
||||
|
||||
<!--<Label Text=" " />-->
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
Title="{Binding Title}">
|
||||
<ScrollView>
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsubsection}" />
|
||||
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsection}" />
|
||||
<Label Text="{Binding Item.NameVO}" Style="{StaticResource Key=content}" />
|
||||
<Label Text="{Binding Item.NamePHB}" Style="{StaticResource Key=content}" />
|
||||
|
||||
<Label Text=" " />
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace AideDeJeuLib.Monsters
|
|||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameVO { get; set; }
|
||||
public string NamePHB { get; set; }
|
||||
public string Power { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Size { get; set; }
|
||||
|
|
@ -48,7 +49,12 @@ namespace AideDeJeuLib.Monsters
|
|||
var monster = new Monster();
|
||||
var divMonster = divBloc?.SelectSingleNode("div[contains(@class,'monstre')]");
|
||||
monster.Name = divMonster?.SelectSingleNode("h1").InnerText;
|
||||
monster.NameVO = divMonster?.SelectSingleNode("div[contains(@class,'trad')]/a")?.InnerText;
|
||||
|
||||
var altNames = divMonster.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
var matchNames = new Regex(@"\[ (?<vo>.*?) \](?: \[ (?<alt>.*?) \])?").Match(altNames);
|
||||
monster.NameVO = matchNames.Groups["vo"].Value;
|
||||
monster.NamePHB = matchNames.Groups["alt"].Value;
|
||||
|
||||
var divSansSerif = divMonster?.SelectSingleNode("div[contains(@class,'sansSerif')]");
|
||||
var typeSizeAlignment = divSansSerif?.SelectSingleNode("h2/em")?.InnerText;
|
||||
if (typeSizeAlignment != null)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ namespace AideDeJeuLib.Spells
|
|||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameUS { get; set; }
|
||||
public string NameVO { get; set; }
|
||||
public string NamePHB { get; set; }
|
||||
public string LevelType { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
|
@ -51,7 +52,10 @@ namespace AideDeJeuLib.Spells
|
|||
{
|
||||
var spell = new Spell();
|
||||
spell.Name = nodeSpell.SelectSingleNode("h1").InnerText;
|
||||
spell.NameUS = nodeSpell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
var altNames = nodeSpell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
var matchNames = new Regex(@"\[ (?<vo>.*?) \](?: \[ (?<alt>.*?) \])?").Match(altNames);
|
||||
spell.NameVO = matchNames.Groups["vo"].Value;
|
||||
spell.NamePHB = matchNames.Groups["alt"].Value;
|
||||
spell.LevelType = nodeSpell.SelectSingleNode("h2/em").InnerText;
|
||||
spell.Level = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
|
||||
spell.Type = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace AideDeJeuLib.Spells
|
|||
{
|
||||
var newSpell = new Spell();
|
||||
newSpell.Name = spell.SelectSingleNode("h1").InnerText;
|
||||
newSpell.NameUS = spell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
newSpell.NameVO = spell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
newSpell.LevelType = spell.SelectSingleNode("h2/em").InnerText;
|
||||
newSpell.Level = newSpell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
|
||||
newSpell.Type = newSpell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue