47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using Game.Data;
|
|
using Game.UI;
|
|
|
|
namespace Game {
|
|
internal class Program {
|
|
static int Main(string[] args) {
|
|
CommandLineOptions opts = CommandLineOptions.Parse(args);
|
|
|
|
TextDisplay display = new TextDisplay();
|
|
if (!display.InitWindow()) {
|
|
return 1;
|
|
}
|
|
display.PrintSimpleWelcome();
|
|
Thread.Sleep(1200);
|
|
display.ShowSplash();
|
|
Thread.Sleep(2500);
|
|
|
|
GameConfig gameConfig;
|
|
try {
|
|
GameConfig? existingGameConfig = GameFiles.ReadGameConfig();
|
|
if (existingGameConfig == null) {
|
|
gameConfig = GameFiles.CreateDefaultGameConfig();
|
|
} else {
|
|
gameConfig = existingGameConfig;
|
|
}
|
|
} catch {
|
|
display.ShowFatalError(I18n.GetMessage(I18n.Message.ERROR_READ_CONFIG_UNKNOWN));
|
|
Console.ReadKey();
|
|
return 2;
|
|
}
|
|
|
|
string databaseFileName = opts.databaseFilename ?? gameConfig.databasePath;
|
|
Database questionDatabase;
|
|
try {
|
|
questionDatabase = Database.ReadFromFile(databaseFileName);
|
|
} catch (DatabaseReadException e) {
|
|
display.ShowFatalError(string.Format(I18n.GetMessage(I18n.Message.SYNTAX_ERROR), I18n.GetMessage(e.messageId), e.line.ToString(), e.column.ToString()));
|
|
Console.ReadKey();
|
|
return 3;
|
|
}
|
|
|
|
display.ResetWindow();
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
} |