mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Add code from target-android branch
Some changes to the added code were made so it would work with this structure.
This commit is contained in:
27
SampleGame.Android/MainActivity.cs
Normal file
27
SampleGame.Android/MainActivity.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
|
||||
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!"; };*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
SampleGame.Android/Properties/AndroidManifest.xml
Normal file
5
SampleGame.Android/Properties/AndroidManifest.xml
Normal file
@@ -0,0 +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" />
|
||||
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name"></application>
|
||||
</manifest>
|
||||
117
SampleGame.Android/Resources/Resource.designer.cs
generated
Normal file
117
SampleGame.Android/Resources/Resource.designer.cs
generated
Normal file
@@ -0,0 +1,117 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("SampleGame.Android.Resource", IsApplication=true)]
|
||||
|
||||
namespace SampleGame.Android
|
||||
{
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
static Resource()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
public const int sampleGameView1 = 2131034112;
|
||||
|
||||
static Id()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Id()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Layout
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int Main = 2130903040;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Layout()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Mipmap
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f020000
|
||||
public const int Icon = 2130837504;
|
||||
|
||||
static Mipmap()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Mipmap()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f040002
|
||||
public const int app_name = 2130968578;
|
||||
|
||||
// aapt resource value: 0x7f040001
|
||||
public const int hello = 2130968577;
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
public const int library_name = 2130968576;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
6
SampleGame.Android/Resources/layout/Main.axml
Normal file
6
SampleGame.Android/Resources/layout/Main.axml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?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>
|
||||
129
SampleGame.Android/SampleGame.Android.csproj
Normal file
129
SampleGame.Android/SampleGame.Android.csproj
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5A378BB7-11D6-4008-980E-A67507CD9969}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SampleGame.Android</RootNamespace>
|
||||
<AssemblyName>SampleGame.Android</AssemblyName>
|
||||
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
</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>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86;arm64-v8a</AndroidSupportedAbis>
|
||||
<AotAssemblies>false</AotAssemblies>
|
||||
<EnableLLVM>false</EnableLLVM>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<MandroidI18n>CJK</MandroidI18n>
|
||||
</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>
|
||||
<ItemGroup>
|
||||
<Reference Include="ManagedBass, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ManagedBass.2.0.4\lib\netstandard1.4\ManagedBass.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ManagedBass.Fx, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ManagedBass.Fx.2.0.1\lib\netstandard1.4\ManagedBass.Fx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="osuTK.Android">
|
||||
<HintPath>..\..\opentk\src\osuTK.Android\bin\Release\monoandroid50\50\osuTK.Android.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="osuTK">
|
||||
<HintPath>..\..\opentk\src\osuTK\bin\Release\netstandard2.0\osuTK.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SampleGameView.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidNativeLibrary Include="lib\arm64-v8a\libbass.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AndroidNativeLibrary>
|
||||
<AndroidNativeLibrary Include="lib\arm64-v8a\libbass_fx.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AndroidNativeLibrary>
|
||||
<AndroidNativeLibrary Include="lib\armeabi-v7a\libbass.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AndroidNativeLibrary>
|
||||
<AndroidNativeLibrary Include="lib\armeabi-v7a\libbass_fx.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AndroidNativeLibrary>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Main.axml" />
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\drawable\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidAsset Include="Assets\AboutAssets.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\osu.Framework.Android\osu.Framework.Android.csproj">
|
||||
<Project>{87D8D3B5-7E16-4207-9972-8242AF1DEC3C}</Project>
|
||||
<Name>osu.Framework.Android</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\osu.Framework\osu.Framework.csproj">
|
||||
<Project>{c76bf5b3-985e-4d39-95fe-97c9c879b83a}</Project>
|
||||
<Name>osu.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SampleGame\SampleGame.csproj">
|
||||
<Project>{E3882853-43D1-4603-AD33-D9D59C8A8692}</Project>
|
||||
<Name>SampleGame</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="bass.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
||||
25
SampleGame.Android/SampleGameView.cs
Normal file
25
SampleGame.Android/SampleGameView.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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.Util;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using osu.Framework;
|
||||
|
||||
namespace SampleGame.Android
|
||||
{
|
||||
class SampleGameView : osu.Framework.Android.AndroidGameView
|
||||
{
|
||||
public SampleGameView(Context context, IAttributeSet attrs) : base(context, attrs)
|
||||
{
|
||||
CreateGame();
|
||||
}
|
||||
public override Game CreateGame() => new SampleGameGame();
|
||||
}
|
||||
}
|
||||
11
SampleGame.Android/app.config
Normal file
11
SampleGame.Android/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
BIN
SampleGame.Android/bass.dll
Normal file
BIN
SampleGame.Android/bass.dll
Normal file
Binary file not shown.
BIN
SampleGame.Android/lib/arm64-v8a/libbass.so
Normal file
BIN
SampleGame.Android/lib/arm64-v8a/libbass.so
Normal file
Binary file not shown.
BIN
SampleGame.Android/lib/arm64-v8a/libbass_fx.so
Normal file
BIN
SampleGame.Android/lib/arm64-v8a/libbass_fx.so
Normal file
Binary file not shown.
BIN
SampleGame.Android/lib/armeabi-v7a/libbass.so
Normal file
BIN
SampleGame.Android/lib/armeabi-v7a/libbass.so
Normal file
Binary file not shown.
BIN
SampleGame.Android/lib/armeabi-v7a/libbass_fx.so
Normal file
BIN
SampleGame.Android/lib/armeabi-v7a/libbass_fx.so
Normal file
Binary file not shown.
5
SampleGame.Android/packages.config
Normal file
5
SampleGame.Android/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ManagedBass" version="2.0.4" targetFramework="monoandroid90" />
|
||||
<package id="ManagedBass.Fx" version="2.0.1" targetFramework="monoandroid90" />
|
||||
</packages>
|
||||
@@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleGame", "SampleGame\Sa
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Framework.Tests", "osu.Framework.Tests\osu.Framework.Tests.csproj", "{79803407-6F50-484F-93F5-641911EABD8A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleGame.Desktop", "SampleGame.Desktop\SampleGame.Desktop.csproj", "{2AD6EA6F-CD5A-4348-86F1-5E228B11617D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleGame.Desktop", "SampleGame.Desktop\SampleGame.Desktop.csproj", "{2AD6EA6F-CD5A-4348-86F1-5E228B11617D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -34,4 +34,10 @@ Global
|
||||
{2AD6EA6F-CD5A-4348-86F1-5E228B11617D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2AD6EA6F-CD5A-4348-86F1-5E228B11617D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {27D12E10-E38E-4ECE-8DD1-77E8C387B2DD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
41
osu.Framework.Android/AndroidGameHost.cs
Normal file
41
osu.Framework.Android/AndroidGameHost.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Handlers;
|
||||
using osu.Framework.Platform;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Android
|
||||
{
|
||||
public class AndroidGameHost : GameHost
|
||||
{
|
||||
private readonly AndroidGameView gameView;
|
||||
|
||||
public AndroidGameHost(AndroidGameView gameView)
|
||||
{
|
||||
this.gameView = gameView;
|
||||
Window = new AndroidGameWindow(gameView);
|
||||
Window.WindowStateChanged += (sender, e) =>
|
||||
{
|
||||
if (Window.WindowState != WindowState.Minimized)
|
||||
OnActivated();
|
||||
else
|
||||
OnDeactivated();
|
||||
};
|
||||
}
|
||||
|
||||
public override ITextInputSource GetTextInput() => throw new NotImplementedException();// new AndroidTextInput(gameView);
|
||||
|
||||
protected override IEnumerable<InputHandler> CreateAvailableInputHandlers() =>
|
||||
new InputHandler[] { };//new AndroidTouchHandler(gameView), new AndroidKeyboardHandler(gameView) };
|
||||
|
||||
protected override Storage GetStorage(string baseName) => new AndroidStorage(baseName, this);
|
||||
|
||||
public override void OpenFileExternally(string filename) => throw new NotImplementedException();
|
||||
|
||||
public override void OpenUrlExternally(string url) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
46
osu.Framework.Android/AndroidGameWindow.cs
Normal file
46
osu.Framework.Android/AndroidGameWindow.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Platform;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Framework.Android
|
||||
{
|
||||
public class AndroidGameWindow : GameWindow
|
||||
{
|
||||
private readonly AndroidGameView view;
|
||||
|
||||
protected new osuTK.GameWindow Implementation => (osuTK.GameWindow)base.Implementation;
|
||||
|
||||
public AndroidGameWindow(AndroidGameView view) : base(new AndroidPlatformWindow(view))
|
||||
{
|
||||
this.view = view;
|
||||
|
||||
Load += OnLoad;
|
||||
}
|
||||
|
||||
public override void SetupWindow(FrameworkConfigManager config)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override IGraphicsContext Context => view.GraphicsContext;
|
||||
|
||||
public override bool Focused => true;
|
||||
|
||||
public override osuTK.WindowState WindowState { get => osuTK.WindowState.Normal; set { } }
|
||||
|
||||
protected void OnLoad(object sender, EventArgs e)
|
||||
{
|
||||
var implementationField = typeof(osuTK.NativeWindow).GetRuntimeFields().Single(x => x.Name == "implementation");
|
||||
|
||||
var windowImpl = implementationField.GetValue(Implementation);
|
||||
|
||||
//isSdl = windowImpl.GetType().Name == "Sdl2NativeWindow";
|
||||
}
|
||||
}
|
||||
}
|
||||
144
osu.Framework.Android/AndroidPlatformWindow.cs
Normal file
144
osu.Framework.Android/AndroidPlatformWindow.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
using osuTK.Platform;
|
||||
|
||||
namespace osu.Framework.Android
|
||||
{
|
||||
public class AndroidPlatformWindow : IGameWindow
|
||||
{
|
||||
private readonly AndroidGameView gameView;
|
||||
|
||||
public AndroidPlatformWindow(AndroidGameView gameView)
|
||||
{
|
||||
this.gameView = gameView;
|
||||
|
||||
gameView.Load += (o, e) => Load?.Invoke(o, e);
|
||||
gameView.Unload += (o, e) => Unload?.Invoke(o, e);
|
||||
gameView.UpdateFrame += (o, e) => UpdateFrame?.Invoke(o, e);
|
||||
gameView.RenderFrame += (o, e) => RenderFrame?.Invoke(o, e);
|
||||
gameView.Resize += (o, e) => Resize?.Invoke(o, e);
|
||||
gameView.Closed += (o, e) => Closed?.Invoke(o, e);
|
||||
gameView.Disposed += (o, e) => Disposed?.Invoke(o, e);
|
||||
gameView.TitleChanged += (o, e) => TitleChanged?.Invoke(o, e);
|
||||
gameView.VisibleChanged += (o, e) => VisibleChanged?.Invoke(o, e);
|
||||
gameView.WindowStateChanged += (o, e) => WindowStateChanged?.Invoke(o, e);
|
||||
}
|
||||
// We cannot have titles.
|
||||
public string Title { get => gameView.Title; set { } }
|
||||
|
||||
// Always set this to true.
|
||||
public bool Focused => true;
|
||||
|
||||
public bool Visible { get => gameView.Visible; set { } }
|
||||
|
||||
public bool Exists => true;
|
||||
|
||||
public IWindowInfo WindowInfo => gameView.WindowInfo;
|
||||
|
||||
public WindowState WindowState { get => WindowState.Fullscreen; set { } }
|
||||
public WindowBorder WindowBorder { get => WindowBorder.Hidden; set { } }
|
||||
public Rectangle Bounds { get => new Rectangle(0, 0, Width, Height); set { } }
|
||||
public Point Location { get => Point.Empty; set { } }
|
||||
public Size Size { get => new Size((int)(gameView.Size.Width * gameView.ScaleX), (int)(gameView.Height * gameView.ScaleY)); set { } }
|
||||
public int X { get => 0; set { } }
|
||||
public int Y { get => 0; set { } }
|
||||
public int Width { get => Size.Width; set { } }
|
||||
public int Height { get => Size.Height; set { } }
|
||||
public Rectangle ClientRectangle { get => new Rectangle(0, 0, Width, Height); set { } }
|
||||
public Size ClientSize { get => Size; set { } }
|
||||
public MouseCursor Cursor { get => MouseCursor.Default; set { } }
|
||||
public bool CursorVisible { get => false; set { } }
|
||||
public bool CursorGrabbed { get => true; set { } }
|
||||
|
||||
public Icon Icon { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public event EventHandler<EventArgs> Load;
|
||||
public event EventHandler<EventArgs> Unload;
|
||||
public event EventHandler<FrameEventArgs> UpdateFrame;
|
||||
public event EventHandler<FrameEventArgs> RenderFrame;
|
||||
public event EventHandler<EventArgs> Move;
|
||||
public event EventHandler<EventArgs> Resize;
|
||||
public event EventHandler<CancelEventArgs> Closing;
|
||||
public event EventHandler<EventArgs> Closed;
|
||||
public event EventHandler<EventArgs> Disposed;
|
||||
public event EventHandler<EventArgs> IconChanged;
|
||||
public event EventHandler<EventArgs> TitleChanged;
|
||||
public event EventHandler<EventArgs> VisibleChanged;
|
||||
public event EventHandler<EventArgs> FocusedChanged;
|
||||
public event EventHandler<EventArgs> WindowBorderChanged;
|
||||
public event EventHandler<EventArgs> WindowStateChanged;
|
||||
public event EventHandler<KeyboardKeyEventArgs> KeyDown;
|
||||
public event EventHandler<KeyPressEventArgs> KeyPress;
|
||||
public event EventHandler<KeyboardKeyEventArgs> KeyUp;
|
||||
public event EventHandler<EventArgs> MouseLeave;
|
||||
public event EventHandler<EventArgs> MouseEnter;
|
||||
public event EventHandler<MouseButtonEventArgs> MouseDown;
|
||||
public event EventHandler<MouseButtonEventArgs> MouseUp;
|
||||
public event EventHandler<MouseMoveEventArgs> MouseMove;
|
||||
public event EventHandler<MouseWheelEventArgs> MouseWheel;
|
||||
public event EventHandler<FileDropEventArgs> FileDrop;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
gameView.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
gameView.Dispose();
|
||||
}
|
||||
|
||||
public void MakeCurrent()
|
||||
{
|
||||
gameView.MakeCurrent();
|
||||
}
|
||||
|
||||
public Point PointToClient(Point point)
|
||||
{
|
||||
return point;
|
||||
}
|
||||
|
||||
public Point PointToScreen(Point point)
|
||||
{
|
||||
return point;
|
||||
}
|
||||
|
||||
public void ProcessEvents()
|
||||
{
|
||||
gameView.ProcessEvents();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
gameView.Handler.Post(() =>
|
||||
{
|
||||
RenderFrame?.Invoke(this, new FrameEventArgs() { });
|
||||
SwapBuffers();
|
||||
});
|
||||
UpdateFrame?.Invoke(this, new FrameEventArgs() { });
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
});
|
||||
gameView.Run();
|
||||
}
|
||||
|
||||
public void Run(double updateRate)
|
||||
{
|
||||
gameView.Run(updateRate);
|
||||
}
|
||||
|
||||
public void SwapBuffers()
|
||||
{
|
||||
gameView.SwapBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
75
osu.Framework.Android/AndroidStorage.cs
Normal file
75
osu.Framework.Android/AndroidStorage.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
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;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Framework.Android
|
||||
{
|
||||
class AndroidStorage : DesktopStorage
|
||||
{
|
||||
public AndroidStorage(string baseName, GameHost host)
|
||||
: base(baseName, host)
|
||||
{
|
||||
BasePath = LocateBasePath();
|
||||
}
|
||||
|
||||
//Dopilnuj, aby zamieniać ścieżki względne na bezwzględne
|
||||
|
||||
protected override string LocateBasePath()
|
||||
{
|
||||
return (string)Application.Context.GetExternalFilesDir("");
|
||||
}
|
||||
|
||||
/*public override string[] GetFiles(string path) => (string[])Directory.EnumerateFiles(GetUsablePathFor(path));
|
||||
public override string[] GetDirectories(string path) => Directory.GetDirectories(GetUsablePathFor(path));
|
||||
public override void Delete(string path)
|
||||
{
|
||||
FileSafety.FileDelete(GetUsablePathFor(path));
|
||||
}
|
||||
public override bool Exists(string path)
|
||||
{
|
||||
return File.Exists(GetUsablePathFor(path));
|
||||
}
|
||||
public override void DeleteDirectory(string path)
|
||||
{
|
||||
path = GetUsablePathFor(path);
|
||||
// handles the case where the directory doesn't exist, which will throw a DirectoryNotFoundException.
|
||||
if (Directory.Exists(path))
|
||||
Directory.Delete(path, true);
|
||||
}
|
||||
public override bool ExistsDirectory(string path) => Directory.Exists(GetUsablePathFor(path));
|
||||
public override Stream GetStream(string path, FileAccess access = FileAccess.Read, FileMode mode = FileMode.OpenOrCreate)
|
||||
{
|
||||
path = GetUsablePathFor(path, access != FileAccess.Read);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
switch (access)
|
||||
{
|
||||
case FileAccess.Read:
|
||||
if (!File.Exists(path)) return null;
|
||||
return File.Open(path, FileMode.Open, access, FileShare.Read);
|
||||
default:
|
||||
return File.Open(path, mode, access);
|
||||
}
|
||||
}
|
||||
public override string GetDatabaseConnectionString(string name)
|
||||
{
|
||||
return string.Concat("Data Source=", GetUsablePathFor($@"{name}.db", true));
|
||||
}
|
||||
public override void DeleteDatabase(string name) => Delete($@"{name}.db");*/
|
||||
|
||||
public override void OpenInNativeExplorer()
|
||||
{
|
||||
//Not needed now.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
135
osu.Framework.Android/osu.Framework.Android.csproj
Normal file
135
osu.Framework.Android/osu.Framework.Android.csproj
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>osu.Framework.Android</RootNamespace>
|
||||
<AssemblyName>osu.Framework.Android</AssemblyName>
|
||||
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
</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>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="osuTK.Android">
|
||||
<HintPath>..\..\opentk\src\osuTK.Android\bin\Release\monoandroid50\50\osuTK.Android.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="osuTK">
|
||||
<HintPath>..\..\opentk\src\osuTK\bin\Release\netstandard2.0\osuTK.dll</HintPath>
|
||||
</Reference>
|
||||
<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="AndroidPlatformWindow.cs" />
|
||||
<Compile Include="AndroidStorage.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="AndroidGameWindow.cs" />
|
||||
<Compile Include="AndroidGameView.cs" />
|
||||
<Compile Include="AndroidGameHost.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
</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>
|
||||
Reference in New Issue
Block a user