;======================================================================
;
; BattleDuel Install Script $VER: Install 1.03 (4.5.95)
;
; Copyright  1995 Jochen Terstiege
;
;======================================================================
;
;======================================================================
; language strings
;======================================================================

(if (= @language "deutsch")
	(
		(set #hello "\nWillkommen zur BattleDuel Installation\nund Update\n\n\Version 1.03")
		(set #update (cat "Sie haben BattleDuel auf ihrem System schon installiert. "
								"Alle alten Dateien werden gelscht und die neuen werden installiert."))
		(set #select_destination "Bitte whlen Sie aus, wo das BattleDuel-Verzeichnis erzeugt werden soll")
		(set #destination_help (cat "Whlen Sie eine Partition oder ein Verzeichnis aus. "
											"Ein Verzeichnis mit dem Namen 'BattleDuel' wird dort erzeugt."))
		(set #install_to1 "\nBattleDuel nach \"")
		(set #install_to2 "\" installieren?")
		(set #startup "Ergnze user-startup")
		(set #startup_help "Dieser Assign wird von BattleDuel gebraucht")
		(set #have_fun "Viel Spa mit BattleDuel...")
		(set #which_chipset "Welchen Chipsatz haben Sie?")
		(set #chipset_help (cat "Wenn Sie einen Amiga 4000, A1200 oder eine Grafikkarte "
										"besitzen, dann mssen Sie AGA whlen, ansonsten ECS!"))
		(set #want_mwb_icons "Wollen Sie MagicWB Icons installieren?")
		(set #mwb_icons (cat "MagicWB ist ein Set von Icons mit 8 Farben.\n"
									"MagicWB ist  by Martin Huttenloher"))
		(set #error_extract (cat "Fehler beim Entpacken der Datei: "))
	)
	(
		(set #hello "\nWelcome to the BattleDuel Installation\nand update\n\n\Version 1.03")
		(set #update (cat "You already have BattleDuel installed on your system. "
								"All old files will be deleted and the new ones installed."))
		(set #select_destination "Select the location to install the BattleDuel directory")
		(set #destination_help (cat "Choose a destination partition or directory. "
											"A directory called 'BattleDuel' will be created there."))
		(set #install_to1 "\nInstall BattleDuel to \"")
		(set #install_to2 "\" ?")
		(set #startup "Adding assign to user-startup")
		(set #startup_help "This assign is needed by BattleDuel!")
		(set #have_fun "Have fun with BattleDuel...")
		(set #which_chipset "Which Chipset do you have?")
		(set #chipset_help (cat "If you own an Amiga 4000, A1200 or a graphicboard then "
										"you must select AGA, otherwise you must select ECS!"))
		(set #want_mwb_icons "Do you want to install MagicWB icons?")
		(set #mwb_icons (cat "MagicWB is a set of nice icons with 8 colors.\n"
									"MagicWB is  by Martin Huttenloher"))
		(set #error_extract (cat "Error while extracting from file: "))
	)
)

;======================================================================
; variables
;======================================================================

(set inputdir	(pathonly @icon))		; from where we were started
(set bd_drawer "BattleDuel")			; destination drawer name
(set bd_dest	(getassign "BD"))		; default destination

;======================================================================
; welcome
;======================================================================

(message #hello)

;======================================================================
; already there?
;======================================================================

(if (<> bd_dest "")
	(; update
		(set update true)
		(message #update)
	)
	(; first installation
		(set update false)
		(set bd_dest
			(askdir
				(prompt #select_destination)
				(default "Work:")
				(help #destination_help)
			)
		)
	)
)
(set @default-dest bd_dest)

;======================================================================
; delete old files
;======================================================================

;(if (= update true)
;	(
;		(set del_pattern "#?")
;		(foreach bd_dest del_pattern
;			(delete (tackon bd_dest @each-name))
;		)
;	)
;)

;======================================================================
; make directory
;======================================================================

(if (= update false)
	(
		(set bd_dest (tackon bd_dest bd_drawer))
		(message (cat #install_to1 bd_dest #install_to2))
		(makedir bd_dest (infos))
		(makeassign "BD" bd_dest)
	)
)

;======================================================================
; ask for chipset
;======================================================================

(set aga
	(askbool
		(prompt #which_chipset)
		(help #chipset_help)
		(choices "ECS" "AGA")
		(default 1)
	)
)

;======================================================================
; extract files
;======================================================================

(procedure extract
	(set lx (cat "lx -a -m -q x \"" (tackon inputdir current) ".lha\" * " (tackon "BD:" dir_dest)))
	(working "Installing " current)
	(if (<> (run lx) 0)
		(message #error_extract current)
	)
) 

(complete 0)
(set current "Program")             (set dir_dest "") (extract)
(complete 10)
(if (= update false)
(
	(if (= aga 1)
		( (set current "Gfx_ECS")        (set dir_dest "Gfx/ECS/") (extract)
		  (set current "Landscapes_ECS") (set dir_dest "Landscapes/ECS/") (extract) )
		( (set current "Gfx_AGA")        (set dir_dest "Gfx/AGA/") (extract)
		  (set current "Landscapes_AGA") (set dir_dest "Landscapes/AGA/") (extract) )
	)
	(complete 20)
	(set current "Mods")                (set dir_dest "Mods/") (extract)
	(complete 50)
	(set current "Settings")            (set dir_dest "Settings/") (extract)
	(complete 60)
) )

;======================================================================
; copy selected language
;======================================================================

(if (= @language "deutsch")
	( (set current "Deutsch") (set dir_dest "") (extract) )
	( (set current "English") (set dir_dest "") (extract) )
)
(complete 70)

;======================================================================
; add MagicWB icons?
;======================================================================

(set mwb
	(askbool
		(prompt #want_mwb_icons)
		(help #mwb_icons)
		(choices "Yes" "No")
		(default 1)
	)
)

(if (= mwb 1)
	( (set current "MWB_Icons") (set dir_dest "") (extract) )
	( (set current "Icons") (set dir_dest "") (extract) )
)
(complete 80)

;======================================================================
; set tooltypes
;======================================================================

(if (= aga 1)
	(tooltype
		(dest "BD:BattleDuel")
		(settooltype "DISPLAY_ID"   "0x0")
		(settooltype "DISPLAY_TYPE" "ECS")
	)
	(tooltype
		(dest "BD:BattleDuel")
		(settooltype "DISPLAY_ID"   "0x0")
		(settooltype "DISPLAY_TYPE" "AGA")
	)
)
(complete 90)

;======================================================================
; modify user-startup
;======================================================================

(if (= update false)
	(
		(startup "BattleDuel"
			(prompt #startup)
			(command (cat "Assign >NIL: BD: " bd_dest))
			(help #startup_help)
		)
	)
)

(complete 100)

(exit #have_fun)
