; $VER: EPA Greek Workbench Install script 1.1 (20.01.1997) Copyright 1996, Elias Papanikolaou (EPA)

(set @app-name "EPA Greek Workbench")
(set @default-dest "")

; =====================================================
; P_TrackMFC - Track down Multi Function Commodity
; =====================================================
(procedure P_TrackMFC

(if (askbool
      (prompt "Do you use MCP or MCX ?")
      (help "Both are commodities that do a number of patches to the system "
            "to make it better. The user can select which of the patches she "
            "wants activated and which not. If you have a lot of small programs "
            "that patch various things, the chances are that you can get rid "
            "of them all, and use just MCP or MCX. They can be found on "
            "Aminet:\n\n"
            "MCP121.lha at directory util/cdity (574K)\n\n"
            "mcx257.lha at directory util/cdity (75K)"
      )
      (default 0)
    )
    (set #MFCinuse "yes")
    (set #MFCinuse "no")
)

)

; =====================================================
; P_ReplaceTopaz
; =====================================================
(procedure P_ReplaceTopaz

(startup "EPA Greek Workbench"
  (prompt "The command\n\n"
          "\"" (tackon #bindir "ReplaceTopaz") "\"\n\n"
          "will now be added to your s:User-Startup.")
  (help "This is needed to patch the system ROM Topaz.font that contains "
        "no Greek characters with Topazgr.font that does.\n"
        "(Also see `Installation - Patch the ROM Topaz 8 font' in the guide)")
  (command "\""(tackon #bindir "ReplaceTopaz")"\"")
)

)

; =====================================================
; SetUpFKey
; =====================================================
(procedure P_SetUpFKey

(set #usefkey "no")

(if (exists "SYS:WBStartup/FKey")
  (if (askbool
        (prompt "It seems that you are using the FKey commodity on a constant "
                "basis.\n(it is in your SYS:WBStartup drawer)\n"
                "Since you already use it, it would be a good idea to add "
                "one more hotkey to assist in the keymap change. Do you "
                "want to add ALT SPACE as the hotkey for toggling the "
                "keyboard between the Latin and Greek states ? (Will not take "
                "effect until you reboot)")
        (help "The definition for one more hotkey (ALT SPACE) will be added "
              "to the already assigned hotkeys in the FKey commodity, so that "
              "when you press ALT and SPACE simultaniously the keymap will be "
              "changed from Latin to Greek and vice versa. No existing hotkey "
              "definitions will be lost. In case you choose Yes, the changes "
              "will not take effect until you reboot (or quit and then restart "
              "the FKey commodity).")
        (default 1)
      )
      (set #usefkey "yes")
  )
  (if (exists "SYS:Tools/Commodities/FKey")
    (if (askbool
          (prompt "It seems that you do not use the FKey commodity. Do you want "
                "to start using it now and assign the hotkey ALT ENTER to it, "
                "so that you will be able to toggle between Latin and Greek "
                "when you type ?")
          (help "The FKey program will be moved from SYS:Tools/Commodities to "
              "SYS:WBStartup, and the hotkey ALT ENTER will be added to its "
              "list of hotkeys, to aid you in toggling the active keymap "
              "between Latin and Greek when you press ALT and ENTER "
              "simultaniously.")
          (default 1)
        )
        (if (rename "SYS:Tools/Commodities/FKey" "SYS:WBStartup/FKey")
            (
              (rename "SYS:Tools/Commodities/FKey.info" "SYS:WBStartup/FKey.info")
              (set #usefkey "yes")
            )
        )
    )
    (message "Could not locate the FKey commodity, so no automation for keymap "
             "exchange was installed. See the guide (Installation - Automate "
             "the keymap change) for more." (all)
    )
  )
)

(if (= #usefkey "yes")
  (tooltype
    (prompt "This is going to add the tooltype\n\n"
            "ALT SPACE RUN TOGGLEKEYMAP\n\n"
            "to the icon of the FKey commodity in the SYS:WBStartup drawer.")
    (help "The definition for one more hotkey (ALT SPACE) will be added "
          "to the already assigned hotkeys in the FKey commodity, so that "
          "when you press ALT and SPACE simultaniously the keymap will be "
          "changed from Latin to Greek and vice versa. No existing hotkey "
          "definitions will be lost. In case you choose Yes, the changes "
          "will not take effect until you reboot (or quit and then restart the "
          "FKey commodity.")
    (dest "SYS:WBStartup/FKey")
    (settooltype "ALT SPACE RUN ToggleKeymap" "")
    (confirm)
  )
)

)

; =====================================================
; Get Locale directory
; =====================================================
(procedure P_GetLocaleDir

(set #localedir
  (askdir
    (prompt "Where do you keep your locale files ?")
    (help
        "The locale files are files that make possible the "
        "localization of your system. They contain information "
        "about your country, language, etc. and also "
        "translations of system and non-system messages "
        "in your native language.\n\n"
        "Usually the assign LOCALE:  points to the place that "
        "locale files reside. In that drawer it is assumed "
        "that the drawers `Catalogs', `Languages', "
        "`Countries' and `Help' exist."
    )
    (default "LOCALE:")
  )
)

)

; =====================================================
; Get Font directory
; =====================================================
(procedure P_GetFontDir

(set #fontdir
  (askdir
    (prompt "Where do you want the Latin-Greek fonts to be copied ?")
    (help
        "These are fonts that contain the normal Latin characters "
        "but also the Greek characters. They are needed to be "
        "able to see any Greek text correctly. See the guide for "
        "more information on the fonts.\n\n"
        "Usually FONTS:  is the place that most of the font "
        "files reside. Especially the fonts that are often "
        "used by the system. And the Latin-Greek fonts "
        "supplied with \"EPA Greek Workbench\" are to be "
        "considered system fonts as they need to be used as "
        "default Screen, System, and Icon fonts.\n\n"
        "You will later need to select these fonts as "
        "defaults from the `Font' preferences program.\n"
        "(Also see `Installation' in the guide)"
    )
    (default "FONTS:")
  )
)

)

; =====================================================
; Get Keymap directory
; =====================================================
(procedure P_GetKeymapDir

(set #keymapdir
  (askdir
    (prompt "Where do you keep your keymaps ?")
    (help
        "Keymaps are files that contain information about the "
        "layout of your keyboard, i.e. which character should "
        "appear when a certain key is pressed.\n\n"
        "Usually KEYMAPS: points to the place that "
        "keymap files reside.\n\n"
        "Two keymap files that will allow you to write both "
        "Latin and Greek characters at any time, will be "
        "copied there.\n"
        "(Also see `Installation' in the guide)"
    )
    (default "KEYMAPS:")
  )
)

)

; =====================================================
; Get binaries directory
; =====================================================
(procedure P_GetBinaryDir

(set #bindir
  (askdir
    (prompt "Where should the programs `ToggleKeymap' "
            "and `ReplaceTopaz' be copied?")
    (help
        "These are Amiga binaries.\n\n"
        "`ToggleKeymap' will help you change the active keymap on "
        "the fly, so that you will be able to type Latin or Greek "
        "characters at any time.\n\n"
        "`ReplaceTopaz' will patch the ROM Topaz font with the "
        "supplied Topazgr font, so that you will be able to see "
        "the Greek versions of the system preferences programs "
        "(eg Screenmode), that normally use the Topaz font (which "
        "has no Greek characters in it).\n\n"
        "You should copy these programs at someplace you keep your "
        "executables. C: or SYS:Bin (if you have such a drawer) "
        "are good choices."
    )
    (default "C:")
  )
)

)

; =====================================================
; Get documentation directory
; =====================================================
(procedure P_GetDocDir

(set #helpdir
  (askdir
    (prompt "Where do you want the EPA_Greek_Workbench.guide copied ?")
    (help
        "I suggest you save the guide some place. You never "
        "know when it will come in handy."
    )
    (default "HELP:")
  )
)

)

; =====================================================
; Copy Locale
; =====================================================
(procedure P_CopyLocale

(if (= @user-level 2)
  (if (askbool
        (prompt "Copy the locale files to " #localedir "?")
        (help "I think the question is quite straightforward.")
        (default 1)
      )
      (set #copylocale "yes")
      (set #copylocale "no")
  )
  (set #copylocale "yes")
)

(if (= #copylocale "yes")
(copyfiles
  (source "locale")
  (dest #localedir)
  (all)
)
)

)

; =====================================================
; Copy keymaps
; =====================================================
(procedure P_CopyKeymaps

(if (= @user-level 2)
  (if (askbool
        (prompt "Copy the keymaps to " #keymapdir "?")
        (help "I think the question is quite straightforward.")
        (default 1)
      )
      (set #copykeymaps "yes")
      (set #copykeymaps "no")
  )
  (set #copykeymaps "yes")
)

(if (= #copykeymaps "yes")
  (copyfiles
      (source "devs/keymaps")
      (dest #keymapdir)
      (all)
  )
)

)

; =====================================================
; Copy fonts
; =====================================================
(procedure P_CopyFonts

(if (= @user-level 2)
  (if (askbool
        (prompt "Copy the fonts to " #fontdir "?")
        (help "I think the question is quite straightforward.")
        (default 1)
      )
      (set #copyfonts "yes")
      (set #copyfonts "no")
  )
  (set #copyfonts "yes")
)

(if (= #copyfonts "yes")
  (copyfiles
      (source "fonts")
      (dest #fontdir)
      (all)
  )
)

)

; =====================================================
; Copy binaries
; =====================================================
(procedure P_CopyBinaries

(if (= @user-level 2)
  (if (askbool
        (prompt "Copy the programs `ToggleKeymap' and `ReplaceTopaz' to " #bindir "?")
        (help "I think the question is quite straightforward.")
        (default 1)
      )
      (set #copybinaries "yes")
      (set #copybinaries "no")
  )
  (set #copybinaries "yes")
)

(if (= #copybinaries "yes")
  (copyfiles
      (source "c")
      (dest #bindir)
      (all)
  )
)

)

; =====================================================
; Copy documentation
; =====================================================
(procedure P_CopyDoc

(if (= @user-level 2)
  (if (askbool
        (prompt "Copy the EPA_Greek_Workbench.guide to " #helpdir "?")
        (help "I think the question is quite straightforward.")
        (default 1)
      )
      (set #copydoc "yes")
      (set #copydoc "no")
  )
  (set #copydoc "yes")
)

(if (= #copydoc "yes")
  (
    (copyfiles
      (source "EPA_Greek_Workbench.guide")
      (dest #helpdir)
      (infos)
    )
  )
)

)

; =====================================================
; Copy the font and locale prefs
; =====================================================
(procedure P_CopyPrefs

(if (askbool
      (prompt "Do you want me to change the system font and locale preferences "
              "NOW, so that your workbench becomes Greek ?"
      )
      (help "If you choose Yes, then a font.prefs and a locale.prefs file "
            "will be written to both envarc:sys/ and env:sys/. "
            "The current font and locale preferences will be lost, but this is "
            "something you will have to do anyway.\n"
            "If you choose No, then you will later have to manually select "
            "the appropriate fonts and language, through the `Font' and "
            "`Locale' preferences programs.\n"
            "(Also see `Installation' in the guide)"
      )
      (default 1)
    )
    (set #copyprefs "yes")
    (set #copyprefs "no")
)

(if (= #copyprefs "yes")
  (
    (copyfiles
      (prompt "Which prefs should I save as default ?")
      (help "They will be used as default from the next time you boot and on.")
      (source "EnvArc/Sys")
      (dest "EnvArc:Sys")
      (all)
      (confirm)
    )
    (copyfiles
      (prompt "Which prefs should I activate now ?")
      (help "The system will try to use them now. Most probably the change in "
            "the font.prefs will cause the Intuition to try to reopen its "
            "screen, so it will ask you to close any programs. You can ingore "
            "the request until the end of this script, and then conform.")
      (source "EnvArc/Sys")
      (dest "Env:Sys")
      (all)
      (confirm)
    )
  )
)

)

; =====================================================
; Welcome
; =====================================================

(welcome
    "Welcome to the installation of EPAGreekWorkbench 1.1. "
    "This package is a set of files that will allow you to select the "
    "Greek language as the default language of your Workbench. "
    "You will be able to do that through the standard `Locale' preferences "
    "program that can be found in your `SYS:Preferences' drawer. See the "
    "guide for more."
)

(P_GetLocaleDir)
(P_GetFontDir)
(P_GetKeymapDir)
(P_GetBinaryDir)
(P_GetDocDir)

(P_CopyLocale)
(P_CopyFonts)
(P_CopyKeymaps)
(P_CopyBinaries)
(P_CopyDoc)

(P_TrackMFC)
(if (= #MFCinuse "no")
  (
    (P_ReplaceTopaz)
    (P_SetUpFKey)
  )
  (message "Since you already use MCP or MCX, this script will not install "
           "the `ReplaceTopaz' program, and will not set up and use the "
           "FKey commodity. It is better that you use MCP or MCX to do the "
           "job.\n"
           "See the guide (Installation) for more."
  )
)

(P_CopyPrefs)

(exit)

