Skip to content

Commit

Permalink
Various changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonHaze420 committed Jan 3, 2019
1 parent 5963e7a commit 7511c79
Showing 1 changed file with 75 additions and 16 deletions.
91 changes: 75 additions & 16 deletions wudecon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using System.Reflection;
using ShenmueDKSharp;
using ShenmueDKSharp.Files;
using ShenmueDKSharp.Files.Models;
using ShenmueDKSharp.Files.Containers;
using ShenmueDKSharp.Utils;
Expand Down Expand Up @@ -43,7 +44,7 @@ static void ExportMT7(string path, string objFilepath)
{
if(bVerbose)
Console.WriteLine("Converting {0} to {1}", file, dest);

ExportMT7(file, dest);
}
catch(Exception e)
Expand All @@ -64,12 +65,18 @@ static void ExportMT7(string path, string objFilepath)
}
else
{
var destFile = Path.GetFileName(objFilepath);
objFilepath += "_\\";

Directory.CreateDirectory(objFilepath);
objFilepath += destFile;

try
{
MT7 mt7 = new MT7(path);
OBJ obj = new OBJ(mt7);

obj.Write(objFilepath);
obj.Write(objFilepath);
}
catch (Exception e)
{
Expand Down Expand Up @@ -127,6 +134,12 @@ static void ExportMT5(string path, string objFilepath)
}
else
{
var destFile = Path.GetFileName(objFilepath);
objFilepath += "_\\";

Directory.CreateDirectory(objFilepath);
objFilepath += destFile;

try
{
MT5 mt5 = new MT5(path);
Expand Down Expand Up @@ -163,11 +176,13 @@ static void ExtractPKF(string path, string folder)
Directory.CreateDirectory(currentChildDir);

string dest = currentChildDir + "\\";

try
{
PKF pkf = new PKF(file);

dest+= "\\_" + Path.GetFileName(file) + "_\\";
Directory.CreateDirectory(dest);

if (bVerbose)
Console.WriteLine("Unpacking {0} to {1}", file, dest);

Expand Down Expand Up @@ -523,7 +538,7 @@ static void ExtractTAC(string tadFilepath, string tacFilepath, string folder)
TAD tad = new TAD(tadFilepath);
TAC tac = new TAC(tad);

tac.Unpack(true, false, folder);
tac.Unpack(bVerbose, false, folder);
}
catch (Exception e)
{
Expand Down Expand Up @@ -625,7 +640,7 @@ static void Main(string[] args)
Console.WriteLine("Processing all formats (except TAC):");
else
{
destFolder = args[2] + "TAC";
destFolder = args[2] + "\\TAC";

Console.WriteLine("Processing all formats:");

Expand Down Expand Up @@ -661,42 +676,42 @@ static void Main(string[] args)
Console.WriteLine("Finished processing TAC!");
}

destFolder = args[2] + "PKF";
destFolder = args[2] + "\\PKF";
Console.WriteLine("Processing PKF..");
ExtractAFS(src, destFolder);
ExtractPKF(src, destFolder);
Console.WriteLine("Finished processing PKF!");

destFolder = args[2] + "PKS";
destFolder = args[2] + "\\PKS";
Console.WriteLine("Processing PKS..");
ExtractPKS(src, destFolder);
Console.WriteLine("Finished processing PKS!");

destFolder = args[2] + "SPR";
destFolder = args[2] + "\\SPR";
Console.WriteLine("Processing SPR..");
ExtractSPR(src, destFolder);
Console.WriteLine("Finished processing SPR!");

destFolder = args[2] + "IPAC";
/*destFolder = args[2] + "\\IPAC";
Console.WriteLine("Processing IPAC..");
ExtractIPAC(src, destFolder);
Console.WriteLine("Finished processing IPAC!");
destFolder = args[2] + "GZ";
destFolder = args[2] + "\\GZ";
Console.WriteLine("Processing GZ..");
ExtractGZ(src, destFolder);
Console.WriteLine("Finished processing GZ!");
destFolder = args[2] + "AFS";
destFolder = args[2] + "\\AFS";
Console.WriteLine("Processing AFS..");
ExtractAFS(src, destFolder);
Console.WriteLine("Finished processing AFS!");
destFolder = args[2] + "MT5";
destFolder = args[2] + "\\MT5";
Console.WriteLine("Processing MT5..");
ExportMT5(src, destFolder);
Console.WriteLine("Finished Processing MT5!");
Console.WriteLine("Finished Processing MT5!");*/

destFolder = args[2] + "MT7";
destFolder = args[2] + "\\MT7";
Console.WriteLine("Processing MT7..");
ExportMT7(src, destFolder);
Console.WriteLine("Finished processing MT7!");
Expand All @@ -705,8 +720,52 @@ static void Main(string[] args)

Console.WriteLine("Operations completed in {0} minutes ({1}ms)", timeStart.ElapsedMilliseconds/60000, timeStart.ElapsedMilliseconds);
}
else if((args[0].Contains("--process")))
{
var texDir = args[1];
src = args[2];
destFolder = args[2];

Console.WriteLine("Initializing TextureDatabase..");
TextureDatabase.SearchDirectory(texDir);

Console.WriteLine("Converting models..");
ExportMT7(src, destFolder);

Console.WriteLine("Finished!");

/*Console.WriteLine("Processing all TAD's");
var ext = new List<string> { ".tac", ".TAC" };
var tacFiles = Directory.GetFiles(src, "*.*", SearchOption.AllDirectories).Where(s => ext.Contains(Path.GetExtension(s)));
ext = new List<string> { ".tad", ".TAD" };
var tadFiles = Directory.GetFiles(src, "*.*", SearchOption.AllDirectories).Where(s => ext.Contains(Path.GetExtension(s)));
foreach (string tacFile in tacFiles)
{
foreach (string tadFile in tadFiles)
{
if (Path.GetFileNameWithoutExtension(tacFile).Equals(Path.GetFileNameWithoutExtension(tadFile)))
{
try
{
ExtractTAC(tadFile, tacFile, destFolder);
}
catch (Exception e)
{
Console.WriteLine("Oops! {0} failed!\nException: {1}", tacFile, e.ToString());
++iNumFailedOperations;
}
++iNumOperations;
}
}
}
Console.WriteLine("Finished processing");*/

}

if(iNumOperations > 0 || iNumFailedOperations > 0)
if (iNumOperations > 0 || iNumFailedOperations > 0)
Console.WriteLine("Failed {1}/{0} operations.", iNumOperations, iNumFailedOperations);
}
}
Expand Down

0 comments on commit 7511c79

Please sign in to comment.