!include "Sections.nsh" Var AR_SecFlags Var AR_RegFlags !macro CheckDependencies SecName SectionGetFlags ${${SecName}} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 $${SecName}_state +6 StrCpy $${SecName}_state $R0 StrCmp $${SecName}_state ${SF_SELECTED} +3 Call deselect_${SecName}_dependents Goto checked_${SecName} Call select_${SecName}_dependencies checked_${SecName}: !macroend !macro UnselectDependent SecName SectionGetFlags ${${SecName}} $R0 IntOp $R1 $R0 & ${SF_SELECTED} StrCmp $R1 ${SF_SELECTED} 0 +5 IntOp $R0 $R0 ^ ${SF_SELECTED} SectionSetFlags ${${SecName}} $R0 StrCpy $${SecName}_state 0 Call deselect_${SecName}_dependents !macroend !macro SelectDependency SecName SectionGetFlags ${${SecName}} $R0 IntOp $R1 $R0 & ${SF_SELECTED} StrCmp $R1 ${SF_SELECTED} +5 IntOp $R0 $R0 | ${SF_SELECTED} SectionSetFlags ${${SecName}} $R0 StrCpy $${SecName}_state ${SF_SELECTED} Call select_${SecName}_dependencies !macroend !macro DeclareStates SecName Var ${SecName}_state !macroend !macro InitStates SecName SectionGetFlags ${SecName} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCpy $${SecName}_state 0 !macroend !macro InitSection SecName ClearErrors ReadRegDWORD $AR_RegFlags HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed" IfErrors "default_${SecName}" IntOp $AR_RegFlags $AR_RegFlags & 0x0001 SectionGetFlags ${${SecName}} $AR_SecFlags IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags SectionSetFlags ${${SecName}} $AR_SecFlags "default_${SecName}:" !macroend !macro FinishSection SecName SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags IntOp $AR_SecFlags $AR_SecFlags & 0x0001 IntCmp $AR_SecFlags 1 "leave_${SecName}" !insertmacro "Remove_${${SecName}}" WriteRegDWORD HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed" 0 Goto "exit_${SecName}" "leave_${SecName}:" WriteRegDWORD HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed" 1 "exit_${SecName}:" !macroend !macro RemoveSection SecName !insertmacro "Remove_${${SecName}}" !macroend !define InstFile "sigen.exe" OutFile "${InstFile}" !define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\ \Sigma Game Engine" InstallDir "$PROGRAMFILES\Sigma Game Engine" Name "Sigma Game Engine" ComponentText "Check the components you want to add and uncheck the components you want to remove:" ShowInstDetails show ShowUnInstDetails show Section "Required Section" SectionIn RO CreateDirectory $INSTDIR WriteUninstaller "$INSTDIR\Uninstall.exe" WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayName" "Sigma Game Engine" WriteRegStr HKLM "${REG_UNINSTALL}" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr HKLM "${REG_UNINSTALL}" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayIcon" "$INSTDIR\sigen.png" WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayVersion" "0.0.2" WriteRegStr HKLM "${REG_UNINSTALL}" "Publisher" "Nerdy Productions" WriteRegStr HKLM "${REG_UNINSTALL}" "InstallSource" "$EXEDIR\" WriteRegStr HKLM "${REG_UNINSTALL}" "HelpLink" "http://www.sourceforge.net/projects/sigen" WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoModify" 0 WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoRepair" 0 WriteRegStr HKLM "${REG_UNINSTALL}" "Comments" "The Sigma Geme Engine is an RPG/Strategy game engine inspired by the original Pokémon™ Games" WriteRegStr HKLM "${REG_UNINSTALL}" "ModifyPath" '"$EXEDIR\${InstFile}"' SectionEnd Section /o "Common sources" common_src DetailPrint "*** Installing common sources..." setOutPath "$INSTDIR\src" CreateDirectory "$INSTDIR\src" file CMakeLists.txt file cross-mingw32.cmake file cross-mingw32-sigen.sh file headers.pri file install.pri file kde4.pri file latex.cmake file latex.pri file LICENSE file sigen.pro file version.pri SectionEnd !macro Remove_${common_src} DetailPrint "*** Removing common sources..." RMDir /R "$INSTDIR\src" !macroend Section /o "Sigmod" sigmod_bin DetailPrint "*** Installing Sigmod..." setOutPath "$INSTDIR\bin" CreateDirectory "$INSTDIR\bin" file bin/sigmod0.dll SectionEnd !macro Remove_${sigmod_bin} DetailPrint "*** Removing Sigmod..." Delete "$INSTDIR\bin\sigmod0.dll" !macroend Section /o "Sigmod sources" sigmod_src DetailPrint "*** Installing Sigmod sources..." setOutPath "$INSTDIR\src\sigmod" CreateDirectory "$INSTDIR\src\sigmod" file sigmod/CMakeLists.txt file sigmod/sigmod.pro file sigmod/TODO file sigmod/*.h file sigmod/*.cpp SectionEnd !macro Remove_${sigmod_src} DetailPrint "*** Removing Sigmod sources..." RMDir /R "$INSTDIR\src\sigmod" !macroend Section /o "Sigscript" sigscript_bin DetailPrint "*** Installing Sigscript..." setOutPath "$INSTDIR\bin" CreateDirectory "$INSTDIR\bin" file bin/sigscript0.dll SectionEnd !macro Remove_${sigscript_bin} DetailPrint "*** Removing Sigscript..." Delete "$INSTDIR\bin\sigscript0.dll" !macroend Section /o "Sigscript sources" sigscript_src DetailPrint "*** Installing Sigscript sources..." setOutPath "$INSTDIR\src\sigscript" CreateDirectory "$INSTDIR\src\sigscript" file sigscript/CMakeLists.txt file sigscript/sigscript.pro file sigscript/TODO file sigscript/*.h file sigscript/*.cpp SectionEnd !macro Remove_${sigscript_src} DetailPrint "*** Removing Sigscript sources..." RMDir /R "$INSTDIR\src\sigscript" !macroend Section /o "Sigbattle" sigbattle_bin DetailPrint "*** Installing Sigbattle..." setOutPath "$INSTDIR\bin" CreateDirectory "$INSTDIR\bin" file bin/sigbattle0.dll SectionEnd !macro Remove_${sigbattle_bin} DetailPrint "*** Removing Sigbattle..." Delete "$INSTDIR\bin\sigbattle0.dll" !macroend Section /o "Sigbattle sources" sigbattle_src DetailPrint "*** Installing Sigbattle sources..." setOutPath "$INSTDIR\src\sigbattle" CreateDirectory "$INSTDIR\src\sigbattle" file sigbattle/CMakeLists.txt file sigbattle/sigbattle.pro file sigbattle/TODO file sigbattle/*.h file sigbattle/*.cpp SectionEnd !macro Remove_${sigbattle_src} DetailPrint "*** Removing Sigbattle sources..." RMDir /R "$INSTDIR\src\sigbattle" !macroend Section /o "Sigmodr" sigmodr_bin DetailPrint "*** Installing Sigmodr..." setOutPath "$INSTDIR\bin" CreateDirectory "$INSTDIR\bin" file bin/sigmodr.exe setOutPath "$INSTDIR\doc" CreateDirectory "$INSTDIR\doc" file doc/sigmodr.pdf setOutPath "$INSTDIR" ; TODO: Where to put this? :( file sigmodr/sigmodrui.rc file sigmod.knsrc SectionEnd !macro Remove_${sigmodr_bin} DetailPrint "*** Removing Sigmodr..." Delete "$INSTDIR\bin\sigmodr.exe" Delete "$INSTDIR\doc\sigmodr.pdf" Delete "$INSTDIR\sigmodrui.rc" Delete "$INSTDIR\sigmod.knsrc" !macroend Section /o "Sigmodr Sources" sigmodr_src DetailPrint "*** Installing Sigmodr sources..." setOutPath "$INSTDIR\src\sigmodr" CreateDirectory "$INSTDIR\src\sigmodr" file sigmodr/CMakeLists.txt file sigmodr/sigmodr.pro file sigmodr/sigmodr.tex file sigmodr/TODO file sigmodr/*.h file sigmodr/*.cpp file sigmodr/models/*.h file sigmodr/models/*.cpp file sigmodr/gui/*.ui file sigmodr/overlays/*.png file sigmodr/overlays/*.qrc SectionEnd !macro Remove_${sigmodr_src} DetailPrint "*** Removing Sigmodr sources..." RMDir /r "$INSTDIR\src\sigmodr" !macroend !macro SectionList MacroName !insertmacro "${MacroName}" "common_src" !insertmacro "${MacroName}" "sigmod_bin" !insertmacro "${MacroName}" "sigmod_src" !insertmacro "${MacroName}" "sigscript_bin" !insertmacro "${MacroName}" "sigscript_src" !insertmacro "${MacroName}" "sigbattle_bin" !insertmacro "${MacroName}" "sigbattle_src" !insertmacro "${MacroName}" "sigmodr_bin" !insertmacro "${MacroName}" "sigmodr_src" !macroend !insertmacro SectionList "DeclareStates" Function .onInit !insertmacro SectionList "InitStates" !insertmacro SectionList "InitSection" FunctionEnd Function deselect_common_src_dependents !insertmacro UnselectDependent sigmod_src FunctionEnd Function deselect_sigmod_src_dependents !insertmacro UnselectDependent sigmodr_src !insertmacro UnselectDependent sigscript_src FunctionEnd Function deselect_sigscript_src_dependents !insertmacro UnselectDependent sigbattle_src FunctionEnd Function deselect_sigbattle_src_dependents FunctionEnd Function deselect_sigmodr_src_dependents FunctionEnd Function deselect_sigmod_bin_dependents !insertmacro UnselectDependent sigmodr_bin !insertmacro UnselectDependent sigscript_bin FunctionEnd Function deselect_sigscript_bin_dependents !insertmacro UnselectDependent sigbattle_bin FunctionEnd Function deselect_sigbattle_bin_dependents FunctionEnd Function deselect_sigmodr_bin_dependents FunctionEnd Function select_common_src_dependencies FunctionEnd Function select_sigmod_src_dependencies !insertmacro SelectDependency common_src FunctionEnd Function select_sigscript_src_dependencies !insertmacro SelectDependency sigmod_src FunctionEnd Function select_sigbattle_src_dependencies !insertmacro SelectDependency sigscript_src FunctionEnd Function select_sigmodr_src_dependencies !insertmacro SelectDependency sigmod_src FunctionEnd Function select_sigmod_bin_dependencies FunctionEnd Function select_sigscript_bin_dependencies !insertmacro SelectDependency sigmod_bin FunctionEnd Function select_sigbattle_bin_dependencies !insertmacro SelectDependency sigscript_bin FunctionEnd Function select_sigmodr_bin_dependencies !insertmacro SelectDependency sigmod_bin FunctionEnd Function .onSelChange Push $R0 Push $R1 !insertmacro SectionList CheckDependencies Pop $R1 Pop $R0 FunctionEnd Section -FinishComponents !insertmacro SectionList "FinishSection" SectionEnd Section -Post ExecShell "open" "$INSTDIR" SectionEnd Section Uninstall !insertmacro SectionList "RemoveSection" RMDIR /r $INSTDIR DeleteRegKey HKLM "${REG_UNINSTALL}" SectionEnd