;   -----------------------------
;       Install BancaBase
;   -----------------------------
;   Description:
;
;   Commodore Installer Script for BancaBase 1.3a
;   $VER: 1.02 (c) 1997 by Stefano Dardari

; some useful variables
	(set 
		newline 		"\n"
		#bbprogname 	"BancaBase13a.lha"
        #bb3-path       "BancaBase/"
        #catalogsname   "catalogs/"
        #docsname       "docs/"
        #examplename    "examples.lha"
		#patternsname 	"Patterns.lha"
        #soundsname     "Sounds.lha"
        #registername   "Register.lha"
        #bb3-dest       "SYS:"
        #bb3-key        "BBase.key"
        #bb3-prefs      "BancaBase.prefs"
        #bb3-readme     "ReadMe.doc"
        #bb3-readme-ita "Leggimi.doc"
        #bb3-icon-MWB   "Icons/MagicWB/"
        #bb3-icon-NI    "Icons/NewIcon/"
        #bb3-icon-STD   "Icons/Standard/"
        #STDTYPE        0
        #NITYPE         1
        #MWBTYPE        2
        #iconpattern    "#?.info"
        #bb3-lang-eng   "english"
        #bb3-lang-deu   "deutsch"
        #bb3-lang-ita   "italiano"
        #bb3-lang-fra   "français"
        #bb3-lang-rus   "russian"
        #ENG            0
        #DEU            1
        #ITA            2
        #FRA            3
        #RUS            4
	)

