; $VER InstallEditor 1.5 (14.05.1996)

(if (> (exists ("env:Language")) 0) (set lanfound (getenv "Language")) )
(set lan 0)
(set #lanQuestion "Please select language:")
(set #nohelp "Sorry, no help-text.")
(if (= "deutsch" lanfound)
    (
        (set lan 1)
        (set #lanQuestion "Bitte Sprache auswählen:")
        (set #nohelp "Sorry, kein help-text.")
    )
)

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

(complete 0)
(set lan  (askchoice (choices "English" "Deutsch"
                         (prompt #lanQuestion)
                         (help #nohelp)
                         (default lan)
                     )
          )
)

(set #normal "normal")
(set #mwb1 "MagicWB (1)")
(set #mwb2 "MagicWB (2)")
(set #rare "RareDiamond")

(if (= lan 0)
    (
        (set #alreadyinstalled "You have already installed a version greater or equal 1.5!\n")
        (set #oldversion "You have already installed an older version of the Diamond Editor.\nDo you want to update or install completely new?")
        (set #installnew "Install new")
        (set #update "Update")
        (set #copy "Copying..." )
        (set #guidesource "english/DiamondEditor.guide")
        (set #whaticons "What kind of Icons do you want?")
        (set #noicons "none")
        (set #nodc "Directory DC: not found!\nYou need an installed Version of Diamond Caves to run the Diamond Editor.")
        (set #end "\nDiamond Edit V1.5 installation/update complete.\n\nHave fun!")
    )
    (
        (set #alreadyinstalled "Es ist schon eine Version größer oder gleich V1.5 installiert!")
        (set #oldversion "Es ist schon eine ältere Version des Diamond Caves Editors installiert.\nWollen Sie dieVersion erneuern oder alles komplett neu installieren?")
        (set #installnew "neu installieren")
        (set #update "erneuern")
        (set #copy "Kopiere..." )
        (set #guidesource "deutsch/DiamondEditor.guide")
        (set #whaticons "Was für Icons möchten Sie?")
        (set #noicons "keine")
        (set #nodc "Konnte Directory DC: nicht finden!\nEs muß eine installierte Version von Diamond Caves vorhanden sein!")
        (set #end "\nDiamond Edit V1.5 fertig installiert/erneuert.\n\nViel Spaß!")
    )
)

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

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

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

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

                (if (> version 104)
                    (
                        (message #alreadyinstalled)
                        (exit (quiet))
                    )
                )

                (set Update
                    (askchoice
                        (prompt #oldversion)
                        (choices #installnew #update)
                        (help #nohelp)
                        (default 1)
                    )
                )
            )
        )
    )
    (
        (message #nodc)
        (exit (quiet))
    )
)

(if (= Update 1)                  ; only Update according to present Version
    (
        (complete 30)
        (if (< version 100)         ; this is only for versions <1.0 (gfx-data)
            (copyfiles
                (prompt #copy)
                (help @copyfiles-help)
                (source "new")
                (dest DrawerName)
                (all)
                (infos)
            )
        )

        (complete 50)
        (if (< version 104)         ; update from V1.0-V1.3 (main-prg new gfx)
            (copyfiles
                (prompt "Copying necessary files to \"" DrawerName "\".")
                (help @copyfiles-help)
                (source "UpdateFromV1.0-1.3")
                (dest DrawerName)
                (all)
                (infos)
            )
        )

        (complete 70)
        (if (< version 105)         ; update from V1.0-V1.4 (main-prg)
            (copyfiles
                (prompt #copy)
                (help @copyfiles-help)
                (source "UpdateFromV1.0-1.4")
                (dest DrawerName)
                (all)
                (infos)
            )
        )


    )

    (                             ; new install: copy everything to "DrawerName" (should be "DC:" !)
        (complete 10)
        (set icons
            (askchoice
                (prompt #whaticons)
                (choices #normal #mwb1 #mwb2 #rare #noicons)
                (help #nohelp)
                (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 #copy)
                    (help #nohelp)
                    (source IconName)
                    (dest DrawerName)
                    (pattern "DiamondEdit#?")
                    (infos)
                )
            )
        )


        (complete 30)
        (copyfiles
            (prompt #copy)
            (help @copyfiles-help)
            (source "new")
            (dest DrawerName)
            (all)
            (infos)
        )

        (complete 50)
        (copyfiles
            (prompt #copy)
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.3")
            (dest DrawerName)
            (all)
            (infos)
        )

        (complete 70)
        (copyfiles
            (prompt #copy)
            (help @copyfiles-help)
            (source "UpdateFromV1.0-1.4")
            (dest DrawerName)
            (all)
            (infos)
        )


    )
)

(complete 70)
(copyfiles                  ; new guide
    (prompt #copy)
    (help #nohelp)
    (source #guidesource)
    (dest DrawerName)
)

(complete 80)
(copyfiles                  ; Catalogs
    (prompt #copy)
    (help #nohelp)
    (source "locale")
    (dest DrawerName)
    (all)
)

(complete 100)
(message #end)

(exit (quiet))
