Skip to content

Commit

Permalink
Remove old libsquish, update version, licence
Browse files Browse the repository at this point in the history
  • Loading branch information
ghorsington committed Jan 24, 2018
1 parent f994401 commit fadfbda
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 489 deletions.
6 changes: 3 additions & 3 deletions CM3D2.TexTool/AssemblyInfo.cpp
Expand Up @@ -12,11 +12,11 @@ using namespace System::Security::Permissions;
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute(L"CM3D2TexTool")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyDescriptionAttribute(L"A TEX2PNG converter for CM3D2/COM3D2.")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"")];
[assembly:AssemblyProductAttribute(L"CM3D2TexTool")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2018")];
[assembly:AssemblyCopyrightAttribute(L"Copyright Geoffrey Horsingtin 2018")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];

Expand All @@ -31,7 +31,7 @@ using namespace System::Security::Permissions;
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:AssemblyVersionAttribute("2.0.0.0")];

[assembly:ComVisible(false)];

Expand Down
3 changes: 0 additions & 3 deletions CM3D2.TexTool/CM3D2.TexTool.vcxproj
Expand Up @@ -166,9 +166,6 @@
<Project>{6a8518c3-d81a-4428-bd7f-c37933088ac1}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Text Include="help.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
3 changes: 0 additions & 3 deletions CM3D2.TexTool/CM3D2.TexTool.vcxproj.filters
Expand Up @@ -52,7 +52,4 @@
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Text Include="help.txt" />
</ItemGroup>
</Project>
160 changes: 81 additions & 79 deletions CM3D2.TexTool/Program.cpp
Expand Up @@ -11,92 +11,94 @@ using namespace System::Windows::Forms;

namespace TexTool
{
public ref class Program
{
public:
static String^ VersionNumber = Assembly::GetExecutingAssembly()->GetName()->Version->ToString();
static String^ ProcessName = System::Diagnostics::Process::GetCurrentProcess()->ProcessName;

void PrintHelp()
{
MessageBox::Show(String::Format(HELP, VersionNumber, ProcessName), "Info", MessageBoxButtons::OK, MessageBoxIcon::Information);
}

void Process(array<String^>^ paths)
{
for each(String^% path in paths)
{
if (File::Exists(path))
ProcessFile(path);
else if (Directory::Exists(path))
ProcessDirectory(path);
else
Console::WriteLine(String::Format("[WARN] {0} is not a valid file nor directory (does it exist? can it be accessed?)", path));
}
}

void ProcessFile(String^ file)
{
Texture^ tex;
auto fileName = Path::GetFileNameWithoutExtension(file);
auto ext = Path::GetExtension(file)->ToLowerInvariant();

try
{
tex = Texture::Open(file);
}
catch (OutOfMemoryException^)
{
Console::WriteLine(String::Format("Skipping {0}{1}: Not an image (or format not supported)", fileName, ext));
return;
}
catch (Exception^ ex)
{
Console::WriteLine(String::Format("[FAIL] Cannot parse {0}{1}: {2}", fileName, ext, ex->Message));
return;
}

auto newExt = gcnew String(ext == Texture::TEX_EXTENSION ? ".png" : ".tex");
auto newName = fileName;
int i = 0;
while (File::Exists(String::Format("{0}{1}", newName, newExt)))
{
i++;
newName = fileName + (i > 0 ? i.ToString() : "");
}

try
{
tex->Save(String::Format("{0}{1}", newName, newExt));
}
catch (Exception^ e)
{
Console::WriteLine(String::Format("[FAIL] Failed to save {0}{1}: {2}", newName, newExt, e->Message));
}
delete tex;
}

void ProcessDirectory(String^ path)
{
for each(String^% file in Directory::EnumerateFiles(path, "*", SearchOption::AllDirectories))
ProcessFile(file);
}
};
public ref class Program
{
public:
static String^ VersionNumber = Assembly::GetExecutingAssembly()->GetName()->Version->ToString();
static String^ ProcessName = System::Diagnostics::Process::GetCurrentProcess()->ProcessName;

void PrintHelp()
{
MessageBox::Show(String::Format(HELP, VersionNumber, ProcessName), "Info", MessageBoxButtons::OK, MessageBoxIcon::Information);
}

void Process(array<String^>^ paths)
{
for each(String^% path in paths)
{
if (File::Exists(path))
ProcessFile(path);
else if (Directory::Exists(path))
ProcessDirectory(path);
else
Console::WriteLine(String::Format("[WARN] {0} is not a valid file nor directory (does it exist? can it be accessed?)", path));
}
}

void ProcessFile(String^ file)
{
Texture^ tex;
auto fileName = Path::GetFileNameWithoutExtension(file);
auto ext = Path::GetExtension(file)->ToLowerInvariant();

try
{
tex = Texture::Open(file);
}
catch (OutOfMemoryException^)
{
Console::WriteLine(String::Format("Skipping {0}{1}: Not an image (or format not supported)", fileName, ext));
return;
}
catch (Exception^ ex)
{
Console::WriteLine(String::Format("[FAIL] Cannot parse {0}{1}: {2}", fileName, ext, ex->Message));
return;
}

auto newExt = gcnew String(ext == Texture::TEX_EXTENSION ? ".png" : ".tex");
auto newName = fileName;
int i = 0;

while (File::Exists(String::Format("{0}{1}", newName, newExt)))
{
i++;
newName = fileName + (i > 0 ? i.ToString() : "");
}

try
{
tex->Save(String::Format("{0}{1}", newName, newExt));
}
catch (Exception^ e)
{
Console::WriteLine(String::Format("[FAIL] Failed to save {0}{1}: {2}", newName, newExt, e->Message));
}

delete tex;
}

void ProcessDirectory(String^ path)
{
for each(String^% file in Directory::EnumerateFiles(path, "*", SearchOption::AllDirectories))
ProcessFile(file);
}
};

}

int main(array<System::String ^> ^args)
{
Program^ prog = gcnew Program();
Program^ prog = gcnew Program();

if (args->Length == 0)
{
prog->PrintHelp();
return 0;
}
if (args->Length == 0)
{
prog->PrintHelp();
return 0;
}

prog->Process(args);
return 0;
prog->Process(args);
return 0;
}


Expand Down

0 comments on commit fadfbda

Please sign in to comment.