Changement de l'affichage des messages en jeu

master
cldupland 5 years ago
parent d8f815fa8e
commit 5d2df0423c

@ -1,11 +1,11 @@
#pragma warning disable 1591 #pragma warning disable 1591
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Ce code a été généré par un outil. // This code was generated by a tool.
// Version du runtime :4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si // Changes to this file may cause incorrect behavior and will be lost if
// le code est régénéré. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -0,0 +1,30 @@
using System;
using System.Collections;
using Android.App;
using Android.Views;
using Android.Widget;
using TheGameExtreme.Droid.Services;
using TheGameExtreme.Interface;
[assembly: Xamarin.Forms.Dependency(typeof(MessageAndroid))]
namespace TheGameExtreme.Droid.Services
{
public class MessageAndroid : IMessage
{
public IDictionary Properties => throw new NotImplementedException();
public void LongAlert(string message)
{
Toast toast = Toast.MakeText(Application.Context, message, ToastLength.Long);
toast.SetGravity(GravityFlags.Center | GravityFlags.Center, 0, 0);
toast.Show();
}
public void ShortAlert(string message)
{
Toast toast = Toast.MakeText(Application.Context, message, ToastLength.Short);
toast.SetGravity(GravityFlags.Center | GravityFlags.Center, 0, 0);
toast.Show();
}
}
}

@ -74,6 +74,7 @@
<Compile Include="MainActivity.cs" /> <Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\MessageAndroid.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\AboutResources.txt" /> <None Include="Resources\AboutResources.txt" />
@ -111,6 +112,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Assets\fonts\" /> <Folder Include="Assets\fonts\" />
<Folder Include="Services\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\drawable\EngrenageV1.png" /> <AndroidResource Include="Resources\drawable\EngrenageV1.png" />

@ -77,6 +77,7 @@
<None Include="Info.plist" /> <None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<BundleResource Include="TrierImageB.ico" /> <BundleResource Include="TrierImageB.ico" />
<Compile Include="Services\MessageIOS.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json"> <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json">
@ -186,4 +187,7 @@
<BundleResource Include="Resources\Elsole.png" /> <BundleResource Include="Resources\Elsole.png" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
</Project> </Project>

@ -0,0 +1,51 @@
using System;
using System.Collections;
using Foundation;
using TheGameExtreme.Interface;
using TheGameExtreme.iOS.Services;
using UIKit;
[assembly: Xamarin.Forms.Dependency(typeof(MessageIOS))]
namespace TheGameExtreme.iOS.Services
{
public class MessageIOS : IMessage
{
const double LONG_DELAY = 3.5;
const double SHORT_DELAY = 2.0;
public void LongAlert(string message)
{
ShowAlert(message, LONG_DELAY);
}
public void ShortAlert(string message)
{
ShowAlert(message, SHORT_DELAY);
}
void ShowAlert(string message, double seconds)
{
var alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert);
var alertDelay = NSTimer.CreateScheduledTimer(seconds, obj =>
{
DismissMessage(alert, obj);
});
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null);
}
void DismissMessage(UIAlertController alert, NSTimer alertDelay)
{
if (alert != null)
{
alert.DismissViewController(true, null);
}
if (alertDelay != null)
{
alertDelay.Dispose();
}
}
}
}

@ -0,0 +1,10 @@
using System;
namespace TheGameExtreme.Interface
{
public interface IMessage
{
void LongAlert(string message);
void ShortAlert(string message);
}
}

@ -34,6 +34,7 @@
<Folder Include="model\gameActions\decimals\" /> <Folder Include="model\gameActions\decimals\" />
<Folder Include="model\gameActions\abstractRules\" /> <Folder Include="model\gameActions\abstractRules\" />
<Folder Include="model\gameActions\fraction\" /> <Folder Include="model\gameActions\fraction\" />
<Folder Include="Interface\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="model\effect\StopColm.cs" /> <Compile Remove="model\effect\StopColm.cs" />

@ -2,6 +2,7 @@
using Xamarin.Forms; using Xamarin.Forms;
using TheGameExtreme.IO; using TheGameExtreme.IO;
using TheGameExtreme.Resx; using TheGameExtreme.Resx;
using TheGameExtreme.Interface;
namespace TheGameExtreme.view namespace TheGameExtreme.view
{ {
@ -22,9 +23,9 @@ namespace TheGameExtreme.view
await Navigation.PushAsync(new GamePreparationPage()); await Navigation.PushAsync(new GamePreparationPage());
} }
private async void OpenMultiPlayerMode(object sender, EventArgs args) private void OpenMultiPlayerMode(object sender, EventArgs args)
{ {
await DisplayAlert("Mode en cours de développement", null, "Fermer"); DependencyService.Get<IMessage>().ShortAlert("Mode en cours de développement");
//await Navigation.PushAsync(new MultiPlayerMode()); //await Navigation.PushAsync(new MultiPlayerMode());
} }

@ -9,6 +9,7 @@ using TouchTracking;
using Xamarin.Essentials; using Xamarin.Essentials;
using TheGameExtreme.Resx; using TheGameExtreme.Resx;
using TheGameExtreme.model.card.cardType; using TheGameExtreme.model.card.cardType;
using TheGameExtreme.Interface;
namespace TheGameExtreme.view namespace TheGameExtreme.view
{ {
@ -84,7 +85,7 @@ namespace TheGameExtreme.view
{ {
if (viewmodel.Alert != null) if (viewmodel.Alert != null)
{ {
DisplayAlert("😆", viewmodel.Alert, "OK"); DependencyService.Get<IMessage>().ShortAlert(viewmodel.Alert);
viewmodel.Alert = null; viewmodel.Alert = null;
} }
} }

Loading…
Cancel
Save