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

(set #LANG_FOUND 0)

(if (= "deutsch" @language)
       (
        (set #MSG_READIMPORTANT "\nBitte lesen Sie \"Important\" bevor Sie KeyReq installieren.\n\nDas Installations-Skript wird erst funktionieren, wenn das gemacht wurde!!")

	(set #MSG_WELCOME "Willkommen beim Installations-Skript für \"KeyReq\".")
	(set #MSG_WELCOME_WARN "\n\nSie benutzen eine alte Version (<42) des Installers. Das könnte unter Umständen Probleme bereiten!")

	(set #MSG_SELECTEXEPATH "In welches Verzeichnis soll das Programm  (\"KeyReq\") kopiert werden?")
	(set #MSG_SELECTDOCPATH "In welches Verzeichnis soll die Dokumentation (\"KeyReq.guide\") kopiert werden?")

	(set #MSG_WHERESTART "Von wo soll KeyReq während des Bootens gestartet werden?")
	(set #MSG_DONTSTART "KeyReq nicht beim Booten starten")

	(set #MSG_CONFIG "Wollen Sie KeyReq gleich jetzt konfigurieren? Das können Sie auch manuell machen, wenn Sie nach der Installation die KeyReq Start-Zeile in der %s editieren.")
	(set #MSG_CONFIG_OKKEY "Mit welcher Taste (neben RETURN) sollen Requester bestätigt werden können?")
	(set #MSG_CONFIG_CANCELKEY "Mit welcher Taste (neben ESC) sollen Requester abgebrochen werden können?")
	(set #MSG_CONFIG_COMMAND "Wollen Sie, daß LAMIGA zusätzlich zu den vorher definierten Tasten gedrückt werden muß (gilt nicht für RETURN und ESC)?")
	(set #MSG_CONFIG_POS "An welcher Position sollen die Requester erscheinen?")
	(set #MSG_CONFIG_POS_NORMAL "In der linken oberen Ecke des Screens")
	(set #MSG_CONFIG_POS_CENTER "In der Mitte des Screens")
	(set #MSG_CONFIG_POS_MOUSE "Unter dem Mauszeiger")
	(set #MSG_CONFIG_HIGHLIGHT "Wollen Sie, daß das aktive Gadget eines Requesters gehighlighted wird (mit einem Rechteck, siehe \"Screenshot.png\")?")
	(set #MSG_CONFIG_PENRGB "Soll zum Zeichnen des Highlight Rechteckes ein Pen aus der DrawInfo Struktur verwendet werden?")
	(set #MSG_CONFIG_PENRGB_PEN "Ja. Pennummer bestimmen ... ")
	(set #MSG_CONFIG_PENRGB_RGB "Nein. RGB-Farbwert bestimmen ...")
	(set #MSG_CONFIG_HIGHPEN "Welcher DRIPen soll zum Zeichnen des Highlight-Rechteckes verwendet werden (siehe Guide)?")
	(set #MSG_CONFIG_HIGHRGB "Welcher Farbe soll zum Zeichnen des Highlight-Recheckes verwendet werden (Format: 0xRRGGBB)?")
	(set #MSG_CONFIG_TAB "Wollen Sie, daß man mit TAB zwischen den Gadgets cyclen kann (wie bei MUI)?")
	(set #MSG_CONFIG_KEYGAD "Soll das KeyGadget Feature benutzt werden (bei Tastendruck wird entsprechendes Gadget selektiert gezeichnet, und man kann Tastendruck 'abbrechen', siehe Guide)?")

	(set #MSG_FA "Es wird nun ein Programm gestartet, mit dem Sie auswählen können, an welcher Stelle in der %s KeyReq gestartet werden soll. Sie sollten die vorgeschlagene Position nur ändern, wenn Sie wirklich wissen, was Sie tun!")
	(set #MSG_FA2 "\n\nWenn Sie KeyReq bereits in der %s haben, können Sie mit CONTROL + LINKER MAUSTASTE die entsprechenden Zeilen herauslöschen.\n\nVor dem Speichern der geänderten %s wird ein Backup davon gemacht!")

	(set #MSG_COPY_EXE "Kopiere KeyReq")
	(set #MSG_COPY_DOC "Kopiere Dokumentation")

	(set #MSG_ICONPOS "Korrigiere Icon Position")

	(set #MSG_NOHELP "Keine Hilfe verfügbar. Sorry. Ich bin einfach zu faul :-( Lesen Sie das \"KeyReq.guide\"!")
	(set #MSG_DONE "\nDie Installation von KeyReq ist abgeschlossen.\n\nDer Source-Code von KeyReq wurde nicht auf Ihre Festplatte kopiert. Machen Sie das manuell, wenn Sie daran interessiert sind.")

	(set #LANG_FOUND 1)
       )
)

(if (= "italiano" @language)
       (
        (set #MSG_READIMPORTANT "\nLegga prima il file \"Important\".\n\nLo script di installazione funzionerà solo dopo aver fatto questo!!")

	(set #MSG_WELCOME "Benvenuto nello script di installazione per \"KeyReq\".")
	(set #MSG_WELCOME_WARN "\n\nLei possiede una versione vecchia (<42) dell'Installer. Questo potrebbe eventualmente causare dei problemi!")

	(set #MSG_SELECTEXEPATH "In che directory devo copiare il programma (\"KeyReq\")?")
	(set #MSG_SELECTDOCPATH "In che directory devo copiare la documentazione (\"KeyReq.guide\")?")

	(set #MSG_WHERESTART "Da dove deve essere lanciato KeyReq durante il boot")
	(set #MSG_DONTSTART "Non lanciare KeyReq durante il boot")

	(set #MSG_CONFIG "Vuole configurare KeyReq subito? Questo può essere fatto anche dopo l'installazione editando la start-line di KeyReq nella %s.")
	(set #MSG_CONFIG_OKKEY "Che tasto (RETURN da parte) vuole usare per confermare un requester?")
	(set #MSG_CONFIG_CANCELKEY "Che tasto (ESC da parte) vuole usare per annullare un requester?")
	(set #MSG_CONFIG_COMMAND "Vuole che sia necessario premere anche LAMIGA per poter usare i tasti definiti prima (non vale per RETURN/ESC)?")
	(set #MSG_CONFIG_POS "In che posizione devono apparire i requester?")
	(set #MSG_CONFIG_POS_NORMAL "Nell'angolo in alto a sinistra dello schermo")
	(set #MSG_CONFIG_POS_CENTER "Nel centro dello schermo")
	(set #MSG_CONFIG_POS_MOUSE "Sotto il puntatore del mouse")
	(set #MSG_CONFIG_HIGHLIGHT "Vuole che il gadget attivo dei requester venga 'highlighted' (con un rettangolo intorno al gadget, vedi \"Screenshot.png\")?")
	(set #MSG_CONFIG_PENRGB "Deve essere usuato un pen della DrawInfo per il rendering del rettangolo?")
	(set #MSG_CONFIG_PENRGB_PEN "Si. Definire numero del pen ...")
	(set #MSG_CONFIG_PENRGB_RGB "No. Definire un valore RGB ...")
	(set #MSG_CONFIG_HIGHPEN "Che DRIPen deve essere usato (vedi guida)?")
	(set #MSG_CONFIG_HIGHRGB "Che colore deve essere usato (in formato: 0xRRGGBB)?")
	(set #MSG_CONFIG_TAB "Vuole che sia possible 'cyclare' tra i gadgets del requester con TAB (come in MUI)?")
	(set #MSG_CONFIG_KEYGAD "Deve essere attivato il KeyGadget feature (quando si preme un tasto il gadget relativo verrà renderizzato in modo selettato e sarà possibile 'annulare' la premuta di tasto, vedi guida)?")

	(set #MSG_FA "Adesso sarà lanciato un programma che permette di scegliere in che posizione (quando) far lanciare KeyReq. Cambiare la posizione predefinita solo se è veramente sicuro di quello che fa!")
	(set #MSG_FA2 "\n\nSe KeyReq si trova di già nella %s si possono cancellare le linee corrispondenti con CONTROL + TASO SINISTRO MOUSE.\n\nPrima del salvataggio della %s cambiata ne sarà fatto un backup!")

	(set #MSG_COPY_EXE "Copio KeyReq")
	(set #MSG_COPY_DOC "Copio documentazione")
	
	(set #MSG_ICONPOS "Corrego posizione dell'icona")

	(set #MSG_NOHELP "Nessun aiuto disponibile. Sorry. Sono troppo pigro :-( Leggi il \"KeyReq.guide\"!")
	(set #MSG_DONE "\nL'installazione di KeyReq è finita.\n\nLe sorgenti di KeyReq non sono stati copiati sul suo HD. Lo faccia manualmente se è interessato.")

        (set #LANG_FOUND 1)
       )
)

(if (= 0 #LANG_FOUND)
       (
        (set #MSG_READIMPORTANT "\nPlease read \"Important\" before installing KeyReq.\n\nThe installation script will only work after having done that!!")

	(set #MSG_WELCOME "Welcome to the installation script for \"KeyReq\".")
	(set #MSG_WELCOME_WARN "\n\nYou are using an old version (<42) of the Installer. This might eventually cause problems!!")

	(set #MSG_SELECTEXEPATH "Where do you want the executable (\"KeyReq\") to be copied?")
	(set #MSG_SELECTDOCPATH "Where do you want the documentation (\"KeyReq.guide\") to be copied?")

	(set #MSG_WHERESTART "From where do you want KeyReq do be started during boot?")
	(set #MSG_DONTSTART "Don't start KeyReq during boot")

	(set #MSG_CONFIG "Do you want to configure KeyReq right now? You can also do this manually by editing the KeyReq start line in the %s after installation is finished.")
	(set #MSG_CONFIG_OKKEY "With which key (apart from RETURN) shall it be possible to confirm requesters?")
	(set #MSG_CONFIG_CANCELKEY "With which key (apart from ESC) shall it be possible to abort requesters?")
	(set #MSG_CONFIG_COMMAND "Do you want LAMIGA be necessary to be pressed together with the keys defined before (apart from RETURN/ESC)?")
	(set #MSG_CONFIG_POS "At which position do you want the requesters to be opened?")
	(set #MSG_CONFIG_POS_NORMAL "In the upper left corner of the screen")
	(set #MSG_CONFIG_POS_CENTER "In the center of the screen")
	(set #MSG_CONFIG_POS_MOUSE "Under the mouse pointer")
	(set #MSG_CONFIG_HIGHLIGHT "Do you want the active gadget of a requester to be highlighted (with a rectangle, see \"Screenshot.png\"?")
	(set #MSG_CONFIG_PENRGB "Shall a DrawInfo pen be used for the drawing of the rectangle?")
	(set #MSG_CONFIG_PENRGB_PEN "Yes. Define pen number ...")
	(set #MSG_CONFIG_PENRGB_RGB "No. Define a RGB color value ...")
	(set #MSG_CONFIG_HIGHPEN "Which DRIPen shall be used for the highlight rectangle (see guide)?")
	(set #MSG_CONFIG_HIGHRGB "Which color shall be used for the highlight rectangle (format: 0xRRGGBB)?")
	(set #MSG_CONFIG_TAB "Shall it be possible to cycle through the gadgets with TAB (similiar to MUI)?")
	(set #MSG_CONFIG_KEYGAD "Shall the KeyGadget feature be used (when pressing a key the relative gadget will be rendered in selected state and it will be possible to 'abort' key presses, see guide)?")

	(set #MSG_FA "Now a program will be started that allows you to select at which position to insert KeyReq in the %s. Change the predefined position only if you really know what you do!")
	(set #MSG_FA2 "\n\nIf KeyReq is already in your %s you can delete the corresponding lines by using CONTROL + LEFT MOUSE BUTTON.\n\nBefore saving the changed %s a backup of it will be created!")

	(set #MSG_COPY_EXE "Copying KeyReq")
	(set #MSG_COPY_DOC "Copying documentation")
	
	(set #MSG_ICONPOS "Correcting icon position")

	(set #MSG_NOHELP "No help available. Sorry. I'm just too lazy :-( Have a look at \"KeyReq.guide\"!")
	(set #MSG_DONE "\nThe installation of KeyReq is finished.\n\nThe source code of KeyReq has not been copied to your HD. Do this manually if you are interested in them.")

       )
)

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

(if (<> 0 (exists "MustReadImportant"))
	 (abort #MSG_READIMPORTANT)
)

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

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

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

;******************
;*                *
;* SELECT EXE DIR *
;*                *
;******************

(set #exedest
	(Expandpath
		(askdir (prompt #MSG_SELECTEXEPATH)
			(default "SYS:C")
			(help #MSG_NOHELP)
		)
	)
)

;******************
;*                *
;* SELECT DOC DIR *
;*                *
;******************

(set #docdest
	(Expandpath
		(askdir (prompt #MSG_SELECTDOCPATH)
			(default "HELP:")
			(help #MSG_NOHELP)
		)
	)
)

;************************
;*                      *
;* ASK WEHRE TO START   *
;*                      *
;************************

(set #startwahl
 (askchoice 
 	(prompt #MSG_WHERESTART)
 	(choices "Startup-Sequence" "User-Startup" #MSG_DONTSTART)
 	(default 0)
 	(help #MSG_NOHELP)
 )
)

(if (= #startwahl 0)
	(set #startfile "Startup-Sequence")
	(set #startfile "User-Startup")
)


;
;if startwahl <> nirgends then
;
(if (<> #startwahl 2)

 (

;************************
;*                      *
;* CONFIGURATION        *
;*                      *
;************************

(if (= 1 (askbool
		(prompt (#MSG_CONFIG #startfile))
		(help #MSG_NOHELP)
		(default 1)
	 )
    )
 (


;** OK_KEY

 	(set #string (askstring (prompt #MSG_CONFIG_OKKEY)
 			        (default "V")
 			        (help #MSG_NOHELP)
 		     )
 	)
 	
 	(if (<> #string "V")
 		(set #exeargs (cat #exeargs " OK_KEY=" #string))
 	)


;** CANCEL_KEY

 	(set #string (askstring (prompt #MSG_CONFIG_CANCELKEY)
 			        (default "B")
 			        (help #MSG_NOHELP)
 		     )
 	)
 	
 	(if (<> #string "B")
 		(set #exeargs (cat #exeargs " CANCEL_KEY=" #string))
 	)


;** COMMAND

	(if (= 0 (askbool (prompt #MSG_CONFIG_COMMAND)
		 	  (default 1)
		 	  (help #MSG_NOHELP)
		 )
	    )
	    (set #exeargs (cat #exeargs " NOCOMMAND"))
	)


;** REQ POSITION

	(set #integer (askchoice (prompt #MSG_CONFIG_POS)
				 (choices #MSG_CONFIG_POS_NORMAL #MSG_CONFIG_POS_CENTER #MSG_CONFIG_POS_MOUSE)
				 (help #MSG_NOHELP)
				 (default 0)
		      )
	)
	
	(if (= 1 #integer)
		(set #exeargs (cat #exeargs " CENTERREQ"))
	)
	
	(if (= 2 #integer)
		(set #exeargs (cat #exeargs " MOUSEREQ"))
	)

;** HIGHLIGHT
	
	(if (= 1 (askbool (prompt #MSG_CONFIG_HIGHLIGHT)
			  (default 1)
			  (help #MSG_NOHELP)
		 )
	    )
	    (
	     (set #integer 0)
	     (if (> #OSVERSION 38)
	        (
	     	 (set #integer (askchoice (prompt #MSG_CONFIG_PENRGB)
	     	 			  (choices #MSG_CONFIG_PENRGB_PEN #MSG_CONFIG_PENRGB_RGB)
	     				  (default 0)
	     				  (help #MSG_NOHELP)
	     		      )
	         )
	         (set #maxpen 11)
	        )
	        ;else OS<39
	        (
	         (set #maxpen 9)
	        )
	     )
	     
	     (if (= 0 #integer)
	      (
	       (set #integer (asknumber (prompt #MSG_CONFIG_HIGHPEN)
	       				(range 0 #maxpen)
	       				(default 4)
	       				(help #MSG_NOHELP)
	       		     )
	       )
	       
	       (if (<> 4 #integer)
	         (set #exeargs (cat #exeargs (" HIGHLIGHTCOL=%ld" #integer)))
	       )

	      )
	      ;else (RGB bestimmen)
	      (
	       (set #string (askstring (prompt #MSG_CONFIG_HIGHRGB)
	       			       (default "0xFF0000")
	       			       (help #MSG_NOHELP)
	       		    )
	       )
	       (set #exeargs (cat #exeargs " HIGHLIGHTRGB=" #string))
	       
	      )
	     )
	     
	     ;**TAB

	     (if (= 0 (askbool (prompt #MSG_CONFIG_TAB)
	     		       (default 1)
	     		       (help #MSG_NOHELP)
	     	      )
	     	 )
	     	 (set #exeargs (cat #exeargs " NOTAB"))
	     )
 
	    )
	    ;else (no highlight)
	    (
	     (set #exeargs (cat #exeargs " NOHIGHLIGHT"))
	    )
	)
	
;** KeyGadget
	(if (= 0 (askbool (prompt #MSG_CONFIG_KEYGAD)
			  (default 1)
			  (help #MSG_NOHELP)
	         )
	    )
	    (set #exeargs (cat #exeargs " NOKEYGADGET"))
	 )

 )
)

;**************
;*            *
;* FILEATTACK *
;*            *
;**************


	(textfile
		(dest "T:KeyReq_Start")
		(append (";BEGIN KeyReq\nrun <>NIL: \"%s\"%s\n;END KeyReq" (tackon #exedest "KeyReq") #exeargs))
		(help #MSG_NOHELP)
		(safe)
	)

	(message (#MSG_FA #startfile) (#MSG_FA2 #startfile #startfile))

	(if (= #startwahl 0)
		(run ("c/FileAttack T:KeyReq_Start S:%s Backup S:%s.old DefaultAfter #?SetPatch#?" #startfile #startfile))
		(run ("c/FileAttack T:KeyReq_Start S:%s Backup S:%s.old " #startfile #startfile))
	)

 )
)

;endif ;// if startwahl <> nirgends then

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

(copyfiles (prompt #MSG_COPY_EXE)
	   (source "KeyReq")
	   (dest #exedest)
	   (confirm)
	   (help #MSG_NOHELP)
)

(copyfiles (prompt #MSG_COPY_DOC)
	   (source "")
	   (choices "KeyReq.guide" "KeyReq.guide.info")
	   (dest #docdest)
	   (confirm)
	   (infos)
	   (help #MSG_NOHELP)
)

(if (exists (tackon #docdest "KeyReq.guide.info"))
	(run	("c/noiconpos %s" (tackon #docdest "KeyReq.guide"))
		(prompt #MSG_ICONPOS)
		(help #MSG_NOHELP)
		(confirm)
	)
)

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

(exit #MSG_DONE #MSG_DONE2
	(quiet)
)
