;--------------------------------------------------------------------------
; $VER: MUI-ASL Installer script 40.6 (7.9.97) by Flavio Stanchina
; Originally by Marcin Orlowski <carlos@dedal.man.szczecin.pl>
;--------------------------------------------------------------------------
;
; History
; --------------------
; 10.11.96 14:32:08 - Initial release
;
;--------------------------------------------------------------------------

(set #lib-source "Libs")
(set #mcc-source "Libs/MUI")
(set #cat-source "Locale/Catalogs")
(set #exe-source "C")
(set #lib-dest   "LIBS:")
(set #mcc-dest   "MUI:Libs/MUI")
(set #cat-dest   "LOCALE:Catalogs")
(set #exe-dest   "C:")

(set #lib-name "MUI-ASL.library")
(set #patch-name "PatchAsl")

(procedure P_copylang
 (foreach (tackon #cat-source #lang) "#?.catalog"
  (copylib (source (tackon (tackon #cat-source #lang) @each-name))
           (dest (tackon #cat-dest #lang)))
 )
)

(set #def-lang-english     0)
(set #def-lang-dansk       1)
(set #def-lang-deutsch     2)
(set #def-lang-español     4)
(set #def-lang-français    8)
(set #def-lang-italiano   16)
(set #def-lang-nederlands 32)
(set #def-lang-norsk      64)
(set #def-lang-português 128)
(set #def-lang-svenska   256)

(set @default-dest "")

;*** Strings ***

;;;(if (= @language "english") (
  (set #bad-kick "Sorry, MUI-ASL requires Kickstart 3.0 (V39) or later.")
  (set #bad-CPU  "Sorry, MUI-ASL requires at least a 68020.")
  (set #bad-MUI  "Sorry, MUI-ASL requires MUI 3.8 or later.")

  (set #def-lang #def-lang-english)
  (set #lang-prompt "Select languages you will use with MUI-ASL\n(English is built-in)")

  (set #rename-prompt "Rename \"%s\"\nas \"%s\"?")
  (set #rename-help (cat "   The previous versions of MUI-ASL saved a copy of your original"
                         " 'asl.library' under a different name, so that it could be restored"
                         " in case of a problem in MUI-ASL.\n"
                         "   This version of MUI-ASL doesn't replace your 'asl.library' anymore,"
                         " so it is recommended to restore the original one."))

  (set #patch-prompt "Do you want to install the patch program?")
  (set #patch-help (cat "   The patch program will activate MUI-ASL in place of the traditional 'asl.library'.\n"
                        "   Later during the installation you will be asked if"
                        " you want to run the patch program during system startup."))

  (set #mcc-prompt "Do you want to copy the MUI custom class '%s' to '%s'?")
  (set #mcc-help (cat "   MUI custom classes are components that extend MUI functionality.\n"
                      "   This class (%s) is essential for the operation of MUI-ASL.")

  (set #help-prompt "Do you want to install the English help in \"HELP:english\"?")
  (set #help-help (cat "   I will place the English help in \"HELP:english\".\n"
                       "   If you install the help file, you will be able to get context-sensitive"
                       " help in MUI-ASL requesters by pressing the HELP key."))

  (set #startup-prompt "Do you want to run the patch program during system startup?")
  (set #startup-help (cat "   You need to run the patch program if you want to activate MUI-ASL.\n"
                          "   After installation the patch program will be started by the 'User-Startup' script."
                          " For optimal performance it should be started by the 'Startup-Sequence'"
                          " script, just after the 'SetPatch' command."
                          " Therefore, expert users should manually move the line that runs 'PatchAsl'"
                          " from the 'User-Startup' file to the 'Startup-Sequence' file.\n"
                          "   If you are not confident with this task, don't take any risk!"
                          " This explanation is incomplete on purpose just to keep inexperienced"
                          " users from messing up with things they are not confident with."
                          " The author will refuse any responsibility."))

  (set #exit-message "You have to reboot to see MUI-ASL at work.\nHave fun!")
;;;))

(if (= @language "italiano") (
  (set #bad-kick "Spiacente, MUI-ASL richiede il Kickstart 3.0 (V39) o successivo.")
  (set #bad-CPU  "Spiacente, MUI-ASL richiede almeno un 68020.")
  (set #bad-MUI  "Spiacente, MUI-ASL richiede MUI 3.8 o successiva.")

  (set #def-lang #def-lang-italiano)
  (set #lang-prompt "Scegli le lingue che userai con MUI-ASL\n(l'inglese è incorporato)")

  (set #rename-prompt "Rinominare \"%s\"\ncome \"%s\"?")
  (set #rename-help (cat "   Le versioni precedenti di MUI-ASL mantenevano una copia della"
                         " 'asl.library' originale con un altro nome, così da poterla"
                         " ripristinare in caso di problemi con MUI-ASL.\n"
                         "   Questa versione di MUI-ASL non sostituisce più la 'asl.library',"
                         " pertanto è consigliato ripristinare quella originale."))

  (set #patch-prompt "Vuoi installare il programma di patch?")
  (set #patch-help (cat "   Il programma di patch attiverà MUI-ASL al posto della 'asl.library' tradizionale.\n"
                        "   Più avanti nel corso dell'installazione verrà chiesto se"
                        " avviare il programma di patch durante l'avvio del sistema."))

  (set #mcc-prompt "Vuoi copiare la classe MUI '%s' in '%s'?")
  (set #mcc-help (cat "   Le classi MUI sono dei componenti aggiuntivi che estendono le funzionalità di MUI.\n"
                      "   Questa classe (%s) è indispensabile per il funzionamento di MUI-ASL.")

  (set #help-prompt "Vuoi installare la guida in inglese in \"HELP:english\"?\n\n(spiacente, la guida in italiano non è disponibile... qualcuno vuole scriverla?)")
  (set #help-help (cat "   Copierò la guida in inglese in \"HELP:english\" (spiacente, la guida in italiano non è disponibile).\n\n"
                       "   Se installi il file della guida, potrai avere una spiegazione sensibile al contesto nei requester di MUI-ASL premendo il tasto HELP."))

  (set #startup-prompt "Vuoi avviare il programma di patch durante l'avvio del sistema?")
  (set #startup-help (cat "   È mecessario avviare il programma di patch se si vuole attivare MUI-ASL.\n"
                          "   Dopo l'installazione il programma di patch verrà eseguito dal file 'User-Startup'."
                          " Per un funzionamento ottimale è preferibile eseguirlo dal file 'Startup-Sequence',"
                          " immediatamente dopo il comando 'SetPatch'."
                          " Pertanto si consiglia agli utenti esperti di spostare la riga che esegue 'PatchAsl'"
                          " dal file 'User-Startup' al file 'Startup-Sequence'.\n"
                          "   Se non sei sicuro di essere in grado di fare questa modifica, non correre rischi!"
                          " Questa spiegazione è volutamente laconica proprio per evitare che"
                          " gli utenti inesperti si avventurino in un campo sconosciuto."
                          " L'autore declina ogni responsabilità in caso di inconvenienti."))

  (set #exit-message "Devi riavviare il computer per vedere MUI-ASL all'opera.\nBuon divertimento!")
))

;*** Checking environment ***

(complete 0)

(if (< (getversion "LIBS:version.library") (* 39 65536)) (
 (abort #bad-kick)
))

(if (< (database "cpu") 68020) (
 (abort #bad-CPU)
))

(if (not (exists "MUI:" (noreq))) (
 (abort #bad-MUI)
))

(set MUI_ver (getversion "MUI:Libs/muimaster.library"))
(if (AND (< MUI_ver (* 19 65536)) (<> MUI_ver 0)) (abort #bad-MUI))

;--------------------------------------------------------------------------
; choose language
(set #cat-lang
 (askoptions
  (prompt #lang-prompt)
  (choices
   "Dansk"
   "Deutsch"
   "Español"
   "Français"
   "Italiano"
   "Nederlands"
   "Norsk"
   "Português"
   "Svenska"
  )
  (help @askoptions-help)
  (default #def-lang)
 )
)

(complete 10)

;--------------------------------------------------------------------------
(set #oldname "LIBS:asl.library")
(set #newname "LIBS:asl.library,orig")

; check for existence of "asl.library" and "asl.library,orig"
(if (and (exists #oldname (noreq)) (exists #newname (noreq))) (
  (if (askbool (prompt (#rename-prompt #newname #oldname)) (help #rename-help)) (
    (delete #oldname)
    (rename #newname #oldname)
  ))
))

(complete 20)

(copylib (source (tackon #lib-source #lib-name))
         (dest #lib-dest))

(complete 25)

(copylib (source (tackon #exe-source #patch-name))
         (dest #exe-dest)
         (prompt #patch-prompt)
         (help   #patch-help)
)

(complete 30)

(foreach #mcc-source "#?.mcc" (
 (copylib (source (tackon #mcc-source @each-name))
          (dest #mcc-dest)
          (prompt (#mcc-prompt @each-name #mcc-dest))
          (help   (#mcc-help   @each-name)) (confirm))
))

(complete 40)

(if (askbool (prompt #help-prompt) (help #help-help) (default 1)) (
 (copyfiles (source "Help/English/MUI-ASL.guide") (dest "HELP:english/"))
))

(complete 50)

;--------------------------------------------------------------------------
(if (> #cat-lang 0) (
  (if (not (exists #cat-dest)) (makedir #cat-dest))

(complete 60)
  (if (bitand #cat-lang #def-lang-dansk     ) ((set #lang "dansk"     ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-deutsch   ) ((set #lang "deutsch"   ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-español   ) ((set #lang "español"   ) (P_copylang)))
(complete 70)
  (if (bitand #cat-lang #def-lang-français  ) ((set #lang "français"  ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-italiano  ) ((set #lang "italiano"  ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-nederlands) ((set #lang "nederlands") (P_copylang)))
(complete 80)
  (if (bitand #cat-lang #def-lang-norsk     ) ((set #lang "norsk"     ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-português ) ((set #lang "português" ) (P_copylang)))
  (if (bitand #cat-lang #def-lang-svenska   ) ((set #lang "svenska"   ) (P_copylang)))
))

(complete 90)

(startup "MUI-ASL"
  (prompt #startup-prompt)
  (help   #startup-help)
  (command "Run <>NIL: C:PatchAsl")
)

(complete 100)

;--------------------------------------------------------------------------
(exit #exit-message)

;*** EOF ***
