float_wnd_set_ondraw コマンド – FlyWithLua

2023年3月25日

パーキングブレーキのオンオフのトグルコマンド。

require("graphics")
local test_wnd = nil                                 -- window handle
local winLeft, winTop, winRight, winBottom = 0, 0, 0, 0 -- float_wnd_get_geometry
local dWidth, dHeight = 0, 0                         -- float_wnd_get_dimensions

-- functions ------------------------------------------------------------------
function gps2w_ondraw(test_wnd, x, y)
    dWidth, dHeight = float_wnd_get_dimensions(test_wnd)
    winLeft, winTop, winRight, winBottom = float_wnd_get_geometry(test_wnd)
	-- draw box around window
    XPLMSetGraphicsState(0, 0, 0, 1, 1, 0, 0)

    graphics.set_color(1, 1, 1, 0.3)
    graphics.draw_rectangle(x + 18, y + 205, x + 75, y + 220) --長方形を描く
    draw_string(winLeft + 20, winTop - 152, "Q-Search", "red")
end -- function gps2w_ondraw

function gps2w_onclick(test_wnd, x, y, state)
    -- ボタンダウンアクション
    if (state == 1) then
        if (x >= 18 and x <= 75 and y >= 205 and y <= 220) then --865 877
            command_once("sim/flight_controls/brakes_toggle_max")
        end
    end -- if state
end  -- function gps2w_onclick

-- window close
function gps2w_onclose(test_wnd)
    float_wnd_destroy(test_wnd)
end

test_wnd = float_wnd_create(171, 362, 1, false)
float_wnd_set_title(test_wnd, "gps2w_xp11")
float_wnd_set_position(test_wnd, 180, 150)
float_wnd_set_ondraw(test_wnd, "gps2w_ondraw")
float_wnd_set_onclick(test_wnd, "gps2w_onclick")
float_wnd_set_onclose(test_wnd, "gps2w_onclose")