-
Notifications
You must be signed in to change notification settings - Fork 2
/
Setup.cs
253 lines (240 loc) · 9.21 KB
/
Setup.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
using System.IO;
using System.Threading;
namespace Shortcut_Generator
{
public partial class Setup : Form
{
public Setup()
{
InitializeComponent();
}
FolderBrowserDialog fbd = new FolderBrowserDialog();
public bool hold = false;
Point CP;
//continue
private void Continue_Click(object sender, EventArgs e)
{
string GDText = GameDirectory.Text;
string SDText = ShortcutDirectory.Text;
string CDText = CEMUDirectory.Text;
string IDText = IconDirectory.Text;
if (Directory.Exists(GDText))
{
if (Directory.Exists(SDText))
{
if (File.Exists(CDText + @"\cemu.exe"))
{
RegistryKey Software =
Registry.CurrentUser.CreateSubKey("Software");
using (RegistryKey
Directories = Software.CreateSubKey("Shortcut-Generator"))
{
Directories.SetValue("GameDirectory", GDText);
Directories.SetValue("ShortcutDirectory", SDText);
Directories.SetValue("CEMUDirectory", CDText);
if (!IDText.StartsWith("[Experimental]"))
{
if (File.Exists(IDText + @"\#Credit (don't delete).txt"))
{
Directories.SetValue("IconDirectory", IDText);
}
else
{
MessageBox.Show("\"" + IDText + "\\#Credit (don't delete).txt\" not found!\r\nIt is important to keep that file for the Program to know,\r\nif the folder is correct!");
DialogResult dialogResult = MessageBox.Show("Should the file be created in \"" + IDText + "\"?", "Shortcut-Generator", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Directories.SetValue("IconDirectory", IDText);
}
else if (dialogResult == DialogResult.No)
{
MessageBox.Show("Continuing without Icons!");
}
}
}
}
MainWindow m = new MainWindow();
this.Hide();
m.Show();
}
else
{
MessageBox.Show("\"" + SDText + "\\cemu.exe\" not found!");
}
}
else
{
MessageBox.Show("\"" + SDText + "\" not found!");
}
}
else
{
MessageBox.Show("\"" + GDText + "\" not found!");
}
}
//Browse
private void BrowseGame_Click(object sender, EventArgs e)
{
if (Directory.Exists(GameDirectory.Text))
fbd.SelectedPath = GameDirectory.Text;
if (fbd.ShowDialog() == DialogResult.OK)
GameDirectory.Text = fbd.SelectedPath;
}
private void BrowseShortcut_Click(object sender, EventArgs e)
{
if (Directory.Exists(ShortcutDirectory.Text))
fbd.SelectedPath = ShortcutDirectory.Text;
if (fbd.ShowDialog() == DialogResult.OK)
ShortcutDirectory.Text = fbd.SelectedPath;
}
private void BrowseCEMU_Click(object sender, EventArgs e)
{
if (Directory.Exists(CEMUDirectory.Text))
fbd.SelectedPath = CEMUDirectory.Text;
if (fbd.ShowDialog() == DialogResult.OK)
CEMUDirectory.Text = fbd.SelectedPath;
}
private void BrowseIcon_Click(object sender, EventArgs e)
{
if (Directory.Exists(IconDirectory.Text))
fbd.SelectedPath = IconDirectory.Text;
if (fbd.ShowDialog() == DialogResult.OK)
IconDirectory.Text = fbd.SelectedPath;
}
//move window
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
hold = true;
CP = Cursor.Position;
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
hold = false;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (hold)
{
Point FormLocation = Location;
Point CursorLocation = Cursor.Position;
if (FormLocation.Y <= CursorLocation.Y + 50)
{
Top = FormLocation.Y + (CursorLocation.Y - CP.Y);
Left = FormLocation.X + (CursorLocation.X - CP.X);
//.Show((CursorLocation.X - FormLocation.X).ToString() + "\r\n" + (CursorLocation.Y - FormLocation.Y));
CP = Cursor.Position;
}
}
}
//control box
private void X_Click(object sender, EventArgs e)
{
this.Close();
}
private void minus_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
//X
private void X_MouseEnter(object sender, EventArgs e)
{
this.X.Image = global::Shortcut_Generator.Properties.Resources.X_hover;
}
private void X_MouseLeave(object sender, EventArgs e)
{
this.X.Image = global::Shortcut_Generator.Properties.Resources.X;
}
private void X_MouseDown(object sender, MouseEventArgs e)
{
this.X.Image = global::Shortcut_Generator.Properties.Resources.X_click;
}
private void X_MouseUp(object sender, MouseEventArgs e)
{
this.X.Image = global::Shortcut_Generator.Properties.Resources.X_hover;
}
//minus
private void minus_MouseEnter(object sender, EventArgs e)
{
this.minus.Image = global::Shortcut_Generator.Properties.Resources.minus_hover;
}
private void minus_MouseLeave(object sender, EventArgs e)
{
this.minus.Image = global::Shortcut_Generator.Properties.Resources.minus;
}
private void minus_MouseDown(object sender, MouseEventArgs e)
{
this.minus.Image = global::Shortcut_Generator.Properties.Resources.minus_click;
}
private void minus_MouseUp(object sender, MouseEventArgs e)
{
this.minus.Image = global::Shortcut_Generator.Properties.Resources.minus_hover;
}
//label-moving
private void label1_MouseDown(object sender, MouseEventArgs e)
{
Form1_MouseDown(sender, e);
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
Form1_MouseMove(sender, e);
}
private void label1_MouseUp(object sender, MouseEventArgs e)
{
Form1_MouseUp(sender, e);
}
//credit
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://sythriox.deviantart.com/art/Wii-U-game-icons-for-CEMU-667116100");
}
private void Form1_Load(object sender, EventArgs e)
{
RegistryKey Software =
Registry.CurrentUser.OpenSubKey("Software");
string SD;
using (RegistryKey
Directories = Software.OpenSubKey("Shortcut-Generator"))
{
try
{
GameDirectory.Text = Directories.GetValue("GameDirectory").ToString();
}
catch
{
GameDirectory.Text = "[Example] C:\\CEMU-Games";
}
try
{
SD = Directories.GetValue("ShortcutDirectory").ToString();
ShortcutDirectory.Text = SD;
}
catch
{
SD = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
ShortcutDirectory.Text = SD;
}
try
{
CEMUDirectory.Text = Directories.GetValue("CEMUDirectory").ToString();
}
catch
{
CEMUDirectory.Text = "[Example] C:\\Cemu_1.10.0";
}
try
{
IconDirectory.Text = Directories.GetValue("IconDirectory").ToString();
}
catch
{
IconDirectory.Text = "[Experimental] Directory with properly named files required!";
}
}
}
}
}