;$VER: Image Descriptor Install Script 1.4 (28.12.98) hApPy NeW yEaR `99

(onerror (CLEANUP))
(procedure CLEANUP
	(delete "t:gfx1")
    (delete "t:gfx1.prefs")
	(exit "\n\n\n\nInstallation aborted !\n\n\nBecouse installation was aborted it is unable to uninstall files already copied.\n\nCheck what happens and try again ..." (quiet))
)

(set @user-level 2)
(set #version @installer-version)
(set #ver (/ #version 65536))
(if (< #ver 43)
	(exit "\n\n\n\nYou have incorrect version of Installer." (quiet))
)
(working "Please wait... Installer preparing files.")
(if
	(= (exists "S:.owner") "1")
    (
		(copyfiles
			(prompt "Working ...\n")
			(source "s:.owner")
			(dest "env:")
			(newname "emax.temp")
			(nogauge)
		)
        (delete "s:.owner")
	)
)
(if
	(= (exists "env:emax_owner.idf") "0")
	(rename "env:emax.temp" "env:emax_Owner.idf")
	(delete "env:emax.temp")
)

(set #user_name (getenv "emax_owner.idf"))
(copyfiles
	(prompt "Working ...\n")
	(source "installerfx/install_lo.iff")
	(dest "T:")
	(newname "gfx1")
	(help	@copyfiles-help)
	(nogauge)
)
(copyfiles
	(prompt "Working ...\n")
	(source "installerfx/install.prefs")
	(dest "T:")
	(newname "gfx1.prefs")
	(help	@copyfiles-help)
	(nogauge)
)

(run "run installerfx/InstallerFX T:GFX1")

(set #hi_user ("\nHello %s !" #user_name))
(message #hi_user
	"\nWelcome to Image Descriptor 1.4.3 Installation Script\n"
	"------------------------------------\n\n"
	 "Created by Tomasz Malerczyk\n(c)1998 Emax SC.\n\n"
	 "This script will install Image Descriptor 1.4.3 on your Amiga\n\n"
	 "\n\n"
	 "Do you wish to proceed?"
)

(message
	"IMPORTANT !\n"
	"---------------\n"
	"Image Descriptor operates on ILBM and GIF images but don`t "
	"decompress it.\nSo it don`t use any (de)compress algorithms.\n"
	"Installer script powered by InstallerFX by TRIUMPH\n\n"
	"Image Descriptor use great requester toolkit called:\n"
	"reqtools.library\n"
	"Copyright by Nico François and Magnus Holmgren.\n\n"
	"Image Descriptor was coded in pure assembler using:\n"
	"ASM-PRO by GENETIC\n"
	"http://surf.to/asmpro"
)

