Installers

F4Browse, CATE, Tacedit, Terrainview & TheaterMaker etc utility related

Moderators: Lone Wolf, Snake Man

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-06-12 20:53:27

Impressive work, guys. Thanks to your effort I could make an installer for our theater. In addition to the installer I wanted to add the option to uninstall, but it did not. Can you help me?

Working with NSIS,

The scricpt is:

Code: Select all

!define TNAME "spain"
!define FRIENDLYNAME "F4Spain Beta Spain"
!define APP "SpainBetaInstalador"
;for some reason, this has to be #.#.#.# but I usually change the name after I build the exe
!define VER "0.5.0.0"

; define other variables to free up generic ones
var F4root
var ErrCode
var F4ver
var F4subver

; these establish some things about the installer the most important one to me is the outfile
Name "${FRIENDLYNAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "Spain Beta_v${VER}.exe"
Caption "${FRIENDLYNAME}"
; these VI definitions are what is displayed if you hover the mouse over the icon
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${FRIENDLYNAME}"
VIAddVersionKey Comments "Instalar el Teatro de Operaciones Beta Spain."
VIAddVersionKey LegalCopyright "F4Spain"
VIAddVersionKey FileDescription "${FRIENDLYNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${FRIENDLYNAME}"

;=== Runtime Switches
; the CRC check is something I use on bigger installers to make sure everything checks out.
CRCCheck On
; this makes it more efficient
AutoCloseWindow True
; this is something I use to make sure it uses the LZMA compression, which I believe is the best
SetCompressor lzma
; branding text is just something that's displayed at the bottom of the installer
BrandingText "http://f4spain-g-sims.com"

;=== Includes - this will include the necessary dlls and functions that I use in the installer
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "Registry.nsh"
!include "WinMessages.nsh"
!include "TextFunc.nsh"
!include "Sections.nsh"

