Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Templates/dotnetTemplates/Install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet new install .\
66 changes: 66 additions & 0 deletions Templates/dotnetTemplates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# KNI .NET Templates (`nkast.Kni.Templates`)

This package provides KNI project templates for `dotnet new`.

## Install

```bash
dotnet new install nkast.Kni.Templates
```

## Uninstall

```bash
dotnet new uninstall nkast.Kni.Templates
```

## List installed templates

```bash
dotnet new list kni
```

## Usage

After installation, create a project from one of the installed KNI templates:

```bash
dotnet new <template-short-name> -n ProjectName
```

## Available templates

### Project templates

| Short name | Template | Platform | Graphics backend | Audio backend |
|---|---|---|---|---|
| `kni-android-gl` | KNI Android Game Project | Android | GL ES | OpenAL |
| `kni-blazor-gl` | KNI Web Game Project (.net8) | Blazor WebAssembly | WebGL | WebAudio |
| `kni-ios-gl` | KNI iOS Game Project | iOS | GL ES | OpenAL |
| `kni-oculus-gl` | KNI Oculus Game Project | Oculus | OpenGL | OpenAL |
| `kni-sdl2-gl` | KNI Cross Platform Desktop Game Project (.net8) | SDL2 (Windows/Linux/macOS) | OpenGL | OpenAL |
| `kni-sdl2-gl-netframework` | KNI Cross Platform Desktop Game Project (.NET Framework) | SDL2 (Windows/Linux/macOS) | OpenGL | OpenAL |
| `kni-winforms-dx11` | KNI Windows Game Project (.net8) | WinForms | DirectX11 | XAudio |
| `kni-winforms-dx11-netframework` | KNI Windows Game Project (.NET Framework) | WinForms | DirectX11 | XAudio |
| `kni-uap-core-dx11-netframework` | KNI Windows 10 Universal (Core) Game Project (.uap10) | UWP Core | DirectX11 | XAudio |
| `kni-uap-xaml-dx11-netframework` | KNI Windows 10 Universal (XAML) Game Project (.uap10) | UWP XAML | DirectX11 | XAudio |
| `kni-multiplatform` | KNI Multiplatform Game Project (.net8) | Android/Blazor/SDL2/WinForms | GLES/WebGL/OpenGL/DirectX11 | OpenAL/WebAudio/XAudio |
| `kni-multiplatform-netframework` | KNI Multiplatform Game Project (.NET Framework) | SDL2/WinForms/UWP | DirectX11/OpenGL | XAudio/OpenAL |
| `kni-ContentPipelineExtension` | KNI Content Pipeline Extension Project (.NetStandard) | - | - | - |

### Item templates

| Short name | Template |
|---|---|
| `KniDrawableGameComponent` | KNI DrawableGameComponent Item |
| `KniGameComponent` | KNI GameComponent Item |

## What is included

This package includes templates for KNI game projects and related project setups available under the `Templates/dotnetTemplates/content` folder.

## Links

- Repository: https://github.com/kniEngine/kni
- Issues: https://github.com/kniEngine/kni/issues
- Discussions: https://github.com/kniEngine/kni/discussions
1 change: 1 addition & 0 deletions Templates/dotnetTemplates/Uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet new uninstall .\
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<TargetFramework>net8.0-android</TargetFramework>
<ProjectGuid>$guid1$</ProjectGuid>
<OutputType>Exe</OutputType>
<IsTrimmable>True</IsTrimmable>
<TrimMode>partial</TrimMode>
<RootNamespace>$safeprojectname$</RootNamespace>
<AssemblyName>$safeprojectname$</AssemblyName>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DefineConstants>$(DefineConstants);ANDROID</DefineConstants>
<KniPlatform>Android</KniPlatform>
<ApplicationId>com.companyname.$safeprojectname$</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidStoreUncompressedFileExtensions>.m4a</AndroidStoreUncompressedFileExtensions>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nkast.Xna.Framework" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Content" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Audio" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Media" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Input" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Game" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Devices" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Storage" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.XR" Version="4.2.9001" />
<PackageReference Include="nkast.Kni.Platform.Android.GL" Version="4.2.9001" />
<PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="4.2.9001" />
</ItemGroup>
<ItemGroup>
<Compile Include="$projectname$Activity.cs" />
<Compile Include="$projectname$Game.cs" />
</ItemGroup>
<ItemGroup>
<None Include="AndroidManifest.xml" />
<None Include="Assets\AboutAssets.txt" />
<None Include="Resources\AboutResources.txt" />
<AndroidResource Include="Resources\Drawable\Icon.png" />
<AndroidResource Include="Resources\Drawable\Splash.png" />
<AndroidResource Include="Resources\Values\Strings.xml" />
<AndroidResource Include="Resources\Values\Styles.xml" />
<Folder Include="Resources\Layout\" />
</ItemGroup>

