(set #ver (/ @installer-version 65536))
(set #inst1 "Heretic_IIA")
(if (>= #ver 44)
    (
	(effect "lower_right" "radial" $C85037 $000000)
	(showmedia "symbol" "Heretic_IIA:Installer Data/backdrop.iff" "center" "none" 0)
    )
)

(if (< #ver 43)
    (
	(exit "Your Installer is too old. Get a new version from Aminet" (quiet))
    )
)

(if (= @language "deutsch")
(
 (set #choice-yes "\x1B[2pJa")
 (set #choice-no "Nein")
 (set #welcome-prompt (cat
	"Willkommen zum Heretic 2 Update Installations-Programm. Es wird Sie schrittweise "
	"durch die Installation führen. Wenn Sie Probleme bekommen, können Sie durch "
	"den Hilfe-Knopf weitere Informationen erhalten.\n"
	"Bitte wählen Sie nun den Installations-Modus."
 ))
    (set #licence-msg (cat
	"Bitte bestätigen Sie, daß sie die Lizenz gelesen und verstanden haben "
	"und sie akzeptieren."
    ))
    (set #licence-accept "\x1B[2pIch stimme der Lizenz zu")
    (set #licence-reject "Ich stimme der Lizenz nicht zu")
    (set #not-installed "Heretic II muss installiert sein, um das Update zu installieren.")
    (set #extract-base "Programm-Dateien werden auf die Festplatte kopiert...")
    (set #finish-msg "Das Heretic II Update wurde in der Schublade %s erfolgreich installiert\n")
    (set #see-readme "\x1B[2pEinen Blick auf die LIESMICH-Datei werfen")
    (set #register-msg (cat
  	"Um die Installation abzuschließen werden Sie jetzt nach Ihrer Serien-Nummer und "
  	"Benutzer-Informationen wie Namen und Anschrift gefragt. Sie müssen dies ausfüllen "
  	"um den Kundendienst in Anspruch zu nehmen. Geben Sie die Seriennummer sehr sorgfältig "
  	"und genau so wie abgedruckt ein (einschließlich der Bindestriche), da die Installation "
  	"ansonsten nicht funktioniert."
    ))

 (set #not-successful "Die Heretic II Installation war nicht erfolgreich. Bitte wiederholen Sie diese, bevor Sie das Update installieren.")
 (set #copy-docs "Die Dokumentation ins HereticII Directory installieren ?")
 (set #copying-docs "Kopiere Update-Dokumentation...")
)
(
 (set #choice-yes "\x1B[2pYes")
 (set #choice-no "No")
 (set #welcome-prompt (cat
	"Welcome to the Heretic 2 Update Installation Program. This Utility "
	"will guide you through the Installation in a step-by-step "
	"process. At any time, "
	"if you're stuck, you can press the help button to get more detailed "
	"information. \n"
	"Please indicate your level of expertise."
 ))
    (set #licence-msg (cat
	"Please confirm that you have read and understood the licence agreement "
	"and that you accept it"
    ))
    (set #licence-accept "\x1B[2pI have read and accepted the licence agreement")
    (set #licence-reject "I do not accept the licence agreement")
    (set #copy-movies (cat
	"Since there is enough free space on your partition, you might want to also copy "
	"the movie files to your harddisk, although this is not really required if you have "
	"a 4x or faster CD-Rom drive.\nDo you want to install the movie files(approx. 100 MB)?"
    ))
    (set #not-installed "Heretic II needs to be installed to install the update.")
    (set #extract-base "Copying program files to your harddisk...")
    (set #finish-msg "The Heretic II update has been installed to %s\n on your system")
    (set #see-readme "\x1B[2pHave a look at the README-File")
    (set #register-msg (cat
	"To conclude the installation process you will be asked for your serial number and "
	"user information, like name, address, city and country. You must fill them "
	"in, otherwise we will not be able to answer your support questions. "
	"Be very careful to type in the serial number as it is printed, including "
	"dashes, otherwise your installation will not work."
    ))
 (set #not-successful "Heretic II Installation was unsuccessfull. Please reinstall the game before installing the update.")
 (set #copy-docs "Do you want to install the documentation into the Heretic II Directory ?")
 (set #copying-docs "Copying Update-Documentation...")
)
)

(procedure P_BuildCommandline arg1
    (set #cmdline
	(cat
	    "c/hUnpackH2 -archive \""
	    (arg1)
	    "\" -dest \""
	    (getenv "HereticII/InstallationPath")
	    "\""
	)
    )
)

(procedure P_DoRegister
    (message #register-msg)
    (set #cmdline (cat
	"Heretic_IIA:C/RegisterGUI \""
	(tackon @default-dest "quake2.dll")
	"\" "
    ))
    (set #retval
	(run #cmdline
	(help @run-help)
    ))
    (if (= #retval 10)
	(exit "Internal Error during registering. Please contact tech suport" (quiet))
    )
    (if (= #retval 20)
	(exit #user-abort (quiet))
    )
)

(procedure P_AskDisk 
	(set #curvol #inst1)
    (set #curvol (cat #curvol ":"))
)

(welcome #welcome-prompt)
(P_AskDisk)
(complete 0)
(set #flag (exists "ENV:HereticII/InstallationPath"))
(if (= #flag 1)
    (
	(set @default-dest (getenv "HereticII/InstallationPath"))
	(if (exists (tackon @default-dest "installer-cookie"))
    (exit #not-successful (quiet))
  )
    )
    (
	(exit #not-installed (quiet))
    )		
)

(textfile
    (dest (tackon @default-dest "update-cookie"))
    (append "I am a cookie. Bite me")
)


(if (>= #ver 44)
(showmedia 'license' 'LICENSE' 'upper_right' 'medium' 1 'wordwrap')
(run "sys:Utilities/Multiview LICENSE")
)

(set #flag
	(askchoice
	    (prompt #licence-msg)
	    (help @askchoice-help)
	    (default 0)
	    (choices #licence-accept #licence-reject)
	)
    )
    (if (= #flag 1) (exit (quiet)))

(if (>= #ver 44) (closemedia license))

(set #dest-dir @default-dir)

(complete 20)

(P_BuildCommandLine "update.hpa")
(working #extract-base)
(set #status
	(run #cmdline
		(help @run-help)
	)
)

(if (= #status 2)
    (
	(exit #user-abort (quiet))
    )
)
(complete 50)
(P_DoRegister)

(set #opts
    (askchoice
      (help @askchoice-help)
      (prompt #copy-docs)
      (choices #choice-yes #choice-no)
      (default 0)
    )
)

(if (= #opts 0)
(
(if (not(exists(tackon @default-dest "update-docs/Update_Docs.htm")))
 (copyfiles (source"update-docs/Update_Docs.htm") (dest (tackon @default-dest "update-docs")))
)
(if (not(exists(tackon @default-dest "update-docs/Tweaking.htm")))
 (copyfiles (source"update-docs/Tweaking.htm") (dest (tackon @default-dest "update-docs")))
)
(if (not(exists(tackon @default-dest "update-docs/thf_install.htm")))
 (copyfiles (source"update-docs/thf_install.htm") (dest (tackon @default-dest "update-docs")))
)
(if (not(exists(tackon @default-dest "update-docs/warpos_install.htm")))
 (copyfiles (source"update-docs/warpos_install.htm") (dest (tackon @default-dest "update-docs")))
)
)
)
(complete 80)
(if (not(exists(tackon @default-dest "update-docs/README")))
(copyfiles (source"README") (dest (tackon @default-dest "update-docs")))
)
(if (not(exists(tackon @default-dest "update-docs/LICENSE")))
(copyfiles (source"LICENSE") (dest (tackon @default-dest "update-docs")))
)

(complete 100)
(delete (tackon @default-dest "update-cookie"))
(set #opts
    (askoptions
	(help @askoptions-help)
	(prompt (#finish-msg @default-dest))
	(choices #see-readme)
	(default 1)
    )
)

(if (IN #opts 0)
    (if (>= #ver 44)
	(showmedia "readme" "README" "upper_right" "medium" 1)
	(run "sys:Utilities/Multiview README")
    )
)