; MUI Settings - the MUI is the Modern UI for NSIS, this section defines its parameters (there are alot more that I don't use)
!define MUI_ABORTWARNING
!define MUI_INSTALLCOLORS /windows

; Welcome page - this is the first page of the installer (I also have a snippet for a splashscreen, but we'll keep this simple)
;!define MUI_WELCOMEFINISHPAGE_BITMAP "@@:\FF4Installers\leftgraphic.bmp"
; using the variables means we don't have to remember to change all these when we use the template for another theater
!define MUI_WELCOMEFINISHPAGE_BITMAP "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\banner.bmp"
!define MUI_WELCOMEPAGE_TITLE "${FRIENDLYNAME} ${VER} Asistente de configuración"
!define MUI_WELCOMEPAGE_TEXT "El configurador instalará ${FRIENDLYNAME} ${VER} en tu instalación de Falcon."
!insertmacro MUI_PAGE_WELCOME

!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\EULA.txt"



; Instfiles page
!define MUI_FINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_PAGE_INSTFILES
; Finish page - this is the last page people see
!define MUI_FINISHPAGE_TITLE "${FRIENDLYNAME} ${VER} Instalación completada."
!define MUI_FINISHPAGE_TEXT "Click en 'Terminar' para cerrar el asistente."
!insertmacro MUI_PAGE_FINISH

;Desinstalacion
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH



; Language files
!insertmacro MUI_LANGUAGE "Spanish"
; MUI end ------

; now we're ready for the actual installer!
Section "Installer" SEC01

; F4registry check - if no F4 registry, it kicks to the end - the $0 is a variable that holds the -1 (not found) or 0 (found)
; we can also start to determine which install we have
${registry::KeyExists} "HKLM\Software\MicroProse\Falcon\4.0" $0
${registry::KeyExists} "HKLM\Software\Lead Pursuit\Battlefield Operations\Falcon" $1
; IntCmp compares the integer in $0 with our number (0) and if it is =, it goes to label "F4Exists"
IntCmp $0 0 F4Exists
IntCmp $1 0 AFInstall
; this copies the string to $ErrCode - I'm using that as an error label
StrCpy $ErrCode "Registro encontrado no adecuado."
Goto Error

F4Exists:
; this determines if there's an AF reg entry, and if so, it only advances 1 line, if not, it goes to F4Install
IntCmp $1 0 0 F4Version

; at this point, we need to determine if the person wants to install over "original" F4 or RV

Messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "" "Selecciona donde quieres instalar el teatro" "OF/RV" "AF" IDCANCEL
; this places the response 1, 2, or 3, into $0
Pop $0
IntCmp $0 3 Finish
IntCmp $0 2 AFInstall

F4Version:
; now we know they want OF/RV so we need to differentiate - I'm only going to look for RV, if it isn't RV, I'm going to assume OF for now
; this will also validate the install a bit
; this reads the specified registry value into $0
ReadRegStr $F4root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
; if the file exists, go to next line (don't skip a line) if it doesn't, go to label "NoFileFound"
IfFileExists $F4root\theater.lst 0 NoFileFound
IfFileExists $F4root\terrdata\objects\KoreaObj.Dxl RVFound
IfFileExists $F4root\terrdata\objects\KoreaObj.lod OFFound NoFileFound

NoFileFound:
StrCpy $ErrCode "No se ha encontrado la instalación de Falcon."
Goto Error

; I want to set up a variable to differentiate OF and RV
RVFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "RV"
Goto F4Install

OFFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "OF"
Goto F4Install

AFInstall:
; get the AF base directory into a variable
ReadRegStr $F4Root HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
; sets the right campaign directory
StrCpy $1 "$F4Root\campaign\korea" ; campaing\save string
StrCpy $2 "$F4Root\Theaters\${TNAME}\utilidades\LxNormalFix.exe $$LP @${TNAME} @$F4Root\Theaters\${TNAME}\terrdata" ; lxnormalfix string
StrCpy $F4Ver "AF"
Goto CreateDirs

F4Install:
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$F4Root\Theaters\${TNAME}\utilidades\LxNormalFix.exe @${TNAME} @$F4Root\Theaters\${TNAME}\terrdata"

CreateDirs:
SetOutPath $F4Root
CreateDirectory "$F4Root\Theaters\${TNAME}\campaign\spain1"
CreateDirectory "$F4Root\Theaters\${TNAME}\terrdata\weather\"
CreateDirectory "$F4Root\Theaters\${TNAME}\objects\"

SetOutPath "$F4root\Theaters\${TNAME}"

; new intelligent campaing copy files list
CopyFiles /filesonly "$1\*.pri" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.txt" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.b" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.db" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.ia" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.dfs" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.gbd" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.lst" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.idx" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\*.wch" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\atc.ini" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\falcon4.aii" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\falcon4.rt" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\falcon4.tt" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
CopyFiles /filesonly "$1\validac.*" "$F4Root\Theaters\${TNAME}\campaign\spain1\"

; database objects (same dir for all versions)
; this needs to be recursively because RV has koreaobj subdir.
CopyFiles "$F4Root\terrdata\objects\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$F4Root\Theaters\${TNAME}\terrdata\weather\"

; unpack the theater files
; this is the subdir in the developer's PC that has the files for AF
File /r "F:\F4SPAIN\BETAS\THEATERS\spain\*.*"


; common campaign dirs
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\common\*.*" "$F4Root\Theaters\${TNAME}\campaign\spain1\"

; database copy
StrCmp $F4subver "OF" DataBaseOF
StrCmp $F4subver "RV" DataBaseRV

; UI AF
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-AF\*.*" "$F4Root\Theaters\${TNAME}\art\art\"
; database AF
CopyFiles "$F4Root\Theaters\${TNAME}\objects\AF\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-AF\*.*" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
goto EndOfDataBaseCopy

DataBaseOF:
; UI OF
; copy only one \art\ as we have the art1024 dir there too, heh hmm.
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-OF\*.*" "$F4Root\Theaters\${TNAME}\art\"
; database OF
CopyFiles "$F4Root\Theaters\${TNAME}\objects\OF\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-OF\*.*" "$F4Root\Theaters\${TNAME}\campaign\spain1\"
goto EndOfDataBaseCopy

DataBaseRV:
; UI RV
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-RV\*.*" "$F4Root\Theaters\${TNAME}\art\art\"
; database RV
CopyFiles "$F4Root\Theaters\${TNAME}\objects\RV\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\spain1\"


EndOfDataBaseCopy:
RMDir /r "$F4Root\Theaters\${TNAME}\objects\AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common\"

; end of falcon version DATABASE & UI


StrCmp $F4ver "F4" F4curTheater TheaterAdmin

StrCpy $ErrCode "Unknown error before curTheater: $F4ver."
Goto Error

F4curTheater:
; set current theater to new theater
; this reads the specified registry value into $3 for use later
ReadRegStr $3 HKLM "Software\MicroProse\Falcon\4.0" "curTheater"
${registry::Write} "hklm\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "Operation Desert Storm" "REG_SZ" $R0

; if it is an OF install, skip straight to theater admin otherwise, do RV stuff
StrCmp $F4subver "OF" TheaterAdmin

; this will be the area where we do stuff that it doesn't really matter which install it is
TheaterAdmin:
SetOutPath "$F4Root\Theaters\${TNAME}\utilidades"

; plus additional two lstupdate entries
ExecWait "$F4Root\Theaters\${TNAME}\utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}.tdf"
ExecWait '$F4Root\Theaters\${TNAME}\utilidades\SPTinstall.exe -auto "$F4Root\Theaters\${TNAME}\terrdata"'
ExecWait "$F4Root\Theaters\${TNAME}\utilidades\LxNormalFix.exe $2"

; just compress textures if F4 then finish
StrCmp $F4ver "AF" Finish
ExecWait "$F4Root\Utilities\utilidades\SeasonSwitcher.exe -0"
MessageBox MB_YESNO "¿Quieres hacer que este teatro sea el por defecto?" IDYES Finish IDNO OldReg
OldReg:
${registry::Write} "hklm\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "$3" "REG_SZ" $R0

SetOutPath "$F4Root"



;Creo mi desinstalador
WriteUninstaller "$F4Root\Theaters\${TNAME}\Desinstalar.exe"



SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manualdelusuario_BetaSpain.lnk" "$F4Root\Theaters\${TNAME}\Manuales\Manualdelusuario.pdf"
CreateShortCut "$DESKTOP\Desinstalar_Beta_Spain.lnk" "$F4Root\Theaters\${TNAME}\Desinstalar.exe"
RMDir /r "$F4Root\Theaters\${TNAME}\utilidades\"
Goto Finish

Error:
Messagebox MB_OK $ErrCode

Finish:

SectionEnd

;--------------------------------
;Seccion de desinstalacion

Section "Uninstall"

Delete "$F4Root\Theaters\${TNAME}\*.*"
RMDir  "$F4Root\Theaters\${TNAME}\"
Delete "$DESKTOP\Desinstalar_Beta_Spain.lnk"
Delete "$DESKTOP\Manualdelusuario_BetaSpain.lnk"


SectionEnd


Establishing Desisntalar.exe (uninstall.exe) but it does not works.

Cordialmente,

Image

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-10-08 18:48:37

We have updated the installer of our theater.
You could create a script for removal of the theater installed? Any idea?

Code: Select all


!define TNAME "nombre reducido del teatro"
!define FRIENDLYNAME "Nombre del teatro"
!define APP "Instalador"
;for some reason, this has to be #.#.#.# but I usually change the name after I build the exe
!define VER "0.5.0.0"

; define other variables to free up generic  ones
var F4root
var ErrCode
var F4ver
var F4subver

; these establish some things about the installer the most important one to me is the outfile
Name "${FRIENDLYNAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "Nombre del ejecutable_v${VER}.exe"
Caption "${FRIENDLYNAME}"
; these VI definitions are what is displayed if you hover the mouse over the icon
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${FRIENDLYNAME}"
VIAddVersionKey Comments "Comentarios"
VIAddVersionKey LegalCopyright "F4Spain"
VIAddVersionKey FileDescription "${FRIENDLYNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${FRIENDLYNAME}"

;=== Runtime Switches
; the CRC check is something I use on bigger installers to make sure everything checks out.
CRCCheck On
; this makes it more efficient
AutoCloseWindow True
; this is something I use to make sure it uses the LZMA compression, which I believe is the best
SetCompressor lzma
; branding text is just something that's displayed at the bottom of the installer
BrandingText "Página web"

;=== Includes - this will include the necessary dlls and functions that I use in the installer
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "Registry.nsh"
!include "WinMessages.nsh"
!include "TextFunc.nsh"
!include "Sections.nsh"

; MUI Settings - the MUI is the Modern UI for NSIS, this section defines its parameters (there are alot more that I don't use)
!define MUI_ABORTWARNING
!define MUI_INSTALLCOLORS /windows

; Welcome page - this is the first page of the installer (I also have a snippet for a splashscreen, but we'll keep this simple)
;!define MUI_WELCOMEFINISHPAGE_BITMAP "@@:\FF4Installers\leftgraphic.bmp"
; using the variables means we don't have to remember to change all these when we use the template for another theater
!define MUI_WELCOMEFINISHPAGE_BITMAP "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\banner.bmp"
!define MUI_WELCOMEPAGE_TITLE "${FRIENDLYNAME} ${VER} Asistente de configuración"
!define MUI_WELCOMEPAGE_TEXT "El configurador instalará ${FRIENDLYNAME} ${VER} en tu instalación de Falcon."
!insertmacro MUI_PAGE_WELCOME

!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\EULA.txt"



; Instfiles page
!define MUI_FINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_PAGE_INSTFILES
; Finish page - this is the last page people see
!define MUI_FINISHPAGE_TITLE "${FRIENDLYNAME} ${VER} Instalación completada."
!define MUI_FINISHPAGE_TEXT "Click en 'Terminar' para cerrar el asistente."
!insertmacro MUI_PAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "Spanish"
; MUI end ------

; now we're ready for the actual installer!
Section "Installer" SEC01

; F4registry check - if no F4 registry, it kicks to the end - the $0 is a variable that holds the -1 (not found) or 0 (found)
; we can also start to determine which install we have
${registry::KeyExists} "HKLM\Software\MicroProse\Falcon\4.0" $0
${registry::KeyExists} "HKLM\Software\Lead Pursuit\Battlefield Operations\Falcon" $1
; IntCmp compares the integer in $0 with our number (0) and if it is =, it goes to label "F4Exists"
IntCmp $0 0 F4Exists
IntCmp $1 0 AFInstall
; this copies the string to $ErrCode - I'm using that as an error label
StrCpy $ErrCode "Registro encontrado no adecuado."
Goto Error

F4Exists:
; this determines if there's an AF reg entry, and if so, it only advances 1 line, if not, it goes to F4Install
IntCmp $1 0 0 F4Version

; at this point, we need to determine if the person wants to install over "original" F4 or RV

Messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "" "Selecciona donde quieres instalar el teatro" "OF/RV" "AF" IDCANCEL
; this places the response 1, 2, or 3, into $0
Pop $0
IntCmp $0 3 Finish
IntCmp $0 2 AFInstall

F4Version:
; now we know they want OF/RV so we need to differentiate - I'm only going to look for RV, if it isn't RV, I'm going to assume OF for now
; this will also validate the install a bit
; this reads the specified registry value into $0
ReadRegStr $F4root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
; if the file exists, go to next line (don't skip a line) if it doesn't, go to label "NoFileFound"
IfFileExists $F4root\theater.lst 0 NoFileFound
IfFileExists $F4root\terrdata\objects\KoreaObj.Dxl RVFound
IfFileExists $F4root\terrdata\objects\KoreaObj.lod OFFound NoFileFound

NoFileFound:
StrCpy $ErrCode "No se ha encontrado la instalación de Falcon. Selecciona la versión que tengas instalada: AF/OF/RV"
Goto Error

; I want to set up a variable to differentiate OF and RV
RVFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "RV"
Goto F4Install

OFFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "OF"
Goto F4Install

AFInstall:
; get the AF base directory into a variable
ReadRegStr $F4Root HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
; sets the right campaign directory
StrCpy $1 "$F4Root\campaign\korea" ; campaing\save string
StrCpy $2 "$F4Root\Theaters\${TNAME}\utilidades\LxNormalFix.exe $$LP @${TNAME} @$F4Root\Theaters\${TNAME}\terrdata" ; lxnormalfix string
StrCpy $F4Ver "AF"
Goto CreateDirs

F4Install:
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$F4Root\Theaters\${TNAME}\utilidades\LxNormalFix.exe @${TNAME} @$F4Root\Theaters\${TNAME}\terrdata"

CreateDirs:
SetOutPath $F4Root
CreateDirectory "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1"
CreateDirectory "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2"
CreateDirectory "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3"
CreateDirectory "$F4Root\Theaters\${TNAME}\terrdata\weather\"
CreateDirectory "$F4Root\Theaters\${TNAME}\objects\"

SetOutPath "$F4root\Theaters\${TNAME}"

; new intelligent campaing copy files list
CopyFiles /filesonly "$1\*.pri" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.txt" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.b" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.db" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.ia" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.dfs" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.gbd" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.lst" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.idx" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.wch" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\atc.ini" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.aii" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.rt" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.tt" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\validac.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"

; database objects (same dir for all versions)
; this needs to be recursively because RV has koreaobj subdir.
CopyFiles "$F4Root\terrdata\objects\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$F4Root\Theaters\${TNAME}\terrdata\weather\"

; then copy it to the two another campaign dirs
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"

CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$F4Root\Theaters\${TNAME}\terrdata\weather\"


; unpack the theater files
; this is the subdir in the developer's PC that has the files for AF
File /r "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\*.*"

;COMMON campaign files
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\common\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\common\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles /filesonly "$F4Root\Theaters\${TNAME}\campaign\common\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"

; beginning of falcon version DATABASE & UI

; database copy
StrCmp $F4subver "OF" DataBaseOF
StrCmp $F4subver "RV" DataBaseRV

; UI AF
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-AF\*.*" "$F4Root\Theaters\${TNAME}\art\art\"
; database AF
CopyFiles "$F4Root\Theaters\${TNAME}\objects\AF\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-AF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-AF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-AF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"
goto EndOfDataBaseCopy

DataBaseOF:
; UI OF
; copy only one \art\ as we have the art1024 dir there too, heh hmm.
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-OF\*.*" "$F4Root\Theaters\${TNAME}\art\"
; database OF
CopyFiles "$F4Root\Theaters\${TNAME}\objects\OF\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-OF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-OF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-OF\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"
goto EndOfDataBaseCopy

DataBaseRV:
; UI RV
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-RV\*.*" "$F4Root\Theaters\${TNAME}\art\art\"
; database RV
CopyFiles "$F4Root\Theaters\${TNAME}\objects\RV\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"

EndOfDataBaseCopy:
RMDir /r "$F4Root\Theaters\${TNAME}\objects\AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common\"


; end of falcon version DATABASE & UI


StrCmp $F4ver "F4" F4curTheater TheaterAdmin

StrCpy $ErrCode "Unknown error before curTheater: $F4ver."
Goto Error

F4curTheater:
; set current theater to new theater 
; this reads the specified registry value into $3 for use later
ReadRegStr $3 HKLM "Software\MicroProse\Falcon\4.0" "curTheater"
${registry::Write} "HKEY_LOCAL_MACHINE\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "${TNAME}1" "REG_SZ" $R0

; if it is an OF install, skip straight to theater admin otherwise, do RV stuff
StrCmp $F4subver "OF" TheaterAdmin

; this will be the area where we do stuff that it doesn't really matter which install it is
TheaterAdmin:
SetOutPath "$F4Root\Theaters\${TNAME}\utilidades"

; plus additional two lstupdate entries
ExecWait "$F4Root\Theaters\${TNAME}\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$F4Root\Theaters\${TNAME}\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$F4Root\Theaters\${TNAME}\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}3.tdf"
ExecWait '$F4Root\Theaters\${TNAME}\Utilidades\SPTinstall.exe -auto "$F4Root\Theaters\${TNAME}\terrdata"'
ExecWait '$F4Root\Theaters\${TNAME}\Utilidades\BaZT-SRTM-Theater.exe "$F4Root" "$F4Root\Theaters\${TNAME}\terrdata"'
ExecWait "$F4Root\Theaters\${TNAME}\Utilidades\LxNormalFix.exe $2"



; just compress textures if F4 then finish
StrCmp $F4ver "AF" Prefinish


; conversión a DDS
ExecWait "$F4Root\Theaters\${TNAME}\utilidades\SeasonSwitcher.exe -0"

; el anterior teatro activo vuelve a activarse. Se deja su instalación de Falcon tal como estaba.
${registry::Write} "hklm\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "$3" "REG_SZ" $R0

;Para crear un enlace directo en el escritorio al Manual del usuario.
Prefinish:
MessageBox MB_YESNO "¿Deseas un enlace en el escritorio al Manual del usuario?" IDYES Enlace IDNO Clear
Enlace:
SetOutPath "$F4Root"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manualdelusuario_BetaSpain.lnk" "$F4Root\Theaters\${TNAME}\Manuales\Manualdelusuario.pdf"
StrCmp $F4ver "F4" Clear
StrCmp $F4ver "AF" Clear

Clear:
; Se borran las carpetas que ya no se usarán
RMDir /r "$F4Root\Theaters\${TNAME}\Utilidades\"
StrCmp $F4ver "F4" Finish
StrCmp $F4ver "AF" Finish

Error:
Messagebox MB_OK $ErrCode

Finish:
SectionEnd
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-10-08 21:21:22

My uninstaller,

Get to remove the links but did not erase the installation folder of the theater:


Code: Select all


...


;DESINSTALACIÓN-------------------------
CreateShortCut "$DESKTOP\Desinstalar ${TNAME}.lnk" "$F4Root\Theaters\${TNAME}\Desinstalar.exe"

; Escribimos los registros de instalación dentro del directorio del registro
WriteRegStr HKLM SOFTWARE\${TNAME} "Install_Dir" "$F4Root\Theaters\${TNAME}"
; Escribimos las claves de desinstalación de Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TNAME}" "DisplayName" "${FRIENDLYNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TNAME}" "UninstallString" '"$F4Root\Theaters\${TNAME}\Desinstalar.exe"'
;Creo mi desinstalador
WriteUninstaller "$F4Root\Theaters\${TNAME}\Desinstalar.exe"
;----------------------------------------


;Para el final
StrCmp $F4ver "F4" Finish
StrCmp $F4ver "AF" Finish



Error:
Messagebox MB_OK $ErrCode

Finish:
SectionEnd


;--------------------------------
;Seccion de desinstalacion

Section "Uninstall"


; Remover las claves del Registro
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${TNAME}"
DeleteRegKey HKLM "SOFTWARE\${TNAME}"
Delete "$DESKTOP\Desinstalar ${TNAME}.lnk"
Delete "$DESKTOP\Manualdelusuario ${TNAME}.lnk"
Delete "$F4Root\Theaters\${TNAME}\*.*"
RMDir  "$F4Root\Theaters\${TNAME}"


SectionEnd


Here is the problem. Can not delete folders containing ... okay ...


Code: Select all

Delete "$F4Root\Theaters\${TNAME}\*.*"
RMDir  "$F4Root\Theaters\${TNAME}"

But if you attempt to delete a single file of my installation also works Theater. Ignores the rule.

Code: Select all

DeleteRegKey HKLM "SOFTWARE\${TNAME}"   ------------> OK!!!
Delete "$DESKTOP\Desinstalar ${TNAME}.lnk"  ------------> OK!!!           
Delete "$DESKTOP\Manualdelusuario ${TNAME}.lnk"  ------------> OK!!!
Delete "$F4Root\Theaters\${TNAME}\version.txt"   ------------> IGNORE!!!FAILED



Any idea.
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

User avatar
Phoenix711
Captain
Posts: 186
Joined: 2007-10-03 07:52:29
Location: Istanbul Turkey
Contact:

Post by Phoenix711 » 2008-10-10 05:01:34

is $F4ROOT Correct?

Does your F4 installation directory include SPACE character?

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-10-10 07:19:44

A good question.
so is.

The "$F4Root" is:

Code: Select all

E:\Juegos\Falcon AF\

The directory of installation of the theater is:

Code: Select all

E:\Juegos\Falcon AF\Theaters\POH
... in my PC.

you mean the uninstaller will only work if the installation path there are no spaces. How can I fix this pitfall?
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Post by Snake Man » 2008-10-10 08:34:50

Its been said many times, never ever use spaces in file / path names or other non supported characters.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

User avatar
Phoenix711
Captain
Posts: 186
Joined: 2007-10-03 07:52:29
Location: Istanbul Turkey
Contact:

Post by Phoenix711 » 2008-10-10 12:40:42

Install AF to a directory without spaces in its name.

Correct

c:\FalconAF

or

d:\Sims\FalconAF



but not like

Wrong

c:\program files\FalconAF

or

c:\Falcon AF

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-10-10 13:03:20

During the installation the installer remove files and directory with spaces (in my theater:E:\Juegos\Falcon AF\Theaters\POH)

Code: Select all


...
DataBaseRV:
; UI RV
CopyFiles "$F4Root\Theaters\${TNAME}\art\art-RV\*.*" "$F4Root\Theaters\${TNAME}\art\art\"
; database RV
CopyFiles "$F4Root\Theaters\${TNAME}\objects\RV\*.*" "$F4Root\Theaters\${TNAME}\objects\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}1\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}2\"
CopyFiles "$F4Root\Theaters\${TNAME}\campaign\common-RV\*.*" "$F4Root\Theaters\${TNAME}\campaign\${TNAME}3\"

EndOfDataBaseCopy:
RMDir /r "$F4Root\Theaters\${TNAME}\objects\AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\objects\OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\art\art-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-AF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-OF\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common-RV\"
RMDir /r "$F4Root\Theaters\${TNAME}\campaign\common\"


; end of falcon version DATABASE & UI
These folders are deleted without any problems, actually

The idea is:

NSIS can to create a installator that can to install the theater into a directory with spaces. And can even delete files in those folders during the install... only during the install

... but NSIS can not create an unistall that can to uninstall this theater with spaces.

Why?


I dont understand.


I have no problem in removing these spaces in my installation of Falcon AF. But how can I know that all users do not use also space? For these users the uninstaller does not work, then.

No one could add a script to save this obstacle; maybe not with NSIS... I mean: to create the installer with NSIS and the uninstaller with another program. It is possible.
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

INSTALLER/UNINSTALLER FINAL

Post by Joe Labrada » 2008-10-14 22:53:32

Finally, what I got. An uninstaller operating. There have been many hours of research but it works. We can check in the "Pillars of Hercules Theater 0.5.0 Beta." You step by the script if you want to try it ... Do not forget to install the files nsh that loads the script.


Here is everything needed to create the script:
-HM NIS Edit 2.0.3
-NSIS 2.39
-plugins: messagebox v0.98 beta 3
-includes:AdvUninstLog.nsh, Registry.nsh
-POH Theater Beta Script

To install in this order.


To learn how to use the NSIS: Main Page-NSIS


Ahh... The most important thing. Never mind that the installation path has spaces. Works with all.

Code: Select all

!define TNAME "POH"
!define APP_NAME "Pillars of Hercules Theater"
!define APP "POHInstalador"
;for some reason, this has to be #.#.#.# but I usually change the name after I build the exe
!define VER "0.5.0.0"
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" 



; define other variables to free up generic  ones
var ErrCode
var F4ver
var F4subver
var F4Root

; these establish some things about the installer the most important one to me is the outfile
Name "${APP_NAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "${APP_NAME} Beta ${VER}.exe"
Caption "${APP_NAME}"
; these VI definitions are what is displayed if you hover the mouse over the icon
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${APP_NAME}"
VIAddVersionKey Comments "Teatro de Operaciones ${TNAME} (${APP_NAME}) desarrollado por la comunidad."
VIAddVersionKey LegalCopyright "F4Spain/F4Portugal"
VIAddVersionKey FileDescription "${APP_NAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${APP_NAME}"

;=== Runtime Switches
; the CRC check is something I use on bigger installers to make sure everything checks out.
CRCCheck On
; this makes it more efficient
AutoCloseWindow True
; this is something I use to make sure it uses the LZMA compression, which I believe is the best
SetCompressor lzma
; branding text is just something that's displayed at the bottom of the installer
BrandingText "http://f4spain-g-sims.com"







;=== Includes - this will include the necessary dlls and functions that I use in the installer
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "Registry.nsh"
!include "WinMessages.nsh"
!include "TextFunc.nsh"
!include "Sections.nsh"
!include "AdvUninstLog.nsh"

; MUI Settings - the MUI is the Modern UI for NSIS, this section defines its parameters (there are alot more that I don't use)
!define MUI_ABORTWARNING
!define MUI_INSTALLCOLORS /windows


ShowInstDetails nevershow
ShowUninstDetails nevershow
InstallDir "$INSTDIR"
InstallDirRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"


  !insertmacro UNATTENDED_UNINSTALL
  ;!insertmacro INTERACTIVE_UNINSTALL

; Welcome page - this is the first page of the installer (I also have a snippet for a splashscreen, but we'll keep this simple)
;!define MUI_WELCOMEFINISHPAGE_BITMAP "@@:\FF4Installers\leftgraphic.bmp"
; using the variables means we don't have to remember to change all these when we use the template for another theater
!define MUI_WELCOMEFINISHPAGE_BITMAP "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\banner.bmp"
!define MUI_WELCOMEPAGE_TITLE "${APP_NAME} ${VER} Asistente de configuración"
!define MUI_WELCOMEPAGE_TEXT "El configurador instalará ${APP_NAME} ${VER} en tu instalación de Falcon."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\EULA.txt"
!define MUI_LICENSEPAGE_RADIOBUTTONS
; Instfiles page
!define MUI_FINISHPAGE_NOAUTOCLOSE


!insertmacro MUI_PAGE_INSTFILES



; Finish page - this is the last page people see
!define MUI_FINISHPAGE_TITLE "${APP_NAME} ${VER} Instalación completada."
!define MUI_FINISHPAGE_TEXT "Click en 'Terminar' para cerrar el asistente."
!insertmacro MUI_PAGE_FINISH






!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "Spanish"


###########################################################################################
## The code below is what is needed to use my modification (if you want localized messages)
###########################################################################################

!define UNINSTALLOG_LOCALIZE ;if you define this you have to provide language strings to use

LangString UNLOG_HEADER ${LANG_ENGLISH} "=========== Uninstaller Log \
                                         please do not edit this file ==========="
LangString UNLOG_DAT_NOT_FOUND ${LANG_ENGLISH} "${UNINST_DAT} not found, \
                                                unable to perform uninstall."
LangString UNLOG_DEL_FILE ${LANG_ENGLISH} 'Delete File "$R9"?'
LangString UNLOG_DEL_DIR ${LANG_ENGLISH} 'Delete Directory "$R9"?'
LangString UNLOG_EMPTY_DIR ${LANG_ENGLISH} "Previous installation detected at $0.$\n\
                                            Required file ${UNINSTALL_LOG}.dat is missing.$\n$\n\
                                            It is highly recommended to select an \
                                            empty directory and perform a fresh \
                                            installation."
LangString UNLOG_ERROR_LOG ${LANG_ENGLISH} "Error in log ${UNINSTALL_LOG}."
LangString UNLOG_ERROR_CREATE ${LANG_ENGLISH} "Error creating ${UNINSTALL_LOG}."

###########################################################################################
## End my modifications
###########################################################################################
; MUI end ------









; now we're ready for the actual installer!
Section "Pillars of Hercules Theater_v${VER}" SEC01









; F4registry check - if no F4 registry, it kicks to the end - the $0 is a variable that holds the -1 (not found) or 0 (found)
; we can also start to determine which install we have
${registry::KeyExists} "HKLM\Software\MicroProse\Falcon\4.0" $0
${registry::KeyExists} "HKLM\Software\Lead Pursuit\Battlefield Operations\Falcon" $1
; IntCmp compares the integer in $0 with our number (0) and if it is =, it goes to label "F4Exists"
IntCmp $0 0 F4Exists
IntCmp $1 0 AFInstall
; this copies the string to $ErrCode - I'm using that as an error label
StrCpy $ErrCode "Registro encontrado no adecuado."
Goto Error

F4Exists:
; this determines if there's an AF reg entry, and if so, it only advances 1 line, if not, it goes to F4Install
IntCmp $1 0 0 F4Version

; at this point, we need to determine if the person wants to install over "original" F4 or RV

Messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "" "Selecciona donde quieres instalar el teatro" "OF/RV" "AF" IDCANCEL
; this places the response 1, 2, or 3, into $0
Pop $0
IntCmp $0 3 Finish
IntCmp $0 2 AFInstall

F4Version:
; now we know they want OF/RV so we need to differentiate - I'm only going to look for RV, if it isn't RV, I'm going to assume OF for now
; this will also validate the install a bit
; this reads the specified registry value into $0
ReadRegStr $INSTDIR HKLM "Software\MicroProse\Falcon\4.0" "basedir"
; if the file exists, go to next line (don't skip a line) if it doesn't, go to label "NoFileFound"
IfFileExists $INSTDIR\theater.lst 0 NoFileFound
IfFileExists $INSTDIR\terrdata\objects\KoreaObj.Dxl RVFound
IfFileExists $INSTDIR\terrdata\objects\KoreaObj.lod OFFound NoFileFound

NoFileFound:
StrCpy $ErrCode "No se ha encontrado la instalación de Falcon. Selecciona la versión que tengas instalada: AF/OF/RV"
Goto Error


RVFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "RV"
Goto RVInstall

OFFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "OF"
Goto F4Install




AFInstall:
ReadRegStr $INSTDIR HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
WriteRegStr HKLM SOFTWARE\${TNAME}-AF "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-AF" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
StrCpy $1 "$F4Root\campaign\korea" ; campaing\save string
StrCpy $2 "$INSTDIR\Theaters\${TNAME}\utilidades\LxNormalFix.exe $$LP @${TNAME} @$INSTDIR\Theaters\${TNAME}\terrdata" ; lxnormalfix string
StrCpy $F4Ver "AF"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "DisplayName" "${APP_NAME}-AF"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "UninstallString" "${UNINST_EXE}"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "HelpLink" "http://f4spain.g-sims.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace1 IDNO Prefinish1
Enlace1:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-AF.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish1:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace2 IDNO CreateDirs
Enlace2:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-AF.lnk" "$INSTDIR\Uninstall.exe"

Goto CreateDirs



RVInstall:
WriteRegStr HKLM SOFTWARE\${TNAME}-RV "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-RV" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$INSTDIR\Theaters\${TNAME}\utilidades\LxNormalFix.exe @${TNAME} @$INSTDIR\Theaters\${TNAME}\terrdata"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "DisplayName" "${APP_NAME}-RV"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "UninstallString" "${UNINST_EXE}"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "HelpLink" "http://f4spain.g-sims.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace3 IDNO Prefinish2
Enlace3:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-RV.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish2:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace4 IDNO CreateDirs
Enlace4:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-RV.lnk" "$INSTDIR\Uninstall.exe"


Goto CreateDirs




F4Install:
WriteRegStr HKLM SOFTWARE\${TNAME}-OF "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-OF" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$INSTDIR\Theaters\${TNAME}\utilidades\LxNormalFix.exe @${TNAME} @$INSTDIR\Theaters\${TNAME}\terrdata"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "DisplayName" "${APP_NAME}-OF"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "UninstallString" "${UNINST_EXE}"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "HelpLink" "http://f4spain.g-sims.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace5 IDNO Prefinish3
Enlace5:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-OF.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish3:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace6 IDNO CreateDirs
Enlace6:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-OF.lnk" "$INSTDIR\Uninstall.exe"










CreateDirs:




SetOutPath $F4Root



CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}1"
CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}2"
CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}3"
CreateDirectory "$F4root\Theaters\${TNAME}\terrdata\weather\"
CreateDirectory "$F4root\Theaters\${TNAME}\objects\"


SetOutPath $INSTDIR
CopyFiles /filesonly "$1\*.pri" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.txt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.b" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.db" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.ia" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.dfs" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.gbd" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.lst" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.idx" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.wch" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\atc.ini" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.aii" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.rt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.tt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\validac.*" "$INSTDIR\campaign\${TNAME}1\"





; database objects (same dir for all versions)
; this needs to be recursively because RV has koreaobj subdir.
CopyFiles "$F4Root\terrdata\objects\*.*" "$INSTDIR\objects\"
CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$INSTDIR\terrdata\weather\"

; then copy it to the two another campaign dirs
CopyFiles /filesonly "$INSTDIR\campaign\${TNAME}1\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles /filesonly "$INSTDIR\campaign\${TNAME}1\*.*" "$INSTDIR\campaign\${TNAME}3\"

CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$INSTDIR\terrdata\weather\"







!insertmacro UNINSTALL.LOG_OPEN_INSTALL

;
;
;
; unpack the theater files
; this is the subdir in the developer's PC that has the files for AF
File /r "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\*.*"
;
;
;
;
;
;

!insertmacro UNINSTALL.LOG_CLOSE_INSTALL





;COMMON campaign files
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}3\"

; beginning of falcon version DATABASE & UI

; database copy
StrCmp $F4subver "OF" DataBaseOF
StrCmp $F4subver "RV" DataBaseRV

; UI AF
CopyFiles "$INSTDIR\art\art-AF\*.*" "$INSTDIR\art\art\"
; database AF
CopyFiles "$INSTDIR\objects\AF\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}3\"
goto EndOfDataBaseCopy

DataBaseOF:
; UI OF
; copy only one \art\ as we have the art1024 dir there too, heh hmm.
CopyFiles "$INSTDIR\art\art-OF\*.*" "$INSTDIR\art\"
; database OF
CopyFiles "$INSTDIR\objects\OF\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}3\"
goto EndOfDataBaseCopy

DataBaseRV:
; UI RV
CopyFiles "$INSTDIR\art\art-RV\*.*" "$INSTDIR\art\art\"
; database RV
CopyFiles "$INSTDIR\objects\RV\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}3\"

EndOfDataBaseCopy:
RMDir /r "$INSTDIR\objects\AF\"
RMDir /r "$INSTDIR\objects\RV\"
RMDir /r "$INSTDIR\objects\OF\"
RMDir /r "$INSTDIR\art\art-AF\"
RMDir /r "$INSTDIR\art\art-RV\"
RMDir /r "$INSTDIR\art\art-OF\"
RMDir /r "$INSTDIR\campaign\common-AF\"
RMDir /r "$INSTDIR\campaign\common-OF\"
RMDir /r "$INSTDIR\campaign\common-RV\"
RMDir /r "$INSTDIR\campaign\common\"


; end of falcon version DATABASE & UI


StrCmp $F4ver "F4" F4curTheater TheaterAdmin

StrCpy $ErrCode "Unknown error before curTheater: $F4ver."
Goto Error

F4curTheater:
; set current theater to new theater PARA QUE POH
; this reads the specified registry value into $3 for use later
ReadRegStr $3 HKLM "Software\MicroProse\Falcon\4.0" "curTheater"
${registry::Write} "HKEY_LOCAL_MACHINE\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "${TNAME}1" "REG_SZ" $R0

; if it is an OF install, skip straight to theater admin otherwise, do RV stuff
StrCmp $F4subver "OF" TheaterAdmin







; this will be the area where we do stuff that it doesn't really matter which install it is


TheaterAdmin:
SetOutPath "$INSTDIR\utilidades"

; plus additional two lstupdate entries
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}3.tdf"
ExecWait '$INSTDIR\Utilidades\SPTinstall.exe -auto "$INSTDIR\terrdata"'
ExecWait '$INSTDIR\Utilidades\BaZT-SRTM-Theater.exe "$INSTDIR" "$INSTDIR\terrdata"'
ExecWait "$INSTDIR\Utilidades\LxNormalFix.exe $2"









; just compress textures if F4 then finish
StrCmp $F4ver "AF" Clear


; conversión a DDS
ExecWait "$INSTDIR\utilidades\SeasonSwitcher.exe -0"

; el anterior teatro activo vuelve a activarse. Se deja su instalación de Falcon tal como estaba.
${registry::Write} "hklm\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "$3" "REG_SZ" $R0





Clear:
; Se borran las carpetas que ya no se usarán
RMDir /r "$INSTDIR\Utilidades\"
StrCmp $F4ver "F4" Finish
StrCmp $F4ver "AF" Finish

Error:
Messagebox MB_OK $ErrCode

Finish:
SectionEnd





Function .onInit
	!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
FunctionEnd

Function .onInstSuccess
	!insertmacro UNINSTALL.LOG_UPDATE_INSTALL
FunctionEnd













Section UnInstall
Messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "" "Confirma correctamente de donde quieres desinstalar el teatro." "AF" "OF" "RV" IDCANCEL
; this places the response 1, 2, or 3, into $0


Pop $0
IntCmp $0 4 Finish
IntCmp $0 3 RVInstall
IntCmp $0 2 OFInstall



;AFInstall
        !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
	!insertmacro UNINSTALL.LOG_UNINSTALL "$APPDATA\${APP_NAME}"
        !insertmacro UNINSTALL.LOG_END_UNINSTALL
        RMDir /r "$INSTDIR\"
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-AF.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-AF.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-AF"
Goto Finish

RVInstall:
        !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
	!insertmacro UNINSTALL.LOG_UNINSTALL "$APPDATA\${APP_NAME}"
        !insertmacro UNINSTALL.LOG_END_UNINSTALL
        RMDir /r "$INSTDIR\"
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-RV.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-RV.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-RV"
Goto Finish
OFInstall:
        !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
	!insertmacro UNINSTALL.LOG_UNINSTALL "$APPDATA\${APP_NAME}"
        !insertmacro UNINSTALL.LOG_END_UNINSTALL
        RMDir /r "$INSTDIR\"
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-OF.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-OF.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-OF"
Finish:
SectionEnd

Function UN.onInit
	!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
FunctionEnd
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

87th_striker
Brig. General
Posts: 467
Joined: 2001-01-02 23:01:01
Location: Oslo, Norway
Contact:

Post by 87th_striker » 2008-10-20 21:36:00

If making the installer possible for WinXp64,

Wndows Registry Editor Version 5.00:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MicroProse]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MicroProse\Falcon]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MicroProse\Falcon\4.0]
"baseDir"="d:\\Falcon4"
"objectDir"="d:\\Falcon4\\terrdata\\objects"
"misctexDir"="d:\\Falcon4\\terrdata\\misctex"
"theaterDir"="d:\\Falcon4\\terrdata\\Korea"
"movieDir"="d:\\Falcon4"
"curTheater"="Korea"
"PilotName"=hex:53,74,72,69,6b,65,72,00,74,00,00,00,00,00,00,00,00,00,00,00
"PilotCallsign"=hex:53,74,72,69,6b,65,72,00,00,00,00,00
"initData"=bla bla bla
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MicroProse\Falcon\4.0\MPR]
"MPRDetect3Dx"=dword:00000001
"MPRDetectCPU"=dword:00000001
"MPRDetectMMX"=dword:00000001
"MPRDetectXMM"=dword:00000001
"MPRGlideDll"="glide2x.dll"
"MPRAllD3DDevices"="FALSE"

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Re: Installers

