mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Liens inter sorts <-> monstres qui fonctionnent :)
This commit is contained in:
		
							parent
							
								
									9828c9afe5
								
							
						
					
					
						commit
						5f6422bc3e
					
				
					 2 changed files with 55 additions and 2 deletions
				
			
		|  | @ -81,11 +81,11 @@ | ||||||
| 
 | 
 | ||||||
|             <Label Text="Capacités" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" /> |             <Label Text="Capacités" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" /> | ||||||
|             <!--<Label FormattedText="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />--> |             <!--<Label FormattedText="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />--> | ||||||
|             <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}"  IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" /> |             <mdview:MarkdownView x:Name="mdSpecialFeatures" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}"  IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" /> | ||||||
| 
 | 
 | ||||||
|             <Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" /> |             <Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" /> | ||||||
|             <!--<Label FormattedText="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />--> |             <!--<Label FormattedText="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />--> | ||||||
|             <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" /> |             <mdview:MarkdownView x:Name="mdActions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" /> | ||||||
| 
 | 
 | ||||||
|             <Label Text="Réactions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" /> |             <Label Text="Réactions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" /> | ||||||
|             <!--<Label FormattedText="{Binding Item.Reactions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />--> |             <!--<Label FormattedText="{Binding Item.Reactions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />--> | ||||||
|  |  | ||||||
|  | @ -4,8 +4,14 @@ using AideDeJeuLib.Monsters; | ||||||
| using SkiaSharp; | using SkiaSharp; | ||||||
| using SkiaSharp.Views.Forms; | using SkiaSharp.Views.Forms; | ||||||
| using System; | using System; | ||||||
|  | using System.Text.RegularExpressions; | ||||||
|  | using System.Threading.Tasks; | ||||||
| using Xamarin.Forms; | using Xamarin.Forms; | ||||||
| using Xamarin.Forms.Xaml; | using Xamarin.Forms.Xaml; | ||||||
|  | using System.Linq; | ||||||
|  | using AideDeJeuLib.Spells; | ||||||
|  | using System.Text; | ||||||
|  | using System.Globalization; | ||||||
| 
 | 
 | ||||||
| namespace AideDeJeu.Views | namespace AideDeJeu.Views | ||||||
| { | { | ||||||
|  | @ -19,8 +25,55 @@ namespace AideDeJeu.Views | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
| 
 | 
 | ||||||
|             BindingContext = this.viewModel = viewModel; |             BindingContext = this.viewModel = viewModel; | ||||||
|  | 
 | ||||||
|  |             mdSpecialFeatures.NavigateToLink = async(s) => await NavigateToLink(s); | ||||||
|  |             mdActions.NavigateToLink = async (s) => await NavigateToLink(s); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public async Task NavigateToLink(string s) | ||||||
|  |         { | ||||||
|  |             var regex = new Regex("/(?<file>.*)\\.md#(?<anchor>.*)"); | ||||||
|  |             var match = regex.Match(s); | ||||||
|  |             var file = match.Groups["file"].Value; | ||||||
|  |             var anchor = match.Groups["anchor"].Value; | ||||||
|  |             if (file == "spells_hd") | ||||||
|  |             { | ||||||
|  |                 var spells = await viewModel.Main.GetItemsViewModel(ItemSourceType.SpellHD).GetAllItemsAsync(); | ||||||
|  |                 var spell = spells.Where(i => IdFromName(i.Id) == anchor).FirstOrDefault(); | ||||||
|  |                 var page = new SpellDetailPage(new SpellDetailViewModel(spell as Spell)); | ||||||
|  |                 await Navigation.PushAsync(page); | ||||||
|  |             } | ||||||
|  |             else if (file == "monsters_hd") | ||||||
|  |             { | ||||||
|  |                 var monsters = await viewModel.Main.GetItemsViewModel(ItemSourceType.MonsterHD).GetAllItemsAsync(); | ||||||
|  |                 var monster = monsters.Where(i => IdFromName(i.Id) == anchor).FirstOrDefault(); | ||||||
|  |                 var page = new MonsterDetailPage(new MonsterDetailViewModel(monster as Monster)); | ||||||
|  |                 await Navigation.PushAsync(page); | ||||||
|  |             } | ||||||
|  |             //Device.OpenUri(new Uri(s)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public static string Capitalize(string text) | ||||||
|  |         { | ||||||
|  |             return string.Concat(text.Take(1)).ToUpper() + string.Concat(text.Skip(1)).ToString().ToLower(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public static string RemoveDiacritics(string text) | ||||||
|  |         { | ||||||
|  |             if (string.IsNullOrWhiteSpace(text)) | ||||||
|  |                 return text; | ||||||
|  | 
 | ||||||
|  |             text = text.Normalize(NormalizationForm.FormD); | ||||||
|  |             var chars = text.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray(); | ||||||
|  |             return new string(chars).Normalize(NormalizationForm.FormC); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         static string IdFromName(string name) | ||||||
|  |         { | ||||||
|  |             return RemoveDiacritics(name.ToLower().Replace(" ", "-")); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|         public MonsterDetailPage() |         public MonsterDetailPage() | ||||||
|         { |         { | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez