;
;----------------------------------------------------------------------------
;
; Xit 1.0 - Installer script by Laurent Kempé <lkempe@nucleus.fr>
;
;----------------------------------------------------------------------------
;
; $VER: Installer script v1.0 for Xit (28.10.96) © Laurent Kempé
;
;
;  History
; --------------------
;
; - Lundi 28-Oct-96 17:57:40 - First release with Xit 1.0
;
;----------------------------------------------------------------------------

(set #def_lang_English       0)
(set #def_lang_Français      1)
;(set #def_lang_Deutsch       2)

(set #def_doc_français  0)
(set #def_doc_english   1)
;(set #def_doc_deutsch   2)

;----------------------------------------------------------------------------
; ***** english texts *****

(IF (= @language "english")
(
(set #def_cat_lang #def_lang_English)
(set #def#def_doc_lang  #def_doc_english)
(set #wrongOS  "Xit needs OS2.04 or higher to work\n")
(set #wrongMUI "Xit needs MUI3.1 or higher to work\n")

(set #proc_type "Select which version of Xit you would like to install:")
(set #proc_help (cat "Here you can select which version of Xit to install "
                     "depending on type of processor you own."))
(set #proc_any "Compatible with any processor")
(set #proc_020 "Optimized for 68020 and 68030")
(set #proc_060 "Optimized for 68040 and 68060")

(set #Xit_dir  (cat"Choose the path where you want to install Xit.\n"
                   "(a new directory will be created !)"))

(set #lang_catalog (cat "Which language would you like to install for Xit ?\n"
                        "(English is default)"))
(set #lang_manual "Choose the language for the doc (amigaguide)")

(set #icons        "Which icons would you like to install for Xit ?")
(set #icons_help   (cat "for a preview of the available icons "
                        "take a look at the \"Icons\" drawer ...\n\n"))

(set #done_1   (cat "\nXit has been succesfully installed.\n\n"
                    "Click on the \"Xit\" icon in the directory\n"))
(set #done_2   (cat "\nto run it.\n\nEnjoy it !!!\n\n"
                    "Xit © 1996 by Laurent Kempé.\n\n"
                    "Register if you want new versions."))

(set #nomultiview (cat "The installer could not find multiview or you are running on a 2.0x Amiga. "
                       "The Xit Installer will let you choose between a few different icon to use. "
                       "You can use a picture viewer to look at the 'Icons/Xit_Icons.iff' to see the choices side-by-side, "
                       "or you can just look in the Icon drawer from where you are installing Xit from."
                  )
)

)
)

; ***** french texts *****

(IF (= @language "français")
(
(set #def_cat_lang #def_lang_Français)
(set #def#def_doc_lang  #def_doc_français)
(set #wrongOS  "Xit a besoin de OS2.04 ou plus recent pour fonctionner\n")
(set #wrongMUI "Xit a besoin de MUI3.1 ou plus recent pour fonctionner\n")

(set #proc_type "Quelle version de Xit voulez vous installer:")
(set #proc_help (cat "Vous pouvez choisir la version de Xit à installer "
                     "en fonction du type de processeur que vous posseder."))
(set #proc_any "Compatible avec tout processeur")
(set #proc_020 "Optimisé pour 68020 et 68030")
(set #proc_060 "Optimisé for 68040 et 68060")

(set #Xit_dir  (cat"Indiquez l'emplacement du répertoire de Xit.\n"
                   "(Un tiroir supplémentaire sera créé!)"))

(set #lang_catalog (cat "Quelle langue voulez-vous installer  pour l'interface de Xit ?\n"
                        "(L'anglais est la langue par défaut)"))
(set #lang_manual "Choisir la langue du fichier d'aide (amigaguide)")

(set #icons        "Quelle icônes voulez-vous installer pour Xit ?")
(set #icons_help   (cat "Pour un aperçu des icones, jeter un coup "
                        "d'oeil au contenu du tiroir \"Icons\"...\n\n"))

(set #done_1   (cat "\nXit a été correctement installé.\n\n"
                    "Clicker sur l'icon \"Xit\" du tiroir\n"))
(set #done_2   (cat "\npour le tester.\n\nAmusez-vous bien...\n\n"
                    "Xit © 1996 par Laurent Kempé.\n\n"
                    "Enregistrez-vous si vous voulez de nouvelles versions."))

(set #nomultiview (cat "The installer could not find multiview or you are running on a 2.0x Amiga. "
                       "The Xit Installer will let you choose between a few different icon to use. "
                       "You can use a picture viewer to look at the 'Icons/Xit_Icons.iff' to see the choices side-by-side, "
                       "or you can just look in the Icon drawer from where you are installing Xit from."
                  )
)

)
)

;----------------------------------------------------------------------------

(if (< (getversion "exec.library" (resident))    2424832) (abort #wrongOS))
(if (< (getversion "MUI:Libs/muimaster.library")  851968) (abort #wrongMUI))

(set cpu_type (database "cpu"))
(set cpu 0)
(if (= cpu_type "68020") (set cpu 1))
(if (= cpu_type "68030") (set cpu 1))
(if (= cpu_type "68040") (set cpu 2))
(if (= cpu_type "68060") (set cpu 2))


;----------------------------------------------------------------------------

(complete 0)

(set Xit_def_dir ("RAM:"))

(set Xit_dir
  (askdir
    (default Xit_def_dir)
    (prompt  #Xit_dir)
    (help    @askdir-help)
  )
)

(set cpu
   (askchoice
      (prompt #proc_type)
      (help #proc_help "\n" @askchoice-help)
      (choices #proc_any #proc_020 #proc_060)
      (default cpu)
   )
)

(set Catalog_lang
  (askoptions
    (prompt  #lang_catalog)
    (help @askoptions-help)
    (choices "Français"
    )
    (default #def_cat_lang)
  )
)

(set Docs_lang
  (askchoice
    (prompt  #lang_manual)
    (help    @askoptions-help)
    (choices "Français"
             "English"
    )
    (default #def#def_doc_lang)
  )
)

   (if (= newicon 0) 
     (
       (if (> (exists ("c:multiview")) 0)  ((set #mpath "c:") (set mfound 1)) )
       (if (> (exists ("sys:Utilities/multiview")) 0) ((set #mpath "sys:Utilities") (set mfound 1)) )
       (if (= mfound 1) (run (cat "run " (tackon #mpath "multiview ") "/Icons/Xit_Icons.iff")) )
       (if (<> mfound 1) (message #nomultiview))

       (set Icons
         (askchoice
            (prompt  #icons)
            (help    #icons_help
                     @askoptions-help
            )
            (choices "Icon1"
                     "Icon2"
                     "Icon3"
                     "Icon4"
            )
            (default 0)
         )
       )
     )
   )

;-------------------------- here we go... -----------------------------------

(makedir (tackon Xit_dir "Xit"))

; ** Copy Xit.info pour avoir l'icône du directory **
(copyfiles (source "//Xit.info")
           (dest Xit_dir)
           (infos)
           (help @copyfiles-help)
)

(set Xit_dir (tackon Xit_dir "Xit"))

(select cpu (set src "/Xit") (set src "/Xit.020") (set src "/Xit.040"))
(copyfiles (source src)
                                         (dest Xit_dir)
                                         (newname "Xit")
                                         (infos)
                                         (help @copyfiles-help)
)

(copyfiles (source "/Icons/def_Xit.info")
           (dest Xit_dir)
           (infos)
           (help @copyfiles-help)
)

(copyfiles (source "/Xit")
           (dest Xit_dir)
           (infos)
           (help @copyfiles-help)
)

(if (> Catalog_lang 0)
        (
        (set Cat_dir (tackon Xit_dir "Catalogs"))
        (if (not (exists Cat_dir))  (makedir Cat_dir))

   (if (bitand Catalog_lang #def_lang_Français  ) ((set lang "français")   (copyfiles (source (tackon "/Catalogs" lang)) (choices "Xit.catalog") (dest (tackon Cat_dir lang)))))
   )
)


(if (= Docs_lang #def_doc_français) (copyfiles (source "/Docs/Xit_français.guide") (dest Xit_dir) (newname "Xit.guide") (infos)))
(if (= Docs_lang #def_doc_english) (copyfiles (source "/Docs/Xit_english.guide") (dest Xit_dir) (newname "Xit.guide") (infos)))


(if (= Icons 0) (copyfiles (source "/Icons/Xit1.info") (dest Xit_dir) (newname "Xit.info") (all)))
(if (= Icons 1) (copyfiles (source "/Icons/Xit2.info") (dest Xit_dir) (newname "Xit.info") (all)))
(if (= Icons 2) (copyfiles (source "/Icons/Xit3.info") (dest Xit_dir) (newname "Xit.info") (all)))
(if (= Icons 3) (copyfiles (source "/Icons/Xit4.info") (dest Xit_dir) (newname "Xit.info") (all)))

;-------------------------- ... and we gone. -------------------------------

(complete 100)
(message #done_1
         "\"" Xit_dir "\""
         #done_2
)

;********************

(exit (QUIET))
