; $VER: "IDEfix-CD32-Emulator-Support-Guide" - Installer script V1.02 (03. 12. 1997)
; By Thomas Rehbein

(if (= @language "deutsch")
  (set #loc 1)
 (set #loc 0)
)

(set #ag-default "SYS:C")
(set #mv-default "SYS:Utilities")

(if (= #loc 1)
  (set #guide-name "IDEfixCD32Emul.deu.guide")
 (set #guide-name "IDEfixCD32Emul.eng.guide")
)
(set #guidestd-name "IDEfixCD32Emul.guide")
(set #readme-name "IDEfixCD32Guid.readme")
(set #installd-name "IDEfixCD32Guide-InstDisk")

(set #reqch-path "SYS:C/RequestChoice")
(set #reqchold-path "SYS:C/RequestChoiceOld.bak")

(set #startup-path "SYS:S/StartUp-Sequence")

(set #newstartup-dest "SYS:S/IDEfixCD32Guide-StartUp")

(set #reqchold-text "\"RequestChoiceOld.bak\"")
(set #execom-text "\"Execute S:IDEfixCD32Guide-StartUp\"")
(set #newstartup-text "\"IDEfixCD32Guide-StartUp\"")

; ========================================================================

(if (= #loc 1)
  (
   (set #no-help " Hier ist keine Hilfe vorhanden.")

   (set #oldvexists-text
     (cat "\n\nHast Du auf Deinem Rechner momentan auch"
          " den "@app-name" V1.01 (Erste öffentlich Version) installiert?"
     )
   )

   (set #deloldv-text
     (cat "\n\nHierbei handelt es sich um eine etwas erweiterte und"
          " veränderte Version. Ich schlage vor, die alte Version"
          " zu löschen. Stimmst Du zu?\n\n"
          "(Siehe Hilfe für mehr Infos!)"
     )
   )

   (set #deloldv-help
     (cat " Die alte Version wird nicht mehr benötigt. Beim Installieren"
          " dieser neuen Version kann es vorkommen, dass Teile der alten"
          " Version auf dem Datenträger verbleiben, was nicht unbedingt"
          " erwünscht ist, nicht wahr?\n\n Wenn Du zustimmst, wird das Skript"
          " abgebrochen. Du solltest dann im \"ReadMe\" nachschauen,"
          " welche Dateien bei der Deinstallation gelöscht werden müssen."
          " Diese Dateien sollten dann auch gelöscht werden. :-)\n\n"
          " Wenn Dir die alte Version (bzw. Teile davon)"
          " nichts ausmacht, kann auch ruhig mit dem Skript fortgefahren"
          " werden."
     )
   )

   (set #goon-text "\n\nOkay, weiter geht's... :-)")

   (set #welcome-text
     (cat "\n\nHiermit wird der "@app-name" V1.02 (03. 12. 1997)"
          " installiert.\n\nEs besteht nun gleich die Möglichkeit,"
          " Anzeigeprogramm(e) und Zielverzeichnis zu wählen!"
     )
   )

   (set #agandmv-text
     (cat "\n\nBesitzt Du sowohl den Guide-Viewer \"AmigaGuide\" als"
          " auch \"MultiView\"?"
     )
   )

   (set #agandmv-help
     (cat " Wenn Du 'glücklicher' Besitzer beider Programme bist, kann"
          " eventuell die Benutzerfreundlichkeit beim Booten erhöht"
          " werden (Mehr dazu gleich!)."
     )
   )

   (set #gno-text
     (cat "\nDu hast die Möglichkeit, zwischen 2 Varianten zu wählen,"
          " die sich mehr oder weniger auf die Benutzerfreundlichkeit"
          " beim Booten auswirken:\n"
     )
   )

   (set #gno-help
     (cat " Das ist eine reine Geschmacksfrage! ;-)\n\n"
          " Wenn Du es magst, dass Du Dich beim Booten zwischen den beiden"
          " Guide-Viewern entscheiden kannst, wähle die 1. Variante"
          " (Du hast übrigens nicht nur die Möglichkeit, zwischen"
          " beiden Viewern zu wählen, sondern auch gar keinen zu wählen"
          " und damit den "@app-name" erst gar nicht"
          " anzeigen zu lassen!)!\n\n"
          " Wenn Du davon nichts hälst und lieber einen 'festen',"
          " permanenten Viewer bevorzugst, wähle Variante 2!"
     )
   )

   (set #which-text "\n\nWie heisst Dein Guide-Viewer?")

   (set #viewerpath-text
     (cat "Bitte wähle nun den kompletten Pfad für"
          " Dein Anzeigeprogramm "
     )
   )

   (set #destdir-text
     (cat "Bitte wähle das Zielverzeichnis für"
          " den "@app-name" aus!"
     )
   )

   (set #destdir-help
     (cat " Um den Überblick zu behalten, sollte für den Guide ein"
          " separates Verzeichnis angelegt werden. Diese Vorgehensweise"
          " vereinfacht außerdem eine eventuelle Deinstallation des Guides,"
          " die zu diesem Zeitpunkt noch manuell durchgeführt werden"
          " müsste!\n\nBeispiel-Verzeichnis: \"SYS:S/IDEfixCD32Guide\".\n\n"
          "Es wird dringend empfohlen, solch ein Verzeichnis"
          " einzurichten!\n\n"
     )
   )

   (set #reqchinst-text
     (cat "\n\nNun wird \"RequestChoice\" (V40.2) ins \"C\"-Verzeichnis"
          " installiert. Dies ist wichtig, wenn Du vorhin beide Viewer"
          " und die 'Auswahlmöglichkeit' gewählt hast. Aber auch, wenn dies"
          " nicht zutreffen sollte, ist die neue Version sicherlich nichts"
          " Schlechtes. :D\n\nBemerkungen:\n"
          " Eine eventuell ältere Version wird in"
          " "#reqchold-text" umbenannt.\nEinige kleine Texte zur neuen"
          " Version werden ebenfalls 'installiert', welche man nicht"
          " ignorieren sollte! :-)"
     )
   )

   (set #reqchok-text
     (cat "\n\nDu warst anscheinend schneller als ich! ;-)"
          " Du hast bereits die neue Version von \"RequestChoice\""
          " installiert!\n\nHerzlichen Glückwunsch! 0=)"
     )
   )

   (set #editseq-text
     (cat "\nDamit der Guide kurz vor dem Start des CD32-Emulators"
          " aufgerufen werden kann, muss in die StartUp-Sequence"
          " folgende Zeile eingefügt werden\n(Direkt vor dem Pfad"
          " Deines CD32-Emulators):\n\n"#execom-text"\n\n"
          "Möchtest Du die StartUp-Sequence jetzt gleich"
          " oder erst später MANUELL ändern?\n\n"
          "(Siehe Hilfe für mehr Informationen!)"
     )
   )

   (set #editseq-help
     (cat " In diese neue StartUp-Sequence mit dem"
          " Namen "#newstartup-text", welche durch den"
          " \"Execute\"-Befehl ausgeführt wird, werden alle"
          " für den Aufruf des "@app-name"s"
          " wichtigen Befehle hineingeschrieben!\n\n Wähle \"Jetzt\","
          " um die StartUp-Sequence jetzt gleich zu editieren!"
          " Dafür wird dann der Editor \"Ed\" benutzt. Falls sich"
          " dieser nicht im \"SYS:C\"-Verzeichnis befindet, kannst Du "
          " den richtigen Pfad wählen oder aber Dir einen ganz anderen"
          " Texteditor aussuchen!\n\n Wählst Du \"Später\", muss"
          " die StartUp-Sequence nach der Installation geändert werden!"
     )
   )

   (set #editseqok-text
     (cat "\n\nFolgende Zeile muss eingefügt werden (Direkt vor dem"
          " Pfad Deines CD32-Emulators):\n\n"#execom-text"\n\n"
          "Alles klar? Auf geht's... ;-)"
     )
   )

   (set #badtexted-text
     (cat "Konnte den Editor \"Ed\" nicht im \"SYS:C\"-Verzeichnis"
          " finden! Bitte wähle jetzt einen geeigneten Texteditor aus!"
     )
   )

   (set #notexted-text
     (cat "\n\nDu hast leider überhaupt keine Datei ausgewählt!\n\n"
          "Bitte ändere die StartUp-Sequence nach der Installation!"
     )
   )

   (set #nicehint-text
     (cat "\nKleiner Hinweis zum Schluss\n"
          "---------------------------\n\n"
          "Du kannst statt "#execom-text" auch folgende Variante"
          " benutzen:\n\n\"Run >NIL: Execute S:IDEfixCD32Guide-StartUp\"\n\n"
          "Nachdem Du die 'normale' Variante getestet hast,"
          " kannst Du ja mal diese ausprobieren und schauen,"
          " was passiert!\nVielleicht gefällt es Dir besser... ;-)"
     )
   )

   (set #exitremind-text
     (cat "\n\nBitte vergiss nicht, in die StartUp-Sequence"
          " die Zeile\n"#execom-text"\n"
          "direkt vor dem Pfad Deines CD32-Emulators einzufügen!"
     )
   )

   (set #exit-text
     (cat "\n\nUnd jetzt viel Spaß mit dem Guide wünscht Dir\n\n"
          "Thomas Rehbein\n<Tommy@SpyBox.shnet.org>! ;-)"
     )
   )
  )

; ------------------------------------------------------------------------

 (
  (set #no-help " Sorry, no help available.")

  (set #oldvexists-text
    (cat "\n\nDid you already install the "@app-name" V1.01"
         " (First public release) on your system?"
    )
  )

  (set #deloldv-text
    (cat "\n\nThis is a new version that has been extended. It differs"
         " from the old one, especially with reference to file names."
         " I suggest that you remove the old version. Do you agree?\n\n"
         "(See Help for more information!)"
    )
  )

  (set #deloldv-help
    (cat " The old version is no more necessary. After installation of this"
         " new version parts of the old version might still be on your"
         " disk. I think you don't want that, don't you?\n\n If you agree"
         " the script will be aborted. By looking into"
         " the \"ReadMe\" you should find out which files have to be"
         " deleted on deinstallation. These files should be"
         " removed. :-)\n\n If you think the described situation"
         " doesn't matter you can go on with the installation."
    )
  )

  (set #goon-text "\n\nOkay, let's go on... :-)")

  (set #welcome-text
    (cat "\n\nThis script will install the "@app-name" V1.02"
         " (03. 12. 1997).\n\nNext you can choose your guide viewer(s)"
         " and your destination directory!"
    )
  )

  (set #agandmv-text "\n\nDo you have both \"AmigaGuide\" and \"MultiView\"?")

  (set #agandmv-help
    (cat " If you have both programs the comfortability on bootup can be"
         " improved (More information follow!)."
    )
  )

  (set #gno-text
    (cat "\nNow you can choose between 2 variants that will influence"
         " the comfortability on bootup:\n"
    )
  )

  (set #gno-help
    (cat " It's just a 'matter of taste'! ;-)\n\n"
         " If you like the idea to be able to choose between the two"
         " guide viewers, select the 1st variant"
         " (Note that you also have the possibility to select none of the"
         " guide viewers. In that case the "@app-name" wouldn't be"
         " shown!)!\n\n"
         " If you prefer using one permanent viewer select variant 2!"
    )
  )

  (set #which-text "\n\nWhich is your guide viewer?")

  (set #viewerpath-text
    (cat "Please select the complete path of your guide viewer ")
  )

  (set #destdir-text
    (cat "Select the destination directory for the "@app-name"!")
  )

  (set #destdir-help
    (cat " You should create a separate directory for the guide,"
         " otherwise you might lose control due to a great amount"
         " of files in different directories (E. g. the"
         " \"S\"-directory)! Besides, in this way a possible"
         " deinstallation of the guide that you would have to make"
         " manually will be easier.\n\nExample drawer:"
         " \"SYS:S/IDEfixCD32Guide\".\n\nIt is highly"
         " recommended to use such a directory!\n\n"
    )
  )


  (set #reqchinst-text
    (cat "\n\nNow \"RequestChoice\" (V40.2) will be copied into"
         " the \"C\"-directory. This is significant if you have selected"
         " both viewers and the 'Choice' option. However, if you don't"
         " have done so it's surely not bad to install the newest"
         " version. :D\n\nNote:\nAn older version will be renamed"
         " to "#reqchold-text".\nBesides, some documents which you"
         " shouldn't ignore will be copied, too! :-)"
    )
  )

  (set #reqchok-text
    (cat "\n\nCongratulations!\n\nYou already have installed the new version"
         " of \"RequestChoice\"! 0=)"
    )
  )

  (set #editseq-text
    (cat "\nThe guide should be shown before the CD32-Emulator starts."
         " For that purpose the following line has to be added to the"
         " StartUp-Sequence\n(Before the path"
         " of your CD32-Emulator):\n\n"#execom-text"\n\n"
         "Do you want to edit the StartUp-Sequence now or"
         " later MANUALLY?\n\n"
         "(See Help for more information!)"
    )
  )

  (set #editseq-help
    (cat " In this new StartUp-Sequence "#newstartup-text" that will be"
         " executed by the \"Execute\"-command will be inserted all commands"
         " necessary for starting the "@app-name"!\n\n"
         " Select \"Now\" to edit the StartUp-Sequence right now!"
         " The editor \"Ed\" will be used for that. If it is not in your"
         " \"SYS:C\"-directory you can choose the right path or a complete"
         " different editor!\n\n If you select \"Later\" you have to edit"
         " the StartUp-Sequence after the installation!"
    )
  )

  (set #editseqok-text
    (cat "\n\nThe following line has to be added (Before the"
         " path of your CD32-Emulator):\n\n"#execom-text"\n\n"
         "Let's get to work... ;-)"
    )
  )

  (set #badtexted-text
    (cat "Couldn't find the editor \"Ed\" in your \"SYS:C\"-drawer!"
         " Please select an editor of your choice!"
    )
  )

  (set #notexted-text
    (cat "\n\nYou didn't select anything!\n\n"
         "Please edit the StartUp-Sequence afterwards!"
    )
  )

  (set #nicehint-text
    (cat "\nHint\n"
         "----\n\n"
         "Instead of using "#execom-text" you can also try this"
         " variant:\n\n\"Run >NIL: Execute S:IDEfixCD32Guide-StartUp\"\n\n"
         "After you've tested the 'normal' variant you can try this one.\n"
         "Maybe you like it better... ;-)"
    )
  )

  (set #exitremind-text
    (cat "\n\nDon't forget to add the line\n"#execom-text"\n"
         "to the StartUp-Sequence (Before the path of your CD32-Emulator)!"
    )
  )

  (set #exit-text
    (cat "\n\nThomas Rehbein\n<Tommy@SpyBox.shnet.org>\n\n"
         "wishes you a lot of fun with the guide! ;-)"
    )
  )
 )
)

; ========================================================================

(set #oldvexists
  (askbool
    (prompt #oldvexists-text)
    (help #no-help)
  )
)

(if (= #oldvexists 1)
  (
   (set #deloldv
     (askbool
       (prompt #deloldv-text)
       (help #deloldv-help)
       (if (= #loc 1)
         (choices "Ja, alte Version löschen" "Nein, weiter")
        (choices "Yes, remove old version" "No, go on")
       )
     )
   )
   (if (= #deloldv 1)
     (exit (quiet))
    (message #goon-text)
   )
  )
 (message #goon-text)
)

(welcome)

(complete 0)

(message #welcome-text)

(set #agandmv
  (askbool
    (prompt #agandmv-text)
    (help #agandmv-help)
  )
)

(complete 5)

(if (= #agandmv 1)
  (
   (set #gno
     (askchoice
       (prompt #gno-text)
       (help #gno-help)
       (if (= #loc 1)
         (choices "Auswahlmöglichkeit zwischen beiden Viewern" "'Fester' Viewer")
        (choices "Choice between the two viewers" "One permanent viewer")
       )
     )
   )
   (if (= #gno 1)
     (set #agandmv 0)
   )
  )
)

(if (= #agandmv 0)
  (
   (set #which
     (askbool
       (prompt #which-text)
       (help #no-help)
       (choices "AmigaGuide" "MultiView")
     )
   )
   (if (= #which 1)
     (set #viewer "AmigaGuide")
    (set #viewer "MultiView")
   )
  )
)

(complete 10)

(if (= #agandmv 0)
  (
   (if (= #loc 1)
     (set #vieweradd-text
       (cat "\""#viewer"\" aus!")
     )
    (set #vieweradd-text
      (cat "\""#viewer"\"!")
    )
   )
   (set #viewer-path
     (askfile
       (prompt #viewerpath-text #vieweradd-text)
       (help @askfile-help)
       (if (= #which 1)
         (default #ag-default)
        (default #mv-default)
       )
     )
   )
  )
 (
  (if (= #loc 1)
    (set #vieweradd-text
      (cat "\"AmigaGuide\" aus!")
    )
   (set #vieweradd-text
     (cat "\"AmigaGuide\"!")
   )
  )
  (set #viewer1-path
    (askfile
      (prompt #viewerpath-text #vieweradd-text)
      (help @askfile-help)
      (default #ag-default)
    )
  )
  (if (= #loc 1)
    (set #vieweradd-text
      (cat "\"MultiView\" aus!")
    )
   (set #vieweradd-text
     (cat "\"MultiView\"!")
   )
  )
  (set #viewer2-path
    (askfile
      (prompt #viewerpath-text #vieweradd-text)
      (help @askfile-help)
      (default #mv-default)
    )
  )
 )
)

(complete 25)

(set #dest-dir
  (askdir
    (prompt #destdir-text)
    (help #destdir-help @askdir-help)
    (default "SYS:S")
    (newpath)
    (disk)
  )
)

(set @default-dest #dest-dir)

(complete 30)

(copyfiles
  (source #guide-name)
  (dest @default-dest)
  (infos)
)

(rename (tackon @default-dest #guide-name) (tackon @default-dest #guidestd-name))
(rename
  (cat (tackon @default-dest #guide-name) ".info")
  (cat (tackon @default-dest #guidestd-name) ".info")
)

(copyfiles
  (source #readme-name)
  (dest @default-dest)
  (infos)
)

(copyfiles
  (source "ReqCh.lha")
  (dest @default-dest)
)

(copyfiles
  (source "ReqCh.readme")
  (dest @default-dest)
)

(copyfiles
  (source @icon)
  (dest @default-dest)
  (infos)
)

(copyfiles
  (source #installd-name)
  (dest @default-dest)
  (infos)
)

(complete 50)

(set #reqch-ver
  (getversion #reqch-path)
)

(if (< #reqch-ver 2621442)
  (
   (message #reqchinst-text)
   (run "LhA x ReqCh.lha RAM:")
   (if (exists #reqch-path)
     (rename #reqch-path #reqchold-path)
   )
   (copyfiles
     (source "ReqCh.readme")
     (dest #ag-default)
   )
   (copyfiles
     (source "RAM:ReqCh")
     (dest #ag-default)
     (all)
   )
   (delete "RAM:ReqCh#?"
     (all)
   )
  )
 (message #reqchok-text)
)

(complete 65)

(set #editseq
  (askbool
    (prompt #editseq-text)
    (help #editseq-help)
    (if (= #loc 1)
      (choices "Jetzt" "Später")
     (choices "Now" "Later")
    )
  )
)

(if (= #editseq 1)
  (
   (message #editseqok-text)
   (if (exists "C:Ed")
     (run "C:Ed" #startup-path)
    (
     (set #texted
       (askfile
         (prompt #badtexted-text)
         (help @askfile-help)
         (default "SYS:")
       )
     )
     (if (= (fileonly #texted) "")
       (
        (message #notexted-text)
        (set #editseq 0)
       )
      (
       (message #editseqok-text)
       (run #texted #startup-path)
      )
     )
    )
   )
  )
)

(complete 80)

(set #guide-path (tackon @default-dest #guidestd-name))

(if (= #agandmv 0)
  (textfile
    (dest #newstartup-dest)
    (if (= #which 1)
      (append "; $VER: \""@app-name"\" - StartUp-Sequence V1.0 (18. 07. 1997)\n"
              "; By Thomas Rehbein\n"
              "; Your guide viewer: \"AmigaGuide\"\n\n"
              "\""#viewer-path"\" \""#guide-path"\""
      )
     (append "; $VER: \""@app-name"\" - StartUp-Sequence V1.0 (18. 07. 1997)\n"
             "; By Thomas Rehbein\n"
             "; Your guide viewer: \"MultiView\"\n\n"
             "Assign LIBS: SYS:Classes Add\n"
             "Assign LOCALE: SYS:Locale\n"
             "Assign HELP: LOCALE:Help DEFER\n\n"
             "\""#viewer-path"\" \""#guide-path"\""
     )
    )
  )
 (textfile
   (dest #newstartup-dest)
   (if (= #loc 1)
     (append "; $VER: \""@app-name"\" - StartUp-Sequence V1.0 (18. 07. 1997)\n"
             "; By Thomas Rehbein\n"
             "; Your guide viewer: \"AmigaGuide\"/\"MultiView\"/None\n\n"
             "C:RequestChoice >NIL: TITLE \"IDEfix-CD32-Emulator-Hilfs-Guide - Nachfrage\" BODY \"Welcher Guide-Viewer soll benutzt werden?\" GADGETS \"AmigaGuide\" \"MultiView\" \"Abbruch\"\n\n"
             "IF VAL $ReqChGG EQ 1\n"
             "\""#viewer1-path"\" \""#guide-path"\"\n"
             "EndIF\n\n"
             "IF VAL $ReqChGG EQ 2\n"
             "Assign LIBS: SYS:Classes Add\n"
             "Assign LOCALE: SYS:Locale\n"
             "Assign HELP: LOCALE:Help DEFER\n"
             "\""#viewer2-path"\" \""#guide-path"\"\n"
             "EndIF\n\n"
             "UnSet ReqChGG"
     )
    (append "; $VER: \""@app-name"\" - StartUp-Sequence V1.0 (18. 07. 1997)\n"
            "; By Thomas Rehbein\n"
            "; Your guide viewer: \"AmigaGuide\"/\"MultiView\"/None\n\n"
            "C:RequestChoice >NIL: TITLE \"IDEfix-CD32-Emulator-Support-Guide - Request\" BODY \"Which guide viewer should be used?\" GADGETS \"AmigaGuide\" \"MultiView\" \"Abort\"\n\n"
            "IF VAL $ReqChGG EQ 1\n"
            "\""#viewer1-path"\" \""#guide-path"\"\n"
            "EndIF\n\n"
            "IF VAL $ReqChGG EQ 2\n"
            "Assign LIBS: SYS:Classes Add\n"
            "Assign LOCALE: SYS:Locale\n"
            "Assign HELP: LOCALE:Help DEFER\n"
            "\""#viewer2-path"\" \""#guide-path"\"\n"
            "EndIF\n\n"
            "UnSet ReqChGG"
    )
   )
 )
)

(complete 95)

(protect #newstartup-dest "-e +s")

(complete 98)

(message #nicehint-text)

(complete 100)

(if (= #editseq 0)
  (exit #exitremind-text #exit-text)
)

(exit #exit-text)
