;*** $VER: NcodeR 1.55 (02.12.99) ***
;*** (C) 1999 by André Osterhues


(set vernum1 (getversion "NcodeR"))
(set ver1 (/ vernum1 65536))
(set rev1 (- vernum1 (* ver1 65536)))
(set ncoderver (cat ver1 "." rev1))
(if (= ver1 0) (set ncoderver ""))


;*** general strings ***
(set #boing     (cat "Boing"))
(set #fantastic (cat "Fantastic"))
(set #fractal   (cat "Fractal"))
(set #jesus     (cat "Jesus"))
(set #mechanic  (cat "Mechanic"))
(set #redplus   (cat "Redplus"))
(set #standard  (cat "Standard"))
(set #subwar    (cat "Subwar"))

;*** english ***
(set #yes       (cat "Yes"))
(set #no        (cat "No"))
(set #welcome   (cat "\n\n\nWelcome to NcodeR " ncoderver "\n\nThe MP3-Encoder for the Amiga\n\n© 1999 by André Osterhues\n\nDistributed by Titan Computer"))
(set #which     (cat "\nWhich version do you want to install?\n"))
(set #cpu68020  (cat "68020 (no FPU)"))
(set #cpu68020F (cat "68020 (FPU)"))
(set #cpu68040  (cat "68040 (no FPU)"))
(set #cpu68040F (cat "68040 (FPU)"))
(set #cpu68060  (cat "68060"))
(set #cpuppc    (cat "PPC (PowerUP)"))
(set #cpuwos    (cat "PPC (WarpOS)"))
(set #wheregtl  (cat "Where do you want to install gtlayout.library?"))
(set #overgtl   (cat "The gtlayout.library is already installed.\nDo you want to overwrite it?"))
(set #old       (cat "Already installed version:"))
(set #new       (cat "Version to install:"))
(set #where     (cat "Where do you want to install NcodeR?\n(A drawer will be created)"))
(set #burnit    (cat "Do you want to install the\nEncodeMP3 Operator for BurnIt V2.0?"))
(set #wherebit  (cat "Where is BurnIt V2.0 located?"))
(set #serial    (cat "Please enter your name and serial number."))
(set #skins     (cat "Do you want to install skins?"))
(set #skin      (cat "Which skins do you want to install?"))
(set #defskin   (cat "Select the default skin:"))
(set #sourcedir (cat "Select the source directory\n(where the WAVE/AIFF/MAUD files reside):"))
(set #targetdir (cat "Select the target directory\n(where the MP3 files should be stored):"))
(set #byebye    (cat "\nNcodeR installation complete!\n\n"))


;*** german ***
(if (= @language "deutsch")
  (
    (set #yes       (cat "Ja"))
    (set #no        (cat "Nein"))
    (set #welcome   (cat "\n\n\nWillkommen zu NcodeR " ncoderver "\n\nDer MP3-Encoder für den Amiga\n\n© 1999 by André Osterhues\n\n Vertrieb durch Titan Computer"))
    (set #which     (cat "\nWelche Version möchten Sie installieren?\n"))
    (set #cpu68020  (cat "68020 (ohne FPU)"))
    (set #cpu68020F (cat "68020 (FPU)"))
    (set #cpu68040  (cat "68040 (ohne FPU)"))
    (set #cpu68040F (cat "68040 (FPU)"))
    (set #cpu68060  (cat "68060"))
    (set #cpuppc    (cat "PPC (PowerUP)"))
    (set #cpuwos    (cat "PPC (WarpOS)"))
    (set #wheregtl  (cat "Wo möchten Sie die gtlayout.library installieren?"))
    (set #overgtl   (cat "Die gtlayout.library ist bereits installiert.\nMöchten Sie sie überschreiben?"))
    (set #old       (cat "Bereits installierte Version:"))
    (set #new       (cat "Zu installierende Version:"))
    (set #where     (cat "Wo möchten Sie NcodeR installieren?\n(Verzeichnis wird erzeugt)"))
    (set #burnit    (cat "Möchten Sie den EncodeMP3-Operator\n für BurnIt V2.0 installieren?"))
    (set #wherebit  (cat "Wo befindet sich BurnIt V2.0?"))
    (set #serial    (cat "Bitte geben Sie Ihren Namen und Ihre Seriennummer ein."))
    (set #skins     (cat "Möchten Sie Skins installieren?"))
    (set #skin      (cat "Welche Skins möchten Sie installieren?"))
    (set #defskin   (cat "Wählen Sie das Default-Skin:"))
    (set #sourcedir (cat "Wählen Sie das Quell-Verzeichnis\n(wo sich die WAVE-/AIFF-/MAUD-Dateien befinden):"))
    (set #targetdir (cat "Wählen Sie das Ziel-Verzeichnis\n(wo die MP3-Dateien gespeichert werden sollen):"))
    (set #byebye    (cat "\nNcodeR ist vollständig installiert!\n\n"))
  )
)


;*** welcome user ***
(message #welcome)
(complete 0)


;*** install gtlayout.library ***
(if (> (exists "libs/gtlayout.library") 0)
  (
    (set wheregtlayout
      (askdir
        (prompt #wheregtl)
        (help   #wheregtl)
        (default "LIBS:")
      )
    )
    (if (> (exists (tackon wheregtlayout "gtlayout.library")) 0)
      (
        (set gtlversion1 (getversion "LIBS:gtlayout.library"))
        (set gtlver1 (/ gtlversion1 65536))
        (set gtlrev1 (- gtlversion1 (* gtlver1 65536)))
        (set gtlversion2 (getversion "libs/gtlayout.library"))
        (set gtlver2 (/ gtlversion2 65536))
        (set gtlrev2 (- gtlversion2 (* gtlver2 65536)))
        (set overwrite
          (askbool
            (prompt (cat #overgtl "\n\n" #old gtlver1 "." gtlrev1 "\n" #new gtlver2 "." gtlrev2))
            (help "No help")
            (default 1)
            (choices #yes #no)
          )
        )
        (if (= overwrite 1)
          (
            (copyfiles
              (source "libs/gtlayout.library")
              (dest wheregtlayout)
              (optional "nofail")
            )
            (if (= (exists ("C:avail")) 0)
             (run "avail flush >NIL:")
           )
          )
        )
      )
    )
    (if (= (exists (tackon wheregtlayout "gtlayout.library")) 0)
      (copylib
        (source "libs/gtlayout.library")
        (dest wheregtlayout)
        (optional "nofail")
      )
    )
  )
)
(complete 10)


;*** ask for version to install ***
(set #cpu (cat (database "cpu")))
(set ppc 0)
(if (= (exists ("libs:powerpc.library")) 1) (set ppc 2))
(if (= (exists ("libs:ppc.library")) 1) (set ppc 1))
(if (= cpu "68020") (set default_version 1))
(if (= cpu "68030") (set default_version 2))
(if (= cpu "68040") (set default_version 3))
(if (= cpu "68060") (set default_version 4))
(if (= ppc 1) (set default_version 5))
(if (= ppc 2) (set default_version 6))
(set version
  (askchoice
    (choices #cpu68020 #cpu68020F #cpu68040 #cpu68040F #cpu68060 #cpuppc #cpuwos)
    (prompt #which)
    (help #which)
    (default default_version)
  )
)
(if (= version 0) (set ncode "Ncode.020"))
(if (= version 1) (set ncode "Ncode.020F"))
(if (= version 2) (set ncode "Ncode.040"))
(if (= version 3) (set ncode "Ncode.040F"))
(if (= version 4) (set ncode "Ncode.060"))
(if (= version 5) (set ncode "Ncode.elf"))
(if (= version 6) (set ncode "Ncode.wos"))
(complete 20)


;*** ask where to install NcodeR ***
(set where
  (askdir
    (prompt #where)
    (help #where)
    (default "Work:")
  )
)
(complete 30)


;*** ask if and where EncodeMP3 Operator for BurnIt should be installed ***
(set burnit
  (askbool
    (prompt #burnit)
    (help #burnit)
    (default 1)
    (choices #yes #no)
  )
)
(if (= burnit 1)
  (set wherebit
    (askdir
      (prompt #wherebit)
      (help   #wherebit)
      (default "Work:")
    )
  )
)
(complete 40)


;*** copy files ***
(if (< (exists (tackon where "NcodeR")) 2)
  (makedir
    (tackon where "NcodeR")
    (infos)
  )
)
(set whereprg (tackon where "NcodeR"))
(if (exists "NcodeR")
  (copyfiles
    (source "NcodeR")
    (dest whereprg)
    (newname "NcodeR")
    (optional "nofail")
  )
)
(if (exists "NcodeR.info")
  (copyfiles
    (source "NcodeR.info")
    (dest whereprg)
    (optional "nofail")
  )
)
(tooltype
  (dest (tackon whereprg "NcodeR"))
  (setstack 30000)
  (noposition)
)
(copyfiles
  (source ncode)
  (dest "T:")
  (newname "Ncode")
  (optional "nofail")
)
(if (= burnit 1)
  (
    (copyfiles
      (source "EncodeMP3")
      (dest "T:")
      (optional "nofail")
    )
    (copyfiles
      (source "EncodeMP3.elf")
      (dest "T:")
      (optional "nofail")
    )
  )
)
(working #serial)
(complete 50)
(if (= (exists "Register") 1)
  (run "Register")
)
(copyfiles
  (source "T:Ncode")
  (dest whereprg)
  (newname "Ncode")
  (optional "nofail")
)
(if (= burnit 1)
  (
    (copyfiles
      (source "T:EncodeMP3")
      (dest (tackon wherebit "Operators"))
      (newname "EncodeMP3")
      (optional "nofail")
    )
    (copyfiles
      (source "T:EncodeMP3.elf")
      (dest (tackon wherebit "Operators/PPC"))
      (newname "EncodeMP3.elf")
      (optional "nofail")
    )
  )
)
(if (= (exists "T:Ncode") 1)
  (delete "T:Ncode")
)
(if (= burnit 1)
  (
    (if (= (exists "T:EncodeMP3") 1)
      (delete "T:EncodeMP3")
    )
    (if (= (exists "T:EncodeMP3.elf") 1)
      (delete "T:EncodeMP3.elf")
    )
  )
)
(if (exists "StopNcodeR")
  (copyfiles
    (source "StopNcodeR")
    (dest whereprg)
    (infos)
    (optional "nofail")
  )
)
(complete 60)


;*** install skins ***
(set skins
  (askbool
    (prompt #skins)
    (help #skins)
    (default 1)
    (choices #yes #no)
  )
)
(complete 70)
(if (= skins 1)
  (
    (set skin
      (askoptions
        (choices #boing #fantastic #fractal #jesus #mechanic #redplus #standard #subwar)
        (prompt #skin)
        (help #skin)
        (default 127)
      )
    )
    (set defskin -1)
    (if (in skin 7)
      (
        (if (= (exists (tackon whereprg #subwar)) 0)
          (copyfiles
            (source #subwar)
            (dest (tackon whereprg #subwar))
            (all)
          )
        )
        (set defskin 7)
      )
    )
    (if (in skin 6)
      (
        (if (= (exists (tackon whereprg #standard)) 0)
          (copyfiles
            (source #standard)
            (dest (tackon whereprg #standard))
            (all)
          )
        )
        (set defskin 6)
      )
    )
    (if (in skin 5)
      (
        (if (= (exists (tackon whereprg #redplus)) 0)
          (copyfiles
            (source #redplus)
            (dest (tackon whereprg #redplus))
            (all)
          )
        )
        (set defskin 5)
      )
    )
    (if (in skin 4)
      (
        (if (= (exists (tackon whereprg #mechanic)) 0)
          (copyfiles
            (source #mechanic)
            (dest (tackon whereprg #mechanic))
            (all)
          )
        )
        (set defskin 4)
      )
    )
    (if (in skin 3)
      (
        (if (= (exists (tackon whereprg #jesus)) 0)
          (copyfiles
            (source #jesus)
            (dest (tackon whereprg #jesus))
            (all)
          )
        )
        (set defskin 3)
      )
    )
    (if (in skin 2)
      (
        (if (= (exists (tackon whereprg #fractal)) 0)
          (copyfiles
            (source #fractal)
            (dest (tackon whereprg #fractal))
            (all)
          )
        )
        (set defskin 2)
      )
    )
    (if (in skin 1)
      (
        (if (= (exists (tackon whereprg #fantastic)) 0)
          (copyfiles
            (source #fantastic)
            (dest (tackon whereprg #fantastic))
            (all)
          )
        )
        (set defskin 1)
      )
    )
    (if (in skin 0)
      (
        (if (= (exists (tackon whereprg #boing)) 0)
          (copyfiles
            (source #boing)
            (dest (tackon whereprg #boing))
            (all)
          )
        )
        (set defskin 0)
      )
    )
    (if (> defskin -1)
      (
        (set defskin
          (askchoice
            (choices #boing #fantastic #fractal #jesus #mechanic #redplus #standard #subwar)
            (prompt #defskin)
            (help #defskin)
            (default defskin)
          )
        )
        (if (= defskin 0)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #boing)
            (noposition)
          )
        )
        (if (= defskin 1)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #fantastic)
            (noposition)
          )
        )
        (if (= defskin 2)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #fractal)
            (noposition)
          )
        )
        (if (= defskin 3)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #jesus)
            (noposition)
          )
        )
        (if (= defskin 4)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #mechanic)
            (noposition)
          )
        )
        (if (= defskin 5)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #redplus)
            (noposition)
          )
        )
        (if (= defskin 6)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #standard)
            (noposition)
          )
        )
        (if (= defskin 7)
          (tooltype
            (dest (tackon whereprg "NcodeR"))
            (settooltype "SKIN" #subwar)
            (noposition)
          )
        )
      )
    )
  )
)
(complete 80)


;*** set default directories ***
(set sourcedir
  (askdir
    (prompt #sourcedir)
    (help #sourcedir)
    (default "Work:")
  )
)
(tooltype
  (dest (tackon whereprg "NcodeR"))
  (settooltype "SOURCE" sourcedir)
  (noposition)
)
(complete 90)
(set targetdir
  (askdir
    (prompt #targetdir)
    (help #targetdir)
    (default "Work:")
  )
)
(tooltype
  (dest (tackon whereprg "NcodeR"))
  (settooltype "TARGET" targetdir)
  (noposition)
)
(complete 100)


;*** exit ***
(set @default-dest whereprg)
(exit #byebye)
