View Single Post
08-03-10, 05:59 PM   #7
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Your problem is that each time you change the shape of the minimap you are creating a new texture and slapping it over what was there before. You need to create one texture and reuse it to avoid your problem (and just for good programming).

Also, I can't figure out why you are creating the GetMinimapShape function. You don't use it in your code at all. I have seen a couple different people post something similar and all I can think of it is for compatibility with another addon or everyone is just basing their code off the same bad example. If that function really is needed I would suggest using an internal variable to keep track of the shape (should be saving it anyway) and create the function once and have it just return that setting.

To fix your problem quickly based on what you posted:
Code:
local t = m:CreateTexture(nil, 'ARTWORK')
t:SetPoint('TOPLEFT', m, 'TOPLEFT', -12, 12)
t:SetPoint('BOTTOMRIGHT', m, 'BOTTOMRIGHT', 12, -12)
t:SetBlendMode('BLEND')

local function SHAPE(msg)
	msg = msg:lower()
	if msg == "square" then
		m:SetMaskTexture([[Interface\AddOns\wMmap\texture\Mask]])
		t:SetTexture([[Interface\AddOns\wMmap\texture\square]])
		print(wname.."|cFF00FFFF: Shape set to square.|r")
	elseif msg == "round" then
		m:SetMaskTexture([[Interface\AddOns\wMmap\texture\Mask-ROUND]])
		t:SetTexture([[Interface\AddOns\wMmap\texture\round]])
		print(wname.."|cFF00FFFF: Shape set to round.|r")
	else
		print(wname.."|cFF00FFFF: Type /shape round or square to change the shape.|r")
	end
end

SLASH_SHAPE1 = "/shape"
SlashCmdList["SHAPE"] = SHAPE

You could also rename the texture files you are using to simplify it even more:
Code:
local t = m:CreateTexture(nil, 'ARTWORK')
t:SetPoint('TOPLEFT', m, 'TOPLEFT', -12, 12)
t:SetPoint('BOTTOMRIGHT', m, 'BOTTOMRIGHT', 12, -12)
t:SetBlendMode('BLEND')

local function SHAPE(msg)
	msg = msg:lower()
	if msg == "round" or msg == "square" then
		m:SetMaskTexture([[Interface\AddOns\wMmap\texture\mask-]] .. msg)
		t:SetTexture([[Interface\AddOns\wMmap\texture\]] .. msg)
		print(wname.."|cFF00FFFF: Shape set to " .. msg .. ".|r")
	else
		print(wname.."|cFF00FFFF: Type /shape round or square to change the shape.|r")
	end
end

SLASH_SHAPE1 = "/shape"
SlashCmdList["SHAPE"] = SHAPE
  Reply With Quote