2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-03 11:09:40 -04:00

Moved example menu

- Menu for example removed from Test projects and moved to exampes.
- Changed nativeLibName from raylib.dll to raylib. It should find the correct one this way but might need a dll.config file.
This commit is contained in:
ChrisDill 2018-10-23 17:13:25 +01:00
parent 0727eda0bf
commit 3c747fa18d
6 changed files with 43 additions and 101 deletions

View File

@ -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;

View File

@ -6,7 +6,7 @@
<SharedGUID>36e54e2a-5899-4d4d-9d78-120db1b4c7b2</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Test.Common</Import_RootNamespace>
<Import_RootNamespace>Examples</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)audio\audio_module_playing.cs" />
@ -57,6 +57,7 @@
<Compile Include="$(MSBuildThisFileDirectory)shapes\shapes_lines_bezier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)shapes\shapes_logo_raylib.cs" />
<Compile Include="$(MSBuildThisFileDirectory)shapes\shapes_logo_raylib_anim.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Test.cs" />
<Compile Include="$(MSBuildThisFileDirectory)textures\textures_image_drawing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)textures\textures_image_generation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)textures\textures_image_loading.cs" />

30
Examples/Test.cs Normal file
View File

@ -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();
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}