
if not BackUpIndicator then
    SUB_PAGE_NAME = 'P4_SUB_PAGE'
    SUB_PAGE_VAL = Pages[Pages.P4].BASE
end

local planeArmSim = AddSimple(nil,nil,nil,Page4_sim)
local planeLineVertical = {
    {-0.232218*width,height},
	{-0.249308*width,0.948400*height},
	{-0.492717*width,0.629621*height},
	{-0.493979*width,0.589527*height},
	{-0.477017*width,0.516337*height},
	{-0.260053*width,0.578192*height},
	{-0.327513*width,0.270047*height},
	{-0.833344*width,-0.308283*height},
	{-0.833344*width,-0.512770*height},
	{-0.364097*width,-0.652863*height}
}
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--左机身1
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,true)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--右机身1
planeLineVertical = {
    {-0.233547*width,-0.389783*height},
	{-0.419069*width,-0.768795*height},
	{-0.418228*width,-0.914882*height},
	{-0.413189*width,-0.934516*height},
	{-0.396373*width,-0.960566*height},
	{-0.185052*width,-0.703613*height},
	{-0.233547*width,-0.389783*height}
}
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--左垂尾
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,true)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--右垂尾
planeLineVertical = {
    {-0.300524*width,-0.853037*height},
	{-0.244045*width,-0.926864*height},
	{-0.165887*width,-0.809022*height},
	{-0.157431*width,-0.749109*height},
	{-0.148491*width,-0.779875*height},
	{-0.022880*width,-0.779875*height},
	{-0.006715*width,-0.697720*height},
	{0.009737*width,-0.697720*height}
}
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,false)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--机身2
planeLineVertical = {
    {-0.375420*width,-0.648936*height},
	{-0.375420*width,-0.532256*height},
	{-0.613386*width,-0.460316*height},
	{-0.613386*width,-0.575481*height}
}
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--左襟翼
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,true)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--右襟翼
planeLineVertical = {
    {-0.613386*width,-0.460316*height},
	{-0.833735*width,-0.391812*height}
}
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--左副翼
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,true)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--右副翼
planeLineVertical = {
    {-0.782656*width,-0.253421*height},
	{-0.744177*width,-0.292848*height},
	{-0.369328*width,0.116408*height},
	{-0.369328*width,0.210774*height}
}
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--左前缘襟翼
planeLineVertical = MirrorSimpleLine(planeLineVertical,'Y',0.009737,true)
AddSimpleLine(nil,0.005*width,planeLineVertical,nil,nil,'DBG_WHITE',nil,nil,planeArmSim)--右前缘襟翼

AddText(nil,'ECM','unicode_cn_green',{0,0.4*height},nil,DEFAULT_FONT_SIZE[4],nil,nil,planeArmSim,nil,
	{'ECM_STATUS'},
	{
		{AnimalControllor.parameterCompareWithNumber,0,1}
	}
)
local antiMslSimple = AddSimple(nil,{0.009737*width,-0.574295*height},nil,planeArmSim)
local font_size = DEFAULT_FONT_SIZE[6]
if BackUpIndicator then
    font_size = {DEFAULT_FONT_SIZE[6][1]*0.9,DEFAULT_FONT_SIZE[6][2]*0.9,DEFAULT_FONT_SIZE[6][3],DEFAULT_FONT_SIZE[6][4]}
end
AddText(nil,nil,'unicode_cn_white',{-0.15*width,0},Align.LC,font_size,nil,nil,antiMslSimple,{'箔条:%.0f\n','热诱:%.0f'},
	{'CHAFF_QTY','FLARE_QTY'},
	{
		{AnimalControllor.textUsingParameter,0,0},
		{AnimalControllor.textUsingParameter,1,1}
	}
)
AddBoxBorder(nil,0.15*width,0.1*height,0.005*width,nil,nil,FrameEdgeMaterial,nil,nil,antiMslSimple)
-- 添加内置机炮数量显示
AddText(nil, nil, 'unicode_cn_white', {0, 0.7 * height}, Align.LC, DEFAULT_FONT_SIZE[6], nil, nil, planeArmSim, {'当前:%s'},
	{'GUN_NAME','GUN_MODE'},
	{
		{AnimalControllor.textUsingParameter,0,0},
		{AnimalControllor.parameterCompareWithNumber,1,1}
	}
)

