Преглед на файлове

Refactor to make project more structured for cross-platform development and using 3.8.*

CartBlanche преди 2 седмици
родител
ревизия
c00bd14dd0
променени са 28 файла, в които са добавени 590 реда и са изтрити 217 реда
  1. 35 0
      BatteryStatus/.vscode/launch.json
  2. 52 0
      BatteryStatus/.vscode/tasks.json
  3. 0 107
      BatteryStatus/BatteryStatus.iOS.csproj
  4. 43 0
      BatteryStatus/BatteryStatus.sln
  5. 0 0
      BatteryStatus/Core/Content/Default.png
  6. 0 0
      BatteryStatus/Core/Content/SpriteFont1.xnb
  7. 49 0
      BatteryStatus/Core/Game1.cs
  8. 0 84
      BatteryStatus/Game1.cs
  9. 9 0
      BatteryStatus/Platforms/Android/AndroidManifest.xml
  10. 24 0
      BatteryStatus/Platforms/Android/BatteryStatus.Android.csproj
  11. 30 0
      BatteryStatus/Platforms/Android/MainActivity.cs
  12. 77 0
      BatteryStatus/Platforms/Android/PowerStatus.cs
  13. BIN
      BatteryStatus/Platforms/Android/Resources/Drawable/AscentGame.ico
  14. BIN
      BatteryStatus/Platforms/Android/Resources/Drawable/Icon.png
  15. 4 0
      BatteryStatus/Platforms/Android/Resources/Values/Strings.xml
  16. 23 0
      BatteryStatus/Platforms/DesktopGL/BatteryStatus.DesktopGL.csproj
  17. 10 0
      BatteryStatus/Platforms/DesktopGL/PowerStatus.cs
  18. 14 0
      BatteryStatus/Platforms/DesktopGL/Program.cs
  19. 24 0
      BatteryStatus/Platforms/Windows/BatteryStatus.Windows.csproj
  20. 12 0
      BatteryStatus/Platforms/Windows/PowerStatus.cs
  21. 14 0
      BatteryStatus/Platforms/Windows/Program.cs
  22. 18 0
      BatteryStatus/Platforms/iOS/AppDelegate.cs
  23. 23 0
      BatteryStatus/Platforms/iOS/BatteryStatus.iOS.csproj
  24. 22 0
      BatteryStatus/Platforms/iOS/Info.plist
  25. 56 0
      BatteryStatus/Platforms/iOS/PowerStatus.cs
  26. 13 0
      BatteryStatus/Platforms/iOS/Program.cs
  27. 38 0
      BatteryStatus/README.md
  28. 0 26
      BatteryStatus/main.cs

+ 35 - 0
BatteryStatus/.vscode/launch.json

@@ -0,0 +1,35 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Windows",
+            "type": "coreclr",
+            "request": "launch",
+            "preLaunchTask": "build-windows",
+            "program": "${workspaceFolder}/Platforms/Windows/bin/Debug/net8.0-windows/BatteryStatus.Windows.exe",
+            "args": [],
+            "cwd": "${workspaceFolder}/Platforms/Windows",
+            "stopAtEntry": false,
+            "console": "internalConsole"
+        },
+        {
+            "name": "DesktopGL",
+            "type": "coreclr",
+            "request": "launch",
+            "preLaunchTask": "build-desktopgl",
+            "program": "${workspaceFolder}/Platforms/DesktopGL/bin/Debug/net8.0/BatteryStatus.DesktopGL.exe",
+            "args": [],
+            "cwd": "${workspaceFolder}/Platforms/DesktopGL",
+            "stopAtEntry": false,
+            "console": "internalConsole"
+        },
+        {
+            "name": "Android",
+            "type": "mono",
+            "request": "attach",
+            "address": "localhost",
+            "port": 10000,
+			"preLaunchTask": "debug-android"
+        }
+    ]
+}

+ 52 - 0
BatteryStatus/.vscode/tasks.json

