Nearly finalized, added back all the osx compatibility.

Hopefully this now works with both OSX and Windows... I tried to create platform specific properties everywhere I could. All Windows build tasks for VSCode seem to be working correctly now.
This commit is contained in:
foxnne 2019-09-02 17:49:21 -05:00
parent 7975cccbe9
commit 3e5a7e6a78
13 changed files with 345 additions and 134 deletions

View File

@ -10,7 +10,7 @@ Set-Location ../project_name
$fxc = "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\fxc.exe"
$files = Get-ChildItem -Path "Content\*" -Include *fx
$files = Get-ChildItem -Path "Content\*" -Recurse -Include *fx
foreach ($file in $files)
{

42
.vscode/launch.json vendored
View File

@ -1,16 +1,44 @@
{
// Change "mono" to "clr" for 64-bit .NET Framework debugging on Windows.
// Delete unnecessary configurations if unneeded. "type" isnt supported for platform specifc properties.
// (See: https://github.com/OmniSharp/omnisharp-vscode/wiki/Desktop-.NET-Framework)
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"name": "Launch (Mac)",
"type": "mono",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}/project_name",
"preLaunchTask": "Build (Debug)",
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
},
},
},
{
"name": "Launch Without Building (Mac)",
"type": "mono",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}",
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
},
}
},
{
"name": "Launch (Windows)",
"type": "clr",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}/project_name",
"preLaunchTask": "Build (Debug)",
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
@ -19,14 +47,14 @@
},
{
"name": "Launch Without Building",
"type": "mono",
"name": "Launch Without Building (Windows)",
"type": "clr",
"request": "launch",
"program": "${workspaceFolder}/Fook/bin/Debug/Fook.exe",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}",
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/Fook/bin/Debug/osx/"
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
},
}
},
@ -39,4 +67,4 @@
"port": 55555
}
]
}
}

View File

@ -11,6 +11,7 @@
"**/.[^v]*": true, // hide any files that start with a '.' but keep the .vscode folder
".vs": true, // Visual Studio settings
"getFNA.sh": true,
"getFNA.ps1": true,
"imgui.ini": true,
"MonoGameContent.targets": true,
"**/obj": true,

43
.vscode/tasks.json vendored
View File

@ -52,7 +52,6 @@
"dependsOn": "Build Content",
},
//Confused how release works with this template by default, no release config seems to be setup in the sln
{
"label": "Build (Release)",
"type": "shell",
@ -75,9 +74,10 @@
"command": "DYLD_LIBRARY_PATH=${workspaceFolder}/project_name/bin/Debug/osx/ mono ${workspaceFolder}/project_name/bin/Debug/project_name.exe"
},
"windows":{
"command": "cmd",
"command": "start",
"args": [
"/k",
"/wait",
"${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"${workspaceFolder}/project_name/bin/Debug/project_name.exe"
]
},
@ -93,9 +93,10 @@
"command": "DYLD_LIBRARY_PATH=${workspaceFolder}/project_name/bin/Release/osx/ mono ${workspaceFolder}/project_name/bin/Release/project_name.exe"
},
"windows":{
"command": "cmd",
"command": "start",
"args": [
"/k",
"/wait",
"${workspaceFolder}/project_name/bin/Release/project_name.exe",
"${workspaceFolder}/project_name/bin/Release/project_name.exe"
]
},
@ -108,7 +109,7 @@
"type": "shell",
"group": "build",
"osx":{
"command": "${workspaceFolder}/.vscode/buildEffects.ps1"
"command": "${workspaceFolder}/.vscode/buildEffects.sh"
},
"windows":{
"command": "& ${workspaceFolder}/.vscode/buildEffects.ps1"
@ -127,30 +128,48 @@
"problemMatcher": "$msCompile"
},
//I dont fully understand this function or how to replicate on windows.
/* {
{
"label": "Force Build Content",
"type": "shell",
"group": "build",
"command": "mono /Applications/Pipeline.app/Contents/MonoBundle/MGCB.exe /@:Content.mgcb -r",
"osx": {
"command": "mono /Applications/Pipeline.app/Contents/MonoBundle/MGCB.exe /@:Content.mgcb -r",
},
"windows": {
"command":"C:/Program Files (x86)/MSBuild/MonoGame/v3.0/Tools/MGCB.exe",
"args": [
"/@:Content.mgcb",
"-r"
]
},
"options": {
"cwd": "${workspaceFolder}/project_name/CompiledContent"
},
"problemMatcher": "$msCompile"
}, */
},
{
"label": "Open Pipeline Tool",
"type": "shell",
"group": "build",
"command": "${workspaceFolder}/lucid/CompiledContent/Content.mgcb",
"osx": {
"command": "export MONOGAME_PIPELINE_PROJECT=${workspaceFolder}/project_name/CompiledContent/Content.mgcb && /Applications/Pipeline.app/Contents/MacOS/Pipeline"
},
"windows": {
"command": "${workspaceFolder}/project_name/CompiledContent/Content.mgcb"
},
"problemMatcher": "$msCompile"
},
{
"label": "Process T4 Templates",
"type": "shell",
"command": "${workspaceFolder}/.vscode/processT4Templates.ps1",
"osx": {
"command": "${workspaceFolder}/.vscode/processT4Templates.sh"
},
"windows": {
"command": "& ${workspaceFolder}/.vscode/processT4Templates.ps1"
},
"group": "build",
"problemMatcher": "$msCompile",
},

