size = { 412, 462 }

defineProperty("prflt_cam_lock", globalPropertyi("cl300/prflt_cam_lock"))
defineProperty("prflt_cam_pos",  globalPropertyi("cl300/prflt_cam_pos")) -- JackZero: New Dataref for the preflight camera position (in order to control preflight via external plugins), reset to 0 once the camera is free to move again
defineProperty("prflt_cam_vis",  globalPropertyi("cl300/prflt_cam_vis")) -- JackZero: New Dataref for the preflight visited positions (for the green bubbles) as a bitmap

defineProperty("gust_lock", globalPropertyf("cl300/gust_lock"))

defineProperty("ext_pr_panel_s", globalPropertyi("cl300/ext_pr_panel_s"))

defineProperty("rembf1", globalPropertyi("cl300/rembf1"))
defineProperty("rembf2", globalPropertyi("cl300/rembf2"))
defineProperty("rembf3", globalPropertyi("cl300/rembf3"))
defineProperty("rembf4", globalPropertyi("cl300/rembf4"))
defineProperty("rembf5", globalPropertyi("cl300/rembf5"))
defineProperty("rembf6", globalPropertyi("cl300/rembf6"))
defineProperty("rembf7", globalPropertyi("cl300/rembf7"))
defineProperty("rembf8", globalPropertyi("cl300/rembf8"))
defineProperty("rembf9", globalPropertyi("cl300/rembf9"))
defineProperty("rembf10", globalPropertyi("cl300/rembf10"))
defineProperty("rembf11", globalPropertyi("cl300/rembf11"))
defineProperty("rembf12", globalPropertyi("cl300/rembf12"))
defineProperty("rembf13", globalPropertyi("cl300/rembf13"))
defineProperty("rembf14", globalPropertyi("cl300/rembf14"))

defineProperty("disp", globalPropertyf("cl300/disp"))

defineProperty("night_lights", globalPropertyf("sim/graphics/scenery/percent_lights_on"))

defineProperty("gpu_state", globalPropertyi("cl300/gpu_state")) -- JackZero: New DataRef: 0 = gpu not connectable, 1 = gpu can connect, 2 = gpu connected
defineProperty("gpu_mode",  globalPropertyi("cl300/gpu_mode")) -- JackZero: New DataRef: 0 = auto, 1 = manual

defineProperty("wing_insp_h", globalPropertyf("cl300/wing_insp_h"))
defineProperty("nav_h", globalPropertyf("cl300/nav_h"))
defineProperty("entrlight_h", globalPropertyi("cl300/entrlight_h"))
defineProperty("emeright_h", globalPropertyi("cl300/emeright_h"))
defineProperty("landlight1_h", globalPropertyi("cl300/landlight1_h"))
defineProperty("landlight2_h", globalPropertyi("cl300/landlight2_h"))
defineProperty("xap_taxilight_h", globalPropertyi("cl300/xap_taxilight_h"))
defineProperty("strobe_h", globalPropertyi("cl300/strobe_h"))
defineProperty("bat_on", globalPropertyi("cl300/left_bat_h"))
defineProperty("bat_on2", globalPropertyi("cl300/right_bat_h"))
defineProperty("gear_hand_dn", globalPropertyi("sim/cockpit2/controls/gear_handle_down"))
defineProperty("parkbrake", globalPropertyi("sim/flightmodel/controls/parkbrake"))
defineProperty("hydrpump", globalPropertyi("sim/cockpit2/switches/electric_hydraulic_pump_on"))

defineProperty("aux_hpump_h", globalPropertyi("cl300/aux_hpump_h"))
defineProperty("l_hpump_h", globalPropertyi("cl300/l_hpump_h"))
defineProperty("r_hpump_h", globalPropertyi("cl300/r_hpump_h"))


defineProperty("headposx", globalPropertyf("sim/graphics/view/pilots_head_x"))
defineProperty("headposy", globalPropertyf("sim/graphics/view/pilots_head_y"))
defineProperty("headposz", globalPropertyf("sim/graphics/view/pilots_head_z"))
defineProperty("headpsi", globalPropertyf("sim/graphics/view/pilots_head_psi"))
defineProperty("headthe", globalPropertyf("sim/graphics/view/pilots_head_the"))


