-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
119 lines (104 loc) · 4.34 KB
/
Copy pathProgram.cs
File metadata and controls
119 lines (104 loc) · 4.34 KB
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
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Text;
using Spectre.Console;
using Utilities;
using static Utilities.Client;
public static class Launcher
{
public static void Main(string[] args)
{
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\simplyzetax";
if (!Directory.Exists(appdata)) Directory.CreateDirectory(appdata);
if (!File.Exists(appdata + "\\8bitsquirtle.png"))
using (var client = new WebClient())
{
client.DownloadFile(new Uri("https://cdn.nexusfn.net/file/2023/07/8bitsquirtle.png"),
appdata + "\\8bitsquirtle.png");
}
var image = new CanvasImage(appdata + @"8bitsquirtle.png");
image.MaxWidth(8);
AnsiConsole.Write(image);
AnsiConsole.WriteLine();
var option = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("[deepskyblue1 bold]What do you want to do?[/]")
.PageSize(4)
.MoreChoicesText("[grey](Move up and down to reveal more options)[/]")
.AddChoices(new[]
{
"Start client", "Start headless server", "Change credentials", "Change path"
}));
switch (option)
{
case "Start client":
if (!File.Exists(appdata + @"\path.txt"))
{
string path = ChangePath(appdata, args);
Start(path, false, appdata);
}
else
{
var path = File.ReadAllText(appdata + "\\path.txt");
Start(path, false, appdata);
}
break;
case "Start headless server":
File.Exists(appdata + @"\path.txt");
if (!File.Exists(appdata + @"\path.txt"))
{
string path = ChangePath(appdata, args);
Start(path, true, appdata);
}
else
{
var path = File.ReadAllText(appdata + "\\path.txt");
Start(path, true, appdata);
}
break;
case "Change credentials":
ChangeCredentials(appdata, args);
Main(args);
break;
case "Change path":
ChangePath(appdata, args);
Main(args);
break;
}
}
private static string ChangePath(string appdata, string[] args)
{
if (!File.Exists(appdata + "\\path.txt")) File.Create(appdata + "\\path.txt");
AnsiConsole.MarkupLine("[deepskyblue1]Please enter the path to your Fortnite installation.[/]");
var path = AnsiConsole.Ask<string>("Path: ");
if (!File.Exists(path + "\\FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe"))
{
AnsiConsole.MarkupLine("[deepskyblue1]The path you entered does not contain Fortnite[/]");
ChangePath(appdata, args);
}
File.WriteAllText(appdata + "\\path.txt", path);
AnsiConsole.Clear();
AnsiConsole.MarkupLine("[deepskyblue1]Path changed![/]");
return path;
}
private static string[] ChangeCredentials(string appdata, string[] args)
{
AnsiConsole.MarkupLine("[deepskyblue1]Please enter the path to your Fortnite installation.[/]");
string email = AnsiConsole.Ask<string>("Email: ");
string password = AnsiConsole.Ask<string>("Password: ");
using (FileStream emailFile = File.OpenWrite(appdata + "\\email.txt"))
{
byte[] emailBytes = Encoding.UTF8.GetBytes(email);
emailFile.Write(emailBytes, 0, emailBytes.Length);
}
using (FileStream passwordFile = File.OpenWrite(appdata + "\\password.txt"))
{
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
passwordFile.Write(passwordBytes, 0, passwordBytes.Length);
}
AnsiConsole.Clear();
AnsiConsole.MarkupLine("[deepskyblue1]Credentials changed![/]");
return new[] { email, password };
}
}