; 
; $VER: Installation script for EGS-Sorcery V1.0 (06-18-94)
;
; written by Brian C. Wright
;
; 
;	Installer and Installer project icon
;	(c) Copyright 1991-93 Commodore-Amiga, Inc.  All Rights Reserved.
;	Reproduced and distributed under license from Commodore.
;
;	INSTALLER SOFTWARE IS PROVIDED "AS-IS" AND SUBJECT TO CHANGE;
;	NO WARRANTIES ARE MADE.  ALL USE IS AT YOUR OWN RISK.  NO LIABILITY
;	OR RESPONSIBILITY IS ASSUMED. 
;
;

(welcome "EGS-Sorcery Version 1.0 Installation")

(message "\n\nWelcome to the EGS-Sorcery V1.0 icon system for the EGS-Dock. "
         "This system contains over 1 meg of icon files which can be mixed "
         "and matched to your own preference.  Example EGSDock.config files "
         "will be provided.  At the end of the installation, you may choose "
         "which config file you wish to begin using."
) 
         

(set integrated     0)
(set non-integrated 0)
(set prefs          0)
(set apps           0)

(set installed     0)
(set which-icons   0)
(set int-size    323)
(set nint-size   164)
(set prefs-size  497)
(set apps-size     8)

(set configdest "EGS:s/EGSDock.config")

(set configf1 "Integrated (A) Blue Prefs")	; %0000000001
(set configf2 "Integrated (A) No Prefs")	; %0000000010
(set configf3 "Integrated (A) icons only")	; %0000000100
(set configf4 "Integrated (A) Rainbow Prefs")	; %0000001000
(set configf5 "Integrated (S) Rainbow Prefs")	; %0000010000
(set configf6 "Integrated (S) with Apps")	; %0000100000
(set configf7 "Non-Integrated with Apps")	; %0001000000
(set configf8 "Non-Integrated icons only")	; %0010000000
(set configf9 "Non-Integrated Orange Prefs")	; %0100000000
(set configf10 "Text only")			; %1000000000

(set config1 "s/IntegratedABluePrefs")
(set config2 "s/IntegratedANoPrefs")
(set config3 "s/IntegratedANoPrefsNoApps")
(set config4 "s/IntegratedARainbowPrefs")
(set config5 "s/IntegratedSRainbowPrefs")
(set config6 "s/IntegratedSAppsNoPrefs")
(set config7 "s/NonIntegratedAppsNoPrefs")
(set config8 "s/NonIntegratedNoPrefsNoApps")
(set config9 "s/NonIntegratedOrangePrefs")
(set config10 "s/TextOnly")

(procedure copyconfig
  (
    (set configsource (tackon egs-dest configsource))
    (copyfiles
         (help @copyfiles-help)
         (source configsource)
         (dest "EGS:s")
         (newname configdest)
    )
  )
)

(procedure copyicons
    (
         (set temp (tackon egs-dest dirname))
         (makedir temp)
         (copyfiles
              (prompt ("Installing %s Icons..." dirname))
              (help @copyfiles-help)
              (source dirname)
              (dest temp)
              (all)
         )
    )
)

(procedure copypref
    (copyfiles
           (help @copyfiles-help)
           (source configfile)
           (dest temp)
    ) 
)

(procedure copyinformational
    (working "Installing informational files...")
    (complete 16)
    (copyfiles
           (help @copyfiles-help)
           (source ".dirinfo")
           (dest destination)
           (newname "EGS-Sorcery.info")
           (nogauge)
    )
    (complete 17)
    (copyfiles
           (help @copyfiles-help)
           (source ".catinfo")
           (dest egs-dest)
           (newname "Catalog.readme.info")
           (nogauge)
    )
    (complete 18)
    (copyfiles
           (help @copyfiles-help)
           (source ".copyrightinfo")
           (dest egs-dest)
           (newname "Copyright.readme.info")
           (nogauge)
    )
    (complete 19)
    (copyfiles
           (help @copyfiles-help)
           (source ".sorcereadinfo")
           (dest egs-dest)
           (newname "EGS-Sorcery.readme.info")
           (nogauge)
    )
    (complete 20)
    (copyfiles 
           (help @copyfiles-help)
           (source ".instconfiginfo")
           (dest egs-dest)
           (newname "Install_SorceryConfig.info")
           (nogauge)
    )
    (complete 21)
    (copyfiles
           (help @copyfiles-help)
           (source "Install_SorceryConfig")
           (dest egs-dest)
           (nogauge)
    )
    (complete 22)
    (copyfiles
           (help @copyfiles-help)
           (source "Installer")
           (dest egs-dest)
           (nogauge)
    )
    (complete 23)
    (copyfiles
           (help @copyfiles-help)
           (source "Sorcery.large")
           (dest egs-dest)
           (nogauge)
    )
    (complete 24)
    (copyfiles
           (help @copyfiles-help)
           (source "Sorcery")
           (dest egs-dest)
           (nogauge)
    )
    (complete 25)                      
    (copyfiles
           (help @copyfiles-help)
           (source "")
           (dest egs-dest)
           (pattern "#?.readme")
           (files)
           (nogauge)
    )

    (set temp (tackon egs-dest "s"))
    (makedir temp)
    (working "Setting up config files...")
    (complete 30)
    (copyfiles
           (help @copyfiles-help)
           (source "s")
           (dest temp)
           (all)
           (nogauge)
    )
)