Post by Joe Labrada » 2008-10-29 08:20:32

The previous uninstaller is obsolete (works if you install the theater in only one version of Falcon. But if we have installed the theater in multiple sites has given me problems). Now I'm working on a new uninstaller, when it is fully tested upload the script.
Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Re: POH Theater Beta 0.5.0 Installer

Post by Joe Labrada » 2008-12-15 16:56:36

The installer / uninstaller of our Pillars of Hercules Theater Beta 0.5.0. Fully functional and tested

Install / Uninstall in one step.

It can be downloaded here. I have included the directories and files that must be put in each folder and program and NSIS edit plugins required.

Are necessary skills in the use of HM NIS Edit to edit it and adapt it to your theater.

Now I'm working on automating the installation/unistall of custom screens "LOADING" and "STAND BY". I also have nearly completed a script to include images as wallpaper that appear as it progresses the installation process. Add these new features in the beta 0.6.0

INSTALLER POH AF/Of/RV

Code: Select all

;DEFINICIÓN DE PARÁMETROS


!define TNAME "POH"
!define APP_NAME "Pillars of Hercules Theater"
!define APP "POHInstalador"
;for some reason, this has to be #.#.#.# but I usually change the name after I build the exe
!define VER "0.5.0.0"
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" 



; define other variables to free up generic  ones
var ErrCode
var F4ver
var F4subver
var F4Root

