;**************************
;
;    Install_Retina
;
;**************************
;
; Retina Installationsscript
;  für Commodores Installer
;
;**************************
;
; Autor:
; Ibrahim Tertemiz für
; MS MacroSystem GmbH
;      Witten
;
;**************************
;
; History:
; ========
; 16. Juni letzte Änderungen
;     Juni '93 für Rel. 1.3 umgeschrieben
; 17. März komplett überarbeitet
;  7. März 93 erste Version
;
;**************************
;
; bekannte Bugs
; =============
;
;
;**************************

; Einige Variablen setzen
(Set FALSE 0)
(Set TRUE 1)
(Set srcdisk "Retina:")

(Set oldlevel @user-level) ;orginal user-level speichern...
(Set check FALSE) ;Eigentlich muss nicht geprüft werden
(Set Overwrite FALSE) ;Und auch nichts überschrieben

; OS2.0 - Test machen...
(Set os2 (NOT (< (/ (getversion) 65536) 37)))

; Was für ein Prozessor?
(if (>= (+ (database "cpu")) 68020)
   (Set CPU030 TRUE)
   (Set CPU030 FALSE)
)

; LOCALE vorhanden?
(Set WB2.1 (= (exists "libs:locale.library") 1))


(if (patmatch @language "deutsch")
   ;Sprache ist deutsch
  (
   (Set default-lang 2)
   (Set MSG_GetDisk "Bitte legen Sie die Diskette mit dem Namen \"RETINA\" in ein beliebiges Laufwerk.")
   (Set HLP_GetDisk (cat MSG_GetDisk "\nIch benötige diese Diskette, um die Installation vornehmen zu können!\n"))
   (Set MSG_NoOS2 "Amiga DOS 2.0 nicht gefunden\n Bitte installieren Sie erst\n Workbench Version 2.0\n oder größer" )
   (Set MSG_WorkLibs "Kopiere benötigte Libraries...")
   (Set MSG_WorkPreset "Kopiere Grundvoreinstellungen...")
   (Set MSG_WorkLoc "Kopiere Sprachdateien...")
   (Set MSG_WorkRsys "Kopiere Verzeichnis RetinaSystem...")
   (Set MSG_WorkRTools "Kopiere Verzeichnis RetinaTools...")
   (Set MSG_WorkADPro "Kopiere ADPro-Dateien...")
   (Set MSG_WorkIM "Kopiere ImageMaster-Dateien...")
   (Set MSG_WorkDevel "Kopiere Entwicklerunterlagen...")
   (Set MSG_Makeminlocdir "Erstelle Verzeichnisse für \"minloc.library\" ")
   (Set HLP_Makeminlocdir "Erstelle Verzeichnisse für \"minloc.library\" ")
   (Set MSG_WhereRetSys "Wo sollen die Workbench-Emulation und die zugehörigen Programme hinkopiert werden?")
   (Set HLP_WhereRetSys "Geben Sie bitte das Zielverzeichnis für die Workbench-Emulation und die zugehörigen Programme an?")
   (Set MSG_WhereRetTool "Wo sollen die Hilfsprogramme für Retina hinkopiert werden?")
   (Set HLP_WhereRetTool "Geben Sie bitte das Zielverzeichnis für die Hilfsprogramme an.")
   (Set MSG_CopyRetTool "Kopiere Retina-Tools")
   (Set HLP_CopyRetTool "Kopiere Hilfsprogramme für Retina...")
   (Set MSG_SureDir (cat "\n Das Verzeichnis " DirName " wird automatisch erstellt!"))
   (Set MSG_WorkPreset "Kopiere die Grundvoreinstellungen")
   (Set MSG_CopyADPro "Möchten Sie den Retina-Saver für ADPro installieren?")
   (Set HLP_CopyADPro "Wenn Sie wünschen, wird die neueste Version des Retina-Savers für ADPro installiert.")
   (Set MSG_EnterADProDir "Bitte geben Sie das Verzeichnis an, in dem ADPro installiert ist...")
   (Set HLP_EnterADProDir MSG_EnterADProDir )
   (Set MSG_Enterrexxdir "Geben Sie bitte das Verzeichnis an, in dem die ADPro-ARexx Scripte sind...")
   (Set HLP_Enterrexxdir MSG_Enterrexxdir)
   (Set MSG_CopySaver "Möchten Sie den Retina-Saver für \"ADPro\" installieren?")
   (Set HLP_CopySaver MSG_CopySaver)
   (Set MSG_CopyIM "Möchten Sie den Retina-Anzeiger für \"ImageMaster\" installieren?")
   (Set HLP_CopyIM (cat MSG_CopyIM "\n Falls Sie wünschen, wird der Retina-Anzeiger installiert, um Grafiken in höchster Qualität auf der Retina darstellen zu können\n"))
   (Set MSG_CopyIMStuff "Kopiere für Imagemaster benötigtes Programm: ")
   (Set HLP_CopyIMStuff "Kopiere für Imagemaster benötigtes Programm: ")
   (Set MSG_GetDestDir (cat "Bitte geben Sie das Verzeichnis an, in dem \" " ProgName " \" installiert werden soll.\nDas Verzeichnis \" " ProgName " \" wird automatisch erzeugt."))
   (Set HLP_GetDestDir (cat "Suchen Sie bitte das Verzeichnis aus, in das \" " Progname " \" kopiert werden soll.\nDas Verzeichnis \" " Progname " \" wird bei Bedarf automatisch erzeugt!\n"))
   (Set MSG_Copy (cat"Kopiere die für " ProgName " benötigten Dateien\n"))
   (Set HLP_Copy MSG_Copy)
   (Set MSG_CopyDevel? "Soll das Entwicklerpaket auch kopiert werden?")
   (Set HLP_CopyDevel? MSG_CopyDevel?)
   (Set MSG_WhereDevel "Wo soll das Entwicklerpaket hinkopiert werden ?")
   (Set HLP_WhereDevel MSG_WhereDevel)
   (Set MSG_CopyDevel! "Ich kopiere das Entwicklerpaket...")
   (Set HLP_CopyDevel! MSG_CopyDevel!)
   (Set MSG_Create_Dir "Erzeuge benötigte Verzeichnisse...")
   (Set HLP_Create_Dir "Erzeuge benötigte Verzeichnisse, da sie noch nicht existierten...")
  )
   ;Sprache ist englisch
  (
   (Set default-lang 4)
   (Set MSG_NoOS2 "could not locate AmigaOS 2.0 or newer! \n Please install at least Amiga OS 2.0 first...")
   (Set MSG_GetDisk "Please insert disk named \"RETINA\" in any drive.")
   (Set HLP_GetDisk (cat MSG_GetDisk "\nI need this disk to perform the installation!\n"))
   (Set MSG_WorkLibs "Copying needed libraries...")
   (Set MSG_Makeminlocdir "Creating directories needed for \"minloc.library\" ")
   (Set HLP_Makeminlocdir "Creating directories needed for \"minloc.library\" ")
   (Set MSG_WhereRetSys "Where do you want the workbench-emulation and the associated programs to be copied to?")
   (Set HLP_WhereRetSys "Please select the destination directory for the workbench-emulation and the associated files.")
   (Set MSG_WhereRetTool "Where do you want the Retina-Tools to be copied to?")
   (Set HLP_WhereRetTool "Please select the destination directory for the Retina-tools.")
   (Set MSG_CopyRetTool "Copying Retina tools")
   (Set HLP_CopyRetTool "Copying tools for Retina...")
   (Set MSG_SureDir (cat "\n The directory " DirName " will be created automatically!"))
   (Set MSG_WorkPreset "copying basic presets")
   (Set MSG_WorkLibs "copying libraries...")
   (Set MSG_WorkLoc "copying locale files...")
   (Set MSG_WorkRsys "copying directory RetinaSystem...")
   (Set MSG_WorkRTools "copying directory RetinaTools...")
   (Set MSG_WorkADPro "copying files needed for ADPro...")
   (Set MSG_WorkIM "copying files needed for ImageMaster...")
   (Set MSG_WorkDevel "copying developer documentation...")
   (Set MSG_CopyADPro "Do you want to have the latest version of the Retina saver for ADPro installed?")
   (Set HLP_CopyADPro "If you want, I can install the latest version of the Retina saver for ADPro...")
   (Set MSG_EnterADProDir "Please select the directory where you have installed ADPro")
   (Set HLP_EnterADProDir MSG_EnterADProDir )
   (Set MSG_Enterrexxdir "please select the destination directory for the ADPro-Arexx scripts...")
   (Set HLP_Enterrexxdir MSG_Enterrexxdir)
   (Set MSG_CopySaver(cat "Do you want to install the Retinasaver for \"ADPro\"?"))
   (Set HLP_CopySaver MSG_CopySaver)
   (Set MSG_CopyIM "Do you want to have installed the Retinaviewer for \"ImageMaster\" ?")
   (Set HLP_CopyIM (cat MSG_CopyIM "\n If you want, I can also install the Retinaviewer to display your graphics at best quality on the Retina board\n"))
   (Set MSG_CopyIMStuff "copying needed program for \"ImageMaster\" called: ")
   (Set HLP_CopyIMStuff "copying needed program for \"ImageMaster\" called: ")
   (Set MSG_GetDir (cat "Please select the destination directory for \" " ProgName " \". The \" " ProgName " \" directory will be created automatically!"))
   (Set HLP_GetDir MSG_GetXiDir)
   (Set MSG_Copy (cat"Copying files needed for" ProgName ".\n"))
   (Set HLP_Copy MSG_CopyXiPaint)
   (Set MSG_CopyDevel? " Do you want the developer package to be copied, too?")
   (Set HLP_CopyDevel? MSG_CopyDevel)
   (Set MSG_WhereDevel "Where do you want the developer package to be copied?")
   (Set HLP_WhereDevel MSG_WhereDevel)
   (Set MSG_CopyDevel! " copying the developer package...")
   (Set HLP_CopyDevel! MSG_CopyDevel)
   (Set MSG_Create_Dir "Creating needed directories...")
   (Set HLP_Create_Dir "Creating needed directories, because I could not find them...")
  )
)

