function WindMinimapConfig_OnShow()
	WindMinimapConfigBody_show();
	
	local BtnNums = #(WindMinimapConfigAll["BlzButtons"]);
	for i=1, BtnNums do	
		WindMinimapConfigButton_show(i);
	end
end

function WindMinimapConfigVIEWTEX_OnClick(this)
	local parent = this:GetParent():GetName();
	if (this:GetChecked()) then
		this:SetChecked(1);
		getglobal(parent.."_setTexture")(true);
	else
		this:SetChecked(0);
		getglobal(parent.."_setTexture")(false);
	end
end

function WindMinimapConfigVIEWCOORD_OnClick(this)
	local parent = this:GetParent():GetName();
	if (this:GetChecked()) then
		this:SetChecked(1);
		getglobal(parent.."_setCoords")(true);
	else
		this:SetChecked(0);
		getglobal(parent.."_setCoords")(false);
	end
end

-- ************** 미니맵 설정 관련 함수 **************
function WindMinimapConfigBody_show()
	local config = WindMinimapConfigAll["Body"];

	WindConfig_setUnCheckAll("WindMinimapConfigBody");
	WindConfig_setCheck("WindMinimapConfigBody", config[1]);
	WindMinimapConfigBodyX:SetText(config[2]);
	WindMinimapConfigBodyY:SetText(config[3]);
	WindMinimapConfigBodySCALE:SetText(string.format("%0.3f", config[4]));
	if (config[5]) then WindMinimapConfigBodyVIEWTEX:SetChecked(1);
	else WindMinimapConfigBodyVIEWTEX:SetChecked(0); end
	if (config[6]) then WindMinimapConfigBodyCOLOR1NormalTexture:SetVertexColor(config[6][1].r, config[6][1].g, config[6][1].b, config[6][1].a);
	WindMinimapConfigBodyCOLOR2NormalTexture:SetVertexColor(config[6][2].r, config[6][2].g, config[6][2].b, config[6][2].a); end
	if (config[7]) then WindMinimapConfigBodyVIEWCOORD:SetChecked(1);
	else WindMinimapConfigBodyVIEWCOORD:SetChecked(0); end
	if (config[8]) then WindMinimapConfigBody_setForm(); end
end

function WindMinimapConfigBody_setForm()
	local form = nil;
	for i=1, 2 do
		form = getglobal("WindMinimapConfigBodyForm"..i);
		if (form) then form:SetChecked(0); end
	end
	getglobal("WindMinimapConfigBodyForm"..WindMinimapConfigAll["Body"][8]):SetChecked(1);
end

function WindMinimapConfigBody_setConfigPoint(point, x, y)
	local config = WindMinimapConfigAll["Body"];

	config[1] = point;
	config[2] = x;
	config[3] = y;
	WindMinimapBody_setPoint();
end

function WindMinimapConfigBody_setConfigX(x)
	WindMinimapConfigAll["Body"][2] = x;
	WindMinimapBody_setPoint();
end

function WindMinimapConfigBody_setConfigY(y)
	WindMinimapConfigAll["Body"][3] = y;
	WindMinimapBody_setPoint();
end

function WindMinimapConfigBody_setConfigScale(scale)
	WindMinimapConfigAll["Body"][4] = scale;
	WindMinimapBody_setScale();
end

function WindMinimapConfigBody_getPoint()
	return WindMinimapConfigAll["Body"][1];
end

function WindMinimapConfigBody_setTexture(haveTexture)
	WindMinimapConfigAll["Body"][5] = haveTexture;
	WindMinimapBody_setTexture();
	WindMinimapBody_setColor();
end

function WindMinimapConfigBody_setColor(color)
	if (color) then WindMinimapBody_setColor(); end
end

function WindMinimapConfigBody_resetColor()
	WindMinimapBody_resetColor();

	local colorArray = WindMinimapConfigAll["Body"][6];
	WindMinimapConfigBodyCOLOR1NormalTexture:SetVertexColor(colorArray[1].r, colorArray[1].g, colorArray[1].b, colorArray[1].a);
	WindMinimapConfigBodyCOLOR2NormalTexture:SetVertexColor(colorArray[2].r, colorArray[2].g, colorArray[2].b, colorArray[2].a);
