Thread Tools Display Modes
08-03-10, 12:33 PM   #1
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post Minimap Shape help

Hi there all. I wanted to update my addon so you can do a command to change the shape.

this is what I have so far. I don't get any errors but when I do /wm round or /wm square my textures over lap the other.

so when you log in i have it set like this

Code:
function GetMinimapShape() return 'SQUARE' end
        local s = m:CreateTexture(nil,"square")
	s:SetTexture("Interface\\AddOns\\wMmap\\texture\\square")
	s:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
	s:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
	s:SetBlendMode("BLEND")

then when you want to change the shape I added this code

Code:
local function SHAPE(msg)
	local msg = strlower(msg)
	
	if msg == "square" then
		m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask.blp")
		function GetMinimapShape() return "SQUARE" end
        local s = m:CreateTexture(nil,"square")
	s:SetTexture("Interface\\AddOns\\wMmap\\texture\\square")
	s:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
	s:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
	s:SetBlendMode("BLEND")
		print(wname.."|cFF00FFFF: Set to Square.|r")
	elseif msg == "round" then
		Minimap:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask-ROUND")
		function GetMinimapShape() return "ROUND" end
        local r = m:CreateTexture(nil,"round")
	r:SetTexture("Interface\\AddOns\\wMmap\\texture\\round")
	r:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
	r:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
	r:SetBlendMode("BLEND")
		print(wname.."|cFF00FFFF: Set to Round.|cFF00FFFF")
	else
		print(wname.."|cFF00FFFF: Type /shape round or square to change the shape|cFF00FFFF")
	end
end

SLASH_SHAPE1 = "/shape"
SlashCmdList["SHAPE"] = SHAPE
an image to see




thanks for your time

Last edited by weasoug : 08-03-10 at 12:48 PM.
  Reply With Quote
08-03-10, 03:22 PM   #2
Guardix
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 42
I think changing mask texture requires a reloaded UI.
__________________
  Reply With Quote
08-03-10, 03:26 PM   #3
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Guardix View Post
I think changing mask texture requires a reloaded UI.


i guess your right, as i have tryed a few things.
  Reply With Quote
08-03-10, 03:27 PM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I thought it even requires a logout rather than reload UI. Not sure though.
  Reply With Quote
08-03-10, 04:07 PM   #5
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Haleth View Post
I thought it even requires a logout rather than reload UI. Not sure though.
wel this is what my minimap addon uses.

if minimapshape == "round" then
function GetMinimapShape() return "ROUND" end
m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask-ROUND")

local r = m:CreateTexture(nil,"round")
r:SetTexture("Interface\\AddOns\\wMmap\\texture\\round")
r:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
r:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
r:SetBlendMode("BLEND")
but like said it needs a reload to change.

as i have

local minimapshape = "round"
and to change the round to the shape you want. and then you can reload. but i felt i could add this into a command.
  Reply With Quote
08-03-10, 04:26 PM   #6
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
I tried this with MidgetMap and did the same thing and thought it wasn't going to work, so I just got rid of my skins, and made it a plain minimap instead so the shape call command ingame would be possible, using your own textures :P
  Reply With Quote
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
08-03-10, 07:29 PM   #8
Ricowan
A Deviate Faerie Dragon
 
Ricowan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 19
Take a look at the source for my minimap addon, I do what you're wanting to do. Feel free to use any of my code you'd like, I don't mind.

GetMinimapShape() is a global function that other addons can call so they can make sure their minimap icons conform to the shape of your minimap. This was initiated by developers using the ACE libraries, but it isn't limited to that group at all. The function should return a string containing one of the pre-defined shapes; mine returns "CORNER-BOTTOMLEFT", "SQUARE", or "ROUND" depending on the shape that's currently being used. I would suggest that all minimap addons that change the shape of the map should use this function, if it applies to your shapes.
  Reply With Quote
08-04-10, 05:58 AM   #9
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Thumbs up

thanks for the help guys.

and on the note of

Code:
function GetMinimapShape() return 'SQUARE' end
I used this as I wanted a way for the addons to load with that shape.

so I have everything all working by. when you log in you just have to do the command to change the shape and image. that I think is what I might keep it that way.

unless there is a way. I can still get the addon to load a default shape/

but to do that. I think I would have to add aload more of junk maybe like

Code:
function GetMinimapShape() return 'SQUARE' end
        m:SetMaskTexture([[Interface\AddOns\wMmap\texture\mask-square]])
        local s = m:CreateTexture(nil,"square")
	s:SetTexture("Interface\\AddOns\\wMmap\\texture\\square")
	s:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
	s:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
	s:SetBlendMode("BLEND")
keep it as S as I could use the T format. but I think the set texture would conflict with the commands. as would SetMaskTexture when the command is used.

if there is a way i can cut this down.


I am very greatful for all your time. and Vrul /bow

but i have taken heed of what you have said. as till im happy with the in game change shape. im going to update my main addon with some of the info you have said. well a clean up as it was.

from
local minimapshape = "round"
--square or round shape of minimap

if minimapshape == "round" then
function GetMinimapShape() return "ROUND" end
m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask-ROUND")

local r = m:CreateTexture(nil,"round")
r:SetTexture("Interface\\AddOns\\wMmap\\texture\\round")
r:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
r:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
r:SetBlendMode("BLEND")

