-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntryPoint.cs
145 lines (89 loc) · 4.28 KB
/
EntryPoint.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System.Text;
using Kahoofection.Scripts;
using Kahoofection.Ressources;
namespace Kahoofection
{
internal class EntryPoint
{
private const string _currentSection = "EntryPoint";
private static readonly ApplicationSettings.Runtime _appRuntime = new();
static async Task Main()
{
string subSection = "Main";
string appVersion = _appRuntime.appVersion;
string appRelease = _appRuntime.appRelease;
ActivityLogger.Log(_currentSection, subSection, string.Empty, true);
ActivityLogger.Log(_currentSection, subSection,"Starting Kahoofection (C) The only way to play");
ActivityLogger.Log(_currentSection, subSection, $"Version '{appVersion}' | Release '{appRelease}'");
ActivityLogger.Log(_currentSection, subSection, "Trying to enable support for ANSI escape sequence.");
(bool ansiSupportEnabled, Exception occurredError) = ConsoleHelper.EnableAnsiSupport();
if (ansiSupportEnabled == false)
{
ActivityLogger.Log(_currentSection, subSection, "[ERROR] Failed to enable ANSI support.");
ActivityLogger.Log(_currentSection, subSection, occurredError.Message, true);
Console.SetCursorPosition(0, 4);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(" WARNING\r\n");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" Failed to enable support for ANSI escape sequences.");
Console.WriteLine(" This will have side effects on the coloring within the console.\r\n");
Console.WriteLine(" Please read the manual on how to fix this error!");
Thread.Sleep(5000);
}
else
{
ActivityLogger.Log(_currentSection, subSection, "Successfully enabled ANSI support!");
}
Console.Title = "Kahoofection";
Console.CursorVisible = false;
Console.OutputEncoding = Encoding.UTF8;
ActivityLogger.Log(_currentSection, subSection, "Displaying welcome message.");
await DisplayWelcomeMessage();
ActivityLogger.Log(_currentSection, subSection, "Welcome message was displayed, redirecting to the main menu.");
await MainMenu.Start();
ActivityLogger.Log(_currentSection, subSection, "Shutting down Kahoofection.");
Environment.Exit(0);
}
private static async Task DisplayWelcomeMessage()
{
ConsoleHelper.ResetConsole();
string welcomeMessage = " Hello stranger! Welcome to";
string kahoofectionSlogan = " ᴛʜᴇ ᴏɴʟʏ ᴡᴀʏ ᴛᴏ ᴘʟᴀʏ.";
string[] kahoofectionHeader =
[
@" _ __ __ _ _ __ __ ___ ___ ________ _ __ __ _ ",
@" | |/ // \| || |/__\ /__\| __| __/ _/_ _| |/__\| \| |",
@" | <| /\ | >< | \/ | \/ | _|| _| \__ | | | | \/ | | ' |",
@" |_|\_\_||_|_||_|\__/ \__/|_| |___\__/ |_| |_|\__/|_|\__|",
];
Console.ForegroundColor = ConsoleColor.White;
foreach (char c in welcomeMessage)
{
Console.Write(c);
await Task.Delay(10);
}
await Task.Delay(500);
Console.WriteLine();
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Blue;
for (int i = 0; i < kahoofectionHeader.Length; i++)
{
if (i == kahoofectionHeader.Length - 1)
{
Console.Write(kahoofectionHeader[i]);
break;
}
Console.WriteLine(kahoofectionHeader[i]);
await Task.Delay(100);
}
await Task.Delay(500);
Console.ForegroundColor = ConsoleColor.White;
foreach (char c in kahoofectionSlogan)
{
Console.Write(c);
await Task.Delay(10);
}
await Task.Delay(1500);
}
}
}