Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
vborovin committed May 1, 2022
1 parent 9d375aa commit cfe0c12
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 3 deletions.
50 changes: 49 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand All @@ -23,6 +23,7 @@ mono_crash.*
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
Expand Down Expand Up @@ -61,6 +62,9 @@ project.lock.json
project.fragment.lock.json
artifacts/

# ASP.NET Scaffolding
ScaffoldingReadMe.txt

# StyleCop
StyleCopReport.xml

Expand All @@ -86,6 +90,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
Expand Down Expand Up @@ -137,6 +142,11 @@ _TeamCity*
.axoCover/*
!.axoCover/settings.json

# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info

# Visual Studio code coverage results
*.coverage
*.coveragexml
Expand Down Expand Up @@ -284,6 +294,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -340,6 +361,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand All @@ -348,3 +372,27 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

# JetBrains Rider
*.sln.iml
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# smupc
Space Marine Locale Converter
# Space Marine UPC converter
Tool to decompress and compress UPC (\*.pc) files that contain locale texts.
Resulting file (\*.locale) can be opened in text editor and edited.
Be careful with spaces and tabs in the file, game accepts only original formatting.

## Usage
Tool requires .Net Framework 4.6.1 and DotNetZip.

Available modes:
- -p: default, packs all \*.locale files in current directory and its subdirs back into UPC
- -pb: same as previous, but in big endian
- -p src dest: packs \*.locale file from src back into UPC
- -pb src dest: same as previous, but in big endian
- -u src dest: unpacks UPC file from src to dest
25 changes: 25 additions & 0 deletions Src/smupc/smupc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "smupc", "smupc\smupc.csproj", "{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {867418B4-EB44-4F93-8C4E-532797298B7F}
EndGlobalSection
EndGlobal
104 changes: 104 additions & 0 deletions Src/smupc/smupc/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Ionic.Zlib;

namespace smupc
{
internal class Program
{
public static void Unpack(string source, string dest)
{
FileStream input = File.Open(source, FileMode.Open, FileAccess.Read);
BinaryReader binaryReader = new BinaryReader(input);
byte[] value = binaryReader.ReadBytes(4);
byte[] compressed = binaryReader.ReadBytes((int)(binaryReader.BaseStream.Length - binaryReader.BaseStream.Position));
byte[] array = ZlibStream.UncompressBuffer(compressed);
Debug.Assert(BitConverter.ToInt32(value, 0) == array.Length);
File.WriteAllBytes(dest, array);
}

public static void Pack(string source, string dest, bool bigEndian)
{
byte[] array = File.ReadAllBytes(source);
byte[] collection = ZlibStream.CompressBuffer(array);
byte[] source2 = BitConverter.GetBytes(array.Length);
if (bigEndian)
{
source2 = source2.Reverse().ToArray();
}
List<byte> list = source2.ToList();
list.AddRange(collection);
File.WriteAllBytes(dest, list.ToArray());
}

public static void Pack(bool bigEndian)
{
string searchPattern = "*.locale";
string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "data"), searchPattern, SearchOption.AllDirectories);
string[] array = files;
string[] array2 = array;
foreach (string text in array2)
{
string extension = Path.GetExtension(text);
string str = Path.Combine(Path.GetDirectoryName(text), Path.GetFileNameWithoutExtension(text));
if (extension == ".locale")
{
Pack(text, str + ".pc", bigEndian);
}
}
}

private static void Main(string[] args)
{
string text = "-p";
if (args.Length >= 1)
{
text = args[0];
}
string text2 = null;
string text3 = null;
if (args.Length == 3)
{
text2 = args[1];
text3 = args[2];
}
int num;
switch (text)
{
case "-pb":
if (text2 != null && text3 != null)
{
Pack(text2, text3, bigEndian: true);
}
else
{
Pack(bigEndian: true);
}
return;
case "-p":
if (text2 != null && text3 != null)
{
Pack(text2, text3, bigEndian: false);
}
else
{
Pack(bigEndian: false);
}
return;
case "-u":
num = ((args.Length == 3) ? 1 : 0);
break;
default:
num = 0;
break;
}
if (num != 0)
{
Unpack(text2, text3);
}
}
}
}
20 changes: 20 additions & 0 deletions Src/smupc/smupc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("smupc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("smupc")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3fa4bd77-2b19-4fff-b286-1367bc15f220")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
16 changes: 16 additions & 0 deletions Src/smupc/smupc/smupc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>smupc</AssemblyName>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<LangVersion>Preview</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0" />
</ItemGroup>
</Project>

0 comments on commit cfe0c12

Please sign in to comment.