@@ -0,0 +1,52 @@
+{
+    "version": "2.0.0",
+    "tasks": [
+        {
+            "label": "build-windows",
+            "command": "dotnet",
+            "type": "process",
+            "args": [
+                "build",
+                "Platforms/Windows/BatteryStatus.Windows.csproj"
+            ],
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "build-desktopgl",
+            "command": "dotnet",
+            "type": "process",
+            "args": [
+                "build",
+                "Platforms/DesktopGL/BatteryStatus.DesktopGL.csproj"
+            ],
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "run-windows",
+            "command": "dotnet",
+            "type": "process",
+            "args": [
+                "run",
+                "--project",
+                "Platforms/Windows/BatteryStatus.Windows.csproj"
+            ],
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "run-desktopgl",
+            "command": "dotnet",
+            "type": "process",
+            "args": [
+                "run",
+                "--project",
+                "Platforms/DesktopGL/BatteryStatus.DesktopGL.csproj"
+            ],
+            "problemMatcher": "$msCompile"
+        },
+        {
+			"label": "debug-android",
+			"type": "shell",
+			"command": "dotnet build -p:Configuration=Debug ${workspaceFolder}/Platforms/Android/BatteryStatus.Android.csproj \"/t:Install\" /p:AndroidAttachDebugger=true /p:AndroidSdbHostPort=10000"
+		}
+    ]
+}

+ 0 - 107
BatteryStatus/BatteryStatus.iOS.csproj

@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{B1E27EDB-2AC5-4A8A-8FD2-29CEEBDF3344}</ProjectGuid>
-    <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <OutputType>Exe</OutputType>
-    <RootNamespace>MonoGame.Samples.BatteryStatus</RootNamespace>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
-    <DebugSymbols>True</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
-    <DefineConstants>DEBUG</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <MtouchLink>None</MtouchLink>
-    <MtouchDebug>True</MtouchDebug>
-    <MtouchI18n />
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>BatteryStatus</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
-    <DebugType>none</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\iPhoneSimulator\Release</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <MtouchI18n />
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>BatteryStatus</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
-    <DebugSymbols>True</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\iPhone\Debug</OutputPath>
-    <DefineConstants>DEBUG</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <MtouchDebug>True</MtouchDebug>
-    <MtouchI18n />
-    <MtouchSdkVersion>4.0</MtouchSdkVersion>
-    <CodesignKey>iPhone Developer</CodesignKey>
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>BatteryStatus</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
-    <DebugType>none</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\iPhone\Release</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <MtouchI18n />
-    <CodesignKey>iPhone Developer</CodesignKey>
-    <MtouchSdkVersion>4.0</MtouchSdkVersion>
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>BatteryStatus</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <WarningLevel>4</WarningLevel>
-    <AssemblyName>MonoGameSamplesBatteryStatus</AssemblyName>
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <WarningLevel>4</WarningLevel>
-    <AssemblyName>MonoGameSamplesBatteryStatus</AssemblyName>
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Xml" />
-    <Reference Include="System.Core" />
-    <Reference Include="monotouch" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Game1.cs" />
-    <Compile Include="main.cs" />
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ItemGroup>
-    <Folder Include="Content\" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Content\SpriteFont1.xnb">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="Default.png">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="Info.iOS.plist">
-      <Link>Info.plist</Link>
-    </None>
-  </ItemGroup>
-</Project>

+ 43 - 0
BatteryStatus/BatteryStatus.sln

