1
0
forked from 0ad/0ad

Texture converter executable (plus some others to launch it with specific settings)

This was SVN commit r1854.
This commit is contained in:
Ykkrosh 2005-01-28 22:16:50 +00:00
parent 4c6713b582
commit 10e1ce7511
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,42 @@
#include <windows.h>
const char* ExeName = "textureconv.exe";
const char* ExtraParams = "REPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEME";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow)
{
static char Path[MAX_PATH];
static char Prog[MAX_PATH];
char *Srch;
LPSTR NewCmdLine;
if (pCmdLine)
{
NewCmdLine = malloc(strlen(pCmdLine) + strlen(ExtraParams) + 2);
if (!NewCmdLine)
return 3;
strcpy(NewCmdLine, ExtraParams);
strcat(NewCmdLine, " ");
strcat(NewCmdLine, pCmdLine);
}
else
{
NewCmdLine = (char*)ExtraParams;
}
if (!GetModuleFileName(hInstance, Path, sizeof(Path)))
return 1;
Srch = strrchr(Path, '\\');
if (!Srch)
return 2;
Srch[0] = '\0';
strcpy(Prog, Path);
strcat(Prog, "\\");
strcat(Prog, ExeName);
ShellExecute(NULL, "open", Prog, NewCmdLine, Path, SW_SHOWNORMAL);
return 0;
}

View File

@ -0,0 +1,33 @@
# Used to make variations of the launcher exe, which is necessary because drag-and-drop
# onto .bat files appears to not run in the right directory (and so there's no way of it
# finding the actual textureconv.exe)
#
# It just compiles launch.c, then replaces the REPLACEME string with other strings
use strict;
use warnings;
my %settings = (
TexConv_Normal => "",
TexConv_WithAlpha => "-alphablock",
TexConv_WithoutAlpha => "-noalphablock",
TexConv_ToTGA => "-tga",
);
system("cl /Od launch.c shell32.lib");
die $? if $?;
open A, 'launch.exe' or die $!;
binmode A;
my $d = do { local $/; <A> };
my $str = "REPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEME";
for my $k (keys %settings) {
die if length $settings{$k} > length $str;
my $d2 = $d;
$d2 =~ s/$str/ $settings{$k} . ("\0" x (length($str) - length($settings{$k}))) /e or die;
open O, '>', "$k.exe" or die $!;
binmode O;
print O $d2;
}