;$VER:2.91 update
;installer script by Curt Esser
;last modified APR 23 1999
;nah, it's not copyrighted  ©
;what could you do with it except install my program?

(complete 0)

;(set @default-dest "WORK:")

; Texts

(set #Intro-Txt
  (cat "\nWelcome to "
  "the Crazy 8's v2.91\n"
  "Update Script\n\n"
  "Crazy 8's is designed and programmed by:\n"
  "Curt Esser\n\n"
  "NOTE: You MUST have already installed\n"
  "Crazy 8's  v2.7 ~ 2.9 to use this update!\n"
  "If not, please abort now and get the full version!"
))

(set #More-Txt
  (cat "\nIMPORTANT!\n\n"
  "The script will NOT remove "
  "your old Crazy 8's version without your permission.\n\n"
  "Your scoring records will NOT be harmed!\n\n"
  "However, if you wish to keep your old version, "
  "I recommend that you abort now and make a backup "
  "of your old Crazy 8's drawer first. "
  "Then run this script, and let it remove the old "
  "files."
))


(set #Warning-Txt
  (cat "Warning !\n\n\n"
  "ReqTools.library not found in SYS:Libs/\n\n\n"
  "You MUST install ReqTools.library to play Crazy 8's!"
))


(set #Path-Txt
  (cat "Where do you keep Crazy 8's?\n "
       "Please click on the program name")  
)


(set #Path-Help
  (cat "Please show me where your "
       "Crazy 8's program is located "
       "by going into it's directory "
       "and clicking the program's name.\n\n"
       @askfile-help)
)



; Main ----------------------------

(message #Intro-Txt)
(message #More-Txt)

(IF (NOT (EXISTS "LIBS:reqtools.library"))
    (message #Warning-Txt (all))
)

(complete 10)



(set execname         ; get name & path to current exec 
  (askfile 
    (prompt #Path-Txt)
    (default @default-dest)
    (help #Path-Help) 
  )
)

(set target (pathonly execname))

(set @default-dest target)


(complete 25)

(set dumpold
  (askbool
    (help "Select YES to remove the old program")
    (prompt 
      ("Should I remove\n")
      ("the old version ")
      (fileonly (execname))
      ("?\n\n ")
      ("Press the YES button to remove it\n")
      ("or the NO button to keep it")
    )
  (default 0)
  )
)

(if (= dumpold 1)
  
  (delete execname
    (infos)
  )
)


(set dumpcpref
  (if (= dumpold 1)
    (askbool
      (help "Select YES to remove the old programs")
      (prompt 
        ("Should I remove\n")
        ("the Card Prefs program and the Locale Setting program?\n\n")
        ("They are no longer needed unless ")
        ("you have a Beta Test version\n\n")
        ("It is recommended that you remove them to save confusion\n\n")
        ("Press the YES button to remove them\n")
        ("or the NO button to keep them")
      )
      (default 0)
    )
  )
)


(COMPLETE 30)

(if (= dumpcpref 1)
  (delete (tackon target "Card.prefs")
    (infos)
  )
)

(if (= dumpcpref 1)
  (delete (tackon target "locale/SetLocale"))
)

(if (= dumpcpref 1)
  (delete (tackon target "locale/C8.LOCALE"))
)

(delete (tackon target "docs/Important!")
  (infos)
)

(COMPLETE 40)

;---- Copy REQUIRED files ---

; - NO choice - these are all required

(copyfiles
  (prompt  "Copying new files")
  (all)
  (infos)
  (source (""))
  (dest (target))
)

(delete (tackon target "Update.Crazy8's")
  (infos)
)

(delete (tackon target "Important!")
  (infos)
)

(complete 100)

(exit "\nAll done!\n\n" 
      "You will find Crazy 8's v2.91 in your\n"
      (target)" directory\n\n"
      "You will need to re-set your prefs the first "
      "time you play.\n\n"   
      "Please read the docs and enjoy the game!"
      (QUIET)

)
