From ba41083e297d5ee07357cd720693a1a95e826c82 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Wed, 21 Nov 2007 10:21:07 +0100 Subject: [PATCH] Win32 dialog box, icon and installer Added a Win32-API dialog box that will let the user select if she wants to run tennix in fullscreen or not. Add a resource file for the dialog box layout and the Win32-specific icon (our executable now has an icon!). New .iss installer script (InnoSetup) that will compile a standalone exe installer from the tennix binaries. README.win32: Docs for Git, resource editing and Inno Setup --- README.win32 | 40 +++++++++++++++++++++++ data/icon.ico | Bin 0 -> 4286 bytes data/makefile | 2 +- makefile | 19 ++++++++++- tennix-installer.iss.in | 46 +++++++++++++++++++++++++++ tennix.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++- tennix.res | Bin 0 -> 4904 bytes 7 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 data/icon.ico create mode 100644 tennix-installer.iss.in create mode 100644 tennix.res diff --git a/README.win32 b/README.win32 index cbb4be6..6f2d546 100644 --- a/README.win32 +++ b/README.win32 @@ -25,6 +25,46 @@ and the "zip" utility (from InfoZIP) is needed for the "release-win32" makefile target, which will create a zipfile with the binary release, ready to be distributed :) +===================== +Additional notes on Git + Win32 resources + InnoSetup +===================== +** GIT ** +You can download and bootstrap Git ported to Windows from +http://code.google.com/p/msysgit/. Simply download the +"GitMe-0.4.2.exe" (or newer) and run it to install Git and +a local version of msys to c:\msysgit\. + +You will be able to use Git on tennix's public repository, +see the Tennix website for more information. + +** Win32 resources ** +We are now using Win32 resource files to have an icon in the +Windows executable an to store the layout of the startup +dialog (that is only displayed in Windows atm). + +I've edited the "tennix.res" file (which contains the icon and +the dialog layout) with "XN Resource Editor", which is a freeware +resource editor for Windows, but you might want to use another +resource editor of you choice. + +URL: http://www.wilsonc.demon.co.uk/d10resourceeditor.htm + +** InnoSetup ** +Make sure you have installed InnoSetup 5 if you +want to generate a setup installer. You also have to set +the $PATH variable to point to the Inno Setup install dir +on your hard drive (eg c:\program files\inno setup 5\). +To check if you have set it up correctly, open your msys +shell and type "iscc". It should respond with "Inno Setup +5 Command-Line Compiler" and some generic information. + +When you have set up iscc correctly, simply do a "make +release-win32-setup" to compile a single setup executable +with innosetup and tennix. + +Thomas Perl , 2007-11-21 +===================== + Enjoy, thp 2007-05-12 diff --git a/data/icon.ico b/data/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..31494a7af37874d7c595bafd4a8fa7660e08983b GIT binary patch literal 4286 zcwViT3sh8f9>=fv1VjkY9=mDV>6D#T$x~>hX_-VC`9K2{%+kyU*1BrXEp^N4Y}?s2 z+3K{%vR3P;wQjs$!(-;o4D+6Wc`^(zFJ^{$Ac`ge_TAt84{*@3+SC3$KZm*8`~Q6Z z|NrlG;kYsM@0MFQ;eYN#630#FIBpghUE&_%qSt@zm^g6)cf<85+`N0|T+@W#3-|p$ zN6OUeuI6Ca?wfZvMt>iDpYYtT8HrO8u3$d;*dr+Tpb&=@I-F=}N447rsXqh}eO9%$ zKl9ZV6bEqGT(cH|OCsC->f$xey8Vo^3#s|BZNrPd8dU|l?>{(ds zb~Kqxko$u8r%H!ac{w9G9$IuiH*VaxpTlx7F)_qUW$c9yq~Tzt2;xAP*xe9!1@TFz z19|Npq}eU_jm3{?HXFpfy%-oA#K{H;zAY|-+U0>J)D3l47>8@>uy8>d)39jad@e37 z?kD-f>rP*uj$>BG5VsqzyS-1{GsQif2 zSP`qXVT>w($yzfeYTK}?-OTvCvrkPh%MU%BN0H4jau!pQldj;WMc0nE%W9zL@Sxb)iDa=4oG3u% zM|?vQCdeGbHG^vmB2I3`qy{T);2Ute%7A}#xftJcCc^k@p31{IofMf)5jHv<%y$J1 zf7_VqYvOO6)b=r}Y zP0y{%#TK~;*-izvIztqf0ce5|WDrl_3b|VNEcn|8;C&%{;P4|w)`30kZrIQDp}Thg z|0*g&*7{tgVeyNv;bvtqrs}1*)liQ+bw;FV6(;92}m@(pfpF2n351?K6+SfHsvhFXq1T{EgFCkmsdzaJZS?`F@ed;MiR(OQOm zUM2BE_*5A^gITxV%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2nL~~+O8t*XKFpxveWGHmzHpNsivsTg&Q-IF?J)-QhljW$a& zfdgalJ$)VIxcz+`x44JnW;$sb8tBzuumc=7cGx)KPYTzt(f18ME6gLzC(J9%FK`5& G!2K_6+{42F literal 0 HcwPel00001 diff --git a/data/makefile b/data/makefile index ccdb31a..c615939 100644 --- a/data/makefile +++ b/data/makefile @@ -13,7 +13,7 @@ sounds_data.c: data2csrc $(SOUNDS) (for i in $(SOUNDS); do ./data2csrc $$i; done)>sounds_data.c clean: - rm -f data2csrc *.o graphics_data.c sounds_data.c + rm -f data2csrc{,.exe} *.o graphics_data.c sounds_data.c .PHONY: clean all .DEFAULT: all diff --git a/makefile b/makefile index 2451205..9c15247 100644 --- a/makefile +++ b/makefile @@ -43,6 +43,9 @@ endif SRC = tennix.c game.c graphics.c input.c sound.c OBJ = tennix.o game.o graphics.o input.o sound.o +ifeq ($(MSYSTEM),MINGW32) + OBJ += tennixres.o +endif WIN32LIBS = *.dll OSXAPP = Tennix.app @@ -73,6 +76,7 @@ data/graphics_data.c: data/*.png data/sounds_data.c: data/*.wav make -C data sounds_data.c +# Mac OS X-specific targets release-osx: tennix mkdir -p $(OSXAPP)/Contents/{MacOS,/Resources} cp -rpv tennix $(OSXAPP)/Contents/MacOS/Tennix @@ -80,20 +84,33 @@ release-osx: tennix cp -rpv osxapp.plist $(OSXAPP)/Contents/Info.plist echo 'APPL????' >$(OSXAPP)/Contents/PkgInfo zip -r tennix-$(RELEASE)-macosx.zip $(OSXAPP) +# End Mac OS X-specific targets +# Windows-specific targets release-win32: tennix zip tennix-$(RELEASE)-win32.zip tennix.exe $(WIN32LIBS) $(DATAFILES) +tennix-installer.iss: tennix-installer.iss.in + sed tennix-installer.iss.in -e 's/{version}/$(RELEASE)/g' >tennix-installer.iss + +release-win32-setup: tennix tennix-installer.iss + iscc tennix-installer.iss + +tennixres.o: tennix.res + windres tennix.res tennixres.o +# End Windows-specific targets + release-bin: tennix tar czvf tennix-$(RELEASE)-bin.tar.gz tennix $(DATAFILES) clean: rm -f *.o tennix{,.exe} rm -rf $(OSXAPP) + rm -f tennixres.o tennix-installer.iss tennix-*-win32-setup.exe make -C data clean distclean: clean rm -f tennix-$(RELEASE).zip tennix-$(RELEASE)-bin.tar.gz -.PHONY: distclean clean release-bin release-win32 release-osx install +.PHONY: distclean clean release-bin release-win32 release-win32-setup release-osx install diff --git a/tennix-installer.iss.in b/tennix-installer.iss.in new file mode 100644 index 0000000..ae04526 --- /dev/null +++ b/tennix-installer.iss.in @@ -0,0 +1,46 @@ +; Inno Setup Script Template for Tennix (on Windows) +; Copyright (c) 2007 Thomas Perl +; Licensed under the same terms as Tennix iself + +[Setup] +AppName=Tennix +AppVerName=Tennix {version} +AppPublisher=Thomas Perl +AppPublisherURL=http://icculus.org/tennix/ +AppSupportURL=http://icculus.org/tennix/ +AppUpdatesURL=http://icculus.org/tennix/ +DefaultDirName={pf}\Tennix +DefaultGroupName=Tennix +LicenseFile=COPYING +OutputDir=. +OutputBaseFilename=tennix-{version}-win32-setup +Compression=lzma +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "tennix.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "SDL.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "SDL_image.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "SDL_mixer.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "libpng12.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "COPYING"; DestDir: "{app}"; Flags: ignoreversion +Source: "README.win32"; DestDir: "{app}"; Flags: ignoreversion +Source: "README"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\Tennix"; Filename: "{app}\tennix.exe" +Name: "{group}\{cm:ProgramOnTheWeb,Tennix}"; Filename: "http://icculus.org/tennix/" +Name: "{group}\{cm:UninstallProgram,Tennix}"; Filename: "{uninstallexe}" +Name: "{commondesktop}\Tennix"; Filename: "{app}\tennix.exe"; Tasks: desktopicon + +[Run] +Filename: "{app}\tennix.exe"; Description: "{cm:LaunchProgram,Tennix}"; Flags: nowait postinstall skipifsilent + diff --git a/tennix.c b/tennix.c index a17227d..70fd8bc 100644 --- a/tennix.c +++ b/tennix.c @@ -25,6 +25,10 @@ #include #include +#ifdef WIN32 +#include +#endif + #include "tennix.h" #include "game.h" #include "graphics.h" @@ -44,8 +48,48 @@ static const char* help_text[] = { /* Height (in pixels) of the help text scroller */ #define HELP_PHASE 50 +#ifdef WIN32 + +/* IDs from the resource file */ +#define START_BUTTON 1 +#define CHECKBOX_FULLSCREEN 2 +#define QUIT_BUTTON 3 + +BOOL CALLBACK ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static int checkbox_is_checked; + + switch (uMsg) { + case WM_CLOSE: + EndDialog(hwndDlg, IDCANCEL); + break; + case WM_COMMAND: + switch (wParam) { + case START_BUTTON: + EndDialog(hwndDlg, (checkbox_is_checked)?(IDYES):(IDNO)); + break; + case QUIT_BUTTON: + EndDialog(hwndDlg, IDCANCEL); + break; + case CHECKBOX_FULLSCREEN: + checkbox_is_checked ^= 1; + break; + } + break; + default: + return FALSE; + } + return TRUE; +} +#endif + +#ifdef WIN32 +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) { +#else int main( int argc, char** argv) { - int i = 0; +#endif + int i; int mx, my; Uint8 *keys; Uint8 mb; @@ -61,8 +105,44 @@ int main( int argc, char** argv) { Point elektrons[ELEKTRONS]; int el; +#ifdef WIN32 + int mb_result; + mb_result = DialogBox(hInstance, "CONFIG", 0, (DLGPROC)ConfigDialogProc); + + switch (mb_result) { + case IDYES: + sdl_flags |= SDL_FULLSCREEN; + break; + case IDCANCEL: + return 0; + break; + default: + break; + } +#else + bool do_help = false; + i = 1; + while (i < argc) { + /* A poor/lazy man's getopt */ + #define OPTION_SET(longopt,shortopt) \ + (strcmp(argv[i], longopt)==0 || strcmp(argv[i], shortopt)==0) + if (OPTION_SET("--fullscreen", "-f")) { + sdl_flags |= SDL_FULLSCREEN; + } + if (OPTION_SET("--help", "-h")) { + do_help = true; + } + i++; + } + fprintf( stderr, "Tennix %s\n%s\n%s\n\n", VERSION, COPYRIGHT, URL); + if (do_help == true) { + fprintf(stderr, "Usage: %s [--fullscreen|-f] [--help|-h]\n", argv[0]); + return 0; + } +#endif + sprintf( copyright_line, "Tennix %s -- %s", VERSION, COPYRIGHT); srand( (unsigned)time( NULL)); @@ -110,6 +190,7 @@ int main( int argc, char** argv) { } help_line_height = get_image_height( GR_SMALLISH_FONT); + i = 0; while( 1) { SDL_PollEvent( &e); if( e.type == SDL_QUIT) { diff --git a/tennix.res b/tennix.res new file mode 100644 index 0000000000000000000000000000000000000000..c0251384e27f76907386c4642c443f3344618aa0 GIT binary patch literal 4904 zcwVho3slr)7XJWE0Tn{*wX0I6Q+i6#Ews|KOeGE9rYM^EKtxDQFtaUn%i6PTXV+w_ z(;mxOt)teu@sii@80Nvem>HNS!)u0tnPFx?d?gC@+x!0pIQXjew0F*(|LflGcfaqu zum7Jh#$t$p0N+d}Bm19+5C`4zd;$wRe~vhapZzu(Hta5T-@Van+LM#-$ij0$?*B>A zqwl^M2mSoiv?&;TJy=fA`z;hPYUB-=^Iv=cX&-0dh(e2#bxkO4aY5?#K}5%*`X-$E z?iAj7=Z{=&uq}}hBYz3%78;D3u=-_WDYcNacR=d(K}Ia`c5;?_{qS{l;oSN2FxzaX zF&ZIvdGSw`7E6;>57_bCtf$$KAwzx%mIVg~6J{*Op7~514i$pOpSy))u z&*Jybd)~r%IBsd^!|lY|Ev*=5tVei_6=5}XU^+h{jauAgaNr}~c?fi-t^q4(t&-k7 zh|gTDs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