#include "../PScriptLib/AsHelper.as"
void BigTab()
{

   Vector4 BgColor = Vector4(0.0,0,0,0.5); // 
   Vector2 Position = Vector2(0.242, 0.15); //
   	 auto screenSize = ImGui_GetDisplaySize();
   	 ImGui_SetNextWindowPos(screenSize * Position);

   	 int windowFlags = 
        ImGuiWindowFlags_NoTitleBar | 
        ImGuiWindowFlags_NoMove | 
        ImGuiWindowFlags_NoResize | 
        ImGuiWindowFlags_NoInputs | 
        ImGuiWindowFlags_NoScrollbar | 
        ImGuiWindowFlags_AlwaysAutoResize|
        0;
    ImGui_PushStyleColor(ImGuiCol_WindowBg, BgColor);
  
    ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(10,2));
    ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0.0);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 5.0f);
    bool open = true;
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();
    ImGui_End();
    
}
void BigTab2()
{

  Vector4  BgColor = Vector4(0.0,0,0,0.5); // 
  Vector2  Position = Vector2(0.49, 0.15); //
   	 auto screenSize = ImGui_GetDisplaySize();
   	 ImGui_SetNextWindowPos(screenSize * Position);

   	 int windowFlags = 
        ImGuiWindowFlags_NoTitleBar | 
        ImGuiWindowFlags_NoMove | 
        ImGuiWindowFlags_NoResize | 
        ImGuiWindowFlags_NoInputs | 
        ImGuiWindowFlags_NoScrollbar | 
        ImGuiWindowFlags_AlwaysAutoResize|
        0;
    ImGui_PushStyleColor(ImGuiCol_WindowBg, BgColor);
  
    ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(10,2));
    ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0.0);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 5.0f);
    bool open = true;
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();
    ImGui_End();
    
}


void TabID()
{
    Vector4 textColor;
    string name = GetCharName(i);
    int name2 = GetHP(i);

    textColor = Vector4(1,1,1,1);

    
  Vector4  BgColor = Vector4(0.0,0,0,0); // 
   Vector2 Position = Vector2(0.33, 0.19); //
   	 auto screenSize = ImGui_GetDisplaySize();
   	 ImGui_SetNextWindowPos(screenSize * Position);

   	 int windowFlags = 
        ImGuiWindowFlags_NoTitleBar | 
        ImGuiWindowFlags_NoMove | 
        ImGuiWindowFlags_NoResize | 
        ImGuiWindowFlags_NoInputs | 
        ImGuiWindowFlags_NoScrollbar | 
        ImGuiWindowFlags_AlwaysAutoResize|
        0;
    ImGui_PushStyleColor(ImGuiCol_WindowBg, BgColor);
    ImGui_PushStyleColor(ImGuiCol_Text, textColor);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(10,5));
    ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0.0);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
    bool open = true;
    if (ImGui_Begin("状态TABID" +  open, windowFlags)){ 

    if(GetTeam(i) == -1)
            {
			
            }
	if(GetTeam(i) == -1)
            {
            }
 

    }
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();
    ImGui_End();
    
}
void TabID2()
{
    Vector4 textColor;
    string name = GetCharName(i);
    int name2 = GetHP(i);
	if(name2 > 0)
    {
    textColor = Vector4(1,1,1,1);
    }
    if(name2 <= 0)
    {
    textColor = Vector4(255,0,0,1);
    }
    
  Vector4  BgColor = Vector4(0.0,0,0,0); // 
 Vector2   Position = Vector2(0.55, 0.19); //
   	 auto screenSize = ImGui_GetDisplaySize();
   	 ImGui_SetNextWindowPos(screenSize * Position);

   	 int windowFlags = 
        ImGuiWindowFlags_NoTitleBar | 
        ImGuiWindowFlags_NoMove | 
        ImGuiWindowFlags_NoResize | 
        ImGuiWindowFlags_NoInputs | 
        ImGuiWindowFlags_NoScrollbar | 
        ImGuiWindowFlags_AlwaysAutoResize|
        0;
    ImGui_PushStyleColor(ImGuiCol_WindowBg, BgColor);
    ImGui_PushStyleColor(ImGuiCol_Text, textColor);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(10,5));
    ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0.0);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
    bool open = true;
    if (ImGui_Begin("状态TABID2" +  open, windowFlags)){ 
        

            if (GetTeam(i) == 0 || GetTeam(i) == 2|| GetTeam(i) == 1)
            {
            }
        	
       
        

    }
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();
    ImGui_End();
    
}
int i ;
int tgtab = 0;
float tgtabtimer = 0;
void Tab()
{
    if( ImGui_IsKeyDown(ImGuiKey_Tab))
    {
        BigTab();
        BigTab2();
        string name = GetCharName(i);
        for(i = 1;i<99;i++)
        {
            if(i>0)
            {
				TabID();
                TabID2();
            }
        }
    }
}
void Level_OnStart()
{
EnableKeyCommand(true); EnableKeyEsc(true);
}

