diff --git a/Bindings/Raylib.cs b/Bindings/Raylib.cs index b9c56e2..116c15d 100644 --- a/Bindings/Raylib.cs +++ b/Bindings/Raylib.cs @@ -5,6 +5,7 @@ * **********************************************************************************************/ using System; +using System.IO; using System.Runtime.InteropServices; namespace Raylib @@ -72,7 +73,7 @@ namespace Raylib // Pixel formats // NOTE: Support depends on OpenGL version and platform - public enum PixelFormat : int + public enum PixelFormat { UNCOMPRESSED_GRAYSCALE = 1, UNCOMPRESSED_GRAY_ALPHA = 2, @@ -188,9 +189,8 @@ namespace Raylib } // enum extension for constants - // Keyboard Function Keys - public enum Key : int + public enum Key { KEY_SPACE = 32, KEY_ESCAPE = 256, @@ -720,7 +720,7 @@ namespace Raylib #region Raylib-cs Variables // Used by DllImport to load the native library. - public const string nativeLibName = "raylib.dll"; + public const string nativeLibName = "raylib"; public const float DEG2RAD = (float)Math.PI / 180.0f; public const float RAD2DEG = 180.0f / (float)Math.PI; diff --git a/Examples/Examples.projitems b/Examples/Examples.projitems index 376dd80..4fe020d 100644 --- a/Examples/Examples.projitems +++ b/Examples/Examples.projitems @@ -6,7 +6,7 @@ 36e54e2a-5899-4d4d-9d78-120db1b4c7b2 - Test.Common + Examples @@ -57,6 +57,7 @@ + diff --git a/Examples/Test.cs b/Examples/Test.cs new file mode 100644 index 0000000..5cb25e4 --- /dev/null +++ b/Examples/Test.cs @@ -0,0 +1,30 @@ +using System; +using System.IO; +using static Raylib.Raylib; + +namespace Examples +{ + public class Test + { + // menu for testing examples + public static void Run(string[] args) + { + Console.WriteLine("Welcome to raylib-cs!"); + + while (true) + { + Console.WriteLine("Enter path to example"); + + var filePath = Console.ReadLine(); + var name = Path.GetFileNameWithoutExtension(filePath); + + Console.WriteLine("Running example " + filePath); + + ChangeDirectory(filePath); + Type.GetType(name)?.GetMethod("Main")?.Invoke(null, args); + + Console.WriteLine(); + } + } + } +} diff --git a/Test.NetCore/Program.cs b/Test.NetCore/Program.cs index 898d2a2..e724209 100644 --- a/Test.NetCore/Program.cs +++ b/Test.NetCore/Program.cs @@ -1,35 +1,11 @@ -using System; -using System.IO; -using Raylib; -using static Raylib.Raylib; - + namespace Test.NetCore { class Program { static void Main(string[] args) { - Console.WriteLine("Welcome to raylib-cs!"); - - var dir = Environment.CurrentDirectory; - while (true) - { - Console.WriteLine("Select raylib example(core/core_2d_camera)"); - - var filePath = Console.ReadLine();; - Console.WriteLine("Running example " + filePath + "..."); - - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir += "\\Examples\\"; - - var folder = dir + Path.GetDirectoryName(filePath); - ChangeDirectory(folder); - Type.GetType(filePath)?.GetMethod("Main")?.Invoke(null, args); - Console.WriteLine(); - } + Examples.Test.Run(args); } } } diff --git a/Test.NetCoreRT/Program.cs b/Test.NetCoreRT/Program.cs index 898d2a2..639c6cf 100644 --- a/Test.NetCoreRT/Program.cs +++ b/Test.NetCoreRT/Program.cs @@ -1,35 +1,11 @@ -using System; -using System.IO; -using Raylib; -using static Raylib.Raylib; - -namespace Test.NetCore + +namespace Test.NetCoreRT { class Program { static void Main(string[] args) { - Console.WriteLine("Welcome to raylib-cs!"); - - var dir = Environment.CurrentDirectory; - while (true) - { - Console.WriteLine("Select raylib example(core/core_2d_camera)"); - - var filePath = Console.ReadLine();; - Console.WriteLine("Running example " + filePath + "..."); - - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir = Directory.GetParent(dir).FullName; - dir += "\\Examples\\"; - - var folder = dir + Path.GetDirectoryName(filePath); - ChangeDirectory(folder); - Type.GetType(filePath)?.GetMethod("Main")?.Invoke(null, args); - Console.WriteLine(); - } + Examples.Test.Run(args); } } } diff --git a/Test.NetFX/Program.cs b/Test.NetFX/Program.cs index 81471c1..14581c0 100644 --- a/Test.NetFX/Program.cs +++ b/Test.NetFX/Program.cs @@ -1,52 +1,11 @@ -using System; -using System.IO; -using System.Reflection; -using System.Windows.Forms; -using Raylib; -using static Raylib.Raylib; - + namespace Test.NetFX { class Program { - [STAThread] static void Main(string[] args) { - Console.WriteLine("Welcome to raylib-cs!"); - - var dir = Environment.CurrentDirectory + "../../../Examples"; - while (true) - { - var ofd = new OpenFileDialog - { - Filter = @"C#|*.cs", - Title = @"Select raylib example", - InitialDirectory = dir - }; - - if (ofd.ShowDialog() != DialogResult.OK) - return; - - var test = Path.GetFileNameWithoutExtension(ofd.FileName); - Console.WriteLine("Running example " + test + "..."); - - ChangeDirectory(Path.GetDirectoryName(ofd.FileName)); - - var call = Type.GetType(test)?.GetMethod("Main"); - - try - { - call?.Invoke(null, args); - } - catch (TargetInvocationException ex) - { - Console.WriteLine(ex.Message); - Console.WriteLine(ex.InnerException.Message); - Console.ReadLine(); - } - - Console.WriteLine(); - } + Examples.Test.Run(args); } } }