-- simDraw.lua

addSearchResourcesPath( moduleDirectory .. "/configuration/" )
local keyButton1 = sasl.gl.loadImage("KeySet_gray11.png", 150, 107, 103,  68)
local keyButton2 = sasl.gl.loadImage("KeySet_gray11.png", 0, 0, 55, 38)
-- local keyButton3 = sasl.gl.loadImage("KeySet_gray11.png", 0, 200, 87, 56)
local roboto2 = loadFont(getXPlanePath().."Resources/fonts/Roboto-Bold.ttf")
local noto2 = loadFont(getXPlanePath().."Resources/fonts/NotoSansCJK-SC-Regular.otf")
local white = {1, 1, 1, 1}
local black	= {0, 0, 0, 1}
local gray_L= {0.9, 0.9, 0.9, 1}
local yellow= {1, 1, 0, 1}
local green = {0, 1, 0, 1}
E1 = "- Click Airport ID field. When it turns green, specify ICAO code for your destination."
E2 = "- Then press \"Start\" to launch"

function draw()
	if get(simStage) == 0 then
		drawText(roboto2,120,20,"Destination:",12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,120,7," Airport ID =",12,false,false,TEXT_ALIGN_LEFT,white)
		if get(isKeyReady) == 1 then
			drawRectangle(200, 5, 100, 15, green)
		else
			drawRectangle(200, 5, 100, 15, gray_L)
		end
		drawText(roboto2,210,7,get(portId)  ,16,false,false,TEXT_ALIGN_LEFT,black)
		drawText(roboto2,305,7,get(portName),16,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,700,22,E1,16,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,700, 7,E2,16,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,520,7,get(Note1)  ,16,false ,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,550,7,get(tDisp) ,16,false ,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		if get(isStartReady) == 1 then
			sasl.gl.drawTexture(keyButton1,5,2,90,30) -- "Liftoff" button
		end

	elseif get(simStage) == 1 then
		velo = math.ceil(10*get(crrVelo))/10
		hDisp = math.ceil(10*get(kmH))/10
		
		drawText(noto2  ,114,20,"速度    m/s" ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,110,7,"Velocity"    ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,185,9,velo          ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,268,20,"高度   km"   ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,275,7," height "    ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,335,9,hDisp         ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,410,20,"時刻     sec",12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,417,7," Timer  "    ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,475,9,"T= "         ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(roboto2,505,9,get(t3)       ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,565,20,"Lon   経度"  ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,630,19,get(curLon) ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(noto2  ,565, 7,"Lat   緯度"  ,12,false,false,TEXT_ALIGN_LEFT,white)
		drawText(roboto2,630, 6,get(curLat) ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2,820,14,get(Note1)     ,16,true ,false,TEXT_ALIGN_LEFT,white)
		-- 
		sasl.gl.drawTexture(keyButton2, 5, 2, 87, 30)   -- "Return" button
	
	elseif get(simStage) == 2 then
		velo = math.ceil(10*get(crrVelo))/10
		hDisp = math.ceil(10*get(kmH))/10
		
		drawText(noto2  ,114,20,"速度    m/s" ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,110, 7,"Velocity"   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,185, 9,velo         ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,258,20,"高度   km"   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,265, 7," height "   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,328, 9,hDisp        ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,410,20,"時刻     sec",12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,417, 7," Timer  "   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,475, 9,"T= "        ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(roboto2,505, 9,get(t3)   ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,565,20,"Lon   経度"  ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,630,19,get(curLon)  ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(noto2  ,565, 7,"Lat   緯度"  ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,630, 6,get(curLat)  ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,820,14,get(Note1)   ,16,true ,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(noto2  ,1120,14,get(tDisp)  ,16,true ,false,TEXT_ALIGN_LEFT,yellow)
		
	else
		velo = math.ceil(10*get(crrVelo))/10
		hDisp = math.ceil(10*get(kmH))/10
		
		drawText(noto2  ,114,20,"速度    m/s" ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,110, 7,"Velocity"   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,185, 9,velo         ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,255,20,"高度   km"   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,262, 7," height "   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,325, 9,hDisp        ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,410,20,"時刻     sec",12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,417, 7," Timer  "   ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,475, 9,"T= "        ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(roboto2,505, 9,get(t3)   ,20,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,565,20,"Lon   経度"  ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,630,19,get(curLon)  ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		drawText(noto2  ,565, 7,"Lat   緯度"  ,12,false,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(roboto2,630, 6,get(curLat)  ,14,false,false,TEXT_ALIGN_LEFT,yellow)
		-- 
		drawText(noto2  ,820,14,get(Note1)   ,16,true ,false,TEXT_ALIGN_LEFT,gray_L)
		drawText(noto2  ,1135,14,get(tDisp)  ,16,true ,false,TEXT_ALIGN_LEFT,yellow)
	end
end