Skip to content

Commit

Permalink
v0.4.4 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Aug 30, 2018
1 parent ff74dfd commit 2236046
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 122 deletions.
6 changes: 3 additions & 3 deletions HipHopFile/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ private static HipSection[] GetFilesData(string INIFile, ref Section_HIPA HIPA,
{
assetDataDictionary.Add(Convert.ToUInt32(Path.GetFileName(i).Substring(1, 8), 16), file);
}
catch
catch (Exception e)
{
SendMessage("Error: asset " + Path.GetFileName(i) + " already imported. Skipping.");
SendMessage("Error importing asset " + Path.GetFileName(i) + ": " + e.Message);
}
}

Expand Down Expand Up @@ -410,7 +410,7 @@ public static HipSection[] SetupStream(ref Section_HIPA HIPA, ref Section_PACK P
{
if (!assetDataDictionary.Keys.Contains(AHDR.assetID))
{
SendMessage("Error: asset id [" + AHDR.assetID.ToString("X8") + "] not present. File will be unusable.");
SendMessage($"Error: asset with ID [{AHDR.assetID.ToString("X8")}] was not found. The archive will not be saved correctly and will be unusable.");
continue;
}
AHDR.containedFile = assetDataDictionary[AHDR.assetID];
Expand Down
1 change: 1 addition & 0 deletions HipHopTool/HipHopTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Option.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions HipHopTool/Option.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HipHopTool
{
public enum Option
{
ExtractHIP = 0,
CreateHIP = 1,
Close = 2,
None = 3
}
}
222 changes: 109 additions & 113 deletions HipHopTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,154 +7,150 @@ namespace HipHopTool
{
class Program
{
public enum Option
{
ExtractHIP = 0,
CreateHIP = 1,
Close = 2,
None = 3
}

[STAThread]
static void Main(string[] args)
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

SendMessage("HipHopTool v0.4.3 by igorseabra4");
SendMessage("HipHopTool v0.4.4 by igorseabra4");

if (args.Length == 0)
ShowNoArgsMenu();
else if (!PerformArgsSelection(args))
foreach (string s in args)
if (Path.GetExtension(s).ToLower() == ".hip" | Path.GetExtension(s).ToLower() == ".hop")
{
SendMessage("File: " + s);
SendMessage("Destination: " + s + ".d");
HipArrayToIni(HipFileToHipArray(s), s + ".d", true);
SendMessage("Success");
}
}

private static bool PerformArgsSelection(string[] args)
{
Option option = Option.None;

if (args.Length == 0)
string hipToUnpack = "null";
string outputPath = "null";
string iniToCreate = "null";
bool multiFolder = true;

for (int i = 0; i < args.Length; i++)
{
while (option != Option.Close)
if (args[i].ToLower() == "-extract" | args[i].ToLower() == "-e" | args[i].ToLower() == "-unpack" | args[i].ToLower() == "-u")
{
SendMessage();
SendMessage("What do you wanna do?");
SendMessage("Type 0 to extract a HIP/HOP file.");
SendMessage("Type 1 to create a HIP/HOP file.");
SendMessage("Type 2 to close.");

try
hipToUnpack = args[i + 1];
option = Option.ExtractHIP;
}
else if (args[i].ToLower() == "-dest" | args[i].ToLower() == "-d")
{
outputPath = args[i + 1];
}
else if (args[i].ToLower() == "-mode" | args[i].ToLower() == "-m")
{
if (args[i + 1].ToLower().Contains("single"))
{
option = (Option)Convert.ToInt32(Console.ReadLine());
multiFolder = false;
}
catch
else if (args[i + 1].ToLower().Contains("multi"))
{
option = Option.None;
multiFolder = true;
}
}
else if (args[i].ToLower() == "-create" | args[i].ToLower() == "-c")
{
iniToCreate = args[i + 1];
option = Option.CreateHIP;
}
}

if (option == Option.ExtractHIP)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Title = "Select a file to unpack",
Filter = "HIP/HOP files|*.hip;*.hop"
};
if (option == Option.ExtractHIP)
{
SendMessage("File: " + hipToUnpack);

if (openFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
SendMessage("File: " + openFileDialog.FileName);
HipArrayToIni(HipFileToHipArray(openFileDialog.FileName), openFileDialog.FileName + ".d", true);
}
}
else if (option == Option.CreateHIP)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Title = "Select an INI file",
Filter = "INI files|*.ini"
};
if (openFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
SaveFileDialog saveFileDialog = new SaveFileDialog()
{
Title = "Save as...",
Filter = "HIP/HOP files|*.hip;*.hop"
};
if (saveFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
File.WriteAllBytes(saveFileDialog.FileName, HipArrayToFile(IniToHipArray(openFileDialog.FileName)));
}
}
}
}
if (outputPath == "null")
outputPath = hipToUnpack + ".d";

