;======================================================================
;
; BattleDuel Install Script $VER: Install 1.6 (1.3.97)
;
; Copyright © 1995-1997 Jochen Terstiege
;
;======================================================================
;
;======================================================================
; language strings
;======================================================================

(set language
	(askchoice
		(prompt ("Please select a language:\nBitte wählen Sie eine Sprache aus:"))
		(help @askchoice-help)
		(choices "English"
					"Deutsch")
	)
)

(if (= language 0)
	(
		(set #hello "\nWelcome to the BattleDuel Installation and Update\n\n\Version 1.6.80")
		(set #update (cat "BattleDuel is already installed on your system. "
								"All old files will be deleted and the new ones installed."))
		(set #select_destination "Select the location where the BattleDuel directory should be created")
		(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 #have_fun "Have fun with BattleDuel...")
		(set #which_chipset "Which Chipset do you have?")
		(set #chipset_help (cat "If you own an Amiga 4000, Amiga 1200 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 #warning_msg (cat "This update should only be used with version 1.5.42 of BattleDuel! "
									"If you apply it to an older version, there could be some problems "
									"with the old landscapes. If you are a registered user, you should "
									"contact the authors to get the right update."))
		(set #assign_msg (cat "The assign BD: is no longer necessary. Please remove the line from "
									"your user-startup."))
		(set #registered_msg (cat "You are a registered user. Please contact the authors to get "
									"the remaining new landscapes!"))
	)
	(
		(set #hello "\nWillkommen zur BattleDuel Installation und Update\n\n\Version 1.6.80")
		(set #update (cat "BattleDuel ist auf ihrem System schon installiert. "
								"Alle alten Dateien werden gelöscht und die neuen werden installiert."))
		(set #select_destination "Bitte wählen Sie aus, wo das BattleDuel-Verzeichnis erzeugt werden soll")
		(set #destination_help (cat "Wählen 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 #have_fun "Viel Spaß mit BattleDuel...")
		(set #which_chipset "Welchen Chipsatz haben Sie?")
		(set #chipset_help (cat "Wenn Sie einen Amiga 4000, Amiga 1200 oder eine Grafikkarte "
										"besitzen, dann müssen Sie AGA auswählen, 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 #warning_msg (cat "Dieses Update sollte nur mit Version 1.5.42 von BattleDuel "
									"benutzt werden! Wenn Sie es auf eine ältere Version anwenden, "
									"gibt es evtl. Probleme mit den alten Landschaften. "
									"Wenn Sie registrierter Benutzer sind, kontaktieren Sie die Autoren, "
									"um ein passendes Update zu bekommen."))
		(set #assign_msg (cat "Das Assign BD: wird nicht mehr benötigt! Bitte entfernen Sie es aus "
									"der User-Startup."))
		(set #registered_msg (cat "Sie sind registrierter Benutzer. Bitte kontaktieren Sie die "
									"Autoren, um die restlichen neuen Landschaften zu bekommen!"))
	)
)

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

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

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

(message #hello)

;======================================================================
; ask for directory
;======================================================================

(set def (getassign "BD"))		; default destination
(if (= def "")
	(
		(set def "Work:")
		(set bd_dest
			(askdir
				(prompt #select_destination)
				(default def)
				(help #destination_help)
			)
		)
		(set bd_dest (tackon bd_dest bd_drawer))
		(message (cat #install_to1 bd_dest #install_to2))
		(makedir bd_dest (infos))
		(set update false)
	)
	(
		(set assign true)
		(set bd_dest def)
		(set update true)
	)
)

(makeassign "BD" bd_dest)
(set @default-dest bd_dest)

(if (= update true)
	(message #update)
)

;======================================================================
; check for old version
;======================================================================

(if (= update true)
	(	(set version (getversion "BD:BattleDuel"))
		(set ver (/ version 65536))
		(set rev (- version (* ver 65536)))
		(if (and (= ver 1) (< rev 5))
			( (message #warning_msg) )
		)
	)
)
;======================================================================
; ask for chipset
;======================================================================

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

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

(if (= update true)
	(
		(if (= aga 1)
			( (delete "BD:Landscapes/ECS/LandscapeUR.iff") )
			( (delete "BD:Landscapes/AGA/LandscapeUR.iff") )
		)
	)
)

;======================================================================
; copy files
;======================================================================

(complete 0)

(makedir "BD:Gfx")
(makedir "BD:Landscapes")
(makedir "BD:Mods")
(makedir "BD:Settings")

(complete 10)
(copyfiles (source "BattleDuel") (dest "BD:"))

(complete 20)
(if (= aga 1)
	(	(makedir "BD:Gfx/ECS")
		(copyfiles (source "Gfx/ECS") (dest "BD:Gfx/ECS") (all))
	)
	(	(makedir "BD:Gfx/AGA")
		(copyfiles (source "Gfx/AGA") (dest "BD:Gfx/AGA") (all))
	)
)

(complete 30)
(if (= aga 1)
	(	(makedir "BD:Landscapes/ECS")
		(copyfiles (source "Landscapes/ECS") (dest "BD:Landscapes/ECS") (all))
	)
	(	(makedir "BD:Landscapes/AGA")
		(copyfiles (source "Landscapes/AGA") (dest "BD:Landscapes/AGA") (all))
	)
)
	
(complete 40)
(copyfiles (source "Mods") (dest "BD:Mods") (all))
(complete 50)
(copyfiles (source "Settings") (dest "BD:Settings") (all))
(complete 60)

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

(if (= language 0)
	( (copyfiles (source "English") (dest "BD:") (all)) )
	( (copyfiles (source "Deutsch") (dest "BD:") (all)) )
)
(complete 70)

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

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

(if (= mwb 1)
	( (copyfiles (source "MWB_Icons") (dest "BD:") (all)) )
	( (copyfiles (source "Icons") (dest "BD:") (all)) )
)
(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)

(if (= assign true)
	( (message #assign_msg) )
)

(if (or (exists ("BD:BattleDuel.key"))
		  (exists ("devs:BattleDuel.key"))
		  (exists ("s:BattleDuel.key")) )
	( (message #registered_msg) )
)

(makeassign "BD")

(complete 100)

(exit #have_fun)
