; $VER DC-Install 2.3 (14.12.95)

(set DrawerNameParent @default-dest)
(set Update 0)
(set version 0)

(run "describe/sync SCRIPT=INSTALL.BAT") ; describe is (C) Dietmar Eilert

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

        (set vernum (getversion "DC:DiamondCaves"))

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

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

        (if (> version 202)
            (
                (message "You have already installed a version greater or equal 2.3!\n")
                (exit (quiet))
            )
            (
                (set DrawerNameParent "DC:")
                (set DrawerName "DC:")
            )
        )

        (set Update
            (askchoice
                (prompt "Diamond Caves V" ver "." rev " already installed.\nDo you want to update or install completely new?")
                (choices "Install new" "Update")
                (help "Soory, no help-file.")
                (default 1)
            )
        )
    )
)

(if (= Update 1)                  ; only Update according to present Version
    (
        (if (< version 103)         ; this is only for V1.0/1.1/1.2 (two fixed game levels)
            (
                (complete 30)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.2")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (< version 104)         ; this is the update for V1.0-1.3 (ten new easy levels, one game level)
            (
                (complete 40)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.3")
                    (dest DrawerName)
                    (all)
                )
            )
        )


        (if (exists "DC:gfx/x999" (NOREQ))
            (
                (complete 50)
                (delete
                        ("DC:gfx/x999")
                        (prompt "Deleting old gfx-file.")
                        (help @deletefile-help)
                )
            )
        )

        (if (< version 106)         ; this is the update for V1.0-1.5 (new gfx-format)
            (
                (complete 60)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.5")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (< version 107)         ; this is the update for V1.0-1.6 (all replay-files and new sfx-format)
            (
                (complete 70)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.6")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (< version 108)         ; this is the update for V1.0-1.7 (2 replay-files)
            (
                (complete 75)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.7")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (< version 200)         ; this is the update for V1.0-1.8 (sample y27)
            (
                (complete 80)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-1.8")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (< version 203)         ; this is the update for V1.0-2.2 (prg & guide)
            (
                (complete 90)
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "UpdateFromV1.0-2.2")
                    (dest DrawerName)
                    (all)
                )
            )
        )

        (if (exists "DC:Registration.txt" (NOREQ))
            (
                (copyfiles
                    (prompt "Copying necessary files to \"" DrawerName "\".")
                    (help @copyfiles-help)
                    (source "new/Registration.txt")
                    (dest DrawerName)
                )
            )
        )
    )

    (                             ; new install: copy everything to "DrawerName"
        (complete 0)
        (set DrawerNameParent
             (askdir
                 (prompt "In which drawer should Diamond Caves V2.3 be installed?\n(A directory called Diamond Caves will be created)")
                 (help @askdir-help)
                 (default DrawerNameParent)
             )
        )

        (set DrawerName (tackon DrawerNameParent "DiamondCaves"))

        (complete 5)
        (makedir DrawerName
            (prompt "I will now create the directory \"" DrawerName "\".")
            (help @makedir-help)
            (infos)
            (confirm)
        )

        (complete 10)
        (set icons
            (askchoice
                (prompt "What kind of Icons do you want?\n")
                (choices "normal" "MagicWB (1)" "MagicWB (2)" "RareDiamond" "none")
                (help "Sorry, no help-file.")
                (default 0)
            )
        )

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

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

        (complete 20)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "new")
            (dest DrawerName)
            (all)
            (infos)
        )

        (complete 25)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.2")
            (dest DrawerName)
            (all)
        )

        (complete 30)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.3")
            (dest DrawerName)
            (all)
        )

        (complete 35)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.5")
            (dest DrawerName)
            (all)
        )

        (complete 40)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.6")
            (dest DrawerName)
            (all)
        )

        (complete 45)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.7")
            (dest DrawerName)
            (all)
        )

        (complete 50)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.8")
            (dest DrawerName)
            (all)
        )

        (complete 60)
        (copyfiles
            (prompt "Copying necessary files to \"" DrawerName "\".")
            (help @copyfiles-help)
            (source "UpdateFromV1.0-2.2")
            (dest DrawerName)
            (all)
        )

        (complete 70)
        (startup "Diamond Caves"
            (prompt "An assign to \"DC:\" will be added to \"S:user-startup\" so that your system will be properly configured to use Diamond Caves.")
            (help "Sorry, no help-file.")
            (command "assign DC: \"" DrawerName "\"")
        )
        (makeassign "DC")
        (makeassign "DC" DrawerName)


        (complete 75)
        (if ((database "vblank") 50)
            (set DefaultMode 0)
            (set DefaultMode 2)
        )
        (set ScreenModeNum
            (askchoice
                (prompt "Which screenmode do you want the title screen of Diamond Caves to use?\n(Note that the title was designed to be used on an interlaced screenmode)")
                (choices "PAL:HighRes" "PAL:HighRes Interlace" "NTSC:HighRes" "NTSC:HighRes Interlace")
                (help "To play Diamond Caves with other Screenmodes, use the program DiamondPrefs.")
                (default DefaultMode)
            )
        )
        (if (= ScreenModeNum 0)
            (set ScreenMode "PAL")
        )
        (if (= ScreenModeNum 1)
            (set ScreenMode "PAL-LACE")
        )
        (if (= ScreenModeNum 2)
            (set ScreenMode "NTSC")
        )
        (if (= ScreenModeNum 3)
            (set ScreenMode "NTSC-LACE")
        )
        (tooltype 
            (prompt "I will now change the tooltype TITLEMODE to " ScreenMode ".")
            (help "Soory, no help-file.")
            (dest "DC:DiamondCaves")
            (settooltype "TITLEMODE" ScreenMode)
            (confirm)
        )


        (complete 80)
        (set ScreenModeNum
            (askchoice
                (prompt "Which screenmode do you want the game to use?\n(Note that you should only use interlace if you have a 17\" monitor)")
                (choices "PAL:LowRes" "PAL:HighRes Interlace" "NTSC:LowRes" "NTSC:HighRes Interlace")
                (help "To play Diamond Caves with other Screenmodes, use the program DiamondPrefs.")
                (default DefaultMode)
            )
        )
        (if (= ScreenModeNum 0)
            (set ScreenMode "PAL")
        )
        (if (= ScreenModeNum 1)
            (set ScreenMode "PAL-LACE")
        )
        (if (= ScreenModeNum 2)
            (set ScreenMode "NTSC")
        )
        (if (= ScreenModeNum 3)
            (set ScreenMode "NTSC-LACE")
        )
        (tooltype 
            (prompt "I will now change the tooltype GAMEMODE to " ScreenMode ".")
            (help "Soory, no help-file.")
            (dest "DC:DiamondCaves")
            (settooltype "GAMEMODE" ScreenMode)
            (confirm)
        )


        (complete 85)
        (set ControlNum
            (askchoice
                (prompt "Which controlling device do you want Player 1 to use?\n")
                (choices "Joystick Port 1" "Joystick Port 2" "Keyboard")
                (help "To redifine the controlling devices, use the program DiamondPrefs.")
                (default 1)
            )
        )
        (if (= ControlNum 0)
            (set ControlMode "JOY1")
        )
        (if (= ControlNum 1)
            (set ControlMode "JOY2")
        )
        (if (= ControlNum 2)
            (set ControlMode "KEYS")
        )
        (tooltype 
            (prompt "I will now change the tooltype PLAYER1 to " ControlMode ".")
            (help "Soory, no help-file.")
            (dest "DC:DiamondCaves")
            (settooltype "PLAYER1" ControlMode)
            (confirm)
        )


        (complete 90)
        (set ControlNum
            (askchoice
                (prompt "Which controlling device do you want Player 2 to use?\n")
                (choices "Joystick Port 1" "Joystick Port 2" "Keyboard")
                (help "To redifine the controlling devices, use the program DiamondPrefs.")
                (default 0)
            )
        )
        (if (= ControlNum 0)
            (set ControlMode "JOY1")
        )
        (if (= ControlNum 1)
            (set ControlMode "JOY2")
        )
        (if (= ControlNum 2)
            (set ControlMode "KEYS")
        )
        (tooltype 
            (prompt "I will now change the tooltype PLAYER2 to " ControlMode ".")
            (help "Sorry, no help-file.")
            (dest "DC:DiamondCaves")
            (settooltype "PLAYER2" ControlMode)
            (confirm)
        )

        (tooltype
            (prompt "setting gameport.device")
            (help "Sorry, no help-file.")
            (dest "DC:DiamondCaves")
            (settooltype "GAMEPORTDEVICE" "OFF")
        )
    )
)

(complete 100)
(message "\nDiamond Caves installation/update complete, please make sure to read at least the first chapter of the doc-file.\n\nIf you want to reconfigure Diamond Caves, please use the program DiamondPrefs V1.3.\n\nAnd now enjoy Diamond Caves V2.3!")

(exit (quiet))