end

function WindMinimapConfigBody_setCoords(haveCoords)
	WindMinimapConfigAll["Body"][7] = haveCoords;
	WindMinimapBody_setCoords();
end

function WindMinimapConfigBody_setType(nmb)
	WindMinimapConfigAll["Body"][8] = nmb;
	WindMinimapConfigBody_setForm();
	WindMinimapBody_setTexture();
	WindMinimapBody_setColor();
	WindMinimapBody_setForm();
end

-- ************** 미니맵 버튼 설정 공통 함수 **************
function WindMinimapConfigButton_show(index)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index];
	local curBtn = curBtnConfig[5];
	local target = getglobal("MiniMap"..curBtnConfig[5]..curBtnConfig[6]);
	local curConfigFrame = "WindMinimapConfig"..curBtn;

	target:Show();	-- 무조건 보인다.(숨김 설정된 것도 일단 보이게 한다.)
	WindConfig_setUnCheckAll(curConfigFrame);
	WindConfig_setCheck(curConfigFrame, curBtnConfig[1]);
	if getglobal(curConfigFrame.."VIEW") then
		local chkView = getglobal(curConfigFrame.."VIEW")
		
		if curBtnConfig[7] == 0 then 
			chkView:SetChecked(0);
		elseif(curBtnConfig[7] > 0) then 
			chkView:SetChecked(1);
		end
	end
	getglobal(curConfigFrame.."X"):SetText(curBtnConfig[2]);
	getglobal(curConfigFrame.."Y"):SetText(curBtnConfig[3]);
	getglobal(curConfigFrame.."SCALE"):SetText(string.format("%0.3f", curBtnConfig[4]));
end

function WindMinimapConfigButton_setConfigPoint(index, point, x, y)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index]; 
	curBtnConfig[1] = point;
	curBtnConfig[2] = x;
	curBtnConfig[3] = y;
	WindMinimapButton_setPoint(index);
end

function WindMinimapConfigButton_setConfigX(index, x)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index]; 
	curBtnConfig[2] = x;
	WindMinimapButton_setPoint(index);
end

function WindMinimapConfigButton_setConfigY(index, y)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index]; 
	curBtnConfig[3] = y;
	WindMinimapButton_setPoint(index);
end

function WindMinimapConfigButton_setConfigScale(index, scale)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index]; 
	curBtnConfig[4] = scale;
	WindMinimapButton_setScale(index);
end

function WindMinimapConfigButton_getPoint(index)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index]; 
	return curBtnConfig[1];
end

function WindMinimapConfigButton_setVisible(index)
	local curBtnConfig = WindMinimapConfigAll["BlzButtons"][index];
	-- -1 로 설정된 파일은 반드시 보여야 할 버튼이므로 설정을 못하게 한다.
	if curBtnConfig[7] == 0 then 
		WindMinimapConfigAll["BlzButtons"][index][7] = 1;
		WindCommon_Print("미니맵에 "..curBtnConfig[5].." 버튼을 표시하도록 설정합니다. 다음 접속부터 적용됩니다.");
	elseif curBtnConfig[7] == 1 then
		WindMinimapConfigAll["BlzButtons"][index][7] = 0;
		WindCommon_Print("미니맵에 "..curBtnConfig[5].." 버튼을 표시하지 않도록 설정합니다. 바로 적용됩니다.");
	elseif curBtnConfig[7] == -1 then
		return;
	end

	WindMinimapButton_setVisible(index);
end

-- 여기서 부터는 WindConfig에서 접근하기 위한 Adapter 역할의 함수...
-- 좀 기형적인 구조이긴 하지만, 이렇게 안하면 Config 관련 하위모듈 다 수정해야 하므로 어쩔 수 없음. -_-;;
-- 미니맵 버튼 index 는 WindMinimapConfig["Buttons"] 요소의 index 값에 따라 간다.
-- 1:Mail, 2:Tracking, 3: Battlefield, 4:MeetingStone, 5:WorldMap