; these establish some things about the installer the most important one to me is the outfile
Name "${APP_NAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "${APP_NAME} Beta ${VER}.exe"
Caption "${APP_NAME}"
; these VI definitions are what is displayed if you hover the mouse over the icon
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${APP_NAME}"
VIAddVersionKey Comments "Teatro de Operaciones ${TNAME} (${APP_NAME}) desarrollado por la comunidad."
VIAddVersionKey LegalCopyright "F4Spain/F4Portugal"
VIAddVersionKey FileDescription "${APP_NAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${APP_NAME}"

;=== Runtime Switches
; the CRC check is something I use on bigger installers to make sure everything checks out.
CRCCheck On
; this makes it more efficient
AutoCloseWindow True
; this is something I use to make sure it uses the LZMA compression, which I believe is the best
SetCompressor lzma
; branding text is just something that's displayed at the bottom of the installer
BrandingText "www.f4spain.com"


;=== Includes - this will include the necessary dlls and functions that I use in the installer
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "Registry.nsh"
!include "WinMessages.nsh"
!include "TextFunc.nsh"
!include "Sections.nsh"


; MUI Settings - the MUI is the Modern UI for NSIS, this section defines its parameters (there are alot more that I don't use)
!define MUI_ABORTWARNING
!define MUI_INSTALLCOLORS /windows


ShowInstDetails nevershow
InstallDir "$INSTDIR"
InstallDirRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"


; Welcome page - this is the first page of the installer (I also have a snippet for a splashscreen, but we'll keep this simple)
;!define MUI_WELCOMEFINISHPAGE_BITMAP "@@:\FF4Installers\leftgraphic.bmp"
; using the variables means we don't have to remember to change all these when we use the template for another theater
!define MUI_WELCOMEFINISHPAGE_BITMAP "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\banner.bmp"  ;IMAGEN 164X314 PX
!define MUI_WELCOMEPAGE_TITLE "${APP_NAME} ${VER} Asistente de configuración"
!define MUI_WELCOMEPAGE_TEXT "El configurador instalará ${APP_NAME} ${VER} en tu instalación de Falcon."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\EULA.txt"
!define MUI_LICENSEPAGE_RADIOBUTTONS
; Instfiles page
!define MUI_FINISHPAGE_NOAUTOCLOSE


!insertmacro MUI_PAGE_INSTFILES



; Finish page - this is the last page people see
!define MUI_FINISHPAGE_TITLE "${APP_NAME} ${VER} Instalación completada."
!define MUI_FINISHPAGE_TEXT "Click en 'Terminar' para cerrar el asistente."
!insertmacro MUI_PAGE_FINISH


; Language files
!insertmacro MUI_LANGUAGE "Spanish"
AddBrandingImage top 50









;SECCIÓN DE INSTALACIÓN

;SELECCIÓN DE LA INSTALACIÓN



; now we're ready for the actual installer!
Section "Pillars of Hercules Theater_v${VER}" SEC01


;TIENE QUE SER ALARGADA. p.e.: 700x100 px  LA IMAGEN SE ADAPTA
SetBrandingImage /RESIZETOFIT "F:\F4SPAIN\BETAS\BETA 0.5.0\ARCHIVOS_COMPILACION\imagen bottom\bitmap.bmp"

; F4registry check - if no F4 registry, it kicks to the end - the $0 is a variable that holds the -1 (not found) or 0 (found)
; we can also start to determine which install we have
${registry::KeyExists} "HKLM\Software\MicroProse\Falcon\4.0" $0
${registry::KeyExists} "HKLM\Software\Lead Pursuit\Battlefield Operations\Falcon" $1
; IntCmp compares the integer in $0 with our number (0) and if it is =, it goes to label "F4Exists"
IntCmp $0 0 F4Exists
IntCmp $1 0 AFInstall
; this copies the string to $ErrCode - I'm using that as an error label
StrCpy $ErrCode "Registro encontrado no adecuado."
Goto Error


F4Exists:
; this determines if there's an AF reg entry, and if so, it only advances 1 line, if not, it goes to F4Install
IntCmp $1 0 0 F4Version

; at this point, we need to determine if the person wants to install over "original" F4 or RV

Messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "" "Selecciona donde quieres instalar el teatro" "OF/RV" "AF" "Cancelar"
; this places the response 1, 2, or 3, into $0
Pop $0
IntCmp $0 3 Finish
IntCmp $0 2 AFInstall

F4Version:
; now we know they want OF/RV so we need to differentiate - I'm only going to look for RV, if it isn't RV, I'm going to assume OF for now
; this will also validate the install a bit
; this reads the specified registry value into $0
ReadRegStr $INSTDIR HKLM "Software\MicroProse\Falcon\4.0" "basedir"
; if the file exists, go to next line (don't skip a line) if it doesn't, go to label "NoFileFound"
IfFileExists $INSTDIR\theater.lst 0 NoFileFound
IfFileExists $INSTDIR\terrdata\objects\KoreaObj.Dxl RVFound
IfFileExists $INSTDIR\terrdata\objects\KoreaObj.lod OFFound NoFileFound

NoFileFound:
StrCpy $ErrCode "No se ha encontrado la instalación de Falcon. Selecciona la versión que tengas instalada: AF/OF/RV"
Goto Error


RVFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "RV"
Goto RVInstall

OFFound:
StrCpy $F4ver "F4"
StrCpy $F4subver "OF"
Goto F4Install



;AF INSTALL


AFInstall:
ReadRegStr $INSTDIR HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
WriteRegStr HKLM SOFTWARE\${TNAME}-AF "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-AF" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\Lead Pursuit\Battlefield Operations\Falcon" "basedir"
StrCpy $1 "$F4Root\campaign\korea" ; campaing\save string
StrCpy $2 "$INSTDIR\utilidades\LxNormalFix.exe $$LP @${TNAME} @$INSTDIR\terrdata" ; lxnormalfix string
StrCpy $F4Ver "AF"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "DisplayName" "${APP_NAME}-AF"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "UninstallString" "$INSTDIR/Uninstall-${TNAME}-AF.exe"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "HelpLink" "www.f4spain.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace1 IDNO Prefinish1
Enlace1:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-AF.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish1:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace2 IDNO CreateDirs
Enlace2:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-AF.lnk" "$INSTDIR\Uninstall-${TNAME}-AF.exe"


Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "Instalación en un paso.Tarda bastante. Cierra todos los programas y deshabilita el protector de pantalla" "Instalar ${TNAME}" "Cancelar"
Pop $0
IntCmp $0 2 cancelAF


Goto CreateDirs
CancelAF:
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-AF.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-AF.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-AF"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-AF"
Goto Cancel

;RV INSTALL

RVInstall:
WriteRegStr HKLM SOFTWARE\${TNAME}-RV "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-RV" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$INSTDIR\utilidades\LxNormalFix.exe @${TNAME} @$INSTDIR\terrdata"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "DisplayName" "${APP_NAME}-RV"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "UninstallString" "$INSTDIR/uninstall-${TNAME}-RV.exe"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "HelpLink" "www.f4spain.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace3 IDNO Prefinish2
Enlace3:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-RV.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish2:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace4 IDNO CreateDirs
Enlace4:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-RV.lnk" "$INSTDIR\Uninstall-${TNAME}-RV.exe"


Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "Instalación en un paso.Tarda bastante. Cierra todos los programas y deshabilita el protector de pantalla" "Instalar ${TNAME}" "Cancelar"
Pop $0
IntCmp $0 2 cancelRV


Goto CreateDirs
CancelRV:
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-RV.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-RV.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-RV"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-RV"
Goto Cancel


;OF INSTALL

F4Install:
WriteRegStr HKLM SOFTWARE\${TNAME}-OF "Install_Dir" "$INSTDIR\Theaters\${TNAME}"
ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-OF" "Install_Dir"
ReadRegStr $F4Root HKLM "Software\MicroProse\Falcon\4.0" "basedir"
StrCpy $1 "$F4Root\campaign\save"
StrCpy $2 "$INSTDIR\utilidades\LxNormalFix.exe @${TNAME} @$INSTDIR\terrdata"
; Escribimos los registros de instalación dentro del directorio del registro
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "InstallDir" "$INSTDIR"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "DisplayName" "${APP_NAME}-OF"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "UninstallString" "$INSTDIR/uninstall-${TNAME}-OF.exe"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "DisplayIcon" "$INSTDIR\${TNAME}.ico"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "Publisher" "F4Spain/F4Portugal"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "HelpLink" "www.f4spain.com"
        WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF" "Comments" "Teatro para Falcon AF/OF/RV de la Península Ibérica, Islas Baleares, Canarias, Azores y Norte de África"
;Para crear un enlace directo en el escritorio al Manual del usuario.

MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Manual del usuario?" IDYES Enlace5 IDNO Prefinish3
Enlace5:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Manual del usuario ${APP_NAME}-OF.lnk" "$INSTDIR\Manuales\Manualdelusuario.pdf"



Prefinish3:
MessageBox MB_YESNO "¿Desearás un enlace en el escritorio al Desinstalador?" IDYES Enlace6 IDNO CreateDirs
Enlace6:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateShortCut "$DESKTOP\Desinstalador ${APP_NAME}-OF.lnk" "$INSTDIR\Uninstall-${TNAME}-OF.exe"



Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "Instalación en un paso.Tarda bastante. Cierra todos los programas y deshabilita el protector de pantalla" "Instalar ${TNAME}" "Cancelar"
Pop $0
IntCmp $0 2 cancelOF


Goto CreateDirs
CancelOF:
        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-OF.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-OF.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-OF"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-OF"
Goto Cancel


;CREACIÓN DIRECTORIOS  AF/RV/OF

CreateDirs:



SetOutPath $F4Root


CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}1"
CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}2"
CreateDirectory "$F4root\Theaters\${TNAME}\campaign\${TNAME}3"
CreateDirectory "$F4root\Theaters\${TNAME}\terrdata\weather\"
CreateDirectory "$F4root\Theaters\${TNAME}\objects\"


SetOutPath $INSTDIR
CopyFiles /filesonly "$1\*.pri" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.txt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.b" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.db" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.ia" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.dfs" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.gbd" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.lst" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.idx" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\*.wch" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\atc.ini" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.aii" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.rt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\falcon4.tt" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$1\validac.*" "$INSTDIR\campaign\${TNAME}1\"


; database objects (same dir for all versions)
; this needs to be recursively because RV has koreaobj subdir.
CopyFiles "$F4Root\terrdata\objects\*.*" "$INSTDIR\objects\"
CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$INSTDIR\terrdata\weather\"

; then copy it to the two another campaign dirs
CopyFiles /filesonly "$INSTDIR\campaign\${TNAME}1\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles /filesonly "$INSTDIR\campaign\${TNAME}1\*.*" "$INSTDIR\campaign\${TNAME}3\"

CopyFiles "$F4Root\terrdata\korea\weather\*.*" "$INSTDIR\terrdata\weather\"



;CARPETA DE NUESTRO PC DONDE ESTÁN LOS ARCHIVOS DEL TEATRO
File /r "F:\F4SPAIN\BETAS\THEATERS\${TNAME}\*.*"  

;COMMON campaign files
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles /filesonly "$INSTDIR\campaign\common\*.*" "$INSTDIR\campaign\${TNAME}3\"



; beginning of falcon version DATABASE & UI   AF/RV/OF

; database copy
StrCmp $F4subver "OF" DataBaseOF
StrCmp $F4subver "RV" DataBaseRV

; UI AF
CopyFiles "$INSTDIR\art\art-AF\*.*" "$INSTDIR\art\art\"
; database AF y borrado uninstalls sobrantes
CopyFiles "$INSTDIR\objects\AF\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-AF\*.*" "$INSTDIR\campaign\${TNAME}3\"
Delete "$INSTDIR\Uninstall-${TNAME}-RV.exe"
Delete "$INSTDIR\Uninstall-${TNAME}-OF.exe"
goto EndOfDataBaseCopy

DataBaseOF:
; UI OF 
; copy only one \art\ as we have the art1024 dir there too, heh hmm.
CopyFiles "$INSTDIR\art\art-OF\*.*" "$INSTDIR\art\"
; database OF y borrado uninstalls sobrantes
CopyFiles "$INSTDIR\objects\OF\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-OF\*.*" "$INSTDIR\campaign\${TNAME}3\"
Delete "$INSTDIR\Uninstall-${TNAME}-RV.exe"
Delete "$INSTDIR\Uninstall-${TNAME}-AF.exe"
goto EndOfDataBaseCopy

DataBaseRV:
; UI RV 
CopyFiles "$INSTDIR\art\art-RV\*.*" "$INSTDIR\art\art\"
; database RV y borrado uninstalls sobrantes
CopyFiles "$INSTDIR\objects\RV\*.*" "$INSTDIR\objects\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}1\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}2\"
CopyFiles "$INSTDIR\campaign\common-RV\*.*" "$INSTDIR\campaign\${TNAME}3\"
Delete "$INSTDIR\Uninstall-${TNAME}-AF.exe"
Delete "$INSTDIR\Uninstall-${TNAME}-OF.exe"

EndOfDataBaseCopy:
RMDir /r "$INSTDIR\objects\AF\"
RMDir /r "$INSTDIR\objects\RV\"
RMDir /r "$INSTDIR\objects\OF\"
RMDir /r "$INSTDIR\art\art-AF\"
RMDir /r "$INSTDIR\art\art-RV\"
RMDir /r "$INSTDIR\art\art-OF\"
RMDir /r "$INSTDIR\campaign\common-AF\"
RMDir /r "$INSTDIR\campaign\common-OF\"
RMDir /r "$INSTDIR\campaign\common-RV\"
RMDir /r "$INSTDIR\campaign\common\"

; end of falcon version DATABASE & UI



StrCmp $F4ver "F4" F4curTheater TheaterAdmin

StrCpy $ErrCode "Unknown error before curTheater: $F4ver."
Goto Error

F4curTheater:
; set current theater to new theater PARA QUE POH
; this reads the specified registry value into $3 for use later
ReadRegStr $3 HKLM "Software\MicroProse\Falcon\4.0" "curTheater"
${registry::Write} "HKEY_LOCAL_MACHINE\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "${TNAME}1" "REG_SZ" $R0

; if it is an OF install, skip straight to theater admin otherwise, do RV stuff
StrCmp $F4subver "OF" TheaterAdmin




; APLICACIÓN UTILIDADES

TheaterAdmin:
SetOutPath "$INSTDIR\utilidades"

; plus additional two lstupdate entries
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$INSTDIR\Utilidades\lstupdate.exe $F4ver +Theaters\${TNAME}\${TNAME}3.tdf"
ExecWait '$INSTDIR\Utilidades\SPTinstall.exe -auto "$INSTDIR\terrdata"'
ExecWait '$INSTDIR\Utilidades\BaZT-SRTM-Theater.exe "$INSTDIR" "$INSTDIR\terrdata"'
ExecWait "$INSTDIR\Utilidades\LxNormalFix.exe $2"




; just compress textures if F4 then finish
StrCmp $F4ver "AF" Clear



; CONVERSIÓN A DDS (SÓLO EN RV Y OF)


ExecWait "$INSTDIR\utilidades\SeasonSwitcher.exe -0"

; el anterior teatro activo vuelve a activarse. Se deja la instalación de Falcon tal como estaba.
${registry::Write} "hklm\SOFTWARE\MicroProse\Falcon\4.0" "curTheater" "$3" "REG_SZ" $R0



; FINALIZACIÓN

Clear:
; Se borran las carpetas que ya no se usarán
SetOutPath $INSTDIR
RMDir /r "$INSTDIR\Utilidades\"



StrCmp $F4ver "F4" Finish
StrCmp $F4ver "AF" Finish

Cancel:
Messagebox::show MB_DEFBUTTON1|MB_TOPMOST "" "" "Instalación de ${TNAME} cancelada por el usuario" "Ok"
Goto Finish

Error:
Messagebox MB_OK $ErrCode

Finish:
SectionEnd



UNINSTALLER POH AF

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;DEFINICIÓN DE PARÁMETROS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NOTA: este desinstalador hay que colocarlo en la raíz de la carpeta del teatro


!define TNAME "POH"
!define APP_NAME "Pillars of Hercules Theater"
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
!define VERFALCON "AF"  
!define F4ver "AF"  ;es para lstupdate. sólo puede ser "AF"  o   "F4"
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "Spanish"
; branding text is just something that's displayed at the bottom of the installer
BrandingText "www.f4spain.com"
Name "${APP_NAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "Uninstall-${TNAME}-${VERFALCON}.exe"
ShowInstDetails nevershow


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DESINSTALADOR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Section Desinstalador


Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "¿Deseas desinstalar ${APP_NAME} de Falcon ${VERFALCON}? " "Sí" "No"
Pop $0
IntCmp $0 2 No


ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-${VERFALCON}" "Install_Dir"  ;este es la entrada de registro del teatro
IfFileExists $INSTDIR\POH.ico 0 +2  ;se comprueba que nuestro teatro esté presente
Goto +5
Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "${TNAME} no se ha detectado en Falcon ${VERFALCON}. Quizá queden rastros ¿Deseas eliminar completamente el Teatro ${TNAME}?" "Sí" "No"
Pop $0
IntCmp $0 2 No




 ;se borrará las entradas de registro, lo enlaces directos al escritorio y todos los ficheros de nuestro teatro.
 ;pero antes se ejecutará lstupdate para borrar las entradas de nuestro teatro en el archivo theaters.lst

SetOutPath $INSTDIR
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}3.tdf"

