mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Switch VF/VO/H&D
This commit is contained in:
		
							parent
							
								
									64e236bb8f
								
							
						
					
					
						commit
						37198340ec
					
				
					 3 changed files with 39 additions and 14 deletions
				
			
		|  | @ -37,7 +37,7 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|     public class MainViewModel : BaseViewModel |     public class MainViewModel : BaseViewModel | ||||||
|     { |     { | ||||||
|         private ItemSourceType _ItemSourceType = ItemSourceType.SpellVF; |         private ItemSourceType _ItemSourceType = ItemSourceType.SpellHD; | ||||||
|         public ItemSourceType ItemSourceType |         public ItemSourceType ItemSourceType | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|  | @ -49,8 +49,8 @@ namespace AideDeJeu.ViewModels | ||||||
|                 //CurrentViewModel.SearchText = ""; |                 //CurrentViewModel.SearchText = ""; | ||||||
|                 SetProperty(ref _ItemSourceType, value); |                 SetProperty(ref _ItemSourceType, value); | ||||||
|                 //CurrentViewModel.SearchText = ""; |                 //CurrentViewModel.SearchText = ""; | ||||||
|  |                 LoadItemsCommand.Execute(null); | ||||||
|                 OnPropertyChanged(nameof(Items)); |                 OnPropertyChanged(nameof(Items)); | ||||||
|                 //LoadItemsCommand.Execute(null); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -73,7 +73,12 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|         public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>() |         public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>() | ||||||
|         { |         { | ||||||
|             { ItemSourceType.SpellVF, new Lazy<ItemsViewModel>(() => new SpellsViewModel()) }, |             { ItemSourceType.SpellVF, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellVF)) }, | ||||||
|  |             { ItemSourceType.SpellVO, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellVO)) }, | ||||||
|  |             { ItemSourceType.SpellHD, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellHD)) }, | ||||||
|  |             { ItemSourceType.MonsterVF, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) }, | ||||||
|  |             { ItemSourceType.MonsterVO, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) }, | ||||||
|  |             { ItemSourceType.MonsterHD, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) }, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType) |         public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType) | ||||||
|  | @ -84,6 +89,8 @@ namespace AideDeJeu.ViewModels | ||||||
|         public Dictionary<ItemSourceType, Lazy<FilterViewModel>> AllFiltersViewModel = new Dictionary<ItemSourceType, Lazy<FilterViewModel>>() |         public Dictionary<ItemSourceType, Lazy<FilterViewModel>> AllFiltersViewModel = new Dictionary<ItemSourceType, Lazy<FilterViewModel>>() | ||||||
|         { |         { | ||||||
|             { ItemSourceType.SpellVF, new Lazy<FilterViewModel>(() => new VFSpellFilterViewModel()) }, |             { ItemSourceType.SpellVF, new Lazy<FilterViewModel>(() => new VFSpellFilterViewModel()) }, | ||||||
|  |             { ItemSourceType.SpellVO, new Lazy<FilterViewModel>(() => new VOSpellFilterViewModel()) }, | ||||||
|  |             { ItemSourceType.SpellHD, new Lazy<FilterViewModel>(() => new HDSpellFilterViewModel()) }, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType) |         public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType) | ||||||
|  | @ -137,6 +144,9 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|         public Command SwitchToSpells { get; private set; } |         public Command SwitchToSpells { get; private set; } | ||||||
|         public Command SwitchToMonsters { get; private set; } |         public Command SwitchToMonsters { get; private set; } | ||||||
|  |         public Command SwitchToVF { get; private set; } | ||||||
|  |         public Command SwitchToVO { get; private set; } | ||||||
|  |         public Command SwitchToHD { get; private set; } | ||||||
|         public Command AboutCommand { get; private set; } |         public Command AboutCommand { get; private set; } | ||||||
|         public Command<string> SearchCommand { get; private set; } |         public Command<string> SearchCommand { get; private set; } | ||||||
| 
 | 
 | ||||||