elseif minimapshape == "square" then
function GetMinimapShape() return "SQUARE" end
m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask.blp")

local s = m:CreateTexture(nil,"square")
s:SetTexture("Interface\\AddOns\\wMmap\\texture\\square")
s:SetPoint("TOPLEFT", m, "TOPLEFT", -12, 12)
s:SetPoint("BOTTOMRIGHT", m, "BOTTOMRIGHT", 12, -12)
s:SetBlendMode("BLEND")
end
to

--square or round shape of minimap
local minimapshape = "round"

local t = m:CreateTexture(nil, 'ARTWORK')
t:SetPoint('TOPLEFT', m, 'TOPLEFT', -12, 12)
t:SetPoint('BOTTOMRIGHT', m, 'BOTTOMRIGHT', 12, -12)
t:SetBlendMode('BLEND')

if minimapshape == "round" then
function GetMinimapShape() return "ROUND" end
m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask-ROUND")
t:SetTexture("Interface\\AddOns\\wMmap\\texture\\round")

elseif minimapshape == "square" then
function GetMinimapShape() return "SQUARE" end
m:SetMaskTexture("Interface\\AddOns\\wMmap\\texture\\Mask.blp")
t:SetTexture("Interface\\AddOns\\wMmap\\texture\\square")
end
of what is a lot better. less code. hehe
i cant see what to use other then minimapshape. for this.

as people who use my addon. they have to change
local minimapshape = "round"
to
local minimapshape = "square"
thats why i have been asking for help. so people can use a command in game.

and with the code you have helped me with. works well.
I feel would be too soon. to update my addon with hthat code. till all commands are in with help.

but as always im greatful. and i cant wait for other cool ways or edits i can aadd to your code.

it might even get to the ppoint where i just use you command style as it is. if i cant work out how to tell the addon to load a defult.
im not big into SV as most still is saved in the layout-local

Last edited by weasoug : 08-04-10 at 06:32 AM.
  Reply With Quote
08-04-10, 10:21 AM   #10
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
The first line should be near the top of your file, the rest can be at the end:
Code:
local minimapshape = 'ROUND'

function GetMinimapShape()
	return minimapshape
end

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:upper()
	if msg == 'SQUARE' then
		minimapshape = msg
		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
		minimapshape = msg
		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

SHAPE(minimapshape)
  Reply With Quote
09-10-10, 10:40 AM   #11
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

with this working fine. people keep asking to have the shape they use in game to save. ive been trying a few things.

and maybe i was thinknig usen
Code:
t:SetUserPlaced(true)
Code:
t:RegisterEvent("ADDON_LOADED")
as i read that saves to the layout-local

but unsure if that would work due to i think i remember it dont work for frame maken.

like

Code:
wmshape = "arrow"
--top of code

function Getwmshape()
	return wmshape
end

local t = Minimap:CreateTexture(nil, 'ARTWORK')
t:SetPoint('TOPLEFT', Minimap, 'TOPLEFT', -12, 12)
t:SetPoint('BOTTOMRIGHT', Minimap, 'BOTTOMRIGHT', 12, -12)
t:SetBlendMode('BLEND')
t:RegisterEvent("ADDON_LOADED") 
local wname = "|cff3399FFw|rMmap|r"
local function CList(msg)
	msg = msg:lower()
	if msg == "gold" or msg == "gloss" or msg == "arrow" or msg == "tec" then
		Minimap:SetMaskTexture([[Interface\AddOns\wMmap\texture\mask-]] .. msg)
		t:SetTexture([[Interface\AddOns\wMmap\texture\]] .. msg)
                t:SetUserPlaced(true) 
		print(wname.."|cFF00FFFF: Shape set to " .. msg .. ".|r")
	else
	print(wname..": Type |cFF00FFFF /wm shape|r here. Example: |cFFFFFF00/wm gold|r or |cFFFFFF00/wm gloss|r or |cFFFFFF00/wm arrow|r or |cFFFFFF00/wm tec|r.")
	end
end

SLASH_CList1 = "/wm"
SlashCmdList["CList"] = CList

CList(wmshape)
any help would be very welcome
  Reply With Quote
09-10-10, 05:48 PM   #12
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
The shape (round or square) will be saved but that doesn't help much since I'm sure the users would care more about the actual texture (custom texture) that goes with it. The only way to keep that value persistent across sessions is to use saved variables. Considering all your other configuration is basically done through editing the top of the lua file, I don't really see the point in one setting being different than all the others.

I'd recommend just keeping the configuration solely through lua edits like it is for the rest, otherwise, you will need to use saved variables and apply the settings once they are loaded. If you are going to do that for one setting then you may as well do it for all of them. Which means needing to expand your slash command or adding a GUI.

Also, I think it was you that mentioned wanting the addon to be light weight and that was one reason you were sticking to editing the lua for all configuration (could be mistaken). I'd say just remove the ability to change the "shape" in game and have them manually edit wmshape in the lua like for the other config options.

Side note: In that code you just posted, textures don't have OnEvent scripts or a RegisterEvent method. And registering an event without an OnEvent handler won't accomplish anything anyway. I doubt textures have a SetUserPlaced method either (don't feel like checking).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Minimap Shape help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off