mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
Updated demos and templates to MonoGame 3.8.1
This commit is contained in:
parent
48dfa8f1ee
commit
711f60a97e
26 changed files with 612 additions and 646 deletions
|
@ -90,6 +90,10 @@ Fixes
|
|||
Additions
|
||||
- Added MLEM.Startup.FNA, which is fully compatible with FNA
|
||||
|
||||
### MLEM.Templates
|
||||
Improvements
|
||||
- Updated to MonoGame 3.8.1
|
||||
|
||||
## 5.3.0
|
||||
### MLEM
|
||||
Additions
|
||||
|
|
36
Demos.Android/.config/dotnet-tools.json
Normal file
36
Demos.Android/.config/dotnet-tools.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-mgcb": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-linux": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-linux"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-windows": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-windows"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-mac": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-mac"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +1,55 @@
|
|||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Net;
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MLEM.Extensions;
|
||||
using MLEM.Misc;
|
||||
using Uri = Android.Net.Uri;
|
||||
|
||||
namespace Demos.Android {
|
||||
[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 {
|
||||
namespace Demos.Android;
|
||||
|
||||
private GameImpl game;
|
||||
private View view;
|
||||
[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 {
|
||||
|
||||
protected override void OnCreate(Bundle bundle) {
|
||||
base.OnCreate(bundle);
|
||||
// render under notches
|
||||
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
|
||||
this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
|
||||
private GameImpl game;
|
||||
private View view;
|
||||
|
||||
MlemPlatform.Current = new MlemPlatform.Mobile(KeyboardInput.Show, l => this.StartActivity(new Intent(Intent.ActionView, Uri.Parse(l))));
|
||||
this.game = new GameImpl();
|
||||
// reset MlemGame width and height to use device's aspect ratio
|
||||
this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window);
|
||||
// disable mouse handling for android to make emulator behavior more coherent
|
||||
this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false;
|
||||
// set the game to fullscreen to cause the status bar to be hidden
|
||||
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
||||
this.view = this.game.Services.GetService(typeof(View)) as View;
|
||||
this.SetContentView(this.view);
|
||||
this.game.Run();
|
||||
}
|
||||
|
||||
public override void OnWindowFocusChanged(bool hasFocus) {
|
||||
base.OnWindowFocusChanged(hasFocus);
|
||||
// hide the status bar
|
||||
if (hasFocus)
|
||||
this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.ImmersiveSticky | SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen);
|
||||
}
|
||||
protected override void OnCreate(Bundle bundle) {
|
||||
base.OnCreate(bundle);
|
||||
// render under notches
|
||||
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
|
||||
this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
|
||||
|
||||
MlemPlatform.Current = new MlemPlatform.Mobile(KeyboardInput.Show, l => this.StartActivity(new Intent(Intent.ActionView, Uri.Parse(l))));
|
||||
this.game = new GameImpl();
|
||||
// reset MlemGame width and height to use device's aspect ratio
|
||||
this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window);
|
||||
// disable mouse handling for android to make emulator behavior more coherent
|
||||
this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false;
|
||||
// set the game to fullscreen to cause the status bar to be hidden
|
||||
this.game.GraphicsDeviceManager.IsFullScreen = true;
|
||||
this.view = this.game.Services.GetService(typeof(View)) as View;
|
||||
this.SetContentView(this.view);
|
||||
this.game.Run();
|
||||
}
|
||||
|
||||
public override void OnWindowFocusChanged(bool hasFocus) {
|
||||
base.OnWindowFocusChanged(hasFocus);
|
||||
// hide the status bar
|
||||
if (hasFocus) {
|
||||
#pragma warning disable CS0618
|
||||
// TODO this is deprecated, find out how to replace it
|
||||
this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.ImmersiveSticky | SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen);
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
6
Demos.Android/AndroidManifest.xml
Normal file
6
Demos.Android/AndroidManifest.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.ellpeck.mlem.demos.android" android:versionCode="1" android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
<application android:label="MLEM Android Demos" />
|
||||
</manifest>
|
|
@ -1,104 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{410C0262-131C-4D0E-910D-D01B4F7143E0}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Demos.Android</RootNamespace>
|
||||
<AssemblyName>Demos.Android</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidStoreUncompressedFileExtensions>.m4a</AndroidStoreUncompressedFileExtensions>
|
||||
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
|
||||
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;ANDROID</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>TRACE;ANDROID</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
||||
<AotAssemblies>false</AotAssemblies>
|
||||
<EnableLLVM>false</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<MandroidI18n />
|
||||
<AndroidPackageFormat>aab</AndroidPackageFormat>
|
||||
<AndroidUseAapt2>true</AndroidUseAapt2>
|
||||
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
|
||||
<TargetFramework>net6.0-android</TargetFramework>
|
||||
<SupportedOSPlatformVersion>31</SupportedOSPlatformVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ApplicationId>de.ellpeck.mlem.demos.android</ApplicationId>
|
||||
<ApplicationVersion>1</ApplicationVersion>
|
||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Mono.Android" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Activity1.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Drawable\Icon.png" />
|
||||
<AndroidResource Include="Resources\Values\Strings.xml" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.263" />
|
||||
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.1.263" />
|
||||
|
||||
<ProjectReference Include="..\Demos\Demos.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="..\Demos\Content\Content.mgcb" />
|
||||
<None Include="..\Demos\Content\*\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Coroutine" Version="2.1.3" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.0.1641" />
|
||||
<PackageReference Include="TextCopy" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Demos\Demos.csproj">
|
||||
<Project>{1bc4682b-aa14-4937-b5c7-707e20fe88ff}</Project>
|
||||
<Name>Demos</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.csproj">
|
||||
<Project>{997f4739-7bec-4621-b9ca-68deb2d74412}</Project>
|
||||
<Name>MLEM.Startup</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.csproj">
|
||||
<Project>{6f00629a-8b87-4264-8896-19983285e32f}</Project>
|
||||
<Name>MLEM.Ui</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MLEM\MLEM.csproj">
|
||||
<Project>{1d6ab762-43c4-4775-8924-707c7ec3f142}</Project>
|
||||
<Name>MLEM</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.ellpeck.mlem.demos.android" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
|
||||
<application android:label="MLEM Android Demos" android:resizeableActivity="true" />
|
||||
</manifest>
|
|
@ -1,15 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MLEM Android Demos")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MLEM Android Demos")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
76
Demos.Android/Resources/Resource.Designer.cs
generated
76
Demos.Android/Resources/Resource.Designer.cs
generated
|
@ -1,76 +0,0 @@
|
|||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("Demos.Android.Resource", IsApplication=true)]
|
||||
|
||||
namespace Demos.Android
|
||||
{
|
||||
|
||||
|
||||
[global::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()
|
||||
{
|
||||
}
|
||||
|
||||
public partial class Attribute
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Drawable
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7F010000
|
||||
public const int Icon = 2130771968;
|
||||
|
||||
static Drawable()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7F020000
|
||||
public const int app_name = 2130837504;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
36
Demos.DesktopGL/.config/dotnet-tools.json
Normal file
36
Demos.DesktopGL/.config/dotnet-tools.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-mgcb": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-linux": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-linux"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-windows": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-windows"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-mac": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-mac"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,28 +2,32 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
<AssemblyName>MLEM Desktop Demos</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.263" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263" />
|
||||
|
||||
<ProjectReference Include="..\Demos\Demos.csproj" />
|
||||
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.csproj" />
|
||||
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.csproj" />
|
||||
<ProjectReference Include="..\MLEM\MLEM.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="..\Demos\Content\Content.mgcb" />
|
||||
<Content Include="..\Demos\Content\*\**" />
|
||||
<EmbeddedResource Include="Icon.ico" />
|
||||
<EmbeddedResource Include="Icon.bmp" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -11,7 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
|
2
FNA
2
FNA
|
@ -1 +1 @@
|
|||
Subproject commit 700a6f096ad359cc12634eeb5608ee9c8d29798c
|
||||
Subproject commit 102990f514f1e5bfac07d33f7c33e2e712946da4
|
|
@ -1 +1 @@
|
|||
Subproject commit 460a60ca817e10b6c9bae3e3c05affd1b0bb4ba7
|
||||
Subproject commit f0774130cad6cec0b790a58bc7c811a186443fb3
|
|
@ -17,7 +17,6 @@ namespace MLEM.Data.Content {
|
|||
#endif
|
||||
{
|
||||
// premultiply the texture's color to be in line with the pipeline's texture reader
|
||||
// TODO this can be converted to use https://github.com/MonoGame/MonoGame/pull/7369 in the future
|
||||
using (var texture = Texture2D.FromStream(manager.GraphicsDevice, stream)) {
|
||||
var ret = new Texture2D(manager.GraphicsDevice, texture.Width, texture.Height);
|
||||
using (var textureData = texture.GetTextureData()) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<PackageReference Include="MonoGame.Extended.Tiled" Version="3.8.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.1.5">
|
||||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.1.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-mgcb": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-linux": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-linux"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-windows": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-windows"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-mac": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-mac"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -11,12 +11,17 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Contentless" Version="3.*" />
|
||||
<PackageReference Include="MLEM.Startup" Version="6.*" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.263" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Icon.ico" />
|
||||
<EmbeddedResource Include="Icon.bmp" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
using MLEM.Startup;
|
||||
|
||||
namespace TemplateNamespace {
|
||||
public class GameImpl : MlemGame {
|
||||
namespace TemplateNamespace;
|
||||
|
||||
public static GameImpl Instance { get; private set; }
|
||||
public class GameImpl : MlemGame {
|
||||
|
||||
public GameImpl() {
|
||||
Instance = this;
|
||||
}
|
||||
public static GameImpl Instance { get; private set; }
|
||||
|
||||
public GameImpl() {
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MLEM.Startup" Version="6.*" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*">
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
|
36
Sandbox/.config/dotnet-tools.json
Normal file
36
Sandbox/.config/dotnet-tools.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-mgcb": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-linux": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-linux"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-windows": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-windows"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-mac": {
|
||||
"version": "3.8.1.263",
|
||||
"commands": [
|
||||
"mgcb-editor-mac"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,13 +62,4 @@
|
|||
#begin Textures/Test.png
|
||||
/copy:Textures/Test.png
|
||||
|
||||
#begin Tiled/Map.tmx
|
||||
/importer:TiledMapImporter
|
||||
/processor:TiledMapProcessor
|
||||
/build:Tiled/Map.tmx
|
||||
|
||||
#begin Tiled/Tileset.tsx
|
||||
/importer:TiledMapTilesetImporter
|
||||
/processor:TiledMapTilesetProcessor
|
||||
/build:Tiled/Tileset.tsx
|
||||
|
||||
|
|
|
@ -27,378 +27,373 @@ using MonoGame.Extended;
|
|||
using MonoGame.Extended.Tiled;
|
||||
using MonoGame.Extended.ViewportAdapters;
|
||||
|
||||
namespace Sandbox {
|
||||
public class GameImpl : MlemGame {
|
||||
namespace Sandbox;
|
||||
|
||||
private Camera camera;
|
||||
private TiledMap map;
|
||||
private IndividualTiledMapRenderer mapRenderer;
|
||||
private TiledMapCollisions collisions;
|
||||
private RawContentManager rawContent;
|
||||
private TokenizedString tokenized;
|
||||
public class GameImpl : MlemGame {
|
||||
|
||||
public GameImpl() {
|
||||
this.IsMouseVisible = true;
|
||||
this.Window.ClientSizeChanged += (o, args) => {
|
||||
Console.WriteLine("Size changed");
|
||||
};
|
||||
private Camera camera;
|
||||
private TiledMap map;
|
||||
private IndividualTiledMapRenderer mapRenderer;
|
||||
private TiledMapCollisions collisions;
|
||||
private RawContentManager rawContent;
|
||||
private TokenizedString tokenized;
|
||||
|
||||
public GameImpl() {
|
||||
this.IsMouseVisible = true;
|
||||
this.Window.ClientSizeChanged += (o, args) => {
|
||||
Console.WriteLine("Size changed");
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadContent() {
|
||||
base.LoadContent();
|
||||
|
||||
this.Components.Add(this.rawContent = new RawContentManager(this.Services));
|
||||
|
||||
this.map = MlemGame.LoadContent<TiledMap>("Tiled/Map");
|
||||
this.mapRenderer = new IndividualTiledMapRenderer(this.map);
|
||||
this.collisions = new TiledMapCollisions(this.map);
|
||||
|
||||
this.camera = new Camera(this.GraphicsDevice) {
|
||||
AutoScaleWithScreen = true,
|
||||
Scale = 2,
|
||||
LookingPosition = new Vector2(25, 25) * this.map.GetTileSize(),
|
||||
MinScale = 0.25F,
|
||||
MaxScale = 4
|
||||
};
|
||||
|
||||
var tex = this.rawContent.Load<Texture2D>("Textures/Test");
|
||||
using (var data = tex.GetTextureData()) {
|
||||
var textureData = data;
|
||||
textureData[1, 9] = Color.Pink;
|
||||
textureData[textureData.FromIndex(textureData.ToIndex(25, 9))] = Color.Yellow;
|
||||
}
|
||||
|
||||
protected override void LoadContent() {
|
||||
// TODO remove with MonoGame 3.8.1 https://github.com/MonoGame/MonoGame/issues/7298
|
||||
this.GraphicsDeviceManager.PreferredBackBufferWidth = 1280;
|
||||
this.GraphicsDeviceManager.PreferredBackBufferHeight = 720;
|
||||
this.GraphicsDeviceManager.ApplyChanges();
|
||||
|
||||
base.LoadContent();
|
||||
|
||||
this.Components.Add(this.rawContent = new RawContentManager(this.Services));
|
||||
|
||||
this.map = MlemGame.LoadContent<TiledMap>("Tiled/Map");
|
||||
this.mapRenderer = new IndividualTiledMapRenderer(this.map);
|
||||
this.collisions = new TiledMapCollisions(this.map);
|
||||
|
||||
this.camera = new Camera(this.GraphicsDevice) {
|
||||
AutoScaleWithScreen = true,
|
||||
Scale = 2,
|
||||
LookingPosition = new Vector2(25, 25) * this.map.GetTileSize(),
|
||||
MinScale = 0.25F,
|
||||
MaxScale = 4
|
||||
};
|
||||
|
||||
var tex = this.rawContent.Load<Texture2D>("Textures/Test");
|
||||
using (var data = tex.GetTextureData()) {
|
||||
var textureData = data;
|
||||
textureData[1, 9] = Color.Pink;
|
||||
textureData[textureData.FromIndex(textureData.ToIndex(25, 9))] = Color.Yellow;
|
||||
}
|
||||
|
||||
var system = new FontSystem();
|
||||
system.AddFont(File.ReadAllBytes("Content/Fonts/Cadman_Roman.otf"));
|
||||
//var font = new GenericSpriteFont(LoadContent<SpriteFont>("Fonts/TestFont"));
|
||||
//var font = new GenericBitmapFont(LoadContent<BitmapFont>("Fonts/Regular"));
|
||||
var font = new GenericStashFont(system.GetFont(32));
|
||||
var spriteFont = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/TestFont"));
|
||||
this.UiSystem.Style = new UntexturedStyle(this.SpriteBatch) {
|
||||
Font = font,
|
||||
TextScale = 0.5F,
|
||||
PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
|
||||
ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4)
|
||||
};
|
||||
this.UiSystem.AutoScaleReferenceSize = new Point(1280, 720);
|
||||
this.UiSystem.AutoScaleWithScreen = true;
|
||||
this.UiSystem.GlobalScale = 5;
|
||||
|
||||
/*this.OnDraw += (g, time) => {
|
||||
const string strg = "This is a test string\nto test things\n\nMany things are being tested, like the ability\nfor this font to agree\n\nwith newlines";
|
||||
this.SpriteBatch.Begin();
|
||||
spriteFont.DrawString(this.SpriteBatch, strg, new Vector2(600, 100), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
|
||||
font.DrawString(this.SpriteBatch, strg, new Vector2(600, 100), Color.White, 0, Vector2.Zero, 2, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.End();
|
||||
};*/
|
||||
|
||||
var panel = new Panel(Anchor.Center, new Vector2(0, 100), Vector2.Zero) {SetWidthBasedOnChildren = true};
|
||||
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(100, 10)));
|
||||
panel.AddChild(new Button(Anchor.AutoCenter, new Vector2(80, 10)));
|
||||
//this.UiSystem.Add("Panel", panel);
|
||||
|
||||
panel.SetData("TestKey", new Vector2(10, 2));
|
||||
//Console.WriteLine(panel.GetData<Vector2>("TestKey"));
|
||||
|
||||
var obj = new Test(Vector2.One, "test") {
|
||||
Vec = new Vector2(10, 20),
|
||||
Point = new Point(20, 30),
|
||||
Dir = Direction2.Left,
|
||||
OtherTest = new Test(Vector2.One, "other") {
|
||||
Vec = new Vector2(70, 30),
|
||||
Dir = Direction2.Right
|
||||
}
|
||||
};
|
||||
Console.WriteLine(obj);
|
||||
|
||||
for (var i = 0; i < 360; i += 45) {
|
||||
var rad = MathHelper.ToRadians(i);
|
||||
var vec = new Vector2((float) Math.Sin(rad), (float) Math.Cos(rad));
|
||||
var dir = vec.ToDirection();
|
||||
Console.WriteLine(vec + " -> " + dir);
|
||||
}
|
||||
|
||||
var writer = new StringWriter();
|
||||
this.Content.GetJsonSerializer().Serialize(writer, obj);
|
||||
//Console.WriteLine(writer.ToString());
|
||||
// {"Vec":"10 20","Point":"20 30","Rectangle":"1 2 3 4","RectangleF":"4 5 6 7"}
|
||||
|
||||
// Also:
|
||||
//this.Content.AddJsonConverter(new CustomConverter());
|
||||
|
||||
var res = this.Content.LoadJson<Test>("Test");
|
||||
Console.WriteLine("The res is " + res);
|
||||
|
||||
var gradient = this.SpriteBatch.GenerateGradientTexture(Color.Green, Color.Red, Color.Blue, Color.Yellow);
|
||||
/*this.OnDraw += (game, time) => {
|
||||
this.SpriteBatch.Begin();
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Rectangle(640 - 4, 360 - 4, 8, 8), Color.Green);
|
||||
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Rectangle(200, 400, 200, 400), Color.Green);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1), new Vector2(200, 400), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, ellipsis: "..."), new Vector2(200, 450), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, true), new Vector2(200, 500), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, true, "..."), new Vector2(200, 550), Color.White);
|
||||
|
||||
this.SpriteBatch.Draw(gradient, new Rectangle(300, 100, 200, 200), Color.White);
|
||||
this.SpriteBatch.End();
|
||||
};*/
|
||||
|
||||
var sc = 4;
|
||||
var formatter = new TextFormatter();
|
||||
formatter.AddImage("Test", new TextureRegion(tex, 0, 8, 24, 24));
|
||||
formatter.Macros.Add(new Regex("<testmacro>"), (f, m, r) => "<test1>");
|
||||
formatter.Macros.Add(new Regex("<test1>"), (f, m, r) => "<test2> blue");
|
||||
formatter.Macros.Add(new Regex("<test2>"), (f, m, r) => "<c Blue>");
|
||||
var strg = "This text uses a bunch of non-breaking~spaces to see if macros work. Additionally, it uses a macro that resolves into a bunch of other macros and then, at the end, into <testmacro> text</c>.";
|
||||
//var strg = "Lorem Ipsum <i Test> is simply dummy text of the <i Test> printing and typesetting <i Test> industry. Lorem Ipsum has been the industry's standard dummy text <i Test> ever since the <i Test> 1500s, when <i Test><i Test><i Test><i Test><i Test><i Test><i Test> an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
|
||||
//var strg = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
|
||||
//var strg = "This is <u>a test of the underlined formatting code</u>!";
|
||||
this.tokenized = formatter.Tokenize(font, strg);
|
||||
this.tokenized.Split(font, 400, sc);
|
||||
|
||||
var square = this.SpriteBatch.GenerateSquareTexture(Color.Yellow);
|
||||
var round = this.SpriteBatch.GenerateCircleTexture(Color.Green, 128);
|
||||
|
||||
var region = new TextureRegion(round) {Pivot = new Vector2(0.5F)};
|
||||
var region2 = new TextureRegion(round);
|
||||
|
||||
var atlas = this.Content.LoadTextureAtlas("Textures/Furniture");
|
||||
foreach (var r in atlas.Regions)
|
||||
Console.WriteLine(r.Name + ": " + r.U + " " + r.V + " " + r.Width + " " + r.Height + " " + r.PivotPixels);
|
||||
|
||||
this.OnDraw += (g, time) => {
|
||||
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
//this.SpriteBatch.Draw(square, new Rectangle(10, 10, 400, 400), Color.White);
|
||||
//this.SpriteBatch.Draw(round, new Rectangle(10, 10, 400, 400), Color.White);
|
||||
this.SpriteBatch.Draw(region, new Vector2(50, 50), Color.White, 0, Vector2.Zero, 0.5F, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.Draw(region2, new Vector2(50, 50), Color.Yellow * 0.5F, 0, Vector2.Zero, 0.5F, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Vector2(50, 50), Color.Pink);
|
||||
|
||||
//this.SpriteBatch.FillRectangle(new RectangleF(400, 20, 400, 1000), Color.Green);
|
||||
//font.DrawString(this.SpriteBatch, this.tokenized.DisplayString, new Vector2(400, 20), Color.White * 0.25F, 0, Vector2.Zero, sc, SpriteEffects.None, 0);
|
||||
//this.tokenized.Draw(time, this.SpriteBatch, new Vector2(400, 20), font, Color.White, sc, 0);
|
||||
//this.SpriteBatch.DrawGrid(new Vector2(30, 30), new Vector2(40, 60), new Point(10, 5), Color.Yellow, 3);
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
this.OnUpdate += (g, time) => {
|
||||
if (this.InputHandler.IsPressed(Keys.W)) {
|
||||
this.tokenized = formatter.Tokenize(font, strg);
|
||||
this.tokenized.Split(font, this.InputHandler.IsModifierKeyDown(ModifierKey.Shift) ? 400 : 500, sc);
|
||||
}
|
||||
this.tokenized.Update(time);
|
||||
};
|
||||
|
||||
/*var testPanel = new Panel(Anchor.Center, new Vector2(0.5F, 100), Vector2.Zero);
|
||||
testPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.25F, -1)));
|
||||
testPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(2500, 1)) {PreventParentSpill = true});
|
||||
this.UiSystem.Add("Test", testPanel);
|
||||
|
||||
var invalidPanel = new Panel(Anchor.Center, Vector2.Zero, Vector2.Zero) {
|
||||
SetWidthBasedOnChildren = true,
|
||||
SetHeightBasedOnChildren = true
|
||||
};
|
||||
invalidPanel.AddChild(new Paragraph(Anchor.AutoRight, 1, "This is some test text!", true));
|
||||
invalidPanel.AddChild(new VerticalSpace(1));
|
||||
this.UiSystem.Add("Invalid", invalidPanel);*/
|
||||
|
||||
/*var loadGroup = new Group(Anchor.TopLeft, Vector2.One, false);
|
||||
var loadPanel = loadGroup.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, false) {
|
||||
ChildPadding = new Padding(5, 10, 5, 5)
|
||||
});
|
||||
for (var i = 0; i < 1; i++) {
|
||||
var button = loadPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
|
||||
SetHeightBasedOnChildren = true,
|
||||
Padding = new Padding(0, 0, 0, 1),
|
||||
ChildPadding = new Padding(3)
|
||||
});
|
||||
button.AddChild(new Group(Anchor.AutoLeft, new Vector2(0.5F, 30), false) {
|
||||
CanBeMoused = false
|
||||
});
|
||||
}
|
||||
var par = loadPanel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is another\ntest string\n\nwith many lines\nand many more!"));
|
||||
par.OnUpdated = (e, time) => {
|
||||
GenericFont newFont = Input.IsModifierKeyDown(ModifierKey.Shift) ? spriteFont : font;
|
||||
if (newFont != par.RegularFont.Value) {
|
||||
par.TextScaleMultiplier = newFont == font ? 1 : 0.5F;
|
||||
par.RegularFont = newFont;
|
||||
par.ForceUpdateArea();
|
||||
}
|
||||
};
|
||||
par.OnDrawn = (e, time, batch, a) => batch.DrawRectangle(e.DisplayArea.ToExtended(), Color.Red);
|
||||
this.UiSystem.Add("Load", loadGroup);*/
|
||||
|
||||
/*var spillPanel = new Panel(Anchor.Center, new Vector2(100), Vector2.Zero);
|
||||
var squishingGroup = spillPanel.AddChild(new SquishingGroup(Anchor.TopLeft, Vector2.One));
|
||||
squishingGroup.AddChild(new Button(Anchor.TopLeft, new Vector2(30), "TL") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D1),
|
||||
Priority = 10
|
||||
}).SetData("Ref", "TL");
|
||||
squishingGroup.AddChild(new Button(Anchor.TopRight, new Vector2(30), "TR") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D2),
|
||||
Priority = 20
|
||||
}).SetData("Ref", "TR");
|
||||
squishingGroup.AddChild(new Button(Anchor.BottomLeft, new Vector2(30), "BL") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D3),
|
||||
Priority = 30
|
||||
}).SetData("Ref", "BL");
|
||||
squishingGroup.AddChild(new Button(Anchor.BottomRight, new Vector2(30), "BR") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D4),
|
||||
Priority = 40
|
||||
}).SetData("Ref", "BR");
|
||||
squishingGroup.AddChild(new Button(Anchor.Center, Vector2.Zero, "0") {
|
||||
PositionOffset = new Vector2(-10, -5),
|
||||
Size = new Vector2(60, 55),
|
||||
OnPressed = e => {
|
||||
e.Priority = 100 - e.Priority;
|
||||
((Button) e).Text.Text = e.Priority.ToString();
|
||||
e.SetAreaDirty();
|
||||
}
|
||||
}).SetData("Ref", "Main");
|
||||
this.UiSystem.Add("SpillTest", spillPanel);*/
|
||||
|
||||
var regularFont = spriteFont.Font;
|
||||
var genericFont = spriteFont;
|
||||
|
||||
var index = 0;
|
||||
var pos = new Vector2(100, 20);
|
||||
var scale = 1F;
|
||||
var origin = Vector2.Zero;
|
||||
var rotation = 0F;
|
||||
var effects = SpriteEffects.None;
|
||||
|
||||
this.OnDraw += (g, time) => {
|
||||
const string testString = "This is a\ntest string\n\twith long lines.\nLet's write some more stuff. Let's\r\nsplit lines weirdly.";
|
||||
if (MlemGame.Input.IsKeyPressed(Keys.I)) {
|
||||
index++;
|
||||
if (index == 1) {
|
||||
scale = 2;
|
||||
} else if (index == 2) {
|
||||
origin = new Vector2(15, 15);
|
||||
} else if (index == 3) {
|
||||
rotation = 0.25F;
|
||||
} else if (index == 4) {
|
||||
effects = SpriteEffects.FlipHorizontally;
|
||||
} else if (index == 5) {
|
||||
effects = SpriteEffects.FlipVertically;
|
||||
} else if (index == 6) {
|
||||
effects = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
|
||||
}
|
||||
}
|
||||
|
||||
this.SpriteBatch.Begin();
|
||||
if (MlemGame.Input.IsKeyDown(Keys.LeftShift)) {
|
||||
this.SpriteBatch.DrawString(regularFont, testString, pos, Color.Red, rotation, origin, scale, effects, 0);
|
||||
} else {
|
||||
genericFont.DrawString(this.SpriteBatch, testString, pos, Color.Green, rotation, origin, scale, effects, 0);
|
||||
}
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
|
||||
var viewport = new BoxingViewportAdapter(this.Window, this.GraphicsDevice, 1280, 720);
|
||||
var newPanel = new Panel(Anchor.TopLeft, new Vector2(200, 100), new Vector2(10, 10));
|
||||
newPanel.AddChild(new Button(Anchor.TopLeft, new Vector2(100, 20), "Text", "Tooltip text"));
|
||||
this.UiSystem.Add("Panel", newPanel);
|
||||
|
||||
var keybindPanel = new Panel(Anchor.BottomRight, new Vector2(130, 150), new Vector2(5));
|
||||
for (var i = 0; i < 15; i++) {
|
||||
var button = keybindPanel.AddChild(new Button(default, default, i.ToString()));
|
||||
button.Anchor = Anchor.AutoInline;
|
||||
button.Padding = new Padding(0.5F);
|
||||
button.SetHeightBasedOnChildren = false;
|
||||
button.Size = new Vector2(30, 50);
|
||||
}
|
||||
this.UiSystem.Add("Keybinds", keybindPanel);
|
||||
|
||||
var packer = new RuntimeTexturePacker();
|
||||
var regions = new List<TextureRegion>();
|
||||
packer.Add(new UniformTextureAtlas(tex, 16, 16), r => {
|
||||
regions.AddRange(r.Values);
|
||||
Console.WriteLine($"Returned {r.Count} regions: {string.Join(", ", r.Select(kv => kv.Key + ": " + kv.Value.Area))}");
|
||||
}, 1, true, true);
|
||||
packer.Add(this.Content.LoadTextureAtlas("Textures/Furniture"), r => {
|
||||
regions.AddRange(r.Values);
|
||||
Console.WriteLine($"Returned {r.Count} regions: {string.Join(", ", r.Select(kv => kv.Key + ": " + kv.Value.Area))}");
|
||||
}, 1, true);
|
||||
packer.Pack(this.GraphicsDevice);
|
||||
|
||||
using (var stream = File.Create("_Packed.png"))
|
||||
packer.PackedTexture.SaveAsPng(stream, packer.PackedTexture.Width, packer.PackedTexture.Height);
|
||||
|
||||
this.OnDraw += (g, t) => {
|
||||
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
var x = 0;
|
||||
var y = 10;
|
||||
foreach (var r in regions) {
|
||||
const int sc = 5;
|
||||
this.SpriteBatch.DrawRectangle(new Vector2(x, y), new Vector2(r.Width * sc, r.Height * sc), Color.Green);
|
||||
this.SpriteBatch.Draw(r, new Vector2(x, y), Color.White, 0, Vector2.Zero, sc, SpriteEffects.None, 0);
|
||||
x += r.Width * sc + 1;
|
||||
if (x >= 1000) {
|
||||
x = 0;
|
||||
y += 250;
|
||||
}
|
||||
}
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
}
|
||||
|
||||
protected override void DoUpdate(GameTime gameTime) {
|
||||
base.DoUpdate(gameTime);
|
||||
if (this.InputHandler.IsKeyPressed(Keys.F11))
|
||||
this.GraphicsDeviceManager.SetFullscreen(!this.GraphicsDeviceManager.IsFullScreen);
|
||||
|
||||
var delta = this.InputHandler.ScrollWheel - this.InputHandler.LastScrollWheel;
|
||||
if (delta != 0) {
|
||||
this.camera.Zoom(0.1F * Math.Sign(delta), this.InputHandler.ViewportMousePosition.ToVector2());
|
||||
}
|
||||
|
||||
/*if (Input.InputsDown.Length > 0)
|
||||
Console.WriteLine("Down: " + string.Join(", ", Input.InputsDown));*/
|
||||
if (MlemGame.Input.InputsPressed.Length > 0)
|
||||
Console.WriteLine("Pressed: " + string.Join(", ", MlemGame.Input.InputsPressed));
|
||||
MlemGame.Input.HandleKeyboardRepeats = false;
|
||||
Console.WriteLine("Down time: " + MlemGame.Input.GetDownTime(Keys.A));
|
||||
Console.WriteLine("Time since press: " + MlemGame.Input.GetTimeSincePress(Keys.A));
|
||||
Console.WriteLine("Up time: " + MlemGame.Input.GetUpTime(Keys.A));
|
||||
}
|
||||
|
||||
protected override void DoDraw(GameTime gameTime) {
|
||||
this.GraphicsDevice.Clear(Color.Black);
|
||||
this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, this.camera.ViewMatrix);
|
||||
/*this.mapRenderer.Draw(this.SpriteBatch, this.camera.GetVisibleRectangle().ToExtended());
|
||||
|
||||
foreach (var tile in this.collisions.GetCollidingTiles(new RectangleF(0, 0, this.map.Width, this.map.Height))) {
|
||||
foreach (var area in tile.Collisions) {
|
||||
this.SpriteBatch.DrawRectangle(area.Position * this.map.GetTileSize(), area.Size * this.map.GetTileSize(), Color.Red);
|
||||
}
|
||||
}*/
|
||||
var system = new FontSystem();
|
||||
system.AddFont(File.ReadAllBytes("Content/Fonts/Cadman_Roman.otf"));
|
||||
//var font = new GenericSpriteFont(LoadContent<SpriteFont>("Fonts/TestFont"));
|
||||
//var font = new GenericBitmapFont(LoadContent<BitmapFont>("Fonts/Regular"));
|
||||
var font = new GenericStashFont(system.GetFont(32));
|
||||
var spriteFont = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/TestFont"));
|
||||
this.UiSystem.Style = new UntexturedStyle(this.SpriteBatch) {
|
||||
Font = font,
|
||||
TextScale = 0.5F,
|
||||
PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
|
||||
ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4)
|
||||
};
|
||||
this.UiSystem.AutoScaleReferenceSize = new Point(1280, 720);
|
||||
this.UiSystem.AutoScaleWithScreen = true;
|
||||
this.UiSystem.GlobalScale = 5;
|
||||
|
||||
/*this.OnDraw += (g, time) => {
|
||||
const string strg = "This is a test string\nto test things\n\nMany things are being tested, like the ability\nfor this font to agree\n\nwith newlines";
|
||||
this.SpriteBatch.Begin();
|
||||
spriteFont.DrawString(this.SpriteBatch, strg, new Vector2(600, 100), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
|
||||
font.DrawString(this.SpriteBatch, strg, new Vector2(600, 100), Color.White, 0, Vector2.Zero, 2, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.End();
|
||||
base.DoDraw(gameTime);
|
||||
};*/
|
||||
|
||||
var panel = new Panel(Anchor.Center, new Vector2(0, 100), Vector2.Zero) {SetWidthBasedOnChildren = true};
|
||||
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(100, 10)));
|
||||
panel.AddChild(new Button(Anchor.AutoCenter, new Vector2(80, 10)));
|
||||
//this.UiSystem.Add("Panel", panel);
|
||||
|
||||
panel.SetData("TestKey", new Vector2(10, 2));
|
||||
//Console.WriteLine(panel.GetData<Vector2>("TestKey"));
|
||||
|
||||
var obj = new Test(Vector2.One, "test") {
|
||||
Vec = new Vector2(10, 20),
|
||||
Point = new Point(20, 30),
|
||||
Dir = Direction2.Left,
|
||||
OtherTest = new Test(Vector2.One, "other") {
|
||||
Vec = new Vector2(70, 30),
|
||||
Dir = Direction2.Right
|
||||
}
|
||||
};
|
||||
Console.WriteLine(obj);
|
||||
|
||||
for (var i = 0; i < 360; i += 45) {
|
||||
var rad = MathHelper.ToRadians(i);
|
||||
var vec = new Vector2((float) Math.Sin(rad), (float) Math.Cos(rad));
|
||||
var dir = vec.ToDirection();
|
||||
Console.WriteLine(vec + " -> " + dir);
|
||||
}
|
||||
|
||||
private class Test {
|
||||
var writer = new StringWriter();
|
||||
this.Content.GetJsonSerializer().Serialize(writer, obj);
|
||||
//Console.WriteLine(writer.ToString());
|
||||
// {"Vec":"10 20","Point":"20 30","Rectangle":"1 2 3 4","RectangleF":"4 5 6 7"}
|
||||
|
||||
public Vector2 Vec;
|
||||
public Point Point;
|
||||
public Direction2 Dir { get; set; }
|
||||
public Test OtherTest;
|
||||
// Also:
|
||||
//this.Content.AddJsonConverter(new CustomConverter());
|
||||
|
||||
public Test(Vector2 test, string test2) {
|
||||
Console.WriteLine("Constructed with " + test + ", " + test2);
|
||||
var res = this.Content.LoadJson<Test>("Test");
|
||||
Console.WriteLine("The res is " + res);
|
||||
|
||||
var gradient = this.SpriteBatch.GenerateGradientTexture(Color.Green, Color.Red, Color.Blue, Color.Yellow);
|
||||
/*this.OnDraw += (game, time) => {
|
||||
this.SpriteBatch.Begin();
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Rectangle(640 - 4, 360 - 4, 8, 8), Color.Green);
|
||||
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Rectangle(200, 400, 200, 400), Color.Green);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1), new Vector2(200, 400), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, ellipsis: "..."), new Vector2(200, 450), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, true), new Vector2(200, 500), Color.White);
|
||||
font.DrawString(this.SpriteBatch, font.TruncateString("This is a very long string", 200, 1, true, "..."), new Vector2(200, 550), Color.White);
|
||||
|
||||
this.SpriteBatch.Draw(gradient, new Rectangle(300, 100, 200, 200), Color.White);
|
||||
this.SpriteBatch.End();
|
||||
};*/
|
||||
|
||||
var sc = 4;
|
||||
var formatter = new TextFormatter();
|
||||
formatter.AddImage("Test", new TextureRegion(tex, 0, 8, 24, 24));
|
||||
formatter.Macros.Add(new Regex("<testmacro>"), (f, m, r) => "<test1>");
|
||||
formatter.Macros.Add(new Regex("<test1>"), (f, m, r) => "<test2> blue");
|
||||
formatter.Macros.Add(new Regex("<test2>"), (f, m, r) => "<c Blue>");
|
||||
var strg = "This text uses a bunch of non-breaking~spaces to see if macros work. Additionally, it uses a macro that resolves into a bunch of other macros and then, at the end, into <testmacro> text</c>.";
|
||||
//var strg = "Lorem Ipsum <i Test> is simply dummy text of the <i Test> printing and typesetting <i Test> industry. Lorem Ipsum has been the industry's standard dummy text <i Test> ever since the <i Test> 1500s, when <i Test><i Test><i Test><i Test><i Test><i Test><i Test> an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
|
||||
//var strg = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
|
||||
//var strg = "This is <u>a test of the underlined formatting code</u>!";
|
||||
this.tokenized = formatter.Tokenize(font, strg);
|
||||
this.tokenized.Split(font, 400, sc);
|
||||
|
||||
var square = this.SpriteBatch.GenerateSquareTexture(Color.Yellow);
|
||||
var round = this.SpriteBatch.GenerateCircleTexture(Color.Green, 128);
|
||||
|
||||
var region = new TextureRegion(round) {Pivot = new Vector2(0.5F)};
|
||||
var region2 = new TextureRegion(round);
|
||||
|
||||
var atlas = this.Content.LoadTextureAtlas("Textures/Furniture");
|
||||
foreach (var r in atlas.Regions)
|
||||
Console.WriteLine(r.Name + ": " + r.U + " " + r.V + " " + r.Width + " " + r.Height + " " + r.PivotPixels);
|
||||
|
||||
this.OnDraw += (g, time) => {
|
||||
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
//this.SpriteBatch.Draw(square, new Rectangle(10, 10, 400, 400), Color.White);
|
||||
//this.SpriteBatch.Draw(round, new Rectangle(10, 10, 400, 400), Color.White);
|
||||
this.SpriteBatch.Draw(region, new Vector2(50, 50), Color.White, 0, Vector2.Zero, 0.5F, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.Draw(region2, new Vector2(50, 50), Color.Yellow * 0.5F, 0, Vector2.Zero, 0.5F, SpriteEffects.None, 0);
|
||||
this.SpriteBatch.Draw(this.SpriteBatch.GetBlankTexture(), new Vector2(50, 50), Color.Pink);
|
||||
|
||||
//this.SpriteBatch.FillRectangle(new RectangleF(400, 20, 400, 1000), Color.Green);
|
||||
//font.DrawString(this.SpriteBatch, this.tokenized.DisplayString, new Vector2(400, 20), Color.White * 0.25F, 0, Vector2.Zero, sc, SpriteEffects.None, 0);
|
||||
//this.tokenized.Draw(time, this.SpriteBatch, new Vector2(400, 20), font, Color.White, sc, 0);
|
||||
//this.SpriteBatch.DrawGrid(new Vector2(30, 30), new Vector2(40, 60), new Point(10, 5), Color.Yellow, 3);
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
this.OnUpdate += (g, time) => {
|
||||
if (this.InputHandler.IsPressed(Keys.W)) {
|
||||
this.tokenized = formatter.Tokenize(font, strg);
|
||||
this.tokenized.Split(font, this.InputHandler.IsModifierKeyDown(ModifierKey.Shift) ? 400 : 500, sc);
|
||||
}
|
||||
this.tokenized.Update(time);
|
||||
};
|
||||
|
||||
/*var testPanel = new Panel(Anchor.Center, new Vector2(0.5F, 100), Vector2.Zero);
|
||||
testPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.25F, -1)));
|
||||
testPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(2500, 1)) {PreventParentSpill = true});
|
||||
this.UiSystem.Add("Test", testPanel);
|
||||
|
||||
var invalidPanel = new Panel(Anchor.Center, Vector2.Zero, Vector2.Zero) {
|
||||
SetWidthBasedOnChildren = true,
|
||||
SetHeightBasedOnChildren = true
|
||||
};
|
||||
invalidPanel.AddChild(new Paragraph(Anchor.AutoRight, 1, "This is some test text!", true));
|
||||
invalidPanel.AddChild(new VerticalSpace(1));
|
||||
this.UiSystem.Add("Invalid", invalidPanel);*/
|
||||
|
||||
/*var loadGroup = new Group(Anchor.TopLeft, Vector2.One, false);
|
||||
var loadPanel = loadGroup.AddChild(new Panel(Anchor.Center, new Vector2(150, 150), Vector2.Zero, false, true, false) {
|
||||
ChildPadding = new Padding(5, 10, 5, 5)
|
||||
});
|
||||
for (var i = 0; i < 1; i++) {
|
||||
var button = loadPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
|
||||
SetHeightBasedOnChildren = true,
|
||||
Padding = new Padding(0, 0, 0, 1),
|
||||
ChildPadding = new Padding(3)
|
||||
});
|
||||
button.AddChild(new Group(Anchor.AutoLeft, new Vector2(0.5F, 30), false) {
|
||||
CanBeMoused = false
|
||||
});
|
||||
}
|
||||
var par = loadPanel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is another\ntest string\n\nwith many lines\nand many more!"));
|
||||
par.OnUpdated = (e, time) => {
|
||||
GenericFont newFont = Input.IsModifierKeyDown(ModifierKey.Shift) ? spriteFont : font;
|
||||
if (newFont != par.RegularFont.Value) {
|
||||
par.TextScaleMultiplier = newFont == font ? 1 : 0.5F;
|
||||
par.RegularFont = newFont;
|
||||
par.ForceUpdateArea();
|
||||
}
|
||||
};
|
||||
par.OnDrawn = (e, time, batch, a) => batch.DrawRectangle(e.DisplayArea.ToExtended(), Color.Red);
|
||||
this.UiSystem.Add("Load", loadGroup);*/
|
||||
|
||||
/*var spillPanel = new Panel(Anchor.Center, new Vector2(100), Vector2.Zero);
|
||||
var squishingGroup = spillPanel.AddChild(new SquishingGroup(Anchor.TopLeft, Vector2.One));
|
||||
squishingGroup.AddChild(new Button(Anchor.TopLeft, new Vector2(30), "TL") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D1),
|
||||
Priority = 10
|
||||
}).SetData("Ref", "TL");
|
||||
squishingGroup.AddChild(new Button(Anchor.TopRight, new Vector2(30), "TR") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D2),
|
||||
Priority = 20
|
||||
}).SetData("Ref", "TR");
|
||||
squishingGroup.AddChild(new Button(Anchor.BottomLeft, new Vector2(30), "BL") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D3),
|
||||
Priority = 30
|
||||
}).SetData("Ref", "BL");
|
||||
squishingGroup.AddChild(new Button(Anchor.BottomRight, new Vector2(30), "BR") {
|
||||
OnUpdated = (e, time) => e.IsHidden = Input.IsKeyDown(Keys.D4),
|
||||
Priority = 40
|
||||
}).SetData("Ref", "BR");
|
||||
squishingGroup.AddChild(new Button(Anchor.Center, Vector2.Zero, "0") {
|
||||
PositionOffset = new Vector2(-10, -5),
|
||||
Size = new Vector2(60, 55),
|
||||
OnPressed = e => {
|
||||
e.Priority = 100 - e.Priority;
|
||||
((Button) e).Text.Text = e.Priority.ToString();
|
||||
e.SetAreaDirty();
|
||||
}
|
||||
}).SetData("Ref", "Main");
|
||||
this.UiSystem.Add("SpillTest", spillPanel);*/
|
||||
|
||||
var regularFont = spriteFont.Font;
|
||||
var genericFont = spriteFont;
|
||||
|
||||
var index = 0;
|
||||
var pos = new Vector2(100, 20);
|
||||
var scale = 1F;
|
||||
var origin = Vector2.Zero;
|
||||
var rotation = 0F;
|
||||
var effects = SpriteEffects.None;
|
||||
|
||||
this.OnDraw += (g, time) => {
|
||||
const string testString = "This is a\ntest string\n\twith long lines.\nLet's write some more stuff. Let's\r\nsplit lines weirdly.";
|
||||
if (MlemGame.Input.IsKeyPressed(Keys.I)) {
|
||||
index++;
|
||||
if (index == 1) {
|
||||
scale = 2;
|
||||
} else if (index == 2) {
|
||||
origin = new Vector2(15, 15);
|
||||
} else if (index == 3) {
|
||||
rotation = 0.25F;
|
||||
} else if (index == 4) {
|
||||
effects = SpriteEffects.FlipHorizontally;
|
||||
} else if (index == 5) {
|
||||
effects = SpriteEffects.FlipVertically;
|
||||
} else if (index == 6) {
|
||||
effects = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"{this.GetHashCode()}: {nameof(this.Vec)}: {this.Vec}, {nameof(this.Point)}: {this.Point}, {nameof(this.OtherTest)}: {this.OtherTest}, {nameof(this.Dir)}: {this.Dir}";
|
||||
this.SpriteBatch.Begin();
|
||||
if (MlemGame.Input.IsKeyDown(Keys.LeftShift)) {
|
||||
this.SpriteBatch.DrawString(regularFont, testString, pos, Color.Red, rotation, origin, scale, effects, 0);
|
||||
} else {
|
||||
genericFont.DrawString(this.SpriteBatch, testString, pos, Color.Green, rotation, origin, scale, effects, 0);
|
||||
}
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
|
||||
var viewport = new BoxingViewportAdapter(this.Window, this.GraphicsDevice, 1280, 720);
|
||||
var newPanel = new Panel(Anchor.TopLeft, new Vector2(200, 100), new Vector2(10, 10));
|
||||
newPanel.AddChild(new Button(Anchor.TopLeft, new Vector2(100, 20), "Text", "Tooltip text"));
|
||||
this.UiSystem.Add("Panel", newPanel);
|
||||
|
||||
var keybindPanel = new Panel(Anchor.BottomRight, new Vector2(130, 150), new Vector2(5));
|
||||
for (var i = 0; i < 15; i++) {
|
||||
var button = keybindPanel.AddChild(new Button(default, default, i.ToString()));
|
||||
button.Anchor = Anchor.AutoInline;
|
||||
button.Padding = new Padding(0.5F);
|
||||
button.SetHeightBasedOnChildren = false;
|
||||
button.Size = new Vector2(30, 50);
|
||||
}
|
||||
this.UiSystem.Add("Keybinds", keybindPanel);
|
||||
|
||||
var packer = new RuntimeTexturePacker();
|
||||
var regions = new List<TextureRegion>();
|
||||
packer.Add(new UniformTextureAtlas(tex, 16, 16), r => {
|
||||
regions.AddRange(r.Values);
|
||||
Console.WriteLine($"Returned {r.Count} regions: {string.Join(", ", r.Select(kv => kv.Key + ": " + kv.Value.Area))}");
|
||||
}, 1, true, true);
|
||||
packer.Add(this.Content.LoadTextureAtlas("Textures/Furniture"), r => {
|
||||
regions.AddRange(r.Values);
|
||||
Console.WriteLine($"Returned {r.Count} regions: {string.Join(", ", r.Select(kv => kv.Key + ": " + kv.Value.Area))}");
|
||||
}, 1, true);
|
||||
packer.Pack(this.GraphicsDevice);
|
||||
|
||||
using (var stream = File.Create("_Packed.png"))
|
||||
packer.PackedTexture.SaveAsPng(stream, packer.PackedTexture.Width, packer.PackedTexture.Height);
|
||||
|
||||
this.OnDraw += (g, t) => {
|
||||
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
var x = 0;
|
||||
var y = 10;
|
||||
foreach (var r in regions) {
|
||||
const int sc = 5;
|
||||
this.SpriteBatch.DrawRectangle(new Vector2(x, y), new Vector2(r.Width * sc, r.Height * sc), Color.Green);
|
||||
this.SpriteBatch.Draw(r, new Vector2(x, y), Color.White, 0, Vector2.Zero, sc, SpriteEffects.None, 0);
|
||||
x += r.Width * sc + 1;
|
||||
if (x >= 1000) {
|
||||
x = 0;
|
||||
y += 250;
|
||||
}
|
||||
}
|
||||
this.SpriteBatch.End();
|
||||
};
|
||||
}
|
||||
|
||||
protected override void DoUpdate(GameTime gameTime) {
|
||||
base.DoUpdate(gameTime);
|
||||
if (this.InputHandler.IsKeyPressed(Keys.F11))
|
||||
this.GraphicsDeviceManager.SetFullscreen(!this.GraphicsDeviceManager.IsFullScreen);
|
||||
|
||||
var delta = this.InputHandler.ScrollWheel - this.InputHandler.LastScrollWheel;
|
||||
if (delta != 0) {
|
||||
this.camera.Zoom(0.1F * Math.Sign(delta), this.InputHandler.ViewportMousePosition.ToVector2());
|
||||
}
|
||||
|
||||
/*if (Input.InputsDown.Length > 0)
|
||||
Console.WriteLine("Down: " + string.Join(", ", Input.InputsDown));*/
|
||||
if (MlemGame.Input.InputsPressed.Length > 0)
|
||||
Console.WriteLine("Pressed: " + string.Join(", ", MlemGame.Input.InputsPressed));
|
||||
MlemGame.Input.HandleKeyboardRepeats = false;
|
||||
Console.WriteLine("Down time: " + MlemGame.Input.GetDownTime(Keys.A));
|
||||
Console.WriteLine("Time since press: " + MlemGame.Input.GetTimeSincePress(Keys.A));
|
||||
Console.WriteLine("Up time: " + MlemGame.Input.GetUpTime(Keys.A));
|
||||
}
|
||||
|
||||
protected override void DoDraw(GameTime gameTime) {
|
||||
this.GraphicsDevice.Clear(Color.Black);
|
||||
this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, this.camera.ViewMatrix);
|
||||
/*this.mapRenderer.Draw(this.SpriteBatch, this.camera.GetVisibleRectangle().ToExtended());
|
||||
|
||||
foreach (var tile in this.collisions.GetCollidingTiles(new RectangleF(0, 0, this.map.Width, this.map.Height))) {
|
||||
foreach (var area in tile.Collisions) {
|
||||
this.SpriteBatch.DrawRectangle(area.Position * this.map.GetTileSize(), area.Size * this.map.GetTileSize(), Color.Red);
|
||||
}
|
||||
}*/
|
||||
|
||||
this.SpriteBatch.End();
|
||||
base.DoDraw(gameTime);
|
||||
}
|
||||
|
||||
private class Test {
|
||||
|
||||
public Vector2 Vec;
|
||||
public Point Point;
|
||||
public Direction2 Dir { get; set; }
|
||||
public Test OtherTest;
|
||||
|
||||
public Test(Vector2 test, string test2) {
|
||||
Console.WriteLine("Constructed with " + test + ", " + test2);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"{this.GetHashCode()}: {nameof(this.Vec)}: {this.Vec}, {nameof(this.Point)}: {this.Point}, {nameof(this.OtherTest)}: {this.OtherTest}, {nameof(this.Dir)}: {this.Dir}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using MLEM.Misc;
|
||||
|
||||
namespace Sandbox {
|
||||
internal static class Program {
|
||||
namespace Sandbox;
|
||||
|
||||
private static void Main() {
|
||||
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
||||
using var game = new GameImpl();
|
||||
game.Run();
|
||||
}
|
||||
internal static class Program {
|
||||
|
||||
private static void Main() {
|
||||
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
||||
using var game = new GameImpl();
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -14,17 +14,16 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.263" />
|
||||
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
|
||||
<PackageReference Include="MonoGame.Extended.Tiled" Version="3.8.0" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
||||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.1.5" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263" />
|
||||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.1.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
<Content Include="Content\*\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue