-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
221 lines (146 loc) · 6.23 KB
/
Program.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
using System.Diagnostics;
using Newtonsoft.Json;
using Spectre.Console;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using static Terminal.Gui.Graphs.PathAnnotation;
using static XybLauncher.FilesManager;
using static XybLauncher.AccountHandler;
using System.Net.Http;
using System.Text.Json.Serialization;
namespace XybLauncher;
public static class Program
{
//Variables
//Variables for Season Selection
private static string selectedSeason = null;
private static string selectedSeasonFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher/selectedseason.json";
private static string selectedPath = null;
private static string versionsdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher/versions.json";
public static async Task Main(string[] args)
{
//Variables
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher";
string versionsdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher/versions.json";
Console.Title = "XYB Launcher CLI";
AnsiConsole.Clear();
AnsiConsole.Write(
new FigletText("XYB Launcher CLI")
.Centered()
.Color(Color.Blue)
);
AnsiConsole.Write(new Rule("[blue]Welcome to XYB Launcher CLI[/]").Centered());
AnsiConsole.MarkupLine("Use the arrow keys [underline blue]UP[/] and [underline blue]DOWN[/] to navigate through the options.");
VersionHandler.LoadSelectedSeason();
VersionHandler.DisplaySelectedSeason();
AccountHandler.ShowSelectedAccount();
if (!Directory.Exists(appdata))
{
AnsiConsole.MarkupLine("[yellow]Appdata folder is missing, creating one [/]");
Directory.CreateDirectory(appdata);
}
var option = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("[blue]What do you want to do[/]?")
.PageSize(6)
.AddChoices(new[]
{
"Start Client" ,"Start Server", "Add Fortnite Version", "Select Fortnite Version","Build Manager", "Download Build", "Account Manager", "Exit",
}));
switch (option)
{
// Client Phase
case "Start Client":
AnsiConsole.Clear();
AnsiConsole.MarkupLine("Starting the client");
ClientManager.Test(args);
break;
// Server Phase
case "Start Server":
AnsiConsole.Clear();
XybLauncher.ServerHandler.RunFortniteServer();
AnsiConsole.MarkupLine("Starting the Server");
Console.ReadLine();
break;
//Change Password Phase
case "Change Fortnite Path":
AnsiConsole.MarkupLine("Please enter the path to your fortnite folder");
string setPath = AnsiConsole.Ask<string>("Path: ");
string fortnitePath = Path.Combine(setPath, "FortniteGame", "Binaries", "Win64");
if (Directory.Exists(fortnitePath))
{
Console.WriteLine(fortnitePath);
File.WriteAllText(appdata + "\\path.txt", setPath);
Console.Clear();
AnsiConsole.MarkupLine("Path changed, you can now start the game");
Main(args);
}
else
{
Console.WriteLine(fortnitePath);
AnsiConsole.MarkupLine("[red]Path is invalid![/]");
Main(args);
}
break;
//case "Exit":
// Environment.Exit(1);
// break;
case "Change Account Info":
AnsiConsole.MarkupLine("[red]Please Enter Your Email and Password![/]");
Console.Write("Email: ");
string email = Console.ReadLine();
File.WriteAllText(appdata + "\\email.txt", email);
Console.Write("Password: ");
string password = Console.ReadLine();
File.WriteAllText(appdata + "\\password.txt", password);
AnsiConsole.MarkupLine("[green]Email and Password Saved![/]");
break;
case "Add Fortnite Version":
VersionHandler.AddFortniteVersion();
AnsiConsole.Clear();
Main(args);
break;
case "Select Fortnite Version":
VersionHandler.SelectFortniteVersion();
AnsiConsole.Clear();
Main(args);
break;
case "Download Build":
try
{
Console.WriteLine("Starting DownloadBuild process...");
// Instantiate FilesManager
FilesManager filesManager = new FilesManager();
// Call the main logic method in FilesManager
await filesManager.HandleActionAsync("DownloadBuild");
// Log after the method call
Console.WriteLine("HandleActionAsync completed.");
// Indicate that the process has completed
Console.WriteLine("Download completed successfully. Press Enter to exit.");
}
catch (Exception ex)
{
// Log any exceptions that occur
Console.WriteLine($"An unexpected error occurred: {ex.Message}");
}
finally
{
// Keep the console window open
Console.ReadLine();
}
Main(args);
break;
case "Account Manager":
AccountHandler.StartAccountManager();
break;
case "Exit":
Environment.Exit(0);
break;
}
}
public static void MainMenu()
{
Program.Main(new string[0]);
}
}