;
; Script d'intallation pour LangTools 1.2 +  ©2000 Seahorse Production 21
; LangTools est copyright 2000 Németh Miklós.
;
; $VER : 1.03 (28-sept.-2000) ©2000 seahorse@mail-freelance.com
;                                   seahorse21@libertysurf.fr
;
;=======================================================================
; Please ask before use part(s) of this script. :)
;=======================================================================

; Variables par défaut :

(SET #L_English    0 )
(SET #L_Français   1 )
(SET #L_Magyar     12)      ; Hongrois

(SET #NomProg "LangTools")
(SET #NomRepert "LangTools")

;//+ **** -> Anglais   (0 - Défaut)

(SET #Def_lang #L_English #Def_doc #L_English)

(SET #wrongOS  "Sorry, but:\nOS 3.0 or newer is required!\n")
(SET #wrongMUI "Sorry, but:\nMUI 3.8 or newer is required!\n")

(set #Msg_dir "\nChoose your LangTools directory\n(A drawer called \"LangTools\" will be created!)")
(set #Msg_cat "\nWhich catalog file do you want to install?\n(English language is built-in)")
(set #Msg_doc "\nSelect language for documentation in AmigaGuide format")

(SET #Creer_dir "\nCreating \"%s\" directory...")
(SET #Help_dir (CAT "\nChoose where you wish to install LangTools.\n"
                    "Again a \"LangTools\" drawer will be created."))
(SET #Msg_Assign (CAT "LangTools must be assigned.\n"
                      "Do you want I add the assignation\n"
                      "`LTools:' inside `S:User-Startup' for you?"))
(SET #Pour "For ")
(SET #Help_Nil "")
(SET #Bad_Class (cat "\nWrong « %s » version (%s).\n"
                     "Please install the %s version or newer."))
(SET #liba "Installing « Ltools.library »...")
(SET #liba_hlp   (CAT "Installation of 'ltools' library."
                      "\nmust be copied to Libs:." ))
;+//
; -------------------------------------------------------------------
; //+ **** -> Français  (1)

(IF (= @language "français")
(
(SET #Def_lang #L_Français  #Def_doc #L_Français)

(SET #wrongCPU "Il vous faut au moins un 68020 !\n")
(SET #wrongOS  "Désolé, mais :\nil vous faut au moins le systčme 3.0 !\n")
(SET #wrongMUI "Désolé, mais :\nil vous faut au moins MUI 3.8 !\n")

(SET #Msg_dir "\nOů voulez-vous installer LangTools ?\n(Un répertoire « LangTools » sera crée.)\n")
(SET #Msg_cat "\nQuel langage voulez-vous installer ?\nL'Anglais est en interne.\n")
(SET #Msg_doc "\nQuelle documentation voulez-vous installer ?\n")

(SET #Creer_dir "Création du répertoire \"%s\"...")
(SET #Help_dir (CAT "\nChoisissez l'endroit oů vous souhaitez installer LangTools.\n"
                    "Je vous rappel qu'un répertoire « LangTools » sera crée."))

(SET #Msg_Assign (CAT "LangTools doit-ętre assigné.\n"
                      "Voulez-vous que j'ajoute l'assignation\n"
                      "« LTools: » dans « S:User-Startup » pour vous ?"))
(SET #Pour "Pour ")
(SET #Bad_Class (cat "\nMauvaise version de « %s » (%s).\n"
                     "Veuillez installer la version %s ou supérieure."))
(SET #liba "Installation de « Ltools.library »...")
(SET #liba_hlp   (CAT "Installation de la bibliothčque de « ltools »."
                      "\nElle doit-ętre copiée dans « Libs: »." ))
)) ; +// Fin IF
; -------------------------------------------------------------------
; //+ **** -> Allemand  (6)
                                   
(if (= @language "deutsch")
(
; (SET #Def_lang #L_Deutsch  #Def_doc #L_Deutsch) ; Normal way
(SET #Def_lang #L_English  #Def_doc #L_English) ; Current way

(set #wrongCPU "\nLangTools benötigt mindestens eine 68020 CPU!\n")
(set #wrongOS  "\nLangTools benötigt mindestens OS 3.0!\n")
(set #wrongMUI "\nLangTools benötigt mindestens MUI 3.8!\n")

(set #Msg_dir "\nIn welchem Verzeichnis soll LangTools installiert werden?\n(Ein Verzeichnis namens \"LangTools\" wird automatisch erstellt!)")
(set #Msg_cat "\nWelche Katalogdateien sollen installiert werden?\n(Für Englisch wird keine Datei benötigt.)")
(set #Msg_doc "\nIn welcher Sprache soll die AmigaGuide Dokumentation installiert werden?")

(SET #Creer_dir "\nErzeuge Verzeichnis \"%s\"...")
(SET #Help_dir (CAT "\nWähle wo LangTools installiert werden soll.\n"
                    "Das Verzeichnis \"LangTools\" wird automatisch erzeugt."))
(SET #Msg_Assign (CAT "LangTools must be assigned.\n"
                      "Do you want I add the assignation\n"
                      "`LTools:' inside `S:User-Startup' for you?"))
(SET #Pour "Für ")
(SET #Bad_Class (cat "\nWrong « %s » version (%s).\n"
                     "Please install the %s version or newer."))
(SET #liba "Installing « Ltools.library »...")
(SET #liba_hlp   (CAT "Installation of 'ltools' library."
                      "\nmust be copied to Libs:" ))
))  ; +//
; -------------------------------------------------------------------
; //+ **** -> Italien   (10)

(if (= @language "italiano")
(
;(SET #Def_lang #L_Italiano  #Def_doc #L_Italiano) ; Normal way
(SET #Def_lang #L_English  #Def_doc #L_English) ; Current way

(set #wrongCPU "\nLangTools necessita almeno di una CPU 68020 per poter girare !\n")
(set #wrongOS  "\nLangTools necessita almeno di OS 3.0 per poter girare !\n")
(set #wrongMUI "\nLangTools necessita almeno della MUI 3.8 per funzionare !\n")

(set #Msg_dir "\nScegli la directory per LangTools\n(Sarŕ creato un cassetto chiamato \"LangTools\"!)")
(set #Msg_cat "\nQuale file catalogo desideri installare?\n(Il programma č in inglese)")
(set #Msg_doc "\nScegli la lingua della documentazione in formato AmigaGuide")

(SET #Creer_dir "\nSto creando la directory \"%s\" ...")
(SET #Help_dir (CAT "\nScegli dove desideri installare LangTools.\n"
            "Sarŕ creato un cassetto \"LangTools\" ."))
(SET #Msg_Assign (CAT "LangTools must be assigned.\n"
                      "Do you want I add the assignation\n"
                      "`LTools:' inside `S:User-Startup' for you?"))
(SET #Pour "per ")
(SET #Help_Nil "")
(SET #Bad_Class (cat "\nWrong « %s » version (%s).\n"
                     "Please install the %s version or newer."))
(SET #liba "Installazione dell « Ltools.library »...")
(SET #liba_hlp   (CAT "Installazione dell 'ltools' library."
                      "\ndeve esser copiato in Libs:" ))
))   ; +//
; -------------------------------------------------------------------
; //+ **** -> Hungarian (magyar) (12)

(IF (= @language "magyar")
(
(SET #Def_lang #L_Magyar  #Def_doc #L_Magyar)
;(SET #Def_lang #L_English  #Def_doc #L_English) ; Current way
(SET #wrongOS  "Sajnálom, de:\nOS 3.0 vagy újabb szükséges!\n")
(SET #wrongMUI "Sajnálom, de:\nMUI 3.8 vagy újabb szükséges!\n")

(set #Msg_dir (CAT "\nVálaszd ki, hogy hova telepítsem a programot!\n"
                   "(A \"LangTools\" nevű fiókot autómatikusan létrehozom!)"))
(set #Msg_cat "\nMely katalógusokat telepítsem?\n(English az alapbeállítás!)")
(set #Msg_doc "\nMely nyelvű AmigaGuide dokumentációt telepítsem?")

(SET #Creer_dir "\nLétrehozom a(z) \"%s\" nevű fiókot...")
(SET #Help_dir (CAT "\nVálasz ki a LangTools telepítési útvonalát!\n"
            "Újra! A \"LangTools\" fiókot automatikusan létrehozom."))
(SET #Msg_Assign (CAT "A programnak szüksége van hozzárendelésre!\n"
              "Hozzákapcsoljam az `Ltools:' hozzárendelést\n"
              "az  `S:User-Startup' állományhoz?"))
(SET #Pour "For ")
(SET #Help_Nil "")
(SET #Bad_Class (cat "\nNem megfelelő a\(z|) « %s » verziója (%s).\n"
             "Kérlek telepítsd a %s verziót vagy egy újabbat!"))
(SET #liba "Installing « Ltools.library »...")
(SET #liba_hlp   (CAT "Installation of 'ltools' library."
                      "\nmust be copied to Libs:" ))
)) ; +// Fin IF
; -------------------------------------------------------------------

; ---- * ====================================================== * ----
;//+        ====                Procédures                    ====
; ---- * ======================================================== * ----

(PROCEDURE P_CheckClass #arg1 #arg2
(SET #MUI_class (getversion (TACKON "MUI:libs/mui/" #arg1)))
(SET #Vers (CAT(/ #MUI_Class 65536) "." (- #MUI_Class (* (/ #MUI_Class 65536) 65536))))
(if (< #Vers #arg2)
 (Message (#Bad_Class #arg1 #Vers #arg2))
; (Message ("C'est ok. %s" #vers))
) ;if
) ;proc

; ---- * ======================================================== * ----
;+//     ====              Fin des procédures                ====
; ---- * ====================================================== * ----
;
; --------------------------------------------------------------------
; ========================  <*  SCRIPT  *>  ==========================
; --------------------------------------------------------------------

; --***  Vérifier l'environnement
(set Type_CPU (database "cpu"))
(if (< Type_CPU "68020") (abort #wrongCPU))
(set OS_ver (getversion "exec.library" (resident)))
(if (< OS_ver (* 39 65536)) (abort #wrongOS))
(set #MUI_ver (getversion "MUI:libs/muimaster.library"))
(if (AND (< #MUI_ver (* 19 65536)) (<> #MUI_ver 0)) (abort #wrongMUI))

; -- **  Vérification de classes MUI
(P_CheckClass "texteditor.mcc" "15.9")
(P_CheckClass "Nlist.mcc" "19.97")
(P_CheckClass "NListview.mcc" "19.62")

; --***  Choix du répertoire de destination
(SET #Dest_dir
        (askdir
              (default @default-dest)
              (prompt  #Msg_dir)
              (help    #Help_dir) )
)
(SET #Dest_dir (TACKON #Dest_dir #NomRepert))
(SET @default-dest #Dest_dir)

; --***  Choix du catalogue

(SET #H_Langage (askchoice
    (PROMPT  #Msg_cat)
    (HELP    @askchoice-help)
    (CHOICES
             "English"
             "Français"
             ""  ""
             ""  ""
             ""  ""
             ""  ""
             ""  ""
             "Magyar"
    )
    (DEFAULT #Def_lang)
               )
)

(COMPLETE 10)

; --  Choix de la documentation (1 seulle)

(SET #H_Guide (askchoice
    (PROMPT #Msg_doc)
    (HELP   @askchoice-help)
    (CHOICES
             "English"
             "Français"
             ""
             ""
             ""
             ""
             ""
             ""
             ""
             ""
             ""
             ""
             "Magyar"
    )
    (DEFAULT #Def_doc)
             )
)

(COMPLETE 20)

; --
; **** Installation (dir)
; --

(MAKEDIR #Dest_dir (PROMPT (#Creer_dir #NomRepert)) (INFOS))
(MAKEDIR (TackOn #Dest_dir "Dics"))
(MAKEDIR (TackOn #Dest_dir "Source"))
(MAKEDIR (TackOn #Dest_dir "Translated"))

(SET #Cat_dir (tackon #Dest_dir "Catalogs"))
(IF (NOT (EXISTS #Cat_dir)) (MAKEDIR #Cat_dir (PROMPT (#Creer_dir "Catalogs"))) )

(COMPLETE 30)

(copyfiles (source "dic.list") (dest #Dest_dir) (optional "nofail"))
(IF (> #H_Langage 0)
(
   (if (= #H_langage #L_Français)
     ( (copyfiles (source (tackon "Catalogs" "français")) (ALL) (dest (tackon #Cat_dir "français")))
       (copyfiles (source "extra/dic.list_fra") (dest #Dest_dir) (Newname "Dic.list") (optional "nofail"))
     ))
   (if (= #H_langage #L_Magyar )
     ( (copyfiles (source (tackon "Catalogs" "magyar"))  (ALL) (dest (tackon #Cat_dir "magyar")))
       (copyfiles (source "extra/dic.list_hun") (dest #Dest_dir) (Newname "Dic.list") (optional "nofail"))
     ))
))

(COMPLETE 40)
;
; -- SI 1 SEULLE DOCUMENTATION AU CHOIX !!  (AskChoice)
;
(copyfiles (source "Langtools.guide.info") (dest #Dest_dir)(optional "nofail"))
(copyfiles (source "DicHandle.guide.info") (dest #Dest_dir)(optional "nofail"))

(IF (= #H_Guide #L_English)
   ( (copyfiles (source "Docs/LangTools_Eng.guide") (dest #Dest_dir) (NewName "LangTools.guide") (infos))
     (copyfiles (source "Docs/DicHandle_Eng.guide") (dest #Dest_dir) (NewName "DicHandle.guide") (infos))
   ))
(IF (= #H_Guide #L_Français)
   ( (copyfiles (source "Docs/LangTools_Fra.guide") (dest #Dest_dir) (NewName "LangTools.guide") (infos))
     (copyfiles (source "Docs/DicHandle_Fra.guide") (dest #Dest_dir) (NewName "DicHandle.guide") (infos))
   ))
(IF (= #H_Guide #L_Magyar)
   ( (copyfiles (source "Docs/LangTools_Hun.guide") (dest #Dest_dir) (NewName "LangTools.guide") (infos))
     (copyfiles (source "Docs/DicHandle_Hun.guide") (dest #Dest_dir) (NewName "DicHandle.guide") (infos))
   ))
(COMPLETE 50)
;
(copylib  (source "libs/LTools.library") (dest "Libs:") (confirm)
          (prompt #liba) (HELP #liba_hlp) (optional "askuser"))

(copyfiles (source "DicHandle") (dest #Dest_dir) (infos) (optional "nofail"))
(copyfiles (source "LangTools") (dest #Dest_dir) (infos) (optional "nofail"))
(copyfiles (source "Langtools.sig") (dest #Dest_dir)(optional "nofail"))
(copyfiles (source "Langtools.key") (dest #Dest_dir)(optional "nofail"))
(COMPLETE 60)

(copyfiles (source "Tools") (dest (Tackon #Dest_dir "Tools")) (All) (optional "nofail"))
(COMPLETE 80)
(copyfiles (source "Userdic") (dest (Tackon #Dest_dir "Userdic")) (All) (optional "nofail"))
(copyfiles (source "Images") (dest (Tackon #Dest_dir "Images")) (All))
(copyfiles (source "MakeAssign") (dest #Dest_dir) (infos) (optional "nofail"))
(COMPLETE 90)

(Startup " --******--   LangTools" (PROMPT #Msg_Assign)
                     (HELP @startup-help) (Confirm)
                     (Command (Cat "Assign LTools: " (CAT "\"" #Dest_Dir "\"")) ))
(MakeAssign "LTools" #Dest_Dir)

(COMPLETE 100)

(exit)

; -------------------------------------------------------------------
; -------------------------- FIN DE SCRIPT --------------------------
; -------------------------------------------------------------------