; search for the EGS Assign.  If unavailable, quit.

(set egs-assign
        (getassign "EGS")
)

(if (= egs-assign "")
        (
             (abort "\n\nNo EGS: assign available.\n\n" 
                    "Please assign EGS and restart the installation.")
        )
)

; Set the destination and append EGS-Sorcery to it.

(set in-egs
        (askbool
               (prompt "\n\nInstall EGS-Sorcery into the EGS: directory? "
                       "\n\nNote: This is the location where the included config "
                       "files expect it to be.  If you select 'No' here, you will "
                       "need to write your own config files for where ever you select "
                       "to have it installed."
               )
               (help @askbool-help)
               (choices "Yes" "No")
        )
)

(if (= in-egs 1)
        (set destination "EGS:")
        (set destination
               (askdir 
                       (prompt "Into which directory would you like EGS-Sorcery installed? "
                               "\n(An 'EGS-Sorcery' subdirectory will be created.)" )
                       (help @askdir-help)
                       (default "EGS:")
               )
        )
)

(set egs-dest (tackon destination "EGS-Sorcery"))
(set @default-dest egs-dest)
(makedir egs-dest)

(complete 10)

(set install-all
        (askbool
               (prompt "\n\n\nWould you like to install everything?")
               (help @askbool-help)
               (choices "Yes" "No")
        )
)

(if (= install-all 0)
        (set which-icons
               (askoptions
                      (prompt "Which set(s) of icons would you like to install?")
                      (help @askoptions-help)
                      (choices ("Integrated     (%ldK)" int-size)
                               ("Non-Integrated (%ldK)" nint-size) 
                               ("Prefs          (%ldK)" prefs-size) 
                               ("Apps           (%ldK)" apps-size)
                      )
               )
        )
    
        (if (= which-icons 0)
            (
               (complete 15)
               (copyinformational)

               (complete 35)
               (set integrated 1)
               (set dirname "Integrated")
               (copyicons)

               (complete 45)
               (set non-integrated 1)
               (set dirname "Non-Integrated")
               (copyicons)

               (complete 65)
               (set prefs 1)
               (set dirname "Prefs")
               (copyicons)

               (complete 85)
               (set apps 1)
               (set dirname "Apps")
               (copyicons)

               (set installed 1)
            ) 
        )

)

(if (= installed 0)
   (
     (set button1 (BITAND which-icons %0001))
     (set button2 (BITAND which-icons %0010))
     (set button3 (BITAND which-icons %0100))
     (set button4 (BITAND which-icons %1000))
     
     (complete 15)

     (copyinformational)

     (if (> button1 0)
         (
             (set integrated 1)
             (set dirname "Integrated")
	     (complete 35)
             (copyicons)
         )
         (complete 35)
     )

     (if (> button2 0)
        (
             (set non-integrated 1)
             (set dirname "Non-Integrated")
             (complete 50)
             (copyicons)
         )
         (complete 50)
     )

     (if (> button3 0)
         (
             (set prefs 1)
             (set dirname "Prefs")
             (complete 65)
             (copyicons)
         )
         (complete 65)
         
     )

     (if (> button4 0)
         (
             (set apps 1)
             (set dirname "Apps")
             (complete 85)
             (copyicons)
         )
         (complete 85)
     )
  )
)    

(set which-file 
    (askbool
        (prompt "\n\nWould you like a working configuration file installed? \n\n"
                "Note: This action will rename your old EGSDock.config file "
                "and replace have just installed.  You need to be aware which icon "
                "sets you have installed to install the proper configuration file."
        )
        (help @askbool-help)
        (choices "Yes" "No")
    )
)

(if (= which-file 1)
        (set which-conf-file
                (askchoice
                       (prompt "Which configuration file would you like installed?")
                       (help @askchoice-help)
                       (choices configf1 configf2 configf3 configf4 configf5
                                configf6 configf7 configf8 configf9 configf10
                       )
                       (default 0)
                )
        )
        (exit "Thank you for choosing EGS-Sorcery!")
)


(if (> (exists configdest (noreq)) 0)
        (rename "EGS:s/EGSDock.config" "EGS:s/EGSDock.config.bak")
)


(if (= which-conf-file 0)
    (
	(set configsource config1)
        (copyconfig)
    )
)

(if (= which-conf-file 1)
    (
	(set configsource config2)
        (copyconfig)
    )
)

(if (= which-conf-file 2)
    (
	(set configsource config3)
        (copyconfig)
    )
)

(if (= which-conf-file 3)
    (
	(set configsource config4)
        (copyconfig)
    )
)

(if (= which-conf-file 4)
    (
	(set configsource config5)
        (copyconfig)
    )
)

(if (= which-conf-file 5)
    (
	(set configsource config6)
        (copyconfig)
    )
)

(if (= which-conf-file 6)
    (
	(set configsource config7)
        (copyconfig)
    )
)
(if (= which-conf-file 7)
    (
	(set configsource config8)
        (copyconfig)
    )
)

(if (= which-conf-file 8)
    (
	(set configsource config9)
        (copyconfig)
    )
)

(if (= which-conf-file 9)
    (
	(set configsource config10)
        (copyconfig)
    )
)

(complete 100)
