1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-29 23:58:34 +01:00
MLEM/Demos/Program.cs

40 lines
1.4 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());
}
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();
}
}
}