;$VER: Image Descriptor Setup Script 2.3 (1.12.2000) 
;


;··· ·· · cleanup · ·· ···

(procedure CLEANUP
	(delete "t:install")
	(delete "t:back")
)

(ONERROR (CLEANUP))

;··· ·· · Installation procedure · ·· ···

(procedure SETUP

(working "\n\n\n\n\nPreparing ...")

(copyfiles (prompt) (help @copyfiles-help) (source "installerfx/background.iff") (dest "t:") (newname "back") (nogauge))
(copyfiles (prompt) (help @copyfiles-help) (source "installerfx/background.prefs") (dest "t:") (newname "back.prefs") (nogauge))

(run "run <>nil: installerfx/installerfx t:back")

(copyfiles (prompt) (help @copyfiles-help) (source "installerfx/install.iff") (dest "t:") (newname "install") (nogauge))
(copyfiles (prompt) (help @copyfiles-help) (source "installerfx/install.prefs") (dest "t:") (newname "install.prefs") (nogauge))

(run "run <>nil: installerfx/installerfx t:install")

(run "wait 3")
(run "installerfx/wintofront")

(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 algorithm is 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"
)
(message
	"\n"
	"! !!   NEW   !! !\n\n\n\n\n"
	"::: :: :   Image Descriptor Lite!   : :: :::\n"
	"is now added for your enjoyment"
	"\n\n\n\n"
	"For more information look into\n"
	"Lite! Version drawer"
)

; Yep folks!, no more 8 colors MagicWB icons
; NewIcons rulez!

;ShowNI from NewIcons v4.6 package
;

(working	
	"\n\n\n\n"
	"Please select " #app-name " icon...\n\n"
	"If you cancel this, standard 4 color icon\n"
	"will be installed\n\n"
)
(if
	(=(exists "libs:newicon.library") 1)
	(
	(run 'installerfx/showni label="" title="Available icons" select icon/1_id2.info icon/2_id2.info icon/3_id2.info >ENV:.installtmp')
	)
)

(set #ni_selected (getenv ".installtmp"))

(if
(= #ni_selected "")
(set #ni_selected "icon/0_id2.info")
)

(message "\n\n"
	"Since v2.3, only AmigaGuide docs are available."
	"\n\n"
	"Furthermore, this guide is used as ONLINE help\n"
	"for Image Descriptor."
	"\n\n"
	"Files 'id2.guide' and 'id2arexx.guide' will be\n"
	"automaticaly copied into 'HELP:english' drawer\n"
	"(if available)"
)

;Only AmigaGuide is available since v2.3
;i`m to lazy to write 2 times the same things

(set #dest
	(askdir
		(prompt ("\nPlease select drawer for main program.\n"))
		(help @askdir-help)
		(default "Work:")
	)
)
;(set #doc_dest
;	(askdir
;		(prompt "\nPlease select drawer for AmigaGuide documentation.\n")
;		(help @askdir-help)
;		(default "HELP:english")
;	)
;)
(set #doc_dest "HELP:english")
(message
	"\n\n\n\n\n\n\nInstaller have enough informations now to begin "
	"installation\n\n"
)

;··· ·· · Create id2 drawer in ENVARC: · ·· ···
(working "\n\n\n\n\nCreating " #app-name " drawer in ENV: ...")
(makedir "ENVARC:ImageDescriptor"
	(prompt "")
	(help	@makedir-help)
)

;··· ·· · Copy main file · ·· ···
(working "\n\n\n\n\nCopying " #app-name " executable ...")
(copyfiles
	(prompt "")
	(source "Program/id2")
	(dest #dest)
	(nogauge)
)

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

;··· ·· · Copy documentation file · ·· ···
(working "\n\n\n\n\nCopying " #app-name " documentation ...")
(copyfiles
		(prompt "")
		(help @copyfiles-help)
		(source "docs/id2.guide")
		(dest #doc_dest)
		(newname "id2.guide")
		(nogauge)
)
(copyfiles
		(prompt "")
		(help @copyfiles-help)
		(source "docs/id2arexx.guide")
		(dest #doc_dest)
		(newname "id2arexx.guide")
		(nogauge)
)

(set #doc_name (tackon #doc_dest "id2.guide"))


;··· ·· · Copy icon · ·· ···
(working "\n\n\n\n\nCopying " #app-name " icon ...")
(copyfiles
	(prompt)
	(help @copyfiles-help)
	(source #ni_selected)
	(dest #dest)
	(newname "id2.info")
	(nogauge)
)

(copyfiles
	(prompt)
	(help @copyfiles-help)
	(source "icon/app_icon.info")
	(dest "envarc:imagedescriptor")
	(newname "id2.info")
	(nogauge)
)

(working "\n\n\n\n\nCreating uninstall information ...")
(textfile
	(prompt)
	(help @textfile-help)
	(dest "ENVARC:ImageDescriptor/version")
	(append #id_version)
)
(textfile
	(prompt)
	(help @textfile-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')
	(append "delete <>NIL: HELP:english/id2.guide force\n")
	(append "delete <>NIL: HELP:english/id2arexx.guide force\n")
)
(working "\n\n\n\n\nRemoving unwanted files ...")
(CLEANUP)
(exit 	"\n\n\n\n\n"
	"Thank you for choosing " #app-name "\nHope you enjoy it."
	"\n\nTo remove it please use this script again"
(quiet))
)

; ··· ·· · Uninstall procedure · ·· ···

(procedure REMOVE

(set #un_standard "envarc:imagedescriptor/uninstall")
(set #ask_std "0")

(set @user-level 2)
(set #details (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" "#ver_actual" 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 AmigaDOS commands:\n\n"
	#details)
)

(working "\n\n\n\n\nRemoving files ...")
(execute #un_standard)
(if
	(= #what_do "1")

	(exit 	"\n\n\n\n\n\n"
	@app-name " " #ver_actual " was succesfully uninstaled."
	"\n\nThank You."
	(quiet)
))
)
;··· ·· · Begin of script · ·· ···

(trap CLEANUP)
(iconinfo
	(prompt)
	(help @iconinfo-help)
	(dest "install")
	(gettooltype "VERSION" "#id_version")
)
(set #app-name (cat @app-name " " #id_version))
(message "\n\n::: :: :   Welcome to " #app-name " Setup   : :: :::\n"
	 "\n\n\n"
	 #app-name 
	"\n"
	"created by (c) 2000 Tomasz Malerczyk"
	 "\n\n\n"
	 "\n"
	 "\n"
	 "Do you wish to proceed?"
)
(if (=(exists "envarc:imagedescriptor/uninstall") 0)
	(SETUP)
)	
(set #un_version "envarc:imagedescriptor/version")
(set #ver_actual "2.0")
(if
	(=(exists "envarc:imagedescriptor/version") 1)
	(set #ver_actual (getenv #un_version))
)
(set #un_ask1 (cat "[2pInstall version "#id_version))
(set #un_ask2 (cat "Remove version "#ver_actual" and install version "#id_version))
(set #un_ask3 (cat "Remove version "#ver_actual))
(set #what_do
(askchoice
	(prompt 
	"Installer found "@app-name" Uninstall information\n"
	"(pre 2.0 versions are not recognized by this script)\n\n"
	"Current version: "#id_version"\n"
	"Installed version: "#ver_actual"\n\n"
	"What you wish to do?\n")
	(help)
	(choices
		#un_ask1
		#un_ask3
		#un_ask2
	)
	(default 1)
))
(if
	(= #what_do "0")
		(
		(SETUP)
		)
)
(if
	(= #what_do "2")
	(
	(REMOVE)
	(SETUP)
	)
)
(REMOVE)
(exit (quiet))
(welcome "thank you")