defineProperty("customslider3_r", globalPropertyf("cl300/customslider3_r"))
defineProperty("customslider4_r", globalPropertyf("cl300/customslider4_r"))


defineProperty("background", loadImage("menu1.png", 0, 561, 412, 462))
defineProperty("green_circle", loadImage("menu1.png", 266, 1, 20, 20))
defineProperty("closing", loadImage("closing.png", 16, 16))


-- JackZero: Added option to use forward view instead of 3d cockpit for POS1
--           Set this to false if you want to use the 2D forward view for the inside views
--           or true if you want to use the 3D cockpit command view
USE_3D_COCKPIT = true

captview = findCommand("sim/view/forward_with_nothing")
cockview2 = findCommand("sim/view/3d_cockpit_cmnd_look")


local font1 = loadFont('font_5.fnt')

pf_state_1 = 0
pf_lights  = 0

last_states = {get(ext_pr_panel_s)} -- JackZero: That's the only dataref we'll still need

--[[
JackZero: Overhaul of code. 
- Complete overhaul of the camera system
  - The current position is set via a new dataref (therefore it can be triggered by an external plugin)
  - The visited positions are saved in a dataref (as bitmap)
  - The fixed position for #1 is removed (it wasn't helpfull anyways because you couldn't see the L HYDR PUMP switch). 
    Instead, the current camera position is saved once any position is triggered and can be recalled via the position 1.
- "Start again" and "Fast preflight" also sets the gust lock to OFF
- Added command for "Fast preflight"
--]]


CURSOR = {x = 10, y = 28, width = 32, height = 16, shape = loadImage("clickable.png")}

CAMERA_POSITIONS = {
    nil, --{headposx = -0.4724400639534, headposy = 0.90220862627029, headposz = -6.510527, headpsi = 21.699899673462, headthe = -19.589195251465},
    {headposx = -6.389056, headposy = -0.149156, headposz = -7.541492, headpsi = 86.729546, headthe = 12.584431},
    {headposx = -0.602418, headposy = -0.745473, headposz = -12.931976, headpsi = 172.449005, headthe = 9.898267},
    {headposx = 0.024869, headposy = 0.925803, headposz = -13.851510, headpsi = 177.866440, headthe = 4.870494},
    {headposx = 5.954782, headposy = -0.183105, headposz = -8.712113, headpsi = 252.719376, headthe = 12.929071},
    {headposx = 5.5005741119385, headposy = -0.70470744371414, headposz = -6.7671151161194-1.2192, headpsi = 239.03746032715, headthe = 21.444511413574},
    {headposx = 2.8268129825592, headposy = -1.5780529975891, headposz = -3.589056968689-1.2192, headpsi = 214.55076599121, headthe = 29.718217849731},
    {headposx = 2.4867901802063, headposy = 0.5495440363884, headposz = 2.1360440254211-1.2192, headpsi = 309.39141845703, headthe = 4.2717700004578},
    {headposx = 8.2728357315063, headposy = -0.18656487762928, headposz = 3.1257970333099-1.2192, headpsi = 272.12274169922, headthe = 12.508261680603},
    {headposx = 12.376005172729, headposy = 0.13815033435822, headposz = 3.5698390007019-1.2192, headpsi = 253.622818, headthe = 5.0102624893188},
    {headposx = 10.119519233704, headposy = 0.85619628429413, headposz = 6.598979473114-1.2192, headpsi = 297.48208618164, headthe = -20.244525909424},
    {headposx = 3.730618, headposy = -1.591129, headposz = -2.296650, headpsi = 211.093384, headthe = 9.854322},
    {headposx = 5.06405210495, headposy = 0.31791409850121, headposz = 1.8548974990845-1.2192, headpsi = 216.37120056152, headthe = 12.05148887634},
    {headposx = 3.4712388515472, headposy = -0.037349700927734, headposz = 11.332137107849-1.2192, headpsi = 325.51080322266, headthe = 18.729112625122},
    {headposx = 1.1529536247253, headposy = -1.6946949958801, headposz = 11.890969276428-1.2192, headpsi = 340.324890, headthe = 38.639538},
    {headposx = 6.603047, headposy = 0.869100, headposz = 13.991118, headpsi = 295.579224, headthe = 27.799990},
    {headposx = -3.906355, headposy = -1.624961, headposz = 8.346842, headpsi = 39.960983, headthe = 16.427885},
    {headposx = -3.9402742385864, headposy = -0.037349700927734, headposz = 10.278121, headpsi = 21.260725, headthe = 14.961067},
    {headposx = -3.831425, headposy = -1.596274, headposz = -2.358464, headpsi = 144.938568, headthe = 10.654785},
    {headposx = -9.933014, headposy = 0.797059, headposz = 5.192961, headpsi = 40.441746, headthe = -23.406305},
    {headposx = -12.121741, headposy = -0.018101, headposz = 0.970637, headpsi = 123.337196, headthe = 9.109984},
    {headposx = -8.0549201965332, headposy = -0.27915194630623, headposz = 3.0759136676788-1.2192, headpsi = 60.066551208496, headthe = 8.5916862487793},
    {headposx = -4.0922675132751, headposy = -1.5789767503738, headposz = -3.6380000114441-1.2192, headpsi = 141.23330688477, headthe = 16.260517120361},
    {headposx = -3.758221, headposy = 1.265534, headposz = -3.536954, headpsi = 147.782196, headthe = 3.163780}
}