(set #imie
(askstring
	(prompt
		"Image Descriptor - Ownership Information\n\n"
		"Please enter your name, it will be used in ABOUT info\n"
		"to show who is owner of this Image Descriptor copy"
	)
    (help   @askstring-help)
	(default #user_name)
)
)

(makedir "ENVARC:ImageDescriptor"
	(prompt "Creating ImageDescriptor drawer in ENVARC:\n")
	(help	@makedir-help)
)

(textfile
	(prompt "Creating ownership file ...\n")
	(help	@textfile-help)
	(dest	"EnvArc:emax_Owner.idf")
	(append	#imie)
)

(set #icon
	(askchoice
		(prompt "Please select Icons style.\n")
		(help	@askchoice-help)
		(choices
		   "Standard"
		   "MagicWB"
		   "NewIcons"
		)
	)
)

(set #doc-type
	(askchoice
		(prompt "Please select Documentation type.\n")
		(help	@askchoice-help)
		(choices
			"Standard text file"
			"Amiga Guide document"
		)
	)
)

(set #dest
(askdir
	(prompt ("Please select drawer for %s main program.\n" @app-name))
	(help @askdir-help)
	(default "Work:")
))

(set #doc_dest
(askdir
	(prompt "Please select drawer for documentation files.\n")
	(help @askdir-help)
	(default "HELP:english")
))

(copylib
	(prompt "Installing reqtools.library ...\n")
	(source "libs/reqtools.library")
	(dest "LIBS:")
	(help	@copylib-help)
	(confirm 0)
)

(if
	(= (exists "C:MultiView") "0")(
    (set #mv_check
		(askbool
			(prompt "\n"
					"Installer could not find MultiView in C: drawer."
					"\n\n\n"
					"You will be asked for MultiView location and then "
					"Installer will copy it to C: drawer"
					"\nYou may skip this part and copy it by yourself."
					"\n\n\nIf you do not copy MultiView to C: drawer "
					"Image Descriptor will disable View option."
			)
			(help @askbool-help)
			(default 1)
        	(choices "Proceed" "Skip this part")
		)
	)
	(if
		(= #mv_check "1")
		(
		(set #mv_location
		(askdir
			(prompt "Where is MultiView")
			(help @askdir-help)
            (default "sys:utilities")
		))
		(set #mv_file (tackon #mv_location "MultiView"))
		(copyfiles
			(prompt "Copying MultiView\n")
			(source #mv_file)
			(dest "C:")
			(optional "nofail")
		)
		)
    )
	)
)

(copyfiles
	(prompt "Copying Image Descriptor main program ...\n")
	(source "Program/ID")
	(dest #dest)
)
(set #td_name (tackon #dest "ID"))
(set #main_name (tackon #dest "ID*"))
(set #main_icon (tackon #dest "ID.info*"))

(if
	(= #doc-type "1")
	(
		(copyfiles
			(prompt "Copying AmigaGuide file ...\n")
			(help)
			(source "program/id.guide")
			(dest #doc_dest)
			(newname "ID.Guide")
		)
	(set #doc_name (tackon #doc_dest "ID.Guide*"))
	)
)

(if
	(= #doc-type "0")
	(
		(copyfiles
            (prompt "Copying Text file ...\n")
			(help)
			(source "program/id.txt")
			(dest #doc_dest)
			(newname "ID.Txt")
		)
	(set #doc_name (tackon #doc_dest "ID.Txt*"))
	)
)

(if
	(= #icon "0")
    (
       	(copyfiles
			(help @copyfiles-help)
			(source "Icons/nor/ID.info")
			(dest #dest)
		)
        (if
			(= #doc-type "0")
            (
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/nor/id.guide.info")
                    (dest #doc_dest)
                    (newname "ID.Txt.info")
				)
            (set #doc_icon (tackon #doc_dest "ID.Txt.info*"))
			)
		)
		(if
			(= #doc-type "1")
			(
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/nor/ID.Guide.info")
					(dest #doc_dest)
    				)
            (set #doc_icon (tackon #doc_dest "ID.Guide.info*"))
			)
		)
	)
)

(if
	(= #icon "1")
    (
       	(copyfiles
			(help @copyfiles-help)
			(source "Icons/mwb/ID.info")
			(dest #dest)
		)
		(if
			(= #doc-type "0")
            (
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/mwb/id.guide.info")
                    (dest #doc_dest)
					(newname "ID.Txt.info")
				)
            (set #doc_icon (tackon #doc_dest "ID.Txt.info*"))
			)
		)
		(if
			(= #doc-type "1")
			(
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/mwb/ID.Guide.info")
					(dest #doc_dest)
				)
            (set #doc_icon (tackon #doc_dest "ID.Guide.info*"))
			)
		)
	)
)

(if
	(= #icon "2")
    (
       	(copyfiles
			(help @copyfiles-help)
			(source "Icons/new/ID.info")
			(dest #dest)
		)
		(if
			(= #doc-type "0")
            (
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/new/ID.Guide.info")
                    (dest #doc_dest)
					(newname "ID.Txt.info")
				)
            (set #doc_icon (tackon #doc_dest "ID.Txt.info*"))
			)
		)
		(if
			(= #doc-type "1")
			(
				(copyfiles
					(help @copyfiles-help)
					(source "Icons/new/ID.Guide.info")
					(dest #doc_dest)
				)
            (set #doc_icon (tackon #doc_dest "ID.Guide.info*"))
			)
		)
	)
)
(if
	(= (exists "S:ToolsDaemon.menu") "1")
		(
		(if
			(= (exists "sys:prefs/ToolsPrefs") "1")
			(
		        (set #td_check
				(askbool
				(prompt "\n"
					"Installer detects ToolsDaemon installed on your AMIGA"
					"\n\n\n"
					"Would you like to add Image Descriptor to your "
					"ToolsDaemon menu?"
					"\nIf you select Proceed Installer will add new item at "
					"the BOTTOM of items list.\n"
					"Then ToolsPrefs will be launched so you can place Image Descriptor "
					"in your desired menu or submenu"
				)
				(help @askbool-help)
				(default 1)
        		(choices "Proceed" "Skip this part")
				))
     (if
		(= #td_check "1")
		(
        (working "Adding new item to ToolsDaemon menu..")
		(copyfiles
			(source "s:toolsdaemon.menu")
			(dest "s:backup_of_toolsdaemon.menu")
            (nogauge)
			(optional "nofail")
		)
		(copyfiles
			(source "s:toolsdaemon.menu")
			(dest "t:")
			(nogauge)
			(optional "nofail")
		)
		(run "installerfx/item.exe")
        (textfile
			(prompt)
            (dest "T:menu")
            (include "T:toolsdaemon.menu")
			(append " Image Descriptor\n")
			(append "(WB) ")
			(append #TD_NAME)
			(append "\nEND\n")
			)
		(run "sys:prefs/toolsprefs T:menu")
		(delete "t:toolsdaemon.menu")
		(delete "t:menu")
        ))
	)
) )    )

(working "Creating unInstall information ...")
(textfile
	(prompt	"Creating unInstall information ...")
	(help	@textfile-help)
	(dest	"ENVARC:ImageDescriptor/unInstall")
	(append "ENVARC:ImageDescriptor/unInstall*")
	(append "ENVARC:ImageDescriptor*")
	(append #main_name)
    (append #main_icon)
	(append #doc_name)
	(append #doc_icon)
)

(delete "t:gfx1")
(delete "t:gfx1.prefs")

(exit "\n\n\n\n\n\nThank you for choosing Image Descriptor\nHope you enjoy it." (quiet))
(welcome "Nice trick ;-). Greetinx to all my friends ...")