SendMessage("Destination: " + outputPath);

HipArrayToIni(HipFileToHipArray(hipToUnpack), outputPath, multiFolder);

SendMessage("Success");
}
else
else if (option == Option.CreateHIP)
{
string hipToUnpack = "null";
string outputExtractPath = "null";
string iniToCreate = "null";
bool multiFolder = true;
SendMessage("File: " + iniToCreate);

for (int i = 0; i < args.Length; i++)
{
if (args[i].ToLower() == "-extract" | args[i].ToLower() == "-e" | args[i].ToLower() == "-unpack" | args[i].ToLower() == "-u")
{
hipToUnpack = args[i + 1];
option = Option.ExtractHIP;
}
else if (args[i].ToLower() == "-dest" | args[i].ToLower() == "-d")
{
outputExtractPath = args[i + 1];
}
else if (args[i].ToLower() == "-mode" | args[i].ToLower() == "-m")
{
if (args[i + 1].ToLower().Contains("single"))
{
multiFolder = false;
}
else if (args[i + 1].ToLower().Contains("multi"))
{
multiFolder = true;
}
}
else if (args[i].ToLower() == "-create" | args[i].ToLower() == "-c")
{
iniToCreate = args[i + 1];
option = Option.CreateHIP;
}
}
if (outputPath == "null")
outputPath = Path.ChangeExtension(iniToCreate, ".HIP");

if (option == Option.ExtractHIP)
{
SendMessage("File: " + hipToUnpack);
SendMessage("Destination: " + outputPath);

if (outputExtractPath == "null")
outputExtractPath = hipToUnpack + ".d";
File.WriteAllBytes(outputPath, HipArrayToFile(IniToHipArray(iniToCreate)));

SendMessage("Destination: " + outputExtractPath);
SendMessage("Success");
}

HipArrayToIni(HipFileToHipArray(hipToUnpack), outputExtractPath, multiFolder);
return option != Option.None;
}

SendMessage("Success");
}
else if (option == Option.CreateHIP)
{
SendMessage("File: " + iniToCreate);
private static void ShowNoArgsMenu()
{
Option option = Option.None;

if (outputExtractPath == "null")
outputExtractPath = Path.ChangeExtension(iniToCreate, ".HIP");
while (option != Option.Close)
{
SendMessage();
SendMessage("What do you wanna do?");
SendMessage("Type 0 to extract a HIP/HOP file.");
SendMessage("Type 1 to create a HIP/HOP file.");
SendMessage("Type 2 to close.");

SendMessage("Destination: " + outputExtractPath);
try
{
option = (Option)Convert.ToInt32(Console.ReadLine());
}
catch
{
option = Option.None;
}

File.WriteAllBytes(outputExtractPath, HipArrayToFile(IniToHipArray(iniToCreate)));
if (option == Option.ExtractHIP)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Title = "Select a file to unpack",
Filter = "HIP/HOP files|*.hip;*.hop"
};

SendMessage("Success");
if (openFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
SendMessage("File: " + openFileDialog.FileName);
HipArrayToIni(HipFileToHipArray(openFileDialog.FileName), openFileDialog.FileName + ".d", true);
}
}
else if (option == Option.None)
else if (option == Option.CreateHIP)
{
foreach (string s in args)
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Title = "Select an INI file",
Filter = "INI files|*.ini"
};
if (openFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
if (Path.GetExtension(s).ToLower() == ".hip" | Path.GetExtension(s).ToLower() == ".hop")
SaveFileDialog saveFileDialog = new SaveFileDialog()
{
SendMessage("File: " + s);
SendMessage("Destination: " + s + ".d");
HipArrayToIni(HipFileToHipArray(s), s + ".d", true);
SendMessage("Success");
Title = "Save as...",
Filter = "HIP/HOP files|*.hip;*.hop"
};
if (saveFileDialog.ShowDialog(new Form() { TopMost = true, TopLevel = true }) == DialogResult.OK)
{
File.WriteAllBytes(saveFileDialog.FileName, HipArrayToFile(IniToHipArray(openFileDialog.FileName)));
}
}
}
}
}
}
}
}
12 changes: 6 additions & 6 deletions HipHopTool/readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= HipHopTool v0.4.2 by igorseabra4 =
= HipHopTool v0.4.4 by igorseabra4 =
Tool to extract and create HIP/HOP archive files used in games by Heavy Iron Studios.

