Get Android working with these changes.

This commit is contained in:
tangalbert919
2018-12-08 15:49:23 -06:00
parent c132da9518
commit 38ef358d37
11 changed files with 98 additions and 202 deletions

View File

@@ -1,5 +1,7 @@
using Android.App;
using Android.Widget;
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using Android.App;
using Android.OS;
namespace SampleGame.Android
@@ -7,21 +9,11 @@ namespace SampleGame.Android
[Activity(Label = "SampleGame", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
/*Button button = FindViewById<Button>(Resource.Id.myButton);
button.Click += delegate { button.Text = $"{count++} clicks!"; };*/
}
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="ppy.SampleGame">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28" />
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name"></application>
</manifest>

View File

@@ -26,8 +26,6 @@ namespace SampleGame.Android
public static void UpdateIdValues()
{
global::osu.Framework.Android.Resource.String.library_name = global::SampleGame.Android.Resource.String.library_name;
global::osuTK.Android.Resource.String.library_name = global::SampleGame.Android.Resource.String.library_name;
}
public partial class Attribute
@@ -46,8 +44,11 @@ namespace SampleGame.Android
public partial class Id
{
// aapt resource value: 0x7f050001
public const int button1 = 2131034113;
// aapt resource value: 0x7f050000
public const int sampleGameView1 = 2131034112;
public const int textView1 = 2131034112;
static Id()
{
@@ -94,14 +95,11 @@ namespace SampleGame.Android
public partial class String
{
// aapt resource value: 0x7f040002
public const int app_name = 2130968578;
// aapt resource value: 0x7f040001
public const int hello = 2130968577;
public const int app_name = 2130968577;
// aapt resource value: 0x7f040000
public const int library_name = 2130968576;
public const int hello = 2130968576;
static String()
{

View File

@@ -1,6 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
<!--<Button android:id="@+id/myButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello" />-->
<SampleGame.Android.SampleGameView
android:id="@+id/sampleGameView1" android:layout_width="match_parent" android:layout_height="match_parent" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="By pressing this button, you accept the fact that osu!lazer is completely unstable and will crash randomly."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:textAlignment="center"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:textSize="16dp" />
<!--<SampleGame.Android.SampleGameView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/sampleGameView1" />-->
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:onClick="majoroof" />
</LinearLayout>

View File

@@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<RootNamespace>SampleGame.Android</RootNamespace>
<AssemblyName>SampleGame.Android</AssemblyName>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
@@ -59,10 +59,10 @@
<HintPath>..\packages\ManagedBass.Fx.2.0.1\lib\netstandard1.4\ManagedBass.Fx.dll</HintPath>
</Reference>
<Reference Include="osuTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\ppy.osuTK.NS20.1.0.11\lib\netstandard2.0\osuTK.dll</HintPath>
<HintPath>..\packages\ppy.osuTK.NS20.1.0.13\lib\netstandard2.0\osuTK.dll</HintPath>
</Reference>
<Reference Include="osuTK.Android, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ppy.osuTK.Android.1.0.11\lib\monoandroid50\osuTK.Android.dll</HintPath>
<HintPath>..\packages\ppy.osuTK.Android.1.0.13\lib\monoandroid50\osuTK.Android.dll</HintPath>
</Reference>
<Reference Include="SharpFNT">
<HintPath>..\packages\SharpFNT.1.0.1\lib\netstandard1.3\SharpFNT.dll</HintPath>
@@ -78,6 +78,7 @@
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="SampleGameView.cs" />
</ItemGroup>
<ItemGroup>
@@ -128,9 +129,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="bass.dll">
<None Include="bass.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</None>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

View File

@@ -11,15 +11,18 @@ using Android.Util;
using Android.Views;
using Android.Widget;
using osu.Framework;
using osu.Framework.Android;
namespace SampleGame.Android
{
class SampleGameView : osu.Framework.Android.AndroidGameView
public class SampleGameView : AndroidGameView
{
public SampleGameView(Context context, IAttributeSet attrs) : base(context, attrs)
public SampleGameView(Context context, IAttributeSet attrs) :
base(context, attrs)
{
CreateGame();
}
public override Game CreateGame() => new SampleGameGame();
}
}

View File

@@ -2,6 +2,6 @@
<packages>
<package id="ManagedBass" version="2.0.4" targetFramework="monoandroid90" />
<package id="ManagedBass.Fx" version="2.0.1" targetFramework="monoandroid90" />
<package id="ppy.osuTK.Android" version="1.0.11" targetFramework="monoandroid90" />
<package id="ppy.osuTK.NS20" version="1.0.11" targetFramework="monoandroid90" />
<package id="ppy.osuTK.Android" version="1.0.13" targetFramework="monoandroid80" />
<package id="ppy.osuTK.NS20" version="1.0.13" targetFramework="monoandroid80" />
</packages>

View File

@@ -2,33 +2,26 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using osu.Framework;
using osu.Framework.Graphics.OpenGL;
using osuTK;
using osuTK.Graphics;
using osuTK.Graphics.ES30;
using osuTK.Platform.Android;
namespace osu.Framework.Android
{
[Register("AndroidGameView")]
public abstract class AndroidGameView : osuTK.Android.AndroidGameView
{
int viewportWidth, viewportHeight;
int program;
private AndroidGameHost host;
public abstract Game CreateGame();
public AndroidGameView(Context context) : base(context)
{
Init();
}
public AndroidGameView(Context context, IAttributeSet attrs) : base(context, attrs)
{
Init();
@@ -37,11 +30,10 @@ namespace osu.Framework.Android
{
Init();
}
void Init()
private void Init()
{
AutoSetContextOnRenderFrame = true;
ContextRenderingApi = GLVersion.ES3;
RenderThreadRestartRetries = 1;
}
protected override void CreateFrameBuffer()
{
@@ -78,14 +70,10 @@ namespace osu.Framework.Android
MakeCurrent();
}
void RenderGame()
public void RenderGame()
{
Run();
host = new AndroidGameHost(this);
host.Run(CreateGame());
SwapBuffers();
}
public abstract Game CreateGame();
}
}

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace osu.Framework.Android
{
[Activity(Label = "GameAppActivity")]
public class GameAppActivity : Activity
{
private AndroidGameView view;
private AndroidGameHost host;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
}
}
}

View File

@@ -0,0 +1,11 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using System.Runtime.CompilerServices;
// We publish our internal attributes to other sub-projects of the framework.
// Note, that we omit visual tests as they are meant to test the framework
// behavior "in the wild".
[assembly: InternalsVisibleTo("osu.Framework.Tests")]
[assembly: InternalsVisibleTo("osu.Framework.Tests.Dynamic")]

View File

@@ -1,137 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit.3.10.1\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.10.1\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{87D8D3B5-7E16-4207-9972-8242AF1DEC3C}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Project Sdk="MSBuild.Sdk.Extras/1.6.55">
<PropertyGroup Label="Project">
<TargetFramework>monoandroid80</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>osu.Framework.Android</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyTitle>osu!framework Android</AssemblyTitle>
<AssemblyName>osu.Framework.Android</AssemblyName>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<RootNamespace>osu.Framework.Android</RootNamespace>
<Description>A 2D application/game framework written with rhythm games in mind.</Description>
<Product>osu!framework</Product>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<JavaMaximumHeapSize>
</JavaMaximumHeapSize>
<LangVersion>Default</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<JavaMaximumHeapSize>
</JavaMaximumHeapSize>
<LangVersion>Default</LangVersion>
<PropertyGroup Label="Nuget">
<Title>osu!framework Android</Title>
<PackageId>ppy.osu.Framework.Android</PackageId>
<Authors>ppy Pty Ltd</Authors>
<PackageLicenseUrl>https://github.com/ppy/osu-framework/blob/master/LICENCE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/ppy/osu-framework</PackageProjectUrl>
<RepositoryUrl>https://github.com/ppy/osu-framework</RepositoryUrl>
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
<copyright>Copyright (c) 2007-2018 ppy Pty Ltd contact@ppy.sh</copyright>
<PackageTags>osu game framework</PackageTags>
</PropertyGroup>
<ItemGroup>
<Reference Include="Java.Interop" />
<Reference Include="osuTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\ppy.osuTK.NS20.1.0.11\lib\netstandard2.0\osuTK.dll</HintPath>
</Reference>
<Reference Include="osuTK.Android, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ppy.osuTK.Android.1.0.11\lib\monoandroid50\osuTK.Android.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations">
<HintPath>..\packages\JetBrains.Annotations.2018.2.1\lib\netstandard2.0\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Reflection.Metadata">
<HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple">
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis">
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.9.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.9.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.10.1\lib\netstandard2.0\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Diagnostics.Runtime">
<HintPath>..\packages\ppy.Microsoft.Diagnostics.Runtime.0.9.180305.1\lib\netstandard2.0\Microsoft.Diagnostics.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Buffers">
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Memory">
<HintPath>..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="SixLabors.Core">
<HintPath>..\packages\SixLabors.Core.1.0.0-beta0006\lib\netstandard1.1\SixLabors.Core.dll</HintPath>
</Reference>
<Reference Include="SixLabors.ImageSharp">
<HintPath>..\packages\SixLabors.ImageSharp.1.0.0-beta0005\lib\netstandard2.0\SixLabors.ImageSharp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Cyotek.Drawing.BitmapFont">
<HintPath>..\packages\Cyotek.Drawing.BitmapFont.1.3.4\lib\netstandard1.3\Cyotek.Drawing.BitmapFont.dll</HintPath>
</Reference>
<Reference Include="ManagedBass">
<HintPath>..\packages\ManagedBass.2.0.4\lib\netstandard1.4\ManagedBass.dll</HintPath>
</Reference>
<Reference Include="ManagedBass.Fx">
<HintPath>..\packages\ManagedBass.Fx.2.0.1\lib\netstandard1.4\ManagedBass.Fx.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AndroidStorage.cs" />
<Compile Include="GameAppActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="AndroidGameWindow.cs" />
<Compile Include="AndroidGameView.cs" />
<Compile Include="AndroidGameHost.cs" />
<NativeLibs Include="$(MSBuildThisFileDirectory)*\*.dll*" />
<NativeLibs Include="$(MSBuildThisFileDirectory)*.a" />
<None Include="@(NativeLibs)">
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Resources\AboutResources.txt" />
<None Include="packages.config" />
<ProjectReference Include="..\osu.Framework\osu.Framework.csproj" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\Strings.xml" />
<PackageReference Include="ppy.osuTK.Android" Version="1.0.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu.Framework\osu.Framework.csproj">
<Project>{C76BF5B3-985E-4D39-95FE-97C9C879B83A}</Project>
<Name>osu.Framework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets')" />
</Project>