;;;; $VER: Install 3.0 (30.7.96)


;;; Strings

(set #ask-rexx
     "Do you want to install some arexx scripts?")

(set #ask-rexx-help
     "The scripts provided helps you solve the first level")

(set #where-languages
     "Where do you want to install the language catalogs?")

(set #where-languages-help
     (cat "This lets you choose if you want the language catalogs to be "
          "copied to the same location as the rest of the program, or if "
          "you want to have them in the global Catalog dir."))

(set #which-languages
     "Which languages do you want ASokoban to support?")

(set #which-languages-help
     (cat "Check all languages you want ASokoban to support.\n"
          "\nIf a language is already installed and you don't check it, "
          "it will be removed."))

(set #where-install
     (cat "Choose location where you want to install ASokoban"
	  "(Note that NO new drawer will be created)."))


;;; Procedures

(procedure install-program
	   (set @default-dest prog-dest)
	   ;; install program and doc
	   (copylib (source (tackon sourcedir "ASokoban"))
		    (dest prog-dest))
	   (copylib (source (tackon sourcedir "ASokoban.guide"))
		    (dest prog-dest))
	   ;; install icons
	   (if (= 0 (exists (tackon prog-dest "ASokoban.info") (noreq)))
	       (copyfiles (source (tackon sourcedir "ASokoban.info"))
			  (dest prog-dest)))
	   (if (= 0 (exists (tackon prog-dest "ASokoban.guide.info") (noreq)))
	       (copyfiles (source (tackon sourcedir "ASokoban.guide.info"))
			  (dest prog-dest)))
	   ;; install images
	   (makedir (tackon prog-dest "Images"))
	   (copyfiles (source (tackon sourcedir "Images/Original"))
		      (pattern "#?.xpm")
		      (dest (tackon prog-dest "Images/Original")))
	   (copyfiles (source (tackon sourcedir "Images/Color"))
		      (pattern "#?.xpm")
		      (dest (tackon prog-dest "Images/Color")))
	   ;; install levels
	   (makedir (tackon prog-dest "Levels"))
	   (copyfiles (source (tackon sourcedir "Levels/Original"))
		      (pattern "screen.#?")
		      (dest (tackon prog-dest "Levels/Original")))
	   ;; make various directories
	   (makedir (tackon prog-dest "Saves"))
	   (makedir (tackon prog-dest "Rexx")))

(procedure install-rexx
	   (if (= 1 (askbool (prompt #ask-rexx) (help #ask-rexx-help)))
	       (copyfiles (source (tackon sourcedir "Rexx"))
			  (pattern "#?.rexx")
			  (dest (tackon prog-dest "Rexx")))))

(procedure install-locales
	   (set locale-dest (tackon prog-dest "Catalogs"))
	   (set where-languages (askchoice (prompt #where-languages)
					   (help #where-languages-help)
					   (choices locale-dest
						    locale-sysdest)))
	   (if (= where-languages 1)
	       (set locale-dest locale-sysdest))
	   (set which-languages (askoptions (prompt #which-languages)
					    (help #which-languages-help)
					    (choices "Bosanski"
						     "Deutsch"
						     "Español"
						     "Français"
						     "Svenska")))
	   (set locale "Bosanski")
	   (if (IN which-languages 0)
	       (install-locale)
	       (remove-locale))
	   (set locale "Deutsch")
	   (if (IN which-languages 1)
	       (install-locale)
	       (remove-locale))
	   (set locale "Español")
	   (if (IN which-languages 2)
	       (install-locale)
	       (remove-locale))
	   (set locale "Français")
	   (if (IN which-languages 3)
	       (install-locale)
	       (remove-locale))
	   (set locale "Svenska")
	   (if (IN which-languages 4)
	       (install-locale)
	       (remove-locale)))

(procedure install-locale
	   (makedir locale-dest)
	   (makedir (tackon locale-dest locale))
	   (copylib (source (tackon (tackon locale-srcdir locale)
				    "asokoban.catalog"))
		    (dest (tackon locale-dest locale))))

(procedure remove-locale
	   (delete (tackon (tackon locale-dest locale) "asokoban.catalog"))
	   (if (NOT (= locale-dest locale-sysdest))
	       ((delete (tackon locale-dest locale))
		(delete locale-dest))))

;;; Main program

(set sourcedir (pathonly @icon))
(set locale-srcdir (tackon sourcedir "Catalogs"))
(set locale-sysdest "LOCALE:Catalogs")

(set prog-dest (askdir (prompt #where-install)
		       (help @askdir-help)
		       (default @default-dest)))

(install-program)
(install-rexx)
(install-locales)