Currently supported games:
Expand All @@ -7,7 +7,7 @@ Currently supported games:
- The Incredibles Game (GCN)
- The Spongebob Squarepants Movie Game (GCN, XBOX)
- The Incredibles: Rise of the Underminer
- Other platform versions of the above games might also be supported, however I have not tested them.
- Other platform versions of the above games are probably also supported, however I have not tested them.

= File Description =
HIP archives (internally, they are all HIPs, HOP is just a filename thing) are used by the games above to put together all assets used in a scene ingame. They are divided into multiple layers, and each layer contains multiple (sometimes thousands of) assets. Every texture, model, object, sound, pickup object etc is an asset.
Expand Down Expand Up @@ -36,16 +36,16 @@ will extract the EXAMPLE.HOP file to a default folder and all assets to one fold
== Creating ==
HipHopTool.exe -create EXAMPLE_OUT\Settings.ini -dest OUT.HIP

will create a new archive called OUT.HIP from an INI file called Settings.ini located in the EXAMPLE_OUT folder. You can also use -c for the same effect of -create. Ommiting -dest will save the HIP to the same folder as Settings.ini(extension defaults to .HIP).
will create a new archive called OUT.HIP from an INI file called Settings.ini located in the EXAMPLE_OUT folder. You can also use -c for the same effect of -create. Ommiting -dest will save the HIP to the same folder as Settings.ini (extension defaults to .HIP).

Note that you can use full paths and not just filenames for -extract, -create and -dest. If the path includes spaces, make sure to enclose it in quotes.


== INI Format ==
HipHopTool generates a Settings.ini file when extracting an archive, which is used to rebuild it later. You can edit this file in a text editor.

If you want to add a new asset, add it to the list in the layer you want it to be. Give it a unique asset ID and make sure the asset is also present in a folder with that same ID. Which folder you put it in doesn't matter, the file name doesn't matter either; as long as the asset ID which is the hexadecimal number at the start of the filename is the same, the program will find the asset and include it. The order doesn't matter. The asset ID is the hexadecimal number at the start of the asset entry (don't bother with the one at the end, that's a checksum which actually goes unused).
If you want to add a new asset, add it to the list in the layer you want it to be. Give it a unique asset ID and make sure the asset is also present in a folder with that same ID. Which folder you put it in doesn't matter, the file name doesn't matter either; as long as the asset ID which is the hexadecimal number at the start of the filename is the same, the program will find the asset and include it. The order doesn't matter either, as HipHopTool will sort the assets automatically when building the file. The asset ID in the INI is the hexadecimal number at the start of the asset entry (don't bother with the one at the end, that's a checksum which actually goes unused).

If an asset ID is referenced in the INI but there's no file for it, the program will show an error; if there are multiple files with the same asset ID, the program will show an error.
If an asset ID is referenced in the INI but there's no file for it, the program will show an error, and the resulting file will be unusable as it'll have an asset with no data. If there are multiple files with the same asset ID, the program will show an error, and the first one found will be used.

You can remove assets simply by removing the line from the INI, there's no need to delete the asset file as it will be ignored. Adding a # before the line will comment it and it will also be ignored.
You can remove assets simply by removing the line from the INI (or commenting it with a # at the beginning), there's no need to delete the asset file as it will be ignored.

0 comments on commit 2236046

Please sign in to comment.