WindActionPetSize = {
	{355, 49},
	{185, 83},
	{83, 185},
	{49, 355}
}

function WindActionPet_OnLoad()
	this:RegisterEvent("VARIABLES_LOADED");
end

function WindActionPet_OnEvent()
	if (event == "VARIABLES_LOADED") then
		WindActionPet_initConfig();
		WindActionPet_setPointAndSize();
		WindActionPet_setBorder();
		WindActionPet_setScale();
	end
end

function WindActionPet_initConfig()
	if (not WindActionPetConfig) then WindActionPetConfig = WindActionDefault["Pet"]; end

	if (IsAddOnLoaded("WindConfig")) then 
		WindActionConfigPet_show();
		WindActionConfigPet_setColor(color); 
	end
end

function WindActionPet_setPointAndSize()
	local index = WindActionPetConfig[5];
	WindCommon_setSize(WindActionPet, WindActionPetSize[index][1], WindActionPetSize[index][2]);
	WindCommon_setPoint(WindActionPet, WindActionPetConfig[1], UIParent, WindActionPetConfig[1], WindActionPetConfig[2], WindActionPetConfig[3]);
	-- 팻 액션버튼 위치 설정
	WindCommon_setPoint(PetActionButton1, "TOPLEFT", WindActionPet, "TOPLEFT", 10, -9);
	WindActionPet_setAnchor(index);
end


function WindActionPet_setScale()
	WindActionPet:SetScale(WindActionPetConfig[4]);
	for i=1, 10 do
		getglobal("PetActionButton"..i):SetScale(WindActionPetConfig[4]);

		-- Frame Strata를 낮춘다.
		getglobal("PetActionButton"..i):SetFrameStrata("LOW");
	end
end

function WindActionPet_setAnchor(index)
	if (index == 1) then
		WindCommon_setPoint(PetActionButton2, "LEFT", PetActionButton1, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton3, "LEFT", PetActionButton2, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton4, "LEFT", PetActionButton3, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton5, "LEFT", PetActionButton4, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton6, "LEFT", PetActionButton5, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton7, "LEFT", PetActionButton6, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton8, "LEFT", PetActionButton7, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton9, "LEFT", PetActionButton8, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton10, "LEFT", PetActionButton9, "RIGHT", 4, 0);
	elseif (index == 2) then
		WindCommon_setPoint(PetActionButton2, "LEFT", PetActionButton1, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton3, "LEFT", PetActionButton2, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton4, "LEFT", PetActionButton3, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton5, "LEFT", PetActionButton4, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton6, "TOPLEFT", PetActionButton1, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton7, "LEFT", PetActionButton6, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton8, "LEFT", PetActionButton7, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton9, "LEFT", PetActionButton8, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton10, "LEFT", PetActionButton9, "RIGHT", 4, 0);
	elseif (index == 3) then
		WindCommon_setPoint(PetActionButton2, "LEFT", PetActionButton1, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton3, "TOPLEFT", PetActionButton1, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton4, "LEFT", PetActionButton3, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton5, "TOPLEFT", PetActionButton3, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton6, "LEFT", PetActionButton5, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton7, "TOPLEFT", PetActionButton5, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton8, "LEFT", PetActionButton7, "RIGHT", 4, 0);
		WindCommon_setPoint(PetActionButton9, "TOPLEFT", PetActionButton7, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton10, "LEFT", PetActionButton9, "RIGHT", 4, 0);
	elseif (index == 4) then
		WindCommon_setPoint(PetActionButton2, "TOPLEFT", PetActionButton1, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton3, "TOPLEFT", PetActionButton2, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton4, "TOPLEFT", PetActionButton3, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton5, "TOPLEFT", PetActionButton4, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton6, "TOPLEFT", PetActionButton5, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton7, "TOPLEFT", PetActionButton6, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton8, "TOPLEFT", PetActionButton7, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton9, "TOPLEFT", PetActionButton8, "BOTTOMLEFT", 0, -4);
		WindCommon_setPoint(PetActionButton10, "TOPLEFT", PetActionButton9, "BOTTOMLEFT", 0, -4);
	end
end

function WindActionPet_setBorder()
	if (WindActionPetConfig[6]) then 
		WindActionPet:SetBackdrop(WindCommon_ColorBorder);
		WindActionPet_setColor();
	else 
		WindActionPet:SetBackdrop(nil); 
	end
end

function WindActionPet_setColor()
	WindActionPet:SetBackdropBorderColor(WindActionPetConfig[7][1].r, WindActionPetConfig[7][1].g, WindActionPetConfig[7][1].b, WindActionPetConfig[7][1].a);
	WindActionPet:SetBackdropColor(WindActionPetConfig[7][2].r, WindActionPetConfig[7][2].g, WindActionPetConfig[7][2].b, WindActionPetConfig[7][2].a);
end

function WindActionPet_resetColor()
	WindActionPetConfig[7] = WindActionDefault["Pet"][7];
	WindActionPet_setColor();
end