; Wenn kein OS2.0 installiert, abbrechen
(if (not os2)
   (abort MSG_NoOS2)
)

;Prozeduren um File kurz zu halten...
(procedure Check ((If (NOT (patmatch (fileonly DestDir) DirName))
                       (; wenn DestDir <> *(/|:) DirName
                        (if (= (exists (tackon DestDir DirName)) 2)
                         ; Wenn DestDir ex. reingehen...
                         (Set DestDir (tackon DestDir DirName))
                         ; Sonst erst makedir und dann reingehen...
                         ((makedir (tackon DestDir DirName)
                                   (prompt MSG_Create_Dir DirName)
                                   (help HLP_Create_Dir DirName @makedir-help)
                                   (infos)
                                   (safe)
                          )
                          (Set DestDir (tackon DestDir DirName))
                         )
                        )
                       )
                  )
                 )
)

;Prozedur GetDir: sucht ein neues Verzeichnis aus und liefert DestDir
(procedure GetDir ((Set DestDir (askdir   (prompt MSG_EnterDest) 
                                          (help HLP_EnterDest @askdir-help)
                                          (default mydefdest)
                                )
                   )

                  )
)

; main()
;*******

;gucken ob srcDisk in einem Laufwerk ist
(Set existsrc (getassign "Retina" "v"))
(if (= existsrc "") ;wenn "Retina:" in keinem Laufwerk
   (askdisk (prompt MSG_GetDisk)
            (help HLP_GetDisk @askdisk-help)
            (dest "Retina")
   )
)         