View File

@ -6,16 +6,20 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Common.props') ">C:\Program Files (x86)\MSBuild</MonoGameInstallDirectory>
Condition=" '$(OS)' == 'Windows_NT' And '$(MonoGameInstallDirectory)' == '' And Exists('C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Common.props') ">C:\Program Files (x86)\MSBuild</MonoGameInstallDirectory>
<MonoGameInstallDirectory
Condition=" '$(OS)' != 'Windows_NT' And '$(MonoGameInstallDirectory)' == '' And Exists('/Library/Frameworks/Mono.framework/External/xbuild/MonoGame/v3.0/MonoGame.Common.props') ">/Library/Frameworks/Mono.framework/External/xbuild</MonoGameInstallDirectory>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' ">$(MSBuildProgramFiles32)</MonoGameInstallDirectory>
<ContentOutputDir>bin/DesktopGL</ContentOutputDir>
<ContentIntermediateDir>obj/DesktopGL</ContentIntermediateDir>
</PropertyGroup>
<UsingTask TaskName="MonoGame.Build.Tasks.CollectContentReferences"
<UsingTask Condition=" '$(OS)' == 'Windows_NT' " TaskName="MonoGame.Build.Tasks.CollectContentReferences"
AssemblyFile="C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Build.Tasks.dll" />
<UsingTask Condition=" '$(OS)' != 'Windows_NT' " TaskName="MonoGame.Build.Tasks.CollectContentReferences"
AssemblyFile="\Library\Frameworks\MonoGame.framework\v3.0\MonoGame.Build.Tasks.dll" />
<!-- Add MonoGameContentReference to item type selection in Visual Studio -->
<ItemGroup>
<AvailableItemName Include="MonoGameContentReference" />

View File

