
;***********
;*         *
;* STRINGS *
;*         *
;***********

(set #LANG_FOUND 0)

(if (= "deutsch" @language)
       (
	(set #MSG_WELCOME "Willkommen beim Installations-Skript für die \"Südtirol Transfer-Animation\".")
	(set #MSG_WELCOME_WARN "\n\nSie benutzen eine alte Version (<42) des Installers. Das könnte unter Umständen Probleme bereiten!")

	(set #MSG_SELECTBROWSER "Für welche Browser soll die Transfer-Animation installiert werden?")
	(set #MSG_BACKUP "Sollen von den zur Zeit installierten Transfer-Animationen Backups gemacht werden?")
	(set #MSG_BACKUP_SUFFIX "Wählen Sie einen Suffix für die Backups")

	(set #MSG_SELECTPATH "Wo befindet sich das Verzeichnis von %s?")
	(set #MSG_WRONGPATH "Dies scheint nicht das richtige Verzeichnis zu sein! Sie müssen das Verzeichnis auswählen, in dem sich das Programm %s befindet!")

	(set #MSG_COPY "Installiere Transfer-Animation für %s")
	(set #MSG_CREATEBACKUP "Erzeuge Backup von der Transfer-Animation, die %s zur Zeit verwendet")

	(set #MSG_NOHELP "Keine Hilfe verfügbar. Sorry. Ich bin einfach zu faul :-( Lesen Sie das \"CopyIcon.guide\"!")

	(set #MSG_DONE "\nInstallation abgeschlossen!")

	(set #LANG_FOUND 1)
       )
)

(if (= "italiano" @language)
       (
	(set #MSG_WELCOME "Benvenuto nello script di installazione per la \"South-Tyrol Transfer Animation\".")
	(set #MSG_WELCOME_WARN "\n\nLei possiede una versione vecchia (<42) dell'Installer. Questo potrebbe eventualmente causare dei problemi!")

	(set #MSG_SELECTBROWSER "Per quali Browser devo installare la Transfer-Animation?")
	(set #MSG_BACKUP "Devo fare dei backups dei Transfer-Animations installati attualmente?")
	(set #MSG_BACKUP_SUFFIX "Scelga un suffix per i backups")

	(set #MSG_SELECTPATH "In che directory si trova %s?")
	(set #MSG_WRONGPATH "Questo non sembra essere il directory giusto. Deve specificare il directory nel quale si trova il programma %s!")

	(set #MSG_COPY "Installo la Transfer-Animation per %s")
	(set #MSG_CREATEBACKUP "Creo il backup della Transfer-Animation attualmente usata da %s")

	(set #MSG_NOHELP "Nessun aiuto disponibile. Sorry. Sono troppo pigro :-( Leggi il \"CopyIcon.guide\"!")

	(set #MSG_DONE "\nInstallazione completa!")

        (set #LANG_FOUND 1)
       )
)

(if (= 0 #LANG_FOUND)
       (
	(set #MSG_WELCOME "Welcome to the installation script for the \"South-Tyrol Transfer Animation\".")
	(set #MSG_WELCOME_WARN "\n\nYou are using an old version (<42) of the Installer. This might eventually cause problems!!")

	(set #MSG_SELECTBROWSER "For which browsers do you want the transfer animation to be installed?")
	(set #MSG_BACKUP "Shall I backup the actually installed transfer animations?")
	(set #MSG_BACKUP_SUFFIX "Choose a suffix for the backup files")

	(set #MSG_SELECTPATH "Where's the %s directory?")
	(set #MSG_WRONGPATH "This does not seem to be the correct directory. You must select the one, the %s program resides in!")

	(set #MSG_COPY "Installing transfer animation for %s")
	(set #MSG_CREATEBACKUP "Creating backup of the transfer animation actually used by %s")

	(set #MSG_NOHELP "No help available. Sorry. I'm just too lazy :-( Have a look at \"CopyIcon.guide\"!")

	(set #MSG_DONE "\nInstallation complete!")

       )
)

;==========================================================================

;********
;*      *
;* MAIN *
;*      *
;********

(set #OSVERSION (/ (getversion) 65536))

(if (< (/ @installer-version 65536) 42)
	(welcome #MSG_WELCOME #MSG_WELCOME_WARN)
	(welcome "\n" #MSG_WELCOME)
)

;******************
;*                *
;* SELECT BROWSER *
;*                *
;******************

(set #browser (askoptions (prompt #MSG_SELECTBROWSER)
						  (choices "VoyagerNG" "IBrowse" "AWeb")
						  (default 0)
						  (help #MSG_NOHELP)
			  )
)

(if (= 0 #browser)
	(exit #MSG_DONE (quiet))
)

(if (= 1 (askbool (prompt #MSG_BACKUP)
		  (default 1)
		  (help #MSG_NOHELP)
	 )
    )
    (
     (set #suffix (askstring (prompt #MSG_BACKUP_SUFFIX)
     			     (default ".bak")
     			     (help #MSG_NOHELP)
     		  )
     )
     (set #dobackup 1)
    )
)

(set #defpath "SYS:")

;*** Voyager Path

(if (BITAND #browser 1)
	(
	 (while (= #VOYFOUND 0)
	  (
	   (set #VoyagerPath
		(Expandpath
			(askdir (prompt (#MSG_SELECTPATH "VoyagerNG"))
				(default #defpath)
				(help #MSG_NOHELP)
			)
		)
	   )
	  )
	  (if (exists (tackon #VoyagerPath "TransferAnim"))
	   (
	    (set #VOYFOUND 1)
	    (set #defpath (expandpath (tackon #VoyagerPath "/")))
	   )
	   (message (#MSG_WRONGPATH "VoyagerNG"))
	  )
	 )
	)
)

;*** IBrowse Path

(if (BITAND #browser 2)
	(
	 (while (= #IBRFOUND 0)
	  (
	   (set #IBrowsePath
		(Expandpath
			(askdir (prompt (#MSG_SELECTPATH "IBrowse"))
				(default #defpath)
				(help #MSG_NOHELP)
			)
		)
	   )
	  )
	  (if (exists (tackon #IBrowsePath "images/def_TransferAnimation"))
	   (
	    (set #IBRFOUND 1)
	    (set #defpath (expandpath (tackon #IBrowsePath "/")))
	   )
	   (message (#MSG_WRONGPATH "IBrowse"))
	  )
	 )
	)
)

;*** AWeb Path

(if (BITAND #browser 4)
	(
	 (while (= #AWBFOUND 0)
	  (
	   (set #AWebPath
		(Expandpath
			(askdir (prompt (#MSG_SELECTPATH "AWeb"))
				(default #defpath)
				(help #MSG_NOHELP)
			)
		)
	   )
	  )
	  (if (exists (tackon #AWebPath "images/def_TransferAnim"))
	   (set #AWBFOUND 1)
	   (message (#MSG_WRONGPATH "AWeb"))
	  )
	 )
	)
)


;**************
;*            *
;* COPY FILES *
;*            *
;**************

;** VoyagerNG

(if (BITAND #browser 1)
 (
  (if (= 1 #dobackup)
   (
    (rename (tackon #VoyagerPath "TransferAnim") (tackon #VoyagerPath (cat "TransferAnim" #suffix))
            (prompt (#MSG_CREATEBACKUP "VoyagerNG"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
    (rename (tackon #VoyagerPath "TransferAnim.info") (tackon #VoyagerPath (cat "TransferAnim" #suffix ".info"))
            (prompt (#MSG_CREATEBACKUP "VoyagerNG"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
   )
  )
  (copyfiles (prompt (#MSG_COPY "VoyagerNG"))
  	     (source "TransferAnim")
  	     (dest #VoyagerPath)
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
  (copyfiles (prompt (#MSG_COPY "VoyagerNG"))
  	     (source "Icon_Voyager/Transferanim.info")
  	     (dest #VoyagerPath)
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
 )
)

;** IBroswe

(if (BITAND #browser 2)
 (
  (if (= 1 #dobackup)
   (
    (rename (tackon #IBrowsePath "images/def_TransferAnimation") (tackon #IBrowsePath (cat "images/def_TransferAnimatiom" #suffix))
            (prompt (#MSG_CREATEBACKUP "IBrowse"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
    (rename (tackon #IBrowsePath "images/def_TransferAnimation.info") (tackon #IBrowsePath (cat "images/def_TransferAnimatiom" #suffix ".info"))
            (prompt (#MSG_CREATEBACKUP "IBrowse"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
   )
  )
  (copyfiles (prompt (#MSG_COPY "IBrowse"))
  	     (source "TransferAnim")
  	     (dest (tackon #IBrowsePath "images"))
  	     (newname "def_TransferAnimation")
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
  (copyfiles (prompt (#MSG_COPY "IBrowse"))
  	     (source "Icon_IBrowse/def_TransferAnimation.info")
  	     (dest (tackon #IBrowsePath "images"))
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
 )
)

;** AWeb

(if (BITAND #browser 4)
 (
  (if (= 1 #dobackup)
   (
    (rename (tackon #AWebPath "images/def_TransferAnim") (tackon #AWebPath (cat "images/def_TransferAnim" #suffix))
            (prompt (#MSG_CREATEBACKUP "AWeb"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
    (rename (tackon #AWebPath "images/def_TransferAnim.info") (tackon #AWebPath (cat "images/def_TransferAnim" #suffix ".info"))
            (prompt (#MSG_CREATEBACKUP "AWeb"))
    	    (confirm)
    	    (help #MSG_NOHELP)
    )
   )
  )
  (copyfiles (prompt (#MSG_COPY "AWeb"))
  	     (source "TransferAnim")
  	     (dest (tackon #AWebPath "images"))
  	     (newname "def_TransferAnim")
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
  (copyfiles (prompt (#MSG_COPY "AWeb"))
  	     (source "Icon_AWeb/def_TransferAnim.info")
  	     (dest (tackon #AWebPath "images"))
  	     (help #MSG_NOHELP)
  	     (confirm)
  )
 )
)



;***********
;*         *
;* THE END *
;*         *
;***********

(exit #MSG_DONE (quiet))