(working MSG_WorkLibs)
;libs kopieren
;retina.library
(copylib (source (tackon srcdisk "libs/retina.library"))
         (dest "libs:")
         (prompt MSG_CopyLibs1 "retina.library" MSG_CopyLibs2)
         (help @copylib-help)
         (confirm)
         
)
(complete 5)
;multipic.library
(copylib (source (tackon srcdisk "libs/multipic.library"))
         (dest "libs:")
         (prompt MSG_CopyLibs1 "multipic.library" MSG_CopyLibs2)
         (help @copylib-help)
         (confirm)

)
(complete 7)
;vlab.library
(copylib (source (tackon srcdisk "libs/vlab.library"))
         (dest "libs:")
         (prompt MSG_CopyLibs1 "multipic.library" MSG_CopyLibs2)
         (help @copylib-help)
         (confirm)

)
(complete 10)

;harlequin.library
(copylib (source (tackon srcdisk "libs/harlequin.library"))
         (dest "libs:")
         (prompt MSG_CopyLibs1 "harlequin.library" MSG_CopyLibs2)
         (help @copylib-help)
         (confirm)

)
(complete 15)

; Presets kopieren
(working MSG_WorkPreset)
(if (= (exists "ENVARC:Retina/Monitor") 0)
   (; Presets existieren nicht, also kopieren
    (copyfiles  (prompt MSG_CopyPrefsTo)
                (help HLP_CopyPrefsTo @copyfiles-help)
                (source (tackon srcdisk "Prefs/Env-Archive/Retina"))
                (dest "ENVARC:Retina")
                (all)
    )
    (copyfiles  (prompt MSG_CopyPrefsTo)
                (help HLP_CopyPrefsTo @copyfiles-help)
                (source "ENVARC:Retina")
                (dest "ENV:Retina")
                (all)
    )
   )
)
(complete 20)