; some strings
(set #omp (cat "One moment please..." newline))

(set #installtext (cat "Welcome to the BancaBase installation script.\n\nBancaBase3 V 1.3a (C) 1997 by Stefano Dardari\n\nAll rights reserved"))
(set #BB3dest-prompt "Please select the directory where you want the BancaBase drawer installed.\n(See help for details)")
(set #BB3dest-help (cat "Select the desidered disk/directory were install the program.\nA drawer named BancaBase will be created."))
(set #BB3lang-prompt "Select desired language (from availables) that program must use for menus and gadgets.")
(set #BB3lang-help "Selecting one of the listed languages, corresponding catalogs files will be copied. If the selected languages is ENGLISH, no files are copied, because it's the default built-in language.")
(set #BB3docs-prompt "Select desired language (from avaialbes) for the documentation amiga guide format files.")
(set #BB3docs-help "It's possible to select the language (from listed) for the documentation files. If you don't found your language translation install the English version now, but write to the author.")
(set #BB3patt-prompt "\n\n\nDo you want to install some pretty patterns to use with the GUI ?\nNOTE: you can use it, only with an WorkBench 3.0 or better.")
(set #BB3patt-help (cat "The backdrop patterns are to be considere as add-on.\nBancaBase work well also without them, but are very nice if used with the program's GUI.\n\nNote that program uses the Datatypes to load picture files\nso if you don't have an V39 (or better) kickstart ... choose the NO gadget."))
(set #BB3end (cat "Installation complete. Read the readme file before start."))
(set #BB3icon-prompt "\nSelect from available the ICON set to install :")
(set #BB3icon-help "Select desired type of icon-set to install for BancaBase and all the tools.\nIf for example your WorkBench use the MagicWB icons, you must select MagicWB.\nSame thing for the other types.")
(set #copyng-icon-prompt "Please wait ... icon installation running.")

(welcome #installtext)

(procedure set_icon
   (set #def-icon
      (askchoice
         (prompt #BB3icon-prompt)
         (help   #bb3icon-help)
         (choices "Standard Icon" "NewIcon Icon" "MagicWB Icon")
         (default 0)
      )
   )
)

(procedure set_lang_catalogs
   (set #def-lang
      (askchoice
         (prompt #BB3lang-prompt)
         (help   #bb3lang-help)
         (choices "English (built in)" "Deutsch" "Italiano" "Français" "Russian")
         (default #ENG)
      )
   )
)

(procedure set_lang_docs
    (if (> #def-lang #ITA)
        (set #def-lang #ENG)
    )
   (set #def-lang
      (askchoice
         (prompt #BB3docs-prompt)
         (help   #bb3docs-help)
         (choices "English" "Deutsch" "Italiano")
         (default #def-lang)
      )
   )
)

(procedure set_dir
   (set #bb3-dest
      (askdir
         (prompt #BB3dest-prompt)
         (help #BB3dest-help)
         (default #bb3-dest)
         (newpath)
      )
   )
)

(set_dir)
(set #dest-path (tackon #bb3-dest #bb3-path))
(set @default-dest #dest-path)


(if (exists #dest-path (noreq))
   (
      (set #file-exist (cat "Sorry but directory " #dest-path " already exist.\nPlease select a different destination .\n"))
      (message #file-exist)
      (set_dir)
      (set #dest-path (tackon #bb3-dest #bb3-path))
      (set @default-dest #dest-path)
   )
)

(makedir #dest-path (infos))

(working #omp "UnPacking and coping program files.")

(run "lha -x x "#bbprogname" "#dest-path)

(complete 20)

(if (exists #examplename (noreq))
       (
          (working #omp "Unpacking and coping example files.")
          (run "lha -x x "#examplename" "#dest-path )
       )
)


(complete 30)
(set_lang_catalogs)
(if (= #def-lang #ENG)
    (set #lang #bb3-lang-eng)
    )
(if (= #def-lang #DEU)
    (set #lang #bb3-lang-deu)
    )
(if (= #def-lang #ITA)
    (set #lang #bb3-lang-ita)
    )
(if (= #def-lang #FRA)
    (set #lang #bb3-lang-fra)
    )
(if (= #def-lang #RUS)
    (set #lang #bb3-lang-rus)
    )

(set #src-path (tackon "Catalogs" #lang))
(set #src-path (cat #src-path ".lha"))
(set #dst-path (tackon #dest-path #catalogsname))

(if (exists #src-path (noreq))
       (
          (makedir (cat #dest-path #catalogsname) (infos))
          (working #omp "Unpacking and coping localized catalog files.")
          (run "lha -x x "#src-path" "#dst-path )
          (if (exists (cat #catalogsname "BancaBase.cd"))
             (copyfiles
          		(source (cat #catalogsname "BancaBase.cd"))
    		    (dest #dst-path)
                (files)
	          )
          )        
          (if (exists (cat #catalogsname "SDBase.cd"))
             (copyfiles
                (source (cat #catalogsname "SDBase.cd"))
    	        (dest #dst-path)
                (files)
             )
	      )

       )
)

(complete 40)

(set_lang_docs)
(if (= #def-lang #ENG)
    (set #lang #bb3-lang-eng)
    )
(if (= #def-lang #DEU)
    (set #lang #bb3-lang-deu)
    )
(if (= #def-lang #ITA)
    (set #lang #bb3-lang-ita)
    )

(set #src-path (tackon "Docs" #lang))
(set #src-path (cat #src-path ".lha"))
(set #dst-path (tackon #dest-path #docsname))

(if (exists #src-path (noreq))
       (
          (makedir (cat #dest-path #docsname) (infos))
          (working #omp "Unpacking and coping documentation files.")
          (run "lha -x x "#src-path" "#dst-path )
       )
)


(complete 50)
(if (exists #registername (noreq))
       (
          (working #omp "Unpacking and coping registration docs files.")
          (run "lha -x x "#registername" "#dest-path )
       )
)

(if (exists #bb3-readme (noreq))
	(copyfiles
        (prompt #omp "Coping information files.")
		(source #bb3-readme)
		(dest #dest-path)
        (files)
	)
)

(complete 60)
(if (exists #patternsname (noreq))
   (
      (if (askbool (prompt #BB3patt-prompt) (help #BB3patt-help) (default 1))
          (
             (working #omp "UnPacking and coping patterns files.")
             (run "lha -x x "#patternsname" "#dest-path )
          )
      )
   )
)

(complete 70)
(set_icon)
(if (= #def-icon #STDTYPE)
    (set #src-icon #bb3-icon-STD)
    )
(if (= #def-icon #NITYPE)
    (set #src-icon #bb3-icon-NI)
    )
(if (= #def-icon #MWBTYPE)
    (set #src-icon #bb3-icon-MWB)
    )

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-icon)
   (dest  #dest-path)
   (pattern #iconpattern)
   (noposition)
)

(set #src-path (tackon #src-icon "Docs"))
(set #dst-path (tackon #dest-path "Docs"))

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-path)
   (dest  #dst-path)
   (all)
   (noposition)
)

(set #src-path (tackon #src-icon "Register"))
(set #dst-path (tackon #dest-path "Register"))

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-path)
   (dest  #dst-path)
   (all)
   (noposition)
)

(complete 80)

(if (exists #soundsname (noreq))
       (
          (working #omp "UnPacking and coping sound files.")
          (run "lha -x x "#soundsname" "#dest-path )
       )
)


(complete 90)

(if (exists #bb3-prefs (noreq))
	(copyfiles
        (prompt #omp "Coping prefs file.")
		(source #bb3-prefs)
		(dest #dest-path)
        (files)
	)
)

(if (exists #bb3-key (noreq))
	(copyfiles
        (prompt #omp "Coping the KeyFile.")
		(source #bb3-key)
		(dest #dest-path)
        (files)
	)
)

(complete 100)


; The last message
	(set end_text (cat "Hope you like BancaBase!\n"
                   "Don't hesitate to send me comments, bugreports and suggestions.\n\n"
                   "Registrations are also WELCOME !!!! :))"))

; the end
(set @default-dest #dest-path)
    (exit end_text)
;EOF
