;Varez_Install Script v1.1 written by sOCIETY^rSE 1999

(if (= x 1) (welcome))
(onerror (CLEANUP))
; Cleanup any temporary mess we created
(procedure CLEANUP
    ; Nothing to cleanup
    (delete "t:Background")
    (delete "t:Background.prefs")
    (delete "t:Logopic")
    (delete "t:Logopic.prefs")
) ; CLEANUP
(set @user-level 0)
;(set Opt 3)
;(complete 0)
(copyfiles
        (source "Installdat/Background")
        (dest "t:")
        (newname "Background")
)
(copyfiles
        (source "Installdat/Background.prefs")
        (dest "t:")
        (newname "Background.prefs")
)
(run "run InstallerFX t:Background")
(set @user-level 2)

(working "System check...")
(set #wel "\n\n------------------------------------------------------\n\n· R · E · S · I · S · T · A · N · C · E · - · 1 · 9 · 9 · 9 ·\n\n------------------------------------------------------\n\nsOCIETY kicks your ass with Varez!\nThe Serial & Boards database")
(set #ds 450000)
(complete 0)
(if (< @installer-version 43) (abort "The Varez install script needs Installer V43+!"))
(complete 1)
(set #ex (getversion "exec.library" (resident)))
(complete 3)
(if (< (shiftright #ex 16) 37) (abort "Varez needs AmigaOS 2.04 (V37) or higher!"))
(complete 6)
(if (not (exists "MUI:Libs/muimaster.library" (noreq))) (abort "You need an installed MUI system (V3.8 or higher)!"))
(complete 10)
(if (< (shiftright (getversion "MUI:Libs/muimaster.library") 16) 19) (abort "Your MUI system is too old!\nPlease update it to V3.8 or higher."))
(message #wel) (welcome)
(complete 16)
(set #dst (askdir (prompt "Select the destination directory.\nA new drawer called 'Varez' will be created.")
                  (help "All files belongs to Varez will be copied to this directory.\nA new drawer called 'Varez' will be automatically created.")
                  (default "WORK:")))
(copyfiles
        (source "Installdat/Varez")
        (dest "t:")
        (newname "Logopic")
)
(copyfiles
        (source "Installdat/Varez.prefs")
        (dest "t:")
        (newname "Logopic.prefs")
)
(run "run InstallerFX t:logopic")

(complete 17)
(if (< (getdiskspace #dst) #ds) (abort ("There is not enough free disk space for Varez.\nMin. %ld KB are required." (/ #ds 1024))))
(complete 18)
(set #dst (tackon #dst "Varez"))
(complete 19)
(message ("\n\n\nInstalling Varez to '%s'?" #dst))
(complete 20)
(set #dstdev (tackon #dst "Documentation"))
(complete 22)
(set #dstser (tackon #dst "Libs"))
(complete 24)
(set #cpuexe (database "cpu"))
(set #cpuexe (- #cpuexe 68000))
(set #cpuexe (/ #cpuexe 10))

(complete 26)
(set #locale 0)
(if ((>= (shiftright #ex 16) 38) (set #locale (askchoice (prompt "Select your country language:")
                                                         (help "Please select your language with you would to use Varez.")
                                                         (choices "english" "deutsch" "italiano" "françias")
                                                         (default 0)))
                                 (set #locdir 0)
                                 (complete 28)
                                 (if (> #locale 0) (set #locdir (askchoice (prompt "Select the directory for the catalog file:")
                                                                           (help "You can copy the catalog file to main directory of Varez (PROGDIR:)\nor to the system locale directory (LOCALE:)")
                                                                           (choices "PROGDIR:" "LOCALE:")
                                                                           (default 1))))))
(complete 40)
(complete 43)
(complete 47)
(working "Installing Varez...")
(copyfiles (prompt "Installing main files...")
           (help "n/a")
           (source "instdata/bin")
           (dest #dst)
           (nogauge)
           (all))
(complete 54)
(copyfiles (prompt "Installing documention...")
           (help "n/a")
           (source "instdata/Varez.guide")
           (dest #dst)
           (infos)
           (noposition)
           (nogauge))
(complete 55)
(copyfiles (prompt "Installing librarys...")
           (help "n/a")
           (source "libs/")
           (dest "libs:")
           (infos)
           (nogauge)
           (all))
(complete 65)
(copyfiles (prompt "Installing Env variables...")
           (help "n/a")
           (source "env/")
           (dest "envarc:")
           (infos)
           (nogauge)
           (all))
(complete 75)
(if (= #locale 1) (set #locname "instdata/Catalogs/deutsch/Varez.catalog"))
(if (= #locale 2) (set #locname "instdata/Catalogs/français/Varez.catalog"))
(if (= #locale 3) (set #locname "instdata/Catalogs/italiano/Varez.catalog"))
(if (= #locale 1) (set #locdst "Catalogs/deutsch"))
(if (= #locale 2) (set #locdst "Catalogs/français"))
(if (= #locale 3) (set #locdst "Catalogs/italiano"))
(if (= #locdir 0) (set #locdir #dst))
(if (= #locdir 1) (set #locdir "LOCALE:"))
(if (> #locale 0) (set #tmp (tackon #locdir "Catalogs")))
(if (> #locale 0) (makedir #tmp))
(if (> #locale 0) (set #catdst (tackon #locdir #locdst)))
(if (> #locale 0) (copyfiles (prompt "Installing language catalog...")
                             (help "n/a")
                             (source #locname)
                             (dest #catdst)
                             (nogauge)))
(complete 100)
(CLEANUP)
(exit "\nVarez is now installed.\n\nFor bugreports/support/comments etc. please refer to the Resistance Homepage...\n\nRegister you known Serials or your Boards from Amiga/PC/Mac/Console/XXX!" (quiet))
