Skip to content

Commit

Permalink
Added partial support to Shin Megami Tensei IV Apocalypse and profile…
Browse files Browse the repository at this point in the history
….mbm sanitation feature
  • Loading branch information
Megaflan committed Sep 17, 2020
1 parent d27ac1f commit 823b43d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
1 change: 1 addition & 0 deletions Moonbeam/MBM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static int[] GetCodeSizes(byte byte0, byte byte1)
case 1: case 2: case 0x12: case 0x16: case 0x17: case 0x18: return new int[0];
case 0x14: case 0x7C: return new[] { 1, 1 };
case 0x13: return new[] { 2, 2 };
case 0x1B: return new[] { 2, 2, 2 };
case 0x7B: return new[] { 1, 1, 1, 1 };
default: return new[] { 1 };
}
Expand Down
47 changes: 39 additions & 8 deletions Moonbeam/Moonbeam.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,65 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Composition.AttributedModel, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.AttributedModel.1.2.0\lib\netstandard2.0\System.Composition.AttributedModel.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Composition.Convention, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Convention.1.2.0\lib\netstandard2.0\System.Composition.Convention.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Composition.Hosting, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Hosting.1.2.0\lib\netstandard2.0\System.Composition.Hosting.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Composition.Runtime, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.Runtime.1.2.0\lib\netstandard2.0\System.Composition.Runtime.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Composition.TypedParts, Version=1.0.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Composition.TypedParts.1.2.0\lib\netstandard2.0\System.Composition.TypedParts.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Core">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Xml.Linq">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.CSharp">
<Private>False</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Data">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Net.Http">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Xml">
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Yarhl, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Yarhl.2.0.0-alpha.2\lib\netstandard2.0\Yarhl.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Yarhl.Media, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Yarhl.Media.2.0.0-alpha.2\lib\netstandard2.0\Yarhl.Media.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
23 changes: 21 additions & 2 deletions Moonbeam/PO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void XML2PO(string file)
POExport(POHeader, source.Replace("{F801}", "\n"), target.Replace("{F801}", "\n"), c);
c++;
}
POWrite(POHeader, file.Replace(".xml", ""));
POWrite(POHeader, Path.GetFileNameWithoutExtension(file));
}

public XElement PO2XML(string file)
Expand All @@ -61,7 +61,26 @@ public void POExport(Po POHeader, string source, string target, int i)

public void POWrite(Po POHeader, string file)
{
POHeader.ConvertTo<BinaryFormat>().Stream.WriteTo(file + ".po");
POHeader.ConvertTo<BinaryFormat>().Stream.WriteTo(Path.GetFileNameWithoutExtension(file) + ".po");
}

public void ProfileMode(string file)
{
Po POBuffer;
using (var binary = new BinaryFormat(file))
{
POBuffer = binary.ConvertTo<Po>();
foreach (var entry in POBuffer.Entries)
{
var lines = entry.Text.Split('\n');
foreach (var line in lines)
{
if (line.Length > 45)
Console.WriteLine(entry.Context + " // " + "Line length exceeded: " + line.Length + " // " + line);
}
}
Console.ReadLine();
}
}

}
Expand Down
5 changes: 4 additions & 1 deletion Moonbeam/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void Main(string[] args)
switch (Path.GetExtension(args[1]).ToLower())
{
case ".xml":
File.WriteAllBytes(args[1] + ".mbm", MBM.FromXElement(XElement.Load(args[1])).ToByteArray());
File.WriteAllBytes(Path.GetFileNameWithoutExtension(args[1]), MBM.FromXElement(XElement.Load(args[1])).ToByteArray());
break;
default:
try
Expand Down Expand Up @@ -71,6 +71,9 @@ from entry in MBM.FromByteArray(File.ReadAllBytes(path))
select new XElement("entry", idattr, entry.Text))));
File.WriteAllText(args[1] + ".xml", root.ToString());
break;
case "-profile":
PO.ProfileMode(args[1]);
break;
case "-xml2po":
switch (Path.GetExtension(args[1]).ToLower())
{
Expand Down

0 comments on commit 823b43d

Please sign in to comment.