;Tango 1.0 installation script
(set #intro (cat "\n\nWelcome to Tango\n\nCopyright © 1999\n\nSören Forsberg\n") )
(set #info (cat "\n\nThis installer will\n\ninstall Tango in Samba:\n\na new directory 'Tango' will be created.\n\n") )
(message #intro)
(welcome) 
(message #info)

(if (= (exists "samba:tango") 0 )  (makedir "Samba:Tango") )

;copy main
(copyfiles (source "Tango")   (dest "samba:Tango")    (infos) (all))

;copy drawer icon
(copyfiles    (prompt "Copying drawer icon")    (source "Tango.info")    (dest "Samba:") )

;copy catalogs
;(copyfiles (source "Locale")   (dest "sys:Locale")    (infos) (all))

(set #catnofind "Can not find this catalog in this  archive.")
(set #whatcat "\nTango has no internal catalog.\nSelect the Language catalog you wish to install.\nThat language has to be selected in Prefs:Locales ")
(set #whatcathelp "If your language is not among the choises,\nYou must choose another language.")



(if (> (exists ("env:Language")) 0) (set lanfound (getenv "Language")) )
(set lan 0)
(if (= "english" lanfound) (set lan 0))  (if (= "deutsch"  lanfound) (set lan 1))
(if (= "svenska" lanfound) (set lan 2)) (if (= "español" lanfound) (set lan 3)) 
(if (= "russian" lanfound) (set lan 3)) 
(set #English    "English")  (set #Deutsch    "Deutsch")
(set #Svenska    "Svenska")  (set #Español    "Español")
(set #Russian    "Russian")  

(if (> (exists ("ENV:i.høld.0")) 0)   (set l0 (getenv "ENV:i.høld.0")) ) 
(if (> (exists ("ENV:i.høld.1")) 0)   (set l1 (getenv "ENV:i.høld.1")) )
(if (> (exists ("ENV:i.høld.2")) 0)   (set l2 (getenv "ENV:i.høld.2")) )
(run "delete env:i.høld.#?")
(set catalog (askchoice (choices  "English" "Deutsch" "Svenska" "Español" "Russian")            
                        (prompt #whatcat )
                        
	                (help   #whatcathelp)
                        (default lan)
             )
)

(if (= catalog 0)  (set #lcat #English))  
(if (= catalog 1)  (set #lcat #Deutsch))
(if (= catalog 2)  (set #lcat #Svenska))  
(if (= catalog 3)  (set #lcat #Español))  
(if (= catalog 4)  (set #lcat #Russian))  

(if (<> #lcat "N/A")
 (
      (if (> (exists (cat "Catalogs/" #lcat "/tango.catalog")) 0)
      (
        (
         (if (< (exists "Samba:Tango/Catalogs") 2) (makedir "Samba:Tango/Catalogs") )
         (if (< (exists (cat "Samba:Tango/Catalogs/" #lcat)) 2) (makedir (cat "Samba:Tango/Catalogs/" #lcat)) )
         (copyfiles (source (cat "Catalogs/" #lcat )) (dest (cat "Samba:Tango/Catalogs/" #lcat)) (all) )
        )
  

      )


  (message (cat "\nCatalogs/" #lcat "/tango.catalog\n\n" #catnofind))
  )


); End if Catalog dir
  (message (cat "Error:" "\nCatalogs/" #lcat "/tango.catalog\n\n" #catnofind))
); 

(if (exists "c:defaultbrowser")
        (message "OBSOLETE!\n\nYou have defaultbrowser installed.\n\n"
        "Defaultbrowser is discontinued and will be removed \n"
        "from your system. Tango now uses openurl instead.")
)
(run "delete c:defaultbrowser")
(run 'delete "sys:prefs/default browser.info"')
(run "delete envarc:defaultbrowser")

(set #isthere (cat "You have Tango installed."))
(run "status >ENV:Tango_inst com samba:tango/tango")
(if (> (exists ("env:Tango_inst")) 0) (set tangoon (getenv "Tango_inst")) )
(if (<> tangoon "") (set #isthere (cat "You have Tango installed and running.\nPlease shutdown Tango before proceeding. ")) )

(if (exists "ENV:tango.prefs")
	(
        (message (cat #isthere"\n\n"
        "All librarys and locales\n"
        "will now be flushed."))
		(run "avail flush > NIL:")

		
	)
)

(run "status >ENV:Tango_inst com samba:tango/tango")
(if (> (exists ("env:Tango_inst")) 0) (set tangoon (getenv "Tango_inst")) )
(if (<> tangoon "") (message "You didn't shutdown Tango.\nBefore you start Tango you should:\nReboot, make 'Avail flush'\nor run the installer again!"))


;BEGIN Share 1.0 installation script
(set osver (/ (getversion "LIBS:version.library") 65536))
(if (= osver 44) (set workbench "3.5")) 


;(set #bye (cat "\nShare Install Complete!\nYou will find share in Samba:\n" ))
(set #share (cat "\n\nThe new Share utility will now be installed.\n\nThis will install Share in C:\n\n") )

(message #share)

;copy share
(copyfiles
    (prompt "Copying share")
    (source "Tango/Extras/Share/Share")
    (dest "C:")
)
(copyfiles
    (prompt "Copying icon")
    (source "Tango/Extras/Share/Share.info")
    (dest "C:")
)

(if (> osver 44)
	(if
		(askbool
			(prompt "AmigaOS 3.5 detected.\n\nWould you like to add Share to the tools-menu?\nThis will install a 'Share directory'.\nShare.menu will be added to WBStartup\n")
			(help "Really?.")
			(choices "Install" "Don't install")
			(default 1)
			)
		(
			(copyfiles
		    		(prompt "Copying menu")
		    		(source "Tango/Extras/Share/OS3_5/WBStartup/share.menu")
		    		(dest "sys:wbstartup/")
			)
			(copyfiles
		    		(prompt "Copying menu icon")
		    		(source "Tango/Extras/Share/OS3_5/WBStartup/share.menu.info")
		    		(dest "sys:wbstartup")
			)
			(copyfiles
		    		(prompt "Copying menu script")
		    		(source "Tango/Extras/Share/OS3_5/S/share.WB")
		    		(dest "S:")
			)
			(if
				(askbool
					(prompt "Would you like to add the menu now?\nElse the menu will be available after reboot.\n")
					(help "Really?.")
					(choices "Yes" "No")
					(default 1)
				) 
					(run (cat "run sys:rexxc/rx sys:wbstartup/share.menu") )
			)	
		)
	)
)
;END Share 1.0 installation script

(set donow (askoptions (choices "Tango readme (text)" "Tango guide  (html)" "Open Tango drawer (OS3.5)" "Launch Tango" )
		      (prompt "\nInstallation is complete!\n\nSelect what to do now.\n")
	                (help   "")
	              (default 2)
	  )
)

(if (IN donow 0) (run "run sys:utilities/multiview samba:tango/readme" ))


(if (IN donow 1)
	(if (> (exists ("c:openurl")) 0) (run "openurl file://localhost/samba:tango/guide.html"))
)

;RX "ADDRESS DOPUS.1;'lister new samba:'"
;RX "ADDRESS WORKBENCH;'ICON WINDOW root NAMES Samba: OPEN'" funkar inte då ikonen inte är på wb

(if (IN donow 2)
  	(run "Sys:rexxc/RX opendrawer.rexx")
  )

(if (IN donow 3)
  	(run "samba:tango/tango" )
  )

(exit (quiet))