-- ************** 미니맵 메일(Mail) 버튼 설정 관련 함수 **************
function WindMinimapConfigMail_show() WindMinimapConfigButton_show(1); end
function WindMinimapConfigMail_setConfigPoint(point, x, y) WindMinimapConfigButton_setConfigPoint(1, point, x, y); end
function WindMinimapConfigMail_setConfigX(x) WindMinimapConfigButton_setConfigX(1, x); end
function WindMinimapConfigMail_setConfigY(y) WindMinimapConfigButton_setConfigY(1, y); end
function WindMinimapConfigMail_setConfigScale(scale) WindMinimapConfigButton_setConfigScale(1, scale); end
function WindMinimapConfigMail_getPoint() return WindMinimapConfigButton_getPoint(1); end

-- ************** 미니맵 추적(Tracking) 버튼 설정 관련 함수 **************
function WindMinimapConfigTracking_show() WindMinimapConfigButton_show(2); end
function WindMinimapConfigTracking_setConfigPoint(point, x, y) WindMinimapConfigButton_setConfigPoint(2, point, x, y); end
function WindMinimapConfigTracking_setConfigX(x) WindMinimapConfigButton_setConfigX(2, x); end
function WindMinimapConfigTracking_setConfigY(y) WindMinimapConfigButton_setConfigY(2, y); end
function WindMinimapConfigTracking_setConfigScale(scale) WindMinimapConfigButton_setConfigScale(2, scale); end
function WindMinimapConfigTracking_getPoint() return WindMinimapConfigButton_getPoint(2); end

-- ************** 미니맵 전장(Battlefield) 버튼 설정 관련 함수 **************
function WindMinimapConfigBattlefield_show() WindMinimapConfigButton_show(3); end
function WindMinimapConfigBattlefield_setConfigPoint(point, x, y) WindMinimapConfigButton_setConfigPoint(3, point, x, y); end
function WindMinimapConfigBattlefield_setConfigX(x) WindMinimapConfigButton_setConfigX(3, x); end
function WindMinimapConfigBattlefield_setConfigY(y) WindMinimapConfigButton_setConfigY(3, y); end
function WindMinimapConfigBattlefield_setConfigScale(scale) WindMinimapConfigButton_setConfigScale(3, scale); end
function WindMinimapConfigBattlefield_getPoint() return WindMinimapConfigButton_getPoint(3); end

-- ************** 미니맵 파티찾기(MeetingStone) 버튼 설정 관련 함수 **************
function WindMinimapConfigMeetingStone_show() WindMinimapConfigButton_show(4); end
function WindMinimapConfigMeetingStone_setConfigPoint(point, x, y) WindMinimapConfigButton_setConfigPoint(4, point, x, y); end
function WindMinimapConfigMeetingStone_setConfigX(x) WindMinimapConfigButton_setConfigX(4, x); end
function WindMinimapConfigMeetingStone_setConfigY(y) WindMinimapConfigButton_setConfigY(4, y); end
function WindMinimapConfigMeetingStone_setConfigScale(scale) WindMinimapConfigButton_setConfigScale(4, scale); end
function WindMinimapConfigMeetingStone_getPoint() return WindMinimapConfigButton_getPoint(4); end

-- ************** 미니맵 세계지도(WorldMap) 버튼 설정 관련 함수 **************
function WindMinimapConfigWorldMap_show() WindMinimapConfigButton_show(5); end
function WindMinimapConfigWorldMap_setConfigPoint(point, x, y) WindMinimapConfigButton_setConfigPoint(5, point, x, y); end
function WindMinimapConfigWorldMap_setConfigX(x) WindMinimapConfigButton_setConfigX(5, x); end
function WindMinimapConfigWorldMap_setConfigY(y) WindMinimapConfigButton_setConfigY(5, y); end
function WindMinimapConfigWorldMap_setConfigScale(scale) WindMinimapConfigButton_setConfigScale(5, scale); end
function WindMinimapConfigWorldMap_getPoint() return WindMinimapConfigButton_getPoint(5); end
function WindMinimapConfigWorldMap_setVisible() WindMinimapConfigButton_setVisible(5); end