function setCamera(pos) 
    if pos == 0 then return end
    
    if pos > 0 and pos <= #CAMERA_POSITIONS then
    
        if CAMERA_POSITIONS[1] == nil then -- save original camera position as #1
            CAMERA_POSITIONS[1] = {headposx = get(headposx), headposy = get(headposy), headposz = get(headposz), headpsi = get(headpsi), headthe = get(headthe)}
        end
        
        if pos == 1 and not USE_3D_COCKPIT then
        	commandOnce(captview)
        	setVisited(pos)
        else
	        commandOnce(cockview2)
    	    setVisited(pos)
        	setCameraPosition(pos)
        end
        
        set(prflt_cam_pos, -pos) -- set to negative to register initial processing has been done but store the original value
        
    elseif get(prflt_cam_lock) == 1 and pos < -1 and pos >= -#CAMERA_POSITIONS then
        setCameraPosition(-pos) -- lock camera, e.g. for TrackIR
    end
end

function setCameraPosition(pos)
    if pos > 0 and pos <= #CAMERA_POSITIONS then
        local p = CAMERA_POSITIONS[pos]
        if p ~= nil then
            set(headposx, p.headposx)
            set(headposy, p.headposy)
            set(headposz, p.headposz)
            set(headpsi,  p.headpsi)
            set(headthe,  p.headthe)
        end
    end
end

function setVisited(pos)
    set(prflt_cam_vis, bit.bor(get(prflt_cam_vis), bit.lshift(1, pos-1)))
end

function getVisited(pos)
    return bit.band(get(prflt_cam_vis), bit.lshift(1, pos-1)) > 0
end

function setPreflight(state)
    local f = (state and 1 or 0)
    set(rembf1,f)
    set(rembf2,f)
    set(rembf3,f)
    set(rembf4,f)
    set(rembf5,f)
    set(rembf6,f)
    set(rembf7,f)
    set(rembf8,f)
    set(rembf9,f)
    set(rembf10,f)
    set(rembf11,f)
    set(rembf12,f)
    set(rembf13,f)
    set(rembf14,f)
    set(gust_lock,1-f)
    set(prflt_cam_vis, f*0xFFFFFF)
    pf_state_1 = f*5
    pf_lights  = f*127
end

createCommand("cl300/preflight/fast_preflight", "Fast Preflight")
fast_preflight = findCommand("cl300/preflight/fast_preflight")
 function fast_preflightHandler(phase)
     if 0 == phase then
        setPreflight(true)
     end
     return 1
 end
registerCommandHandler(fast_preflight, 1, fast_preflightHandler);

