;$VER: MetaView Install 2.5 (15.3.1998)
;Copyright Š1996/97/98 Henk Jonas

(set @app-name "MetaView V2.5")
(set @sourcedir (pathonly @icon))
(set #wbversion (getversion "libs:version.library"))
(set #wbversion (/ #wbversion 65536))

(if (< #wbversion 37)
  (abort "\n\nAmigaDOS 2.0 or better is needed for this software.")
)
(if (< #wbversion 40)
  (
    (set #language-bit
      (askchoice
        (prompt "Please chooce your favorite language for the installation")
        (choices "English" "Deutsch" "Espaņol" "Polski" "Ceská")
        (default 0)
        (help @askchoice-help)
      )
    )
    (if (IN #language-bit 0)
      (set #language-number 0)
    )
    (if (IN #language-bit 1)
      (set #language-number 1)
    )
    (if (IN #language-bit 2)
      (set #language-number 2)
    )
    (if (IN #language-bit 3)
      (set #language-number 3)
    )
    (if (IN #language-bit 4)
      (set #language-number 4)
    )
  )
  (
    (set #language (getenv "language"))
    (set #language-number 0)
    (if (= #language "deutsch")
      (set #language-number 1)
    )
    (if (= #language "espaņol")
      (set #language-number 2)
    )
    (if (= #language "polski")
      (set #language-number 3)
    )
    (if (= #language "ceská")
      (set #language-number 4)
    )
  )
)

(message "Henk Jonas\n"
         "present:\n\n"
         "MetaView\n\n"
         "This programm shows and converts gfx-metafiles,\n"
         "uses the amigametaformat.library\n"
         "and is Shareware.")
(set #user-level @user-level)
(set #defaultdir "ram:")
(if (= 1 (exists ("envarc:MetaView.path")))
  (
    (set #defaultdir (expandpath (tackon (pathonly (getenv "MetaView.path")) "/")))
    (set @parentdir
      (askdir
        (prompt "I found the MetaView drawer,\n"
                "leave the path in the parent directory\n"
                "of the MetaView drawer for\n"
                "updating an existing MetaView installation.")
        (help @askdir-help)
        (default #defaultdir)
      )
    )
  )
  (
    (user 2)
    (set @parentdir
      (askdir
        (prompt "Please chooce the destination for MetaView.\n"
                "I will create a MetaView drawer there,\n"
                "if it does not exist.")
        (help @askdir-help)
        (default #defaultdir)
      )
    )
    (user #user-level)
  )
)

(set @default-dest (tackon @parentdir "MetaView"))

(makedir @default-dest
  (prompt "I am creating the drawer 'MetaView'.")
  (help @makedir-help)
  (infos)
)

(complete 5)

(copylib 
  (prompt "Now I will install the 'amigametaformat.library'.")
  (source (tackon @sourcedir "libs/amigametaformat.library"))
  (dest  "libs:")
  (optional "nofail" "force" "askuser")
  (help "This library are needed for this programm.\n"
        "It is very importent to install this!")
)

(complete 10)

(set #driver
  (askoptions
    (prompt "Now I will install the different Outputdrivers for the 'amigametaformat.library'.")
    (choices "Strip" "AMF" "CGM" "EPS" "GEM" "WordWorth" "DR2D" "HPGL" "AI" "JMF" "WMF" "FIG")
    (help "the options:\n"
          "* Strip     : the driver for all renderings, like screen, ILBM, printer etc.\n"
          "* AMF       : are for output as Amiga Metafile Format.\n"
          "* CGM       : are for output as Computer Graphics Metafile.\n"
          "* EPS       : are for output as Encapsulated PostScript.\n"
          "* GEM       : are for output as GEM Metafile.\n"
          "* WordWorth : create ARexx scripts, for use in WordWorth.\n"
          "* DR2D      : are for output as DR2D (for PageStream, DrawStudio...)\n"
          "* HPGL      : are for output as HPGL (for Plotters)\n"
          "* AI        : are for output as AdobeIllustrator\n"
          "* JMF       : are for output as JavaMetaFile (for www-publishing)\n"
          "* WMF       : are for output as WindowsMetaFile\n"
          "* FIG       : are for output as XFIG file\n")
  )
)

(complete 20)

(makedir "libs:AMF")

(if (IN #driver 0)
  (copylib 
    (prompt "Now I will install the stripdriver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-strip.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "strip for all renderings on screen, printer and ILBM-output\n")
  )
)

(complete 21)

(if (IN #driver 1)
  (copylib 
    (prompt "Now I will install the filedriver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-file.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "file for saving as Amiga Meta Format Metafile\n")
  )
)

(complete 22)

(if (IN #driver 2)
  (copylib 
    (prompt "Now I will install the CGMdriver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-cgm.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "CGM for saving as Computer Graphics Metafile\n")
  )
)

(complete 23)

(if (IN #driver 3)
  (copylib 
    (prompt "Now I will install the EPSdriver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-eps.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "EPS for saving as Encapsulated PostScript\n")
  )
)

(complete 24)

(if (IN #driver 4)
  (copylib 
    (prompt "Now I will install the GEMdriver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-gem.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "GEM for saving as GEM Metafile\n")
  )
)

(complete 25)

(if (IN #driver 5)
  (copylib 
    (prompt "Now I will install the WordWorth-ARexx-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-ww.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "WordWorth-ARexx-driver for creating WordWorth-ARexx-script\n")
  )
)

(complete 26)

(if (IN #driver 6)
  (copylib 
    (prompt "Now I will install the DR2D-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-dr2d.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "DR2D-driver for creating DR2D-Output\n")
  )
)

(complete 27)

(if (IN #driver 7)
  (copylib 
    (prompt "Now I will install the HPGL-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-hpgl.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "HPGL-driver for creating HPGL-Output\n")
  )
)

(complete 28)

(if (IN #driver 8)
  (copylib 
    (prompt "Now I will install the AI-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-ai.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "AI-driver for creating AI-Output\n")
  )
)

(complete 29)

(if (IN #driver 9)
  (copylib 
    (prompt "Now I will install the JMF-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-jmf.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "JMF-driver for creating JMF-Output\n")
  )
)

(complete 30)

(if (IN #driver 10)
  (copylib 
    (prompt "Now I will install the WMF-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-wmf.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "WMF-driver for creating WMF-Output\n")
  )
)

(complete 31)

(if (IN #driver 11)
  (copylib 
    (prompt "Now I will install the FIG-driver for 'amigametaformat.library'.")
    (source (tackon @sourcedir "libs/AMF/amigametaformat-xfig.driver"))
    (dest  "libs:AMF/")
    (optional "nofail" "force" "askuser")
    (help "FIG-driver for creating FIG-Output\n")
  )
)

(complete 40)

(copyfiles
  (prompt "copy programm")
  (source (tackon @sourcedir "MetaView"))
  (dest @default-dest)
  (infos)
  (help "Now, I will copy the programm.")
)

(complete 50)

(copyfiles
  (prompt "copy MetaView.doc")
  (source (tackon @sourcedir "MetaView.doc"))
  (dest @default-dest)
  (infos)
  (help "Now, I will copy the MetaView.doc.")
)

(complete 60)

(user 2)
(set #language
  (askoptions
    (prompt "Now I will copy the guide for MetaView.\n"
            "What is your favorite language?")
    (choices "English" "Deutsch" "Espaņol" "Polski" "Ceská")
    (default #language-number)
    (help @askoptions-help)
  )
)
(user #user-level)

(complete 61)

(if (IN #language 0)
  (copyfiles
    (prompt "copy English MetaView.guide")
    (source (tackon @sourcedir "MetaView.guide"))
    (dest @default-dest)
    (infos)
    (help "Now, I will copy the English MetaView.guide.")
  )
)

(complete 62)

(if (IN #language 1)
  (copyfiles
    (prompt "copy German MetaView.guide")
    (source (tackon @sourcedir "translations/MetaView_deutsch.guide"))
    (dest @default-dest)
    (infos)
    (help "Now, I will copy the German MetaView.guide.")
  )
)

(complete 63)

(if (IN #language 2)
  (copyfiles
    (prompt "copy Spanish MetaView.guide")
    (source (tackon @sourcedir "translations/MetaView_espanol.guide"))
    (dest @default-dest)
    (infos)
    (help "Now, I will copy the Spanish MetaView.guide.")
  )
)

(complete 64)

(if (IN #language 3)
  (copyfiles
    (prompt "copy Polish MetaView.guide")
    (source (tackon @sourcedir "translations/MetaView_polski.guide"))
    (dest @default-dest)
    (infos)
    (help "Now, I will copy the Polish MetaView.guide.")
  )
)

(complete 65)

(if (IN #language 4)
  (copyfiles
    (prompt "copy Czech MetaView.guide")
    (source (tackon @sourcedir "translations/MetaView_ceska.guide"))
    (dest @default-dest)
    (infos)
    (help "Now, I will copy the Czech MetaView.guide.")
  )
)

(complete 70)

(copyfiles
  (prompt "copy amigametaformat.readme")
  (source (tackon @sourcedir "libs/amigametaformat.readme"))
  (dest @default-dest)
  (infos)
  (help "Now, I will copy the amigametaformat.readme.")
)

(complete 80)

(copyfiles
  (prompt "copy ARexx-Examples")
  (source (tackon @sourcedir "ARexx-Examples"))
  (dest (tackon @default-dest "ARexx-Examples"))
  (files)
  (all)
  (infos)
  (help "Now, I will copy some ARexx-Examples.")
)

(user 2)
(if (= 1 (askbool
            (prompt "Do you have DrawStudio installed,\n"
                    "and want to im- and export gfx\n"
                    "with MetaView?")
            (choices "Yes" "No")
            (help "I want to install two ARexx scripts for import and export\n"
                  "graphics in DrawStudio with MetaView")
         )
    )
    (
       (set #dspath
          (askdir
            (prompt "Please choose the DrawStudio ARexx scripts drawer.")
            (help "I want toinstall two ARexx scripts for import and export\n"
                  "graphics in DrawStudio with MetaView")
            (default "Rexx:")
            (disk)
          )
       )
       (copyfiles
         (prompt "copying DrawStudio import script")
         (source (tackon @sourcedir "ARexx-Examples/DrawStudio_Import.dsrx"))
         (dest #dspath)
       )
       (copyfiles
         (prompt "copying DrawStudio export script")
         (source (tackon @sourcedir "ARexx-Examples/DrawStudio_Export.dsrx"))
         (dest #dspath)
       )
    )
)

(if (= 1 (askbool
            (prompt "Do you have PageStream 3.x installed,\n"
                    "and want to import gfx with MetaView?")
            (choices "Yes" "No")
            (help "I want to install one ARexx script for import\n"
                  "graphics in PageStream with MetaView")
         )
    )
    (
       (set #pspath
          (askdir
            (prompt "Please choose the PageStream ARexx scripts drawer.")
            (help "I want to install one ARexx script for import\n"
                  "graphics in PageStream with MetaView")
            (default "Rexx:")
            (disk)
          )
       )
       (copyfiles
         (prompt "copying PageStream import script")
         (source (tackon @sourcedir "ARexx-Examples/PageStream_Import.rexx"))
         (dest #pspath)
       )
    )
)

(if (= 1 (askbool
            (prompt "Do you have WordWorth installed,\n"
                    "and want to import gfx with MetaView?")
            (choices "Yes" "No")
            (help "I want to install one ARexx script for import\n"
                  "graphics in WordWorth with MetaView")
         )
    )
    (
       (set #wwpath
          (askdir
            (prompt "Please choose the WordWorth ARexx scripts drawer.")
            (help "I want to install one ARexx script for import\n"
                  "graphics in WordWorth with MetaView")
            (default "Rexx:")
            (disk)
          )
       )
       (copyfiles
         (prompt "copying WordWorth import script")
         (source (tackon @sourcedir "ARexx-Examples/WordWorth_Import_gfx.rexx"))
         (dest #wwpath)
       )
    )
)

(if (= 1 (askbool
            (prompt "Do you have FinalWriter installed,\n"
                    "and want to import gfx with MetaView?")
            (choices "Yes" "No")
            (help "I want to install one ARexx script for import\n"
                  "graphics in FinalWriter with MetaView")
         )
    )
    (
       (set #fwpath
          (askdir
            (prompt "Please choose the FinalWriter ARexx scripts drawer.")
            (help "I want to install one ARexx script for import\n"
                  "graphics in FinalWriter with MetaView")
            (default "Rexx:")
            (disk)
          )
       )
       (copyfiles
         (prompt "copying FinalWriter import script")
         (source (tackon @sourcedir "ARexx-Examples/FinalWriter_Import.rexx"))
         (dest #fwpath)
       )
    )
)
(user #user-level)


(if (= 1 (askbool
            (prompt "Should I copy the example files?")
            (choices "Copy" "Skip")
            (help @askbool-help)
            (default 1)
         )
    )
    (copyfiles
      (prompt "copy Examples")
      (source (tackon @sourcedir "Examples"))
      (dest (tackon @default-dest "Examples"))
      (files)
      (all)
      (infos)
      (help "Now, I want to copy some Examples.")
    )
)

(complete 85)

(set #osvernum (getversion))
(set #osver (/ #osvernum 65536))
(set #osrev (- #osvernum (* #osver 65536) ) )
(set #oldpatchvernum (getversion "c:SetPatch"))
(set #newpatchvernum (getversion (tackon @sourcedir "SetPatch43_6/SetPatch")))

(if (AND (> #osver 39) (< #oldpatchvernum #newpatchvernum))
  (if (= 1 (askbool
              (prompt "I want to copy a new SetPatch (43.6) to your 'c:' directory.\n"
                      "This Software are published from Amiga Technologie and\n"
                      "fix also a bug on 'mathieeesingbas.library' in Kick 3.1.\n"
                      "The old 'c:SetPatch' will renamed to 'c:SetPatch.old'.")
              (choices "Copy" "Skip")
              (help "Press 'Copy' to install the new SetPatch and 'Skip' for not install.\n"
                    "You are advised to install this Patch.\n"
                    "But if you get a GURU on MetaView-startup you must!")
              (default 1)
           )
      )
      (
        (rename "c:SetPatch" "c:SetPatch.old")
        (copylib
          (prompt "copy new SetPatch")
          (source (tackon @sourcedir "SetPatch43_6/SetPatch"))
          (dest  "c:")
          (optional "nofail" "force" "askuser")
          (help @copylib-help)
        )
      )
  )
)

(if (> #osver 38)
  (copylib
     (prompt "copy tabs.gadget")
     (source (tackon @sourcedir "libs/gadgets/tabs.gadget"))
     (dest  "libs:gadgets/")
     (optional "nofail" "force" "askuser")
     (help @copylib-help)
  )
)

(complete 90)

(if (= 1 (exists ("envarc:MetaView.path")))
  (if (= 1 (askbool
              (prompt "Should I update the MetaView.path environment variable?")
              (choices "Update" "Skip")
              (help "The ARexxScripts and the MetaView.datatype will use the variable for locate the executable.")
              (default 1)
           )
      )
    (
      (textfile
        (prompt "Create ENVARC: variable with path of MetaView")
        (dest "envarc:MetaView.path")
        (append (tackon @default-dest "Metaview"))
        (help "The ARexxScripts and the Metaview.datatype will use the variable for locate the executable.")
      )
      (textfile
        (prompt "Create ENV: variable with path of MetaView")
        (dest "env:MetaView.path")
        (append (tackon @default-dest "Metaview"))
        (help "The ARexxScripts and the Metaview.datatype will use the variable for locate the executable.")
      )
    )
  )
)

(complete 95)

(user 2)
(if (= 1 (exists (tackon @sourcedir "keyfile.metaview")))
    (copyfiles
      (prompt "copy keyfile")
      (source (tackon @sourcedir "keyfile.metaview"))
      (dest @default-dest)
      (infos)
      (help "Now I copy the keyfile.")
    )
)
(if (= 0 (exists (tackon @default-dest "keyfile.metaview")))
    (message
       "Don`t forget to register!\n\n"
       "Please send $20 or 30,- DM to me:\n\n"
       "Henk Jonas\n"
       "Zionskirchstr. 28\n"
       "10119 Berlin\n"
       "Germany"
       (help "Look at MetaView.readme, MetaView.doc "
             "or MetaView.guide for register")
    )
)
(if (= 1 (exists (tackon @default-dest "keyfile.metaview")))
    (message
      "Thank you for registering MetaView!"
    )
)

(complete 100)

