
(set @default-dest (expandpath ""))

;--------------------------- Englische Texte ----------------------------

(set #modeprompt "Would you like to install or deinstall?")
(set #mode0 "Deinstall")
(set #mode1 "Install")
(set #modehelp (cat "\nYeah, right.  There aren't many installation scripts "
        "that can do both, are there? ;-)") )
(set #ioptionprompt "What parts of the installation do you want to perform?")
(set #ioption0 "install i2c.library")
(set #ioption1 "install teletext fonts")
(set #ioption2 "reset some of \"VideoText\"'s ToolTypes")
(set #ioption3 "install WordWrap")
(set #ioption4 "install VTType")
(set #ioption5 "permanently assign \"WNVT:\"")
(set #ioptionhelp (cat "\nBoth i2c.library and the teletext fonts are "
        "required, so if you are running this script for the first time, "
        "you should select those options ON.\n\n"
        "Resetting ToolTypes will clear the SCREENMODE and HOMEDIR "
        "settings, will let you make choices about PALETTE and color "
        "arrangement (COLPERM), and "
        "will let you specify BUSDELAY and an external text EDITOR.\n\n"
        "WordWrap can reformat ASCII texts.  You need it if you want to "
        "run the \"WidePrint\" ARexx script.  VTType is a CLI utility for "
        "quickly converting teletext pages from binary to ASCII format.\n\n"
        "The \"WNVT:\" assign is only needed for teletext projects that "
        "have \"WNVT:VideoText\" as their default tool."
        ) )
(set #uoptionprompt "What parts of the installation do you want to undo?")
(set #uoption0 "remove i2c.library")
(set #uoption1 "remove teletext fonts")
(set #uoption2 "remove WordWrap")
(set #uoption3 "remove VTType")
(set #uoption4 "remove the \"WNVT:\" assignment")
(set #uoptionhelp (cat "\nYou might want to keep the i2c.library, if you "
        "have applications other than \"VideoText\" that still need it.  "
        "Jan Leuverink's TeleText 1.21, for example, does.\n\n"
        "You might also want to keep WordWrap, which is a general purpose "
        "utility for reformatting ASCII texts.\n\n"
        "However, it's safe to get rid of all the other stuff, the "
        "teletext fonts (actually called 'videotext') in particular.") )
(set #hwchoiceprompt "Pick your type of I²C interface:")
(set #hwchoice0 "serial port, as proposed by \"c't\" magazine")
(set #hwchoice1 "serial port, Wiegand VTX 2000 hardware")
(set #hwchoice2 "serial port, HSL VideoTXT hardware")
(set #hwchoice3 "serial port, KDK Satcom PC-Videotext")
(set #hwchoice4 "parallel port, as proposed by Jan Leuverink")
(set #hwchoice5 "parallel port, Printtechnik hardware")
(set #hwchoice6 "parallel port, Microtext hardware")
(set #hwchoice7 "autoconfig board, M&T TeleTxt")
(set #hwchoice8 "floppy port")
(set #hwchoicehelp (cat "\nDepending on the kind of interface hardware you "
        "own, I will install one of several customized i2c.library "
        "versions.\n\n"
        "If you picked the wrong library and now want to try another, "
        "note that the old library might still be resident in memory, so "
        "the new one won't be loaded until you reboot your system.  "
        "I will try to remove the current library from memory, but this may "
        "fail (e.g. if an application has this library still open).") )
(set #edprompt "Pick your favourite text editor:")
(set #edhelp (cat "\n\"VideoText\" relies on an external text editor "
        "to let you create and/or modify page presets files.\n\n"
        "This editor should be able to insert text from the Clipboard, "
        "and it should be quick to start.\n\n"
        "In case of doubt, 'c:Ed' is perfectly OK to use.") )
(set #delayprompt "I²C bus delay parameter:")
(set #delayhelp (cat "\nToo little delay will disable the I²C "
        "bus, too much will degrade its throughput.\n\n"
        "The given default value is just a good guess, judging from "
        "the chipset installed in your system (ECS or AGA), and might "
        "be wrong.  So in case you have already determined a good delay "
        "value for your system using \"I2Cscan\", don't hesitate to "
        "enter it here.") )
(set #visualprompt "Visual appearance of the \"VideoText\" screen:")
(set #voption0 "softer colours")
(set #voption1 "black background")
(set #visualhelp (cat "\nI'd say it's a bad idea to activate neither of "
        "these options, but go ahead, try and see what you like best.") )
(set #startupprompt (cat "Click 'Proceed' to have \"WNVT:\" permanently "
        "assigned.  (Yes, I know, you have already confirmed that, but "
        "the Installer is a bit stubborn about such things.)" ) )
(set #startup2prompt (cat "Please click 'Proceed' to once more confirm "
        "the needed modifications to 'user-startup' (removal of the "
        "\"WNVT:\" assignment):") )
(set #uifarewell "Deinstallation complete!")

;--------------------------- Deutsche Texte -----------------------------

(if (= @language "deutsch") (
(set #modeprompt (cat "Möchten Sie die Installation ausführen oder "
        "rückgängig machen?") )
(set #mode0 "Deinstallieren")
(set #mode1 "Installieren")
(set #modehelp (cat "\nDas ist doch nett, oder? Ich habe sogar an die "
        "gedacht, die mein Programm nicht leiden können! ;-)") )
(set #ioptionprompt "Welche Teile der Installation wollen Sie durchführen?")
(set #ioption0 "I²C-Library installieren")
(set #ioption1 "Videotext Fonts installieren")
(set #ioption2 "einige der Programm-Merkmale zurücksetzen")
(set #ioption3 "WordWrap installieren")
(set #ioption4 "VTType installieren")
(set #ioption5 "ein permanentes Assign \"WNVT:\" einrichten")
(set #ioptionhelp (cat "\nSie benötigen sowohl die Fonts als auch die "
        "Library. Wenn Sie dieses Skript zum ersten Mal ausführen, "
        "sollten Sie also beide Optionen EINschalten.\n\n"
        "Beim Zurücksetzen von Programm-Merkmalen (ToolTypes) werden die "
        "Einträge zu SCREENMODE und HOMEDIR gelöscht, Sie können ein paar "
        "Details zu PALETTE und Farbreihenfolge (COLPERM) auswählen, und "
        "Sie dürfen den BUSDELAY-Parameter sowie einen externen EDITOR für "
        "die Vorauswahl-Dateien festlegen.\n\n"
        "WordWrap kann ASCII-Texte umformatieren. Es wird für das "
        "mitgelieferte \"WidePrint\" ARexx-Script benötigt. VTType ist "
        "ein CLI-Utility, das VT-Seiten aus Binärdateien als ASCII "
        "anzeigt.\n\n"
        "Das \"WNVT:\"-Assign ist empfehlenswert, um ein schnelles "
        "Anzeigen von VT-Seitendateien mit dem Standardprogramm "
        "\"WNVT:VideoText\" zu ermöglichen."
        ) )
(set #uoptionprompt (cat "Wie weit soll die Installation rückgängig "
        "gemacht werden?") )
(set #uoption0 "I²C-Library entfernen")
(set #uoption1 "Videotext Fonts entfernen")
(set #uoption2 "WordWrap entfernen")
(set #uoption3 "VTType entfernen")
(set #uoption4 "das \"WNVT:\"-Assign aufheben")
(set #uoptionhelp (cat "\nEs könnte sein, daß Sie die i2c.library behalten "
        "wollen, falls Sie nämlich noch andere Anwendungen außer "
        "\"VideoText\" haben, die diese Library benutzen. Das träfe "
        "z. B. auf Jan Leuverink's TeleText 1.21 zu.\n\n"
        "Ebenso könnten Sie WordWrap behalten wollen, den vielseitigen "
        "ASCII-Textformatierer, der auch als "
        "eigenständiges CLI-Tool noch sehr nützlich ist.\n\n"
        "Was aber den restlichen Kram angeht, insbesondere die "
        "Videotext-Fonts: weg damit, braucht keiner mehr.") )
(set #hwchoiceprompt "Was für ein I²C-Bus-Interface verwenden Sie?")
(set #hwchoice0 "wie in der \"c't\" empfohlen, am RS232-Port")
(set #hwchoice1 "Wiegand VTX 2000, am RS232-Port")
(set #hwchoice2 "HSL VideoTXT, am RS232-Port")
(set #hwchoice3 "KDK Satcom PC-Videotext, am RS232-Port")
(set #hwchoice4 "Jan Leuverinks TT120, am Parallelport")
(set #hwchoice5 "Printtechnik Hardware, am Parallelport")
(set #hwchoice6 "Microtext, am Parallelport")
(set #hwchoice7 "die Markt & Technik TeleTxt-Karte")
(set #hwchoice8 "Interface am Floppy-Port")
(set #hwchoicehelp (cat "\nJe nachdem, was für Interface-Hardware Sie "
        "besitzen, wird eine von mehreren speziell angepassten Varianten "
        "der i2c.library installiert.\n\n"
        "Falls Sie beim ersten Versuch einen falschen Hardware-Typ "
        "angegeben hatten und die Installation darum jetzt wiederholen: "
        "Beachten Sie, daß die zuletzt installierte Library noch resident "
        "im Speicher sein könnte, so daß eine Änderung erst nach Neustart "
        "des Systems bemerkbar würde.  "
        "Ich werde zwar versuchen, die zuletzt installierte Library aus "
        "dem Speicher zu entfernen, das kann aber fehlschlagen (z. B. weil "
        "ein Anwendungsprogramm noch mit dieser Library arbeitet).") )
(set #edprompt "Geben Sie Ihren bevorzugten Texteditor an:")
(set #edhelp (cat "\n\"VideoText\" benutzt einen externen Texteditor "
        "zum Erzeugen und Bearbeiten der Seitenvorauswahl-Dateien. "
        "Dieser Editor sollte Texte aus der Zwischenablage (Clipboard) "
        "einfügen können, und er sollte sich schnell starten lassen.\n\n"
        "Wenn Sie sich unsicher sind: 'c:Ed' ist auf jeden Fall "
        "geeignet.") )
(set #delayprompt "Timing-Parameter für den I²C-Bus:")
(set #delayhelp (cat "\nEin zu kleiner Timing-Parameter macht den I²C-Bus "
        "unbrauchbar, ein zu großer führt lediglich zu "
        "Leistungseinbußen.\n\n"
        "Der vorgeschlagene Wert ist nur eine Vermutung, die auf Analyse "
        "des installierten Chipsatzes (ECS oder AGA) basiert, und kann "
        "schlichtweg falsch sein. Sollten Sie mit Hilfe des "
        "\"I2Cscan\"-Programmes bereits einen "
        "für Ihr System optimalen Timing-Wert ermittelt haben, zögern "
        "Sie nicht, ihn hier einzutragen.") )
(set #visualprompt "Gesamteindruck des \"VideoText\"-Screens:")
(set #voption0 "gedämpftere Farben")
(set #voption1 "schwarzer Hintergrund")
(set #visualhelp (cat "\nMeiner Meinung nach sollten Sie mindestens eine "
        "dieser Optionen auswählen, aber das ist letztendlich reine "
        "Geschmackssache.") )
(set #startupprompt (cat "Klicken Sie bitte 'Weiter', um das permanente "
        "Assign \"WNVT:\" einzurichten. (Ich weiß, das hatten Sie bereits "
        "bestätigt, aber der Installer ist in solchen Dingen leider "
        "etwas starrsinnig.)") )
(set #startup2prompt (cat "Die Änderungen an 'user-startup' (zur Aufhebung "
        "des \"WNVT:\"-Assigns) müssen Sie leider nochmal mit 'Weiter' "
        "bestätigen:") )
(set #uifarewell "Deinstallation abgeschlossen!")
) )

;--------------------- Vorgaben für die Rückfragen ----------------------

(set #doinstall 1)      ; Installieren, nicht Deinstallieren
(set #instmode %101111)       ; alles außer VTType
(set #uinstmode %11010)       ; alles außer WordWrap und i2c.library
(set #hwtype 0)         ; c't-Hardware
(set #editor "c:Ed")
(if (patmatch "(ECS|AGNUS)" (database "chiprev"))
  (set #busdelay 0)
;else
  (set #busdelay 4)
)
(set #visual 1)         ; gedämpfte Farben, aber kein schwarzer H'grund
(set #palette "000,f00,0f0,ff0,00f,f0f,0ff,fff")
(set #colperm "60712345")

;------------------------------ Rückfragen ------------------------------

(if (= @user-level 2)
  (set #doinstall
    (askchoice
      (prompt #modeprompt)
      (help #modehelp)
      (choices #mode0 #mode1)
      (default #doinstall)
    )
  )
)

(if #doinstall (
  (if (= @user-level 2)
    (set #instmode
      (askoptions
        (prompt #ioptionprompt)
        (help #ioptionhelp)
        (choices #ioption0 #ioption1 #ioption2 #ioption3 #ioption4 #ioption5)
        (default #instmode)
      )
    )
  )
  (set #uinstmode 0)
) ( ; "else", d. h. NOT #doinstall:
  (set #uinstmode
    (askoptions
      (prompt #uoptionprompt)
      (help #uoptionhelp)
      (choices #uoption0 #uoption1 #uoption2 #uoption3 #uoption4)
      (default #uinstmode)
    )
  )
  (set #instmode 0)
) )

(if (BITAND 1 #instmode)
  (set #hwtype
    (askchoice
      (prompt #hwchoiceprompt)
      (help #hwchoicehelp)
      (choices #hwchoice0 #hwchoice1 #hwchoice2 #hwchoice3 #hwchoice4
               #hwchoice5 #hwchoice6 #hwchoice7 #hwchoice8 )
      (default #hwtype)
    )
  )
)

(if (AND (BITAND 4 #instmode) (= @user-level 2))
  (
    (set #editor
      (askfile
        (prompt #edprompt)
        (help #edhelp)
        (default (expandpath #editor))
        ; einfach '(default #editor)' bringt einen seltsamen Bug ...
      )
    )
    (set #busdelay
      (asknumber
        (prompt #delayprompt)
        (help #delayhelp)
        (range 0 100)
        (default #busdelay)
      )
    )
    (set #visual
      (askoptions
        (prompt #visualprompt)
        (help #visualhelp)
        (choices #voption0 #voption1)
        (default #visual)
      )
    )
    (if (BITAND 1 #visual)
      (set #palette "000,d00,0d0,ee0,00d,909,0cc,fff")
    )
    (if (BITAND 2 #visual)
      (set #colperm "06741235")
    )
  )
)

;----------------------------- Installation -----------------------------

(if (BITAND 1 #instmode) (
  (select #hwtype
    (copyfiles
      (source "libs/i2c.library.ser")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.ser2")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.ser3")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.ser4")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.par")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.par2")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.par3")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.card")
      (dest "LIBS:")
      (newname "i2c.library")
    )
    (copyfiles
      (source "libs/i2c.library.disk")
      (dest "LIBS:")
      (newname "i2c.library")
    )
  )
  (run "Avail FLUSH >NIL:")
) )

(if (BITAND 2 #instmode)
  (copyfiles
    (source "fonts/")
    (pattern "~(#?.info)")
    (dest "FONTS:")
  )
)

(if (BITAND 4 #instmode)
  (tooltype
    (dest "VideoText")
    (settooltype "SCREENMODE")    ; ToolType löschen
    (settooltype "HOMEDIR")
    (settooltype "PALETTE" #palette)
    (settooltype "COLPERM" #colperm)
    (settooltype "EDITOR" #editor)
    (settooltype "BUSDELAY" (cat #busdelay))
  )
)

(if (BITAND 8 #instmode)
  (copyfiles
    (source "c/WordWrap")
    (dest "C:")
  )
)

(if (BITAND 16 #instmode)
  (copyfiles
    (source "c/VTType")
    (dest "C:")
  )
)

(if (BITAND 32 #instmode) (
  (makeassign "WNVT" @default-dest)
  (startup "VideoText"
    (prompt #startupprompt)
    (help "\n" @startup-help)
    (command (cat "Assign WNVT: \"" @default-dest "\"\n"))
  )
) )

;---------------------------- Deinstallation ----------------------------

(if (BITAND 1 #uinstmode)
  (delete "LIBS:i2c.library")
)

(if (BITAND 2 #uinstmode)
  (
    (delete "FONTS:videotext.font")
    (delete "FONTS:videotext/9")
    (delete "FONTS:videotext/15")
    (delete "FONTS:videotext")
  )
)

(if (BITAND 4 #uinstmode)
  (delete "C:WordWrap")
)

(if (BITAND 8 #uinstmode)
  (delete "C:VTType")
)

(if (BITAND 16 #uinstmode)
  (startup "VideoText"
    (prompt #startup2prompt)
    (help "\n" @startup-help)
  )
)

(if (NOT #doinstall) (
  (message #uifarewell)
  (exit (quiet))
) )

