;Install script for Klondike III Update
; 1996 Gerard Sweeney
;(v1.0)
;
;Install the main program
;

(message "\nWelcome to the main installation program for the fixed version of Klondike III AGA [HD version]. This program will run you through some simple questions, and in the end you will end up with the\nnew version of Klondike installed on your Hard Drive.\n\nYou should then refer to the documentation to see what this slight update will mean for you.\n\n\nClick Proceed when ready....")

(set #directory
	(askdir
		(prompt "Where do you keep the main Klondike program?)")
		(help "This program has to know where the main Klondike program is kept so that the updated version can be copied to it....\n\nNote that only the directories will show up on this requester.. In other words, you won't actually SEE the KlondikeIII file, you just have to know where it is (use a file manager if at all unsure).")
		(default "Klondike:")
	)
)

(makeassign "Klondike_Dir" #directory)
(set @default-dest #directory)


(set Old_Ver_Found (exists "Klondike_Dir:KlondikeIII" (noreq)))


(if (= Old_Ver_Found 0)
 (
 (set #oldvernotexists
	(askbool
		(prompt "This program couldn't find the main Klondike program.\nThis indicates that you have probably selected the wrong directory.\n\nHowever, if you are sure you have sleceted this directory correctly (like perhaps you have already renamed/erased/moved the old KlondikeIII file, it can continue.\nSo, Are you SURE this is the correct directory?\n\nAnswer:-\n\nYES ..... Installation will continue....\nNO ...... Installation will abort (sorry).")
		(help "Just what it says there.\n\nI may as well take this time to say sorry I couldn't get it to jump back to the start.. I'm new at this script writing lark myself. Maybe if the Amiga had been shipped with a MANUAL for the installer program?!?!?")
		(choices "No. Stop here"
                         "Yes. Carry on regardless")
		(default 0)
        )
)


(if (= #oldvernotexists 1)
 (
 (exit "Try running this installation program once you have verified where the file KLONDIKEIII is kept.\n\nIf you are convinced you are doing everything properly, run a file manager like DOpus and manually copy the file KLONDIKEIII-UPDATE from the location of this installation program to the location of the old KLONDIKEIII file, and rename it as KLONDIKEIII" (QUIET))
)
)
)
)


(if (= Old_Ver_Found 1)
 (
 (set #oldverexists
	(askbool
		(prompt "Do you want to backup the old version of the main Klondike program?\n\n\nAnswer:-\n\nYES ..... If you want your old version to be kept safe....\nNO ...... If  you want your old version to be overwritten.")
		(help "This install program will rename the old version to KlondikeIII.OLD_1 before copying the new version over.")
		(choices "No. Overwrite it"
                         "Yes. Back it up")
		(default 0)
        )
)




(if (= #oldverexists 0)
(

                (run "rename Klondike_Dir:KlondikeIII Klondike_Dir:KlondikeIII.OLD_1")
                (run "rename Klondike_Dir:KlondikeIII.info Klondike_Dir:KlondikeIII.OLD_1.info")
)
)
)
)


(copyfiles
    (prompt "Copying Updated version of Klondike")
    (help @copyfiles-help)
    (source "KlondikeIII-Update")
    (dest "Klondike_Dir:")
)


(copyfiles
    (prompt "Copying Updated version of Klondike Info")
    (help @copyfiles-help)
    (source "KlondikeIII-Update.inf")
    (dest "Klondike_Dir:")
    (newname "KlondikeIII.info")
)


(set extra_assigns
 (Askbool
  (prompt "Do you wish to assign your own location for the cardsets and music, or do you wish to go with the default Klondike III locations?")
  (Help "By default, the location for the cardsets for is in a subdirectory from Klondike called CARDS, and the music in a subdirectory called MUSIC.\nHowever, with this update, you can have the music and cardsets kept anywhere, and they are given assigns of CARDS: and MUSIC:\n\nNote you can change where the assigns point to during the game by typing in ASSIGN CARDS: [wherever] and the same for music")
  (Choices "No, I'm happy with the defaults"
           "Yes, Let me point elsewhere")
  (default 0)
 )
)


(if (= extra_assigns 1)
(
  (set music_drawer (exists "Klondike_Dir:music" (noreq)))
  (set cards_drawer (exists "Klondike_Dir:cards" (noreq)))

   (if (= music_drawer 1)
   (
   (makeassign "Music" "Klondike_Dir:music")
   )
   )

   (if (= cards_drawer 1)
   (
   (makeassign "Cards" "Klondike_Dir:cards")
   )
   )
 (textfile
  (Prompt "Creating a test text file")
  (Help "Help me!!")
  (dest "Klondike_Dir:KlondikeIII")
  (append ";Klondike III updated version (c) 1995-1996 Rastan. Default music and card locations.\n")
  (append "assign Cards: ")
  (append '\"')
  (append #directory)
  (append "/cards")
  (append '\"')
  (append "\n")
  (append "assign Music: ")
  (append '\"')
  (append #directory)
  (append "/music")
  (append '\"')
  (append "\n")
  (append "KlondikeIII-Update\n")
 )
)
)


(if (= extra_assigns 0)
 (
 (set #cards_directory
	(askdir
		(prompt "Where do you keep your cardsets?)")
		(help "This will be the default place you keep your cardsets. You can change it during the game, but this is where it looks when starting.\nNote that only the directories will show up on this requester.. In other words, you won't actually SEE the KlondikeIII file, you just have to know where it is (use a file manager if at all unsure).")
		(default #directory)
	)
 )

 (set #music_directory
	(askdir
		(prompt "Where do you keep your music?)")
		(help "This will be the default place you keep your music. You can change it during the game, but this is where it looks when starting.\nNote that only the directories will show up on this requester.. In other words, you won't actually SEE the KlondikeIII file, you just have to know where it is (use a file manager if at all unsure).")
		(default #directory)
	)
 )

(makeassign "Music" #music_directory)
(makeassign "Cards" #cards_directory)
 (textfile
  (Prompt "Creating a test text file")
  (Help "Help me!!")
  (dest "Klondike_Dir:KlondikeIII")
  (append ";Klondike III updated version (c) 1995-1996 Rastan. New music and card locations.\n")
  (append "assign Cards: ")
  (append '\"')
  (append #cards_directory)
  (append '\"')
  (append "\n")
  (append "assign Music: ")
  (append '\"')
  (append #music_directory)
  (append '\"')
  (append "\n")
  (append "KlondikeIII-Update\n")
 )
)
)



(set default_musx (exists "Music:default.musx" (noreq)))
(set default_winm (exists "Music:default.winm" (noreq)))
(set intro_musx (exists "Music:intro.musx" (noreq)))

(set errorstr1 "DEFAULT.MUSX found OK\n")
(set errorstr2 "DEFAULT.WINM found OK\n")
(set errorstr3 "INTRO.MUSX found OK\n")
(set music_error 0)

(if (= default_musx 0)
(
 (set errorstr1 "DEFAULT.MUSX is MISSING!\n")
 (set music_error 1)
)
)

(if (= default_winm 0)
(
 (set errorstr2 "DEFAULT.WINM is MISSING!\n")
 (set music_error 1)
)
)

(if (= intro_musx 0)
(
 (set errorstr3 "INTRO.MUSX is MISSING!\n")
 (set music_error 1)
)
)

(if (= music_error 1)
(
 (set errorstr4 "\n\nThese are important music files which Klondike uses. If you decide to continue, you are SERIOUSLY advised to copy these files to the assign MUSIC:")
 (message (cat "POSSIBLE PROBLEM!!!\n\nThe location you have chosen for your music reported the following:-\n\n" errorstr1 errorstr2 errorstr3 errorstr4))
)
)