(working MSG_WorkLoc)
; LOCALE: einrichten und kopieren
(If (NOT WB2.1)
   (; WB >= 2.1 existiert NICHT => minloc installieren
      (copylib (source (tackon srcdisk "libs/minloc.library"))
               (dest "libs:")
               (prompt MSG_CopyLibs1 "minloc.library" MSG_CopyLibs2)
               (help @copylib-help)
               (confirm)

      )
      ; Locale usw. für minloc erzeugen
      (makedir "SYS:Locale"
               (prompt MSG_Makeminlocdir)
               (help HLP_Makeminlocdir @makedir-help)
      )
      (makedir "SYS:Locale/Catalogs"
               (prompt MSG_Makeminlocdir)
               (help HLP_Makeminlocdir @makedir-help)
      )
      (Set locdest "SYS:Locale/Catalogs")
      (if (= default-lang 2)
         (
           (textfile (prompt MSG_CreateMLL)
                     (help HLP_CreateMLL)
                     (dest "ENVARC:MINLOCLANGUAGE")
                     (append "deutsch\n")
           )
           (textfile (prompt MSG_CreateMLL)
                     (help HLP_CreateMLL)
                     (dest "ENV:MINLOCLANGUAGE")
                     (append "deutsch\n")
           )
         )
      )
   )
   (; Wenn >= 2.1 dann dest = LOCALE:Catalogs
    (Set locdest "LOCALE:Catalogs")
    ; Falls altes Catalog ex. löschen
    (if (= (exists "LOCALE:Catalogs/deutsch/retina.catalog") 1)
      (delete "LOCALE:Catalogs/deutsch/retina.catalog"
              (prompt MSG_DelOldCat)
              (help HLP_DelOldCat)
              (optional "force")
      )
    )
   )
)
(copyfiles (prompt MSG_CopyLocale)
           (help HLP_CopyLocale @help-copyfiles)
           (source (tackon srcdisk "Locale/catalogs"))
           (dest locdest)
           (all)
           (optional "nofail")
)
(complete 25)

