-
Notifications
You must be signed in to change notification settings - Fork 17
/
gameloadDialog.cs
123 lines (100 loc) · 3.81 KB
/
gameloadDialog.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
using ComponentFactory.Krypton.Toolkit;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DualSenseAT
{
public partial class gameloadDialog : KryptonForm
{
public gameloadDialog()
{
InitializeComponent();
}
public string gameName;
public string picture_url;
public int app_id;
public bool isSteamGame;
private void gameloadDialog_Load(object sender, EventArgs e)
{
WebClient client = new WebClient();
Stream image_data = new MemoryStream(client.DownloadData(picture_url));
pictureBox1.Image = Image.FromStream(image_data);
label1.Text = gameName;
getGameFiles();
}
public void getGameFiles()
{
metroProgressBar1.ProgressBarStyle = ProgressBarStyle.Continuous;
metroProgressBar1.Value = 0;
System.IO.DirectoryInfo di = new DirectoryInfo(Constants.TEMP_PATH + "\\" + app_id + "\\download\\");
try
{
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
dir.Delete(true);
}
}
catch (Exception ex)
{
}
if (!Directory.Exists(Constants.TEMP_PATH + "\\" + app_id + "\\download\\"))
Directory.CreateDirectory(Constants.TEMP_PATH + "\\" + app_id + "\\download\\");
WebClient client = new WebClient();
client.DownloadProgressChanged += ProgressChanged;
client.DownloadFileCompleted += Completed;
client.DownloadFileAsync(new Uri(Constants.BASE_URL + "games/"+app_id+"/pack_data.zip"), Constants.TEMP_PATH + "\\"+app_id+"\\download\\pack_data.zip");
}
public void startMod()
{
//Read game Manifests
var json = File.ReadAllText(Constants.TEMP_PATH + "\\" + app_id + "\\download\\gameManifest.json");
JObject manifest = JObject.Parse(json);
// MessageBox.Show(manifest.ToString(Newtonsoft.Json.Formatting.Indented));
//Prepare .EXE Loading...
Clipboard.SetText(Constants.TEMP_PATH + "\\" + app_id + "\\download\\" + manifest["info"][0]["exec"]);
Process.Start(Constants.TEMP_PATH + "\\" + app_id + "\\download\\" + manifest["info"][0]["exec"]);
this.Close();
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
metroProgressBar1.Value = e.ProgressPercentage;
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
metroProgressBar1.ProgressBarStyle = ProgressBarStyle.Marquee;
metroProgressBar1.Value = 40;
try
{
ZipFile.ExtractToDirectory(Constants.TEMP_PATH + "\\" + app_id + "\\download\\pack_data.zip", Constants.TEMP_PATH + "\\" + app_id + "\\download");
metroProgressBar1.ProgressBarStyle = ProgressBarStyle.Continuous;
metroProgressBar1.Value = 100;
startMod();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void metroProgressBar1_Click(object sender, EventArgs e)
{
}
private void metroButton1_Click(object sender, EventArgs e)
{
}
}
}