-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
120 lines (99 loc) · 3.07 KB
/
Program.cs
File metadata and controls
120 lines (99 loc) · 3.07 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
using System;
using System.IO;
using System.Text.RegularExpressions;
namespace BoneAxisModifier
{
class Program
{
static readonly Regex BaseDataRegex = new(@"(Scale|Position|Rotate)([XYZ])");
static void Main(string[] args)
{
if (args.Length != 4)
{
Console.WriteLine("Usage: BoneAxisModifier.exe <file> <animName> <animTarget> <additionTransform>");
Console.ReadLine();
return;
}
string file = args[0];
if (!File.Exists(file))
{
Console.WriteLine($"'{file}' does not exist!");
Console.ReadLine();
return;
}
if (!file.EndsWith(".json"))
{
Console.WriteLine("Warning supplied file is not a JSON file! Stuff may break!\n\n Press any key to continue..");
Console.ReadLine();
}
string baseDataKey = args[2];
if (!BaseDataRegex.IsMatch(args[2]))
{
Console.WriteLine($"Invalid target: {args[2]}");
Console.ReadLine();
return;
}
int baseDataIndex = 1;
MatchCollection matches = BaseDataRegex.Matches(args[2]);
foreach (Match v in matches)
{
if (v.Groups.Count > 1)
{
baseDataKey = v.Groups[1].Value;
if (baseDataKey == "Position") // 1 off inconsistent naming
baseDataKey = "Translate";
switch (v.Groups[2].Value)
{
case "X":
baseDataIndex = 0;
break;
case "Y":
baseDataIndex = 1;
break;
case "Z":
baseDataIndex = 2;
break;
}
}
}
if (!decimal.TryParse(args[3], out decimal transform))
{
Console.WriteLine($"Invalid transform: {args[3]}");
Console.ReadLine();
return;
}
Animation anim = new()
{
SourceFile = new FileInfo(file),
Name = args[1],
Target = args[2],
BaseDataKey = baseDataKey,
BaseDataIndex = baseDataIndex,
Transform = transform
};
anim.Open();
if (!anim.HasName())
{
Console.WriteLine($"Invalid anim name: '{args[1]}'!");
Console.ReadLine();
return;
}
if (!anim.HasTarget())
{
Console.WriteLine($"Invalid target name: '{args[2]}'!\n");
}
try
{
anim.Modify();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
#if DEBUG
Console.WriteLine(e.StackTrace);
#endif
Console.ReadLine();
}
}
}
}