createCommand("cl300/preflight/prev_cam_pos", "Previous Preflight Camera Position")
prev_cp_preflight = findCommand("cl300/preflight/prev_cam_pos")
 function prev_cp_preflightHandler(phase)
     if 0 == phase then
        local cp = math.abs(get(prflt_cam_pos)) - 1
        if cp < 1 then cp = 24 end
        set(prflt_cam_pos, cp)
     end
     return 1
 end
registerCommandHandler(prev_cp_preflight, 1, prev_cp_preflightHandler);

createCommand("cl300/preflight/next_cam_pos", "Next Preflight Camera Position")
next_cp_preflight = findCommand("cl300/preflight/next_cam_pos")
 function next_cp_preflightHandler(phase)
     if 0 == phase then
        local cp = math.abs(get(prflt_cam_pos)) + 1
        if cp > 24 then cp = 1 end
        set(prflt_cam_pos, cp)
     end
     return 1
 end
registerCommandHandler(next_cp_preflight, 1, next_cp_preflightHandler);


function update ()

    -- preflt 1:
    if pf_state_1 == 0 and get(gear_hand_dn) == 1 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 0 and get(r_hpump_h) == 0 and get(aux_hpump_h) == 0 then
        pf_state_1 = 1
    end

    if pf_state_1 == 1 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 2 and get(parkbrake) == 1 then
        pf_state_1 = 2
    end

    if pf_state_1 == 2 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 0  then
        pf_state_1 = 3
    end

    if pf_state_1 == 3 then
        if get(emeright_h)      == 2 then pf_lights = bit.bor(pf_lights,  1) end
        if get(nav_h)           == 2 then pf_lights = bit.bor(pf_lights,  2) end
        if get(landlight1_h)    == 1 then pf_lights = bit.bor(pf_lights,  4) end
        if get(landlight2_h)    == 1 then pf_lights = bit.bor(pf_lights,  8) end
        if get(xap_taxilight_h) == 2 then pf_lights = bit.bor(pf_lights, 16) end
        if get(strobe_h)        == 2 then pf_lights = bit.bor(pf_lights, 32) end
        if get(wing_insp_h)     == 1 then pf_lights = bit.bor(pf_lights, 64) end
        if pf_lights == 127 and get(emeright_h) == 0 and get(nav_h) == 0 and get(landlight1_h) == 0 and get(landlight2_h) == 0 and get(xap_taxilight_h) == 0 and get(strobe_h) == 0 and get(wing_insp_h) == 0 then
            pf_state_1 = 4
        end
    end

    if pf_state_1 == 4 and get(bat_on) == 0 and get(bat_on2) == 0 and get(gust_lock) == 0 then
        pf_state_1 = 5
        set(prflt_cam_vis, bit.bor(get(prflt_cam_vis), 1))
    end

    -- handle camera
    setCamera(get(prflt_cam_pos))

    if get(ext_pr_panel_s) == 0 and last_states[1] == 1 then
        set(prflt_cam_pos, 1)
    end
    last_states = {get(ext_pr_panel_s)}
end


