; Install script for Plugged

(set Need3 "\nPlugged need at least OS3.0")
(if (< (/ (getversion) 65536) 39)
  (abort Need3)
)

(set CatHelp "You can have plugged localized to a particular language.")
(set POPKEYHelp "With this hotkey you can popup plugged main window.")
(set PROGKEYHelp "With this hotkey you can open the program window.")
(set EDITKEYHelp "With this hotkey you can open the Edit CD window.")
(set CTRKEYHelp "With this hotkey you can open the control panel.")
(set ASKDIRHelp "If you install Plugged in SYS:WBStartup (default), it will be launched automatically at every startup.\nIf you want only to test Plugged, copy it in another place, changing the destination directory")
(set GUIDEHelp "This is the doc of Plugged in .guide format")
(set CONVERTHelp "Plugged uses a format to save CD infos different from the one used by MCDPlayer.\nIf you have several CD defined in MCDPlayer, you would like to convert them in Plugged format.\nIn this case, simply select the directory where all these file are stored and they will be converted automatically.")

(set MySou (pathonly @icon) )

(set vernum (getversion (tackon MySou "Plugged") ) )
(set ver (/ vernum 65536))
(set rev (- vernum (* ver 65536) ) )
(set Vers (cat ver "." rev))

(welcome)

(message (cat "Welcome to Plugged " Vers ) " Installer script\n\n\n\nŠ 1996 R.Ferorelli")

(set CompleteDest
   (askdir
      (prompt "\nSelect a path where to install Plugged main file")
      (help ASKDIRHelp)
      (default "SYS:WBStartup")
   )
)

(copyfiles
   (prompt "Coping Plugged")
   (source MySou)
   (infos)
   (dest CompleteDest)
   (choices "Plugged")
)

; Guide file.
; *************************
(set GuideDest
   (askdir
      (prompt "\nSelect a directory where to install Plugged.guide file.\n")
      (help @askdir-help)
      (default "AMIGAGUIDE:")
   )
)
(copyfiles
   (prompt "Coping Plugged.guide")
   (help GUIDEHelp)
   (source MySou)
   (infos)
   (dest GuideDest)
   (confirm)
   (choices "Plugged.guide")
)

(set LangBit
   (askoptions
      (prompt "\nDo yo want to install languages")
      (help CatHelp)
      (choices "italiano")
      (default 1)
   )
)
(if (IN LangBit 0)
   (copyfiles
      (prompt "Coping the catalog 'italiano'")
      (help @copyfiles-help)
      (source (tackon MySou "catalogs/italiano/plugged.catalog") )
      (dest "locale:catalogs/italiano/")
   )
)

(set DestName (tackon CompleteDest "Plugged"))

(Set Hotkey (askstring
            (prompt "Insert Hotkey for Main interface popup")
            (default "control shift c")
            (help POPKEYHelp)
        )
)
(tooltype
   (settooltype "CX_POPKEY" HotKey)
   (dest DestName)
)

(Set Progkey (askstring
            (prompt "Insert Hotkey for program window popup")
            (default "control shift p")
            (help PROGKEYHelp)
        )
)
(tooltype
   (settooltype "PROGKEY" ProgKey)
   (dest DestName)
)

(Set Editkey (askstring
            (prompt "Insert Hotkey for Edit window popup")
            (default "control shift e")
            (help EDITKEYHelp)
        )
)
(tooltype
   (settooltype "EDITKEY" EditKey)
   (dest DestName)
)

(Set Ctrkey (askstring
            (prompt "Insert Hotkey for control panel popup")
            (default "control shift d")
            (help CTRKEYHelp)
        )
)
(tooltype
   (settooltype "CTRKEY" CtrKey)
   (dest DestName)
)

(set POPBit
   (askbool
      (prompt "\nDo you want interface window to popup at startup?")
      (help "This affects the CX_POPUP tooltype.")
      (default 0)
   )
)

(if (= POPBit 1)
   (tooltype
      (settooltype "CX_POPUP" "YES")
      (dest DestName)
   )
)

(if (= POPBit 0)
   (tooltype
      (settooltype "CX_POPUP" "NO")
      (dest DestName)
   )
)

(set Direct
   (askdir
      (prompt "\nSelect a path. A directory called SONGS will be created here.\n(The CD description will be stored here.)")
      (help DIRHelp)
      (default "SYS:")
   )
)

(makedir (tackon Direct "SONGS") (infos))

(tooltype
   (settooltype "DIRECTORY" (tackon Direct "SONGS"))
   (dest DestName)
)

(set ConvertBit
   (askbool
      (prompt "\nDo you want to convert MCDPlayer CDs to Plugged format?")
      (help CONVERTHelp)
      (default 0)
   )
)

(if (= ConvertBit 1)
   (
      (set MCDPDir
         (askdir
            (prompt "\nSelect the directory where all the MCDPlayer CDs are stored.")
            (help CONVERTHelp)
            (default "SYS:")
         )
      )
      (set Cmd
         (cat (tackon MySou "MCDP2Plugged ") MCDPDir " " (tackon Direct "SONGS"))
      )
      (run Cmd
         (prompt "Converting files...")
         (help "None")
      )
   )
)

(set CopySongsBit
   (askbool
      (prompt "\nDo you want to install some CD description?")
      (help "These description includes disk from:\nAlanis Morrisette,The Cure,Offspring,Nirvana,R.E.M.,Litfiba,Pino Daniele,De Gregori,Run DMC,Madredeus,Pink Floyd")
      (default 0)
   )
)

(if (= CopySongsBit 1)
   (
      (copyfiles
         (prompt "Coping CD descriptions")
         (help @copyfiles-help)
         (source (tackon MySou "Songs"))
         (all)
         (dest (tackon Direct "SONGS"))
      )
   )
)

(message "You can run the program and change other parameters directly in it.\nPlease read documentation for other options")

(set @default-dest CompleteDest )
        (exit)