AddText(nil, nil, 'unicode_cn_white', {0, 0.6 * height}, Align.LC, DEFAULT_FONT_SIZE[6], nil, nil, planeArmSim, {'内置:%.0f'},
	{'GUN_COUNT'},
	{
		{AnimalControllor.textUsingParameter, 0, 0}
	}
)

local mslVertical_1 = {
	{-0.032857*width, 0.311970*height},
	{ 0.032857*width, 0.311970*height},
	{ 0.032857*width,-0.311970*height},
	{-0.032857*width,-0.311970*height}
}
local mslVertical_1_15 = {
	{-0.032857*width, 0.311970*1.2*height},
	{ 0.032857*width, 0.311970*1.2*height},
	{ 0.032857*width,-0.311970*1.2*height},
	{-0.032857*width,-0.311970*1.2*height}
}
local mslVertical_1_17 = {
	{-0.032857*width, 0.311970*1.4*height},
	{ 0.032857*width, 0.311970*1.4*height},
	{ 0.032857*width,-0.311970*1.4*height},
	{-0.032857*width,-0.311970*1.4*height}
}
local mslVertical_2 = {
	{-0.032857*1.5*width, 0.311970*1.5*height},
	{ 0.032857*1.5*width, 0.311970*1.5*height},
	{ 0.032857*1.5*width,-0.311970*1.5*height},
	{-0.032857*1.5*width,-0.311970*1.5*height}
}
local mslVertical_3 = {
	{-0.032857*1.7*width, 0.311970*1.7*height},
	{ 0.032857*1.7*width, 0.311970*1.7*height},
	{ 0.032857*1.7*width,-0.311970*1.7*height},
	{-0.032857*1.7*width,-0.311970*1.7*height}
}
local agm65eVertical = {
	{-0.151970*width, 0.032857*height},
	{ 0.151970*width, 0.032857*height},
	{ 0.151970*width,-0.032857*height},
	{-0.151970*width,-0.032857*height}
}
local pl12_size = {228,1629}
local pl12_XY = {0,0}
local pl12_frame_XY = {pl12_XY[1]+244,pl12_XY[2]+0}
local ld10_XY = {pl12_frame_XY[1]+242,pl12_frame_XY[2]+0}
local ld10_frame_XY = {ld10_XY[1]+243,ld10_XY[2]+0}
local cm102_XY = {0,0}
local cm102_frame_XY = {cm102_XY[1]+244,cm102_XY[2]+0}
local pl15_size = {171,1629}
local pl15_XY = {988,0}
local pl15_frame_XY = {pl15_XY[1]+198,pl15_XY[2]+0}
local pl17_size = {171,1629}
local pl17_XY = {988,0}
local pl17_frame_XY = {pl17_XY[1]+198,pl17_XY[2]+0}
local pl10e_size = {154,1629}
local pl10e_XY = {1380,0}
local pl10e_frame_XY = {pl10e_XY[1]+169,pl10e_XY[2]+0}
local agm65e_size = {1024,308}
local agm65e_XY = {0,1741}
local agm65e_frame_XY = {agm65e_XY[1]+1025,agm65e_XY[2]+0}
local bomb_size = {139,1629}
local bomb_XY = {1730,0}
local bomb_frame_XY = {bomb_XY[1]+174,bomb_XY[2]+0}
local yj12_XY = {3420,0}
local yj12_size = {305,2048}
local yj12_frame_XY = {yj12_XY[1]+347,0}
local gun_XY = {2880,0}
local gun_size = {233,2048}
local gun_frame_XY = {gun_XY[1]+272,0}
local yj83_XY = {2090,0}
local yj83_size = {337,2048}
local yj83_frame_XY = {yj83_XY[1]+384,2048}
local wpnSimple = AddSimple(nil,{0.010893*width,0},nil,planeArmSim)
local mslSimple = AddSimple(nil,{-0.251268*width,0},nil,wpnSimple)
--侧弹仓:格斗弹\AGM65
--1号
--PL10E
AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(pl10e_XY[1], pl10e_XY[2], pl10e_size[1], pl10e_size[2], IconTexureSize[1], IconTexureSize[2]),
    IconMatt, nil, nil, nil, nil, mslSimple,
	{ 'MSL_1_COUNT', 'MSL_1_USING', 'MSL_1_SELECTED','MSL_1_PL10E' },
    {
        { AnimalControllor.parameterInRange,                      0, 0.9,  1e2 },
        { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
    }
)
AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(pl10e_frame_XY[1], pl10e_frame_XY[2], pl10e_size[1], pl10e_size[2], IconTexureSize[1],IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_1_COUNT', 'MSL_1_USING', 'MSL_1_SELECTED','MSL_1_PL10E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9, 1e2 },
        { AnimalControllor.parameterInRange,                        1, -0.1, 0.9 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        3, 0.9, 1.1 }
    }
)
--agm65
AddTexture(nil, agm65eVertical, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(agm65e_XY[1], agm65e_XY[2], agm65e_size[1], agm65e_size[2], IconTexureSize[1], IconTexureSize[2]),
    IconMatt, nil, {90,0}, nil, nil, mslSimple,
	{ 'MSL_1_COUNT', 'MSL_1_USING', 'MSL_1_SELECTED','MSL_1_AGM65E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9,  1.1 },
        { AnimalControllor.parameterInRange,                        1, 0.9, 1.1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        3, 0.9, 1.1 }
    }
)
AddTexture(nil, agm65eVertical, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(agm65e_frame_XY[1], agm65e_frame_XY[2], agm65e_size[1], agm65e_size[2], IconTexureSize[1],IconTexureSize[2]),
	IconMatt, nil, {90,0}, nil, nil, mslSimple,
	{ 'MSL_1_COUNT', 'MSL_1_USING', 'MSL_1_SELECTED','MSL_1_AGM65E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9, 1.1 },
        { AnimalControllor.parameterInRange,                        1, -0.1, 0.9 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        3, 0.9, 1.1 }
    }
)
--count
AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
{'MSL_1_COUNT','MSL_1_USING','MSL_1_SELECTED'},
{
    { AnimalControllor.textUsingParameter,                      0, 0 },
    { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
    { AnimalControllor.parameterCompareWithNumber,              1, 1 },
    { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 0, 0 },
})
AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
{'MSL_1_COUNT','MSL_1_USING','MSL_1_SELECTED'},
{
    { AnimalControllor.textUsingParameter,                      0, 0 },
    { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
    { AnimalControllor.parameterCompareWithNumber,              1, 0 },
    { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
})
--2号
--PL10E
mslSimple = AddSimple(nil, { 0.321268 * width, 0 }, nil, wpnSimple)
AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(pl10e_XY[1], pl10e_XY[2], pl10e_size[1], pl10e_size[2], IconTexureSize[1], IconTexureSize[2]),
    IconMatt, nil, nil, nil, nil, mslSimple,
	{ 'MSL_2_COUNT', 'MSL_2_USING', 'MSL_2_SELECTED','MSL_2_PL10E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9,  1e2 },
        { AnimalControllor.parameterInRange,                        1, 0.9, 1.1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        3, 0.9, 1.1 }
    }
)
AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(pl10e_frame_XY[1], pl10e_frame_XY[2], pl10e_size[1], pl10e_size[2], IconTexureSize[1],IconTexureSize[2]),
	IconMatt, nil, nil, nil, nil, mslSimple,
	{ 'MSL_2_COUNT', 'MSL_2_USING', 'MSL_2_SELECTED','MSL_2_PL10E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9, 1e2 },
        { AnimalControllor.parameterInRange,                        1, -0.1, 0.9 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        3, 0.9, 1.1 }
    }
)
--agm65
AddTexture(nil, agm65eVertical, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(agm65e_XY[1], agm65e_XY[2], agm65e_size[1], agm65e_size[2], IconTexureSize[1], IconTexureSize[2]),
    IconMatt, nil, {90,0}, nil, nil, mslSimple,
	{ 'MSL_2_COUNT', 'MSL_2_USING', 'MSL_2_SELECTED','MSL_2_AGM65E' },
    {
        { AnimalControllor.parameterInRange,                        0, 0.9,  1.1 },
        { AnimalControllor.parameterInRange,                        1, 0.9, 1.1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
    }
)
AddTexture(nil, agm65eVertical, { 0, 1, 2, 2, 3, 0 },
    Texure_coord_gen(agm65e_frame_XY[1], agm65e_frame_XY[2], agm65e_size[1], agm65e_size[2], IconTexureSize[1],IconTexureSize[2]),
	IconMatt, nil, {90,0}, nil, nil, mslSimple,
	{ 'MSL_2_COUNT', 'MSL_2_USING', 'MSL_2_SELECTED','MSL_2_AGM65E' },
    {
        { AnimalControllor.parameterInRange,                      0, 0.9, 1.1 },
        { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
    }
)
--count
AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
{'MSL_2_COUNT','MSL_2_USING','MSL_2_SELECTED'},
{
    { AnimalControllor.textUsingParameter,                      0, 0 },
    { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
    { AnimalControllor.parameterCompareWithNumber,              1, 1 },
    { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 0, 0 },
})
AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
{'MSL_2_COUNT','MSL_2_USING','MSL_2_SELECTED'},
{
    { AnimalControllor.textUsingParameter,                      0, 0 },
    { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
    { AnimalControllor.parameterCompareWithNumber,              1, 0 },
    { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
})
--3-8
for i = 3, 8, 1 do
    local fmod = math.fmod(i,2)
    local offset = math.floor(i*0.5)
    if fmod == 1 then
        mslSimple = AddSimple(nil,{-(0.220390-0.070944*(offset-1))*width+0.07*width,0},nil,wpnSimple)
    else
        mslSimple = AddSimple(nil,{ (0.220390-0.070944*(offset-1))*width+0.07*width,0},nil,wpnSimple)
    end
    --PL12
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl12_XY[1], pl12_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1], IconTexureSize[2]),
        IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL12' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9,  1e2 },
            { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl12_frame_XY[1], pl12_frame_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1],IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL12' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    --PL15
    AddTexture(nil, mslVertical_1_15, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl15_XY[1], pl15_XY[2], pl15_size[1], pl15_size[2], IconTexureSize[1], IconTexureSize[2]),
        IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL15' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9,  1e2 },
            { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    AddTexture(nil, mslVertical_1_15, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl15_frame_XY[1], pl15_frame_XY[2], pl15_size[1], pl15_size[2], IconTexureSize[1],IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL15' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )

	--PL17
    AddTexture(nil, mslVertical_1_17, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl17_XY[1], pl17_XY[2], pl17_size[1], pl17_size[2], IconTexureSize[1], IconTexureSize[2]),
        IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL17' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9,  1e2 },
            { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    AddTexture(nil, mslVertical_1_17, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(pl17_frame_XY[1], pl17_frame_XY[2], pl17_size[1], pl17_size[2], IconTexureSize[1], IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_PL17' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    --LD10
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(ld10_XY[1], ld10_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1], IconTexureSize[2]),
        IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_LD10' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(ld10_frame_XY[1], ld10_frame_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1],IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_LD10' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
        }
    )
    --CM102A
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(cm102_XY[1], cm102_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1], IconTexureSize[2]),
        IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_CM102' },
        {
            { AnimalControllor.parameterInRange,						0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,						1, 0.9, 1.1 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber,	2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,						3, 0.9, 1.1 }
        }
    )
    AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
        Texure_coord_gen(cm102_frame_XY[1], cm102_frame_XY[2], pl12_size[1], pl12_size[2], IconTexureSize[1],IconTexureSize[2]),
		IconMatt, nil, nil, nil, nil, mslSimple,
		{ 'MSL_'..i..'_COUNT', 'MSL_'..i..'_USING', 'MSL_'..i..'_SELECTED','MSL_'..i..'_CM102' },
        {
            { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
            { AnimalControllor.parameterInRange,            		  1, -0.1, 0.9 },
            { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
            { AnimalControllor.parameterInRange,                      3, 0.9, 1.1}
        }
    )
    local fontscale= 0.5-- 字体大小可按需要调整
    local msl_font_size = {DEFAULT_FONT_SIZE_2[6][1]*fontscale,DEFAULT_FONT_SIZE_2[6][2]*fontscale,DEFAULT_FONT_SIZE_2[6][3],DEFAULT_FONT_SIZE_2[6][4]}
	AddText(nil, 'C\nM', 'unicode_cn_green',{0*width,0.05*height},nil,msl_font_size,nil, nil, mslSimple,nil,
    {'MSL_' .. i .. '_USING','MSL_'..i..'_SELECTED','MSL_'..i..'_CM102'},
    {
        { AnimalControllor.parameterCompareWithNumber,              0, 1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   1, 1, 0, 0, 0 },
        { AnimalControllor.parameterInRange,                        2, 0.9, 1.1}
    })
    AddText(nil, 'C\nM', 'unicode_cn_green',{0*width,0.05*height},nil,msl_font_size,nil, nil, mslSimple,nil,
    {'MSL_' .. i .. '_USING','MSL_'..i..'_SELECTED','MSL_'..i..'_CM102'},
    {
        { AnimalControllor.parameterCompareWithNumber,              0, 0 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   1, 1, 1, 1, 1 },
        { AnimalControllor.parameterInRange,                        2, 0.9, 1.1}
    })
    --count
    AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
    {'MSL_'..i..'_COUNT','MSL_' .. i .. '_USING','MSL_'..i..'_SELECTED'},
    {
        { AnimalControllor.textUsingParameter,                      0, 0 },
        { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
        { AnimalControllor.parameterCompareWithNumber,              1, 1 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 0, 0 },
    })
    AddText(nil, nil, 'unicode_cn_green',{0*width,-0.05*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, mslSimple,{'%.0f'},
    {'MSL_'..i..'_COUNT','MSL_' .. i .. '_USING','MSL_'..i..'_SELECTED'},
    {
        { AnimalControllor.textUsingParameter,                      0, 0 },
        { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
        { AnimalControllor.parameterCompareWithNumber,              1, 0 },
        { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
    })

    if i == 5 or i == 6 then
        --炸弹bomb
        AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
            Texure_coord_gen(bomb_XY[1], bomb_XY[2], bomb_size[1], bomb_size[2], IconTexureSize[1], IconTexureSize[2]),
            IconMatt, nil, nil, nil, nil, mslSimple,
			{ 'MSL_' .. i .. '_COUNT', 'MSL_' .. i .. '_USING', 'MSL_' .. i .. '_SELECTED','MSL_'..i..'_BOMB' },
            {
                { AnimalControllor.parameterInRange,                      0, 0.9,  1e2 },
                { AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
                { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
            }
        )
        AddTexture(nil, mslVertical_1, { 0, 1, 2, 2, 3, 0 },
            Texure_coord_gen(bomb_frame_XY[1], bomb_frame_XY[2], bomb_size[1], bomb_size[2], IconTexureSize[1],IconTexureSize[2]),
			IconMatt, nil, nil, nil, nil, mslSimple,
            { 'MSL_' .. i .. '_COUNT', 'MSL_' .. i .. '_USING', 'MSL_' .. i .. '_SELECTED','MSL_'..i..'_BOMB' },
            {
                { AnimalControllor.parameterInRange,                      0, 0.9, 1e2 },
                { AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
                { AnimalControllor.parameterInRange,                      3, 0.9, 1.1 }
            }
        )
    end
end

if USE_EXT_DLL and Type then
    local function drawWeaponsIcon(parent,station)
        local function drawWeapon(weapon,weaponSize,frame,frameSize,v,weaponName)
            AddTexture(nil, v, { 0, 1, 2, 2, 3, 0 },
                Texure_coord_gen(weapon[1], weapon[2], weaponSize[1], weaponSize[2], IconTexureSize[1], IconTexureSize[2]),
                IconMatt, nil, nil, nil, nil, parent,
                { 'MSL_' .. station .. '_COUNT', 'MSL_' .. station .. '_USING', 'MSL_' .. station .. '_SELECTED', 'MSL_' .. station .. '_' .. weaponName },
                {
                    { AnimalControllor.parameterInRange,                      0, 0.9, 1e6 },
					{ AnimalControllor.parameterCompareWithNumber,            1, 1.0 },
                    { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
					{ AnimalControllor.parameterCompareWithNumber,            3, 1.0 }
                }
            )
            AddTexture(nil, v, { 0, 1, 2, 2, 3, 0 },
                Texure_coord_gen(frame[1], frame[2], frameSize[1], frameSize[2], IconTexureSize[1],IconTexureSize[2]),
				IconMatt, nil, nil, nil, nil, parent,
                { 'MSL_' .. station .. '_COUNT', 'MSL_' .. station .. '_USING', 'MSL_' .. station .. '_SELECTED', 'MSL_' .. station .. '_'.. weaponName },
                {
                    { AnimalControllor.parameterInRange,                      0, 0.9,  1e6 },
					{ AnimalControllor.parameterCompareWithNumber,            1, 0 },
					{ AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
					{ AnimalControllor.parameterCompareWithNumber,            3, 1 }
                }
            )
            local fontscale= 0.5-- 字体大小可按需要调整
            local msl_font_size = {DEFAULT_FONT_SIZE_2[6][1]*fontscale,DEFAULT_FONT_SIZE_2[6][2]*fontscale,DEFAULT_FONT_SIZE_2[6][3],DEFAULT_FONT_SIZE_2[6][4]}
	        AddText(nil, 'C\nM', 'unicode_cn_green',{0*width,0.05*height},nil,msl_font_size,nil, nil, parent,nil,
            {'MSL_' .. station .. '_USING','MSL_'..station..'_SELECTED','MSL_'..station..'_CM102'},
            {
                { AnimalControllor.parameterCompareWithNumber,              0, 1 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber,   1, 1, 0, 0, 0 },
                { AnimalControllor.parameterInRange,                        2, 0.9, 1.1}
            })
            AddText(nil, 'C\nM', 'unicode_cn_green',{0*width,0.05*height},nil,msl_font_size,nil, nil, parent,nil,
            {'MSL_' .. station .. '_USING','MSL_'..station..'_SELECTED','MSL_'..station..'_CM102'},
            {
                { AnimalControllor.parameterCompareWithNumber,              0, 0 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber,   1, 1, 1, 1, 1 },
                { AnimalControllor.parameterInRange,                        2, 0.9, 1.1}
            })
            --count
            AddText(nil, nil, 'unicode_cn_green',{0*width,-0.35*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, parent,{'%.0f'},
            {'MSL_'..station..'_COUNT','MSL_' .. station .. '_USING','MSL_'..station..'_SELECTED'},
            {
                { AnimalControllor.textUsingParameter,                      0, 0 },
                { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
                { AnimalControllor.parameterCompareWithNumber,              1, 1 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 0, 0 },
            })
            AddText(nil, nil, 'unicode_cn_green',{0*width,-0.35*height},nil,DEFAULT_FONT_SIZE[6],nil, nil, parent,{'%.0f'},
            {'MSL_'..station..'_COUNT','MSL_' .. station .. '_USING','MSL_'..station..'_SELECTED'},
            {
                { AnimalControllor.textUsingParameter,                      0, 0 },
                { AnimalControllor.parameterInRange,                        0, 1.9, 1e2},
                { AnimalControllor.parameterCompareWithNumber,              1, 0 },
                { AnimalControllor.changeColorWhenParameterEqualToNumber,   2, 1, 1, 1, 1 },
            })

        end
		local function drawWeapon90(weapon,weaponSize,frame,frameSize,v,weaponName)
            AddTexture(nil, v, { 0, 1, 2, 2, 3, 0 },
                Texure_coord_gen(weapon[1], weapon[2], weaponSize[1], weaponSize[2], IconTexureSize[1], IconTexureSize[2]),
                IconMatt, nil, {90,0}, nil, nil, parent,
                { 'MSL_' .. station .. '_COUNT', 'MSL_' .. station .. '_USING', 'MSL_' .. station .. '_SELECTED', 'MSL_' .. station .. '_' .. weaponName },
                {
                    { AnimalControllor.parameterInRange,                      0, 0.9, 1e6 },
					{ AnimalControllor.parameterInRange,                      1, 0.9, 1.1 },
                    { AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
					{ AnimalControllor.parameterInRange,                      3, 0.9, 1.1 },
                }
            )
            AddTexture(nil, v, { 0, 1, 2, 2, 3, 0 },
                Texure_coord_gen(frame[1], frame[2], frameSize[1], frameSize[2], IconTexureSize[1],IconTexureSize[2]),
				IconMatt, nil, {90,0}, nil, nil, parent,
                { 'MSL_' .. station .. '_COUNT', 'MSL_' .. station .. '_USING', 'MSL_' .. station .. '_SELECTED', 'MSL_' .. station .. '_'.. weaponName },
                {
                    { AnimalControllor.parameterInRange,                      0, 0.9,  1e6 },
					{ AnimalControllor.parameterInRange,                      1, -0.1, 0.9 },
					{ AnimalControllor.changeColorWhenParameterEqualToNumber, 2, 1, 1, 1, 1 },
					{ AnimalControllor.parameterInRange,                      3, 0.9, 1.1 },
                }

            )
        end
        --PL12
        drawWeapon(pl12_XY,pl12_size,pl12_frame_XY,pl12_size,mslVertical_1,'PL12')
        --PL15
        drawWeapon(pl15_XY,pl15_size,pl15_frame_XY,pl15_size,mslVertical_1_15,'PL15')
		--PL17
        drawWeapon(pl17_XY,pl17_size,pl17_frame_XY,pl17_size,mslVertical_1_17,'PL17')
        --LD10
        drawWeapon(ld10_XY,pl12_size,ld10_frame_XY,pl12_size,mslVertical_1,'LD10')
        --CM102A
        drawWeapon(cm102_XY,pl12_size,cm102_frame_XY,pl12_size,mslVertical_1,'CM102')
		--AGM-65E
        drawWeapon90(agm65e_XY,agm65e_size,agm65e_frame_XY,agm65e_size,agm65eVertical,'AGM65E')
        --炸弹bomb
        drawWeapon(bomb_XY,bomb_size,bomb_frame_XY,bomb_size,mslVertical_1,'BOMB')
        --YJ12
        drawWeapon(yj12_XY,yj12_size,yj12_frame_XY,yj12_size,mslVertical_3,'YJ12')
        --YJ83
        drawWeapon(yj83_XY,yj83_size,yj83_frame_XY,yj83_size,mslVertical_2,'YJ83')
        --机炮吊舱
        drawWeapon(gun_XY,gun_size,gun_frame_XY,gun_size,mslVertical_2,'GUNPOD')
    end
    mslSimple = AddSimple(nil,{-0.45*width+wpnSimple.init_pos[1]*2,-0.1*height},nil,wpnSimple)
    drawWeaponsIcon(mslSimple,9)

    mslSimple = AddSimple(nil,{0.45*width+wpnSimple.init_pos[1]*2,-0.1*height},nil,wpnSimple)
    drawWeaponsIcon(mslSimple,10)

    mslSimple = AddSimple(nil,{-0.65*width+wpnSimple.init_pos[1]*2,-0.2*height},nil,wpnSimple)
    drawWeaponsIcon(mslSimple,11)

    mslSimple = AddSimple(nil,{0.65*width+wpnSimple.init_pos[1]*2,-0.2*height},nil,wpnSimple)
    drawWeaponsIcon(mslSimple,12)
end
local txt = AddText(nil,'武器','unicode_cn_white',{-0.478897*width,0.928534*height},nil,font_size,nil,nil,Page4_sim)
AddBoxBorder(nil,0.072*width,0.04*height,0.007*width,nil,nil,FrameEdgeMaterial,nil,nil,txt)

local modeTxt = AddText(nil,'模\n式','unicode_cn_green',{-0.93*width,0.56*height},nil,font_size,nil,nil,Page4_sim)
txt = AddText(nil,'空空','unicode_cn_green',{-0.00*width,0.15*height},Align.CC,font_size,nil,nil,modeTxt,nil,{'ATK_MODE'},
{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,1,1,1,1}
})
AddBoxBorder(nil,0.08*width,0.05*height,0.005*width,nil,nil,FrameEdgeMaterial,nil,nil,txt,{'ATK_MODE'},
{
    {AnimalControllor.parameterInRange,0,0.9,1.1}
}
)

txt = AddText(nil,'空地','unicode_cn_green',{-0.0*width,-0.15*height},Align.CC,font_size,nil,nil,modeTxt,nil,{'ATK_MODE'},
{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,2,1,1,1}
})
AddBoxBorder(nil,0.08*width,0.05*height,0.005*width,nil,nil,FrameEdgeMaterial,nil,nil,txt,{'ATK_MODE'},
{
    {AnimalControllor.parameterInRange,0,1.9,2.1}
}
)

local wpnRoomTxt = AddText(nil,'弹\n仓','unicode_cn_green',{0.93*width,0.56*height},nil,font_size,nil,nil,Page4_sim)
txt = AddText(nil,'开','unicode_cn_green',{-0*width,0.15*height},Align.CC,font_size,nil,nil,wpnRoomTxt,nil,{'WPN_ROOM_STATUS'},
{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,1,1,1,1}
}
)
AddBoxBorder(nil,0.05*width,0.05*height,0.005*width,nil,nil,FrameEdgeMaterial,nil,nil,txt,{'WPN_ROOM_STATUS'},
{
    {AnimalControllor.parameterInRange,0,0.9,1.1}
}
)
txt = AddText(nil,'自动','unicode_cn_green',{0.05*width,-0.15*height},Align.RC,font_size,nil,nil,wpnRoomTxt,nil,{'WPN_ROOM_STATUS'},
{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,0,1,1,1}
}
)
AddBoxBorder(nil,0.07*width,0.05*height,0.005*width,{-0.07*width},nil,FrameEdgeMaterial,nil,nil,txt,{'WPN_ROOM_STATUS'},
{
    {AnimalControllor.parameterInRange,0,-0.1,0.8}
}
)
AddMeshPoly(nil,{{-0.078*width,0},{0.078*width,0},{0,0.09*height}},{0,1,2},{-0.882*width,0.894*height},nil,'DBG_WHITE',nil,nil,planeArmSim)
AddMeshPoly(nil,{{-0.06*width,0},{0.06*width,0},{0,0.07*height}},{0,1,2},{-0.882*width,0.904*height},nil,'LIGHT_BLUE',nil,nil,planeArmSim)

AddMeshPoly(nil,{{-0.078*width,0.09*height},{0.078*width,0.09*height},{0,0}},{0,1,2},{0.882*width,0.894*height},nil,'DBG_WHITE',nil,nil,planeArmSim)
AddMeshPoly(nil,{{-0.06*width,0.07*height},{0.06*width,0.07*height},{0,0}},{0,1,2},{0.882*width,0.904*height},nil,'LIGHT_BLUE',nil,nil,planeArmSim)

if not BackUpIndicator then
	local Enable_MP3Player = get_aircraft_property("MP3Player")	
	if Enable_MP3Player~=1 then
		return
	end
    SubPageVal = Pages[Pages.P4].MP3
    dofile(LockOn_Options.script_path.."displays/MFD/Indicator/pages/MP3_page.lua")
end
SUB_PAGE_NAME = nil
SubPageVal = nil