diff --git a/Demos.Android/Activity1.cs b/Demos.Android/Activity1.cs index 30426cf..91fdb3c 100644 --- a/Demos.Android/Activity1.cs +++ b/Demos.Android/Activity1.cs @@ -2,27 +2,38 @@ using Android.App; using Android.Content.PM; using Android.OS; using Android.Views; +using Microsoft.Xna.Framework; +using MLEM.Extensions; using MLEM.Misc; namespace Demos.Android { - [Activity(Label = "Demos.Android" - , MainLauncher = true - , Icon = "@drawable/icon" - , Theme = "@style/Theme.Splash" - , AlwaysRetainTaskState = true - , LaunchMode = LaunchMode.SingleInstance - , ScreenOrientation = ScreenOrientation.UserLandscape - , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)] - public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity { + [Activity( + Label = "@string/app_name", + MainLauncher = true, + Icon = "@drawable/icon", + AlwaysRetainTaskState = true, + LaunchMode = LaunchMode.SingleInstance, + ScreenOrientation = ScreenOrientation.UserLandscape, + ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize + )] + public class Activity1 : AndroidGameActivity { + + private GameImpl game; + private View view; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); + TextInputWrapper.Current = new TextInputWrapper.Mobile(); - var g = new GameImpl(); + this.game = new GameImpl(); + // reset MlemGame width and height to use device's aspect ratio + this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game); // disable mouse handling for android to make emulator behavior more coherent - g.OnLoadContent += game => game.InputHandler.HandleMouse = false; - this.SetContentView((View) g.Services.GetService(typeof(View))); - g.Run(); + this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false; + this.view = this.game.Services.GetService(typeof(View)) as View; + + this.SetContentView(this.view); + this.game.Run(); } } diff --git a/Demos.Android/Demos.Android.csproj b/Demos.Android/Demos.Android.csproj index efa5477..3e49ddd 100644 --- a/Demos.Android/Demos.Android.csproj +++ b/Demos.Android/Demos.Android.csproj @@ -1,106 +1,92 @@ - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {410C0262-131C-4D0E-910D-D01B4F7143E0} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - Demos.Android - Demos.Android - 512 - true - Resources\Resource.Designer.cs - Off - armeabi-v7a;x86 - .m4a - - v7.1 - Android - Properties\AndroidManifest.xml - True - - - true - full - false - bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ - DEBUG;TRACE;ANDROID - prompt - 4 - True - None - - - pdbonly - true - bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ - TRACE;ANDROID - prompt - 4 - False - SdkOnly - - - - ..\packages\Coroutine.1.0.2\lib\netstandard2.0\Coroutine.dll - True - - - - - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll - True - - - - - - - $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Android\MonoGame.Framework.dll - - - ..\packages\TextCopy.3.0.0\lib\netstandard2.1\TextCopy.dll - True - - - - - - - - - - - - - - - - - - - - - - - - {1bc4682b-aa14-4937-b5c7-707e20fe88ff} - Demos - - - {997f4739-7bec-4621-b9ca-68deb2d74412} - MLEM.Startup - - - {1d6ab762-43c4-4775-8924-707c7ec3f142} - MLEM - - - - - \ No newline at end of file + + Debug + AnyCPU + 8.0.30703 + 2.0 + {410C0262-131C-4D0E-910D-D01B4F7143E0} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + Demos.Android + Demos.Android + 512 + true + Resources\Resource.Designer.cs + Resource + Off + .m4a + v9.0 + Properties\AndroidManifest.xml + false + Resources + Assets + true + Xamarin.Android.Net.AndroidClientHandler + + + true + full + false + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + DEBUG;TRACE;ANDROID + prompt + 4 + True + None + + + pdbonly + true + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + TRACE;ANDROID + prompt + 4 + False + SdkOnly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {1bc4682b-aa14-4937-b5c7-707e20fe88ff} + Demos + + + {997f4739-7bec-4621-b9ca-68deb2d74412} + MLEM.Startup + + + {1d6ab762-43c4-4775-8924-707c7ec3f142} + MLEM + + + + diff --git a/Demos.Android/Properties/AndroidManifest.xml b/Demos.Android/Properties/AndroidManifest.xml index 4dbed57..5b4220a 100644 --- a/Demos.Android/Properties/AndroidManifest.xml +++ b/Demos.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - - - - \ No newline at end of file + + + + diff --git a/Demos.Android/Properties/AssemblyInfo.cs b/Demos.Android/Properties/AssemblyInfo.cs index aecac0d..7b7db38 100644 --- a/Demos.Android/Properties/AssemblyInfo.cs +++ b/Demos.Android/Properties/AssemblyInfo.cs @@ -7,22 +7,15 @@ using Android.App; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Demos.Android")] -[assembly: AssemblyProduct("Demos.Android")] -[assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyProduct("Demos.Android")] +[assembly: AssemblyCopyright("Copyright © 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6f377592-2266-4c47-855e-6260ff75e1f4")] - // Version information for an assembly consists of the following four values: // // Major Version @@ -34,8 +27,4 @@ using Android.App; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -// Add some common permissions, these can be removed if not needed -[assembly: UsesPermission(Android.Manifest.Permission.Internet)] -[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] \ No newline at end of file +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Demos.Android/Resources/Drawable/Icon.png b/Demos.Android/Resources/Drawable/Icon.png index f6f4f41..25fe044 100644 Binary files a/Demos.Android/Resources/Drawable/Icon.png and b/Demos.Android/Resources/Drawable/Icon.png differ diff --git a/Demos.Android/Resources/Drawable/Splash.png b/Demos.Android/Resources/Drawable/Splash.png deleted file mode 100644 index 2f86107..0000000 Binary files a/Demos.Android/Resources/Drawable/Splash.png and /dev/null differ diff --git a/Demos.Android/Resources/Resource.Designer.cs b/Demos.Android/Resources/Resource.Designer.cs index 64174da..a040fa0 100644 --- a/Demos.Android/Resources/Resource.Designer.cs +++ b/Demos.Android/Resources/Resource.Designer.cs @@ -47,9 +47,6 @@ namespace Demos.Android // aapt resource value: 0x7F010000 public const int Icon = 2130771968; - // aapt resource value: 0x7F010001 - public const int Splash = 2130771969; - static Drawable() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); @@ -64,10 +61,7 @@ namespace Demos.Android { // aapt resource value: 0x7F020000 - public const int ApplicationName = 2130837504; - - // aapt resource value: 0x7F020001 - public const int Hello = 2130837505; + public const int app_name = 2130837504; static String() { @@ -78,22 +72,6 @@ namespace Demos.Android { } } - - public partial class Style - { - - // aapt resource value: 0x7F030000 - public const int Theme_Splash = 2130903040; - - static Style() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Style() - { - } - } } } #pragma warning restore 1591 diff --git a/Demos.Android/Resources/Values/Strings.xml b/Demos.Android/Resources/Values/Strings.xml index 540633f..a2890aa 100644 --- a/Demos.Android/Resources/Values/Strings.xml +++ b/Demos.Android/Resources/Values/Strings.xml @@ -1,5 +1,4 @@ - Hello World, Click Me! - Demos.Android + Demos.Android diff --git a/Demos.Android/Resources/Values/Styles.xml b/Demos.Android/Resources/Values/Styles.xml deleted file mode 100644 index 5102134..0000000 --- a/Demos.Android/Resources/Values/Styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/Demos.Android/packages.config b/Demos.Android/packages.config deleted file mode 100644 index 6471cfa..0000000 --- a/Demos.Android/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/MLEM.sln b/MLEM.sln index 1fa8130..49e9478 100644 --- a/MLEM.sln +++ b/MLEM.sln @@ -14,12 +14,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.DesktopGL", "Demos.De EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox\Sandbox.csproj", "{289ABC96-7A0B-4EB9-A0BE-75C807C09F74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "Demos.Android\Demos.Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Data", "MLEM.Data\MLEM.Data.csproj", "{28938AAA-FB91-4E6F-8511-0DB99EC831F7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Templates", "MLEM.Templates\MLEM.Templates.csproj", "{C2A2CFED-C9E8-4675-BD66-EFC3DB210977}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "Demos.Android\Demos.Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -54,10 +54,6 @@ Global {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Debug|Any CPU.Build.0 = Debug|Any CPU {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Release|Any CPU.ActiveCfg = Release|Any CPU {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Release|Any CPU.Build.0 = Release|Any CPU - {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.Build.0 = Release|Any CPU {28938AAA-FB91-4E6F-8511-0DB99EC831F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28938AAA-FB91-4E6F-8511-0DB99EC831F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {28938AAA-FB91-4E6F-8511-0DB99EC831F7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -66,5 +62,9 @@ Global {C2A2CFED-C9E8-4675-BD66-EFC3DB210977}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2A2CFED-C9E8-4675-BD66-EFC3DB210977}.Release|Any CPU.ActiveCfg = Release|Any CPU {C2A2CFED-C9E8-4675-BD66-EFC3DB210977}.Release|Any CPU.Build.0 = Release|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/MLEM/Extensions/GraphicsExtensions.cs b/MLEM/Extensions/GraphicsExtensions.cs index bcd4487..a2ac8f6 100644 --- a/MLEM/Extensions/GraphicsExtensions.cs +++ b/MLEM/Extensions/GraphicsExtensions.cs @@ -39,6 +39,13 @@ namespace MLEM.Extensions { manager.ApplyChanges(); } + public static void ResetWidthAndHeight(this GraphicsDeviceManager manager, Game game) { + var (_, _, width, height) = game.Window.ClientBounds; + manager.PreferredBackBufferWidth = Math.Max(height, width); + manager.PreferredBackBufferHeight = Math.Min(height, width); + manager.ApplyChanges(); + } + public static TargetContext WithRenderTarget(this GraphicsDevice device, RenderTarget2D target) { return new TargetContext(device, target); }