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
14 changes: 14 additions & 0 deletions Examples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using static Examples.Program;
using ShapeEngine.Core;

namespace Examples
{
Expand All @@ -8,6 +9,19 @@ public static class Program
public static GameloopExamples GAMELOOP = new();
public static void Main(string[] args)
{
//this is a fix to be able to run the examples executable on macOS with a double click...
//this fix was implemented into shape engine directly, therefore it is not needed here anymore
// if (Game.IsOSX())
// {
//var 1
// var exePath = System.Reflection.Assembly.GetEntryAssembly()?.Location;
// var exeDir = Path.GetDirectoryName(exePath);
// if (exeDir != null) Directory.SetCurrentDirectory(exeDir);
//var 2
// string exeDir = AppContext.BaseDirectory;
// if (!string.IsNullOrEmpty(exeDir)) Directory.SetCurrentDirectory(exeDir);
// }


// GAMELOOP = new();
GAMELOOP.Run(args);
Expand Down
13 changes: 13 additions & 0 deletions ShapeEngine/Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ public Game(GameSettings gameSettings, WindowSettings windowSettings)
ShapeInput.OnInputDeviceChanged += OnInputDeviceChanged;
ShapeInput.GamepadDeviceManager.OnGamepadConnectionChanged += OnGamepadConnectionChanged;

//This sets the current directory to the executable's folder, enabling double-click launches.
//without this, the executable has to be launched from the command line
if (IsOSX())
{
//old version
// string? exePath = System.Reflection.Assembly.GetEntryAssembly()?.Location;
// string? exeDir = Path.GetDirectoryName(exePath);
// if (exeDir != null) Directory.SetCurrentDirectory(exeDir);

//updated version
string exeDir = AppContext.BaseDirectory;
if (!string.IsNullOrEmpty(exeDir)) Directory.SetCurrentDirectory(exeDir);
}
}


Expand Down
Loading