自作 X-Cameraのビュー設定を表示 – FlyWithLua

これはX-Cameraプラグインが無いともちろん機能しない。X-Cameraで設定してIDを設定した場合のみ機能することになる。

-- 画像県警の初期設定 ----
-- C_X-Camera ----
local image_C_1 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-1.png") --1-6
local image_C_2 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-2.png") --1-7
local image_C_3 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-3.png") --2-6
local image_C_4 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-4.png") --2-7
local image_C_5 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-5.png") --3-6
local image_C_6 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-6.png") --3-7
local image_C_7 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-7.png") --4-6
local image_C_8 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-8.png") --4-7
local image_C_9 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_10 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_11 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/C-11.png") --6-2
local image_C_12 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_13 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_14 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_15 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_16 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_17 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_18 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_19 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C_20 = float_wnd_load_image(SCRIPT_DIRECTORY .. "/tab_img/unknown.png")
local image_C = { image_C_1, image_C_2, image_C_3, image_C_4, image_C_5, image_C_6, image_C_7, image_C_8, image_C_9,
	image_C_10, image_C_11, image_C_12, image_C_13, image_C_14, image_C_15, image_C_16, image_C_17, image_C_18,
	image_C_19, image_C_20 }

-- Quick Look 記憶ボタン用(1〜5段と2〜5列)
local XCamera_View_ID_Command = {
	"SRS/X-Camera/Select_View_ID_1", "SRS/X-Camera/Select_View_ID_2", "SRS/X-Camera/Select_View_ID_3",
	"SRS/X-Camera/Select_View_ID_4",
	"SRS/X-Camera/Select_View_ID_5", "SRS/X-Camera/Select_View_ID_6", "SRS/X-Camera/Select_View_ID_7",
	"SRS/X-Camera/Select_View_ID_8",
	"SRS/X-Camera/Select_View_ID_9", "SRS/X-Camera/Select_View_ID_10", "SRS/X-Camera/Select_View_ID_11",
	"SRS/X-Camera/Select_View_ID_12",
	"SRS/X-Camera/Select_View_ID_13", "SRS/X-Camera/Select_View_ID_14", "SRS/X-Camera/Select_View_ID_15",
	"SRS/X-Camera/Select_View_ID_16",
	"SRS/X-Camera/Select_View_ID_17", "SRS/X-Camera/Select_View_ID_18", "SRS/X-Camera/Select_View_ID_19",
	"SRS/X-Camera/Select_View_ID_20"
}

local Image_Button_posX = { "10", "145", "280", "415", "550", "10", "145", "280", "415", "550", "10", "145", "280",
	"415",
	"550", "10", "145", "280", "415", "550", "10", "145", "280", "415", "550" } --左のボタンからの位置 +135
local Image_Button_posY = { "52", "52", "52", "52", "52", "147", "147", "147", "147", "147", "242", "242", "242", "242",
	"242", "337", "337", "337", "337", "337" }                               --上のボタンからの位置 +95

local number_Button_posX = { "15", "150", "285", "420", "555", "15", "150", "285", "420", "555", "15", "150", "285",
	"420", "555",
	"15", "150", "285", "420", "555", "15", "150", "285", "420", "555" }
local number_Button_posY = { "54", "54", "54", "54", "54", "149", "149", "149", "149", "149", "244", "244", "244",
	"244", "244", "339", "339", "339", "339", "339" }

---------------------------------------------------------------------------------
view_selector_wnd = float_wnd_create(825, 442, 1, true)
float_wnd_set_position(view_selector_wnd, 300, 100)
float_wnd_set_title(view_selector_wnd, "X-Plane View Selector")
float_wnd_set_imgui_builder(view_selector_wnd, "view_selector_build_wnd")
float_wnd_set_onclose(view_selector_wnd, "on_close")
---------------------------------------------------------------------------------

function view_selector_build_wnd(view_selector_wnd, x, y)
	if imgui.BeginTabBar("KF_Select_flight_view_tabs") then -- flag NoToolTip flag ツールヒントなし
		if imgui.BeginTabItem("C_X-Camera") then
			for i = 1, 20, 1 do
				----------タブの内容を入れるスペース---------------
				imgui.SetCursorPosX(Image_Button_posX[i])
				imgui.SetCursorPosY(Image_Button_posY[i])
				imgui.PushStyleColor(imgui.constant.Col.Button, "0xFF228B22") --紫
				if imgui.ImageButton(image_C[i], 120, 65) then
					command_once("SRS/X-Camera/Enable_X-Camera")  --有効無効のトグル
					command_once(XCamera_View_ID_Command[i])
				end
				imgui.PopStyleColor()
				--ボタン下のテキスト(中心に入れる設定)
				local XCamera_View_label = "View_ID_" .. i
				local text_size = imgui.CalcTextSize(XCamera_View_label)                   --テキストのサイズを取得
				--68はボタンの中心位置、テキストサイズを半分にして引くとボタンに対してテキストが中心になる。
				imgui.SetCursorPos(65 + Image_Button_posX[i] - (text_size / 2), imgui.GetCursorPosY()) --パラメーターは、Xの位置と、Yの位置
				imgui.TextUnformatted(XCamera_View_label)
				--ボタンナンバーの位置とラベル
				imgui.SetCursorPosX(number_Button_posX[i])
				imgui.SetCursorPosY(number_Button_posY[i])
				imgui.TextUnformatted("C-" .. i)
			end
			--円を作成してX-Cameraのオンオフ表示する。--------------------------
			dataref("XCamera_Enabled", "SRS/X-Camera/integration/X-Camera_enabled") --1か0かの判定用
			if XCamera_Enabled == 1 then                                   --0のとき黄緑ONを表示
				imgui.DrawList_AddCircleFilled(690, 67, 7, 0xFF00FF00)     -- +95 円を作成 1段目 黄緑ONの色 1-2、1-3、1-4、1-5
			else
				imgui.DrawList_AddCircleFilled(690, 67, 7, 0x50FFFFFF)     -- +95 円を作成 1段目 グレー 1-2、1-3、1-4、1-5
			end
			imgui.SetCursorPosX(705)
			imgui.SetCursorPosY(60)
			imgui.TextUnformatted("X-Camera ON/OFF")
			----------タブの内容を入れる END---------------
			imgui.EndTabItem()
		end
		imgui.EndTabBar()
	end
end