diff --git a/configure.ac b/configure.ac index 7963f0e14..fc3679fe3 100644 --- a/configure.ac +++ b/configure.ac @@ -228,6 +228,15 @@ AM_CONDITIONAL(INSTALLER, test "x$enable_installer" = "xyes") AC_MSG_CHECKING([whether to build NSIS installer]) AC_MSG_RESULT([${enable_installer}]) +# windows only option at this time +AC_ARG_ENABLE([portable], + AS_HELP_STRING([--enable-portable], [Build portable version of Warzone (windows ONLY!) [no]]), + [ enable_portable="${enableval}" ], [ enable_portable=no ]) +AS_IF([test "x$enable_portable" = "xyes"],[ + AC_DEFINE([WZ_PORTABLE], 1, [Makes builds become portable (windows ONLY)]) +]) +AM_CONDITIONAL(PORTABLE, test $enable_portable = yes) + AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], [Link statically [no]]), [ enable_static=${enableval} ], [ enable_static=no ]) @@ -318,6 +327,14 @@ AC_DEFINE_UNQUOTED([PACKAGE_DISTRIBUTOR], ["${with_distributor}"], [Name of dist AC_ARG_WITH([makensis], AS_HELP_STRING([--with-makensis], [Path to makensis])) +AC_ARG_WITH([videos], + AS_HELP_STRING([--with-videos], [Install videos with the portable version of Warzone (windows ONLY!) [no]]), + [ with_videos="${withval}" ], [ with_videos=no ]) +#AS_IF([test "x$with_videos" = "xyes"],[ +# AC_DEFINE([WZ_PORTABLE], 1, [Makes builds become portable (windows ONLY)]) +#]) +AM_CONDITIONAL(VIDEOS, test $with_videos = yes) + AC_ARG_WITH([installer_compression], AS_HELP_STRING([--with-installer-compression], [Compression method to use when building NSIS [lzma]]), [ with_installer_compression=${withval} ], [ with_installer_compression="lzma" ]) @@ -495,5 +512,16 @@ AS_IF([test -z "$A2X" -o -z "$WKHTMLTOPDF"],[ but means that things like "make dist" and building a Windows installer will fail.]) ]) +AS_IF([test "x$enable_portable" = "xyes"],[ + AC_MSG_NOTICE() + AC_MSG_NOTICE([*** Creating Portable version of Warzone (this options only affects Windows builds!) ***]) +]) +AS_IF([test "x$with_videos" = "xyes"],[ + AC_MSG_NOTICE() + AC_MSG_NOTICE([*** Creating Portable version of Warzone WITH VIDEOS (this options only affects Windows builds!) ***]) +]) + + + AC_MSG_NOTICE() AC_MSG_NOTICE(Backend used: ${backend}) diff --git a/icons/wz2100headerP.bmp b/icons/wz2100headerP.bmp new file mode 100644 index 000000000..b666a9c38 Binary files /dev/null and b/icons/wz2100headerP.bmp differ diff --git a/icons/wz2100portable.ico b/icons/wz2100portable.ico new file mode 100644 index 000000000..c77b812f9 Binary files /dev/null and b/icons/wz2100portable.ico differ diff --git a/icons/wz2100portableU.ico b/icons/wz2100portableU.ico new file mode 100644 index 000000000..e10a8fa34 Binary files /dev/null and b/icons/wz2100portableU.ico differ diff --git a/icons/wz2100welcomeP.bmp b/icons/wz2100welcomeP.bmp new file mode 100644 index 000000000..200bd387d Binary files /dev/null and b/icons/wz2100welcomeP.bmp differ diff --git a/lib/exceptionhandler/exchndl.cpp b/lib/exceptionhandler/exchndl.cpp index e567145bb..410f0e262 100644 --- a/lib/exceptionhandler/exchndl.cpp +++ b/lib/exceptionhandler/exchndl.cpp @@ -1190,7 +1190,7 @@ void ExchndlSetup(const char *packageVersion) { # if defined(WZ_CC_MINGW) wchar_t miniDumpPath[PATH_MAX] = {'\0'}; - + DWORD dwRetVal = 0; #ifdef HAVE_BFD bfd_init(); #endif /* HAVE_BFD */ @@ -1200,7 +1200,7 @@ void ExchndlSetup(const char *packageVersion) // Retrieve the current version formattedVersionString = strdup(packageVersion); - +#ifndef WZ_PORTABLE // Because of UAC on vista / win7 we use this to write our dumps to (unless we override it via OverrideRPTDirectory()) // NOTE: CSIDL_PERSONAL = C:\Users\user name\Documents if ( SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, miniDumpPath ) )) @@ -1212,13 +1212,37 @@ void ExchndlSetup(const char *packageVersion) { if( ERROR_SUCCESS != SHCreateDirectoryExW( NULL, miniDumpPath, NULL ) ) { - wcscpy(miniDumpPath, L"c:\\temp"); + //last attempt to get a path + dwRetVal = GetTempPathW(PATH_MAX, miniDumpPath); + if (dwRetVal > MAX_PATH || (dwRetVal == 0)) + { + MessageBox((HWND)MB_ICONEXCLAMATION, "Could not created a temporary directory!\nProgram will now exit." , _T("Error"), MB_OK); + exit(1); + } } } } +#else + // we use where they installed it on, since this is a removeable drive (most likely), we will use where the program is located in. + if (dwRetVal = GetCurrentDirectoryW(MAX_PATH, miniDumpPath)) + { + if(dwRetVal > MAX_PATH) + { + MessageBox((HWND)MB_ICONEXCLAMATION, "Buffer exceeds maximum path to create directory. Exiting.", _T("Error"), MB_OK); + exit(1); + } + PathAppendW( miniDumpPath, WSTRING(WZ_WRITEDIR)); + PathAppendW( miniDumpPath, L"\\logs" ); + } +#endif else { // should never fail, but if it does, we fall back to this - wcscpy(miniDumpPath, L"c:\\temp"); + dwRetVal = GetTempPathW(PATH_MAX, miniDumpPath); + if (dwRetVal > MAX_PATH || (dwRetVal == 0)) + { + MessageBox((HWND)MB_ICONEXCLAMATION, "Could not created a temporary directory!\nProgram will now exit." , _T("Error!"), MB_OK); + exit(1); + } } wcscat(szLogFileName, L"Warzone2100.RPT"); diff --git a/lib/framework/i18n.cpp b/lib/framework/i18n.cpp index 1fe148cde..07055112a 100644 --- a/lib/framework/i18n.cpp +++ b/lib/framework/i18n.cpp @@ -37,6 +37,12 @@ # define LOCALEDIR "locale" #endif +#ifdef PORTABLE +# ifdef PACKAGE +# undef PACKAGE +# define PACKAGE "warzone2100_portable" +# endif +#endif // Language names (http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) #define LANG_NAME_BASQUE "euskara" #define LANG_NAME_CATALAN "catalГ " diff --git a/pkg/nsis/Makefile.am b/pkg/nsis/Makefile.am index 1c42c5bbe..db14c172f 100644 --- a/pkg/nsis/Makefile.am +++ b/pkg/nsis/Makefile.am @@ -1,4 +1,9 @@ +if PORTABLE +INSTALLERFILE=$(PACKAGE)_portable-$(VERSION).exe +else INSTALLERFILE=$(PACKAGE)-$(VERSION).exe +endif + UPDATERFILE=$(PACKAGE)-$(VERSION).update.exe EXTRA_DIST = fonts.conf.wd_enable \ @@ -21,9 +26,18 @@ $(top_srcdir)/po/%.gmo: $(top_srcdir)/po/%.po data: $(MAKE) $(AM_MAKEFLAGS) -C ../../data/ all - +if PORTABLE +if VIDEOS +$(INSTALLERFILE): warzone2100.nsi ../../src/warzone2100_portable.exe data $(GMOFILES) + $(MAKENSIS) -DOUTFILE="$(abs_builddir)/$(PACKAGE)-$(PACKAGE_VERSION)-vids_portable.exe" -DPACKAGE="$(PACKAGE)_portable" -DPORTABLE -DINSTALLVIDS -DPACKAGE_NAME="$(PACKAGE_NAME)_portable" -DPACKAGE_VERSION="$(PACKAGE_VERSION)" -DPACKAGE_BUGREPORT="$(PACKAGE_BUGREPORT)" -DVERSIONNUM="$(INSTALLER_VERSION)" -DEXTDIR="$(INSTALLER_EXTDIR)" -DTOP_SRCDIR="$(abs_top_srcdir)" -DTOP_BUILDDIR="$(abs_top_builddir)" -X"SetCompressor /FINAL /SOLID $(INSTALLER_COMPRESSION)" $< +else +$(INSTALLERFILE): warzone2100.nsi ../../src/warzone2100_portable.exe data $(GMOFILES) + $(MAKENSIS) -DOUTFILE="$(abs_builddir)/$(PACKAGE)-$(PACKAGE_VERSION)_portable.exe" -DPACKAGE="$(PACKAGE)_portable" -DPORTABLE -DPACKAGE_NAME="$(PACKAGE_NAME)_portable" -DPACKAGE_VERSION="$(PACKAGE_VERSION)" -DPACKAGE_BUGREPORT="$(PACKAGE_BUGREPORT)" -DVERSIONNUM="$(INSTALLER_VERSION)" -DEXTDIR="$(INSTALLER_EXTDIR)" -DTOP_SRCDIR="$(abs_top_srcdir)" -DTOP_BUILDDIR="$(abs_top_builddir)" -X"SetCompressor /FINAL /SOLID $(INSTALLER_COMPRESSION)" $< +endif +else $(INSTALLERFILE): warzone2100.nsi ../../src/warzone2100.exe data $(GMOFILES) $(MAKENSIS) -DOUTFILE="$(abs_builddir)/$@" -DPACKAGE="$(PACKAGE)" -DPACKAGE_NAME="$(PACKAGE_NAME)" -DPACKAGE_VERSION="$(PACKAGE_VERSION)" -DPACKAGE_BUGREPORT="$(PACKAGE_BUGREPORT)" -DVERSIONNUM="$(INSTALLER_VERSION)" -DEXTDIR="$(INSTALLER_EXTDIR)" -DTOP_SRCDIR="$(abs_top_srcdir)" -DTOP_BUILDDIR="$(abs_top_builddir)" -X"SetCompressor /FINAL /SOLID $(INSTALLER_COMPRESSION)" $< +endif $(UPDATERFILE): warzone2100.update.nsi $(MAKENSIS) -DVERSION="$(VERSION)" -DVERSIONNUM="$(INSTALLER_VERSION)" -DEXTDIR="$(INSTALLER_EXTDIR)" -X"SetCompressor /FINAL /SOLID $(INSTALLER_COMPRESSION)" $< diff --git a/pkg/nsis/warzone2100.nsi b/pkg/nsis/warzone2100.nsi index 60f0110cf..2f482ed71 100644 --- a/pkg/nsis/warzone2100.nsi +++ b/pkg/nsis/warzone2100.nsi @@ -1,5 +1,5 @@ ; This file is part of Warzone 2100. -; Copyright (C) 2006-2010 Warzone 2100 Project +; Copyright (C) 2006-2013 Warzone 2100 Project ; Copyright (C) 2006 Dennis Schridde ; ; Warzone 2100 is free software; you can redistribute it and/or modify @@ -35,62 +35,73 @@ Name "${PACKAGE_NAME}" OutFile "${OUTFILE}" +!ifndef PORTABLE ;Default installation folder InstallDir "$PROGRAMFILES\${PACKAGE_NAME}-${PACKAGE_VERSION}" - ;Get installation folder from registry if available InstallDirRegKey HKLM "Software\${PACKAGE_NAME}-${PACKAGE_VERSION}" "" - ;Request application privileges for Windows Vista RequestExecutionLevel admin - +!else + RequestExecutionLevel user +!endif ;-------------------------------- ;Versioninfo VIProductVersion "${VERSIONNUM}" -VIAddVersionKey "CompanyName" "Warzone 2100 Project" +VIAddVersionKey "CompanyName" "Warzone 2100 Project" VIAddVersionKey "FileDescription" "${PACKAGE_NAME} Installer" VIAddVersionKey "FileVersion" "${PACKAGE_VERSION}" -VIAddVersionKey "InternalName" "${PACKAGE_NAME}" -VIAddVersionKey "LegalCopyright" "Copyright © 2006-2011 Warzone 2100 Project" +VIAddVersionKey "InternalName" "${PACKAGE_NAME}" +VIAddVersionKey "LegalCopyright" "Copyright (c) 2006-2013 Warzone 2100 Project" VIAddVersionKey "OriginalFilename" "${PACKAGE}-${PACKAGE_VERSION}.exe" -VIAddVersionKey "ProductName" "${PACKAGE_NAME}" +VIAddVersionKey "ProductName" "${PACKAGE_NAME}" VIAddVersionKey "ProductVersion" "${PACKAGE_VERSION}" +!ifndef PORTABLE ;-------------------------------- ;Variables - Var MUI_TEMP Var STARTMENU_FOLDER - ;-------------------------------- +!endif ;Interface Settings - +!ifndef PORTABLE !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100header.bmp" !define MUI_HEADERIMAGE_RIGHT !define MUI_WELCOMEPAGE_TITLE "Welcome to Warzone 2100 v. ${PACKAGE_VERSION}" - !define MUI_WELCOMEPAGE_TEXT "$(WZWelcomeText)" !define MUI_WELCOMEFINISHPAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100welcome.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100welcome.bmp" - !define MUI_ICON "${TOP_SRCDIR}\icons\warzone2100.ico" !define MUI_UNICON "${TOP_SRCDIR}\icons\warzone2100.uninstall.ico" + !else + !define MUI_HEADERIMAGE + !define MUI_HEADERIMAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100headerP.bmp" + !define MUI_HEADERIMAGE_RIGHT + !define MUI_WELCOMEPAGE_TITLE "Warzone 2100 v. ${PACKAGE_VERSION} Portable" + !define MUI_WELCOMEFINISHPAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100welcomeP.bmp" + !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${TOP_SRCDIR}\icons\wz2100welcomeP.bmp" + !define MUI_ICON "${TOP_SRCDIR}\icons\wz2100portable.ico" + !define MUI_UNICON "${TOP_SRCDIR}\icons\wz2100portableU.ico" +!endif + !define MUI_WELCOMEPAGE_TEXT "$(WZWelcomeText)" !define MUI_ABORTWARNING +!ifndef PORTABLE ;Start Menu Folder Page Configuration (for MUI_PAGE_STARTMENU) !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PACKAGE_NAME}-${PACKAGE_VERSION}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" - +!endif ; These indented statements modify settings for MUI_PAGE_FINISH !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOAUTOCLOSE - + !define MUI_LICENSEPAGE_RADIOBUTTONS !define MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT "$(WZ_GPL_NEXT)" - + ;-------------------------------- ;Pages @@ -100,7 +111,9 @@ VIAddVersionKey "ProductVersion" "${PACKAGE_VERSION}" !insertmacro MUI_PAGE_LICENSE "${TOP_SRCDIR}\COPYING" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY +!ifndef PORTABLE !insertmacro MUI_PAGE_STARTMENU "Application" $STARTMENU_FOLDER +!endif !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH @@ -129,11 +142,11 @@ Function WelcomePageSetupLinkPre !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "142" ; limit size of the upper label !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "4" ; increase counter !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "Link" - !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "Visit our Official Homepage http://wz2100.net" + !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "Visit our Official Homepage http://wz2100.net for the latest version." !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "State" "http://wz2100.net/" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "300" - !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "160" + !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "154" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "172" FunctionEnd @@ -151,19 +164,10 @@ FunctionEnd ;Installer Sections Section $(TEXT_SecBase) SecBase - SectionIn RO - SetOutPath "$INSTDIR" - SetShellVarContext all - - ; Clean-up section for no-longer supported stuff - Delete "$INSTDIR\mods\multiplay\original.wz" - Delete "$INSTDIR\mods\multiplay\aivolution.wz" - Delete "$SMPROGRAMS\$STARTMENU_FOLDER\${PACKAGE_NAME} - Aivolution.lnk" - Delete "$SMPROGRAMS\$STARTMENU_FOLDER\${PACKAGE_NAME} - Original.lnk" - + ;ADD YOUR OWN FILES HERE... ; Main executable @@ -173,6 +177,14 @@ Section $(TEXT_SecBase) SecBase File "${EXTDIR}\bin\dbghelp.dll.license.txt" File "${EXTDIR}\bin\dbghelp.dll" +!ifdef PORTABLE +; openAL installer + File "${EXTDIR}\bin\oalinst.exe" +!endif +!ifdef INSTALLVIDS +; sequences.wz + File "${EXTDIR}\opt\sequences.wz" +!endif ; Data files File "${TOP_BUILDDIR}\data\mp.wz" File "${TOP_BUILDDIR}\data\base.wz" @@ -203,7 +215,7 @@ Section $(TEXT_SecBase) SecBase Push "COPYING.README.txt" Call unix2dos - ; Create mod directories +; Create mod directories CreateDirectory "$INSTDIR\mods\campaign" CreateDirectory "$INSTDIR\mods\music" CreateDirectory "$INSTDIR\mods\global" @@ -233,6 +245,7 @@ Section $(TEXT_SecBase) SecBase File "${EXTDIR}\etc\fonts\DejaVuSans.ttf" File "${EXTDIR}\etc\fonts\DejaVuSans-Bold.ttf" +!ifndef PORTABLE ;Store installation folder WriteRegStr HKLM "Software\${PACKAGE_NAME}-${PACKAGE_VERSION}" "" $INSTDIR @@ -251,7 +264,7 @@ Section $(TEXT_SecBase) SecBase WriteUninstaller "$INSTDIR\uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - SetOutPath "$INSTDIR" + SetOutPath "$INSTDIR" ;Create shortcuts CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER-${PACKAGE_VERSION}" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER-${PACKAGE_VERSION}\Uninstall.lnk" "$INSTDIR\uninstall.exe" @@ -261,41 +274,25 @@ Section $(TEXT_SecBase) SecBase !insertmacro MUI_STARTMENU_WRITE_END - SetOutPath "$INSTDIR" + SetOutPath "$INSTDIR" CreateShortCut "$DESKTOP\${PACKAGE_NAME}-${PACKAGE_VERSION}.lnk" "$INSTDIR\${PACKAGE}.exe" +!endif #PORTABLE SectionEnd +; NOTE: you need upgraded security privs to install shortcut on desktop for portable. ; Installs OpenAL runtime libraries, using Creative's installer +!ifndef PORTABLE Section $(TEXT_SecOpenAL) SecOpenAL - SetOutPath "$INSTDIR" - File "${EXTDIR}\bin\oalinst.exe" - ExecWait '"$INSTDIR\oalinst.exe" --silent' - SectionEnd +!endif -;SectionGroup /e $(TEXT_SecMods) secMods -; -;Section $(TEXT_SecOriginalMod) SecOriginalMod -; -; SetOutPath "$INSTDIR\mods\multiplay" -; File "${TOP_BUILDDIR}\data\mods\multiplay\old-1.10-balance.wz" -; SetOutPath "$INSTDIR" -; -; !insertmacro MUI_STARTMENU_WRITE_BEGIN "Application" -; CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER-${PACKAGE_VERSION}\${PACKAGE_NAME}- Old 1.10 Balance.lnk" "$INSTDIR\${PACKAGE}.exe" "--mod_mp=old-1.10-balance.wz" -; !insertmacro MUI_STARTMENU_WRITE_END -; -;SectionEnd -; -;SectionGroupEnd +!ifndef INSTALLVIDS SectionGroup $(TEXT_SecFMVs) SecFMVs - - Section /o $(TEXT_SecFMVs_EngHi) SecFMVs_EngHi IfFileExists "sequences.wz" +5 @@ -303,27 +300,22 @@ Section /o $(TEXT_SecFMVs_EngHi) SecFMVs_EngHi Pop $R0 ; Get the return value StrCmp $R0 "success" +2 MessageBox MB_OK|MB_ICONSTOP "Download of videos failed: $R0" - SectionEnd Section /o $(TEXT_SecFMVs_Eng) SecFMVs_Eng - IfFileExists "sequences.wz" +5 NSISdl::download "http://downloads.sourceforge.net/project/warzone2100/warzone2100/Videos/standard-quality-en/sequences.wz" "sequences.wz" Pop $R0 ; Get the return value StrCmp $R0 "success" +2 MessageBox MB_OK|MB_ICONSTOP "Download of videos failed: $R0" - SectionEnd Section /o $(TEXT_SecFMVs_EngLo) SecFMVs_EngLo - IfFileExists "sequences.wz" +5 NSISdl::download "http://downloads.sourceforge.net/project/warzone2100/warzone2100/Videos/low-quality-en/sequences.wz" "sequences.wz" Pop $R0 ; Get the return value StrCmp $R0 "success" +2 MessageBox MB_OK|MB_ICONSTOP "Download of videos failed: $R0" - SectionEnd ;Section /o $(TEXT_SecFMVs_Ger) SecFMVs_Ger @@ -337,6 +329,7 @@ SectionEnd ;SectionEnd SectionGroupEnd +!endif SectionGroup $(TEXT_SecNLS) SecNLS @@ -440,7 +433,7 @@ SectionEnd Section /o $(TEXT_SecNLS_WinFonts) SecNLS_WinFonts SetOutPath "$INSTDIR\fonts" Delete "$INSTDIR\fonts\fonts.conf" - File "/oname=fonts.conf" "${EXTDIR}\etc\fonts\fonts.conf.wd_enable" + File "/oname=fonts.conf" "${EXTDIR}\etc\fonts\fonts.conf.wd_enable" SectionEnd SectionGroupEnd @@ -450,7 +443,7 @@ SectionGroupEnd Function .onInit !insertmacro MUI_LANGDLL_DISPLAY - +!ifndef INSTALLVIDS # increase required size of section 'SecFMVs_EngHi' by file size SectionGetSize ${SecFMVs_EngHi} $0 IntOp $0 $0 + 671938;135 @@ -470,18 +463,26 @@ Function .onInit ; SectionGetSize ${SecFMVs_Ger} $0 ; IntOp $0 $0 + 499187;492 ; SectionSetSize ${SecFMVs_Ger} $0 - + ;HACK: Set section 'Video' as read-only SectionGetFlags ${SecFMVs} $0 IntOp $0 $0 ^ ${SF_SELECTED} IntOp $0 $0 | ${SF_RO} SectionSetFlags ${SecFMVs} $0 - + ;FIXME: Select default video sub-component ; Default is still set to standard instead of high, since there is a ~450MB difference StrCpy $5 ${SecFMVs_Eng} +!endif + +!ifdef PORTABLE + System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)" + GetFullPathName $0 "$0\" + StrCpy $INSTDIR "$0${PACKAGE_NAME}-${PACKAGE_VERSION}\" +!endif FunctionEnd +!ifndef INSTALLVIDS Function .onSelChange ${If} ${SectionIsSelected} ${SecFMVs_Eng} ${OrIf} ${SectionIsSelected} ${SecFMVs_EngHi} @@ -495,6 +496,7 @@ ${OrIf} ${SectionIsSelected} ${SecFMVs_EngLo} !insertmacro EndRadioButtons ${EndIf} FunctionEnd +!endif Function unix2dos ; strips all CRs and then converts all LFs into CRLFs @@ -515,7 +517,7 @@ Function unix2dos unix2dos_loop: FileReadByte $0 $2 ; read a byte (stored in $2) - IfErrors unix2dos_done ; EOL + IfErrors unix2dos_done ; EOL StrCmp $2 13 unix2dos_loop ; skip CR StrCmp $2 10 unix2dos_cr unix2dos_write ; if LF write an extra CR @@ -531,14 +533,18 @@ unix2dos_done: FileClose $1 Pop $0 Delete $0 ; delete original - + FunctionEnd ;-------------------------------- ;Descriptions +!ifndef PORTABLE ;English - LangString WZWelcomeText ${LANG_ENGLISH} "This wizard will guide you through the installation of Warzone 2100.\r\n\r\nIt is recommended that you close all other applications before continuing this installation. This will make it possible to update relevant system files without having to reboot your computer.\r\n\r\nWarzone 2100 is 100% free, if you paid for it, let us know!\r\n\r\nClick Next to continue." + LangString WZWelcomeText ${LANG_ENGLISH} "Welcome to the Warzone 2100 installer!\r\n\r\nThis wizard will guide you through the installation of Warzone 2100.\r\n\r\nIt is recommended that you close all other applications before continuing this installation. This will make it possible to update relevant system files without having to reboot your computer.\r\n\r\nWarzone 2100 is 100% free, fully open sourced program\r\n\r\nClick Next to continue." +!else + LangString WZWelcomeText ${LANG_ENGLISH} "Welcome to the Warzone 2100 portable installer!\r\n\r\nThis wizard will guide you through the installation of the portable version of Warzone 2100.\r\n\r\nThis install is fully self-contained and you can uninstall the program at any time by deleting the directory.\r\n\r\nWarzone 2100 is 100% free, fully open sourced program! \r\n\r\nClick Next to continue." +!endif LangString WZ_GPL_NEXT ${LANG_ENGLISH} "Next" @@ -565,18 +571,18 @@ FunctionEnd LangString TEXT_SecFMVs_Ger ${LANG_ENGLISH} "German" LangString DESC_SecFMVs_Ger ${LANG_ENGLISH} "Download and install German in-game cutscenes (460 MB)." - + LangString TEXT_SecNLS ${LANG_ENGLISH} "Language files" LangString DESC_SecNLS ${LANG_ENGLISH} "Support for languages other than English." LangString TEXT_SecNLS_WinFonts ${LANG_ENGLISH} "WinFonts" LangString DESC_SecNLS_WinFonts ${LANG_ENGLISH} "Include Windows Fonts folder into the search path. Enable this if you want to use custom fonts in config file or having troubles with standard font. Can be slow on Vista and later!" - - LangString TEXT_SecOriginalMod ${LANG_ENGLISH} "1.10 balance" - LangString DESC_SecOriginalMod ${LANG_ENGLISH} "Play the game as it was back in the 1.10 days." + +; LangString TEXT_SecOriginalMod ${LANG_ENGLISH} "1.10 balance" +; LangString DESC_SecOriginalMod ${LANG_ENGLISH} "Play the game as it was back in the 1.10 days." ;Dutch - LangString WZWelcomeText ${LANG_DUTCH} "Deze installatiewizard leidt u door het installatieproces van Warzone 2100.\r\n\r\nHet is aangeraden om alle andere applicaties te sluiten alvorens verder te gaan met deze installatie. Dit maakt het mogelijk om de betreffende systeembestanden te vervangen zonder uw computer opnieuw op te starten" + LangString WZWelcomeText ${LANG_DUTCH} "Deze installatiewizard leidt u door het installatieproces van Warzone 2100.\r\n\r\nHet is aangeraden om alle andere applicaties te sluiten alvorens verder te gaan met deze installatie. Dit maakt het mogelijk om de betreffende systeembestanden te vervangen zonder uw computer opnieuw op te starten" LangString WZ_GPL_NEXT ${LANG_DUTCH} "volgende" @@ -609,9 +615,9 @@ FunctionEnd LangString TEXT_SecNLS_WinFonts ${LANG_DUTCH} "WinFonts" LangString DESC_SecNLS_WinFonts ${LANG_DUTCH} "Include Windows Fonts folder into the search path. Enable this if you want to use custom fonts in config file or having troubles with standard font. Can be slow on Vista and later!" - - LangString TEXT_SecOriginalMod ${LANG_DUTCH} "1.10 balance" - LangString DESC_SecOriginalMod ${LANG_DUTCH} "Speel het spel met de originele 1.10 versie balans stats." + +; LangString TEXT_SecOriginalMod ${LANG_DUTCH} "1.10 balance" +; LangString DESC_SecOriginalMod ${LANG_DUTCH} "Speel het spel met de originele 1.10 versie balans stats." ;German LangString WZWelcomeText ${LANG_GERMAN} "Dieser Wizard wird Sie durch die Warzone-2100-Installation fьhren.\r\n\r\nEs wird empfohlen sдmtliche anderen Anwendungen zu schlieЯen, bevor Sie das Setup starten. Dies ermцglicht es relevante Systemdateien zu aktualisieren, ohne neustarten zu mьssen.\r\n\r\nWarzone 2100 ist zu 100% kostenlos, falls Sie dafьr gezahlt haben, lassen Sie es uns wissen!\r\n\r\nKlicken Sie auf Weiter, um fortzufahren." @@ -641,18 +647,18 @@ FunctionEnd LangString TEXT_SecFMVs_Ger ${LANG_GERMAN} "German" LangString DESC_SecFMVs_Ger ${LANG_GERMAN} "Die deutschen Videos herunterladen und installieren (460 MiB)." - + LangString TEXT_SecNLS ${LANG_GERMAN} "Language files" LangString DESC_SecNLS ${LANG_GERMAN} "Unterstьtzung fьr Sprachen auЯer Englisch (Deutsch inbegriffen)." LangString TEXT_SecNLS_WinFonts ${LANG_GERMAN} "WinFonts" LangString DESC_SecNLS_WinFonts ${LANG_GERMAN} "Den Windows-Schriftarten-Ordner in den Suchpfad aufnehmen. Nutzen Sie dies, falls Sie spдter eigene Schriftarten in der Konfigurationsdatei eingeben wollen oder es zu Problemen mit der Standardschriftart kommt. Kann unter Vista und spдter langsam sein!" - + LangString TEXT_SecOriginalMod ${LANG_GERMAN} "1.10 balance" LangString DESC_SecOriginalMod ${LANG_GERMAN} "Spielen Sie das Spiel mit dem Balancing aus der Originalversion 1.10." ;Russian - LangString WZWelcomeText ${LANG_RUSSIAN} "Этот помощник установки поможет вам установить Warzone2100.\r\n\r\nПеред началом рекомендуем закрыть все другие приложения. Это позволит обновить соответствующие системные файлы без перезагрузки системы.\r\n\r\nWarzone2100 100% бесплатный, если вы за него заплатили сообщите нам!\r\n\r\nНажмите Далее для продолжения." + LangString WZWelcomeText ${LANG_RUSSIAN} "Этот помощник установки поможет вам установить Warzone2100.\r\n\r\nПеред началом рекомендуем закрыть все другие приложения. Это позволит обновить соответствующие системные файлы без перезагрузки системы.\r\n\r\nWarzone2100 100% бесплатный, если вы за него заплатили сообщите нам!\r\n\r\nНажмите Далее для продолжения." LangString WZ_GPL_NEXT ${LANG_RUSSIAN} "Согласен" @@ -697,7 +703,7 @@ FunctionEnd ; !insertmacro MUI_DESCRIPTION_TEXT ${SecMods} $(DESC_SecMods) ; !insertmacro MUI_DESCRIPTION_TEXT ${SecOriginalMod} $(DESC_SecOriginalMod) - + !insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs} $(DESC_SecFMVs) !insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_Eng} $(DESC_SecFMVs_Eng) !insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_EngHi} $(DESC_SecFMVs_EngHi) @@ -707,9 +713,10 @@ FunctionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecNLS} $(DESC_SecNLS) !insertmacro MUI_DESCRIPTION_TEXT ${SecNLS_WinFonts} $(DESC_SecNLS_WinFonts) !insertmacro MUI_FUNCTION_DESCRIPTION_END - + ;-------------------------------- ;Uninstaller Section +!ifndef PORTABLE Section "Uninstall" @@ -900,7 +907,7 @@ Section "Uninstall" RMDir "$INSTDIR" SetShellVarContext all - + ; remove the desktop shortcut icon Delete "$DESKTOP\${PACKAGE_NAME}-${PACKAGE_VERSION}.lnk" @@ -936,7 +943,7 @@ Section "Uninstall" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}-${PACKAGE_VERSION}" SectionEnd - +!endif ;-------------------------------- ;Uninstaller Functions @@ -945,3 +952,4 @@ Function un.onInit !insertmacro MUI_UNGETLANGUAGE FunctionEnd + diff --git a/src/Makefile.am b/src/Makefile.am index 1abf81a6a..769b59848 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,12 @@ EXTRA_DIST = \ autorevision.cache \ cursorselection +if PORTABLE +bin_PROGRAMS = warzone2100_portable +else bin_PROGRAMS = warzone2100 +endif + noinst_HEADERS = \ action.h \ actiondef.h \ @@ -158,11 +163,11 @@ noinst_HEADERS = \ wrappers.h \ $(MOCHEADER) -nodist_warzone2100_SOURCES = \ +nodist_COMMONSOURCES = \ multiint_moc.cpp \ qtscriptdebug_moc.cpp -warzone2100_SOURCES = \ +COMMONSOURCES = \ action.cpp \ advvis.cpp \ ai.cpp \ @@ -272,7 +277,9 @@ warzone2100_SOURCES = \ wavecast.cpp \ wrappers.cpp -warzone2100_LIBS = \ + + +COMMONLIBS = \ $(top_builddir)/lib/widget/libwidget.a \ $(top_builddir)/lib/sequence/libsequence.a \ $(top_builddir)/lib/sound/libsound.a \ @@ -285,18 +292,46 @@ warzone2100_LIBS = \ $(top_builddir)/3rdparty/miniupnpc/libminiupnpc.a \ $(top_builddir)/3rdparty/quesoglc/libquesoglc.a +if PORTABLE +warzone2100_portable_SOURCES = $(COMMONSOURCES) $(nodist_COMMONSOURCES) +warzone2100_portable_LIBS = $(COMMONLIBS) +else +warzone2100_SOURCES = $(COMMONSOURCES) $(nodist_COMMONSOURCES) +warzone2100_LIBS = $(COMMONLIBS) +endif + if BACKEND_QT +if PORTABLE +warzone2100_portable_LIBS += $(top_builddir)/lib/qtgame/libqtgame.a +else warzone2100_LIBS += $(top_builddir)/lib/qtgame/libqtgame.a endif +endif if BACKEND_SDL +if PORTABLE +warzone2100_portable_LIBS += $(top_builddir)/lib/sdl/libsdl.a +else warzone2100_LIBS += $(top_builddir)/lib/sdl/libsdl.a endif +endif + +if PORTABLE +warzone2100_portable_LDADD = $(warzone2100_portable_LIBS) $(LTLIBINTL) $(SDL_LIBS) $(PHYSFS_LIBS) $(PNG_LIBS) $(VORBISFILE_LIBS) $(VORBIS_LIBS) \ + $(THEORA_LIBS) $(OPENAL_LIBS) $(OPENGLC_LIBS) $(OPENGL_LIBS) $(QT4_LIBS) $(GLEW_LIBS) \ + $(X_LIBS) $(X_EXTRA_LIBS) $(LIBCRYPTO_LIBS) $(LDFLAGS) +else warzone2100_LDADD = $(warzone2100_LIBS) $(LTLIBINTL) $(SDL_LIBS) $(PHYSFS_LIBS) $(PNG_LIBS) $(VORBISFILE_LIBS) $(VORBIS_LIBS) \ $(THEORA_LIBS) $(OPENAL_LIBS) $(OPENGLC_LIBS) $(OPENGL_LIBS) $(QT4_LIBS) $(GLEW_LIBS) \ $(X_LIBS) $(X_EXTRA_LIBS) $(LIBCRYPTO_LIBS) $(LDFLAGS) +endif if MINGW32 +if PORTABLE +warzone2100_portable_LDADD += $(top_builddir)/win32/warzone2100_portable.o $(WIN32_LIBS) +else warzone2100_LDADD += $(top_builddir)/win32/warzone2100.o $(WIN32_LIBS) endif +endif + diff --git a/src/main.cpp b/src/main.cpp index d5e898172..32de62868 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -419,12 +419,24 @@ static bool getCurrentDir(char * const dest, size_t const size) static void getPlatformUserDir(char * const tmpstr, size_t const size) { #if defined(WZ_OS_WIN) +// When WZ_PORTABLE is passed, that means we want the config directory at the same location as the program file + DWORD dwRet; wchar_t tmpWStr[MAX_PATH]; +#ifndef WZ_PORTABLE if ( SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, tmpWStr ) ) ) { +#else + if (dwRet = GetCurrentDirectoryW(MAX_PATH, tmpWStr)) + { + if(dwRet > MAX_PATH) + { + debug(LOG_FATAL, "Buffer exceeds maximum path to create directory. Exiting."); + exit(1); + } +#endif if (WideCharToMultiByte(CP_UTF8, 0, tmpWStr, -1, tmpstr, size, NULL, NULL) == 0) { - debug(LOG_ERROR, "Encoding conversion error."); + debug(LOG_FATAL, "Config directory encoding conversion error."); exit(1); } strlcat(tmpstr, PHYSFS_getDirSeparator(), size); diff --git a/win32/Makefile.am b/win32/Makefile.am index 998a380fc..ec6af5b3b 100644 --- a/win32/Makefile.am +++ b/win32/Makefile.am @@ -1,7 +1,11 @@ .rc.o: $(WINDRES) -DVERSION="\"$(VERSION)\"" -o$@ $< +if PORTABLE +dist_noinst_DATA = warzone2100_portable.rc +else dist_noinst_DATA = warzone2100.rc +endif EXTRA_DIST = __BUILD_SCRIPT \ download.pl \ @@ -27,7 +31,13 @@ EXTRA_DIST = __BUILD_SCRIPT \ libs/zlib/Makefile if MINGW32 +if PORTABLE +nodist_noinst_DATA = \ + warzone2100_portable.o +else nodist_noinst_DATA = \ warzone2100.o +endif + CLEANFILES = $(nodist_noinst_DATA) endif diff --git a/win32/warzone2100_portable.rc b/win32/warzone2100_portable.rc new file mode 100644 index 000000000..a50c1b941 --- /dev/null +++ b/win32/warzone2100_portable.rc @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +1 VERSIONINFO + FILEVERSION 9,9,9,9 + PRODUCTVERSION 9,9,9,9 + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Warzone 2100 Project" + VALUE "FileDescription", "Warzone 2100 portable" + VALUE "FileVersion", "master" + VALUE "InternalName", "Warzone 2100" + VALUE "LegalCopyright", "Copyright © 2005-2013 Warzone 2100 Project" + VALUE "OriginalFilename", "warzone2100_portable.exe" + VALUE "ProductName", "Warzone 2100 portable" + VALUE "ProductVersion", "master" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04b0 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +2 ICON "../icons/wz2100portable.ico"