;
; $VER: Installer script 1.1 for YAM 2.0 German Preview (15.2.98) © Marcel Beck
;

(set #def_lang_English       0)
(set #def_lang_Deutsch       1)
(set #def_doc_English   0)
(set #def_doc_Deutsch   1)

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

; ***** English
(set #def_cat_lang #def_lang_English)
(set #def_doc_lang #def_doc_English)
(set #wrongOS  "YAM needs at least OS3.0 to run\n")
(set #wrongMUI "YAM needs at least MUI3.8 to run\n")
(set #wrongCPU "YAM needs at least a 68020 CPU to run\n")
(set #YAM_dir  (cat "Choose YAM home directory\n"
                    "(NO extra drawer will be created!)"))
(set #lang_catalog (cat "Which catalog file do you want to install?\n"
                        "(English language is built-in)"))
(set #lang_manual "Select language for on-line AmigaGuide help")
(set #arexx_prompt "Where do you want to install ARexx scripts?")
(set #assign_prompt (cat "YAM: assign should be added to your S:USER-STARTUP\n"
                         "Do you mind?"))
(set #assign_help (cat "When the Installer program asks if you want to place this "
                       "assignment into your S:user-startup file, you should select "
                       "the \"Proceed\" button; otherwise, the next time you boot up your "
                       "machine, the program won't be able to find the necessary files "
                       "and drawers it needs to run.\n"))
(set #done_1   (cat "\nYAM has been succesfuly installed.\n\n"
                    "Click the \"YAM\" icon in the\n"))
(set #done_2        "\ndirectory to taste it.\n\nHave fun...")

; ***** Deutsch
(IF (= @language "deutsch")
(
(set #def_cat_lang #def_lang_Deutsch)
(set #def_doc_lang #def_doc_Deutsch)
(set #wrongOS  "YAM benötigt OS2.04 oder höher\n")
(set #wrongMUI "YAM benötigt MUI3.8 oder höher\n")
(set #wrongCPU "YAM läuft nur ab einer 68020 CPU\n")
(set #YAM_dir  (cat"Wählen Sie ein Verzeichnis für YAM\n"
                   "(es wird KEIN eigenes Verzeichnis erstellt!)"))
(set #lang_catalog (cat "Welche catalog-Datei wollen Sie installieren?\n"
                        "(Englisch ist eingebaut)"))
(set #lang_manual "Wählen Sie eine Sprache für die Online-AmigaGuide-Hilfe")
(set #arexx_prompt "Wohin wollen Sie die ARexx-Beispiele kopieren?")
(set #assign_prompt (cat "In S:USER-STARTUP sollte ein Assign YAM: eingefügt werden.\n"
                         "Sind Sie damit einverstanden?"))
(set #assign_help (cat "Wenn Sie vom Installer gefragt werden, ob er diese Zuweisung "
                       "in der Datei s:user-startup vornehmen darf, sollten Sie den "
                       "Knopf \"Weiter\" drücken; andernfalls kann das Programm nach "
                       "dem nächsten Booten die benötigten Dateien und Verzeichnisse "
                       "nicht finden.\n"))
(set #done_1   (cat "\nYAM wurde erfolgreich installiert.\n\n"
                    "Klicken Sie auf das \"YAM\"-Icon im Verzeichnis\n"))
(set #done_2        "\nund es kann losgehen.\n\nViel Spass!")
)
)
;----------------------------------------------------------------------------

;**** Checking environment
(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))

(set cpu_type (database "cpu"))
(if (< cpu_type "68020") (abort #wrongCPU))

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

(complete 0)

(if (<> 0 (exists "YAM:" (noreq)))
        (set YAM_def_dir (getassign "YAM"))
        (set YAM_def_dir @default-dest)
)

(set YAM_dir
        (askdir
                (default YAM_def_dir)
                (prompt  #YAM_dir)
                (help    @askdir-help)
        )
)

(complete 10)

(set Catalog_lang
        (askoptions
                (prompt  #lang_catalog)
                (help @askoptions-help)
                (choices "Deutsch"
                )
                (default #def_cat_lang)
        )
)

(complete 20)

(set Docs_lang
        (askchoice
                (prompt  #lang_manual)
                (help    @askoptions-help)
                (choices "English" "Deutsch"
                )
                (default #def_doc_lang)
        )
)

(complete 30)

(set ARexx_dir
                        (askdir
                                        (default "REXX:")
                                        (prompt  #arexx_prompt)
                                        (help    @askdir-help)
                        )
)

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

(complete 40)

(makedir YAM_dir (infos))

(copyfiles (source "/YAM") (dest YAM_dir) (infos) (help @copyfiles-help))

(complete 50)

(copyfiles (source "/.taglines") (dest YAM_dir) (help @copyfiles-help))

(complete 60)

(if (> Catalog_lang 0)
      (
         (set Cat_dir (tackon YAM_dir "Catalogs"))
         (if (not (exists Cat_dir))  (makedir Cat_dir))
         (if (bitand Catalog_lang #def_lang_Deutsch   ) ((set lang "deutsch") (copyfiles (source (tackon "/Catalogs" lang)) (choices "YAM.catalog") (dest (tackon Cat_dir lang)))))
         )
)

(if (= Docs_lang #def_doc_english ) (copyfiles (source "/YAM_english.guide")  (dest YAM_dir) (newname "YAM.guide") (infos)))
(if (= Docs_lang #def_doc_deutsch ) (copyfiles (source "/YAM_deutsch.guide")  (dest YAM_dir) (newname "YAM.guide") (infos)))

(complete 70)

(set Icons_dir (tackon YAM_dir "Icons"))
(if (not (exists Icons_dir))
 (
   (makedir Icons_dir)
   (copyfiles (source "/Icons.info") (dest YAM_dir) (help @copyfiles-help))
 )
)
(copyfiles (source "/Icons/") (dest Icons_dir) (all))

(set Charset_dir (tackon YAM_dir "Charsets"))
(if (not (exists Charset_dir)) (makedir Charset_dir))
(copyfiles (source "/Charsets/") (dest Charset_dir) (all))

(copyfiles (source "/Rexx/") (dest ARexx_dir) (all))

(complete 80)

(copylib (prompt "MUI - BetterString.mcc") (source "/MUI/BetterString.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - BetterString.mcp") (source "/MUI/BetterString.mcp") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - HotkeyString.mcc") (source "/MUI/HotkeyString.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - InfoText.mcc")     (source "/MUI/InfoText.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - ListTree.mcc")     (source "/MUI/ListTree.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - ListTree.mcp")     (source "/MUI/ListTree.mcp") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - NFloattext.mcc")   (source "/MUI/NFloattext.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - NList.mcc")        (source "/MUI/NList.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - NListview.mcc")    (source "/MUI/NListview.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - NListviews.mcp")   (source "/MUI/NListviews.mcp") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - TextEditor.mcc")   (source "/MUI/TextEditor.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - TextEditor.mcp")   (source "/MUI/TextEditor.mcp") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - Toolbar.mcc")      (source "/MUI/Toolbar.mcc") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))
(copylib (prompt "MUI - Toolbar.mcp")      (source "/MUI/Toolbar.mcp") (dest "MUI:Libs/MUI/") (confirm) (help @copylib-help))

(complete 90)

(startup "YAM - Amiga mailer © Marcel Beck"
        (prompt #assign_prompt)
        (help   #assign_help)
        (command "C:Assign YAM: \"" YAM_dir "\"\n")
)

(makeassign "YAM" YAM_dir)

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

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

(exit (QUIET))

