mirror of
				https://github.com/raylib-cs/raylib-cs
				synced 2025-10-29 05:59:51 -04:00 
			
		
		
		
	Update Examples/Test.cs
- Back to using relative paths for testing examples. For example enter "core/core_basic_window".
This commit is contained in:
		| @@ -6,25 +6,45 @@ namespace Examples | |||||||
| { | { | ||||||
|     public class Test |     public class Test | ||||||
|     { |     { | ||||||
|  |         public static string GetExampleDirectory() | ||||||
|  |         { | ||||||
|  |             var dir = Environment.CurrentDirectory; | ||||||
|  |             dir = dir.Substring(0, dir.LastIndexOf("Raylib-cs") + 9) + "\\Examples\\"; | ||||||
|  |             return dir; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // menu for testing examples |         // menu for testing examples | ||||||
|  |         // specify name relative to example directory | ||||||
|         public static void Run(string[] args) |         public static void Run(string[] args) | ||||||
|         { |         { | ||||||
|             Console.WriteLine("Welcome to raylib-cs!"); |             Console.WriteLine("Welcome to raylib-cs!"); | ||||||
|  |             Console.WriteLine("---------------------"); | ||||||
|  |  | ||||||
|  |             var examples = GetExampleDirectory(); | ||||||
|  |             Console.WriteLine("Looking for examples relative to " + examples); | ||||||
|  |             Console.WriteLine("For example, core/core_basic_window"); | ||||||
|  |  | ||||||
|             while (true) |             while (true) | ||||||
|             { |             { | ||||||
|                 Console.WriteLine("Enter path to example"); |                 Console.Write("Choose a example: "); | ||||||
|  |  | ||||||
|  |                 // select example | ||||||
|                 var filePath = Console.ReadLine(); |                 var filePath = Console.ReadLine(); | ||||||
|                 var name = Path.GetFileNameWithoutExtension(filePath); |                 var name = Path.GetFileNameWithoutExtension(filePath); | ||||||
|  |                 var dir = examples + filePath + ".cs"; | ||||||
|                  |                  | ||||||
|                 Console.WriteLine("Running example " + filePath); |                 // run example if it exists | ||||||
|  |                 if (File.Exists(dir)) | ||||||
|                 ChangeDirectory(filePath); |                 { | ||||||
|  |                     ChangeDirectory(Path.GetDirectoryName(dir)); | ||||||
|                     Type.GetType(name)?.GetMethod("Main")?.Invoke(null, args); |                     Type.GetType(name)?.GetMethod("Main")?.Invoke(null, args); | ||||||
|  |  | ||||||
|                     Console.WriteLine(); |                     Console.WriteLine(); | ||||||
|                 } |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     Console.WriteLine(filePath + " is not a valid example"); | ||||||
|  |                 }  | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user