diff --git a/source/tools/textureconv/launch/launch.c b/source/tools/textureconv/launch/launch.c new file mode 100644 index 0000000000..f34add985e --- /dev/null +++ b/source/tools/textureconv/launch/launch.c @@ -0,0 +1,42 @@ +#include + +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; +} \ No newline at end of file diff --git a/source/tools/textureconv/launch/makeexe.pl b/source/tools/textureconv/launch/makeexe.pl new file mode 100644 index 0000000000..27060a3b5d --- /dev/null +++ b/source/tools/textureconv/launch/makeexe.pl @@ -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 $/; }; + +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; +} \ No newline at end of file