; $VER InstallPrefs 1.3i (??.09.95)

(set Update 0)
(set version 0)
(set DrawerName "DC:")

(complete 0)
(if (exists "DC:" (NOREQ))
    (

        (if (exists "DC:DiamondPrefs" (NOREQ))
            (
                (set vernum (getversion "DC:DiamondPrefs"))

                (set ver (/ vernum 65536))
                (set rev (- vernum (* ver 65536)))

                (set version (+ (* 100 ver) rev))

                (if (> version 102)
                    (
                        (message "You have already installed a version greater or equal 1.3!\n")
                        (exit (quiet))
                    )
                )

                (set Update
                    (askchoice
                        (prompt "Diamond Prefs V" ver "." rev " already installed.\nDo you want to update or install completely new?")
                        (choices "Install new" "Update")
                        (help "Sorry, no help-file.")
                        (default 0)
                    )
                )
            )
        )
    )
    (
        (message "Directory "DC:" not found!\nYou need an installed Version of Diamond Caves to run Diamond Prefs.")
        (exit (quiet))
    )
)

(if (= Update 1)                  ; only Update according to present Version
    (
        (complete 30)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "new")
            (dest DrawerName)
            (all)
            (infos)
        )
    )

    (                             ; new install: copy everything to "DrawerName" (should be "DC:" !)
        (complete 10)
        (set icons
            (askchoice
                (prompt "What kind of Icons do you want?\n")
                (choices "normal" "MagicWB (1)" "MagicWB (2)" "RareDiamond" "none")
                (help "Soory, no help-file.")
                (default 0)
            )
        )

        (if (= icons 0)
            (set IconName "/Game2.2/Icons/normal")
        )
        (if (= icons 1)
            (set IconName "/Game2.2/Icons/MagicWB1")
        )
        (if (= icons 2)
            (set IconName "/Game2.2/Icons/MagicWB2")
        )
        (if (= icons 3)
            (set IconName "/Game2.2/Icons/RareDiamond")
        )

        (if (<> icons 4)
            (
                (copyfiles
                    (prompt "Copying necessary Icons to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source IconName)
                    (dest DrawerName)
                    (pattern "DiamondPref#?")
                    (infos)
                )
            )
        )

        (complete 30)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "new")
            (dest DrawerName)
            (pattern "DiamondPrefs#?")
            (infos)
        )
    )
)

(complete 100)
(message "\nDiamondPrefs V1.3 installation/update complete.\n\nHave fun!")

(exit (quiet))
