;   ________________      ________________          ______  ____  ______
; .-\         \    /      \    /         /----------\___  \/  _ \/ ____/-.
; |  \______   \  /        \  /  _______/            |  |  \  _  \____ \ |
; |         \   \ \   /\   / /       /               |_____/__|__/_____/ |
; |          \   \ \_/  \_/ /  _____/                                    |
; |           \   \        /    /       This code is (c) copyright 1997  |
; |           /____\__/\__/____/               Christopher Page          '
; |                                            The World Foundry        /
; |                                        Digital Anarchy Software    .
; |                                                                    |
; |                                             All Rights Reserved    |
; |                                                                    |
; |                               .------------------------------------'
; |                              /
; `-----------------------------'
;
; Install script for StrategoPrefs and it's associated files
;


(set #txt_welcome1              "This script installs StrategoPrefs V")
(set #txt_welcome2              (cat "\n\nThis is a configuration utility for Stratego"
                                     "\nYou must have Stratego installed on your system for"
                                     "\nthis this editor to be the slightest use to you!"
                                ))


(set #prompt_install_location   (cat "Select the directory where you want StrategoPrefs to be installed,"
                                      "\nFor correct operation of the Stratego <-> StrategoPrefs interface"
                                      " you should install StrategoPrefs in the same directory as Stratego"
                                ))
(set #help_install_location     (cat "When you installed Stratego you created a directory, normally"
                                     "called Stratego, in which the Stratego executable was placed."
                                     " In order for Stratego to successfully call the prefs editor (ie:"
                                     "when the user selects 'Prefs' from the game menu) you must "
                                     "install StrategoPrefs in the same directory as Stratego\n\n"
                                     @askdir-help
                                ))


(set #stat_copybinary           "Copying the StrategoPrefs program")
(set #prompt_copybinary         "Copying the StrategoPrefs program to")

(set #stat_copyicon             "Copying the StrategoPrefs default icon")
(set #prompt_copyicon           "Copying the StrategoPrefs default icon to")


(set #stat_copydocs             "Copying StrategoPrefs documentation")
(set #prompt_askifcopydocs      "Would you like to install the StrategoPrefs documentation?")
(set #help_askifcopydocs        (cat "The documents for StrategoPrefs consist of two parts:"
                                     "\nthe documentation itself and a couple of example pictures"
                                     "\nThey can be placed anywhere (a subdir is created for the "
                                     "pictures if you install them) but I recommend that you put "
                                     "them in the same place as the Stratego docs            \n\n"
                                ))
(set #prompt_docdestination     "Where would you like to install the docs?\n(A directory 'PrefsDocs' will be created there)")
(set #prompt_copydocs           "Copying StrategoPrefs docs to ")




(set #stat_copypresets          "Copying StrategoPrefs preset files")
(set #prompt_askifcopypresets   "Would you like to install the example Presets?")
(set #help_askifcopypresets     (cat "The example presets are a selection of .prefs files "
                                     "which can be loaded into StrategoPrefs via the menu "
                                ))
(set #prompt_presetdestination  "Where would you like the presets to be installed?\n(A directory 'Presets' will be created there)")
(set #prompt_copypresets        "Copying presets to ")



(set #exit_byebyetxt            (cat "Installation Complete"
                                   "\n\nNow read StrategoPrefs.guide before you do anything else!"
                                ))


;-------------------------- Get new version number -------------------------
(set #newModuleVersion (getversion "StrategoPrefs"))
(set #newVer (/ #newModuleVersion 65536))
(set #newRev (- #newModuleVersion (* #newVer 65536)))


;----------------------------- welcome the user -----------------------------
(welcome)

(message #txt_welcome1 ("%ld.%ld" #newVer #newRev) #txt_welcome2)


;--------------------------  Select binary directory  ------------------------
(set #binary-dest "WORK:Stratego")
(set #binary-dest
    (askdir
        (prompt #prompt_install_location)
        (help #help_install_location)
        (default #binary-dest)
    )
)

;----------------------------  Copy binary + icon  --------------------------
(set #sourcefile "StrategoPrefs")
(working #stat_copybinary)
(copyfiles
    (prompt #promp_copybinary
            #binary-dest
    )
    (help @copyfiles-help)
    (source #sourcefile)
    (dest #binary-dest)
    (newname "StrategoPrefs")
    (confirm)
    (files)
    (infos)
    (noposition)
)

;----------------------------  Copy Default Icon  --------------------------
(working #stat_copyicon)
(copyfiles
    (prompt #prompt_copyicon #binary-dest)
    (help @copyfiles-help)
    (source "Graphics.info")
    (dest #binary-dest)
    (noposition)
)
(set #binary-dest (tackon #binary-dest "Graphics"))

(copyfiles
    (prompt #prompt_copyicon #binary-dest)
    (help @copyfiles-help)
    (source "Graphics/def_Stratego.info")
    (dest #binary-dest)
    (noposition)
)



;----------------------------  Copy documentation  --------------------------
(working #stat_copydocs)
(if (askbool
        (prompt #prompt_askifcopydocs)
        (default 1)
        (help #help_askifcopydocs)
    )
    (
        (set #doc-dest "Work:Stratego")
        (set #doc-dest
            (askdir
                (prompt #prompt_docdestination)
                (help #help_askifcopydocs @askdir-help)
                (default #doc-dest)
            )
        )
        (copyfiles
            (prompt #prompt_copydocs #doc-dest)
            (help @copyfiles-help)
            (source "PrefsDocs.info")
            (dest #doc-dest)
            (noposition)
        )
        (set #doc-dest (tackon #doc-dest "PrefsDocs"))
        
        (copyfiles
            (prompt #prompt_copydocs #doc-dest)
            (help @copyfiles-help)
            (source "PrefsDocs/")
            (choices "StrategoPrefs.guide")
            (dest #doc-dest)
            (if (> @user-level 1) (confirm))
            (infos)
            (noposition)
        )
        (set #doc-dest (tackon #doc-dest "DocData"))
        (copyfiles
            (prompt #prompt_copydocs #doc-dest)
            (help @copyfiles-help)
            (source "PrefsDocs/DocData/")
            (choices "Stratego_Setup.iff"
                     "TCP_Setup.iff")
            (dest #doc-dest)
            (if (> @user-level 1) (confirm))
            (infos)
            (noposition)
        )
    )
)

;----------------------------  Copy Preset Files  --------------------------
(working #stat_copypresets)
(if (askbool
        (prompt #prompt_askifcopypresets)
        (default 1)
        (help #help_askifcopypresets)
    )
    (
        (set #preset-dest "Work:Stratego")
        (set #preset-dest
            (askdir
                (prompt #prompt_presetdestination)
                (help #help_askifcopypresets @askdir-help)
                (default #preset-dest)
            )
        )
        (copyfiles
            (prompt #prompt_copypresets #preset-dest)
            (help @copyfiles-help)
            (source "Presets.info")
            (dest #preset-dest)
            (noposition)
        )
        (set #preset-dest (tackon #preset-dest "Presets"))
        
        (copyfiles
            (prompt #prompt_copypresets #preset-dest)
            (help @copyfiles-help)
            (source "Presets/")
            (choices "Defaults.prefs"
                     "All_Rules.prefs"
                     "WB_ECS.prefs"
                     "WB_RTG.prefs")
            (dest #preset-dest)
            (if (> @user-level 1) (confirm))
            (infos)
            (noposition)
        )
    )
)


;------------------------------------ end -----------------------------------
(complete 100)
(exit #exit_byebyetxt)