|  | @ -145,10 +155,13 @@ namespace AideDeJeu.ViewModels | ||||||
|         { |         { | ||||||
|             //Spells = new SpellsViewModel(navigator, Items); |             //Spells = new SpellsViewModel(navigator, Items); | ||||||
|             //Monsters = new MonstersViewModel(navigator, Items); |             //Monsters = new MonstersViewModel(navigator, Items); | ||||||
|             LoadItemsCommand = new Command(async () => GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand(GetFilterViewModel(ItemSourceType))); |             LoadItemsCommand = new Command(() => GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand(GetFilterViewModel(ItemSourceType))); | ||||||
|             GotoItemCommand = new Command<Item>(async (item) => await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item)); |             GotoItemCommand = new Command<Item>(async (item) => await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item)); | ||||||
|             SwitchToSpells = new Command(() => ItemSourceType = (ItemSourceType & ~ ItemSourceType.Monster) | ItemSourceType.Spell); |             SwitchToSpells = new Command(() => ItemSourceType = (ItemSourceType & ~ ItemSourceType.Monster) | ItemSourceType.Spell); | ||||||
|             SwitchToMonsters = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.Spell) | ItemSourceType.Monster); |             SwitchToMonsters = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.Spell) | ItemSourceType.Monster); | ||||||
|  |             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 navigator.GotoAboutPageAsync()); | ||||||
|             //SearchCommand = new Command<string>((text) => GetItemsViewModel(ItemSourceType).SearchText = text); |             //SearchCommand = new Command<string>((text) => GetItemsViewModel(ItemSourceType).SearchText = text); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -14,6 +14,11 @@ namespace AideDeJeu.ViewModels | ||||||
| { | { | ||||||
|     public class SpellsViewModel : ItemsViewModel |     public class SpellsViewModel : ItemsViewModel | ||||||
|     { |     { | ||||||
|  |         ItemSourceType ItemSourceType; | ||||||
|  |         public SpellsViewModel(ItemSourceType itemSourceType) | ||||||
|  |         { | ||||||
|  |             this.ItemSourceType = itemSourceType; | ||||||
|  |         } | ||||||
|         private IEnumerable<Spell> _AllSpells = null; |         private IEnumerable<Spell> _AllSpells = null; | ||||||
|         private IEnumerable<Spell> AllSpells |         private IEnumerable<Spell> AllSpells | ||||||
|         { |         { | ||||||
|  | @ -21,16 +26,20 @@ namespace AideDeJeu.ViewModels | ||||||
|             { |             { | ||||||
|                 if(_AllSpells == null) |                 if(_AllSpells == null) | ||||||
|                 { |                 { | ||||||
|                     _AllSpells = Tools.Helpers.GetResourceObject<IEnumerable<Spell>>("AideDeJeu.Data.spells_vf.json"); |                     string resourceName = null; | ||||||
|                     //var serializer = new DataContractJsonSerializer(typeof(IEnumerable<Spell>)); |                     switch(ItemSourceType) | ||||||
|                     //var assembly = typeof(AboutViewModel).GetTypeInfo().Assembly; |                     { | ||||||
|                     ////var names = assembly.GetManifestResourceNames(); |                         case ItemSourceType.SpellVF: | ||||||
|                     ////using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_hd.json")) |                             resourceName = "AideDeJeu.Data.spells_vf.json"; | ||||||
|                     //using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vf.json")) |                             break; | ||||||
|                     ////using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vo.json")) |                         case ItemSourceType.SpellVO: | ||||||
|                     //{ |                             resourceName = "AideDeJeu.Data.spells_vo.json"; | ||||||
|                     //    _AllSpells = serializer.ReadObject(stream) as IEnumerable<Spell>; |                             break; | ||||||
|                     //} |                         case ItemSourceType.SpellHD: | ||||||
|  |                             resourceName = "AideDeJeu.Data.spells_hd.json"; | ||||||
|  |                             break; | ||||||
|  |                     } | ||||||
|  |                     _AllSpells = Tools.Helpers.GetResourceObject<IEnumerable<Spell>>(resourceName); | ||||||
|                 } |                 } | ||||||
|                 return _AllSpells; |                 return _AllSpells; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | @ -87,6 +87,9 @@ | ||||||
|                         <ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="spell_book.png" Command="{Binding SwitchToSpells}" /> |                         <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="Monsters" Text="Monstres" Order="Primary" Icon="dragon_head.png" Command="{Binding SwitchToMonsters}" /> | ||||||
|                         <ToolbarItem Name="About" Text="À propos de..." Order="Primary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" /> |                         <ToolbarItem Name="About" Text="À propos de..." Order="Primary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" /> | ||||||
|  |                         <ToolbarItem Name="VF" Text="VF AideDD" Order="Secondary" Command="{Binding SwitchToVF}" /> | ||||||
|  |                         <ToolbarItem Name="VO" Text="VO AideDD/SRD" Order="Secondary" Command="{Binding SwitchToVO}" /> | ||||||
|  |                         <ToolbarItem Name="HD" Text="VF H&D" Order="Secondary" Command="{Binding SwitchToHD}" /> | ||||||
|                     </ContentPage.ToolbarItems> |                     </ContentPage.ToolbarItems> | ||||||
|                     <StackLayout Orientation="Vertical"> |                     <StackLayout Orientation="Vertical"> | ||||||
|                         <SearchBar x:Name="SearchBar" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}"> |                         <SearchBar x:Name="SearchBar" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}"> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez