; Install script for Address
; This script is Copyrighted © 1997 - 1998 by Kristoffer Larsson

(set #wrong-kickstart
	(cat "You must upgrade to Kickstart 2.04 to be able to use this program!")
)

(set #ask-assign
	(cat "In order to use Address, the logical device name\n"
		 "\"Address:\" must be assigned to the drawer where\n"
		 "you have chosen to install Address. Either the\n"
		 "installation script can add this assign to your\n"
		 "\"S:User-Startup\" file or you must add the assign\n"
		 "manually.\n\n"
		 "Would you like the installation script to\n"
		 "automatically add the necessary assign to your\n"
		 "\"S:User-Startup\" file?")
)

(set #ask-assign-help
	(cat "In order to use Address the logical device name \"Address:\" "
		 "must be assigned to the drawer where you have chosen to "
		 "install the files in this package, i.e., the complete path "
		 "to the drawer \"Address\" which has been created on your "
		 "harddisk/floppy disk.\n\n"
         "The installation script can add this assign to your \"S:User-Startup\" "
		 "file automatically. If you don't wish the script to edit your file "
		 "you must manually add the assign to your \"S:User-Startup\"; otherwise "
		 "Address won't work properly.\n\n")
)

(set #installing-program
	(cat "Installing Address into the drawer you have chosen ...")
)

(set #installing-example
	(cat "Installing an example database ...")
)

(set #installing-documentation
	(cat "Installing the documentation ...")
)

(set #ask-icons
	(cat "Which set of icons would you like to install for the files in "
		 "this package?")
)

(set #ask-icons-help
	(cat "In today's Amiga world a great number of different sets of icons "
		 "exist, such as NewIcons or MagicWB icons. With great help "
		 "from some icon designers I have compiled four different sets "
		 "of icons for the Address package. The icons in question belong "
         "to either of these sets:\n\n"
		 "NewIcons\n"
		 "MagicWB icons\n"
		 "FreshIcons\n"
		 "Standard Amiga icons\n\n"
		 "The last phrase is the term I use for describing the style of the standard Amiga "
		 "icons that were made by Commodore and that were installed when you "
		 "purchased your Amiga.")

)

(set #installing-newicons
    (cat "Installing the NewIcons especially made for Address ...")
)

(set #installing-magicwbicons
    (cat "Installing the MagicWB icons especially made for Address ...")
)

(set #installing-freshicons
    (cat "Installing the FreshIcons especially made for Address ...")
)

(set #installing-standardicons
	(cat "Installing the Standard Amiga icons especially made for Address ...")
)

(set #newicons
	(cat "NewIcons")
)

(set #magicwb
	(cat "MagicWB icons")
)

(set #freshicons
	(cat "FreshIcons")
)

(set #standard
	(cat "Standard Amiga icons")
)

(set #ask-language-help
	(cat "If your system is localized you might experience a not entirely "
		 "correct sorting of the names in the Main Window of Address. "
         "The reason for this is that some of the \"LOCALE:Languages/#?.language\" files "
		 "that Commodore once manufactured are incorrect in certain respects or even missing.\n\n"
		 "The faulty (or non-existent) files are:\n"
		 "\"svenska.language\"\n"
		 "\"norsk.language\"\n"
		 "\"íslenska.language\"\n"
		 "\"deutsch.language\"\n\n"
		 "This installation script can replace these faulty files with "
		 "correct ones by deleting, for example, \"LOCALE:Languages/svenska.language\" "
		 "from your harddisk/floppy disk and installing a correct \"svenska.language\" "
		 "in its place.")
)

(set #ask-language
	(cat "Is your system localized and is either of\n"
		 "\"svenska.language\", \"norsk.language\" or\n"
		 "\"deutsch.language\" installed in your\n"
	     "\"LOCALE:Languages/\"?\n"
         "Do you speak íslenska and would like a correct\n"
		 "\"íslenska.language\" installed in your system?\n\n"
		 "If your answer is \"yes\" to either or both of\n"
		 "the questions above, would you like the\n"
		 "installation script to replace these (probably)\n"
		 "faulty (or non-existent) files with correct ones?")
)

(set #choose-language
	(cat "Choose the file or files you wish to replace.")
)

(set #svenska
	(cat "svenska.language")
)

(set #norsk
	(cat "norsk.language")
)

(set #íslenska
	(cat "íslenska.language")
)

(set #deutsch
	(cat "deutsch.language")
)

(set installing-svenska
	(cat "Installing \"svenska.language\" into \"LOCALE:Languages/\" ...")
)

(set installing-norsk
	(cat "Installing \"norsk.language\" into \"LOCALE:Languages/\" ...")
)

(set installing-íslenska
	(cat "Installing \"íslenska.language\" into \"LOCALE:Languages/\" ...")
)

(set installing-deutsch
	(cat "Installing \"deutsch.language\" into \"LOCALE:Languages/\" ...")
)

(set #ask-drawer
	(cat "Select a drawer in which to install all the files "
		 "that are part of the Address distribution. "
		 "This installation script will create a drawer called \"Address\" "
         "in the drawer you choose here and install "
		 "the Address files into this drawer.")
)

(set #ask-drawer-help
	(cat "By selecting a particular drawer in the requester "
	     "you tell the installation script where it should "
		 "create a drawer called \"Address\".\n"
		 "To this drawer, i.e., \"Address\", the script will copy "
		 "all the files necessary to run Address.")
)

(set #welcome
	(cat "\n\nWelcome to Address 1.0\n\n"
     "All the files in this distribution are\n"
     "Copyrighted © 1997 - 1998 by Kristoffer Larsson\n"
     "All rights reserved")
)