<ItemGroup>
<KniContentReference Include="Content\$projectname$Content.mgcb" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36811.4 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "$projectname$", "$projectname$.csproj", "{$guid1$}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{$guid1$}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{$guid1$}.Debug|Any CPU.Build.0 = Debug|Any CPU
{$guid1$}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{$guid1$}.Release|Any CPU.ActiveCfg = Release|Any CPU
{$guid1$}.Release|Any CPU.Build.0 = Release|Any CPU
{$guid1$}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {$slnguid$}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Views;

namespace $safeprojectname$
{
[Activity(Label = "$projectname$"
, MainLauncher = true
, Icon = "@drawable/icon"
, Theme = "@style/Theme.Splash"
, AlwaysRetainTaskState = true
, LaunchMode = LaunchMode.SingleInstance
, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize | ConfigChanges.ScreenLayout | ConfigChanges.UiMode | ConfigChanges.SmallestScreenSize
, ScreenOrientation = ScreenOrientation.FullSensor
)]
public class $safeprojectname$Activity : Microsoft.Xna.Framework.AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var game = new $safeprojectname$Game();
SetContentView((View)game.Services.GetService(typeof(View)));
game.Run();
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;

namespace $safeprojectname$
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class $safeprojectname$Game : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;

public $safeprojectname$Game()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";

graphics.IsFullScreen = true;
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
}

/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here

base.Initialize();

}

/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);

// TODO: Use this.Content to load your game content here
}

/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}

/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
MouseState mouseState = Mouse.GetState();
KeyboardState keyboardState = Keyboard.GetState();
GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

if (keyboardState.IsKeyDown(Keys.Escape) ||
keyboardState.IsKeyDown(Keys.Back) ||
gamePadState.Buttons.Back == ButtonState.Pressed)
{
try { Exit(); }
catch (PlatformNotSupportedException) { /* ignore */ }
}

// TODO: Add your update logic here

base.Update(gameTime);
}

/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);

// TODO: Add your drawing code here

base.Draw(gameTime);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": " https://json.schemastore.org/ide.host",
"icon": "TemplateIcon.png",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "KNI Engine",
"classifications": [ "KNI", "Games", "Android", "mobile" ],
"identity": "nkast.Kni.Android.GL.Project.CSharp",
"name": "KNI Android Game Project",
"shortName": "kni-android-gl",
"description": "A KNI game project for Android.",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "$projectname$",
"primaryOutputs": [
{
"path": "$projectname$.csproj"
}
],
"symbols": {
"slnguid": { "type": "generated", "generator": "guid", "replaces": "$slnguid$" },
"guid1": { "type": "generated", "generator": "guid", "replaces": "$guid1$" },
"filesafeprojectname": {
"type": "derived",
"valueSource": "name",
"replaces": "$safeprojectname$",
"valueTransform": "safe_name"
}
},
"preferNameDirectory": true,
"icon": "TemplateIcon.png"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="$safeprojectname$.$safeprojectname$" android:versionCode="1" android:versionName="1.0">
<application android:label="$projectname$"></application>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#----------------------------- Global Properties ----------------------------#

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:Android
/config:
/profile:Reach
/compress:False

#-------------------------------- References --------------------------------#


#---------------------------------- Content ---------------------------------#

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>

</Project>

Loading
Loading