@@ -0,0 +1,43 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatteryStatus.Windows", "Platforms\Windows\BatteryStatus.Windows.csproj", "{22222222-2222-2222-2222-222222222222}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatteryStatus.DesktopGL", "Platforms\DesktopGL\BatteryStatus.DesktopGL.csproj", "{33333333-3333-3333-3333-333333333333}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatteryStatus.Android", "Platforms\Android\BatteryStatus.Android.csproj", "{44444444-4444-4444-4444-444444444444}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatteryStatus.iOS", "Platforms\iOS\BatteryStatus.iOS.csproj", "{55555555-5555-5555-5555-555555555555}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{22222222-2222-2222-2222-222222222222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{22222222-2222-2222-2222-222222222222}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{22222222-2222-2222-2222-222222222222}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{22222222-2222-2222-2222-222222222222}.Release|Any CPU.Build.0 = Release|Any CPU
+		{33333333-3333-3333-3333-333333333333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{33333333-3333-3333-3333-333333333333}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{33333333-3333-3333-3333-333333333333}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{33333333-3333-3333-3333-333333333333}.Release|Any CPU.Build.0 = Release|Any CPU
+		{44444444-4444-4444-4444-444444444444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{44444444-4444-4444-4444-444444444444}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{44444444-4444-4444-4444-444444444444}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+		{44444444-4444-4444-4444-444444444444}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{44444444-4444-4444-4444-444444444444}.Release|Any CPU.Build.0 = Release|Any CPU
+		{55555555-5555-5555-5555-555555555555}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{55555555-5555-5555-5555-555555555555}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{55555555-5555-5555-5555-555555555555}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{55555555-5555-5555-5555-555555555555}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {BCD5BF6F-A517-43DF-A3B7-3A94195F5E53}
+	EndGlobalSection
+EndGlobal

+ 0 - 0
BatteryStatus/Default.png → BatteryStatus/Core/Content/Default.png


+ 0 - 0
BatteryStatus/Content/SpriteFont1.xnb → BatteryStatus/Core/Content/SpriteFont1.xnb


+ 49 - 0
BatteryStatus/Core/Game1.cs

@@ -0,0 +1,49 @@
+using System;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace BatteryStatusDemo
+{
+    public class Game1 : Game
+    {
+        GraphicsDeviceManager graphics;
+        SpriteBatch spriteBatch;
+        SpriteFont font;
+
+        public Game1()
+        {
+            graphics = new GraphicsDeviceManager(this);
+            Content.RootDirectory = "Content";
+#if __MOBILE__ 
+            graphics.IsFullScreen = true;
+#endif
+        }
+
+        protected override void Initialize()
+        {
+            base.Initialize();
+        }
+
+        protected override void LoadContent()
+        {
+            spriteBatch = new SpriteBatch(GraphicsDevice);
+            font = Content.Load<SpriteFont>("SpriteFont1");
+        }
+
+        protected override void Update(GameTime gameTime)
+        {
+            base.Update(gameTime);
+        }
+
+        protected override void Draw(GameTime gameTime)
+        {
+            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
+            spriteBatch.Begin();
+            spriteBatch.DrawString(font, "[Battery Status]\n" + PowerStatus.BatteryChargeStatus, new Vector2(10, 100), Color.Black);
+            spriteBatch.DrawString(font, "[PowerLine Status]\n" + PowerStatus.PowerLineStatus, new Vector2(10, 200), Color.Black);
+            spriteBatch.DrawString(font, "[Charge]\n" + PowerStatus.BatteryLifePercent + "%", new Vector2(10, 300), Color.Black);
+            spriteBatch.End();
+            base.Draw(gameTime);
+        }
+    }
+}

+ 0 - 84
BatteryStatus/Game1.cs

@@ -1,84 +0,0 @@
-using System;
-
-using Microsoft.Xna;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Samples;
-using Microsoft.Xna.Samples.BatteryStatus;
-
-namespace Microsoft.Xna.Samples.BatteryStatus
-{
-    /// <summary>
-    /// This is the main type for your game
-    /// </summary>
-    public class Game1 : Microsoft.Xna.Framework.Game
-    {
-        GraphicsDeviceManager graphics;
-        SpriteBatch spriteBatch;		
-		SpriteFont font;
-
-		public Game1()
-        {
-            graphics = new GraphicsDeviceManager(this);
-            Content.RootDirectory = "Content";
-			
-			graphics.IsFullScreen = true;		
-        }
-
-        /// <summary>
-        /// Allows the game to perform any initialization it needs to before starting to run.
-        /// This is where it can query for any required services and load any non-graphic
-        /// related content.  Calling base.Initialize will enumerate through any components
-        /// and initialize them as well.
-        /// </summary>
-        protected override void Initialize()
-        {
-            // TODO: Add your initialization logic here
-            base.Initialize();				
-        }
-
-        /// <summary>
-        /// LoadContent will be called once per game and is the place to load
-        /// all of your content.
-        /// </summary>
-        protected override void LoadContent()
-        {
-            // Create a new SpriteBatch, which can be used to draw textures.
-            spriteBatch = new SpriteBatch(GraphicsDevice);
-
-			font = Content.Load<SpriteFont>("SpriteFont1");
-        }
-
-        /// <summary>
-        /// Allows the game to run logic such as updating the world,
-        /// checking for collisions, gathering input, and playing audio.
-        /// </summary>
-        /// <param name="gameTime">Provides a snapshot of timing values.</param>
-        protected override void Update(GameTime gameTime)
-        {
-            // TODO: Add your update logic here							
-            base.Update(gameTime);
-        }
-
-        /// <summary>
-        /// This is called when the game should draw itself.
-        /// </summary>
-        /// <param name="gameTime">Provides a snapshot of timing values.</param>
-        protected override void Draw(GameTime gameTime)
-        {
-           	graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
-			
-			spriteBatch.Begin();
-	
-			spriteBatch.DrawString(font,"[Battery Status]\n" + PowerStatus.BatteryChargeStatus,new Vector2(10,100),Color.Black);
-			
-			spriteBatch.DrawString(font,"[PowerLine Status]\n" + PowerStatus.PowerLineStatus,new Vector2(10,200),Color.Black);
-			
-			spriteBatch.DrawString(font,"Charge: " + PowerStatus.BatteryLifePercent+"%",new Vector2(10,300),Color.Black);
-		
-			spriteBatch.End();
-			
-            base.Draw(gameTime);
-        }
-    }
-}

+ 9 - 0
BatteryStatus/Platforms/Android/AndroidManifest.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="BatteryStatus"
+          android:versionCode="1"
+          android:versionName="1.0">
+  <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="34" />
+  <uses-feature android:glEsVersion="0x00020000" android:required="true" />
+  <application android:label="@string/app_name" android:icon="@drawable/icon"></application>
+</manifest>

+ 24 - 0
BatteryStatus/Platforms/Android/BatteryStatus.Android.csproj

@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-android</TargetFramework>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>BatteryStatus.Android</RootNamespace>
+    <Nullable>enable</Nullable>
+    <AssemblyTitle>BatteryStatus.Android</AssemblyTitle>
+    <Description>Android platform for BatteryStatus MonoGame sample.</Description>
+    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
+    <SupportedOSPlatformVersion>28</SupportedOSPlatformVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\..\Core\Game1.cs" Link="Game1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.Android" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\Core\Content\SpriteFont1.xnb">
+      <Link>Content\SpriteFont1.xnb</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 30 - 0
BatteryStatus/Platforms/Android/MainActivity.cs

@@ -0,0 +1,30 @@
+using Android.App;
+using Android.Content.PM;
+using Android.OS;
+using Android.Views;
+using Microsoft.Xna.Framework;
+
+namespace BatteryStatusDemo
+{
+	[Activity(Label = "BatteryStatus",
+		Name = "com.cartblanche.batterystatus.MainActivity",
+		MainLauncher = true,
+		ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)]
+	public class MainActivity : AndroidGameActivity
+	{
+		private Game1 _game;
+		private View _view;
+
+		protected override void OnCreate(Bundle bundle)
+		{
+			base.OnCreate(bundle);
+
+			_game = new Game1();
+			//Game1.SetInstance(_game);
+			_view = _game.Services.GetService(typeof(View)) as View;
+
+			SetContentView(_view);
+			_game.Run();
+		}
+	}
+}

+ 77 - 0
BatteryStatus/Platforms/Android/PowerStatus.cs

@@ -0,0 +1,77 @@
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+
+namespace BatteryStatusDemo
+{
+    public static partial class PowerStatus
+    {
+        public static string BatteryChargeStatus
+        {
+            get
+            {
+                var filter = new IntentFilter(Intent.ActionBatteryChanged);
+                var battery = Application.Context.RegisterReceiver(null, filter);
+                if (battery != null)
+                {
+                    int status = battery.GetIntExtra(BatteryManager.ExtraStatus, -1);
+
+                    switch ((Android.OS.BatteryStatus)status)
+                    {
+                        case Android.OS.BatteryStatus.Charging:
+                            return "Charging";
+                        case Android.OS.BatteryStatus.Full:
+                            return "Full";
+                        case Android.OS.BatteryStatus.Discharging:
+                            return "Discharging";
+                        case Android.OS.BatteryStatus.NotCharging:
+                            return "Not Charging";
+                        case Android.OS.BatteryStatus.Unknown:
+                        default:
+                            return "Unknown";
+                    }
+                }
+
+				return "Unknown";
+			}
+        }
+
+        public static string PowerLineStatus
+        {
+            get
+            {
+                var filter = new IntentFilter(Intent.ActionBatteryChanged);
+                var battery = Application.Context.RegisterReceiver(null, filter);
+                if (battery != null)
+                {
+                    int plugged = battery.GetIntExtra(Android.OS.BatteryManager.ExtraPlugged, -1);
+                    if (plugged == (int)Android.OS.BatteryPlugged.Ac)
+                        return "AC";
+                    if (plugged == (int)Android.OS.BatteryPlugged.Usb)
+                        return "USB";
+                    if (plugged == (int)Android.OS.BatteryPlugged.Wireless)
+                        return "Wireless";
+                }
+                return "Unplugged";
+            }
+        }
+
+        public static int BatteryLifePercent
+        {
+            get
+            {
+                var filter = new IntentFilter(Intent.ActionBatteryChanged);
+                var battery = Application.Context.RegisterReceiver(null, filter);
+                if (battery != null)
+                {
+                    int level = battery.GetIntExtra(Android.OS.BatteryManager.ExtraLevel, -1);
+                    int scale = battery.GetIntExtra(Android.OS.BatteryManager.ExtraScale, -1);
+                    if (level >= 0 && scale > 0)
+                        return (int)((level / (float)scale) * 100);
+                }
+                return -1;
+            }
+        }
+    }
+}

BIN
BatteryStatus/Platforms/Android/Resources/Drawable/AscentGame.ico


BIN
BatteryStatus/Platforms/Android/Resources/Drawable/Icon.png


+ 4 - 0
BatteryStatus/Platforms/Android/Resources/Values/Strings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <string name="app_name">BatteryStatus</string>
+</resources>

+ 23 - 0
BatteryStatus/Platforms/DesktopGL/BatteryStatus.DesktopGL.csproj

@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>BatteryStatus.DesktopGL</RootNamespace>
+    <Nullable>enable</Nullable>
+    <AssemblyTitle>BatteryStatus.DesktopGL</AssemblyTitle>
+    <Description>DesktopGL platform for BatteryStatus MonoGame sample.</Description>
+    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\..\Core\Game1.cs" Link="Game1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\Core\Content\SpriteFont1.xnb">
+      <Link>Content\SpriteFont1.xnb</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 10 - 0
BatteryStatus/Platforms/DesktopGL/PowerStatus.cs

@@ -0,0 +1,10 @@
+
+namespace BatteryStatusDemo
+{
+    public static partial class PowerStatus
+    {
+        public static string BatteryChargeStatus => "N/A";
+        public static string PowerLineStatus => "N/A";
+        public static int BatteryLifePercent => 100;
+    }
+}

+ 14 - 0
BatteryStatus/Platforms/DesktopGL/Program.cs

@@ -0,0 +1,14 @@
+using System;
+
+namespace BatteryStatusDemo
+{
+    public static class Program
+    {
+        [STAThread]
+        static void Main()
+        {
+            using (var game = new Game1())
+                game.Run();
+        }
+    }
+}

+ 24 - 0
BatteryStatus/Platforms/Windows/BatteryStatus.Windows.csproj

@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-windows</TargetFramework>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>BatteryStatus.Windows</RootNamespace>
+    <UseWindowsForms>true</UseWindowsForms>
+    <Nullable>enable</Nullable>
+    <AssemblyTitle>BatteryStatus.Windows</AssemblyTitle>
+    <Description>Windows platform for BatteryStatus MonoGame sample.</Description>
+    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\..\Core\Game1.cs" Link="Game1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\Core\Content\SpriteFont1.xnb">
+      <Link>Content\SpriteFont1.xnb</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 12 - 0
BatteryStatus/Platforms/Windows/PowerStatus.cs

@@ -0,0 +1,12 @@
+
+using System.Windows.Forms;
+
+namespace BatteryStatusDemo
+{
+    public static partial class PowerStatus
+    {
+        public static string BatteryChargeStatus => SystemInformation.PowerStatus.BatteryChargeStatus.ToString();
+        public static string PowerLineStatus => SystemInformation.PowerStatus.PowerLineStatus.ToString();
+        public static int BatteryLifePercent => (int)(SystemInformation.PowerStatus.BatteryLifePercent * 100);
+    }
+}

+ 14 - 0
BatteryStatus/Platforms/Windows/Program.cs

@@ -0,0 +1,14 @@
+using System;
+
+namespace BatteryStatusDemo
+{
+    public static class Program
+    {
+        [STAThread]
+        static void Main()
+        {
+            using (var game = new Game1())
+                game.Run();
+        }
+    }
+}

+ 18 - 0
BatteryStatus/Platforms/iOS/AppDelegate.cs

@@ -0,0 +1,18 @@
+using Foundation;
+using UIKit;
+using Microsoft.Xna.Framework;
+
+namespace BatteryStatusDemo
+{
+    [Register("AppDelegate")]
+    public class AppDelegate : UIApplicationDelegate
+    {
+        Game1 game;
+        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
+        {
+            game = new Game1();
+            game.Run();
+            return true;
+        }
+    }
+}

+ 23 - 0
BatteryStatus/Platforms/iOS/BatteryStatus.iOS.csproj

@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-ios</TargetFramework>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>BatteryStatus.iOS</RootNamespace>
+    <Nullable>enable</Nullable>
+    <AssemblyTitle>BatteryStatus.iOS</AssemblyTitle>
+    <Description>iOS platform for BatteryStatus MonoGame sample.</Description>
+    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\..\Core\Game1.cs" Link="Game1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.iOS" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\Core\Content\SpriteFont1.xnb">
+      <Link>Content\SpriteFont1.xnb</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 22 - 0
BatteryStatus/Platforms/iOS/Info.plist

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>CFBundleDisplayName</key>
+    <string>BatteryStatus</string>
+    <key>CFBundleIdentifier</key>
+    <string>com.cartblanche.batterystatus</string>
+    <key>CFBundleVersion</key>
+    <string>1.0</string>
+    <key>CFBundleShortVersionString</key>
+    <string>1.0</string>
+    <key>UILaunchStoryboardName</key>
+    <string>LaunchScreen</string>
+    <key>UISupportedInterfaceOrientations</key>
+    <array>
+        <string>UIInterfaceOrientationPortrait</string>
+        <string>UIInterfaceOrientationLandscapeLeft</string>
+        <string>UIInterfaceOrientationLandscapeRight</string>
+    </array>
+</dict>
+</plist>

+ 56 - 0
BatteryStatus/Platforms/iOS/PowerStatus.cs

@@ -0,0 +1,56 @@
+
+using UIKit;
+
+namespace BatteryStatusDemo
+{
+    public static partial class PowerStatus
+    {
+        static PowerStatus()
+        {
+            UIDevice.CurrentDevice.BatteryMonitoringEnabled = true;
+        }
+
+        public static string BatteryChargeStatus
+        {
+            get
+            {
+                switch (UIDevice.CurrentDevice.BatteryState)
+                {
+                    case UIDeviceBatteryState.Charging:
+                        return "Charging";
+                    case UIDeviceBatteryState.Full:
+                        return "Full";
+                    case UIDeviceBatteryState.Unplugged:
+                        return "Unplugged";
+                    case UIDeviceBatteryState.Unknown:
+                    default:
+                        return "Unknown";
+                }
+            }
+        }
+
+        public static string PowerLineStatus
+        {
+            get
+            {
+                var state = UIDevice.CurrentDevice.BatteryState;
+                if (state == UIDeviceBatteryState.Charging || state == UIDeviceBatteryState.Full)
+                    return "Plugged";
+                if (state == UIDeviceBatteryState.Unplugged)
+                    return "Unplugged";
+                return "Unknown";
+            }
+        }
+
+        public static int BatteryLifePercent
+        {
+            get
+            {
+                float level = UIDevice.CurrentDevice.BatteryLevel;
+                if (level < 0)
+                    return -1;
+                return (int)(level * 100);
+            }
+        }
+    }
+}

+ 13 - 0
BatteryStatus/Platforms/iOS/Program.cs

@@ -0,0 +1,13 @@
+using UIKit;
+
+namespace BatteryStatusDemo
+{
+    public class Application
+    {
+        // This is the main entry point of the application.
+        static void Main(string[] args)
+        {
+            UIApplication.Main(args, null, typeof(AppDelegate));
+        }
+    }
+}

+ 38 - 0
BatteryStatus/README.md

@@ -0,0 +1,38 @@
+# BatteryStatus MonoGame Sample
+
+This project demonstrates a cross-platform MonoGame 3.8.* sample for displaying battery and power status information. The codebase is structured for .NET 8 and supports Windows, DesktopGL, Android, and iOS platforms.
+
+## Directory Structure
+
+```
+/Core                # Shared game logic (Game1, PowerStatus, etc.)
+/Platforms/Windows   # Windows-specific entry point and implementation
+/Platforms/DesktopGL # DesktopGL-specific entry point and implementation
+/Platforms/Android   # Android-specific entry point and implementation
+/Platforms/iOS       # iOS-specific entry point and implementation
+/Content             # Pre-built .xnb content files
+```
+
+## Building and Running
+
+### Prerequisites
+- .NET 8 SDK
+- Visual Studio 2022+ or VSCode
+- MonoGame 3.8.* NuGet packages (restored automatically)
+
+### Windows & DesktopGL
+- Open the solution (`BatteryStatus.sln`) in Visual Studio and build/run the desired platform project.
+- Or, in VSCode, use the provided tasks and launch configurations:
+  - Press `Ctrl+Shift+B` to build (`build-windows` or `build-desktopgl`).
+  - Press `F5` to run/debug (`Windows` or `DesktopGL`).
+
+### Android & iOS
+- Open the solution in Visual Studio 2022+ (with Xamarin/MAUI workloads installed) and build/deploy the respective platform project.
+
+## Notes
+- No `Content.mgcb` is used; the project uses pre-built `.xnb` files directly.
+- Platform-specific code is separated to avoid `#if` blocks.
+- Battery status is only implemented for Windows; other platforms return stub values.
+
+## License
+MIT or as specified by CartBlanche.

+ 0 - 26
BatteryStatus/main.cs

@@ -1,26 +0,0 @@
-using MonoTouch.Foundation;
-using MonoTouch.UIKit;
-using Microsoft.Xna;
-using Microsoft.Xna.Samples;
-using Microsoft.Xna.Samples.BatteryStatus;
-
-namespace Microsoft.Xna.Samples.BatteryStatus
-{
-	[Register ("AppDelegate")]
-	class Program : UIApplicationDelegate 
-	{
-		private Game1 game;
-
-		public override void FinishedLaunching (UIApplication app)
-		{
-			// Fun begins..
-			game = new Game1();
-			game.Run();
-		}
-
-		static void Main (string [] args)
-		{
-			UIApplication.Main (args,null,"AppDelegate");
-		}
-	}
-}