size = { 1230, 142 }

-- initialize component property table
-- slider switchers
defineProperty("switch_17", globalPropertyi("sim/cockpit2/switches/custom_slider_on[0]"))  -- show/hide main menu
defineProperty("retract_rat", globalPropertyi("sim/cockpit2/switches/custom_slider_on[1]")) -- wing retraction ratio
defineProperty("switch_3", globalPropertyi("sim/cockpit2/electrical/generator_on[0]")) -- generator on/off
defineProperty("en_lang", globalPropertyi("sim/cockpit2/switches/custom_slider_on[2]")) -- generator on/off
defineProperty("switch_4", globalPropertyi("sim/cockpit2/electrical/battery_on[1]")) -- battery 2 on/off
defineProperty("switch_5", globalPropertyi("sim/cockpit2/ice/ice_pitot_heat_on_pilot")) -- pitot on/off
defineProperty("switch_6", globalPropertyi("sim/cockpit2/switches/custom_slider_on[4]")) -- touch panel
defineProperty("switch_7", globalPropertyi("sim/cockpit/electrical/landing_lights_on")) -- land lights on/off
defineProperty("switch_8", globalPropertyi("sim/cockpit/electrical/beacon_lights_on")) -- beacon lights on/off
defineProperty("switch_9", globalPropertyi("sim/cockpit/electrical/taxi_light_on")) -- taxi lights on/off
defineProperty("strobe", globalPropertyi("sim/cockpit/electrical/strobe_lights_on")) -- taxi lights on/off
defineProperty("switch_10", globalPropertyf("sim/cockpit2/engine/actuators/mixture_ratio[0]")) -- engine 1 mixture for cut-off
defineProperty("switch_11", globalPropertyf("sim/cockpit2/engine/actuators/mixture_ratio[1]")) -- engine 2 mixture for cut-off
defineProperty("switch_12", globalPropertyi("sim/cockpit2/ice/ice_all_on")) -- de-icer all systems on/off
defineProperty("switch_14", globalPropertyi("sim/cockpit/engine/fuel_tank_selector")) -- fuel_selector
defineProperty("switch_15", globalPropertyi("sim/cockpit/engine/ignition_on[0]")) -- ignition 1 selector
defineProperty("switch_16", globalPropertyi("sim/cockpit/engine/ignition_on[1]")) -- ignition 2 selector
defineProperty("switch_19", globalPropertyi("sim/cockpit2/engine/actuators/fire_extinguisher_on[0]")) -- extinguisher left
defineProperty("switch_18", globalPropertyi("sim/cockpit2/engine/actuators/fire_extinguisher_on[1]")) -- extinguisher right
defineProperty("pilot_hide", globalPropertyf("sim/cockpit2/switches/custom_slider_on[3]")) -- avionics power switch
defineProperty("floats", globalPropertyf("sim/cockpit2/controls/speedbrake_ratio")) -- floats position

defineProperty("hydropump", globalPropertyi("sim/cockpit2/switches/electric_hydraulic_pump_on")) -- hydraulic pump

defineProperty("wave_limit_n", globalPropertyi("sim/custom/xap/wave_limit_n")) -- wave limit value
defineProperty("post_effect", globalPropertyi("sim/custom/xap/post_effect")) -- post effect
defineProperty("position_saving", globalPropertyi("sim/custom/xap/position_saving")) -- position saving

starter_1 = findCommand("sim/starters/engage_starter_1")  -- simulator command for starter 1
starter_2 = findCommand("sim/starters/engage_starter_2")  -- simulator command for starter 2
white_smoke = findCommand("sim/flight_controls/smoke_toggle")

-- images
defineProperty("background", loadImage("switches_panel.png"))  -- background image

-- get panels for manipulate them
defineProperty("panel_1")

defineProperty("p2_sw_off", loadImage("p2_switch.png", 0, 0, 64, 64))
defineProperty("p2_sw_on", loadImage("p2_switch.png", 64, 0, 64, 64))