SetOutPath ..\  ;subimos un nivel para que al aplicar RMDir también borre la carpeta del teatro y no sólo su contenido. Me costó horas descubrir ésto ;-)

        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-${VERFALCON}.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-${VERFALCON}.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-${VERFALCON}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-${VERFALCON}"
        RMDir /REBOOTOK /r "$INSTDIR\"




 MessageBox MB_YESNO|MB_ICONQUESTION "Para completar la desinstalación de ${TNAME} de Falcon ${VERFALCON} es necesario reiniciar. ¿Deseas hacerlo ahora?" IDNO +2
  Reboot

       
Goto Finish


No:
Messagebox::show MB_DEFBUTTON1|MB_TOPMOST "" "" "Desinstalación de ${TNAME} de Falcon ${VERFALCON} cancelada" "Ok"
Goto Finish
       

Finish:
Sectionend

UNISTALLER POH OF

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;DEFINICIÓN DE PARÁMETROS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NOTA: este desinstalador hay que colocarlo en la raíz de la carpeta del teatro


!define TNAME "POH"
!define APP_NAME "Pillars of Hercules Theater"
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
!define VERFALCON "OF"
!define F4ver "F4"  ;es para lstupdate. sólo puede ser "AF"  o   "F4"
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "Spanish"
; branding text is just something that's displayed at the bottom of the installer
BrandingText "www.f4spain.com"
Name "${APP_NAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "Uninstall-${TNAME}-${VERFALCON}.exe"
ShowInstDetails nevershow


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DESINSTALADOR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Section Desinstalador


Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "¿Deseas desinstalar ${APP_NAME} de Falcon ${VERFALCON}? " "Sí" "No"
Pop $0
IntCmp $0 2 No


ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-${VERFALCON}" "Install_Dir"  ;este es la entrada de registro del teatro
IfFileExists $INSTDIR\POH.ico 0 +2  ;se comprueba que nuestro teatro esté presente
Goto +5
Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "${TNAME} no se ha detectado en Falcon ${VERFALCON}. Quizá queden rastros ¿Deseas eliminar completamente el Teatro ${TNAME}?" "Sí" "No"
Pop $0
IntCmp $0 2 No



 ;se borrará las entradas de registro, lo enlaces directos al escritorio y todos los ficheros de nuestro teatro.
 ;pero antes se ejecutará lstupdate para borrar las entradas de nuestro teatro en el archivo theaters.lst

