/*
 * Applications.fx
 *
 * Created on Nov 30, 2009, 7:31:48 PM
 */
package mdot_gui;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.layout.HBox;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.control.Slider;
import javafx.scene.layout.VBox;

/**
 * @author Jamie Lynn
 */
public def subscenelist = [PoliceCar { }, Ambulance { }, FireTruck { }, TowTruck { }, SchoolBus { },
            ConstructionZone { }, Pedestrian { }, CarbonEmissions { }, AdvisoryAlert { }, Gov20 { },
            Configuration { }, LocalWeather { }, Fuel { }, ControlPanel { }, Wallet { }];
public var btnPolice: ApplicationButton;
public var btnAmbulance: ApplicationButton;
public var btnFireTruck: ApplicationButton;
public var btnSchoolBus: ApplicationButton;
public var btnPedestrians: ApplicationButton;
public var btnTowTruck: ApplicationButton;
public var btnConstruction: ApplicationButton;
public var btnCarbon: ApplicationButton;
public var btnWallet: ApplicationButton;
public var btnAlert: ApplicationButton;
public var btnGov: ApplicationButton;
public var btnGauge: ApplicationButton;
public var btnConfig: ApplicationButton;
public var btnWeather: ApplicationButton;
public var btnFuel: ApplicationButton;
public var qualityOfRide: ApplicationButton;
public var driverRestriction = [];
public var engineRestriction = [];
public var grp1: Group;

public class Applications extends CustomNode {

    override var visible = false on replace {
                if (visible == true) {
                    Reset();
                }
            };
    var slider: Slider;

    public override function create(): Node {
        visible = false;
        id = "Applications";
        grp1 = Group {
            translateY: bind 0 - slider.value * 30
            translateX: (Constants.WINDOW_WIDTH / 2) - (Constants.APPLICATION_WIDTH / 2);
            content: [
                Rectangle { width: Constants.APPLICATION_WIDTH;
                    height: Constants.APPLICATION_HEIGHT;
                    fill: Color.BLACK }
                VBox {
                    spacing: 2
                    content: [
                        HBox {
                            spacing: 2
                            content: [
                                btnPolice = ApplicationButton {
                                    index: 0
                                    displayimage: CommonFunctionsFX.getImage("police_lg");
                                }
                                btnAmbulance = ApplicationButton {
                                    index: 1
                                    displayimage: CommonFunctionsFX.getImage("ambulance_lg");
                                }
                                btnFireTruck = ApplicationButton {
                                    index: 2
                                    displayimage: CommonFunctionsFX.getImage("fire_lg");
                                }
                                btnTowTruck = ApplicationButton {
                                    index: 3
                                    displayimage: CommonFunctionsFX.getImage("tow_lg");
                                }
                                btnSchoolBus = ApplicationButton {
                                    index: 4
                                    displayimage: CommonFunctionsFX.getImage("schoolstop_lg");
                                }
                            ]
                        }
                        HBox {
                            spacing: 2
                            content: [
                                btnConstruction = ApplicationButton {
                                    index: 5
                                    displayimage: CommonFunctionsFX.getImage("construction_lg");
                                }
                                btnPedestrians = ApplicationButton {
                                    index: 6
                                    displayimage: CommonFunctionsFX.getImage("pedestrian_lg");
                                }
                                btnCarbon = ApplicationButton {
                                    index: 7
                                    displayimage: CommonFunctionsFX.getImage("leaf_lg");
                                }
                                btnAlert = ApplicationButton {
                                    index: 8
                                    displayimage: CommonFunctionsFX.getImage("alert_lg");
                                }
                                btnGov = ApplicationButton {
                                    index: 9
                                    displayimage: CommonFunctionsFX.getImage("gov20_lg");
                                }
                            ]
                        }
                        HBox {
                            spacing: 2
                            content: [
                                btnConfig = ApplicationButton {
                                    index: 10
                                    displayimage: CommonFunctionsFX.getImage("config_lg");
                                }
                                btnWeather = ApplicationButton {
                                    index: 11
                                    displayimage: CommonFunctionsFX.getImage("weather_lg");
                                }
                                btnFuel = ApplicationButton {
                                    index: 12
                                    displayimage: CommonFunctionsFX.getImage("fuel_lg");
                                }
                                btnGauge = ApplicationButton {
                                    index: 13
                                    displayimage: CommonFunctionsFX.getImage("controlpanel_lg");
                                }
                                btnWallet = ApplicationButton {
                                    index: 14
                                    displayimage: CommonFunctionsFX.getImage("wallet_lg");
                                }
                            ]
                        }
                    ]
                }
            ]
        }
        slider = Slider {
            height: Constants.APPLICATION_HEIGHT / 3 + 22
            width: 20
            translateX: 658;
            translateY: 132;
            blockIncrement: 60
            clickToPosition: true
            min: 0
            max: 10
            vertical: true
            scaleX: 2.5
            scaleY: 2.5
        };
        Group {
            content: [
                grp1,
                slider
            ]
        }
    }

    function Reset(): Void {
        //reset the slider to the top
        slider.value = 0;
    }

    //Insert applications that should be restricted based on
    //driver age or engine state here.
    init {

        insert btnFuel into driverRestriction;
        insert btnWeather into driverRestriction;
        insert btnPolice into driverRestriction;
        insert btnAmbulance into driverRestriction;
        insert btnPedestrians into driverRestriction;
        insert btnTowTruck into driverRestriction;
        insert btnSchoolBus into driverRestriction;
        insert btnFireTruck into driverRestriction;
        insert btnConstruction into driverRestriction;
        insert btnCarbon into driverRestriction;
        insert btnGov into driverRestriction;
        insert btnWallet into driverRestriction;


        insert btnFuel into engineRestriction;
        insert btnWeather into engineRestriction;
        insert btnPolice into engineRestriction;
        insert btnAmbulance into engineRestriction;
        insert btnPedestrians into engineRestriction;
        insert btnTowTruck into engineRestriction;
        insert btnSchoolBus into engineRestriction;
        insert btnFireTruck into engineRestriction;
        insert btnConstruction into engineRestriction;
        insert btnCarbon into engineRestriction;
        insert btnGov into engineRestriction;
        insert btnWallet into engineRestriction;
        insert btnConfig into engineRestriction;
        insert btnAlert into engineRestriction;
        insert btnGauge into engineRestriction;


        }

}
