08-03-10, 12:33 PM | #1 |
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 thanks for your time Last edited by weasoug : 08-03-10 at 12:48 PM. |
|
08-03-10, 03:22 PM | #2 |
I think changing mask texture requires a reloaded UI.
__________________
|
|
08-03-10, 03:26 PM | #3 |
08-03-10, 03:27 PM | #4 |
I thought it even requires a logout rather than reload UI. Not sure though.
|
|
08-03-10, 04:07 PM | #5 | |||
as i have
|
||||
08-03-10, 04:26 PM | #6 |
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
|
|
08-03-10, 05:59 PM | #7 |
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 |
|
08-03-10, 07:29 PM | #8 |
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. |
|
08-04-10, 05:58 AM | #9 | ||||
thanks for the help guys.
and on the note of Code:
function GetMinimapShape() return 'SQUARE' end 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") 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
i cant see what to use other then minimapshape. for this. as people who use my addon. they have to change
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. |
|||||
08-04-10, 10:21 AM | #10 |
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) |
|
09-10-10, 10:40 AM | #11 |
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") 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) |
|
09-10-10, 05:48 PM | #12 |
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). |
|
WoWInterface » Developer Discussions » Lua/XML Help » Minimap Shape help |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|