SetOutPath $INSTDIR
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}3.tdf"

SetOutPath ..\  ;subimos un nivel para que al aplicar RMDir también borre la carpeta del teatro y no sólo su contenido. Me costó horas descubrir ésto ;-)

        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-${VERFALCON}.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-${VERFALCON}.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-${VERFALCON}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-${VERFALCON}"
        RMDir /REBOOTOK /r "$INSTDIR\"




 MessageBox MB_YESNO|MB_ICONQUESTION "Para completar la desinstalación de ${TNAME} de Falcon ${VERFALCON} es necesario reiniciar. ¿Deseas hacerlo ahora?" IDNO +2
  Reboot

       
Goto Finish


No:
Messagebox::show MB_DEFBUTTON1|MB_TOPMOST "" "" "Desinstalación de ${TNAME} de Falcon ${VERFALCON} cancelada" "Ok"
Goto Finish
       

Finish:
Sectionend

UNISTALLER POH RV

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;DEFINICIÓN DE PARÁMETROS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NOTA: este desinstalador hay que colocarlo en la raíz de la carpeta del teatro


!define TNAME "POH"
!define APP_NAME "Pillars of Hercules Theater"
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
!define VERFALCON "RV"
!define F4ver "F4"  ;es para lstupdate. sólo puede ser "AF"  o   "F4"
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "Spanish"
; branding text is just something that's displayed at the bottom of the installer
BrandingText "www.f4spain.com"
Name "${APP_NAME}"
; outfile is the name of the installer.  Unless otherwise set, it will be the same directory as where the script is
OutFile "Uninstall-${TNAME}-${VERFALCON}.exe"
ShowInstDetails nevershow


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DESINSTALADOR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Section Desinstalador


Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "¿Deseas desinstalar ${APP_NAME} de Falcon ${VERFALCON}? " "Sí" "No"
Pop $0
IntCmp $0 2 No


