Explorar o código

GameComponents update to SDK Projects and MG 3.8.*

CartBlanche hai 2 semanas
pai
achega
7cc34631cc

+ 27 - 0
GameComponents/.vscode/launch.json

@@ -0,0 +1,27 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Launch Windows",
+            "type": "coreclr",
+            "request": "launch",
+            "preLaunchTask": "build-windows",
+            "program": "${workspaceFolder}/Platforms/Windows/bin/Debug/net8.0-windows/GameComponents.Windows.exe",
+            "args": [],
+            "cwd": "${workspaceFolder}/Platforms/Windows",
+            "console": "internalConsole",
+            "stopAtEntry": false
+        },
+        {
+            "name": "Launch DesktopGL",
+            "type": "coreclr",
+            "request": "launch",
+            "preLaunchTask": "build-desktopgl",
+            "program": "${workspaceFolder}/Platforms/Desktop/bin/Debug/net8.0/GameComponents.DesktopGL.exe",
+            "args": [],
+            "cwd": "${workspaceFolder}/Platforms/Desktop",
+            "console": "internalConsole",
+            "stopAtEntry": false
+        }
+    ]
+}

+ 126 - 0
GameComponents/.vscode/tasks.json

@@ -0,0 +1,126 @@
+{
+    "version": "2.0.0",
+    "tasks": [
+        {
+            "label": "build-windows",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "build",
+                "Platforms/Windows/GameComponents.Windows.csproj"
+            ],
+            "group": "build",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "build-desktopgl",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "build",
+                "Platforms/Desktop/GameComponents.DesktopGL.csproj"
+            ],
+            "group": "build",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "build-android",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "build",
+                "Platforms/Android/GameComponents.Android.csproj"
+            ],
+            "group": "build",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "run-windows",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "run",
+                "--project",
+                "Platforms/Windows/GameComponents.Windows.csproj"
+            ],
+            "group": "test",
+            "dependsOn": "build-windows",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "run-desktopgl",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "run",
+                "--project",
+                "Platforms/Desktop/GameComponents.DesktopGL.csproj"
+            ],
+            "group": "test",
+            "dependsOn": "build-desktopgl",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "clean",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "clean"
+            ],
+            "group": "build",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        },
+        {
+            "label": "restore",
+            "command": "dotnet",
+            "type": "shell",
+            "args": [
+                "restore"
+            ],
+            "group": "build",
+            "presentation": {
+                "echo": true,
+                "reveal": "always",
+                "focus": false,
+                "panel": "shared"
+            },
+            "problemMatcher": "$msCompile"
+        }
+    ]
+}

BIN=BIN
GameComponents/Content/SpriteFont1.xnb


BIN=BIN
GameComponents/Content/font.xnb


BIN=BIN
GameComponents/Content/monogameicon.png


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


+ 1 - 1
GameComponents/FPSCounterComponent.cs → GameComponents/Core/FPSCounterComponent.cs

@@ -3,7 +3,7 @@ using System;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework;
 
