; $VER: Install-SummertimeGuard 0.10 (5.9.98)

(set current_version "0.9")
(set #lng @language)

(complete 0)

; ====================
; Locale strings

(set #msg_intro0 (cat "\n\nSummertime Guard " current_version "\n\nCopyright © 1998 Eelke Blok"))

; English, all strings are first set to their English version.
(set #msg_intro1 "Utility for automatic summertime control.")
(set #msg_intro2 "Please make sure your Locale-settings are correct before running this script.")

(set #msg_destdir "Please select a location for Summertime Guard.\nA drawer called 'SummertimeGuard' will be created.")

(set #msg_previnst "A previous installation of Summertime Guard has been found.\nDo you want to replace it with this one or do you want to abort the installation?")
(set #msg_previnsthelp1 "The installation-program has found out that the drawer ")
(set #msg_previnsthelp2 " already exists and/or that your WBStartup drawer already contains Summertime Guard. If the found installation is a newer version then the one that is being installed now, do not proceed.")
(set #msg_proceed "Replace")
(set #msg_abort "Abort")

(set #msg_aborttext "The installation of Summertime Guard has been aborted.")

(set #msg_copyexe "This file will be copied to\n")
(set #msg_copydoc "These documentation files will be copied to\n")
(set #msg_copydata1 "The data-file will be copied to\n")
(set #msg_copydata2 "\nThis is HIGHLY recommended. Summertime Guard will not be able to function without it.")
(set #msg_exewbstartup "SummertimeGuard will now be copied to WBStartup,\nso that summertime is checked each time the computer starts.")
(set #msg_datas "The datafile will be copied to S:\nSummertime Guard doesn't need this, but it will mean\nminimum hassle when you move your Amiga.")
(set #msg_copycat "The following catalog will be installed.")
(set #msg_installrun "Summertime Guard will now be started\nto complete the installation.")

(if (= #lng "nederlands")
	(   (set #msg_intro1 "Programma voor automatische zomertijd controlle.")
		(set #msg_intro2 "Verzeker u er alstublieft van dat uw Locale-intellingen correct zijn voordat u dit script draait.")

		(set #msg_destdir "Selecteer alstublieft een locatie voor Summertime Guard.\nEen lade met de naam 'SummertimeGuard' zal worden aangemaakt.")

		(set #msg_previnst "Een bestaande installatie van Summertime Guard is gevonden.\nWilt u hem vervangen door deze of wilt u de installatie annuleren?")
		(set #msg_previnsthelp1 "Het installatie-programma heeft ontdekt dat de lade ")
		(set #msg_previnsthelp2 " bestaat en/of dat uw WBStartup lade Summertime Guard al bevat. Als de gevonden installatie een nieuwere versie is dan die welke wordt geïnstalleerd, dan kunt u de installatie beter afbreken.")
		(set #msg_proceed "Vervang")
		(set #msg_abort "Afbreken")

		(set #msg_aborttext "De installatie van Summertime Guard is afgebroken.")

		(set #msg_copyexe "Dit bestand zal worden gecopieerd naar\n")
		(set #msg_copydoc "Deze documentatie bestanden zullen worden gecopieerd naar\n")
		(set #msg_copydata1 "Het databestand zal worden gecopieerd naar\n")
		(set #msg_copydata2 "\nDit is ten HOOGSTE aanbevolen. Summertime Guard zal zonder het niet correct functioneren.")
		(set #msg_exewbstartup "SummertimeGuard zal nu naar WBStartup gecopieerd worden,\nzodat de zomertijd iedere keer dat de computer opstart\nwordt gecontroleerd.")
		(set #msg_datas "Het databestand zal naar S: worden gecopieerd.\nSummertime Guard heeft dit niet nodig, maar het\nminimaliseert de problemen wanneer u uw Amiga verplaatst.")
		(set #msg_copycat "De volgende 'catalog' zal worden geïnstalleerd.")
		(set #msg_installrun "Summertime Guard zal nu worden gestart\nom de installatie te voltooien.")
	)
)
; *** Say hello
(message #msg_intro0 "\n\n\n\n" #msg_intro1 "\n\n" #msg_intro2 (all))

; *** Ask for destination drawer
(set @default-dest
	(askdir
		(prompt #msg_destdir)
		(help @askdir-help)
		(default @default-dest)
	)
)

(set @default-dest (expandpath @default-dest))

(set #destination (tackon @default-dest "SummertimeGuard"))

(if (OR (<> (exists #destination) 0) (<> (exists "SYS:WBStartup/SummertimeGuard") 0))
	(if (= (askbool (prompt #msg_previnst) (help #msg_previnsthelp1 #destination #msg_previnsthelp2) (choices #msg_abort #msg_proceed)) 1)
		(exit #msg_aborttext (quiet))
	)
)

(complete 5)

; *** Now we should have lost everyone that doesn't want to install the program.
; *** Now, the directory will be created.
(if (= (exists #destination) 0) (makedir #destination (infos)))

; *** The main executable will be copied to the destination.
(copyfiles
	(prompt #msg_copyexe #destination)
	(help @copyfiles-help)
	(source "SummertimeGuard")
	(dest #destination)
	(infos)
	(confirm "expert")
)

(complete 20)

; *** The documentation will be copied to the destination.
(set #docdef (cat "Documentation/SG_" #lng ".guide"))
(if (= (exists #docdef) 0)
	(set #docdef (cat "Documentation/SG_English.guide"))
)
(if (= @user-level 2)
	(copyfiles
		(prompt #msg_copydoc #destination)
		(help @copyfiles-help)
		(source "Documentation/")
		(all)
		(dest #destination)
		(infos)
		(confirm "expert")
	)
	(copyfiles
		(source #docdef)
		(dest #destination)
		(infos)
	)
)

(complete 35)

; *** The datafile will be copied to the destination.
(copyfiles
	(source "SummertimeGuard.data")
	(dest #destination)
	(infos)
)

(complete 50)

; *** The main executable will be copied to WBStartup.
(copyfiles
	(prompt #msg_exewbstartup)
	(help @copyfiles-help)
	(source "SummertimeGuard")
	(dest "SYS:WBStartup")
	(infos)
	(confirm "expert")
)

(complete 65)

; *** The datafile will be copied to S:.
(copyfiles
	(prompt #msg_datas)
	(help @copyfiles-help)
	(source "SummertimeGuard.data")
	(dest "S:")
	(infos)
	(confirm "average")
)

(complete 80)

; *** The catalog will be copied to SYS:catalogs if available
(set #defcat (cat "Catalogs/" #lng "SummertimeGuard.catalog"))
(set #catdest (cat "SYS:Locale/Catalogs/" #lng))

(if (<> (exists #defcat) 0)
	(copyfiles
		(prompt #msg_copycat)
		(help @copyfiles-help)
		(source #defcat)
		(dest #catdest)
		(infos)
		(confirm "expert")
	)
)

(complete 95)

(message #msg_installrun (all))

(run "SummertimeGuard")

(complete 100)