; "RetinaSystem" kopieren
(working MSG_WorkRSys)
(Set DirName "RetinaSystem")
(Set src (tackon srcdisk DirName))
(Set DestDir (askdir (prompt (cat MSG_WhereRetSys MSG_SureDir))
                     (help (cat HLP_WhereRetSys MSG_SureDir))
                     (default (tackon @default-dest DirName))
             )
)

; @default-dest neu festlegen
(set @default-dest (cat (getdevice DestDir) ":"))

(Check)
(copylib (prompt MSG_CopyRetSys)
         (help HLP_CopyRetSys @copyfiles-help)
         (source (tackon src "RetinaEmu"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetSys)
         (help HLP_CopyRetSys @copyfiles-help)
         (source (tackon src "RetinaScreenMode"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetSys)
         (help HLP_CopyRetSys @copyfiles-help)
         (source (tackon src "RetinaPalette"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)
(complete 30)

; "RetinaTools" kopieren
(working MSG_WorkRTools)
(Set DirName "RetinaTools")
(Set src (tackon srcdisk DirName))
(Set DestDir (askdir (prompt (cat MSG_WhereRetTool MSG_SureDir))
                     (help (cat HLP_WhereRetTool MSG_SureDir))
                     (default (tackon @default-dest DirName))
             )
)
(Check)
(Set ToolsDir DestDir)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "DefineMonitor"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)
(copyfiles (prompt MSG_CopyRetTool)
           (help HLP_CopyRetTool @copyfiles-help)
           (source (tackon src "MakeRACE"))
           (dest DestDir)
           (infos)
           (optional "nofail")
)
(copyfiles (prompt MSG_CopyRetTool)
           (help HLP_CopyRetTool @copyfiles-help)
           (source (tackon src "PlayRACE"))
           (dest DestDir)
           (infos)
           (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "Retina4Test"))
         (dest DestDir)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaAvail"))
         (dest DestDir)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaComm"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaDemo"))
         (dest DestDir)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaDisplay"))
         (dest DestDir)
         (infos)
         (optional "nofail")
)