-namespace Microsoft.Xna.Samples.GameComponents
+namespace GameComponents
 {
 	public class FPSCounterComponent : DrawableGameComponent
     {

+ 126 - 110
GameComponents/Game1.cs → GameComponents/Core/Game1.cs

@@ -1,110 +1,126 @@
-using System;
-using System.Collections.Generic;
-
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.GamerServices;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
-using Microsoft.Xna.Framework.Storage;
-
-namespace Microsoft.Xna.Samples.GameComponents
-{
-    /// <summary>
-    /// This is the main type for your game
-    /// </summary>
-    public class Game1 : Microsoft.Xna.Framework.Game
-    {
-        GraphicsDeviceManager graphics;
-        SpriteBatch spriteBatch;		
-		Texture2D texture;
-		Random randomizer;
-		SpriteFont font;
-
-        public Game1()
-        {
-            graphics = new GraphicsDeviceManager(this);
-            Content.RootDirectory = "Content";
-			
-			graphics.IsFullScreen = true;		
-			
-			randomizer = new Random(DateTime.Now.TimeOfDay.Milliseconds);
-        }
-
-        /// <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);
-
-            // TODO: use this.Content to load your game content here
-            texture = Content.Load<Texture2D>("monogameicon");
-			font = Content.Load<SpriteFont>("font");
-						
-			for (int i=0;i<50;i++)
-				AddSprite();
-			
-			Components.Add(new FPSCounterComponent(this,spriteBatch,font));
-        }
-
-		private void AddSprite()
-		{
-			Vector2 speed = new Vector2(5+randomizer.Next(10),5+randomizer.Next(10));
-			Vector2 position = new Vector2(randomizer.Next(260),randomizer.Next(400));
-			Components.Add(new Sprite(this,texture,position, speed, spriteBatch));
-		}
-	
-
-        /// <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
-			
-			if ((Mouse.GetState().X != 0) || (Mouse.GetState().Y != 0))
-			{
-				AddSprite();
-				//Mouse.SetPosition(0,0);
-			}
-            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();
-						
-			base.Draw(gameTime);
-			
-			spriteBatch.DrawString(font,"Tap to add a new sprite",new Vector2(0,25),Color.White);
-			spriteBatch.DrawString(font,"Sprite count: " + (Components.Count-1).ToString(),new Vector2(150,0),Color.White);
-
-
-			spriteBatch.End();  			
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+
+namespace GameComponents
+{
+    /// <summary>
+    /// This is the main type for your game
+    /// </summary>
+    public class Game1 : Microsoft.Xna.Framework.Game
+    {
+        GraphicsDeviceManager graphics;
+        SpriteBatch spriteBatch;		
+		Texture2D texture;
+		Random randomizer;
+		SpriteFont font;
+
+        public Game1()
+        {
+            graphics = new GraphicsDeviceManager(this);
+            Content.RootDirectory = "Content";
+            IsMouseVisible = true;
+            graphics.IsFullScreen = false;
+            graphics.PreferredBackBufferWidth = 800;
+            graphics.PreferredBackBufferHeight = 600;
+			
+			randomizer = new Random(DateTime.Now.TimeOfDay.Milliseconds);
+        }
+
+        /// <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);
+
+            // TODO: use this.Content to load your game content here
+            texture = Content.Load<Texture2D>("logo");
+			font = Content.Load<SpriteFont>("Font");
+						
+			for (int i=0;i<50;i++)
+				AddSprite();
+			
+			Components.Add(new FPSCounterComponent(this,spriteBatch,font));
+        }
+
+		private void AddSprite()
+		{
+			Vector2 speed = new Vector2(5+randomizer.Next(10),5+randomizer.Next(10));
+			Vector2 position = new Vector2(randomizer.Next(260),randomizer.Next(400));
+			Components.Add(new Sprite(this,texture,position, speed, spriteBatch));
+		}
+	
+
+        /// <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
+            
+            KeyboardState currentKeyboardState = Keyboard.GetState();
+			GamePadState currentGamePadState = GamePad.GetState (PlayerIndex.One);
+
+			// Check for exit.
+			if (currentKeyboardState.IsKeyDown(Keys.Escape) ||
+				currentGamePadState.Buttons.Back == ButtonState.Pressed)
+			{
+#if !___IOS___
+				Exit();
+#endif
+			}
+
+            var mouseState = Mouse.GetState();
+			
+			if (mouseState.LeftButton == ButtonState.Pressed ||
+                currentGamePadState.Buttons.A == ButtonState.Pressed ||
+                currentKeyboardState.IsKeyDown(Keys.Space))
+            {
+                AddSprite();
+                //Mouse.SetPosition(0,0);
+            }
+            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();
+						
+			base.Draw(gameTime);
+			
+			spriteBatch.DrawString(font,"Tap/Click/Space/A button to add a new sprite",new Vector2(0,25),Color.White);
+			spriteBatch.DrawString(font,"Sprite count: " + (Components.Count-1).ToString(),new Vector2(150,0),Color.White);
+
+
+			spriteBatch.End();  			
+        }
+    }
+}

+ 11 - 0
GameComponents/Core/GameComponents.Core.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <RootNamespace>GameComponents.Core</RootNamespace>
+    <AssemblyName>GameComponents.Core</AssemblyName>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
+  </ItemGroup>
+</Project>

+ 1 - 1
GameComponents/Sprite.cs → GameComponents/Core/Sprite.cs

@@ -4,7 +4,7 @@ using System.Text;
 using Microsoft.Xna.Framework.Graphics;   //   for Texture2D
 using Microsoft.Xna.Framework;  //  for Vector2
 
-namespace Microsoft.Xna.Samples.GameComponents
+namespace GameComponents
 {
     class Sprite : DrawableGameComponent
     {

+ 0 - 109
GameComponents/GameComponents.iOS.csproj

@@ -1,109 +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>{4F51EB5C-03A1-4488-8EEA-0E8F2411DB0C}</ProjectGuid>
-    <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <OutputType>Exe</OutputType>
-    <RootNamespace>MonoGame.Samples.GameComponents</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>GameComponents</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
-    <DebugType>none</DebugType>
-    <Optimize>True</Optimize>
-    <OutputPath>bin\iPhoneSimulator\Release</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <MtouchI18n />
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>GameComponents</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>
-    <MtouchUseArmv7>false</MtouchUseArmv7>
-    <AssemblyName>GameComponents</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
-    <DebugType>none</DebugType>
-    <Optimize>True</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>GameComponents</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <WarningLevel>4</WarningLevel>
-    <AssemblyName>MonoGameSamplesGameComponents</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>MonoGameSamplesGameComponents</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" />
-    <Compile Include="Sprite.cs" />
-    <Compile Include="FPSCounterComponent.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Default.png">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="Content\monogameicon.png">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="Content\font.xnb">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ItemGroup>
-    <None Include="monogameicon.png" />
-    <None Include="Info.iOS.plist">
-      <Link>Info.plist</Link>
-    </None>
-  </ItemGroup>
-</Project>

+ 44 - 0
GameComponents/GameComponents.sln

@@ -0,0 +1,44 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameComponents.Core", "Core\GameComponents.Core.csproj", "{A1B2C3D4-E5F6-7890-1234-56789ABCDEF0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameComponents.Windows", "Platforms\Windows\GameComponents.Windows.csproj", "{1F4E5B45-2C8A-4B9F-8E3D-7A6B5C9D8E2F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameComponents.DesktopGL", "Platforms\Desktop\GameComponents.DesktopGL.csproj", "{2F5E6C56-3D9B-4C0A-9F4E-8B7C6D0E9F3A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameComponents.Android", "Platforms\Android\GameComponents.Android.csproj", "{3F6E7D67-4E0C-4D1B-0A5F-9C8D7E1F0A4B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameComponents.iOS", "Platforms\iOS\GameComponents.iOS.csproj", "{4F7E8E78-5F1D-4E2C-1B6A-0D9E8F2A1B5C}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{1F4E5B45-2C8A-4B9F-8E3D-7A6B5C9D8E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1F4E5B45-2C8A-4B9F-8E3D-7A6B5C9D8E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1F4E5B45-2C8A-4B9F-8E3D-7A6B5C9D8E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1F4E5B45-2C8A-4B9F-8E3D-7A6B5C9D8E2F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{2F5E6C56-3D9B-4C0A-9F4E-8B7C6D0E9F3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2F5E6C56-3D9B-4C0A-9F4E-8B7C6D0E9F3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2F5E6C56-3D9B-4C0A-9F4E-8B7C6D0E9F3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2F5E6C56-3D9B-4C0A-9F3A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3F6E7D67-4E0C-4D1B-0A5F-9C8D7E1F0A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3F6E7D67-4E0C-4D1B-0A5F-9C8D7E1F0A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3F6E7D67-4E0C-4D1B-0A5F-9C8D7E1F0A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3F6E7D67-4E0C-4D1B-0A5F-9C8D7E1F0A4B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4F7E8E78-5F1D-4E2C-1B6A-0D9E8F2A1B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4F7E8E78-5F1D-4E2C-1B6A-0D9E8F2A1B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4F7E8E78-5F1D-4E2C-1B6A-0D9E8F2A1B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4F7E8E78-5F1D-4E2C-1B6A-0D9E8F2A1B5C}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {EA62DB11-BB65-4CA8-9CAF-4CD0FED7DB86}
+	EndGlobalSection
+EndGlobal

+ 34 - 0
GameComponents/Platforms/Android/Activity1.cs

@@ -0,0 +1,34 @@
+using Android.App;
+using Android.Content.PM;
+using Android.OS;
+using Android.Views;
+using Microsoft.Xna.Framework;
+
+namespace GameComponents.Android
+{
+    [Activity(
+        Label = "@string/app_name",
+        MainLauncher = true,
+        Icon = "@drawable/icon",
+        AlwaysRetainTaskState = true,
+        LaunchMode = LaunchMode.SingleInstance,
+        ScreenOrientation = ScreenOrientation.FullUser,
+        ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize
+    )]
+    public class Activity1 : AndroidGameActivity
+    {
+        private Game1 game;
+        private View gameView;
+
+        protected override void OnCreate(Bundle bundle)
+        {
+            base.OnCreate(bundle);
+
+            game = new Game1();
+            gameView = game.Services.GetService(typeof(View)) as View;
+
+            SetContentView(gameView);
+            game.Run();
+        }
+    }
+}

+ 10 - 0
GameComponents/Platforms/Android/AndroidManifest.xml

@@ -0,0 +1,10 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cartblanche.gamecomponents">
+  <application android:label="GameComponents.Android" android:icon="@mipmap/icon">
+    <activity android:name=".MainActivity">
+      <intent-filter>
+        <action android:name="android.intent.action.MAIN" />
+        <category android:name="android.intent.category.LAUNCHER" />
+      </intent-filter>
+    </activity>
+  </application>
+</manifest>

+ 22 - 0
GameComponents/Platforms/Android/GameComponents.Android.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-android</TargetFramework>
+    <RootNamespace>GameComponents.Android</RootNamespace>
+    <AssemblyName>GameComponents.Android</AssemblyName>
+    <OutputType>Exe</OutputType>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Core\GameComponents.Core.csproj" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.Android" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\CompiledContent\Android\Content\Textures\logo.xnb" Link="Content\logo.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\..\..\CompiledContent\Android\Content\Fonts\Arial.xnb" Link="Content\Font.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 22 - 0
GameComponents/Platforms/Desktop/GameComponents.DesktopGL.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <RootNamespace>GameComponents.DesktopGL</RootNamespace>
+    <AssemblyName>GameComponents.DesktopGL</AssemblyName>
+    <OutputType>Exe</OutputType>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Core\GameComponents.Core.csproj" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\CompiledContent\Windows\Content\Textures\logo.xnb" Link="Content\logo.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\..\..\CompiledContent\Windows\Content\Fonts\Arial.xnb" Link="Content\Font.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 14 - 0
GameComponents/Platforms/Desktop/Program.cs

@@ -0,0 +1,14 @@
+using System;
+using Microsoft.Xna.Framework;
+
+namespace GameComponents.DesktopGL
+{
+    public static class Program
+    {
+        static void Main()
+        {
+            using (var game = new Game1())
+                game.Run();
+        }
+    }
+}

+ 23 - 0
GameComponents/Platforms/Windows/GameComponents.Windows.csproj

@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-windows</TargetFramework>
+    <UseWindowsForms>false</UseWindowsForms>
+    <RootNamespace>GameComponents.Windows</RootNamespace>
+    <AssemblyName>GameComponents.Windows</AssemblyName>
+    <OutputType>WinExe</OutputType>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Core\GameComponents.Core.csproj" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\CompiledContent\Windows\Content\Textures\logo.xnb" Link="Content\logo.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\..\..\CompiledContent\Windows\Content\Fonts\Arial.xnb" Link="Content\Font.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 15 - 0
GameComponents/Platforms/Windows/Program.cs

@@ -0,0 +1,15 @@
+using System;
+using Microsoft.Xna.Framework;
+
+namespace GameComponents.Windows
+{
+    public static class Program
+    {
+        [STAThread]
+        static void Main()
+        {
+            using (var game = new Game1())
+                game.Run();
+        }
+    }
+}

+ 22 - 0
GameComponents/Platforms/iOS/GameComponents.iOS.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>net8.0-ios</TargetFramework>
+    <RootNamespace>GameComponents.iOS</RootNamespace>
+    <AssemblyName>GameComponents.iOS</AssemblyName>
+    <OutputType>Exe</OutputType>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Core\GameComponents.Core.csproj" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="MonoGame.Framework.iOS" Version="3.8.*" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\CompiledContent\iOS\Content\Textures\logo.xnb" Link="Content\logo.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\..\..\CompiledContent\iOS\Content\Fonts\Arial.xnb" Link="Content\Font.xnb">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+</Project>

+ 22 - 0
GameComponents/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>CFBundleIdentifier</key>
+    <string>com.cartblanche.gamecomponents</string>
+    <key>CFBundleName</key>
+    <string>GameComponents.iOS</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>

+ 26 - 0
GameComponents/Platforms/iOS/Program.cs

@@ -0,0 +1,26 @@
+using Foundation;
+using UIKit;
+using Microsoft.Xna.Framework;
+
+namespace GameComponents.iOS
+{
+    [Register("AppDelegate")]
+    public class AppDelegate : UIApplicationDelegate
+    {
+        public override UIWindow Window { get; set; }
+        Game1 game;
+        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
+        {
+            game = new Game1();
+            game.Run();
+            return true;
+        }
+    }
+    public class Application
+    {
+        static void Main(string[] args)
+        {
+            UIApplication.Main(args, null, typeof(AppDelegate));
+        }
+    }
+}

+ 52 - 0
GameComponents/README.md

@@ -0,0 +1,52 @@
+# GameComponents MonoGame Sample
+
+This project demonstrates a cross-platform MonoGame 3.8.* sample, structured for modern .NET 8+ development. It supports Windows, DesktopGL, Android, and iOS platforms, using a clean separation of shared and platform-specific code.
+
+## Project Structure
+
+```
+/Core                # Shared game logic and components
+/Platforms/Windows   # Windows-specific entry point and project
+/Platforms/Desktop   # DesktopGL-specific entry point and project
+/Platforms/Android   # Android-specific entry point, manifest, and project
+/Platforms/iOS       # iOS-specific entry point, Info.plist, and project
+/Content             # Pre-built .xnb content files
+```
+
+## Building and Running
+
+### Prerequisites
+- .NET 8 SDK or newer
+- Visual Studio 2022+ (for Android/iOS) or VSCode
+- MonoGame 3.8.* NuGet packages (restored automatically)
+- Android/iOS build tools for mobile platforms
+
+### With Visual Studio
+1. Open `GameComponents.sln`.
+2. Select the desired platform project (Windows, DesktopGL, Android, or iOS).
+3. Build and run as usual.
+
+### With VSCode
+1. Open the root folder in VSCode.
+2. Use the provided tasks (see below) to build or run each platform:
+   - **Windows**: `dotnet run --project Platforms/Windows/GameComponents.Windows.csproj`
+   - **DesktopGL**: `dotnet run --project Platforms/Desktop/GameComponents.DesktopGL.csproj`
+   - **Android**: `dotnet build Platforms/Android/GameComponents.Android.csproj`
+   - **iOS**: `dotnet build Platforms/iOS/GameComponents.iOS.csproj`
+
+### Content
+- Uses pre-built `.xnb` files in `/Content`.
+- No `Content.mgcb` is required.
+
+## Notes
+- All shared code is in `/Core` and referenced by each platform project.
+- Platform-specific code and entry points are in their respective `/Platforms/*` directories.
+- Only Windows, DesktopGL, Android, and iOS are supported (no Linux, MacOS, or PSMobile).
+
+## Troubleshooting
+- Ensure all required SDKs and build tools are installed for your target platform.
+- If you encounter build errors, run `dotnet restore` first.
+
+---
+
+For more details, see the individual project files and platform directories.

+ 0 - 29
GameComponents/main.cs

@@ -1,29 +0,0 @@
-using MonoTouch.Foundation;
-using MonoTouch.UIKit;
-using Microsoft.Xna;
-using Microsoft.Xna.Samples;
-using Microsoft.Xna.Samples.GameComponents;
-using Microsoft.Xna.Framework;
-
-namespace Microsoft.Xna.Samples.GameComponents
-{
-	[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)
-		{
-			NSAutoreleasePool pool = new NSAutoreleasePool();
-			UIApplication.Main (args,null,"AppDelegate");
-			pool.Dispose();
-		}
-	}
-}

BIN=BIN
GameComponents/monogameicon.png