;
; Memorans 1.2 installation script
; $VER: MemoransInstall 1.2 (18.10.97)
; © 1997 Szymon Pura, FREEWARE
;

(set #VERSION 1)
(set #REVISION 2)
(welcome)

; let's greet the user..

(message ("About to install\nMemorans %ld.%ld\n" #VERSION #REVISION)
         "\nThis installation script will create a new directory\n"
         "and copy all necessary files.\n\n"
         "You must have MUI 3.5 installed on your system.")

; now let's check MUI...

(if (NOT (= (exists "MUI:" (noreq)) 2))
    (abort "ERROR: Can't find MUI !! ")
)

(if (< (/ (getversion "libs:muimaster.library") 65536) 16)
    (abort "ERROR: You need MUI 3.5 or newer !!")
)

; let's install libs & classes
; perhaps (foreach) would be better here...

(copylib (source "libs/reqtools.library")
         (dest "libs:")
         (help @copylib-help)
         (prompt "Installing reqtools.library...")
)

(copylib (source "libs/wbstart.library")
         (dest "libs:")
         (help @copylib-help)
         (prompt "Installing wbstart.library...")
)

(copylib (source "libs/date.library")
         (dest "libs:")
		 (help @copylib-help)
		 (prompt "Installing date.library...")

(copylib (source "libs/MUI/MonthNavigator.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing MonthNavigator.mcc...")
)

(copylib (source "libs/MUI/MonthNavigator.mcp")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing MonthNavigator.mcp")
)

(copylib (source "libs/MUI/Popposition.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Popposition.mcc")
)

(copylib (source "libs/MUI/Popxxx.mcp")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Popxxx.mcp")
)

(copylib (source "libs/MUI/Popdevice.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Popdevice.mcc")
)

(copylib (source "libs/MUI/Pophotkey.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Pophotkey.mcc")
)

(copylib (source "libs/MUI/Popport.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Popport.mcc")
)

(copylib (source "libs/MUI/Poptask.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing Poptask.mcc")
)

(copylib (source "libs/MUI/TextInput.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing TextInput.mcc")
)

(copylib (source "libs/MUI/Textinput.mcp")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing TextInput.mcp")
)

(copylib (source "libs/MUI/Textinputscroll.mcc")
         (dest "MUI:Libs/MUI")
         (help @copylib-help)
         (prompt "Installing TextInputScroll.mcc")
)

; now let's create a new drawer and install Memorans...

(set #dest (askdir (prompt "Where should I create a new drawer for Memorans?")
                   (help @askdir-help)
                   (default @default-dest)
           )
)

(set #dirname (askstring (prompt ("Creating a new directory in\n%s" #dest))
                         (default "Memorans")
                         (help @askstring-help)
              )
)

(set #dest (tackon #dest #dirname))

(makedir #dest)

(copyfiles (dest #dest)
           (pattern "~(libs|WBStartup#?|Install#?|env)")
           (infos)
           (source "")
)

(if (NOT (= (exists "ENV:Memorans/Default.calendar" (noreq)) 1))
    (
        (copyfiles (dest "ENV:")
                   (source "env")
                   (infos)
                   (pattern "Memorans")
        )
    )
)
(if (NOT (= (exists "ENVARC:Memorans/Default.calendar" (noreq)) 1))
    (
        (copyfiles (dest "ENVARC:")
                   (source "env")
                   (infos)
                   (pattern "Memorans")
        )
    )
)

(makedir "ENVARC:Memorans")

; let's ask about WBStartup

(set #choice (askchoice (choices "[2pWBStartup drawer"
                         #dest
                        )
                        (default 0)
                        (help "It's generally better to have Memorans in WBStartup\n\n" @askchoice-help)
                        (prompt "Where should the Memorans commodity be installed?")
             )
)

(if (= #choice 0)
   (
      (set #memorans "SYS:WBStartup/Memorans")
      (copyfiles (dest "SYS:WBStartup")
                 (source "WBStartup/Memorans")
                 (infos)
      )
      (tooltype (dest "SYS:WBStartup/Memorans")
                (settooltype "EDITOR" (tackon #dest "MemoransEditor"))
                (noposition)
      )
   )
   (
      (set #memorans (tackon #dest "WBStartup/Memorans"))
      (copyfiles (dest #dest)
                 (pattern "WBStartup")
                 (source "")
                 (infos)
      )
      (tooltype (dest (tackon #dest "WBStartup/Memorans"))
                (settooltype "EDITOR" (tackon #dest "Memoranseditor"))
                (noposition)
      )
   )
)

(set @default-dest #dest)


