Skip to content

Commit 7ddb70e

Browse files
author
HyperPolygon64
committed
Actually fucking fixed the PKG API
modified: Sonic-06-Mod-Manager/Properties/AssemblyInfo.cs modified: Sonic-06-Mod-Manager/src/UnifyPatcher.cs modified: Sonic-06-Mod-Manager/src/UnifyProgram.cs
1 parent 8bfba1b commit 7ddb70e

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

Sonic-06-Mod-Manager/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
[assembly: ComVisible(false)]
1313
[assembly: Guid("277111e3-79d8-41b5-b0d7-7609dff6e36f")]
1414
[assembly: AssemblyVersion("2.0.0.6")]
15-
[assembly: AssemblyFileVersion("3.2.8.0")]
15+
[assembly: AssemblyFileVersion("3.2.9.0")]

Sonic-06-Mod-Manager/src/UnifyPatcher.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -925,14 +925,17 @@ private static void ParameterEdit(string location, string parameter, string valu
925925
int lineCount = 0;
926926

927927
value = value.Replace("\\\"", "\"");
928-
foreach (string line in script) {
929-
if (line.StartsWith(parameter)) {
928+
foreach (string line in script)
929+
{
930+
if (line.StartsWith(parameter))
931+
{
930932
string[] split = line.Split(' ');
931933
split[2] = value;
932934
for (int i = 3; i < split.Count(); i++) split[i] = string.Empty;
933935
script[lineCount] = string.Join(" ", split);
934936
break;
935937
}
938+
936939
lineCount++;
937940
}
938941

@@ -971,13 +974,16 @@ private static void ParameterRename(string location, string parameter, string _n
971974
string[] script = File.ReadAllLines(location);
972975
int lineCount = 0;
973976

974-
foreach (string line in script) {
975-
if (line.StartsWith(parameter)) {
977+
foreach (string line in script)
978+
{
979+
if (line.StartsWith(parameter))
980+
{
976981
string[] split = line.Split(' ');
977982
split[0] = _new;
978983
script[lineCount] = string.Join(" ", split);
979984
break;
980985
}
986+
981987
lineCount++;
982988
}
983989

@@ -1001,6 +1007,7 @@ private static void TextAdd(string location, string name, string placeholder, st
10011007
Text = text,
10021008
Placeholder = placeholder
10031009
};
1010+
10041011
mst.entries.Add(entry);
10051012

10061013
mst.Save(location, true);
@@ -1019,21 +1026,25 @@ private static void TextEdit(string location, string name, string placeholder, s
10191026
mst.Load(location);
10201027

10211028
bool entryFound = false;
1022-
for (int i = 0; i < mst.entries.Count; i++) {
1023-
if (mst.entries[i].Name == name) {
1029+
for (int i = 0; i < mst.entries.Count; i++)
1030+
{
1031+
if (mst.entries[i].Name == name)
1032+
{
10241033
entryFound = true;
10251034
mst.entries[i].Text = text;
10261035
mst.entries[i].Placeholder = placeholder;
10271036
}
10281037
}
10291038

10301039
// If the entry doesn't exist, create a new one
1031-
if (!entryFound) {
1040+
if (!entryFound)
1041+
{
10321042
MSTEntries newEntry = new MSTEntries {
10331043
Name = name,
10341044
Text = text,
10351045
Placeholder = placeholder
10361046
};
1047+
10371048
mst.entries.Add(newEntry);
10381049
}
10391050

@@ -1068,12 +1079,15 @@ private static void PackageAdd(string location, string _type, string friendlyNam
10681079
S06Package pkg = new S06Package();
10691080
pkg.Load(location);
10701081

1071-
foreach (var type in pkg.Types) {
1072-
if (type.TypeName == _type) {
1082+
foreach (var type in pkg.Types)
1083+
{
1084+
if (type.TypeName == _type)
1085+
{
10731086
S06FileEntry file = new S06FileEntry {
10741087
FilePath = filePath,
10751088
FriendlyName = friendlyName
10761089
};
1090+
10771091
type.Files.Add(file);
10781092
}
10791093
}
@@ -1094,11 +1108,13 @@ private static void PackageEdit(string location, string _type, string friendlyNa
10941108
pkg.Load(location);
10951109

10961110
foreach (var type in pkg.Types)
1111+
{
10971112
if (type.TypeName == _type)
10981113
{
10991114
bool friendlyNameFound = false;
11001115

11011116
for (int i = 0; i < type.Files.Count; i++)
1117+
{
11021118
if (!string.IsNullOrEmpty(filePath))
11031119
{
11041120
// Replace file path if the friendly name exists
@@ -1109,17 +1125,28 @@ private static void PackageEdit(string location, string _type, string friendlyNa
11091125
}
11101126
}
11111127
else
1112-
type.Files.RemoveAt(i);
1128+
{
1129+
// Replace file path if the friendly name exists
1130+
if (type.Files[i].FriendlyName == friendlyName)
1131+
{
1132+
friendlyNameFound = true;
1133+
type.Files.RemoveAt(i);
1134+
}
1135+
}
1136+
}
11131137

11141138
// If the friendly name doesn't exist, create a new reference
1115-
if (!friendlyNameFound) {
1139+
if (!friendlyNameFound)
1140+
{
11161141
S06FileEntry newFile = new S06FileEntry {
11171142
FilePath = filePath,
11181143
FriendlyName = friendlyName
11191144
};
1145+
11201146
type.Files.Add(newFile);
11211147
}
11221148
}
1149+
}
11231150

11241151
pkg.Save(location, true);
11251152
}
@@ -1153,7 +1180,9 @@ public static void DecompileLua(string _file)
11531180
string[] readText = File.ReadAllLines(_file); //Read the Lub into an array
11541181

11551182
if (readText[0].Contains("LuaP"))
1156-
using (Process process = new Process()) {
1183+
{
1184+
using (Process process = new Process())
1185+
{
11571186
process.StartInfo.FileName = "java.exe";
11581187
process.StartInfo.Arguments = $"-jar \"{Program.unlub}\" \"{_file}\"";
11591188
process.StartInfo.UseShellExecute = false;
@@ -1169,6 +1198,7 @@ public static void DecompileLua(string _file)
11691198

11701199
File.WriteAllText(_file, outputBuilder.ToString());
11711200
}
1201+
}
11721202
}
11731203
}
11741204

Sonic-06-Mod-Manager/src/UnifyProgram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Unify.Environment3
3838
{
3939
static class Program
4040
{
41-
public static readonly string GlobalVersionNumber = $"Version 3.28";
41+
public static readonly string GlobalVersionNumber = $"Version 3.29";
4242

4343
#if !DEBUG
4444
public static readonly string VersionNumber = GlobalVersionNumber;

0 commit comments

Comments
 (0)