; Installer Script for UrouHack V1.7+

(set @options "")
(set @commandline "")

(set whatchoice
	(askchoice
		(prompt "You can use this installation script either to install a new version or to change the preferences")
		(help "Where´s the problem?")
		(choices "Installing UrouHack"
				 "Change preferences")
		(default 0)
	)
)
(set patchchoice
	(askoptions
		(prompt "What should be patched?")
		(help "Where´s the problem?")
		(choices "Patch frames"
				 "Patch System gadgets (arrows, close etc.)")
		(default 3)
	)
)
(if (<> 0 (BITAND patchchoice 2))
	(
		(set instchoice
			(askchoice
				(prompt "Which type of sysiimages do you want to use?")
				(help "Where´s the problem?")
				(choices "UrouHack      (my very own style)"
						 "SysiHack      (the famous one 8))"
						 "MWB Plain     (via Datatypes)"
						 "XEN Gradient  (via Datatypes)")
				(default 3)
			)
		)
		(if (= 0 instchoice)
			(set @commandline "c:urouhack s:urouhack.config")
		)
		(if  (= 1 instchoice)
			(set @commandline "c:urouhack s:urouhack.config SYSIHACK")
		)
		(if (= 2 instchoice)
			(set @commandline "c:urouhack s:urouhack.config imgstyle=cleanmwb")
		)
		(if (= 3 instchoice)
			(set @commandline "c:urouhack s:urouhack.config imgstyle=xengradient")
		)
	)
	(set @commandline "c:urouhack s:urouhack.config NOSYSI")
)

(if (<> 0 (BITAND patchchoice 1))
	(
		(set framechoice
			(askchoice
				(prompt "Which type of frames do you want?")
				(help "Where´s the problem?")
				(choices "XEN Style       (like MUI)"
						 "XWindows Style  (like Motif)")
				(default 0)
			)
		)
		(if (= 1 framechoice) (set @options " XWIN"))
	)
	(set @options " NOFRAME")
)
(set windowchoice
	(askchoice
		(prompt "Which type of windowborders do you want?\n")
		(help "Where´s the problem?")
		(choices "Very thin"
				 "Thin"
				 "Thin      (normal titlesize)"
				 "Normal    (HippoPlayer compatible)")
		(default 1)
	)
)
(set scrollerchoice
	(askchoice
		(prompt "Which scrollersizes do you want?")
		(help "Where´s the problem?")
		(choices "11 point  (PAL/NTSC)"
				 "14 point  (DBLNTSC)"
				 "15 point  (DBLPAL)"
				 "18 point  (800x600)"
				 "Normal")
		(default 1)
	)
)
(if (= 0 scrollerchoice)
	(set @options (cat @options " SBOTTOM=11"))
)
(if (= 2 scrollerchoice)
	(set @options (cat @options " SBOTTOM=15"))
)
(if (= 3 scrollerchoice)
	(set @options (cat @options " SBOTTOM=18"))
)
(if (= 0 scrollerchoice)
	(set @options (cat @options " SBOTTOM=11"))
)
(if (= 0 windowchoice)
	(set @options (cat @options " WTOP=2 WBOTTOM=2 WLEFT=2 WRIGHT=2"))
)
(if (= 2 windowchoice)
	(set @options (cat @options " WTOP=2"))
)
(if (= 3 windowchoice)
	(set @options (cat @options " WTOP=2 WBOTTOM=2 WLEFT=4 WRIGHT=4"))
)
(set @commandline (cat @commandline @options))
(if (= 0 whatchoice)
	(
		(if (= (exists "s:urouhack") 0)
			(makedir "s:urouhack")
		)
		(if (= (exists "s:urouhack/cleanmwb") 0)
			(if (= 2 instchoice)
				(copyfiles
					(optional nofail force)
					(prompt "Installing Images")
					(help   "Where´s the problem?")
					(source "s/urouhack/cleanmwb")
					(dest   "s:urouhack/cleanmwb")
					(all)
				)
			)
		)
		(if (= (exists "s:urouhack/xengradient") 0)
			(if (= 3 instchoice)
				(copyfiles
					(optional nofail force)
					(prompt "Installing Images")
					(help   "Where´s the problem?")
					(source "s/urouhack/xengradient")
					(dest   "s:urouhack/xengradient")
					(all)
				)
			)
		)
		(copyfiles
			(prompt "Installing UrouHack")
			(help   "Where´s the problem?")
			(source "urouhack")
			(dest   "c:")
		)
		(if (= (exists "s:urouhack") 0)
			(copyfiles
				(prompt "Installing default Config")
				(help   "Where´s the problem?")
				(source "urouhack.config")
				(dest   "s:")
			)
		)
		(if (NOT (run "C:Search s:startup-sequence #?urouhack#? PATTERN QUIET"))
			(
				(run ("c/ModifyStartUp \"#?urouhack#?\" \"%s\" REPLACE" @commandline))
				(exit "Urouhack was already found in the startup-sequence. The new settings are now written, and the new version was copied.")
			)
		)
		(if (NOT (run "C:Search s:startup-sequence #?AddDataTypes#? PATTERN QUIET"))
			(
				(run ("c/ModifyStartUp #?AddDataTypes#? \"%s\" AFTER" @commandline))
				(exit "Have fun with this nice piece of software. Please consult the manual for setting up the screenlistfile.")
			)
			(
				(if (NOT (run "C:Search s:startup-sequence #?SetPatcht#? PATTERN QUIET"))
					(
					(run ("c/ModifyStartUp \"#?SetPatch#?\" \"%s\" AFTER" @commandline))
					(run ("c/ModifyStartUp \"#?SetPatch#?\" \"Assign ENV: ENVARC:\" AFTER"))
					(exit "Could not find AddDataTypes in startup-sequence. UrouHack could not work correctly! Please consult the manual for resolving problems and setting up a screenlistfile.")
					)
				)
			)
		)
		(exit "Please install UrouHack manually in your startup-sequence. It seems you´re not using a standard sequence.")
	)
	(
		(if (NOT (run "C:Search s:startup-sequence #?urouhack#? PATTERN QUIET"))
			(
				(run ("c/ModifyStartUp \"#?urouhack#?\" \"%s\" REPLACE" @commandline))
				(exit "Urouhack was found in the startup-sequence. The new settings are now written.")
			)
			(exit "Please install UrouHack first on your system. Could not find it in s:startup-sequence.")
		)
	)
)

