1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-26 18:19:24 +01:00
MLEM/Demos/Program.cs

41 lines
1.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
namespace Demos {
public static class Program {
private static readonly Dictionary<string, Func<Game>> Demos = new Dictionary<string, Func<Game>>();
static Program() {
Demos.Add("Ui", () => new UiDemo());
Demos.Add("AutoTiling", () => new AutoTilingDemo());
2019-08-14 19:07:23 +02:00
Demos.Add("Animation", () => new AnimationDemo());
Demos.Add("Pathfinding", () => new PathfindingDemo());
}
public static void Main(string[] args) {
Func<Game> demoUsed;
if (args.Length <= 0 || !Demos.ContainsKey(args[0])) {
beforeDemo:
Console.WriteLine("Please type the name of the demo you want to see and press Enter.");
Console.WriteLine("The following demos are available: " + string.Join(", ", Demos.Keys));
Console.WriteLine("(Alternatively, you can supply the name of the demo you want to see as the first argument)");
var demo = Console.ReadLine();
if (!Demos.ContainsKey(demo)) {
Console.WriteLine("Not a valid demo.");
goto beforeDemo;
} else {
demoUsed = Demos[demo];
}
} else {
demoUsed = Demos[args[0]];
}
using (var game = demoUsed.Invoke())
game.Run();
}
}
}