forked from atenfyr/UAssetGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
68 lines (62 loc) · 2.42 KB
/
Program.cs
File metadata and controls
68 lines (62 loc) · 2.42 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
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using UAssetAPI;
using UAssetAPI.UnrealTypes;
namespace UAssetGUI
{
static class Program
{
[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string[] args = Environment.GetCommandLineArgs();
if (args.Length >= 2)
{
switch (args[1].ToLowerInvariant())
{
// tojson <source> <destination> <engine version>
// UAssetGUI tojson A.umap B.json 514
case "tojson":
if (args.Length < 5) break;
UE4Version selectedVer = UE4Version.UNKNOWN;
if (!Enum.TryParse(args[4], out selectedVer))
{
if (int.TryParse(args[4], out int selectedVerRaw)) selectedVer = (UE4Version)selectedVerRaw;
}
string jsonSerializedAsset = new UAsset(args[2], selectedVer).SerializeJson(Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(args[3], jsonSerializedAsset);
return;
// fromjson <source> <destination>
// UAssetGUI fromjson B.json A.umap
case "fromjson":
if (args.Length < 4) break;
UAsset jsonDeserializedAsset = null;
using (var sr = new FileStream(args[2], FileMode.Open))
{
jsonDeserializedAsset = UAsset.DeserializeJson(sr);
}
if (jsonDeserializedAsset != null)
{
jsonDeserializedAsset.Write(args[3]);
}
return;
}
}
Form1 f1 = new Form1
{
Size = new System.Drawing.Size(1000, 700)
};
Application.Run(f1);
}
}
}