;
;   Chaos:		    The Chess HAppening Organisation System	V5.3
;   Copyright (C)   1993    Jochen Wiedmann
;
;   This program is free software; you can redistribute it and/or modify
;   it under the terms of the GNU General Public License as published by
;   the Free Software Foundation; either version 2 of the License, or
;   (at your option) any later version.
;
;   This program is distributed in the hope that it will be useful,
;   but WITHOUT ANY WARRANTY; without even the implied warranty of
;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;   GNU General Public License for more details.
;
;   You should have received a copy of the GNU General Public License
;   along with this program; if not, write to the Free Software
;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;   This is the Installation-script (Installer 1.24)
;   $VER: Chaos-Install 5.3 (23.03.94)
;


;
;   Printing the disclaimer
;
;============================================================================
;   English strings
(set default_lang 2)

(set #Chaos-Message (cat
    "Chaos:     The Chess HAppening Organisation System\n\n"
    "V5.3       Copyright  1993        Jochen Wiedmann\n\n"
    "This program is FREE SOFTWARE; you can redistribute "
    "it and/or modify it under the terms of the GNU General "
    "Public License as published by the Free Software "
    "Foundation; either version 2 or any later version.\n\n"
    "This program is distributed in the hope that it will be "
    "useful, but WITHOUT ANY WARRANTY! See the GNU General "
    "Public License (in the COPYING-file) for more details."
))

(set #Kickstart-Message
    "Sorry, you need Kickstart 2.04 or higher to run Chaos!"
)

(set #Ask-Bindir-Help (cat
    "We begin with installing the binary.\n\n"
    "You are asked to select a directory where this "
    "should go to. Typical choices would be C: or Work:bin "
    "for running Chaos as a CLI-command and "
    "Sys: or Tools: to install Chaos as "
    "a Workbench-application.\n\n"
    "Other parts of the program will go to different places. "
    "You will be asked for them later.\n\n\n"
))

