WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Understanding how to correctly scale the WorldMapFrame (https://www.wowinterface.com/forums/showthread.php?t=57176)

gemt 06-01-19 01:54 AM

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.

Resike 06-01-19 07:33 AM

The question is do you really want to scale it or just make it bigger?

gemt 06-01-19 07:48 AM

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

Kanegasi 06-01-19 08:19 AM

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.

Aftermathhqt 06-01-19 12:56 PM

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

Seerah 06-01-19 02:21 PM

Is there a parent container for all relevant frames to resize instead?

gemt 06-01-19 04:51 PM

Quote:

Originally Posted by Seerah (Post 332271)
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.

elcius 06-01-19 05:23 PM

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

gemt 06-02-19 01:23 AM

Quote:

Originally Posted by elcius (Post 332273)
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.


All times are GMT -6. The time now is 03:56 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI