1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-31 07:26:09 +00:00

Un peu de blindage, y'a un bug qui reste

This commit is contained in:
Yan Maniez 2018-05-28 11:58:24 +02:00
parent f324ea3f15
commit 8ff866f8b6
5 changed files with 75 additions and 170 deletions

View file

@ -19,6 +19,9 @@ namespace AideDeJeu.Tools
{
public override int Compare(string x, string y)
{
if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y)) return 0;
if (string.IsNullOrEmpty(x)) return 1;
if (string.IsNullOrEmpty(y)) return -1;
var regex = new Regex(@"\((?<xp>\d*?) (PX|XP)\)");
int xpx = int.Parse(regex.Match(x).Groups["xp"].Value);
int xpy = int.Parse(regex.Match(y).Groups["xp"].Value);

View file

@ -90,58 +90,6 @@ namespace AideDeJeu.Tools
}
}
public class ItemsTypeTemplateConverter : IValueConverter
{
public ControlTemplate SpellsTemplate { get; set; }
public ControlTemplate MonstersTemplate { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var itemType = value as ItemType?;
if (itemType == ItemType.Spell)
{
return SpellsTemplate;
}
if (itemType == ItemType.Monster)
{
return MonstersTemplate;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
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 ItemType?;
if (itemType == ItemType.Spell)
{
return Spells;
}
if (itemType == ItemType.Monster)
{
return Monsters;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
public class ItemTypeToStringConverter : ItemTypeConverter<string> { }
public class ItemSourceTypeConverter<T> : IValueConverter
{
@ -154,31 +102,31 @@ namespace AideDeJeu.Tools
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//var itemType = value as ItemSourceType?;
//if (itemType == ItemSourceType.SpellVF)
//{
// return SpellVF;
//}
//if (itemType == ItemSourceType.SpellVO)
//{
// return SpellVO;
//}
//if (itemType == ItemSourceType.SpellHD)
//{
// return SpellHD;
//}
//if (itemType == ItemSourceType.MonsterVF)
//{
// return MonsterVF;
//}
//if (itemType == ItemSourceType.MonsterVO)
//{
// return MonsterVO;
//}
//if (itemType == ItemSourceType.MonsterHD)
//{
// return MonsterHD;
//}
var itemType = value as ItemSourceType?;
if (itemType == ItemSourceType.SpellVF)
{
return SpellVF;
}
if (itemType == ItemSourceType.SpellVO)
{
return SpellVO;
}
if (itemType == ItemSourceType.SpellHD)
{
return SpellHD;
}
if (itemType == ItemSourceType.MonsterVF)
{
return MonsterVF;
}
if (itemType == ItemSourceType.MonsterVO)
{
return MonsterVO;
}
if (itemType == ItemSourceType.MonsterHD)
{
return MonsterHD;
}
return null;
}
@ -188,6 +136,8 @@ namespace AideDeJeu.Tools
}
}
public class ItemSourceTypeToStringConverter : ItemSourceTypeConverter<string> { }
public class ItemSourceTypeToItemsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

View file

@ -4,6 +4,7 @@ using AideDeJeuLib.Monsters;
using AideDeJeuLib.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Input;
@ -52,7 +53,7 @@ namespace AideDeJeu.ViewModels
public FilterKeys Key { get; set; }
public string Name { get; set; }
public List<KeyValuePair<string, string>> KeyValues { get; set; }
private int _Index;
public int _Index;
public int Index
{
get
@ -73,7 +74,11 @@ namespace AideDeJeu.ViewModels
{
get
{
return KeyValues[Index].Key;
if(Index >= 0 && Index < KeyValues.Count)
{
return KeyValues[Index].Key;
}
return null;
}
}
}
@ -90,12 +95,12 @@ namespace AideDeJeu.ViewModels
{
_Filters = new List<Filter>()
{
new Filter() { Key = FilterKeys.Class, Name = "Classe", KeyValues = Classes, Index = 0 },
new Filter() { Key = FilterKeys.MinLevel, Name = "Niveau Min", KeyValues = Niveaux, Index = 0 },
new Filter() { Key = FilterKeys.MaxLevel, Name = "Niveau Max", KeyValues = Niveaux, Index = 9 },
new Filter() { Key = FilterKeys.School, Name = "Ecole", KeyValues = Ecoles, Index = 0 },
new Filter() { Key = FilterKeys.Ritual, Name = "Rituel", KeyValues = Rituels, Index = 0 },
new Filter() { Key = FilterKeys.Source, Name = "Source", KeyValues = Sources, Index = 0 },
new Filter() { Key = FilterKeys.Class, Name = "Classe", KeyValues = Classes, _Index = 0 },
new Filter() { Key = FilterKeys.MinLevel, Name = "Niveau Minimum", KeyValues = Niveaux, _Index = 0 },
new Filter() { Key = FilterKeys.MaxLevel, Name = "Niveau Maximum", KeyValues = Niveaux, _Index = 9 },
new Filter() { Key = FilterKeys.School, Name = "École", KeyValues = Ecoles, _Index = 0 },
new Filter() { Key = FilterKeys.Ritual, Name = "Rituel", KeyValues = Rituels, _Index = 0 },
new Filter() { Key = FilterKeys.Source, Name = "Source", KeyValues = Sources, _Index = 0 },
};
}
return _Filters;
@ -105,12 +110,12 @@ namespace AideDeJeu.ViewModels
public override IEnumerable<Item> FilterItems(IEnumerable<Item> items)
{
var classe = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Class).SelectedKey;
var niveauMin = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MinLevel).SelectedKey;
var niveauMax = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaxLevel).SelectedKey;
var ecole = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.School).SelectedKey;
var rituel = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Ritual).SelectedKey;
var source = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Source).SelectedKey;
var classe = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Class).SelectedKey ?? "";
var niveauMin = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MinLevel).SelectedKey ?? "0";
var niveauMax = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaxLevel).SelectedKey ?? "9";
var ecole = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.School).SelectedKey ?? "";
var rituel = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Ritual).SelectedKey ?? "";
var source = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Source).SelectedKey ?? "";
return items
.Where(item =>
@ -322,13 +327,13 @@ namespace AideDeJeu.ViewModels
{
_Filters = new List<Filter>()
{
new Filter() { Key = FilterKeys.Category, Name = "Catégories", KeyValues = Categories, Index = 0 },
new Filter() { Key = FilterKeys.Type, Name = "Type", KeyValues = Types, Index = 0 },
new Filter() { Key = FilterKeys.MinPower, Name = "Challenge Min", KeyValues = Powers, Index = 0 },
new Filter() { Key = FilterKeys.MaxPower, Name = "Challenge Max", KeyValues = Powers, Index = 28 },
new Filter() { Key = FilterKeys.Size, Name = "Taille", KeyValues = Sizes, Index = 0 },
new Filter() { Key = FilterKeys.Legendary, Name = "Légendaire", KeyValues = Legendaries, Index = 0 },
new Filter() { Key = FilterKeys.Source, Name = "Source", KeyValues = Sources, Index = 0 },
//new Filter() { Key = FilterKeys.Category, Name = "Catégories", KeyValues = Categories, _Index = 0 },
new Filter() { Key = FilterKeys.Type, Name = "Type", KeyValues = Types, _Index = 0 },
new Filter() { Key = FilterKeys.MinPower, Name = "FP Minimum", KeyValues = Powers, _Index = 0 },
new Filter() { Key = FilterKeys.MaxPower, Name = "FP Maximum", KeyValues = Powers, _Index = 28 },
new Filter() { Key = FilterKeys.Size, Name = "Taille", KeyValues = Sizes, _Index = 0 },
//new Filter() { Key = FilterKeys.Legendary, Name = "Légendaire", KeyValues = Legendaries, _Index = 0 },
new Filter() { Key = FilterKeys.Source, Name = "Source", KeyValues = Sources, _Index = 0 },
};
}
return _Filters;
@ -339,13 +344,13 @@ namespace AideDeJeu.ViewModels
{
var powerComparer = new PowerComparer();
var category = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Category).SelectedKey;
var type = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Type).SelectedKey;
var minPower = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MinPower).SelectedKey;
var maxPower = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaxPower).SelectedKey;
var size = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Size).SelectedKey;
var legendary = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Legendary).SelectedKey;
var source = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Source).SelectedKey;
//var category = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Category).SelectedKey ?? "";
var type = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Type).SelectedKey ?? "";
var minPower = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MinPower).SelectedKey ?? "0 (0 PX)";
var maxPower = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaxPower).SelectedKey ?? "30 (155000 PX)";
var size = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Size).SelectedKey ?? "";
//var legendary = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Legendary).SelectedKey ?? "";
var source = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Source).SelectedKey ?? "";
return items.Where(item =>
{

View file

@ -46,9 +46,7 @@ namespace AideDeJeu.ViewModels
}
set
{
//CurrentViewModel.SearchText = "";
SetProperty(ref _ItemSourceType, value);
//CurrentViewModel.SearchText = "";
LoadItemsCommand.Execute(null);
OnPropertyChanged(nameof(Items));
}
@ -115,10 +113,9 @@ namespace AideDeJeu.ViewModels
public Command<string> SearchCommand { get; private set; }
public Navigator Navigator { get; set; }
public MainViewModel()
{
//Spells = new SpellsViewModel(navigator, Items);
//Monsters = new MonstersViewModel(navigator, Items);
LoadItemsCommand = new Command(() =>
{
GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand();
@ -129,7 +126,7 @@ namespace AideDeJeu.ViewModels
SwitchToVF = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.VO & ~ItemSourceType.HD) | ItemSourceType.VF);
SwitchToVO = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.VF & ~ItemSourceType.HD) | ItemSourceType.VO);
SwitchToHD = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.VF & ~ItemSourceType.VO) | ItemSourceType.HD);
//AboutCommand = new Command(async() => await navigator.GotoAboutPageAsync());
AboutCommand = new Command(async() => await Main.Navigator.GotoAboutPageAsync());
SearchCommand = new Command<string>((text) =>
{
GetFilterViewModel(ItemSourceType).SearchText = text;

View file

@ -6,68 +6,18 @@
x:Class="AideDeJeu.Views.MainPage"
x:Name="This"
IsPresented="False"
Title="{Binding ItemsType,Converter={StaticResource ItemTypeToStringConverter}}">
Title="{Binding ItemSourceType,Converter={StaticResource ItemSourceTypeToTitleConverter}}">
<MasterDetailPage.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="SpellsMasterDataTemplate">
<ScrollView Orientation="Vertical">
<StackLayout Orientation="Vertical" Padding="15">
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Classe}" />
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.NiveauMin}" />
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.NiveauMax}" />
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Ecole}" />
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Rituel}" />
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Source}" IsEnabled="False" />
</StackLayout>
</ScrollView>
</ControlTemplate>
<ControlTemplate x:Key="MonstersMasterDataTemplate">
<ScrollView Orientation="Vertical">
<StackLayout Orientation="Vertical" Padding="15">
<Label Text="Type" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Type}" />
<StackLayout Orientation="Horizontal">
<StackLayout Orientation="Vertical">
<Label Text="FP minimum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.MinPower}" />
</StackLayout>
<StackLayout Orientation="Vertical">
<Label Text="FP maximum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.MaxPower}" />
</StackLayout>
</StackLayout>
<Label Text="Taille" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Size}" />
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Source}" IsEnabled="False"/>
</StackLayout>
</ScrollView>
</ControlTemplate>
<tools:ItemTypeToStringConverter
x:Key="ItemTypeToStringConverter"
Spells="Sorts"
Monsters="Monstres" />
<tools:ItemsTypeTemplateConverter
x:Key="ItemsTypeTemplateConverter"
SpellsTemplate="{StaticResource SpellsMasterDataTemplate}"
MonstersTemplate="{StaticResource MonstersMasterDataTemplate}" />
<tools:ItemSourceTypeToStringConverter
x:Key="ItemSourceTypeToTitleConverter"
SpellVF="Sorts"
SpellVO="Spells"
SpellHD="Sorts (H&amp;D)"
MonsterVF="Monstres"
MonsterVO="Monsters"
MonsterHD="Créatures (H&amp;D)"
/>
<tools:ItemSourceTypeToItemsConverter
x:Key="ItemSourceTypeToItemsConverter" />
<tools:ItemSourceTypeToFilterConverter