defineProperty("st_sw_off", loadImage("starter_button.png", 0, 0, 64, 64))
defineProperty("st_sw_on", loadImage("starter_button.png", 64, 0, 64, 64))

defineProperty("roll_1", loadImage("selector.png", 0, 0, 64, 64))
defineProperty("roll_2", loadImage("selector.png", 64, 0, 64, 64))
defineProperty("roll_3", loadImage("selector.png", 128, 0, 64, 64))
defineProperty("roll_4", loadImage("selector.png", 192, 0, 64, 64))

defineProperty("roll2_1", loadImage("selector_2.png", 0, 0, 64, 64))
defineProperty("roll2_2", loadImage("selector_2.png", 64, 0, 64, 64))
defineProperty("roll2_3", loadImage("selector_2.png", 128, 0, 64, 64))
defineProperty("roll2_4", loadImage("selector_2.png", 192, 0, 64, 64))

-- Switches menu components
components = {
    -- background rectangle
--	rectangle {
--		 position = { 0, 0, 1230, 142 },
--		 color = {0.1, 0.1, 0.1, 0.4},
--		 };
-- background image
		textureLit {
		 position = {  0, 0, 1230, 142 },
		 image = get(background),
		 };

-- post effect off -----------------------------------------
    textureLit { 
        position = { 1118, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(post_effect) < 0.5
		end
    },

-- post effect on
    textureLit { 
        position = { 1118, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(post_effect) > 0.5
		end
    },

-- position saving off -----------------------------------------
    textureLit { 
        position = { 988, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(position_saving) < 0.5
		end
    },

-- position saving on
    textureLit { 
        position = { 988, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(position_saving) > 0.5
		end
    },

    
-- green retr wings image-----------------------------------------
    textureLit { 
        position = { 24, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(retract_rat) < 0.5
		end
    },

-- red retr wings image
    textureLit { 
        position = { 24, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(retract_rat) > 0.5
		end
    },


-- pilot hide on -----------------------------------------
    textureLit { 
        position = { 128, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(pilot_hide) < 0.5
		end
    },

-- pilot hide off
    textureLit { 
        position = { 128, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(pilot_hide) > 0.5
		end
    },

-- language en on -----------------------------------------
    textureLit { 
        position = { 328, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(en_lang) < 0.5
		end
    },

-- language en off
    textureLit { 
        position = { 328, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(en_lang) > 0.5
		end
    },

-- green  touch panel -----------------------------------------
    textureLit { 
        position = { 232, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(switch_6) < 0.5
		end
    },

-- red  touch panel
    textureLit { 
        position = { 232, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(switch_6) > 0.5
		end
    },   
   
-- green  touch panel -----------------------------------------
    textureLit { 
        position = { 232, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(switch_6) < 0.5
		end
    },

-- red  touch panel
    textureLit { 
        position = { 232, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(switch_6) > 0.5
		end
    },   
   

-- green switch_10 image-----------------------------------------
    textureLit { 
        position = { 460, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(switch_10) < 0.1
		end
    },

-- red switch_10 image
    textureLit { 
        position = { 460, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(switch_10) > 0.1
		end
    },     

-- starter 1 image
	 textureLit { 
        position = { 702, 30, 64, 64 },
        image = get(st_sw_off),
	 },


---------------------------------------------------------------

------------------------------------------------------------------------
-- switch_15 1 image-----------------------------------------
    textureLit { 
        position = { 590, 28, 64, 64 },
        image = get(roll2_1),
		visible = function()
			return get(switch_15) == 0
		end
    },

    -- switch_15 2 image-----------------------------------------
    textureLit { 
        position = { 590, 28, 64, 64 },
        image = get(roll2_2),
		visible = function()
			return get(switch_15) == 1
		end
    },

        -- switch_15 3 image-----------------------------------------
    textureLit { 
        position = { 590, 28, 64, 64 },
        image = get(roll2_3),
		visible = function()
			return get(switch_15) == 2
		end
    },

            -- switch_15 4 image-----------------------------------------
    textureLit { 
        position = { 590, 28, 64, 64 },
        image = get(roll2_4),
		visible = function()
			return get(switch_15) == 3
		end
    },
------------------------------------------------------------------

 

-- green wave_limit image
    textureLit { 
        position = { 855, 30, 64, 64 },
        image = get(p2_sw_on),
		visible = function()
			return get(wave_limit_n) > 0.5
		end
    },

-- red wave_limit image
    textureLit { 
        position = { 855, 30, 64, 64 },
        image = get(p2_sw_off),
		visible = function()
			return get(wave_limit_n) < 0.5
		end
    }, 






   
   -- clickable area for closing main menu
    clickable {
       position = { 1210, 122, 22, 22 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        set(switch_17, 0 )
        return true
        end
    },   

     
    
    -- clickable area for switch_2
    clickable {
       position = { 36, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(retract_rat) == 0 then set(retract_rat, 1)
           else set(retract_rat, 0)
        end
        return true
        end
    },   


     -- clickable area for hide pilot
    clickable {
       position = { 143, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(pilot_hide) == 0 then set(pilot_hide, 1)
           else set(pilot_hide, 0)
        end
        return true
        end
    }, 


     -- clickable area for touch panel
    clickable {
       position = { 245, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(switch_6) == 0 then set(switch_6, 1)
           else set(switch_6, 0)
        end
        return true
        end
    }, 

     -- clickable area for language en
    clickable {
       position = { 335, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(en_lang) == 0 then set(en_lang, 1)
           else set(en_lang, 0)
        end
        return true
        end
    }, 


-- clickable area for switch_10
    clickable {
       position = { 475, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(switch_10) == 0 then set(switch_10, 1)
           else set(switch_10, 0)
        end
        return true
        end
    }, 


-- clickable area for starter 1
    clickable {
       position = { 712, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        commandOnce(starter_1)
        return true
        end
    }, 



---------------------------------------------------------------

-- clickable area for switch_15
    clickable {
       position = { 600, 45, 32, 32 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 16, 
            height = 16, 
            shape = loadImage("rotateleft.png")
        },  
        
        onMouseClick = function(x, y, button) 
	set(switch_15, get(switch_15) - 1)
		if get(switch_15) < 0 then 
			set(switch_15, 0)
		end
		if get(switch_15) > 3 then 
			set(switch_15, 3)
		end	
            return true
        end
    },

    clickable {
       position = { 619, 45, 32, 32 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 16, 
            height = 16, 
            shape = loadImage("rotateright.png")
        },  
        
        onMouseClick = function(x, y, button) 
	set(switch_15, get(switch_15) + 1)
		if get(switch_15) < 0 then 
			set(switch_15, 0)
		end
		if get(switch_15) > 3 then 
			set(switch_15, 3)
		end	    
		return true
        end
    },  
---------------------------------------------------------------

---------------------------------------------------------------


    -- clickable area for wave limit
    clickable {
       position = { 867, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(wave_limit_n) == 0 then set(wave_limit_n, 1)
           else set(wave_limit_n, 0)
        end
        return true
        end
    }, 

    -- clickable area for post effect
    clickable {
       position = { 1133, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(post_effect) == 0 then set(post_effect, 1)
           else set(post_effect, 0)
        end
        return true
        end
    }, 

    -- clickable area for position saving
    clickable {
       position = { 1003, 45, 34, 34 },
        
       cursor = { 
            x = 0, 
            y = 0, 
            width = 32, 
            height = 16, 
            shape = loadImage("clickable.png")
        },  
        
        onMouseClick = function()
        if get(position_saving) == 0 then set(position_saving, 1)
           else set(position_saving, 0)
        end
        return true
        end
    }, 
        

}