ReadRegStr $INSTDIR HKLM "SOFTWARE\${TNAME}-${VERFALCON}" "Install_Dir"  ;este es la entrada de registro del teatro
IfFileExists $INSTDIR\POH.ico 0 +2  ;se comprueba que nuestro teatro esté presente
Goto +5
Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "" "" "${TNAME} no se ha detectado en Falcon ${VERFALCON}. Quizá queden rastros ¿Deseas eliminar completamente el Teatro ${TNAME}?" "Sí" "No"
Pop $0
IntCmp $0 2 No


 ;se borrará las entradas de registro, lo enlaces directos al escritorio y todos los ficheros de nuestro teatro.
 ;pero antes se ejecutará lstupdate para borrar las entradas de nuestro teatro en el archivo theaters.lst

SetOutPath $INSTDIR
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}1.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}2.tdf"
ExecWait "$INSTDIR\lstupdate.exe ${F4ver} -Theaters\${TNAME}\${TNAME}3.tdf"

SetOutPath ..\  ;subimos un nivel para que al aplicar RMDir también borre la carpeta del teatro y no sólo su contenido. Me costó horas descubrir ésto ;-)

        Delete "$DESKTOP\Manual del usuario ${APP_NAME}-${VERFALCON}.lnk"
        Delete "$DESKTOP\Desinstalador ${APP_NAME}-${VERFALCON}.lnk"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}-${VERFALCON}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
        DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "SOFTWARE\${TNAME}-${VERFALCON}"
        RMDir /REBOOTOK /r "$INSTDIR\"




 MessageBox MB_YESNO|MB_ICONQUESTION "Para completar la desinstalación de ${TNAME} de Falcon ${VERFALCON} es necesario reiniciar. ¿Deseas hacerlo ahora?" IDNO +2
  Reboot

       
