Quantcast Understanding how to correctly scale the WorldMapFrame - WoWInterface
Thread Tools Display Modes
06-01-19, 01:54 AM   #1
gemt
A Murloc Raider
Join Date: Dec 2011
Posts: 4
Understanding how to correctly scale the WorldMapFrame

I am very new to modifying UI elements in wow, so bear with me here please.

I am playing around with modifying the default WorldMapFrame. Using fstack i'm able to figure out which elements to hide/show, and i can move and rescale the frame as I want. All good.

However, when rescaling the WorldMapFrame with SetScale, the WorldMap.ScrollContainer children used for highlighting the zone you're mouseovering, and accepting clicks to change zones, no longer appear to be located where they are visually.



The image above tries to show what I mean. The mouse cursor in the image is at the red dot, NE of STV, while STV is highlighted. The WorldMapFrame in the screenshot is scaled down, and all the visuals are correct, except the mouse cursor thinks STV is located in another location than it is visually.

I have been fiddling around with various ways of scaling the WorldMapFrame, including trying to also explicitly scale the WorldMapFrame.ScrollContainer, or by resizing it with SetWidth/Height instead. With SetWidth/Height, the cursor issue seems to not be present, but that opens other issues, and from my simple understanding of things, setScale is really what I should be using anyway.

I have spent a bit of time looking at existing map addons, testing fragments of their code to see if I get the expected behaviour, but I am not. I feel this should be a fairly simple thing to solve, I am just missing some piece of knowledge of the relationship between the WorldMapFrame and the ScrollContainer/other children. But maybe I'm far of?

Before anyone suggests it, no I don't want to just use an existing map addon. I am interested in understanding how this all ties together for educational purposes.

Is anyone able to explain how these things are fitted together, and how one is meant to scale it?

Edit: Forgot to mention I am testing this on the WoW Classic Beta, and there are differences between the 8.x WorldMapFrame and the Classic WorldMapFrame, but I don' think there is anything that should be different for simple scaling of the map frame.

Last edited by gemt : 06-01-19 at 11:32 AM.
  Reply With Quote
06-01-19, 07:33 AM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
The question is do you really want to scale it or just make it bigger?
  Reply With Quote
06-01-19, 07:48 AM   #3
gemt
A Murloc Raider
Join Date: Dec 2011
Posts: 4
I'm primarily interested in making the entire frame smaller/bigger with mousewheel scroll as shown in these two screenshots.




This scaling is done by only using WorldMapFrame:SetScale(), and visually its all good, until you mouse over zones on the map and realize there is something wrong with how the map interprets the mouse cursor possition.

Edit: For some reason i can't see the embedded images I added, in this post or the OP, so i removed the img tags

Last edited by gemt : 06-01-19 at 11:32 AM.
  Reply With Quote
06-01-19, 08:19 AM   #4
Kanegasi
An Onyxian Warder
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 399
The embedded images weren’t working because you didn’t have any actual image locations. When sharing images hosted elsewhere, you need the image address, here you were using the pages on Imgur the pictures were shown instead. The easiest way to get this is to right click an image and select “copy image address” for Chrome or “copy image location” for Firefox. On Imgur, direct links are provided on the right side of the page.

Here’s the direct links to your three images:

https://i.imgur.com/MihzUT7.jpg
https://i.imgur.com/BwjxQHX.jpg
https://i.imgur.com/TY39Pxf.jpg

On Imgur, there’s a weird bug (might be Chrome related) where right clicking a freshly uploaded picture will give some kind of blob:// string instead. Just refresh the page.

Last edited by Kanegasi : 06-01-19 at 08:22 AM.
  Reply With Quote
06-01-19, 12:56 PM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 783
I had this issue, i tried work around it, but it just won't work, i've tried to re-size WorldMapFrame, WorldMapFrame.ScrollContainer.Child etc, no results.

For now i've just skinned it and repositioned it and this works.

Lua Code:
  1. function WorldMap:SkinMap()
  2.     local WorldMapHolder = CreateFrame("Frame", nil, UIParent)
  3.     WorldMapHolder:Size(WorldMapFrame:GetWidth(), WorldMapFrame:GetHeight())
  4.     WorldMapHolder:Point("CENTER", UIParent, 0, 122)
  5.  
  6.     WorldMapFrame:SetParent(WorldMapHolder)
  7.     WorldMapFrame:ClearAllPoints()
  8.     WorldMapFrame:Point("CENTER", WorldMapHolder, 0, 0)
  9.  
  10.     hooksecurefunc(WorldMapFrame, "SetPoint", function(_,_, Parent)
  11.         if (Parent ~= WorldMapHolder) then
  12.             WorldMapFrame:ClearAllPoints()
  13.             WorldMapFrame:Point("TOP", WorldMapHolder, 0, 0)
  14.         end
  15.     end)
  16. end
  Reply With Quote
06-01-19, 02:21 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,662
Is there a parent container for all relevant frames to resize instead?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-01-19, 04:51 PM   #7
gemt
A Murloc Raider
Join Date: Dec 2011
Posts: 4
Originally Posted by Seerah View Post
Is there a parent container for all relevant frames to resize instead?
You would assume that would be the WorldMapFrame (it's the top level frame on fstack), but that's what I have tried with no luck.
The common parent of the zone frames is the ScrollContainer from what I can understand, and resizing that makes everything go crazy.

Will look at Aftermathhqt suggestion tomorrow.
  Reply With Quote
06-01-19, 05:23 PM   #8
elcius
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 67
The problem is that it uses GetCursorPosition, but does not account for frame scale. if you override the handler it may work.

Lua Code:
  1. WorldMapFrame.ScrollContainer.GetCursorPosition = function(f)
  2.     local x,y = MapCanvasScrollControllerMixin.GetCursorPosition(f);
  3.     local s = WorldMapFrame:GetScale();
  4.     return x/s, y/s;
  5. end

Last edited by elcius : 06-01-19 at 05:25 PM.
  Reply With Quote
06-02-19, 01:23 AM   #9
gemt
A Murloc Raider
Join Date: Dec 2011
Posts: 4
Originally Posted by elcius View Post
The problem is that it uses GetCursorPosition, but does not account for frame scale. if you override the handler it may work.

Lua Code:
  1. WorldMapFrame.ScrollContainer.GetCursorPosition = function(f)
  2.     local x,y = MapCanvasScrollControllerMixin.GetCursorPosition(f);
  3.     local s = WorldMapFrame:GetScale();
  4.     return x/s, y/s;
  5. end
Thank you! This straight up solves the problem.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Understanding how to correctly scale the WorldMapFrame

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