; $VER: InstallPoker 0.9 (1.8.1993)
;
; Installs the Poker software

(set version (/ (getversion) 65536))
(set WB20 36)

(set ChooseDest "Install Poker in which directory?")
(set ChooseGuide "Install Poker.guide in which directory?")
(set CopyingGuide "OK to copy Poker.guide?")
(set WhatName "By what name would you like to be known at the Poker table?")
(set UseCurses (cat "Would you prefer to use the within-shell-window mode of the"
               " Curses interface?"
			   " You may always switch modes at any time by modifying an"
			   " environment variable before running the program.\n\n"
			   )
)
(set ModifyEnv (cat "Do you want me to set needed environment variables in"
			   " your startup file?"
			   )
)
(set DoStartup "Ready to modify startup file(s).")
(set AGprompt "Install Commodore's AmigaGuide?")

(set ChooseHelp (cat "A directory named 'Poker' will be created within the"
                " directory you choose, and all Poker files will be copied"
				" into that directory.\n\n"
				)
)
(set GuideHelp "Choose a directory in which to install the Poker.guide documentation file.\n\n"
)
(set MakeHelp "About to create the 'Poker' directory as instructed.\n\n")
(set EnvHelp (cat "If you are the only person likely to be playing Poker on"
             " your system, you may choose to have the required environment"
			 " variables set in your startup sequence so that you don't have"
			 " to enter them every time you boot.\n\n"
			 )
)
(set CursesHelp (cat "Causes certain environment variables to be set during"
                " your startup sequence.  You can always change it later.\n\n"
				)
)
(set NameHelp "Enter your nickname, or real name, alias or whatever.\n\n")
(set AGhelp (cat "This will run Commodore's InstallAmigaGuide script."
			" AmigaGuide is an online help utility, necessary to view"
			" the Poker documentation (Poker.guide).  The script will not"
			" overwrite a newer version of the utility.\n\n"
			)
)

(set whereto
	(askdir
		(prompt ChooseDest)
		(help ChooseHelp @askdir-help)
		(default @default-dest)
		(newpath)
	)
)

(if @pretend (set whereto "T:"))

(set current-dir (expandpath ""))

(set @execute-dir whereto)

(message ("Extracting Poker into %s, please be patient." whereto))

(run (tackon current-dir "Poker.run"))
(run ("copy %s %s" (tackon current-dir "README#?") 
				   (tackon @execute-dir "Poker")
	 )
)

(set whereguide
	(askdir
		(prompt ChooseGuide)
		(help GuideHelp @askdir-help)
		(default (tackon whereto "Poker"))
		(newpath)
	)
)

(copyfiles
	(prompt CopyingGuide)
	(help @copyfiles-help)
	(source "")
	(dest whereguide)
	(infos)
	(pattern "Poker.guide")
)

(set MuckWithStartup
	(askbool
		(prompt ModifyEnv)
		(help EnvHelp @startup-help @askbool-help)
		(default 1)
	)
)

; In clear violation of the Installer docs, I will change the user-level.
; I believe that even a Novice user may be required to enter his name.

(if MuckWithStartup
	(	
		(set OldLevel (user 1))
		(set Name (askstring 
					(prompt WhatName)
					(default "Slim")
					(help NameHelp @askstring-help)
				  )
		)
		(user OldLevel)
		(set UsingCurses (askbool
							(prompt UseCurses)
							(help CursesHelp @askbool-help)
							(default 0)
;							(default (if (< version WB20) 1 0))
						 )
		)
	)
)

(if MuckWithStartup
	(startup @app-name
		(prompt DoStartup)
		(help EnvHelp @startup-help)
		(command ("setenv POKER \"%s\"\n" Name))
		(command (cat (if UsingCurses ("") (";")) "setenv CURSESTYPE ansi\n"))
		(command (cat (if UsingCurses ("") (";")) "setenv LINES 23\n"))
		(command (cat (if UsingCurses ("") (";")) "setenv COLS 80\n"))
	)
)

(set @execute-dir (tackon @execute-dir "Poker"))

(execute "InstallAmigaGuide"
	(prompt AGprompt)
	(help AGhelp @execute-help)
	(confirm)
)

(set @default-dest (tackon whereto "Poker"))

