; $VER: FreeDB_Install 2.5 (22.11.2001)

(procedure P_SetMessages

    (if (= "italiano" @language)
        (
            (set #WhatInstallPromptMsg          "Cosa vuoi installare?")
            (set #WhatInstallHelpMsg            "Scegli cosa vuoi installare:\n    Librerie - tutte le librerie di FreeDB\n    Classi MUI - le classi MUI di FreeDB\n    FreeDB - l'applicazione FreeDB\n")

            (set #WhatInstallLibrariesMsg       "Librerie")
            (set #WhatInstallMCCsMsg            "Classi MUI")
            (set #WhatInstallFreeDBMsg          "FreeDB")

            (set #AskLibsDirPromptMsg           "Scegli la directory dove installare le librerie")
            (set #AskLibsDirHelpMsg             "Nella directory che sceglierai, verranno copiate varie librerie di FreeDB. Ovviamente la directory scelta, dovrà essere nell'assegnamento logico LIBS:")

            (set #AskMCCsDirPromptMsg           "Scegli la directory dove installare alcuni classi MUI")
            (set #AskMCCsDirHelpMsg             "Nella directory che sceglierai, verranno copiate alcune classi MUI. Ovviamente la directory scelta, dovrà essere nell'assegnamento logico LIBS:")

            (set #AskFreeDBPromptMsg            "Scegli la directory dove installare l'applicazione FreeDB")
            (set #AskFreeDBDirHelpMsg           "Nella directory che sceglierai, verrà copiata l'applicazione FreeDB.")

            (set #CopyingLibsMsg                "Sto copiando le librerie...")
            (set #CopyingMCCsMsg                "Sto copiando le classi MUI...")
            (set #CopyingFreeDBMsg              "Sto copiando l'applicazione FreeDB...")
        )
        (
            (set #WhatInstallPromptMsg          "What do you want to install?")
            (set #WhatInstallHelpMsg            "Choose what you want to install:\n    Libraries - all the libraries needed by FreeDB to work\n    MUI classes - FreeDB MUI custom classes\n    FreeDB - FreeDB application")

            (set #WhatInstallLibrariesMsg       "Libraries")
            (set #WhatInstallMCCsMsg            "MUI classes")
            (set #WhatInstallFreeDBMsg          "FreeDB")

            (set #AskLibsDirPromptMsg           "Select the drawer where you want to copy FreeDB libraries")
            (set #AskLibsDirHelpMsg             "In the drawer you supply here, there will be installed all the FreeDB libraries. This drawer MUST BE in your LIBS: assignment")

            (set #AskMCCsDirPromptMsg           "Select the drawer where you want to copy FreeDB MUI classes")
            (set #AskMCCsDirHelpMsg             "In the drawer you supply here, there will be installed FreeDB MUI classes. This drawer MUST BE in your LIBS: assignment")

            (set #AskFreeDBDirPromptMsg         "Select the drawer where you want to install the FreeDB application")
            (set #AskFreeDBDirHelpMsg           "In the drawer you supply here, there will be installed the FreeDB application.")

            (set #CopyingLibsMsg                "Copying or Updating libraries...")
            (set #CopyingMCCsMsg                "Copying or Updating MUI classes...")
            (set #CopyingRxMUIMsg               "Copying or Updating RxMUI libraries...")
            (set #CopyingFreeDBMsg              "Copying FreeDB...")
        )
    )
)

(procedure P_ChooseWhatIstall
    (set #WhatInstall
        (askoptions (prompt #WhatInstallPromptMsg)
                    (help #WhatInstallHelpMsg)
                    (choices #WhatInstallLibrariesMsg #WhatInstallMCCsMsg #WhatInstallFreeDBMsg)
        )
    )
)

(procedure P_AskLibsDir
    (set #libsDir
        (askdir
            (prompt #AskLibsDirPromptMsg)
            (help #AskLibsDirHelpMsg)
            (default "LIBS:")
        )
    )
)

(procedure P_AskMCCsDir
    (set #MCCsDir
        (askdir
            (prompt #AskMCCsDirPromptMsg)
            (help #AskMCCsDirHelpMsg)
            (default "MUI:LIBS/MUI/")
        )
    )
)

(procedure P_AskFreeDBDir
    (set #FreeDBDir
        (askdir
            (prompt #AskFreeDBDirPromptMsg)
            (help #AskFreeDBDirHelpMsg)
            (default "Ram:")
        )
    )
)

(procedure P_CopyLibs
    (working #CopyingLibsMsg)
    (set #localLibsDir (tackon #source-dir "LIBS/"))
    (foreach #localLibsDir "#?"
        (copylib
            (source (tackon #localLibsDir @each-name))
            (dest #libsDir)
        )
    )
)

(procedure P_CopyMCCs
    (working #CopyingMCCsMsg)

    (set #localMCCSDir (tackon #source-dir "MUI/"))
    (foreach #localMCCsDir "#?"
        (copylib
            (source (tackon #localMCCsDir @each-name))
            (dest #MCCsDir)
        )
    )

    (set #localEnvarcDir (tackon #source-dir "Envarc/FreeDB/"))
    (set #envarcDir "ENVARC:FreeDB")
    (if (= (exists #envarcDir) 0) (makedir #envarcDir))
    (if (= (exists (tackon #envarcDir "FreeDB")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "FreeDB"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )

    (set #localEnvarcDir (tackon #source-dir "Envarc/FreeDB/Images/"))
    (set #envarcDir "ENVARC:FreeDB/Images")
    (if (= (exists #envarcDir) 0) (makedir #envarcDir))
    (if (= (exists (tackon #envarcDir "Get")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Get"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Save")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Save"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Stop")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Stop"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Space")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Space"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Disc")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Disc"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Matches")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Matches"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
    (if (= (exists (tackon #envarcDir "Edit")) 0)
        (copyfiles
            (source (tackon #localEnvarcDir "Edit"))
            (dest #envarcDir)
            (optional force askuser)
        )
    )
)

(procedure P_CopyFreeDB
    (working #CopyingFreeDBMsg)
    (copyfiles
        (source (tackon #source-dir "FreeDB"))
        (dest #FreeDBDir)
        (optional force askuser)
    )
    (copyfiles
        (source (tackon #source-dir "FreeDB.info"))
        (dest #FreeDBDir)
        (optional force askuser)
    )
)

(procedure P_CopyCatalogs
    (set #catSourceDir (tackon #source-dir (tackon "Catalogs" @language)))
    (set #catDestDir (tackon "Locale:" (tackon "Catalogs" @language)))
    (if (= (and (= (exists (#catSourceDir)) 2) (= (exists (#catDestDir)) 2)) 1)
        (foreach #catSourceDir "#?"
            (copylib
                (source (tackon #catSourceDir @each-name))
                (dest #catDestDir)
            )
        )
    )
)

(set @default-dest "LIBS:")
(set #source-dir (if (= 1 (exists @icon)) (pathonly (expandpath @icon)) (expandpath @icon)))

(P_SetMessages)

(complete 0)

(P_ChooseWhatIstall)

(if (= 0 #WhatInstall) (exit))
(if (BITAND #WhatInstall  1)  (P_AskLibsDir))
(if (BITAND #WhatInstall  2)  (P_AskMCCsDir))
(if (BITAND #WhatInstall  4)  (P_AskFreeDBDir))

(if (BITAND #WhatInstall  1)
    (
        (P_CopyLibs)
        (P_CopyCatalogs)
    )
)
(complete 25)

(if (BITAND #WhatInstall  2)  (P_CopyMCCs))
(complete 75)

(if (BITAND #WhatInstall  4)  (P_CopyFreeDB))
(complete 100)
