From 4be95a08ecf3030c8e7257f4199bde9e1d42cdcc Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Tue, 14 Jan 2025 15:38:01 +0100 Subject: [PATCH] Changes --- LocalStorageHelperHolder.cs | 15 ++++ Microsoft.Devices.Sensors/Accelerometer.cs | 10 +++ .../AccelerometerFailedException.cs | 6 ++ .../AccelerometerReading.cs | 12 ++++ Microsoft.Devices.Sensors/ISensorReading.cs | 10 +++ Microsoft.Devices.Sensors/SensorBase.cs | 15 ++++ .../SensorFailedException.cs | 8 +++ .../SensorReadingEventArgs.cs | 10 +++ .../Guide.cs | 13 ++++ .../TrialMode.cs | 70 +++++++++++++++++++ Pages/Index.razor.cs | 2 + Program.cs | 6 +- WindowsPhoneSpeedyBlupi | 2 +- WindowsPhoneSpeedyBlupi.csproj | 60 +++++++++------- 14 files changed, 213 insertions(+), 26 deletions(-) create mode 100644 LocalStorageHelperHolder.cs create mode 100644 Microsoft.Devices.Sensors/Accelerometer.cs create mode 100644 Microsoft.Devices.Sensors/AccelerometerFailedException.cs create mode 100644 Microsoft.Devices.Sensors/AccelerometerReading.cs create mode 100644 Microsoft.Devices.Sensors/ISensorReading.cs create mode 100644 Microsoft.Devices.Sensors/SensorBase.cs create mode 100644 Microsoft.Devices.Sensors/SensorFailedException.cs create mode 100644 Microsoft.Devices.Sensors/SensorReadingEventArgs.cs create mode 100644 Microsoft.Xna.Framework.GamerServices/Guide.cs create mode 100644 Microsoft.Xna.Framework.GamerServices/TrialMode.cs diff --git a/LocalStorageHelperHolder.cs b/LocalStorageHelperHolder.cs new file mode 100644 index 0000000..aeae45f --- /dev/null +++ b/LocalStorageHelperHolder.cs @@ -0,0 +1,15 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.DependencyInjection; + +namespace WindowsPhoneSpeedyBlupi +{ + public class LocalStorageHelperHolder + { + public static LocalStorageHelper LocalStorageHelper { get; set; } + + } +} diff --git a/Microsoft.Devices.Sensors/Accelerometer.cs b/Microsoft.Devices.Sensors/Accelerometer.cs new file mode 100644 index 0000000..2856b67 --- /dev/null +++ b/Microsoft.Devices.Sensors/Accelerometer.cs @@ -0,0 +1,10 @@ +using Microsoft.Devices.Sensors; + +namespace Microsoft.Devices.Sensors +{ + public class Accelerometer : SensorBase + { + public void Start() { } + public void Stop() { } + } +} diff --git a/Microsoft.Devices.Sensors/AccelerometerFailedException.cs b/Microsoft.Devices.Sensors/AccelerometerFailedException.cs new file mode 100644 index 0000000..e125b68 --- /dev/null +++ b/Microsoft.Devices.Sensors/AccelerometerFailedException.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Devices.Sensors +{ + public class AccelerometerFailedException : SensorFailedException + { + } +} diff --git a/Microsoft.Devices.Sensors/AccelerometerReading.cs b/Microsoft.Devices.Sensors/AccelerometerReading.cs new file mode 100644 index 0000000..48663e8 --- /dev/null +++ b/Microsoft.Devices.Sensors/AccelerometerReading.cs @@ -0,0 +1,12 @@ +using System; +using Microsoft.Xna.Framework; + +namespace Microsoft.Devices.Sensors + +{ + public struct AccelerometerReading : ISensorReading + { + public Vector3 Acceleration { get; internal set; } + public DateTimeOffset Timestamp { get; internal set; } + } +} diff --git a/Microsoft.Devices.Sensors/ISensorReading.cs b/Microsoft.Devices.Sensors/ISensorReading.cs new file mode 100644 index 0000000..02cc293 --- /dev/null +++ b/Microsoft.Devices.Sensors/ISensorReading.cs @@ -0,0 +1,10 @@ +using System; + +namespace Microsoft.Devices.Sensors + +{ + public interface ISensorReading + { + DateTimeOffset Timestamp { get; } + } +} diff --git a/Microsoft.Devices.Sensors/SensorBase.cs b/Microsoft.Devices.Sensors/SensorBase.cs new file mode 100644 index 0000000..d82bdd0 --- /dev/null +++ b/Microsoft.Devices.Sensors/SensorBase.cs @@ -0,0 +1,15 @@ +using System; + +namespace Microsoft.Devices.Sensors +{ + public abstract class SensorBase : IDisposable where TSensorReading : ISensorReading + { + private TSensorReading currentValue; + + public event EventHandler> CurrentValueChanged; + + public void Dispose() + { + } + } +} \ No newline at end of file diff --git a/Microsoft.Devices.Sensors/SensorFailedException.cs b/Microsoft.Devices.Sensors/SensorFailedException.cs new file mode 100644 index 0000000..4eb2813 --- /dev/null +++ b/Microsoft.Devices.Sensors/SensorFailedException.cs @@ -0,0 +1,8 @@ +using System; + +namespace Microsoft.Devices.Sensors +{ + public class SensorFailedException : Exception + { + } +} diff --git a/Microsoft.Devices.Sensors/SensorReadingEventArgs.cs b/Microsoft.Devices.Sensors/SensorReadingEventArgs.cs new file mode 100644 index 0000000..81f4627 --- /dev/null +++ b/Microsoft.Devices.Sensors/SensorReadingEventArgs.cs @@ -0,0 +1,10 @@ +using System; + +namespace Microsoft.Devices.Sensors +{ + + public class SensorReadingEventArgs : EventArgs where T : ISensorReading + { + public T SensorReading { get; set; } + } +} \ No newline at end of file diff --git a/Microsoft.Xna.Framework.GamerServices/Guide.cs b/Microsoft.Xna.Framework.GamerServices/Guide.cs new file mode 100644 index 0000000..51f291d --- /dev/null +++ b/Microsoft.Xna.Framework.GamerServices/Guide.cs @@ -0,0 +1,13 @@ +using System.Diagnostics; + +namespace Microsoft.Xna.Framework.GamerServices +{ + public static class Guide + { + public static void Show(PlayerIndex playerIndex) + { + Debug.Write("The Market Place should now be shown."); + } + public static bool IsTrialMode { get; set; } + } +} diff --git a/Microsoft.Xna.Framework.GamerServices/TrialMode.cs b/Microsoft.Xna.Framework.GamerServices/TrialMode.cs new file mode 100644 index 0000000..e4d54b8 --- /dev/null +++ b/Microsoft.Xna.Framework.GamerServices/TrialMode.cs @@ -0,0 +1,70 @@ +using System; +using System.IO; + +namespace Xna.Framework.GamerServices +{ + internal class TrialMode + { + private static DateTime trialStartTime; + + public static void InitializeTrialMode() + { + // Assuming trial mode starts when the game is launched + trialStartTime = DateTime.Now; + } + + public static bool IsTrialModeExpired() + { + return IsTrialMode7DaysLimitExpired() || IsTrialMode10MinutesLimitExpired(); + } + private static bool IsTrialMode10MinutesLimitExpired() + { + // Example: Trial expires after 10 minutes + var expired = (DateTime.Now - trialStartTime).TotalMinutes > 10; + return expired; + } + private static bool IsTrialMode7DaysLimitExpired() + { + // Save trial expiration status to a file or settings + const string TRIAL_END_TIME_TXT = "trialEndTime.txt"; + var trialEndTime = File.Exists(TRIAL_END_TIME_TXT) ? DateTime.Parse(File.ReadAllText(TRIAL_END_TIME_TXT)) : DateTime.MinValue; + + var expired = trialEndTime != DateTime.MinValue && DateTime.Now > trialEndTime; + if (expired) + { + return true; // Trial period is over + } + + // Example of setting trial end time (e.g., 7 days from now) + if (!File.Exists(TRIAL_END_TIME_TXT)) + { + File.WriteAllText(TRIAL_END_TIME_TXT, DateTime.Now.AddDays(7).ToString()); + } + + return false; // Trial period still active + } + private static int trialModeEnabled = -1; + public static bool IsTrialModeEnabled() + { + if (trialModeEnabled == 1) + { + return true; + } + + if (trialModeEnabled == 0) + { + return false; + } + + const string TRIAL_MODE_ENABLED_TXT = "trialModeEnabled.txt"; + var trialModeEnabledString = File.Exists(TRIAL_MODE_ENABLED_TXT) ? File.ReadAllText(TRIAL_MODE_ENABLED_TXT) : "0"; + var trialModeEnabledLocal = trialModeEnabledString.Equals("1"); + trialModeEnabled = trialModeEnabledLocal ? 1 : 0; + + return trialModeEnabledLocal; + } + + + } + +} \ No newline at end of file diff --git a/Pages/Index.razor.cs b/Pages/Index.razor.cs index 32560c1..9f116cf 100644 --- a/Pages/Index.razor.cs +++ b/Pages/Index.razor.cs @@ -1,6 +1,7 @@ using System; using Microsoft.JSInterop; using Microsoft.Xna.Framework; +using static WindowsPhoneSpeedyBlupi.EnvClasses; namespace WindowsPhoneSpeedyBlupi.Pages { @@ -24,6 +25,7 @@ namespace WindowsPhoneSpeedyBlupi.Pages // init game if (_game == null) { + Env.init(Impl.KNI, Platform.Web); _game = new Game1(); _game.Run(); } diff --git a/Program.cs b/Program.cs index 9659fc5..3574d1c 100644 --- a/Program.cs +++ b/Program.cs @@ -18,7 +18,11 @@ namespace WindowsPhoneSpeedyBlupi { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); - await builder.Build().RunAsync(); + //builder.Services.AddSingleton(); + var app = builder.Build(); + //LocalStorageHelper localStorageHelper = app.Services.GetRequiredService(); + //LocalStorageHelperHolder.LocalStorageHelper = localStorageHelper; + await app.RunAsync(); } } } diff --git a/WindowsPhoneSpeedyBlupi b/WindowsPhoneSpeedyBlupi index ea5dabf..99910d4 160000 --- a/WindowsPhoneSpeedyBlupi +++ b/WindowsPhoneSpeedyBlupi @@ -1 +1 @@ -Subproject commit ea5dabf84b7b035870583d525736711c61c46ad3 +Subproject commit 99910d425d9f3b77bf5287ee41d278f278322ccd diff --git a/WindowsPhoneSpeedyBlupi.csproj b/WindowsPhoneSpeedyBlupi.csproj index c06307a..45f8024 100644 --- a/WindowsPhoneSpeedyBlupi.csproj +++ b/WindowsPhoneSpeedyBlupi.csproj @@ -17,9 +17,11 @@ + KNI;WEB + KNI;WEB @@ -29,32 +31,38 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + @@ -405,4 +413,8 @@ + + + +