(set GameDir "Clockwiser")

;try to figure out a place where the user usually installs his games
(if (exists "Games:" (noreq) )
    (set @default-dest "Games:")
    (if (exists "SYS:Games" (noreq) )
        (set @default-dest "SYS:Games")
        (if (exists "Work:Games" (noreq) )
            (set @default-dest "Work:Games")
            (if (exists "JEUX:" (noreq) )
               (set @default-dest "JEUX:")
               (set @default-dest "SYS:")
            )
        )
    )
)
(message "\n\n\nThis loader needs the JST program (NOT INCLUDED)\nto be copied in your path\n\n(if you don't have it already)\n\nJST is available from aminet (game/patch) or on my site\n\nhttp://perso.club-internet.fr/jffabre/amiga/patches.html")

(set #game_ver
 (askchoice
	(prompt "\nWhich version of \"" GameDir "\"\nwould you like to install ?\n")
	(help @askoptions-help)
	(choices "CD32 version" "Floppy version")
 )
)

;ask the user to select a directory to install the game into
(set #dest
     (tackon (askdir (prompt "Where would you like \"" @app-name "\" installed ?\nA drawer called \"" GameDir "\" will be created.")
                     (help @askdir-help)
                     (default @default-dest)
                     (newpath)
             )
     GameDir
     )
)
(set @default-dest #dest)

;;;; update OSEmu

(if (exists "C:OSEmu.400")
    (set install_osemu
	(askbool
		(prompt	"\nDo you need to update OSEmu os emulation module ?")
		(help "An outdated version of C:OSEmu.400 won't allow to run the game")
		(choices "Update" "Leave")
		(default 2)
	)
    )
    (set install_osemu 1)
)
(if (= 1 install_osemu)
    (copyfiles
	(source "OSEmu.400")
	(dest "C:")
    )
)

;;;; end update OSEmu


;create the selected directory

(makedir #dest (infos))

(copyfiles
	(source "ClockwiserDOS")
	(dest #dest)
)
(copyfiles
	(source "ClockwiserHD")
	(dest #dest)
)
(copyfiles
	(source "ClockwiserHD.readme")
	(dest #dest)
	(infos)
)

(set #icon_ver
 (askchoice
	(prompt "\nWhich icon(s) would you like to install ?\n")
	(choices "Normal" "NewIcon")
	(help @askchoice-help)
 )
)
(if (= #icon_ver 0)
    (copyfiles
	(source "Normal")
	(dest #dest)
	(all)
    )
    (copyfiles
	(source "NewIcon")
	(dest #dest)
	(all)
    )
)

(if (= #game_ver 0)
    (	(askdisk
		(prompt	("\n\n\nPlease insert %s CD-ROM in any drive" @app-name))
		(dest	"ClockWiser")
		(help	"Insert the CD in your CD-ROM drive\nor you'll wait for a while!")
		(assigns)
	)
	(copyfiles
		(source "Clockwiser:")
		(dest #dest)
		(pattern "#?")
		(files)
	)
    )
    (	(askdisk
		(prompt	("\n\n\nPlease insert %s disk 1 in any drive" GameDir))
		(dest	"Clock1")
		(help	"Insert volume Clock1 in any drive\nor you'll wait for a while!")
		(assigns)
	)
	(copyfiles
		(source "Clock1:ClockIntro")
		(dest #dest)
		(newname "ClockIntro.exe")
	)
	(askdisk
		(prompt	("\n\n\nPlease insert %s disk 2 in any drive" GameDir))
		(dest	"Clock2")
		(help	"Insert volume Clock2 in any drive\nor you'll wait for a while!")
		(assigns)
	)
	(copyfiles
		(source "Clock2:ClockGame")
		(dest #dest)
		(newname "Clock32.exe")
	)
	;---> remove manual protection !!!
	(if	(= 0 (run ("MultiFR >nil: HFS 41B0390000816C660000044E HRS 414E754E714E714E714E714E %s" (tackon #dest "Clock32.exe"))))
		("")
		(abort "Manual Protection could not be removed!")
	)
    )
)
(exit)