components = {
    textureLit {
        position = {0,0,412,462},
        image = get(background)
    },

--// start again
    clickable {
        position = {295,423,80,20},
        cursor = CURSOR,
        onMouseClick = function() setPreflight(false) end
    },

--// fast preflight
    clickable {
        position = {275,23,110,20},
        cursor = CURSOR,
        onMouseClick = function() setPreflight(true) end
    },

-- JackZero: GPU control
--// auto gpu
    clickable {
        position = {55,423,70,20},
        visible = function () return get(gpu_mode) > 0 end,
        cursor = CURSOR,
        onMouseClick = function()
			set(gpu_mode, 0)
        end
    },

--// man gpu
    clickable {
        position = {30,23,120,20},
        visible = function () return get(gpu_state) > 0 end,
        cursor = CURSOR,
        onMouseClick = function()
			set(gpu_mode, 1)
			if get(gpu_state) == 2 then
				set(gpu_state, 1)
			elseif get(gpu_state) == 1 then
				set(gpu_state, 2)
			end
        end
    },
-- JackZero: End

--// prefl 1
    textureLit {
        position = {193,353,20,20},
        image = get(green_circle),
		visible = function () return pf_state_1 == 5 end,
    },
    clickable {
        position = {193,353,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 1) end
    },

--// prefl 2
    textureLit {
        position = {160,358,20,20},
        image = get(green_circle),
		visible = function () return getVisited(2) and get(rembf1)==1 and get(rembf2)==1 and get(rembf3)==1 and get(rembf4)==1 end,
    },
    clickable {
        position = {160,358,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 2) end
    },

--// prefl 3
    textureLit {
        position = {151,376,20,20},
        image = get(green_circle),
		visible = function () return getVisited(3) and get(rembf5)==1 and get(rembf10)==1 end,

    },
    clickable {
        position = {151,376,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 3) end
    },


--// prefl 4
    textureLit {
        position = {193,419,20,20},
        image = get(green_circle),
		visible = function () return getVisited(4) end,

    },
    clickable {
        position = {193,419,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 4) end
    },

--// prefl 5
    textureLit {
        position = {233,378,20,20},
        image = get(green_circle),
		visible = function () return getVisited(5) and get(rembf6)==1 and  get(rembf7)==1 end,

    },
    clickable {
        position = {233,378,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 5) end
    },

--// prefl 6
    textureLit {
        position = {223,364,20,20},
        image = get(green_circle),
		visible = function () return getVisited(6) and get(rembf8)==1 and  get(rembf9)==1 end,

    },
    clickable {
        position = {223,364,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 6) end
    },

--// prefl 7
    textureLit {
        position = {227,276,20,20},
        image = get(green_circle),
		visible = function () return getVisited(7) end,

    },
    clickable {
        position = {227,276,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 7) end
    },

--// prefl 8
    textureLit {
        position = {228,244,20,20},
        image = get(green_circle),
		visible = function () return getVisited(8) and get(customslider4_r) == 0 end,

    },
    clickable {
        position = {228,244,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 8) end
    },

--// prefl 9
    textureLit {
        position = {300,230,20,20},
        image = get(green_circle),
		visible = function () return getVisited(9) end,

    },
    clickable {
        position = {300,230,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 9) end
    },

--// prefl 10
    textureLit {
        position = {368,191,20,20},
        image = get(green_circle),
		visible = function () return getVisited(10) end,

    },
    clickable {
        position = {368,191,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 10) end
    },

--// prefl 11
    textureLit {
        position = {346,153,20,20},
        image = get(green_circle),
		visible = function () return getVisited(11) end,

    },
    clickable {
        position = {346,153,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 11) end
    },

--// prefl 12
    textureLit {
        position = {261,177,20,20},
        image = get(green_circle),
		visible = function () return getVisited(12) and get(rembf14)==1 end,

    },
    clickable {
        position = {261,177,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 12) end
    },

--// prefl 13
    textureLit {
        position = {228,193,20,20},
        image = get(green_circle),
		visible = function () return getVisited(13) and get(rembf11)==1 end,

    },
    clickable {
        position = {228,193,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 13) end
    },

--// prefl 14
    textureLit {
        position = {225,108,20,20},
        image = get(green_circle),
		visible = function () return getVisited(14) and get(rembf11)==1 end,

    },
    clickable {
        position = {225,108,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 14) end
    },

--// prefl 15
    textureLit {
        position = {220,86,20,20},
        image = get(green_circle),
		visible = function () return getVisited(15) end,

    },
    clickable {
        position = {220,86,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 15) end
    },

--// prefl 16
    textureLit {
        position = {246,68,20,20},
        image = get(green_circle),
		visible = function () return getVisited(16) end,

    },
    clickable {
        position = {246,68,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 16) end
    },

--// prefl 17
    textureLit {
        position = {185,26,20,20},
        image = get(green_circle),
		visible = function () return getVisited(17) end,

    },
    clickable {
        position = {185,26,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 17) end
    },

--// prefl 18
    textureLit {
        position = {162,105,20,20},
        image = get(green_circle),
		visible = function () return getVisited(18) and get(rembf12)==1 end,

    },
    clickable {
        position = {162,105,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 18) end
    },

--// prefl 19
    textureLit {
        position = {137,170,20,20},
        image = get(green_circle),
		visible = function () return getVisited(19) and get(customslider3_r) == 0 and get(rembf13)==1 end,

    },
    clickable {
        position = {137,170,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 19) end
    },

--// prefl 20
    textureLit {
        position = {67,156,20,20},
        image = get(green_circle),
		visible = function () return getVisited(20) end,

    },
    clickable {
        position = {67,156,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 20) end
    },

--// prefl 21
    textureLit {
        position = {21,198,20,20},
        image = get(green_circle),
		visible = function () return getVisited(21) end,

    },
    clickable {
        position = {21,198,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 21) end
    },

--// prefl 22
    textureLit {
        position = {91,235,20,20},
        image = get(green_circle),
		visible = function () return getVisited(22) end,

    },
    clickable {
        position = {91,235,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 22) end
    },

--// prefl 23
    textureLit {
        position = {159,278,20,20},
        image = get(green_circle),
		visible = function () return getVisited(23) end,

    },
    clickable {
        position = {159,278,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 23) end
    },

--// prefl 24
    textureLit {
        position = {159,237,20,20},
        image = get(green_circle),
		visible = function () return getVisited(24) end,

    },
    clickable {
        position = {159,237,20,20},
        cursor = CURSOR,
        onMouseClick = function() set(prflt_cam_pos, 24) end
    },

--// close zone
    textureLit {
        position = {size[1] - 16, size[2] - 16, 16, 16 },
        image = get(closing)
    },
    clickable {
        position = {size[1]-16, size[2]-16, 16, 16 },
        cursor = CURSOR,
        onMouseClick = function()
			set(ext_pr_panel_s, 0)
		 end
	},
}