(set #Ask-Bindir-Message "Please select a binary-directory:")

(set #Copying-binary-Message "Copying the binary...")

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-s-dir-Help (cat
    "We go on selecting a directory where the default-icon "
    "(called Chaos_Project.icon) will live.\n\n"
    "Chaos will look for it in %s or s:.\n\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-s-dir-Message
    "Please select an icon-directory\n(s: or %s recommended)"
)

(set #Copying-s-Message "Copying the default-icon...")

(set #Ask-Languages-Help (cat
    "The last thing that should be installed are the catalogs.\n\n"
    "Catalogs allow to use Chaos in different languages. "
    "Currently only German and English are possible.\n\n"
    "You are asked to select the languages that should be installed "
    "by clicking on the related buttons.\n\n\n"
))

(set #Ask-Languages-Message
    "Please select the languages that should be installed:"
)

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Cat-dir-Help (cat
    "The Catalog-files should be installed in a directory where Chaos "
    "will find them. Chaos will look into %s and Locale:Catalogs.\n\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Cat-dir-Message (cat
    "Please select a catalog-directory\n(%s or Locale:Catalogs "
    "recommended)"
))

(set #Copying-Cat-Message "Copying the Catalogs...")

(set #Set-Default-Language "Setting the icons default language...")
(set #Set-Default-Language-Help (cat
    "It is possible to use other languages than german even without the "
    "locale.library. The icon needs a tooltype LANGUAGE in that case, "
    "which i want to setup now.\n\n"
))

(set #Ask-Install-Rexx-Message "Should I install the ARexx examples?")
(set #Ask-Install-Rexx-Help (cat
    "There are some example scripts to show how to use Chaos from an ARexx "
    "program. Chaos doesn't need them, but they are probably useful for "
    "you, if you wish to add special facilities to Chaos.\n\n"
    "Please decide, if these should be installed too.\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Rexx-Dir-Message (cat
    "Please select a directory where to install the ARexx scripts. "
    "(%s or Rexx: recommended.)"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Rexx-Dir-Help (cat
    "You should select a directory for the ARexx scripts. Chaos does not "
    "know them and so any special place is possible. "
    "%s or Rexx: are recommended.\n\n"
))

(set #Copying-Rexx-Dir-Message "Copying the ARexx examples...")

;============================================================================
;   German strings
(if (= @language "deutsch")
(

(set default_lang 1)

(set #Chaos-Message (cat
    "Chaos:     The Chess HAppening Organisation System\n"
    "V5.3       Copyright  1993        Jochen Wiedmann\n\n"
    "Dieses Programm ist FREIE SOFTWARE; Sie knnen sie verndern "
    "und/oder weitergeben, sofern Sie dabei "
    "die Regeln und Bestimmungen der `GNU General Public License' "
    "(Version 2 oder eine neuere Version ihrer Wahl) beachten.\n\n"
    "Dieses Programm wird verffentlicht in der Hoffnung, da es "
    "ntzlich sein wird, aber OHNE JEDE GARANTIE! Bitte lesen Sie "
    "Details in der `GNU General Public License', die in der "
    "Datei COPYING enthalten sein mu!"
))

(set #Kickstart-Message (cat
    "Tut mir leid, aber Sie brauchen Kickstart 2.04 oder hher, "
    "um Chaos zu benutzen!"
))

(set #Ask-Bindir-Help (cat
    "Wir beginnen mit der Installation des eigentlichen Programms.\n\n"
    "Sie sollten ein Directory auswhlen, wohin dieses kopiert wird, "
    "z.B. C: oder Work:bin, um Chaos als CLI-Programm zu installieren "
    "oder Sys: oder Work: um Chaos auf der Workbench zu installieren.\n\n"
    "Andere Teile des Programms werden in andere Directories kopiert, "
    "die Sie spter bestimmen knnen.\n\n\n"
))

(set #Ask-Bindir-Message
    "Bitte whlen Sie ein Directory fr das eigentliche Programm."
)

(set #Copying-binary-Message "Kopieren des Programms...")

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-s-dir-Help (cat
    "Wir machen mit der Installation des Vorgabe-Icons weiter. "
    "Dieses wird in der Datei Chaos_Project.icon enthalten sein.\n\n"
    "Chaos sucht danach in den Directories %s oder s:.\n\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-s-dir-Message (cat
    "Bitte whlen Sie ein Directory fr das Vorgabeicon\n(%s oder s: "
    "werden empfohlen)"
))

(set #Copying-s-Message "Kopieren des Vorgabe-Icons...")

(set #Ask-Languages-Help (cat
    "Als letztes installieren wir die Catalog-Dateien, die es "
    "erlauben, Chaos in verschiedenen Sprachen zu benutzen. "
    "Zur Zeit sind leider nur Deutsch und Englisch mglich.\n\n"
    "Sie sollten die gewnschten Sprachen durch Anklicken der "
    "entsprechenden Gadgets anklicken.\n\n\n"
))

(set #Ask-Languages-Message
    "Bitte whlen Sie die Sprachen aus, die installiert werden sollen:"
)

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Cat-dir-Help (cat
    "Die Catalogs mssen in einem Directory installiert werden, wo sie "
    "von Chaos gesucht werden. Chaos wird in %s und Locale:Catalogs "
    "danach suchen.\n\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Cat-dir-Message (cat
    "Bitte whlen Sie ein Directory fr die Catalogs\n(%s oder "
    "Locale:Catalogs werden empfohlen)"
))

(set #Copying-Cat-Message "Kopieren der Catalogs...")

(set #Set-Default-Language "Setzen der Vorgabesprache im Icon...")
(set #Set-Default-Language-Help (cat
    "Selbst ohne die locale.library ist es mglich, andere Sprachen als "
    "Englisch zu benutzen. In diesem Fall mu allerdings der Tooltyp "
    "LANGUAGE im Icon gesetzt werden, was ich jetzt tun will.\n\n"
))

(set #Ask-Install-Rexx-Message
    "Soll ich auch die ARexx-Beispiele installieren?"
)
(set #Ask-Install-Rexx-Help (cat
    "Es gibt einige Beispielskripte, die die Benutzung von Chaos aus "
    "einem ARexx-Programm dokumentieren. Chaos bentigt diese Skripts "
    "nicht, aber sie knnten ntzlich sein, falls Sie einmal selbst "
    "zustzliche Mglichkeiten in Chaos einbauen mchten.\n\n"
    "Bitte entscheiden Sie, ob ich diese Skriptdateien ebenfalls "
    "installieren soll.\n\n"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Rexx-Dir-Message (cat
    "Bitte whlen Sie ein Directory, in dem ich die ARexx-Skripte "
    "installieren soll. (Ich empfehle %s oder Rexx:)"
))

;   The following must contain a '%s' which will receive a directory-name
(set #Ask-Rexx-Dir-Help (cat
    "Sie sollten ein Directory whlen, in das die ARexx-Skripte kopiert "
    "werden. Chaos bentzt diese nicht, jedes Directory ist deshalb "
    "mglich. blich sind %s oder Rexx:\n\n"
))

(set #Copying-Rexx-Dir-Message "Kopieren der ARexx-Beispiele...")

))
;============================================================================
;   Welcome the User
;
(user 1)
(welcome)
(set old_level @user-level)
(user 2)
(message #Chaos-Message)
(user old_level)


;============================================================================
;   Check the Kickstart-version and abort if we are running V36 or lower.
;
(set ver (/ (getversion "exec.library" (resident)) 65536))
(if (< ver 37)
(   (abort #Kickstart-Message)
))


;============================================================================
;   Select a directory for the binary
;
(set destdir "c:")
(if  (= @user-level 1)
(   (set destdir (askdir
	(prompt #Ask-Bindir-Message)
	(help #Ask-Bindir-Help @askdir-help)
	(default destdir)
    ))
))


;============================================================================
;   Copy the binary
;
(set destdir (copyfiles
    (prompt #Copying-binary-Message)
    (help #Ask-Bindir-Help @copyfiles-help)
    (source "")
    (dest destdir)
    (choices "Chaos" "Chaos.info")
    (confirm 1)
))
(set @default-dest destdir)


;============================================================================
;   Select a directory where the default-icon will go to.
;
(set sdestdir (tackon destdir "s"))
(if (< @user-level 2)
(   (set sdestdir (askdir
	(prompt (#Ask-s-dir-Message sdestdir))
	(help (cat (#Ask-s-dir-Help sdestdir) @askdir-help))
	(default (select @user-level "s:" sdestdir))
	(newpath)
    ))
))


;============================================================================
;   Copy the default-icon
;
(copyfiles
    (prompt #Copying-s-Message)
    (help (#Ask-s-dir-Help sdestdir) @copyfiles-help)
    (source "s")
    (dest sdestdir)
    (all)
    (confirm)
)


;============================================================================
;   Ask, if the ARexx scripts should be installed too.
;
(user 2)
(set installARexx (askbool
    (prompt #Ask-Install-Rexx-Message)
    (help #Ask-Install-Rexx-Help)
))


;============================================================================
;   Select a directory where the Arexx scripts will go to.
;
(if (= installARexx 1)
(   (set ARexxdestdir (tackon destdir "Rexx"))
    (set ARexxdestdir (askdir
	(prompt (#Ask-Rexx-Dir-Message ))
	(help (cat (#Ask-Rexx-Dir-Help ARexxdestdir) @askdir-help))
	(default (select old_level "Rexx:" ARexxdestdir ARexxdestdir))
	(newpath)
    ))
))
(user old_level)


;============================================================================
;   Copy the ARexx scripts
;
(if (= installARexx 1)
(   (copyfiles
	(prompt #Copying-Rexx-Dir-Message)
	(help (#Ask-Rexx-Dir-Help ARexxdestdir) @copyfiles-help)
	(source "Rexx")
	(dest ARexxdestdir)
	(all)
	(confirm)
    )
))


;============================================================================
;   Check for locale.library
;
(set catdestdir_is_set (NOT @user-level))
(set catdestdir "Locale:Catalogs")
(if (AND  (NOT (exists "Locale:"))  (NOT @user-level))
(   (set catdestdir "Catalogs")
))


;============================================================================
;   Install the catalogs
;
(user 2)
(set languages (askoptions
    (prompt #Ask-Languages-Message)
    (help #Ask-Languages-Help @askoptions-help)
    (choices "Deutsch" "English")
    (default default_lang)
))
(user old_level)

(set n 0)
(while (set thislanguage (select n "Deutsch" "English" ""))
(   (if (AND (<> n 1) (BITAND languages (shiftleft 1 n)))
    (   (if (NOT catdestdir_is_set)
	(   (set catdestdir (tackon destdir "Catalogs"))
	    (if (= 1 @user-level)
	    (   (set catdestdir (askdir
		    (prompt (#Ask-Cat-dir-Message catdestdir))
		    (help (#Ask-Cat-dir-Help catdestdir) @askdir-help)
		    (default catdestdir)
		    (newpath)
		))
	    ))
	    (set catdestdir_is_set 1)
	))

	(if (<> (exists catdestdir) 2)
	(   (makedir catdestdir)
	))
	(set catdestdir (pathonly (copyfiles
	    (prompt #Copying-Cat-Message)
	    (help (#Ask-Cat-dir-help (tackon destdir "Catalogs"))
		   @copyfiles-help)
	    (source (tackon "Catalogs" thislanguage))
	    (dest (tackon catdestdir thislanguage))
	    (all)
	    (confirm)
	)))
	(if (AND (= (+ n 1) default_lang) (= ver 37))
	(   (if (<> default_lang 2)
	    (   (tooltype
		    (prompt #Set-Default-Language)
		    (help #Set-Default-Language-Help)
		    (setstack 20000)
		    (noposition)
		    (dest (tackon destdir "Chaos.info"))
		    (settooltype "(This is the default icon's path.)")
		    (settooltype "(s: will be searched additionally.)")
		    (settooltype (cat "(DEFICON=" @sdestdir ")"))
		    (settooltype "(This suppresses creation of icons.)")
		    (settooltype "(NOICONS)")
		    (settooltype "(This is for workbench 2.0 only!)")
		    (settooltype "(Not needed if language is english.)")
		    (settooltype (cat "LANGUAGE=" @language))
		)
	    ))
	))
    ))
    (set n (+ n 1))
))