@ -1,93 +0,0 @@
<!--
The main project needs a reference to this project. We use our own instead of the default MonoGame version so we can control
where our content gets built since we don't use "Content" but instead use "CompiledContent"
<Import Project="../MonoGameContent.targets" />
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('/Library/Frameworks/Mono.framework/External/xbuild/MonoGame/v3.0/MonoGame.Common.props') ">/Library/Frameworks/Mono.framework/External/xbuild</MonoGameInstallDirectory>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' ">$(MSBuildProgramFiles32)</MonoGameInstallDirectory>
<ContentOutputDir>bin/DesktopGL</ContentOutputDir>
<ContentIntermediateDir>obj/DesktopGL</ContentIntermediateDir>
</PropertyGroup>
<UsingTask TaskName="MonoGame.Build.Tasks.CollectContentReferences"
AssemblyFile="\Library\Frameworks\MonoGame.framework\v3.0\MonoGame.Build.Tasks.dll" />
<!-- Add MonoGameContentReference to item type selection in Visual Studio -->
<ItemGroup>
<AvailableItemName Include="MonoGameContentReference" />
</ItemGroup>
<!-- This disables the IDE feature that skips executing msbuild in some build situations. -->
<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<Target Name="Prepare">
<PropertyGroup>
<MonoGameInstallDir>$(MonoGameInstallDirectory)\MonoGame\v3.0\</MonoGameInstallDir>
<!-- El Capitan Support -->
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/Mono.framework/Versions/Current/bin/mono') ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/local/bin/mono') ">/usr/local/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/bin/mono') ">/usr/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And '$(MonoExe)' == '' ">mono</MonoExe>
<MonoGameContentBuilderExe Condition="'$(MonoGameContentBuilderExe)' == ''">$(MonoGameInstallDir)Tools\MGCB.exe</MonoGameContentBuilderExe>
<MonoGameContentBuilderCmd>"$(MonoGameContentBuilderExe)"</MonoGameContentBuilderCmd>
<MonoGameContentBuilderCmd Condition=" '$(OS)' != 'Windows_NT' ">$(MonoExe) $(MonoGameContentBuilderCmd)</MonoGameContentBuilderCmd>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'MacOSX'">$(MonoMacResourcePrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'iOS'">$(IPhoneResourcePrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'Android'">$(MonoAndroidAssetsPrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' != '' And !HasTrailingSlash('$(PlatformResourcePrefix)')">$(PlatformResourcePrefix)\</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' == ''"></PlatformResourcePrefix>
<MonoGameMGCBAdditionalArguments Condition="'$(MonoGameMGCBAdditionalArguments)' ==''">/quiet</MonoGameMGCBAdditionalArguments>
<Header>/platform:$(MonoGamePlatform)</Header>
</PropertyGroup>
<!-- Get all Mono Game Content References and store them in a list -->
<!-- We do this here so we are compatible with xbuild -->
<CollectContentReferences ContentReferences="@(MonoGameContentReference)" MonoGamePlatform="$(MonoGamePlatform)">
<Output TaskParameter="Output" ItemName="ContentReferences" />
</CollectContentReferences>
<Error
Text="The MonoGame content builder executable could not be located at '$(MonoGameContentBuilderExe)'!"
Condition="!Exists('$(MonoGameContentBuilderExe)')"
/>
<Warning
Text="No Content References Found. Please make sure your .mgcb file has a build action of MonoGameContentReference"
Condition=" '%(ContentReferences.FullPath)' == '' "
/>
</Target>
<PropertyGroup>
<BuildDependsOn>
BuildContent;
$(BuildDependsOn);
</BuildDependsOn>
</PropertyGroup>
<Target Name="RunContentBuilder">
<Exec Condition=" '%(ContentReferences.FullPath)' != '' "
Command="$(MonoGameContentBuilderCmd) $(MonoGameMGCBAdditionalArguments) $(Header) /@:&quot;%(ContentReferences.FullPath)&quot; /outputDir:&quot;$(ContentOutputDir)&quot; /intermediateDir:&quot;$(ContentIntermediateDir)&quot;"
WorkingDirectory="%(ContentReferences.RootDir)%(ContentReferences.Directory)" />
<CreateItem Include="%(ContentReferences.RelativeFullPath)%(ContentReferences.ContentOutputDir)\**\*.*"
AdditionalMetadata="ContentOutputDir=%(ContentReferences.ContentDirectory)">
<Output TaskParameter="Include" ItemName="ExtraContent" />
</CreateItem>
</Target>
<Target Name="BuildContent" DependsOnTargets="Prepare;RunContentBuilder" AfterTargets="Build" Condition=" '@(MonoGameContentReference)' != '' "
Outputs="%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension)">
<CreateItem Include="%(ExtraContent.FullPath)" AdditionalMetadata="Link=$(PlatformResourcePrefix)%(ExtraContent.ContentOutputDir)%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension);CopyToOutputDirectory=PreserveNewest"
Condition="'%(ExtraContent.Filename)' != ''">
<Output TaskParameter="Include" ItemName="Content" Condition="'$(MonoGamePlatform)' != 'Android' And '$(MonoGamePlatform)' != 'iOS' And '$(MonoGamePlatform)' != 'MacOSX'" />
<Output TaskParameter="Include" ItemName="BundleResource" Condition="'$(MonoGamePlatform)' == 'MacOSX' Or '$(MonoGamePlatform)' == 'iOS'" />
<Output TaskParameter="Include" ItemName="AndroidAsset" Condition="'$(MonoGamePlatform)' == 'Android'" />
</CreateItem>
</Target>
</Project>

View File

@ -10,16 +10,18 @@ Start new FNA projects with Nez quickly and easily with handy setup scripts, a v
## Prerequisites ##
- [Visual Studio Code](https://code.visualstudio.com) or [Visual Studio](https://visualstudio.microsoft.com/) (recommended to use Visual Studio Code because it has some custom tasks but either will work fine)
- [Mono Debugger Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) (required for macOS debugging)
- [Visual Studio Code](https://code.visualstudio.com) or [Visual Studio](https://visualstudio.microsoft.com/) (recommended to use Visual Studio Code because it has some custom tasks but either will work fine.)
- [Mono Debugger Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) (required for macOS debugging)
- [MonoGame](http://www.monogame.net/downloads/) (required for compiling content with the Pipeline tool)
- (optional) [.NET Core](https://dotnet.microsoft.com/download) (required for compiling T4 templates)
- (optional) [Microsoft DirectX SDK (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=6812) (required for building effects, [you can use Wine to run this](https://github.com/AndrewRussellNet/FNA-Template#linuxmacos-installing-the-directx-sdk-on-wine))
- (windows only) [7zip](https://www.7-zip.org) (if intending to use fnalibs, the filetype is unsupported for windows and requires 7zip to be installed to decompress/unzip)
- (windows only) [Build tools for Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)(these build tools are required for all Visual Studio Code build tasks. if you intend to use the full Visual Studio, these are already included. be sure to include .NET Core Build Tools in the installation)
## Setup Instructions ##
1. Download and unzip the ZIP archive (don't clone the repo!)
2. Run `./getFNA.sh` (macOS) to download the latest Nez, FNA and fnalibs to the directory. You can run this script again if you want to update either FNA or the fnalibs at a later point.
2. Run `./getFNA.sh` (macOS) or `./getFNA.ps1` (windows) to download the latest Nez, FNA and fnalibs to the directory. You can run this script again if you want to update either FNA or the fnalibs at a later point.
3. Open the root folder that contains the .sln file in Visual Studio Code or the .sln file directly in Visual Studio. Note that only Visual Studio Code has an effect builder command.
That's it! Now you're ready to build and run the base project. If you get missing DLL errors (pointing at SDL) when running in Visual Studio copy the FNA libs into your `/usr/local/lib` folder. With Visual Studio Code, `DYLD_LIBRARY_PATH` is set automatically so it won't run into the DLL not found error. Nez is setup as a submodule so you can update it in the normal fashion.

View File

@ -57,13 +57,9 @@ function updateFNA ()
function check7zip ()
{
try
if ((Test-Path "C:\Program Files\7-Zip") -eq 0)
{
7z | Out-Null
}
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Output "ERROR: 7Zip is not installed. Please install 7Zip and set PATH Environment Variable and try again."
Write-Output "ERROR: 7zip is not installed, please install 7zip and try again."
exit
}
}
@ -79,10 +75,10 @@ function getLibs ()
check7zip
if ((Test-Path "${PSScriptRoot}\fnalibs") -eq 0)
{
7z x "fnalibs.tar.bz2"
& "C:\Program Files\7-Zip\7z.exe" x "fnalibs.tar.bz2"
if ($? -eq 1){ Remove-Item "fnalibs.tar.bz2"}
else { Write-Output "ERROR: Unable to decompress successfully." exit }
7z x "fnalibs.tar" -ofnalibs
& "C:\Program Files\7-Zip\7z.exe" x "fnalibs.tar" -ofnalibs
if ($? -eq 1)
{
Remove-Item "fnalibs.tar"
@ -93,6 +89,70 @@ function getLibs ()
}
function checkMsbuild ()
{
try { msbuild | Out-Null }
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Output "ERROR: 'msbuild' is not available. Attempting to look for build tools..."
if ((Test-Path "C:\Program Files (x86)\Microsoft Visual Studio") -eq 1)
{
$files = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio\*" -Recurse -Include "msbuild.exe" | Where-Object { (Split-Path (Split-Path $_.FullName -Parent) -Leaf) -like 'bin'}
if ($files.Length -gt 0)
{
if ($files.Length -gt 1)
{
Write-Output "Found multiple build tools... unsure which version to use."
for ($i = 0; $i -lt $files.Length; $i++)
{
$filename = $files[$i].FullName
$c = $i + 1
Write-Output "${c}: ${filename}"
}
$max = $files.Length
$choice = Read-Host -Prompt "Choose desired msbuild version? (1-${max})"
if ($choice -le 0 -or $choice -gt $files.Length+1)
{
"ERROR: invalid choice, exiting"
}
$msbuildpath = Split-Path $files[$choice-1].FullName
Write-Output "your choice was ${choice} which equals this path: ${msbuildpath}. attempting to add to PATH..."
[Environment]::SetEnvironmentVariable("Path", $env:Path + $msbuildpath, "Machine")
Write-Output "Close and run getFNA.ps1 again..."
exit
}
else
{
Write-Output "Found build tools, attempting to add to PATH..."
$msbuildpath = Split-Path $files[0].FullName
[Environment]::SetEnvironmentVariable("Path", $env:Path + $msbuildpath, "Machine")
Write-Output "Close and run getFNA.ps1 again..."
exit
}
}
else
{
Write-Output "ERROR: Build tools for Visual Studio not installed or installed in an unknown location."
Write-Output "If you know they are installed somewhere else, please create a PATH Environment Variable for them and retry."
exit
}
}
else
{
Write-Output "ERROR: Build tools for Visual Studio not installed or installed in an unknown location."
Write-Output "If you know they are installed somewhere else, please create a PATH Environment Variable for them and retry."
exit
}
}
}
checkMsbuild
if (Test-Path "${PSScriptRoot}\FNA")
{

171
getFNA.sh Normal file
View File

@ -0,0 +1,171 @@
#!/bin/bash
# Program: getFNA
# Author: Caleb Cornett
# Usage: ./getFNA.sh
# Description: Quick and easy way to install a local copy of FNA and its native libraries.
# Checks if dotnet is installed
function checkDotnet()
{
# || { echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool."; exit 1; }
command -v dotnet > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool."
exit 1
fi
}
# Checks if t4 is installed and installs it if it isnt
function installT4()
{
checkDotnet
command -v t4 > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
dotnet tool install -g dotnet-t4
fi
}
# Checks if git is installed
function checkGit()
{
git --version > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
echo >&2 "ERROR: Git is not installed. Please install git to download FNA."
exit 1
fi
}
# Clones FNA from the git master branch
function downloadFNA()
{
checkGit
echo "Downloading FNA..."
git -C $MY_DIR clone https://github.com/FNA-XNA/FNA.git --recursive
if [ $? -eq 0 ]; then
echo "Finished downloading!"
else
echo >&2 "ERROR: Unable to download successfully. Maybe try again later?"
fi
}
# Pulls FNA from the git master branch
function updateFNA()
{
checkGit
echo "Updating to the latest git version of FNA..."
git -C "$MY_DIR/FNA" pull --recurse-submodules
if [ $? -eq 0 ]; then
echo "Finished updating!"
else
echo >&2 "ERROR: Unable to update."
exit 1
fi
}
# Downloads and extracts prepackaged archive of native libraries ("fnalibs")
function getLibs()
{
# Downloading
echo "Downloading latest fnalibs..."
curl http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > "$MY_DIR/fnalibs.tar.bz2"
if [ $? -eq 0 ]; then
echo "Finished downloading!"
else
>&2 echo "ERROR: Unable to download successfully."
exit 1
fi
# Decompressing
echo "Decompressing fnalibs..."
mkdir -p $MY_DIR/fnalibs
tar xjC $MY_DIR/fnalibs -f $MY_DIR/fnalibs.tar.bz2
if [ $? -eq 0 ]; then
echo "Finished decompressing!"
echo ""
rm $MY_DIR/fnalibs.tar.bz2
else
>&2 echo "ERROR: Unable to decompress successfully."
exit 1
fi
}
# Get the directory of this script
MY_DIR=$(dirname "$BASH_SOURCE")
# gather input
# FNA
if [ ! -d "$MY_DIR/FNA" ]; then
read -p "Download FNA (y/n)? " shouldDownload
else
read -p "Update FNA (y/n)? " shouldUpdate
fi
if [ ! -d "$MY_DIR/fnalibs" ]; then
read -p "Download fnalibs (y/n)? " shouldDownloadLibs
else
read -p "Redownload fnalibs (y/n)? " shouldDownloadLibs
fi
# act on the input
# FNA
if [[ $shouldDownload =~ ^[Yy]$ ]]; then
downloadFNA
elif [[ $shouldUpdate =~ ^[Yy]$ ]]; then
updateFNA
fi
# FNALIBS
if [[ $shouldDownloadLibs =~ ^[Yy]$ ]]; then
getLibs
fi
# install t4 engine
installT4
# Only proceed from here if we have not yet renamed the project
if [ ! -d "$MY_DIR/project_name" ]; then
# old project_name folder already renamed so we are all done here
exit 1
fi
read -p "Enter the project name to use for your folder and csproj file or 'exit' to quit: " newProjectName
if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then
exit 1
fi
# any files that need to have project_name replaced with the new project name should be here
files=(project_name.sln .gitignore project_name/project_name.csproj project_name/Game1.cs project_name/DemoComponent.cs project_name/DefaultScene.cs project_name/Program.cs .vscode/tasks.json .vscode/settings.json .vscode/launch.json .vscode/buildEffects.sh .vscode/processT4Templates.sh)
for file in "${files[@]}"; do
sed -i '' "s/project_name/$newProjectName/g" $file
done
mv project_name.sln "$newProjectName.sln"
mv project_name/project_name.sln "project_name/$newProjectName.sln"
mv project_name/project_name.csproj "project_name/$newProjectName.csproj"
mv project_name/project_name.csproj.user "project_name/$newProjectName.csproj.user"
mv project_name "$newProjectName"
git init
git submodule add https://github.com/prime31/Nez.git
cd Nez
git submodule init
git submodule update
command -v pbcopy > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
printf "\n\nManually run the following command:\n\nnuget restore Nez/Nez.sln && msbuild Nez/Nez.sln && msbuild /t:restore $newProjectName && msbuild $newProjectName.sln\n\n"
else
echo "nuget restore Nez/Nez.sln && msbuild Nez/Nez.sln && msbuild /t:restore $newProjectName && msbuild $newProjectName.sln" | pbcopy
echo ""
echo "A build command was copied to your clipboard. Paste and run it now."
echo ""
fi

View File

@ -24,8 +24,19 @@ Global
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CB9E917-FEF7-453F-A88D-6B85B552B058}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CB9E917-FEF7-453F-A88D-6B85B552B058}.Release|Any CPU.Build.0 = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.Build.0 = Release|Any CPU
{11A5855C-B12C-4F8D-B935-56F3D0B671C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11A5855C-B12C-4F8D-B935-56F3D0B671C3}.Release|Any CPU.Build.0 = Release|Any CPU
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.Build.0 = Release|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
EndGlobal
EndGlobal

View File

@ -2,7 +2,7 @@ using ImGuiNET;
using Nez;
using Nez.ImGuiTools;
namespace project_name
namespace lucid
{
public class DemoComponent : Component
{
@ -11,24 +11,29 @@ namespace project_name
public override void onAddedToEntity()
{
// register with the ImGuiMangaer letting it know we want to render some IMGUI
#if DEBUG
Core.getGlobalManager<ImGuiManager>().registerDrawCommand(imGuiDraw);
#endif
}
public override void onRemovedFromEntity()
{
// remove ourselves when we are removed from the Scene
#if DEBUG
Core.getGlobalManager<ImGuiManager>().unregisterDrawCommand(imGuiDraw);
#endif
}
void imGuiDraw()
{
// do your actual drawing here
ImGui.Begin("Your ImGui Window", ImGuiWindowFlags.AlwaysAutoResize);
ImGui.Begin("Your ImGui Window", ImGuiWindowFlags.AlwaysAutoResize);
ImGui.Text("This is being drawn in DemoComponent");
if(ImGui.Button($"Clicked me {_buttonClickCounter} times"))
if (ImGui.Button($"Clicked me {_buttonClickCounter} times"))
_buttonClickCounter++;
ImGui.End();
}
}
}

View File

@ -14,13 +14,15 @@ namespace project_name
#if DEBUG
System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(System.Console.Out));
// render Nez in the imgui window in debug mode
var imGuiManager = new ImGuiManager();
Core.registerGlobalManager(imGuiManager);
#endif
scene = new DefaultScene();
// optionally render Nez in an ImGui window
var imGuiManager = new ImGuiManager();
Core.registerGlobalManager(imGuiManager);
}
}
}

View File

@ -8,6 +8,7 @@
<AssemblyName>project_name</AssemblyName>
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<!-- Reference FNA, Nez, ImGui and Persistence projects. Optionally add a Farseer reference here and in the .sln file -->