function draw()

drawAll(components)

drawText(font1, 295, 423, "START AGAIN", 0.6, 0.6, 0.6)
drawText(font1, 275, 23, "FAST PREFLIGHT", 0.4, 0.4, 0.4)
-- JackZero: GPU control 
if get(gpu_mode) == 1 then
	drawText(font1,  55, 423, "AUTO GPU", 0.6, 0.6, 0.6)
end
if get(gpu_state) == 1 then
	drawText(font1,  40, 23, "CONNECT GPU", 0.4, 0.4, 0.4)
elseif get(gpu_state) == 2 then
	drawText(font1,  30, 23, "DISCONNECT GPU", 0.4, 0.4, 0.4)
end
-- JackZero: End

drawText(font1, 199, 425, "4", 0.9, 0.9, 0.9)
drawText(font1, 158, 382, "3", 0.9, 0.9, 0.9)
drawText(font1, 167, 364, "2", 0.9, 0.9, 0.9)
drawText(font1, 199, 359, "1", 0.9, 0.9, 0.9)
drawText(font1, 240, 384, "5", 0.9, 0.9, 0.9)
drawText(font1, 230, 370, "6", 0.9, 0.9, 0.9)
drawText(font1, 162, 284, "23", 0.9, 0.9, 0.9)
drawText(font1, 234, 282, "7", 0.9, 0.9, 0.9)
drawText(font1, 94, 241, "22", 0.9, 0.9, 0.9)
drawText(font1, 162, 243, "24", 0.9, 0.9, 0.9)
drawText(font1, 235, 250, "8", 0.9, 0.9, 0.9)
drawText(font1, 307, 236, "9", 0.9, 0.9, 0.9)
drawText(font1, 371, 197, "10", 0.9, 0.9, 0.9)
drawText(font1, 24, 204, "21", 0.9, 0.9, 0.9)
drawText(font1, 70, 162, "20", 0.9, 0.9, 0.9)
drawText(font1, 139, 176, "19", 0.9, 0.9, 0.9)
drawText(font1, 164, 111, "18", 0.9, 0.9, 0.9)
drawText(font1, 188, 32, "17", 0.9, 0.9, 0.9)
drawText(font1, 249, 74, "16", 0.9, 0.9, 0.9)
drawText(font1, 222, 92, "15", 0.9, 0.9, 0.9)
drawText(font1, 227, 114, "14", 0.9, 0.9, 0.9)
drawText(font1, 230, 199, "13", 0.9, 0.9, 0.9)
drawText(font1, 264, 183, "12", 0.9, 0.9, 0.9)
drawText(font1, 349, 159, "11", 0.9, 0.9, 0.9)


end
