Skip to content

Commit

Permalink
feat: added verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Notexe committed Feb 8, 2024
1 parent 9c81f71 commit 4c87436
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
3 changes: 3 additions & 0 deletions G2GFxDataTool/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class Options
[Option('s', "save-paths", SetName = "export", Required = false, HelpText = "Saves Scaleform GFx and UIControl paths to scaleformgfx.txt and uicontrol.txt text files in the output directory.")]
public bool savePaths { get; set; }

[Option('v', "verbose", SetName = "export", Required = false, HelpText = "Sets output to verbose messages mode.")]
public bool verbose { get; set; }

[Option('l', "licenses", SetName = "licenses", Required = false, HelpText = "Prints license information for G2GFxDataTool and third party libraries that are used.")]
public bool licenses { get; set; }
}
Expand Down
8 changes: 4 additions & 4 deletions G2GFxDataTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ static void Main(string[] args)
string ext = Path.GetExtension(file);
if (ext == ".swf")
{
ScaleformGFxWriter.WriteScaleformGfX(file, options.outputPath);
UIControlWriter.WriteUIControl(file, options.outputPath);
ScaleformGFxWriter.WriteScaleformGfX(file, options.outputPath, options.verbose);
UIControlWriter.WriteUIControl(file, options.outputPath, options.verbose);
}
}
}
Expand All @@ -43,8 +43,8 @@ static void Main(string[] args)
string ext = Path.GetExtension(options.inputPath);
if (ext == ".swf")
{
ScaleformGFxWriter.WriteScaleformGfX(options.inputPath, options.outputPath);
UIControlWriter.WriteUIControl(options.inputPath, options.outputPath);
ScaleformGFxWriter.WriteScaleformGfX(options.inputPath, options.outputPath, options.verbose);
UIControlWriter.WriteUIControl(options.inputPath, options.outputPath, options.verbose);
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions G2GFxDataTool/ScaleformGFxWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace G2GFxDataTool
{
internal class ScaleformGFxWriter
{
internal static void WriteScaleformGfX(string inputPath, string outputPath)
internal static void WriteScaleformGfX(string inputPath, string outputPath, bool verbose)
{
string gfxexport = "gfxexport.exe";
string gfxFileName = Path.GetFileNameWithoutExtension(inputPath);
Expand All @@ -16,14 +16,18 @@ internal static void WriteScaleformGfX(string inputPath, string outputPath)
FileName = gfxexport,
Arguments = $"\"{inputPath}\" -d {tempFolderPath} -list -lwr -i DDS",
CreateNoWindow = true,
RedirectStandardOutput = false,
RedirectStandardOutput = true,
UseShellExecute = false
};

try
{
using (Process process = Process.Start(startInfo))
{
if (verbose)
{
Console.WriteLine(process.StandardOutput.ReadToEnd());
}
process.WaitForExit();
}
}
Expand Down Expand Up @@ -72,11 +76,21 @@ internal static void WriteScaleformGfX(string inputPath, string outputPath)

Program.logScaleformGFxPaths.Add(assemblyPathHash + ".GFXF," + assemblyPath);

if (verbose)
{
Console.WriteLine("Saving GFXF file as '" + Path.Combine(outputPath, assemblyPathHash + ".GFXF'"));
}

File.WriteAllBytes(Path.Combine(outputPath, assemblyPathHash + ".GFXF"), s_ResourceMem);

// Cleanup temp files
try
{
if (verbose)
{
Console.WriteLine("\r\nCleaning up temporary files:\r\n" + gfxFile + "\r\n" + Path.Combine(tempFolderPath, gfxFileName + ".lst"));
}

File.Delete(gfxFile);

File.Delete(Path.Combine(tempFolderPath, gfxFileName + ".lst"));
Expand All @@ -86,6 +100,10 @@ internal static void WriteScaleformGfX(string inputPath, string outputPath)
string texturePath = Path.Combine(tempFolderPath, textureFileName);
if (File.Exists(texturePath))
{
if (verbose)
{
Console.WriteLine(texturePath);
}
File.Delete(texturePath);
}
}
Expand Down
28 changes: 27 additions & 1 deletion G2GFxDataTool/UIControlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ internal class Property
public int m_nPropertyId { get; set; } = 0;
}

internal static void WriteUIControl(string inputPath, string outputPath)
internal static void WriteUIControl(string inputPath, string outputPath, bool verbose)
{
var definitions = ParseSWF.ParseAS(inputPath);

foreach (var definition in definitions)
{
UICBData data = new UICBData();

if (verbose)
{
Console.WriteLine("\r\nFound class: " + definition.className + ":");
}

foreach (var method in definition.classMethods)
{

Expand All @@ -76,6 +81,11 @@ internal static void WriteUIControl(string inputPath, string outputPath)
pins.m_eType = typeMapping.GetValueOrDefault(method.argumentTypes[0]);
}

if (verbose)
{
Console.WriteLine("\tFound pin: " + pins.m_sName + " type: " + pins.m_eType + " kind: " + pins.m_eKind);
}

data.m_aPins.Add(pins);
}

Expand All @@ -90,6 +100,11 @@ internal static void WriteUIControl(string inputPath, string outputPath)
m_nPropertyId = 0
};

if (verbose)
{
Console.WriteLine("\tFound property: " + property.classPropertyName + " type: " + property.classPropertyType);
}

data.m_aProperties.Add(properties);
}

Expand Down Expand Up @@ -145,7 +160,18 @@ internal static void WriteUIControl(string inputPath, string outputPath)

string jsonData = JsonSerializer.Serialize(data);

if (verbose)
{
Console.WriteLine("Saving UICT file as '" + Path.Combine(outputPath, uictAssemblyPathHash + ".UICT"));
}

File.Create(Path.Combine(outputPath, uictAssemblyPathHash + ".UICT"));

if (verbose)
{
Console.WriteLine("Saving UICB file as '" + Path.Combine(outputPath, uicbAssemblyPathHash + ".UICB.json"));
}

File.WriteAllText(Path.Combine(outputPath, uicbAssemblyPathHash + ".UICB.json"), jsonData);
}
}
Expand Down

0 comments on commit 4c87436

Please sign in to comment.