void Level_OnUpdate()
{
    int player = GetAnyChar("player");  
	Tab();
    for(int team2life = 0;team2life<99;team2life++)
    {
        int life = GetHP(team2life);
		int attack = GetAttack(team2life);
        int defense = GetDefense(team2life);
        int speed = GetSpeed(team2life);
        int a = life/10000;
        int b = (life - (a*10000))/1000;
        int c = (life - (a*10000)- (b*1000))/100;
        int d = (life - (a*10000)- (b*1000)- (c*100))/10;
        int e = life - (a*10000)- (b*1000)- (c*100)-(d*10);
        SetTarget(0,"char",team2life);
        SetTarget(1,"char",player);
        string name = GetCharName(team2life);
		
        if(Distance(0,1) < 100 &&  life > 0)
        {

            	Vector4 BgColor = Vector4(0,0,0,0.4); 
    	 Vector2 Position = Vector2(0.05, 0.05); 
    	auto screenSize = ImGui_GetDisplaySize();
    	ImGui_SetNextWindowPos(screenSize * Position);
    	int windowFlags = 
        	ImGuiWindowFlags_NoTitleBar | 
        	ImGuiWindowFlags_NoMove | 
       	 ImGuiWindowFlags_NoResize |  
    	 ImGuiWindowFlags_NoInputs |
    	 ImGuiWindowFlags_NoScrollbar | 
    	 ImGuiWindowFlags_AlwaysAutoResize|
       	 0;
   	 ImGui_PushStyleColor(ImGuiCol_WindowBg, BgColor);
   	 ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(15,10));
    	ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0.0);
    	ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 5.1f);
    	bool open = true;
		if( ImGui_IsKeyDown(ImGuiKey_Tab)){
    	if (ImGui_Begin("最近敌人血量" +  open, windowFlags))
	{      
        ImGui_Text(name + "   生命值："+ life/10 + "."+ GetHP(team2life)%10+"攻"+attack+"防"+defense+"速"+speed);
   	 }
	 }
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();
    ImGui_End();		
         }
    }
}
void Level_OnStop(){
	Print("OnStop");
}

void ShowActivePosePanel(){
    // 设置窗口位置
    Vector4 bgColor = Vector4(0,0,0,0.0); // 背景颜色, 0.0~1.0
    Vector2 position = Vector2(0.8, 0.0); // 位置, 0.0~1.0
    auto screenSize = ImGui_GetDisplaySize();
    ImGui_SetNextWindowPos(screenSize * position);

    // 窗口基本属性
    int windowFlags = 
        ImGuiWindowFlags_NoTitleBar | // 无标题栏
        ImGuiWindowFlags_NoMove |  // 禁止拖动
        ImGuiWindowFlags_NoResize |  // 禁止手动调整窗口大小
        ImGuiWindowFlags_AlwaysAutoResize |  // 总是自动调整窗口大小
        ImGuiWindowFlags_NoInputs | // 穿透鼠标
        ImGuiWindowFlags_NoScrollbar | // 无滚动条
        0;

    ImGui_PushStyleColor(ImGuiCol_WindowBg, bgColor);

    // 窗口边框宽度为0
    ImGui_PushStyleVar(ImGuiStyleVar_WindowPadding,  Vector2(0,0));
    ImGui_PushStyleVar(ImGuiStyleVar_IndentSpacing,  0);
    ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);

    bool open = true;
    if (ImGui_Begin("角色Pose面板", open, windowFlags)){
        int[] idList = GetCharIdList(); // 获取角色ID列表
        int charCount = idList.GetSize(); // 总角色人数
        // 循环获取角色ID，并在屏幕上写字
        for (int i = 0; i < charCount; i++){ 
            int charId = idList[i]; 
            int pose = GetActivePose(charId);
            ImGui_Text(charId + " : " + pose);
        }
    }

    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleVar();
    ImGui_PopStyleColor();

    ImGui_End();
}


