
/*********************************************************************************************
 *
 * installation script for the InstallerNG $VER: 1.1 (28.08.99)
 *
 * note, that this script makes use of seveal new features of the InstallerNG
 * like multilined comments and enhanced pattern-match functionality of the DATABASE
 * function
 *
 *********************************************************************************************/

(if (= @language "english")

    (
      (set #msg_welcome (cat "Welcome to the Installation of the InstallerNG\n\n"
                             "The InstallerNG wants to be a substitution of\n"
                             "the original Installer by C=\n"
                             "It offers many new features, looks much better and is\n"
                             "smaller than the C= Installer"
                        )
      )
      (set #msg_askfile_prompt "Where is the default Installer located?")
      (set #msg_askfile_help (cat "Please select the original Installer by C=. "
                                  "This script will make a backup copy of the "
                                  "Installer and then, it will replace the "
                                  "original by the new InstallerNG."
                             )
      )
      (set #msg_copylib_prompt "Now copying the InstallerNG to \"%s\"")
      (set #msg_copylib_help "...")

      (set #msg_catalog_prompt "Which catalog-file do you want to install?")
      (set #msg_catalog_help "...")

      (set #msg_done (cat "Done!\n"
                          "The InstallerNG replaced the original Installer\n"
                          "and made a copy of the old one in \"%s\".\n\n"
                          "Have fun with the new Installer and its features"
                     )
      )

      (set #msg_rename_prompt "Now renaming the C= installer")
      (set #msg_rename_help "...")

      (set #msg_copytools_prompt "Which additional tools you want to install? (see Help)")
      (set #msg_copytools_help (cat "CloseScreenPatch\nA patch, which avoids screen closing, while a window "
                                    "is still open on that screen and helps you to save memory. Just add "
                                    "'run <>nil: c:closescreenpatch' to the end of your 's:user-startup' file"
                                    "\n\nGetSum\n"
                                    "Calculates the checksum of any file, like the Installer does. "
                                    "Usage: type 'getsum <file>' in your shell"
                               )
      )

      (set #msg_tooltypes_prompt "Which Tooltypes you want to preset?")
      (set #msg_tooltypes_help "...")

      (set #msg_askchoice_prompt "Which GUI do you want to use?")
      (set #msg_askchoice_help "...")

      (set #message_letsgo "Installation prepared. Ready to proceed?")

      (set #working_text "Now starting to install the new InstallerNG by Jens Tröger")
    )
)

(if (= @language "deutsch")

    (
      (set #msg_welcome (cat "Willkommen zur Installation des InstallerNG\n\n"
                             "Der InstallerNG soll ein Ersatz für den\n"
                             "originalen Installer von C= sein\n"
                             "Er bietet viele neue Eigenschaften, sieht viel besser aus\n"
                             "und ist kleiner als der C= Installer"
                        )
      )

      (set #msg_askfile_prompt "Wo befindet sich der Installer?")
      (set #msg_askfile_help (cat "Bitte wählen Sie den originalen Installer von C=. "
                                  "Dieses Skript macht eine Kopie des originalen "
                                  "Installers und wird danach den originalen durch "
                                  "den neuen InstallerNG ersetzen."
                             )
      )

      (set #msg_copylib_prompt "Kopiere jetzt den InstallerNG nach \"%s\"")
      (set #msg_copylib_help "...")

      (set #msg_catalog_prompt "Zu welcher Sprache möchten Sie einen Katalog installieren?")
      (set #msg_catalog_help (cat "Wählen Sie hier aus, welche Katalog Datei Sie installieren möchten. "
                                  "Sinnigerweise sollten Sie 'deutsch' wählen."
                             )
      )

      (set #msg_done (cat "Fertig!\n"
                          "Der InstallerNG hat Ihren originalen Installer\n"
                          "ersetzt und eine Kopie des alten als \"%s\" erzeugt.\n\n"
                          "Viel Spaß mit dem neuen Installer und seinen Möglichkeiten"
                     )
      )

      (set #msg_rename_prompt "Benenne nun den C= Installer um")
      (set #msg_rename_help "...")

      (set #msg_copytools_prompt "Welche zusätzlichen Programme wollen Sie installieren?")
      (set #msg_copytools_help (cat "CloseScreenPatch\nEin Patch, welcher verhindert, daß ein Screen geschlossen "
                                    "wird, auf dem noch Fenster geöffnet sind und somit 'Speicherleichen' "
                                    "vorbeugt. Einfach 'run <>nil: c:closescreenpatch' in 's:user-startup' einfügen"
                                    "\n\nGetSum\n"
                                    "Berechnet die Checksumme einer Datei, wie sie auch der Installer berechnet. "
                                    "Nutzung: 'getsum <file>' in der Shell eingeben"
                               )
      )

      (set #msg_tooltypes_prompt "Welche Tooltypes möchten Sie voreinstellen? (siehe Hilfe)")
      (set #msg_tooltypes_help "...")

      (set #msg_askchoice_prompt "Welche Oberfläche möchten Sie verwenden?")
      (set #msg_askchoice_help "...")

      (set #message_letsgo "Installation vorbereitet. Soll nun weitergemacht werden?")

      (set #working_text "Beginne nun mit der Installation des InstallersNG von Jens Tröger")
    )
)

/*********************************************************************************************/

(effect "center_center" "horizontal" $000000 $33FF33)

/*********************************************************************************************/

(user expert)
(message #msg_welcome)
(welcome)
(complete 0)

; -----------------------------------------------------------------------------
; the default settings

(set #default_installer "c:installer"
     #default_catalog 0
     #default_tools 0
     #default_tooltypes 0
     #default_gui 0
)

; -----------------------------------------------------------------------------
; first of all let the user make all the required settings
; for the installation

(swing

  (set #default_installer (askfile (prompt #msg_askfile_prompt)
                                   (default #default_installer)
                                   (help #msg_askfile_help)
                          )
  )

  (set #default_catalog (askoptions (prompt #msg_catalog_prompt)
                                    (help #msg_catalog_help)
                                    (default #default_catalog)
                                    (choices "Deutsch")
                        )
  )

  (set #default_tools (askoptions (prompt #msg_copytools_prompt)
                                  (help #msg_copytools_help)
                                  (default #default_tools)
                                  (choices "CloseScreenPatch" "GetSum")
                      )
  )

  (set #default_tooltypes (askoptions (prompt #msg_tooltypes_prompt)
                                      (help #msg_tooltypes_help)
                                      (default #default_tooltypes)
                                      (choices "LAZYCOMPILE" "DEBUGMODE"
                                               "CREATEUNSINSTALL" "COPYFILESCOMMENT"
                                               "ALWAYSCONFIRM" "NOSYSDELETE"
                                      )
                          )
  )

  (set #default_gui (askchoice (prompt #msg_askchoice_prompt)
                               (help #msg_askchoice_help)
                               (default #default_gui)
                               (choices "BOOPSI by Savage (builtin)"
                                        "MUI by Savage"
                               )
                    )
  )

  (message #message_letsgo)
)

; -----------------------------------------------------------------------------
; now the installation process itself

(set #installer_backup (cat #default_installer ".backup"))

(if (not (exists #installer_backup (noreq)))
    (
      (rename #default_installer #installer_backup (confirm average)
                                                   (prompt #msg_rename_prompt)
                                                   (help #msg_rename_help)
      )
    )
) 

(complete 15)

(copylib (prompt (#msg_copylib_prompt #default_installer))
         (help #msg_copylib_help)
         (confirm average)
         (source (if (database "cpu" "(68000|68010)")
                     ("c/installer000")
                     ("c/installer020")
                 )
         )
         (dest (pathonly #default_installer))
         (newname (fileonly #default_installer))
         (infos)
)

(complete 30)

(if (bitand #default_tools 1)
    (copyfiles (source "tools/GetSum")
               (dest "C:")
    )
)
(if (bitand #default_tools 2)
    (copyfiles (source "tools/CloseScreenPatch")
               (dest "C:")
    )
)

(complete 45)

(if (exists (tackon #default_installer ".info"))

    (tooltype (dest #default_installer)
              (setstack 50000)
              (if (bitand #default_tooltypes  1) (settooltype "LAZYCOMPILE" "")
                                                 (settooltype "(LAZYCOMPILE)" ""))
              (if (bitand #default_tooltypes  2) (settooltype "DEBUGMODE" "")
                                                 (settooltype "(DEBUGMODE)" ""))
              (if (bitand #default_tooltypes  4) (settooltype "CREATEUNINSTALL" "")
                                                 (settooltype "(CREATEUNINSTALL)" ""))
              (if (bitand #default_tooltypes  8) (settooltype "COPYFILECOMMENT" "")
                                                 (settooltype "(COPYFILECOMMENT)" ""))
              (if (bitand #default_tooltypes 16) (settooltype "ALWAYSCONFIRM" "")
                                                 (settooltype "(ALWAYSCONFIRM)" ""))
              (if (bitand #default_tooltypes 32) (settooltype "NOSYSDELETE" "")
                                                 (settooltype "(NOSYSDELETE)" ""))
    )

    (nop)
)

(complete 60)

(if (bitand #default_catalog 1)
    (copylib (source "catalogs/deutsch/installerng.catalog")
             (dest "locale:catalogs/deutsch")
    )
)

(complete 75)

(select #default_gui

        (nop)

        (copylib (source "libs/mui/installergui.library")
                 (dest "libs:")
        )
)

(complete 100)

(exit (#msg_done #installer_backup) (quiet))

