;**********************************************************
;
;    Installation script for Misc v1.0
;       v0.9
;
;  AMINET-STUFF: MAGICWB / SMALLBENCH
;
;**********************************************************

;************
; PROCEDURES
;************

(procedure choosestuff
    (
        (set @default-dest
            (askdir
                (prompt "Choose directory where you would like to place the Misc-executable.\n The Installer will NOT create a directory.")
                (help @askdir-help)
                (default @default-dest)
            )
        )
        (set docdir
            (askdir
                (prompt "Choose directory where you would like to place the Misc documentation\n Again, no directory will be created!")
                (help @askdir-help)
                (default @default-dest)
            )
        )
        (if
            (askbool
                (prompt "Misc requires Textfield.gadget to run, it must be installed in the `sys:classes/gadgets' - drawer.\nIf there's a newer version already installed, it won't be overwritten.\n\nIs this OK?")
                (help "Misc uses Textfield.gadget for editing files in. The Textfield.gadget is included in the package and it can be installed for you now.\nThe version to be installed is version 3.1, if there is a newer version it won't be overwritten.\nFor information on how to use the Textfield.gadget, please read the documentation!\n\n It will be installed in `sys:classes/gadgets'.")
                (default 1)
            )
            (set copygadget "to\n`sys:classes/gadgets'")
            (set copygadget "won't be installed.")
        )
        (set icons
            (askchoice
                (prompt "What type of Icons would you like to have installed?")
                (help "You should choose what type of Icons you would like to have installed for your programs. The choices are:\n\n MagicWB - Default. Icons using the MagicWB-standard by Martin Huttenloher.\n\n Smallbench - MagicWB-style icons for screenmodes with a pixel aspect ratio of 1:2, e.g. High Res NoLace. By Tom Oszczepalski & Paul Henrik.\n\n Normal Workbench icons - These are the standard AmigaOS2-look icons. They suck!")
                (choices "MagicWB" "Smallbench (NoLace)" "Normal Workbench icons")
            )
        )
        (if
            (= icons 0)
            (set icontype "MagicWB")
        )
        (if
            (= icons 1)
            (set icontype "Smallbench")
        )
        (if
            (= icons 2)
            (set icontype "Normal")
        )
        (set putadditional
            (askbool
                (prompt "Would you like to have the Additional Icons installed?\nThese are icons for different ToolManager docks, CircleSoft logos! (YES!) and an Imagedrawer.\nThey will be put in a drawer called `MiscIcons'")
                (help "Here you can choose whether you would like to install some additional icons to the ones necessary to run Misc. They are different ToolManager dockicons (MagicWB, TMTM (TinyMiniToolManager), KMI...). And some CircleSoft logos (We don't know what you would do with this, but our ego forces us to include this with the archive. Plus an Imagedrawer in case you would like to have Misc in an own drawer.")
            )
        )
        (if (= putadditional 1)
            (set iconsdir
                (askdir
                    (prompt "Choose directory where you would like to install the additional Icons. A drawer called `MiscIcons' will be created.")
                    (help @askdir-help)
                    (default @default-dest)
                )
            )
        )
    )
)


;********
;  MAIN
;********

; *****************************
;  Check for correct OS (2.0+)
; *****************************

(if (< (/ (getversion) 65536) 37)
    (abort
        "Misc requires at least AmigaOS v2.0."
    )
)

; *****************************
;  Choose where&what to install
; *****************************

(choosestuff)

(until
    (askbool
        (prompt ("These files will now be copied:\n\n The Misc executable to:\n`%s'\nThe Misc documentation to:\n`%s'\nThe Textfield.gadget %s\n\nAnd you have chosen the %s icons.\n\n Is this OK?" @default-dest docdir copygadget icontype))
        (help "If you click on \"Copy Files\", the files will be copied into the directories of your choice. And if you click on \"Choose again\", you can correct eventual mistakes.")
        (choices "Copy Files" "Choose again")
    )
    (choosestuff)
)

(copyfiles
    (prompt "The executable")
    (source "Misc")
    (dest @default-dest)
)
(copyfiles
    (prompt "The executable icon")
    (source ("Icons/%s/Misc.info" icontype))
    (dest @default-dest)
)
(copyfiles
    (prompt "The documentation")
    (source "Misc.guide")
    (dest docdir)
)
(copyfiles
    (prompt "The Documentation icon")
    (source ("Icons/%s/Misc.guide.info" icontype))
    (dest @default-dest)
)
(if (= copygadget "to\n\n sys:classes/gadgets")
    (
        (copyfiles
            (prompt "Textfield.gadget Docs")
            (source "Docs/Textfield.DOC")
            (dest docdir)
            (infos)
        )
        (copylib
            (prompt "Textfield.gadget")
            (source "Textfield.gadget")
            (dest "sys:classes/gadgets")
        )
        (message "Please read the file `Textfield.DOC'")
    )
)
(if (= putadditional 1)
    (copyfiles
        (prompt "Additional Icons")
        (source "Icons/Additional")
        (dest (tackon iconsdir "MiscIcons"))
        (all)
    )
)
