;$VER: Image Descriptor 2 Setup Script (10.01.2000) 
;

(ONERROR (CLEANUP))

;-- cleanup
(procedure CLEANUP
	(delete "t:install")
)

;--

(procedure SETUP

(if
	(>= (/ @installer-version 65536) "44")
	(
	(effect "lower_center" "horizontal" $00ff00 $000000)
	(showmedia "picture" "installerfx/install.iff" "upper_center" "none" 0)
	)
)

(if 
	(< (/ @installer-version 65536) "44")
(
(copyfiles 
	(prompt "preparing...")
			(help @copyfiles-help)
			(source "installerfx/install.iff")
			(dest "t:")
			(newname "install")
			(nogauge)
)
(copyfiles 
	(prompt "preparing...")
			(help @copyfiles-help)
			(source "installerfx/install.prefs")
			(dest "t:")
			(newname "install.prefs")
			(nogauge)
)
(run "run <>nil: installerfx/installerfx t:install")
)
)

(message
	"\n\n\n"
	@app-name " is MAILWARE\n"
	"(it means You must send me an e-mail)\n\n"
	@app-name " supports GIF format for\n"
	"loading and saving but do not (de)compress it\n"
	"so LZW algorithms are not used here\n\n"
	"If that method of using GIF is illegal too\n"
	"please let me know and GIF support will be removed"
)
(set #icon
	(askchoice
		(prompt "Please select Icons style.\n")
		(help	@askchoice-help)
		(choices
		   "[2pStandard 4 colors icons"
		   "8 colors MagicWB icons"
		   "Multicolor NewIcons icons"
		)
	)
)
(set #doc-type
	(askchoice
		(prompt "Please select Documentation type.\n")
		(help	@askchoice-help)
		(choices
			"[2pASCII text file"
			"AmigaGuide ® document"
		)
	)
)
(set #dest
	(askdir
		(prompt ("Please select drawer for " @app-name " main program.\n"))
		(help @askdir-help)
		(default "SYS:")
	)
)
(set #doc_dest
	(askdir
		(prompt "Please select drawer for documentation files.\n")
		(help @askdir-help)
		(default "HELP:english")
	)
)


(message
	"\n\n\n\n\n\nInstaller has enough information now to begin "
	"installation\n\n"
)

; 	installing
;	----------

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

(copyfiles
	(prompt "Copying " @app-name " main program ...\n")
	(source "Program/id2")
	(dest #dest)
)

(set #main_name (tackon #dest "id2"))
(set #main_icon (tackon #dest "id2.info"))

;	copying .guide or .txt doc files
;	--------------------------------

(if
	(= #doc-type "1")
	(
		(copyfiles
			(prompt "Copying AmigaGuide file ...\n")
			(help @copyfiles-help)
			(source "program/id2.guide")
			(dest #doc_dest)
			(newname "id2.guide")
		)
	(set #doc_name (tackon #doc_dest "id2.guide"))
	)
)
(if
	(= #doc-type "0")
	(
		(copyfiles
            (prompt "Copying Text file ...\n")
			(help @copyfiles-help)
			(source "program/id2.txt")
			(dest #doc_dest)
			(newname "id2.txt")
		)
	(set #doc_name (tackon #doc_dest "id2.txt"))
	)
)

(if
	(= #icon "0")
	(
       		(copyfiles
			(help @copyfiles-help)
			(source "Icons/nor/id2.info")
			(dest #dest)
		)
	)
)
(if
	(= #icon "1")
	(
       		(copyfiles
			(help @copyfiles-help)
			(source "Icons/mwb/id2.info")
			(dest #dest)
		)
	)
)
(if
	(= #icon "2")
	(
       		(copyfiles
			(help @copyfiles-help)
			(source "Icons/new/id2.info")
			(dest #dest)
		)
	)
)

(working "Creating unInstall information ...")
(textfile
	(prompt	"Creating unInstall information ...")
	(help " ")
	(dest "ENVARC:ImageDescriptor/unInstall")
	(append "delete <>NIL: ENVARC:ImageDescriptor force all\n")
	(append "delete <>NIL: ENV:ImageDescriptor force all\n")
	(append "delete <>NIL: "#main_name" force\n")
	(append "delete <>NIL: "#main_icon" force\n")
	(append "delete <>NIL: "#doc_name" force\n")
)
(CLEANUP)
(exit 	"\n\n\n\n"
	@app-name " was succesfully instaled in\n" #dest "\n\n"
	"To remove it please use this script again\n\n"
	"Thank you for choosing " @app-name "\nHope you enjoy it."
(quiet))
)
;	Uninstall procedure
;	-------------------
(procedure REMOVE
(set #temp "envarc:imagedescriptor")
(set #un_standard (tackon #temp "uninstall"))
(set #ask_std "0")

(set @abort-button "Abort")
(set @proceed-button "Begin ")

(set @user-level 2)

(set #details_std (getenv "imagedescriptor/uninstall"))

(message
	"\n\n\n"
	"Installer has found uninstall information\n"
	"and its ready to remove files.\n\n"
	"Make sure that any of "@app-name" files \n"
	"are not in use during uninstall process\n\n"
	"Press HELP for details\n\n"
	(help "Installer has found uninstall information\n"
	"and will perform following commands:\n\n"
	#details_std)
)

(working "Removing files ...")
(execute #un_standard)

(set @abort-button "Abort")
(set @proceed-button "Done")

(if
(= #what_do "1")
(exit 	"\n\n\n\n\n\n"
	@app-name " was succesfully uninstaled."
	"\n\nThank You."
	(quiet))
)
)
;	begin
(trap CLEANUP)
(message "\n\nWelcome to " @app-name " Setup\n"
	 "------------------------------------\n\n\n"
	 @app-name " created by\n(c) 2000 Tomasz Malerczyk"
	 "\n\n\n"
	 "\n\n"
	 "Do you wish to proceed?"
)
(if (=(exists "envarc:imagedescriptor/uninstall") 0)
	(SETUP)
)	

(set #what_do
(askchoice
	(prompt @app-name " is already installed\nYou have two choices")
	(help)
	(choices
		"[2pInstall again and do not remove current installed version."
		"Automatically remove it from my system."
	)
	(default 1)
))
(if
	(= #what_do "0")
		(
		(SETUP)
		)
)
(REMOVE)
(exit (quiet))
(welcome "Image Descriptor 2")
