This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
159 lines (137 loc) · 5.17 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
using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using Newtonsoft.Json;
using static RobloxTweaker.MainVariables;
using static RobloxTweaker.OtherUtils;
using static RobloxTweaker.FileUtils;
using static RobloxTweaker.TexturesManager;
using static RobloxTweaker.VersionDir;
namespace RobloxTweaker
{
internal class Program
{
private const string NAME = "Roblox Tweaker";
private const string VERSION = "3.5";
private const string AUTHOR = "OhRetro";
private const string NAME_VERSION = NAME + " v" + VERSION;
private const string REPOSITORY = "https://github.com/OhRetro/Roblox-Tweaker";
private static string NEW_VERSION = "";
//About
private static void About()
{
string[] extras = {
NAME_VERSION,
string.Format("Made by {0}", AUTHOR),
string.Format("Repository: {0}", REPOSITORY)
};
_ = GenerateMenu("[About]", Array.Empty<string>(), extras, 1);
}
//Ask to Update
private static void AskToUpdate(string newVersion, string newVersionPageURL, string newVersionSetupURL)
{
string title = string.Format("There's a New Version to Update!\nNew Version: v{0}\nCurrent Version: v{1}", newVersion, VERSION);
string[] options = {
"Open New Version Page",
"Download New Version & Run"
};
int choice = Menu(title, options, Array.Empty<string>(), 0, 1);
if (choice == 1) {
Process.Start(newVersionPageURL);
}
else if (choice == 2)
{
Console.WriteLine("Downloading...");
DownloadFile(newVersionSetupURL, NEW_VERSION_SETUP_FILE);
Process.Start(NEW_VERSION_SETUP_FILE);
Environment.Exit(1);
}
NEW_VERSION = string.Format(" (New Version: v{0})", newVersion);
}
//Check for Update
private static void CheckForUpdate(bool isManual=false)
{
if (File.Exists(NEW_VERSION_SETUP_FILE))
{
File.Delete(NEW_VERSION_SETUP_FILE);
}
var response = RequestURL(REPOSITORY.Replace("https://github.com", "https://api.github.com/repos") + "/releases/latest");
if (!response.IsSuccessStatusCode)
{
Console.WriteLine("[CheckForUpdate]: Response from Github API Failed");
Continue(true);
return;
}
var json = response.Content.ReadAsStringAsync().Result;
dynamic release = JsonConvert.DeserializeObject(json);
string tag_name = release["tag_name"].ToString();
string html_url = release["html_url"].ToString();
string browser_download_url = release["assets"].ToObject<List<dynamic>>()[0]["browser_download_url"].ToString();
var newVersion = new Version(tag_name);
var currentVersion = new Version(VERSION);
if (newVersion.CompareTo(currentVersion) > 0)
{
AskToUpdate(tag_name, html_url, browser_download_url);
return;
}
if (isManual)
{
NEW_VERSION = " (There's no New Version)";
}
}
private static void Main()
{
Console.Title = NAME_VERSION;
Console.Clear();
Console.WriteLine("{0} by {1}\n", NAME_VERSION, AUTHOR);
CheckForUpdate();
ReadFile();
VerifyCustomTexturesDir();
string[] options = {
"Delete Surface Textures",
"Restore Surface Textures",
"Apply Custom GUI Textures",
"List Remaining Surface Textures",
"Update Version Directory\n",
"About",
"Check for Update"
};
string[] extras = {
string.Format("Current Selected Version: {0}", ROBLOX_VERSION_DIR_TYPE),
string.Format("Directory: {0}", ROBLOX_VERSION_DIR)
};
int menu;
do
{
menu = Menu(NAME_VERSION + NEW_VERSION, options, extras, 0, 0, "\n");
switch (menu)
{
case 1:
RemoveTextures();
break;
case 2:
RestoreTextures();
break;
case 3:
ReplaceTextures();
break;
case 4:
ListTextures();
break;
case 5:
Update(true);
break;
case 6:
About();
break;
case 7:
CheckForUpdate(true);
break;
default:
break;
}
} while (menu != 0);
}
}
}