Goto Finish


No:
Messagebox::show MB_DEFBUTTON1|MB_TOPMOST "" "" "Desinstalación de ${TNAME} de Falcon ${VERFALCON} cancelada" "Ok"
Goto Finish
       

Finish:
Sectionend

Cordialmente,

Image

NOTE: Apologies my English. I use Google Translator

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Installers

Post by Snake Man » 2008-12-15 19:11:49

Thanks for posting, good to see other NSIS scripts/configs appear here, very nice.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Installers

Post by Snake Man » 2011-12-02 20:57:47

For the next theater releases I have written brand new NSIS script to install them. Its now detecting AF, BMS 4.32 or FF 5.5.5 install and properly build our theater from the small source files into a fully working theater. This means rebuilding terrain from L2 file, doing any PCX tile to DDS conversion and also creating database for historical theaters from only one small file instead of 1.5gb huge dir.

I had some problems getting MessageBox working on the latest NSIS, so I had to use the good old version shown in this topic. Dunno if I get it fixed, I tried all I could and failed. But the installer now works being it older NSIS, so that's what matters.

BTW actually there still is a problem regarding seasonswitcher, but if that util would work for BMS/FF properly, then our installer is working just fine.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

derStef
Banned user
Posts: 696
Joined: 2007-11-14 00:22:45
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Austria

Re: Installers

Post by derStef » 2011-12-05 13:59:38

Snake Man wrote: This means rebuilding terrain from L2 file, doing any PCX tile to DDS conversion and also creating database for historical theaters from only one small file instead of 1.5gb huge dir.
cheers on that one Snake Man!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests