; Installation script for Madhouse V2.12
; Revision 2 - multilingual, docs in lha archive, size-checks.
; Revision 3 - changed for Madhouse 1.2
; Revision 4 - changed for Madhouse 2
; Revision 5 - changed for Madhouse 2.1
; Revision 6 - bugfixed for Madhouse 2.1(1). Update facility.
; Revision 7 - changed to be compatible to Installer 43.3
; Revision 7 - changed for Madhouse 2.5

(complete 0)

(set #mainprgsource "/Madhouse")
(set #mainprgdest "SYS:WBStartup")

; File-sizes for space check. Including icons.   *****
(set #size-mainprg 60000 )
(set #size-locale 30000 )
; (set #size-configed 170000 )
; (set #size-blankers 330000 )
; (set #size-germandoc 155000 )
; (set #size-englishdoc 98000 )
; (set #size-importhelp 70000 )

(set #updatemode 0)

(if (= @language "deutsch") (
	(set #def-anleit 0)
	(set #size-defaultdoc #size-germandoc)
	
   (set #wrong-os
	(cat "\nTut uns leid, Madhouse benötigt OS v2.04 oder höher!!\n"))
	
	(set #diskfull
	(cat "Das Installationsscript muß leider abbrechen, weil auf der "
	     "Festplattenpartition \"%s\" nicht genug Platz "
		  "vorhanden ist." ))
	
	(set #copying-mainprg
	(cat "\nJetzt wird das Programm Madhouse in Ihre "
	            "SYS:WBStartup-Schublade kopiert. Dort wird es dann nach "
					"jedem Reset gestartet.\n"
					"Dieses Programm verwaltet die "
					"Blanker, das Einstellungsprogramm muß ebenfalls damit "
					"aufgerufen werden."))
	; *****
	(set #select-defdir
	(cat "Bitte wählen Sie jetzt die Schublade, in der der "
	            "Anleitungstext, der MadhouseConfigEd und die Blanker installiert werden sollen.\n"
					"In diesem Verzeichnis sollten mindestens ca. 1MB frei sein!\n" ))
	
	(set #select-dir-prompt
	(cat
	            "Wählen Sie das Verzeichnis, in dem Madhouse installiert "
					"werden soll. Vergessen Sie nicht, ein neues Unterverzeichnis "
					"anzulegen, falls Sie eines wünschen!" ))
	
	(set #select-dir-help
	(cat
	            "Wie vorhin gesagt wurde, sollten Sie hier das Zielverzeichnis "
					"für Madhouse auswählen, in das die Anleitungen, der MadhouseConfigEd und "
					"die Blanker geschrieben werden.\nUm ein neues Verzeichnis anzulegen, "
					"benutzen Sie \"Make new drawer...\" und geben Sie den Namen in das Textfeld "
					"ein."))
	
	(set #no-min-space
	(cat "Leider reicht der Platz auf der ausgewählten Festplatte "
	     "nicht mal für die nötigsten Dateien. Bitte wählen Sie einen anderen "
		  "Pfad (\"Proceed\") oder brechen Sie die Installation ab "
		  "(\"Abort Install\")." ))
	(set #no-doc-space
	(cat "Der Platz auf der ausgewählten Diskette / Festplatte reicht zwar für "
	     "die nötigsten Dateien, aber die deutsche Anleitung paßt schon nicht "
		  "mehr. Wollen Sie einen neuen Pfad wählen?" ))
	(set #yes
	(cat "Ja." ))
	(set #no
	(cat "Nein." ))
	
	(set #doing-docs
	(cat "Die deutsche Anleitung wird kopiert." ))
	
	(set #doing-configed
	(cat "\nJetzt wird der MadhouseConfigEd kopiert." ))
	
	(set #blank 
	(cat"\nJetzt werden die Blanker kopiert." ))
	            
	(set #icontext
	(cat "Für das Madhouse-Programm in WBStartup/ stehen sieben Icons zur Auswahl (Zur "
	     "Entscheidungshilfe zuerst in Icons/ ansehen, dann fortfahren.)\n"
		  "MWB=Die MagicWB-Farben müssen installiert sein."))
	(set #iconchoices-1
	(cat "Standard-Icon (Hauptfenster)" ))
	(set #iconchoices-2
	(cat "Schwarzer Keil (MWB)" ))
	(set #iconchoices-3
	(cat "Monitor" ))
	(set #iconchoices-4
	(cat "Monitor (MWB)" ))
	(set #iconchoices-5
	(cat "Schwarzer Monitor" ))
	(set #iconchoices-6
	(cat "Schwarzer Monitor (MWB)" ))
	(set #iconchoices-7
	(cat "Madhouse-Schriftzug" ))
	
	(set #diskfull-locale
	(cat "Dies ist zwar ein Amiga mit OS 2.1 oder höher, die deutschsprachigen "
	     "Locale-Dateien können jedoch trotzdem nicht installiert werden, weil "
		  "auf der zuständigen Festplattenpartition nicht mehr "
		  "genügend Platz ist." ))
	(set #locale-update
	(cat "Die Locale-Dateien sind bereits vorhanden und werden gleich erneuert. "
	     "Es ist jedoch möglich, daß das Betriebssystem diese Daten noch im Speicher "
		  "hält, und Madhouse beim Start die alten Daten aus dem Speicher bekommt. "
		  "Sie umgehen diese Situation durch a) einen Reset nach der Installation oder "
		  "b) durch Beenden von Madhouse und Eingeben von \"avail flush\" in einer Shell, "
		  "dann können Sie das neue Madhouse starten." ))
	
	(set #use-locale
	(cat "TOLL! Dies ist ein Amiga mit OS 2.1 oder höher! Wenn Sie also wollen, können "
	            "die Programtexte von Madhouse auf deutsch erscheinen.\n"
					"Sollen die deutschen Locale-Texte installiert werden?"))
	(set #locale-1
	(cat "Ja" ))
	(set #locale-2
	(cat "Diesen Teil überspringen" ))
	
	; canceled.
	(set #graphicext
	(cat "Vom Blanker Stars sind zwei Versionen verfügbar. Eine, die garantiert funktioniert, "
	     "und eine, die mit Grafikkarten (nicht dem AGA-Chipset, das läuft!) Probleme machen "
		  "wird. Wurde eine besondere Grafikkarte installiert?"))
	(set #graphicext-1
	(cat "Ja / Ich weiß nicht."))
	(set #graphicext-2
	(cat "Nein."))
	(set #graphicexthelp
	(cat "Wer sich hier nicht schlüssig ist, kann es vorerst auch mit \"Nein\" versuchen. "
	     "Der Bildschirmaufbau von Stars kommt dann wahrscheinlich durcheinander, wenn eine "
		  "Grafikkarte im Rechner ist.\nDas AGA-Chipset ist im A1200 und A4000 eingebaut und "
		  "macht keine Probleme." ))
	
	; canceled.
	(set #delprefs
	(cat "Alte Einstellungsdateien \"ENV:\" und \"ENVARC:Madhouse.prefs\" müssen gelöscht werden!!"))
	
	(set #extro
	(cat "Madhouse wurde korrekt installiert. Beim Systemstart wird das Hauptprogramm "
              "von nun an automatisch aktiviert, solange Sie nicht das Programm SYS:WBStartup/Madhouse "
				  "löschen. Dort können Sie es jetzt auch direkt aufrufen, um einen Reset zu "
				  "umgehen.\n\n"
				  "Viel Spaß!" ))

	(set #extro-up
	(cat "Madhouse wurde korrekt up-ge-datet.\n"
		  "Vielleicht wäre ein Reset jetzt nicht schlecht.\n"
		  "Bitte im ConfigEd, System-Seite auf \"Update\" klicken, "
		  "damit neue Blanker in die Liste aufgenommen werden.\n\n"
				  "Viel Spaß!" ))
	
	(set #updating
	(cat "Madhouse ist bereits installiert! Das Update wird vollzogen...\nWenn Madhouse "
		  "im Moment läuft, dann beende es bitte JETZT!" ))

	(set #keyupdating
	(cat "\nDas vorhandene Keyfile kann leider nicht weiterbenutzt werden. Für einen "
		  "Großteil der Benutzer kann das Update des Keyfiles jetzt gleich erfolgen, "
		  "die neuen Keyfiles werden verschlüsselt mitgeliefert."))
	(set #keyupokay "\nDas Keyfile-Update hat funktioniert.\nDer neue Key ist:\n%s")
	(set #keyupfailed
	(cat "\nSorry: Das Keyfile-Update war nicht möglich. Wenn Du noch keine neuen "
	     "Madhouse.key- und Madhouse.key2-Dateien bekommen hast, wende Dich bitte "
	     "an den Autor:\n"
	     "c.jahn@gmx.de\n"
	     "Tel.: +49  (0) 3302 / 80 12 08\n"
	     "Carsten Jahn\nKuckucksruf 34\n16761 Stolpe-Sued\nGermany" ))
))


(if (<> @language "deutsch") (
	(set #def-anleit 1)
	(set size-defaultdoc size-englishdoc)

   (set #wrong-os
	(cat "\nSorry, Madhouse needs OS 2.04 or higher!\n"))
		
	(set #diskfull
	(cat "The script has to abort, because the partition \"%s\" does "
	     "not have enough free disk space." ))
	
	(set #copying-mainprg
	(cat "\nNow, the programm Madhouse will be copied into your SYS:WBStartup-drawer. "
	     "There it will be started after every reset. This program handles the "
		  "blankers, and you have to run the prefs-editor \"MadhouseConfigEd\" from it."))
	
	; *****
	(set #select-defdir
	(cat "Please select the drawer, in which you want to copy the doc, MadhouseConfigEd "
	     "and the blankers in the following requester.\nYou will need about 1MB of "
		  "disk space."))
	
	(set #select-dir-prompt
	(cat "Select the drawer in which you want to install Madhouse. If you prefer an own "
	     "subdirectory for Madhouse, please create one!" ))
	
	(set #select-dir-help
	(cat "The script will copy MadhouseConfigEd, the docs and the blankers into the "
	     "drawer you have to select here. Create a new directory by using "
		  "\"Make New Drawer...\" and entering the name of it into the string gadget." ))
	
	(set #doing-docs
	(cat "Copying english documentation." ))
	
	(set #doing-configed
	(cat "\nNow, MadhouseConfigEd will be copied." ))
	
	(set #blank 
	(cat"\nNow, the blankers will be copied." ))
	            
	(set #icontext
	(cat "You have got the choice out of seven icons for the Madhouse-program (in "
	     "SYS:WBStartup). To make a decision, you can look at the icons right now "
		  "(\"Icons\"-drawer) first. MWB = you "
		  "need the MagicWB-colors on your Workbench."))
	(set #iconchoices-1
	(cat "Standard-Icon (from Madhouse-dir)" ))
	(set #iconchoices-2
	(cat "Colored points & black area (MWB)" ))
	(set #iconchoices-3
	(cat "Monitor" ))
	(set #iconchoices-4
	(cat "Monitor (MWB)" ))
	(set #iconchoices-5
	(cat "Black Monitor" ))
	(set #iconchoices-6
	(cat "Black Monitor (MWB)" ))
	(set #iconchoices-7
	(cat "Madhouse-Text" ))
	
	; Obsolete, english strings are built-in.
	(set #use-locale
	(cat "" ))
	(set #locale-1
	(cat "" ))
	(set #locale-2
	(cat "" ))
	
	; canceled.
	(set #graphicext
	(cat "The Blanker Stars is available in two versions, one that works in every case and one "
	     "that would make troubles with graphic extensions. The AGA-Chipset works with both. "
		  "Do you have installed a graphic extension?"))
	(set #graphicext-1
	(cat "Yes / I don't know."))
	(set #graphicext-2
	(cat "No"))
	(set #graphicexthelp
	(cat "If you don't know the answer, you should perhaps even try \"Yes\", because you would "
	     "know if you've had added something to your Amiga...\nThe AGA-Chipset is in every A1200 "
		  "and A4000 and makes no troubles."))
	
	; canceled.
	(set #delprefs
	(cat "Old preference files \"ENV:\" and \"ENVARC:Madhouse.prefs\" have to be deleted!!"))
	
	(set #extro
	(cat "Madhouse was installed correctly. While booting, the main program \"Madhouse\" "
	     "will be started automatically, as long as you don't delete it (it is in "
		  "SYS:WBStartup). You can start it directly, if you don't want to reset your "
		  "machine.\nEspecially if you do not own a hard disk, you should read the "
		  "doc, otherwise you should it do anyway, of course...\n\nEnjoy!"))
	(set #extro-up
	(cat "Madhouse was updated correctly.\n"
		  "Maybe a reset would be good now.\n"
		  "Please click on \"Update\" (ConfigEd, System page), "
		  "to refresh the blanker list.\n\n"
				  "Enjoy!" ))

	(set #updating
	(cat "Madhouse is already installed! Updating...\nIf Madhouse is running at the "
		  "moment, please quit it NOW." ))
	(set #keyupdating
	(cat "\nYour existing keyfile can't be used any longer. For a lot of users, the "
	     "keyfile update will be possible right now. New keys are submitted in "
	     "encrypted form."))
	(set #keyupokay "\nKeyfile update worked okay.\nYour new key is:\n%s")
	(set #keyupfailed
	(cat "\nSorry: Keyfile Update was not possible with your key. If you did not "
	     "get new Madhouse.key and Madhouse.key2 files yet, please contact the "
	     "author at:\n"
	     "c.jahn@gmx.de\n"
	     "Tel.: +49  (0) 3302 / 80 12 08\n"
	     "Carsten Jahn\nKuckucksruf 34\n16761 Stolpe-Sued\nGermany" ))
))



;  **** Auf OS 2.04 checken.

(if (< (/ (getversion) 65536) 37)
	(
		(message #wrong-os)
		(exit (quiet))
	)
)
(complete 1)




;  **** Madhouse suchen.

(if (exists "SYS:WBStartup/Madhouse") (set #updatemode 1))
(if (exists "SYS:WBStartup/WBStartup (Enabled)/Madhouse") (
	(set #updatemode 1)
	(set #mainprgdest "SYS:WBStartup/WBStartup (Enabled)")
))
(if (exists "SYS:WBStartup/WBStartup (Disabled)/Madhouse") (
	(set #updatemode 1)
	(set #mainprgdest "SYS:WBStartup/WBStartup (Disabled)")
))
(if (exists "SYS:Startup/Madhouse") (
	(set #updatemode 1)
	(set #mainprgdest "SYS:Startup")
))




;  **** ConfigEd suchen. #gtt belegen.  ****  Update vom Keyfile?

; #keyupdate = 0: kein Key. = 1: nur alter Key. = 2 neuer Key schon da.

(run (cat "Gettooltype \"" (tackon #mainprgdest "Madhouse") "\" CONFIGED") )
(set #gtt (getenv "Gettooltype"))
(delete "ENV:Gettooltype")

(set #keypath "S:Madhouse")  ; without .key extension.
(set #keyupdate 0)
(if (exists "S:Madhouse.key" ) (
	(set #keyupdate 1)
))
(if (exists (tackon (pathonly #gtt) "Madhouse.key") ) (
	(set #keypath (tackon (pathonly #gtt) "Madhouse"))
	(set #keyupdate 1)
))

; new keyfile already there?
(if (exists "S:Madhouse.key2" ) (set #keyupdate 2) )
(if (exists (tackon (pathonly #gtt) "Madhouse.key2") ) (
	(set #keyupdate 2)
))
(if (exists "KEYS:Madhouse.key2"			(noreq) ) (set #keyupdate 2) )
(if (exists "KEYFILES:Madhouse.key2"	(noreq) ) (set #keyupdate 2) )
(if (exists "KEYPATH:Madhouse.key2"		(noreq) ) (set #keyupdate 2) )
(if (exists (tackon (getenv "KEYPATH") "Madhouse.key2") ) (set #keyupdate 2) )

(if (= #keyupdate 1) (
; alter Key da, aber kein neuer Key.
	(if (NOT (exists "/KeyUpdate/KeyUpdater")) (
		(exit "\n\nThis is no original distribution archive!\nCouldn't find KeyUpdater.\n")
	))
	(message #keyupdating)
	(set @execute-dir "/KeyUpdate" )
	(set #keyupresult (run ("KeyUpdater >CON:100/100/400/150/KeyUpdater-Output/CLOSE/WAIT GET %s" #keypath )))
	(if (= #keyupresult 0 ) (
		(message (#keyupokay (cat #keypath ".key2" )))
	)(
		(message #keyupfailed)
	))
))


;  **** Update von Madhouse?

(if (= #updatemode 1) (
	(message #updating)
))





;  **** Erster size-check

(set #wb-space (getdiskspace "SYS:" ))

(if (< #wb-space #size-mainprg) (
	(abort (#diskfull (expandpath "SYS:")) )
))

(complete 2)



;  **** Main-Program in SYS:WBStartup/

(complete 0)

(message #copying-mainprg )

(copyfiles
  (source #mainprgsource)
  (dest #mainprgdest)
)
(complete 10)



;  **** Icon for Main-Program

(if (= #updatemode 0) (
	; (run ("delete SYS:WBStartup/Madhouse.info"))
	(set #icontype (askchoice
			(prompt #icontext )
			(help	""	)
			(choices #iconchoices-1 #iconchoices-2 #iconchoices-3 #iconchoices-4 #iconchoices-5 #iconchoices-6 #iconchoices-7 )
			(default 5)
		)
	)
	(set #icondest "BlaBla!")
	(if (= #icontype 0) (
		(set #iconsource "/Madhouse.info")
		(set #icondest "SYS:WBStartup/Madhouse.info")
	))
	(if (= #icontype 1) (
		(set #iconsource "/Icons/Madhouse_MWB1.info")
		(set #icondest "SYS:WBStartup/Madhouse_MWB1.info")
	))
	(if (= #icontype 2) (
		(set #iconsource "/Icons/Madhouse2.info")
		(set #icondest "SYS:WBStartup/Madhouse2.info")
	))
	(if (= #icontype 3) (
		(set #iconsource "/Icons/Madhouse_MWB2.info")
		(set #icondest "SYS:WBStartup/Madhouse_MWB2.info")
	))
	(if (= #icontype 4) (
		(set #iconsource "/Icons/Madhouse3.info")
		(set #icondest "SYS:WBStartup/Madhouse3.info")
	))
	(if (= #icontype 5) (
		(set #iconsource "/Icons/Madhouse_MWB3.info")
		(set #icondest "SYS:WBStartup/Madhouse_MWB3.info")
	))
	(if (= #icontype 6) (
		(set #iconsource "/Icons/Madhouse4.info")
		(set #icondest "SYS:WBStartup/Madhouse4.info")
	))
	(copyfiles
		(source #iconsource)
		(dest "SYS:WBStartup")
		(noposition)
	)
	(run ("rename %s SYS:WBStartup/Madhouse.info" #icondest ))
))
(complete 17)



;  **** Locale

(if (> (/ (getversion) 65536) 37)
	(
		(if (<> #def-anleit 1 ) (

			(set #loc-space (getdiskspace "LOCALE:" ))
			(if (< #loc-space size-locale) (
					(message ( #diskfull-locale ))
				)(
					(set #useloc 0)
					(if (= #updatemode 1) (
						(if (exists "LOCALE:Catalogs/deutsch/madhouse.catalog") (set #useloc 1))
					)(
						(set #useloc  (askbool (prompt #use-locale)
						             (help "")
					   	          (choices #locale-1 #locale-2 )) )
					))
					(if (= #useloc 1)
					(
						;(if (exists "LOCALE:Catalogs/deutsch/madhouse.catalog") (
						;   (message (#locale-update))
						;))
						(copyfiles
						   (source "/locale/deutsch/madhouse.catalog")
						   (dest "LOCALE:Catalogs/deutsch")
						)	
						(copyfiles
						   (source "/locale/deutsch/madhousebg.catalog")
						   (dest "LOCALE:Catalogs/deutsch")
						)
					))
			))
		))
		(run "c:avail flush")
	)
)
(complete 27)


;  **** Library

(copylib
	(source "/libs/madblankersupport.library")
	(dest "Libs:")
)

(complete 30)


;  **** Set directory for docs, blankers etc...

(set #min-space (+ #size-configed #size-blankers))
(set #doc-space (+ #min-space #size-defaultdoc))

(set #loopagain 1)

(if (= #updatemode 1) (
	(set #loopagain 0)
	; #gtt schon belegt.  (s.o.)
	(if (exists #gtt) (
		(set @default-dest (pathonly #gtt))
	)(
		(set #loopagain 1)
		(message #select-defdir )
	))
)(
	(message #select-defdir )
))


(if (= #loopagain 1 ) (
	(set @default-dest
	  (askdir
	    (prompt #select-dir-prompt )
	    (help #select-dir-help )
		 (default ":")
	  )
	)
))
	

(complete 35)


;  **** Doc-Files

(working #doing-docs)

(if (= #updatemode 1) (
	; evtl. alte Anleitung löschen.
	(if (exists (tackon @default-dest "Registration_D.txt")) (
		(delete (tackon @default-dest "Registration_D.txt") )
		(delete (tackon @default-dest "Registration_D.txt.info") )
	))
	(if (exists (tackon @default-dest "Anleitung.guide")) (
		(delete (tackon @default-dest "Anleitung.guide") )
		(delete (tackon @default-dest "Anleitung.guide.info") )
	))
	(if (exists (tackon @default-dest "Registration_E.txt")) (
		(delete (tackon @default-dest "Registration_E.txt") )
		(delete (tackon @default-dest "Registration_E.txt.info") )
	))
	(if (exists (tackon @default-dest "Doc.guide")) (
		(delete (tackon @default-dest "Doc.guide") )
		(delete (tackon @default-dest "Doc.guide.info") )
	))
))


(if (= #def-anleit 1) ( 
	(copyfiles
		(source "/Docs/MadhouseE.guide" )
	   (dest @default-dest)
		(infos)
		(noposition)
	)
)(
	(copyfiles
		(source "/Docs/MadhouseD.guide" )
	   (dest @default-dest)
		(infos)
		(noposition)
	)
))



(if (= #keyupdate 0) (
; kein Keyfile installiert.

	(set #registerdest (tackon @default-dest "MadRegister"))
	(makedir #registerdest)
	(copyfiles
		(source "/MadRegister.info" )
	   (dest @default-dest)
		(infos)
		(noposition)
	)

	(if (= #def-anleit 1) ( 
		(copyfiles
			(source "/MadRegister/Registration_E.txt" )
		   (dest #registerdest)
			(infos)
			(noposition)
		)
		(copyfiles
			(source "/MadRegister/email-Register_E.info" )
		   (dest #registerdest)
			(infos)
			(noposition)
		)
	)(
		(copyfiles
			(source "/MadRegister/Registration_D.txt" )
		   (dest #registerdest)
			(infos)
			(noposition)
		)
		(copyfiles
			(source "/MadRegister/email-Register_D.info" )
		   (dest #registerdest)
			(infos)
			(noposition)
		)
	))
	
	(copyfiles
		(source "/MadRegister/KeyUpdater" )
	   (dest #registerdest)
	)
	(copyfiles
		(source "/MadRegister/emailRegister" )
	   (dest #registerdest)
	)
))
	
	


(complete 45)



;  **** MadhouseConfigEd

(message #doing-configed)
(copyfiles
   (source "/MadhouseConfigEd")
   (dest @default-dest)
)
(complete 55)



;  **** Blankers

(procedure TESTRENAMEBLANKER
(
	; Argument: #checkbl is the blanker's directory.
	
	(run ("getblankertype %s" (tackon #checkbl "gadget")))
	
	(set #blproto (getenv "getblankertype"))
	
	(if (= #blproto "Blitz" ) ( rename #checkbl (cat #checkbl "-Blitz") ))
	(if (= #blproto "Garshne" ) ( rename #checkbl (cat #checkbl "-Garshne") ))
	(if (= #blproto "Swaz" ) ( rename #checkbl (cat #checkbl "-Swaz") ))
	(if (= #blproto "Madhouse" ) (
		; old protocol
		(run ("delete %s ALL" #checkbl))
		(run ("delete %s" (cat #checkbl ".info") ))
	))
	
	(delete "ENV:getblankertype" )
))

(procedure COPYBLANKER
(
	; Argument: #copybl is the blanker's name.   ("Stars")
	;           #bl-dest is destination drawer   ("yz:xy/Blankers")

	(working ("\nCopying submitted blankers...\n%s" #copybl ))
	
	(set #bldir-dest (tackon #bl-dest #copybl))
	(makedir #bldir-dest)
	; if not already existing.

	(if (exists (tackon #bldir-dest "pref")) (
		; don't overwrite user's preferences.
		(copyfiles
			(source (tackon "/Blankers" #copybl) )
			(dest #bldir-dest)
			(help "" )
			(pattern "~(pref)")
			(optional "force" )
			(infos)
			(noposition)
		)
	)(
		(copyfiles
			(source (tackon "/Blankers" #copybl) )
			(dest #bldir-dest)
			(help "" )
			(all)
			(optional "force" )
			(infos)
			(noposition)
		)
	))
))


(message #blank )

(set #bl-dest ( tackon @default-dest "Blankers" ) )

(if (= #updatemode 0 ) (
	(makedir #bl-dest )
)(
	; new Blankers like Interference might already exist (Garshne etc.)
	
	(set #checkbl (tackon #bl-dest "Interference"))
	(TESTRENAMEBLANKER)
	
	(set #checkbl (tackon #bl-dest "Water"))
	(TESTRENAMEBLANKER)
	
))



; copy blankers.

(foreach "/Blankers" "~(#?.info|the_right_drawer)" (
	(set #copybl @each-name)
	(COPYBLANKER)
))



(copyfiles
	(source "/blankers.info" )
	(dest @default-dest )
	(help "" )
)


(if (= #updatemode 1) (
	; delete blankers which are not supported any more.
	
	(foreach #bl-dest "~(#?.info|the_right_drawer)" (
		(working ("\nSearching for old blankers...\n%s" @each-name ))
		(run ("getblankertype %s" (tackon (tackon #bl-dest @each-name) "gadget")))
		
		(set #blproto (getenv "getblankertype"))
		(if (= #blproto "Madhouse" ) (
			; old protocol
			(run ("delete %s ALL" (tackon #bl-dest @each-name)))
			(run ("delete %s" (cat (tackon #bl-dest @each-name) ".info")))	
		))
		
	))
	(delete "ENV:getblankertype")
	
))



(complete 80)



;  **** ImportHelp

(set #imphelp-dest ( tackon @default-dest "ImportHelp" ) )

(if (= #updatemode 0 ) (makedir #imphelp-dest ) )

(copyfiles
	(source "/ImportHelp")
	(dest #imphelp-dest)
	(help "" )
	(all)
	(infos)
	(noposition)
)

(complete 90)



;  **** Set ToolType for SYS:WBStartup/Madhouse

(if (= #updatemode 0) (
	(tooltype  (dest "SYS:WBStartup/Madhouse")
	           (settooltype "CONFIGED" (tackon @default-dest "MadhouseConfigEd"))
	)
))
(complete 95)


;
;  **** Extro

(if (= #updatemode 0 ) (message #extro) (message #extro-up) )


;   **** Finished!


