; $VER: OnyxBase-Install v2.1 (08.03.00)
; Installer script made by Stefan Blixth, OnyxSoft

(set #welcome "\nWelcome to OnyxBase 2.1 installer.\n© 1998-2000 Stefan Blixth, OnyxSoft.\n\nCheck our homepage for more stuff ;-)\n\nwww.onyxsoft.nu\n")
(set #endmsgs "OnyxBase 2.1 has now been installed on your system.\n\nDon't forget to register your copy at : onyxbase@onyxsoft.nu\n\nIt's totaly free!!!\n")

(message #welcome)
(welcome)
(complete 0)

; - create destination dir

(set destination
  (askdir (prompt "Please select the destination directory for OnyxBase.\nA sub-directory \"OnyxBase\" will be created.")
    (default @default-dest)
    (help @askdir-help)
  )
)

(set @default-dest destination)

(set destination (expandpath destination))
(set destination (tackon destination "OnyxBase"))

(if (<> 0 (exists destination))
(
  (message "There is an older installation of OnyxBase in the same directory.\nI'll rename it to OnyxBase_old, so you can delete it later.")
    (run (cat "rename \"" destination "\" \"" destination "_old\""))
    (run (cat "delete \"" destination ".info\" >nil:"))
  )
)

(makedir destination)
(run (cat "copy " "/OnyxBase.info \"" destination ".info\""))

(complete 25)

; - copy main program

(copyfiles
  (prompt "Copying ...")
  (source "")
  (pattern "O#?")
  (dest destination)
  (help @copyfiles-help)
)

(complete 50)

; - copy examples..

(makedir (cat destination "/Examples"))

(copyfiles
  (prompt "Copying ...")
  (source "Examples/")
  (pattern "#?")
  (infos)
  (dest (cat destination "/Examples"))
  (help @copyfiles-help)
)

(makedir (cat destination "/Extras"))

(copyfiles
  (prompt "Copying ...")
  (source "Extras/")
  (pattern "#?")
  (infos)
  (dest (cat destination "/Extras"))
  (help @copyfiles-help)
)

(complete 75)

; - copy catalog

(set choice
  (askchoice
    (prompt "Please select a language you want to use...")
    (choices "English" "ÃeÓtina" "Dansk" "Deutsch" "Svenska")
    (default 0)
    (help @askoptions-help)
  )
)

(if (= 1 choice)
  (if (<> 0 (exists "LOCALE:catalogs/ÃeÓtina/" (noreq)))
    (copyfiles
      (prompt "Copying...")
      (source "catalogs/ÃeÓtina/OnyxBase.catalog")
      (dest "LOCALE:catalogs/ÃeÓtina/")
    )
  )
)

(if (= 2 choice)
  (if (<> 0 (exists "LOCALE:catalogs/dansk/" (noreq)))
    (copyfiles
      (prompt "Copying...")
       (source "catalogs/dansk/OnyxBase.catalog")
       (dest "LOCALE:catalogs/dansk/")
    )
  )
)

(if (= 3 choice)
  (if (<> 0 (exists "LOCALE:catalogs/deutsch/" (noreq)))
    (copyfiles
      (prompt "Copying...")
       (source "catalogs/deutsch/OnyxBase.catalog")
       (dest "LOCALE:catalogs/deutsch/")
    )
  )
)

(if (= 4 choice)
  (if (<> 0 (exists "LOCALE:catalogs/svenska/" (noreq)))
    (copyfiles
      (prompt "Copying...")
       (source "catalogs/svenska/OnyxBase.catalog")
       (dest "LOCALE:catalogs/svenska/")
    )
  )
)


(message "Following procedure will install the required GI1 class\n'tabs.gadget' to your system.\n\nNotice! - This will not check if you have a later version installed\nThis has to be done by hand (by yourself)\n\nUse C:Version Sys:Classes/Gadgets/tabs.gadget\nAnd compare against the gadget that came with this archive.")

(set choice
  (askchoice
    (prompt "Installation of the required class(es)")
    (choices "Install 'tabs.gadget' (required)" "No please! (allready installed)")
    (default 0)
    (help @askoptions-help)
  )
)

(if (= 0 choice)

  (if (= 0 (exists "Sys:Classes/Gadgets/" (noreq)))
    (message "Could not install the tabs.gadget properly\nIt looks like you havn't a proper system setup!\n\nYou need this gadget to run this program!\n\nLook in the 'Classes'-drawer inside this archive.\nThis drawer should be placed directly under your system partition, namely SYS:\n\nPlease contact me at : stefan@onyxsoft.nu\nif you can't get it to work properly!")
  )
)

(if (= 0 choice)
  (if (<> 0 (exists "Sys:Classes/Gadgets/" (noreq)))
    (copyfiles
      (prompt "Copying ...")
      (source "Classes/Gadgets/tabs.gadget")
      (dest "SYS:Classes/Gadgets/")
      (help @copyfiles-help)
    )
  )
)

(complete 100)
(message #endmsgs)
(exit)