(if (< (/ (getversion) 65536) 37)
	(
    	(abort #wrong-kickstart)
	)
)

(complete 0)

(welcome "\n\nWelcome to the Address installation!\n")

(message #welcome)

(complete 20)

(set @default-dest "SYS:")

(set destdir
	(askdir
   		(prompt #ask-drawer)
   		(help #ask-drawer-help)
   		(default @default-dest)
	)
)

(set programdir (tackon destdir "Address"))
(set @default-dest programdir)
(set datadir (tackon programdir "Data"))
(set docdir (tackon programdir "Documentation"))

(makedir programdir)
(makedir datadir)
(makedir docdir)

(copyfiles (prompt #installing-program)
	(source "Bin/Address")
	(dest programdir)
)

(copyfiles (prompt #installing-example)
	(source "Data/people.dat")
	(dest datadir)
)

(copyfiles (prompt #installing-documentation)
	(source "Documentation/Address.guide")
	(dest docdir)
)

(complete 40)

(set iconchoice
	(askoptions
		(prompt #ask-icons)
		(choices #newicons #magicwb #freshicons #standard)
        (default 1)
		(help #ask-icons-help)))

(if (<> 0 (BITAND iconchoice 1))
	(
    	(copyfiles (prompt #installing-newicons)
			(source "Icons/NewIcons/Address_Drawer.info")
            (newname "Address.info")
			(dest destdir))
		(copyfiles (prompt #installing-newicons)
			(source "Icons/NewIcons/Address.info")
			(dest programdir))
		(copyfiles (prompt #installing-newicons)
			(source "Icons/NewIcons/Address.guide.info")
			(dest docdir))
		(copyfiles (prompt #installing-newicons)
			(source "Icons/NewIcons/Documentation.info")
			(dest programdir))
	)
)

(if (<> 0 (BITAND iconchoice 2))
	(
		(copyfiles (prompt #installing-magicwbicons)
			(source "Icons/MagicWB/Address_Drawer.info")
            (newname "Address.info")
			(dest destdir))
		(copyfiles (prompt #installing-magicwbicons)
			(source "Icons/MagicWB/Address.info")
			(dest programdir))
		(copyfiles (prompt #installing-magicwbicons)
			(source "Icons/MagicWB/Address.guide.info")
			(dest docdir))
		(copyfiles (prompt #installing-magicwbicons)
			(source "Icons/MagicWB/Documentation.info")
			(dest programdir))
	)
)

(if (<> 0 (BITAND iconchoice 4))
	(
		(copyfiles (prompt #installing-freshicons)
			(source "Icons/FreshIcons/Address_Drawer.info")
            (newname "Address.info")
			(dest destdir))
		(copyfiles (prompt #installing-freshicons)
			(source "Icons/FreshIcons/Address.info")
			(dest programdir))
		(copyfiles (prompt #installing-freshicons)
			(source "Icons/Standard/Address.guide.info")
			(dest docdir))
		(copyfiles (prompt #installing-freshicons)
			(source "Icons/FreshIcons/Documentation.info")
			(dest programdir))
	)
)

(if (<> 0 (BITAND iconchoice 8))
	(
		(copyfiles (prompt #installing-standardicons)
			(source "Icons/Standard/Address_Drawer.info")
            (newname "Address.info")
			(dest destdir))
		(copyfiles (prompt #installing-standardicons)
			(source "Icons/Standard/Address.info")
			(dest programdir))
		(copyfiles (prompt #installing-standardicons)
			(source "Icons/Standard/Address.guide.info")
			(dest docdir))
		(copyfiles (prompt #installing-standardicons)
			(source "Icons/Standard/Documentation.info")
			(dest programdir))
	)
)

(complete 60)

(if
	(askbool
		(prompt #ask-language)
		(help #ask-language-help)
        (choices "Yes" "No"))
	(
		(set languagechoice
			(askoptions
				(prompt #choose-language)
				(choices #svenska #norsk #íslenska #deutsch)
    		    (default 1)
				(help #ask-language-help)
			)
		)

		(if (<> 0 (BITAND languagechoice 1))
   			(copyfiles (prompt #installing-svenska)
				(source "Languages/svenska.language")
				(dest "LOCALE:Languages/")
			)
		)

		(if (<> 0 (BITAND languagechoice 2))
   			(copyfiles (prompt #installing-norsk)
				(source "Languages/norsk.language")
				(dest "LOCALE:Languages/")
			)
		)

		(if (<> 0 (BITAND languagechoice 4))
   			(copyfiles (prompt #installing-íslenska)
				(source "Languages/íslenska.language")
				(dest "LOCALE:Languages/")
			)
		)

		(if (<> 0 (BITAND languagechoice 8))
   			(copyfiles (prompt #installing-deutsch)
				(source "Languages/deutsch.language")
				(dest "LOCALE:Languages/")
			)
		)
	)
)

(complete 80)

(set #add-to-startup
	(cat "assign Address: \"" (programdir) "\"\n"
	)
)

(if
	(askbool
		(prompt #ask-assign)
		(help #ask-assign-help)
        (choices "Yes" "No")
	)

	(startup "Address"
        (prompt "The following line will be added to your "
			"\"S:User-Startup\" file:\n\n"
            #add-to-startup)
        (help #ask-assign-help)
		(command #add-to-startup)
	)
)

(if (exists programdir)
		(makeassign "Address"
		(programdir)
		(safe)
	)
)

(complete 100)