(set JPEGsrc (tackon src "rjpeg"))
(copyfiles (prompt MSG_CopyRetTool)
           (help HLP_CopyRetTool @copyfiles-help)
           (source JPEGsrc)
           (dest "C:")
           (infos)
           (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaFrameCounter"))
         (dest DestDir)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaIRQ"))
         (dest DestDir)
         (optional "nofail")
)
(copylib (prompt MSG_CopyRetTool)
         (help HLP_CopyRetTool @copyfiles-help)
         (source (tackon src "RetinaMonitor"))
         (dest DestDir)
         (optional "nofail")
)
(complete 65)

; ADPro-Saver kopieren
(working MSG_WorkADPro)
(user 2)
(if (askbool (prompt MSG_CopyADPro)
             (help HLP_CopyADPro)
             (default 0)
    )
   (; user will installieren
      (user oldlevel)
      ;ist ADPro schon installiert?
      (Set DestDir (getassign "ADPRO" "av"))
      (if (<> "" DestDir)
         ((Set FoundADPro TRUE)
          (Set AdProDir DestDir)
         )
         (Set FoundADPro FALSE)
      )
      ; Wenn ADPro nicht korrekt installiert, dann neu suchen
      ; und ADProDir setzen
      (if (NOT FoundADPro)
         ((Set MSG_EnterDest MSG_EnterADProDir)
          (Set HLP_EnterDest HLP_EnterADProDir)
          (Set mydefDest @default-dest)
          (user 2)
          (GetDir)
          (user oldlevel)
          (Set ADProDir DestDir)
         )
      )
      ;ADPro.library kopieren
      (copylib (source (tackon srcdisk "libs/adpro.library"))
               (dest "libs:")
               (prompt MSG_CopyLibs1 "adpro.library" MSG_CopyLibs2)
               (help @copylib-help)
               (confirm)

      )
      (copylib (source "libs:adpro.library")
               (dest AdproDir)
               (prompt MSG_CopyLibs1 "adpro.library" MSG_CopyLibs2)
               (help @copylib-help)
               (confirm)

      )
      ;saver kopieren
      (Set DirName "Savers2")
      (check)
      (copylib (prompt MSG_CopyADPro)
               (help HLP_CopyADPro "\n" @copyfiles-help)
               (source (tackon srcDisk "ADPro/Savers2/RETINA"))
               (dest DestDir)
               (confirm)
      )
      ;Script kopieren
       (Set scriptdir (getassign "ADPROSCRIPTS" "av"))
       ((Set MSG_EnterDest MSG_Enterrexxdir)
        (Set HLP_EnterDest HLP_Enterrexxdir)
        (Set mydefDest scriptdir)
        (user 2)
        (GetDir)
        (user oldlevel)
       )
       (copyfiles
                  (prompt MSG_CopyADPRexx)
                  (help HLP_CopyADPRexx)
                  (source (tackon srcdisk "ADPro/Rexx/CF1.ADPRO"))
                  (dest DestDir)

       )
      (user oldlevel)
   )
   (; will nicht installieren
      (user oldlevel)
   )
)
(complete 75)

; Imagemaster kopieren
(working MSG_WorkIM)
(Set IMRexxDir (getassign "RXPI" "av"))
(if (<> "" IMRexxDir)
   (Set FoundIM TRUE)
   (Set FoundIM FALSE)
)
(if FoundIM
   (if (askbool (prompt MSG_CopyIM)
                (help HLP_CopyIM)
                (default 0)
       )
     (; User will IM Saver installieren
      (copyfiles  (prompt MSG_CopyIMStuff "retinaview.rexx\n" @copyfiles-help)
                  (help HLP_CopyIMStuff "retinaview.rexx\n")
                  (source (tackon srcdisk "ImageMaster/retinaview.rexx"))
                  (dest IMRexxDir)
      )
      (Set IMCDir (getassign "CMPI" "av"))
      (copyfiles  (prompt MSG_CopyIMStuff "RetinaView\n")
                  (help HLP_CopyIMStuff "RetinaView\n" @copyfiles-help)
                  (source (tackon srcdisk "ImageMaster/RetinaView"))
                  (dest IMCDir)
            
      )
     )
   )
)
(complete 85)

;developer Sachen kopieren - Abfrage bei Userlevel >= AVERAGE
(working MSG_WorkDevel)
(if (>= oldlevel 1); wenn userlevel AVERAGE oder EXPERT
      ;sollen die developersachen kopiert werden?
      ( (user 2)
        (set copydevel (askbool (prompt MSG_CopyDevel?)
                                (help HLP_CopyDevel? @askbool-help)
                                (default 1)
                       )
        )
        (if copydevel
         (
           (set DirName "Developer")
           (set MSG_EnterDest MSG_WhereDevel)
           (set HLP_EnterDest HLP_WhereDevel)
           (set mydefdest ToolsDir)
           (GetDir)
           (Check)
         )
        )
        (user oldlevel)
      )
      ; bei NOVICE User zu den RetinaTools
      ( (Set DestDir ToolsDir)
        (Set DirName "Developer")
        (check)
        (Set copydevel TRUE)
      )
)
(if copydevel
   (copyfiles (prompt MSG_CopyDevel!)
              (help HLP_CopyDevel! @copyfiles-help)
              (source (tackon srcdisk "Developer")) 
              (dest DestDir)
              (all)
              (infos)
              (optional "nofail")
   )
)
(complete 100)
