This repository was archived by the owner on Feb 21, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProgram.cs
More file actions
139 lines (115 loc) · 5.84 KB
/
Copy pathProgram.cs
File metadata and controls
139 lines (115 loc) · 5.84 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.IO;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Net;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using Pro_Swapper.API;
namespace Pro_Swapper
{
static class Program
{
public static Logger.Logger logger;
public static HttpClient httpClient;
public const string Oodledll = "oo2core_5_win64.dll";
public const string Oodledll9 = "oo2core_9_win64.dll";
private static void InitializeHttpClient(ref HttpClient httpClient)
{
HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
httpClient = new HttpClient(clientHandler);
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36");
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
try
{
Utils.KillDuplicateProcesses();
InitializeHttpClient(ref Program.httpClient);
Directory.CreateDirectory(global.ProSwapperFolder);
Directory.CreateDirectory(global.ProSwapperFolder + "\\Config");
Directory.CreateDirectory(global.ProSwapperFolder + "\\Images");
Native.SetDllDirectory(global.ProSwapperFolder);
global.InitConfig();
logger = new Logger.Logger(global.ProSwapperFolder + "Pro_Swapper.log");
logger.Log($"Pro Swapper Version: {global.version}");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
UI.Splash splash = new UI.Splash();
Task.Run(() => Application.Run(splash));
logger.Log("Started Splash Screen");
if (!File.Exists(global.CurrentConfig.Paks + @"\pakchunk0-WindowsClient.sig"))
{
logger.Log("Fortnite paks have not been found! Searching for paks now");
if (EpicGamesLauncher.FindPakFiles() && global.CurrentConfig.Paks.Contains("Paks"))
{
logger.Log($"Found paks folder -> {global.CurrentConfig.Paks}");
}
else
{
logger.Log($"ERROR -> Paks folder could not be found!");
MessageBox.Show(@"Your Fortnite install location could not be found! Please make sure you have Fortnite installed!", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
logger.Log(global.GetPaksList);
if (!File.Exists(Oodledll) || !File.Exists(Oodledll9))
{
string OodlePath = Path.Combine(global.ProSwapperFolder, Oodledll);
File.WriteAllBytes(OodlePath, Properties.Resources.oo2core_5_win64);
logger.Log($"Wrote {Oodledll} to {OodlePath}");
string OodlePath9 = Path.Combine(global.ProSwapperFolder, Oodledll9);
File.WriteAllBytes(OodlePath9, Properties.Resources.oo2core_9_win64);
logger.Log($"Wrote {Oodledll9} to {OodlePath9}");
}
else
{
logger.Log($"{Oodledll} already exists so no need to fetch it!");
}
logger.Log($"Fetching latest data from API");
if (!api.UpdateAPI())
{
logger.Log($"ERROR -> Could not fetch latest data from API");
MessageBox.Show("Could not fetch latest data from API! Please try again later!", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Process.GetCurrentProcess().Kill();
}
string apiversion = api.apidata.version;
double TimeNow = global.GetEpochTime();
if (global.CurrentConfig.lastopened + 7200 < TimeNow)
{
global.OpenUrl(api.apidata.discordurl);
global.CurrentConfig.lastopened = TimeNow;
}
int thisVer = int.Parse(global.version.Replace(".", ""));
int apiVer = int.Parse(api.apidata.version.Replace(".", ""));
const string NewDownload = "https://linkvertise.com/86737/proswapper";
if (apiVer > thisVer)
{
MessageBox.Show("New Pro Swapper Update found! Redirecting you to the new download!", "Pro Swapper Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
global.OpenUrl(NewDownload);
Process.GetCurrentProcess().Kill();
}
if (global.IsNameModified())
{
Pro_Swapper.Main.ThrowError($"This Pro Swapper version has been renamed, this means you have not downloaded it from the official source. Please redownload it on the Discord server at {api.apidata.discordurl}");
global.OpenUrl(NewDownload);
}
if (api.apidata.status[0].IsUp == false)
Pro_Swapper.Main.ThrowError(api.apidata.status[0].DownMsg);
logger.Log("Running main form");
RPC.InitializeRPC();
Application.Run(new Main(splash));
}
catch (Exception ex)
{
MessageBox.Show($"Error: {ex.Message}", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Error);
logger.LogError(ex.Message);
}
}
}
}