-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrickyProjectWindow.cs
More file actions
372 lines (343 loc) · 17.3 KB
/
TrickyProjectWindow.cs
File metadata and controls
372 lines (343 loc) · 17.3 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
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
using Microsoft.WindowsAPICodePack.Dialogs;
using System.IO;
using System.Windows.Forms;
using SSXLibrary.JsonFiles.Tricky;
using SSXMultiTool.Utilities;
using SSXLibrary;
using SSX_Library;
namespace SSXMultiTool
{
public partial class TrickyProjectWindow : Form
{
public TrickyProjectWindow()
{
ConsoleWindow.GenerateConsole();
InitializeComponent();
LTGMode.SelectedIndex = 1;
}
private void ExtractLevel_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Map File (*.map,*.big)|*.map;*.big|All files (*.*)|*.*",
FilterIndex = 1,
RestoreDirectory = false
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
CommonOpenFileDialog commonDialog = new CommonOpenFileDialog
{
IsFolderPicker = true
};
if (commonDialog.ShowDialog() == CommonFileDialogResult.Ok)
{
if (Directory.GetFiles(commonDialog.FileName).Count() != 1)
{
this.Text = "Tricky Project Window (Extracting...)";
if (openFileDialog.FileName.ToLower().Contains(".big"))
{
BIG.Extract(openFileDialog.FileName, Application.StartupPath + "\\TempExtract");
string[] strings = Directory.GetFiles(Application.StartupPath + "\\TempExtract", "*.map", SearchOption.AllDirectories);
if (strings.Length != 0)
{
ExtractFiles(strings[0], commonDialog.FileName);
this.Text = "Tricky Project Window (Extracting Done)";
}
else
{
MessageBox.Show("Missing Level Files");
}
Directory.Delete(Application.StartupPath + "\\TempExtract", true);
}
else
{
ExtractFiles(openFileDialog.FileName, commonDialog.FileName);
//MessageBox.Show("Level Extracted");
}
this.Text = "Tricky Project Window (Extracting Done)";
//FlashWindow.Flash(this, 5);
}
else
{
MessageBox.Show("Folder Must Be Empty.");
}
}
}
}
TrickyLevelInterface trickyLevelInterface = new TrickyLevelInterface();
SSXTrickyConfig trickyConfig = new SSXTrickyConfig();
public string ProjectPath = "";
public string BuildPath = "";
void ExtractFiles(string StartPath, string ExportPath)
{
Console.WriteLine("Begining Level Extraction...");
string LoadPath = StartPath.Substring(0, StartPath.Length - 4);
trickyLevelInterface = new TrickyLevelInterface();
trickyLevelInterface.InlineExporting = JSONInlineCheck.Checked;
trickyLevelInterface.ExtractTrickyLevelFiles(LoadPath, ExportPath);
ProjectPath = ExportPath;
SaveConfig.Enabled = true;
RebuildButton.Enabled = true;
RebuildNoPathButton.Enabled = true;
trickyConfig = new SSXTrickyConfig();
trickyConfig.BuildUniLightmap = UnlitLightmapCheckbox.Checked;
trickyConfig.BuildPBDGenerate = GenPBD.Checked;
trickyConfig.BuildSSHGenerate = GenSSH.Checked;
trickyConfig.BuildLSSHGenerate = GenLSSH.Checked;
trickyConfig.BuildLTGGenerate = GenLTG.Checked;
trickyConfig.BuildMAPGenerate = GenMAP.Checked;
trickyConfig.BuildSkyPBDGenerate = GenSkyPBD.Checked;
trickyConfig.BuildSkySSHGenerate = GenSkySSH.Checked;
trickyConfig.BuildADLGenerate = GenADL.Checked;
trickyConfig.BuildSSFGenerate = GenSSF.Checked;
trickyConfig.BuildAIPGenerate = GenAIP.Checked;
trickyConfig.BuildSOPGenerate = GenSOP.Checked;
trickyConfig.BuildLTGGenerateMode = LTGMode.SelectedIndex;
trickyConfig.CreateJson(ExportPath + "/ConfigTricky.ssx");
trickyLevelInterface.LoadAndVerifyFiles(ProjectPath);
UpdateText();
}
void UpdateText()
{
PatchesLabel.Text = trickyLevelInterface.patchPoints.Patches.Count.ToString();
InstancesLabel.Text = trickyLevelInterface.instancesJson.Instances.Count.ToString();
ParticleInstancesLabel.Text = trickyLevelInterface.particleInstanceJson.Particles.Count.ToString();
MaterialLabel.Text = trickyLevelInterface.materialJson.Materials.Count.ToString();
SplinesLabel.Text = trickyLevelInterface.splineJsonHandler.Splines.Count.ToString();
LightLabel.Text = trickyLevelInterface.lightJsonHandler.Lights.Count.ToString();
ModelsLabel.Text = trickyLevelInterface.prefabJsonHandler.Models.Count.ToString();
ParticleModelLabels.Text = trickyLevelInterface.particleModelJsonHandler.ParticlePrefabs.Count.ToString();
SkyMat.Text = trickyLevelInterface.SkyMaterialJson.Materials.Count.ToString();
SkyModel.Text = trickyLevelInterface.SkyPrefabJsonHandler.Models.Count.ToString();
if (ProjectPath != null && ProjectPath != "")
{
TextureLabel.Text = Directory.GetFiles(ProjectPath + "/Textures", "*.png").Length.ToString();
SykboxLabel.Text = Directory.GetFiles(ProjectPath + "/Skybox/Textures", "*.png").Length.ToString();
LightmapLabel.Text = Directory.GetFiles(ProjectPath + "/Lightmaps", "*.png").Length.ToString();
}
LevelNameTextbox.Text = trickyConfig.LevelName;
AuthorTextbox.Text = trickyConfig.Author;
VersionTextbox.Text = trickyConfig.LevelVersion;
DifficultyTextbox.Text = trickyConfig.Difficulty;
LocationTextbox.Text = trickyConfig.Location;
VerticalDropTextbox.Text = trickyConfig.Vertical;
CourseLengthTextbox.Text = trickyConfig.Length;
DescriptionTextbox.Text = trickyConfig.Description;
}
private void RebuildButton_Click(object sender, EventArgs e)
{
if (File.Exists(ProjectPath + "/ConfigTricky.ssx"))
{
SaveFileDialog openFileDialog = new SaveFileDialog
{
Filter = "Map File (*.map,*.big)|*.map;*.big|All files (*.*)|*.*",
FilterIndex = 1,
RestoreDirectory = false
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
SaveConfig_Click(sender, e);
this.Text = "Tricky Project Window (Building...)";
trickyLevelInterface = new TrickyLevelInterface();
trickyLevelInterface.Unilightmap = UnlitLightmapCheckbox.Checked;
trickyLevelInterface.PBDGenerate = GenPBD.Checked;
trickyLevelInterface.SSHGenerate = GenSSH.Checked;
trickyLevelInterface.LSSHGenerate = GenLSSH.Checked;
trickyLevelInterface.LTGGenerate = GenLTG.Checked;
trickyLevelInterface.MAPGenerate = GenMAP.Checked;
trickyLevelInterface.SkyPBDGenerate = GenSkyPBD.Checked;
trickyLevelInterface.SkySSHGenerate = GenSkySSH.Checked;
trickyLevelInterface.ADLGenerate = GenADL.Checked;
trickyLevelInterface.SSFGenerate = GenSSF.Checked;
trickyLevelInterface.AIPGenerate = GenAIP.Checked;
trickyLevelInterface.SOPGenerate = GenSOP.Checked;
trickyLevelInterface.LTGGenerateMode = LTGMode.SelectedIndex;
BuildPath = openFileDialog.FileName;
try
{
if (openFileDialog.FileName.ToLower().Contains(".big"))
{
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract");
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract\\Data");
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract\\data\\models");
string InputPath = Application.StartupPath + "\\TempExtract\\data\\models\\" + Path.GetFileName(openFileDialog.FileName.ToLower()).Substring(0, Path.GetFileName(openFileDialog.FileName).Length - 3) + "map";
trickyLevelInterface.BuildTrickyLevelFiles(ProjectPath, InputPath);
BIG.Create(BigType.C0FB, Application.StartupPath + "\\TempExtract", BuildPath, true);
Directory.Delete(Application.StartupPath + "\\TempExtract", true);
}
else
{
trickyLevelInterface.BuildTrickyLevelFiles(ProjectPath, openFileDialog.FileName);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ErrorUtil.Error);
MessageBox.Show(ErrorUtil.Error);
}
this.Text = "Tricky Project Window (Building Done)";
//FlashWindow.Flash(this);
}
}
else
{
MessageBox.Show("Not a valid project");
}
}
private void RebuildNoPathButton_Click(object sender, EventArgs e)
{
if (File.Exists(ProjectPath + "/ConfigTricky.ssx"))
{
if (BuildPath == "")
{
RebuildButton_Click(sender, e);
return;
}
SaveConfig_Click(sender, e);
this.Text = "Tricky Project Window (Building...)";
trickyLevelInterface = new TrickyLevelInterface();
trickyLevelInterface.Unilightmap = UnlitLightmapCheckbox.Checked;
trickyLevelInterface.PBDGenerate = GenPBD.Checked;
trickyLevelInterface.SSHGenerate = GenSSH.Checked;
trickyLevelInterface.LSSHGenerate = GenLSSH.Checked;
trickyLevelInterface.LTGGenerate = GenLTG.Checked;
trickyLevelInterface.MAPGenerate = GenMAP.Checked;
trickyLevelInterface.SkyPBDGenerate = GenSkyPBD.Checked;
trickyLevelInterface.SkySSHGenerate = GenSkySSH.Checked;
trickyLevelInterface.ADLGenerate = GenADL.Checked;
trickyLevelInterface.SSFGenerate = GenSSF.Checked;
trickyLevelInterface.AIPGenerate = GenAIP.Checked;
trickyLevelInterface.SOPGenerate = GenSOP.Checked;
trickyLevelInterface.LTGGenerateMode = LTGMode.SelectedIndex;
try
{
if (BuildPath.Contains(".big"))
{
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract");
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract\\Data");
Directory.CreateDirectory(Application.StartupPath + "\\TempExtract\\data\\models");
string InputPath = Application.StartupPath + "\\TempExtract\\data\\models\\" + Path.GetFileName(BuildPath.ToLower()).Substring(0, Path.GetFileName(BuildPath).Length - 3) + "map";
trickyLevelInterface.BuildTrickyLevelFiles(ProjectPath, InputPath);
BIG.Create(BigType.C0FB, Application.StartupPath + "\\TempExtract", BuildPath, true);
Directory.Delete(Application.StartupPath + "\\TempExtract", true);
}
else
{
trickyLevelInterface.BuildTrickyLevelFiles(ProjectPath, BuildPath);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ErrorUtil.Error);
MessageBox.Show(ErrorUtil.Error);
}
this.Text = "Tricky Project Window (Building Done)";
//FlashWindow.Flash(this);
//MessageBox.Show("Level Built");
}
}
private void LoadProject_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Config File (*.ssx)|*.ssx|All files (*.*)|*.*",
FilterIndex = 1,
RestoreDirectory = false
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
trickyConfig = SSXTrickyConfig.Load(openFileDialog.FileName);
if (trickyConfig.Version == 3)
{
UnlitLightmapCheckbox.Checked = trickyConfig.BuildUniLightmap;
GenPBD.Checked = trickyConfig.BuildPBDGenerate;
GenSSH.Checked = trickyConfig.BuildSSHGenerate;
GenLSSH.Checked = trickyConfig.BuildLSSHGenerate;
GenLTG.Checked = trickyConfig.BuildLTGGenerate;
GenMAP.Checked = trickyConfig.BuildMAPGenerate;
GenSkyPBD.Checked = trickyConfig.BuildSkyPBDGenerate;
GenSkySSH.Checked = trickyConfig.BuildSkySSHGenerate;
GenADL.Checked = trickyConfig.BuildADLGenerate;
GenSSF.Checked = trickyConfig.BuildSSFGenerate;
GenAIP.Checked = trickyConfig.BuildAIPGenerate;
GenSOP.Checked = trickyConfig.BuildSOPGenerate;
LTGMode.SelectedIndex = trickyConfig.BuildLTGGenerateMode;
BuildPath = trickyConfig.BuildPath;
trickyLevelInterface = new TrickyLevelInterface();
SaveConfig.Enabled = true;
RebuildButton.Enabled = true;
RebuildNoPathButton.Enabled = true;
ProjectPath = Path.GetDirectoryName(openFileDialog.FileName);
trickyLevelInterface.LoadAndVerifyFiles(ProjectPath);
UpdateText();
}
else
{
MessageBox.Show("Cannont Open Due to Incorrect Version");
}
}
}
private void SaveConfig_Click(object sender, EventArgs e)
{
trickyConfig.LevelName = LevelNameTextbox.Text;
trickyConfig.Author = AuthorTextbox.Text;
trickyConfig.LevelVersion = VersionTextbox.Text;
trickyConfig.Difficulty = DifficultyTextbox.Text;
trickyConfig.Location = LocationTextbox.Text;
trickyConfig.Vertical = VerticalDropTextbox.Text;
trickyConfig.Length = CourseLengthTextbox.Text;
trickyConfig.Description = DescriptionTextbox.Text;
trickyConfig.BuildUniLightmap = UnlitLightmapCheckbox.Checked;
trickyConfig.BuildPBDGenerate = GenPBD.Checked;
trickyConfig.BuildSSHGenerate = GenSSH.Checked;
trickyConfig.BuildLSSHGenerate = GenLSSH.Checked;
trickyConfig.BuildLTGGenerate = GenLTG.Checked;
trickyConfig.BuildMAPGenerate = GenMAP.Checked;
trickyConfig.BuildSkyPBDGenerate = GenSkyPBD.Checked;
trickyConfig.BuildSkySSHGenerate = GenSkySSH.Checked;
trickyConfig.BuildADLGenerate = GenADL.Checked;
trickyConfig.BuildSSFGenerate = GenSSF.Checked;
trickyConfig.BuildAIPGenerate = GenAIP.Checked;
trickyConfig.BuildSOPGenerate = GenSOP.Checked;
trickyConfig.BuildLTGGenerateMode = LTGMode.SelectedIndex;
trickyConfig.BuildPath = BuildPath;
trickyConfig.CreateJson(ProjectPath + "/ConfigTricky.ssx");
}
private void PatchesTitleLabel_Click(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
}
private void GenLightingCheckbox_CheckedChanged(object sender, EventArgs e)
{
if (GenLightingCheckbox.Checked)
{
UnlitLightmapCheckbox.Enabled = false;
UnlitInstancesCheckbox.Enabled = false;
}
else
{
UnlitLightmapCheckbox.Enabled = true;
UnlitInstancesCheckbox.Enabled = true;
}
}
private void ConsoleLogCheck_CheckedChanged(object sender, EventArgs e)
{
if (ConsoleLogCheck.Checked)
{
ConsoleWindow.GenerateConsole();
}
else
{
ConsoleWindow.CloseConsole();
}
}
private void TrickyProjectWindow_FormClosing(object sender, FormClosingEventArgs e)
{
ConsoleWindow.CloseConsole();
}
}
}