-
Posted by cowmonster on Tue, 12 Apr 2011 07:53:35
Okay I have been at it for hours and thus far I am at a loss. The idea is simple enough, I created a ScrollFrame and the ScrollChild. In the scroll child I have the 12 textures that make up the world map. The scroll child is inside the parent frame and it is scrollable (Up to this point everything is going smashingly), but I can't get the math just right to scroll the frame based on the GetPlayerMapPosition("player"). I have placed the MapFrame (scroll child parent frame) and sized it and put the Minimap in the center and reduced the alpha. I want to set the scroll of the MapFrame so that MapFrameSC (the scroll child) lines up properly with the minimap. Additionally, I'm open to suggestions on how to make sure that the scaling all lines up right between the minimap and the MapFrameSC textures.
Edit: Okay so I figured out that the textures are 1024x768 (4 tiles wide and 3 tiles high at 256x256 per tile), but the Map itself is 1002x668 which is easy enough to compensate for, but when I attempt to scale everything it gets thrown off. Whatever I scale the 1024x768 frame to then the math should scale too, right?
local mapScale = MapFrameSC:GetScale() --What is our scale of the current map local unitX, unitY = GetPlayerMapPosition("player") --Blizzard's raw player coordinates in percentage of map width and height local pX, pY = unitX*(1002*mapScale), unitY*(668*mapScale) --New player coordinates scaled to the map local cX, cY = MapFrame:GetWidth()/2, MapFrame:GetHeight()/2 --Our offset to center of ScrollChild parent frame local sX, sY = 0, 0 --The variables for our scroll horizontal and vertical --Let's figure out which way we are scrolling and how much if cX > pX then sX = -(cX-pX) end if cX < pX then sX = pX-cX end if cY > pY then sY = -(cY-pY) end if cY < pY then sY = pY-cY end MapFrame:SetHorizontalScroll(sX) MapFrame:SetVerticalScroll(sY)
If I'm not mistaken this should work as well:
MapFrame:SetHorizontalScroll((unitX*(1002*MapFrameSC:GetScale()))-(MapFrame:GetWidth()/2)) MapFrame:SetVerticalScroll((unitY*(668*MapFrameSC:GetScale()))-(MapFrame:GetHeight()/2))
At any rate, so long as the map scale is 1 (100%) everything seems to line up okay. If I scale the map any then I run into problems. Beyond that if I can get the right scale so the minimap and the full map match up not just in player position, but if the textures weren't considerably larger in one than the other then that would be pretty great as well, so if anyone has any info I'm all ears.
-
Posted by jnwhiteh on Tue, 12 Apr 2011 15:23:53
I don't see you doing anything really wrong, other than using GetScale() instead of GetEffectiveScale(). GetScale() just returns the SetScale() value, which is not how the actual height and width of the frame is computed. That involves the parent frame, scale, etc. all the way up the parent chain. Perhaps take a look at that?
-
Posted by cowmonster on Wed, 13 Apr 2011 05:10:08
Based on the actual size of the map graphics and not of the textures that make them up I was able to calculate that if I make the map 501x334 and set all the textures to 128x128 tiled down from the TOPLEFT at 0, 0 and extending off the frame I can make the math come out right and everything lines up fairly well.
I am thinking that if I were to place the Minimap in the MapFrameSC and do the scrolling the same way I could Keep the Minimap positioned on player position on the map and scroll so the minimap will stay in the center. Then I could scale the Minimap and the other map together keeping the aspect ration I get with the minimap zoomed all the way out and the map at the afore meantioned size and the Minimap at 150x150. This sound reasonable?
-
Posted by cowmonster on Wed, 13 Apr 2011 06:54:24
I had tried GetEffectiveScale() before and tried again and the math still comes out wrong. Additionally, I tried putting the Minimap inside the MapFrameSC...that turned out horrible. The Minimap doesn't scroll with the parent it just gets severely misshapen to adhere to the MapFrame or perhaps it is set to ClampToScreen...either way it was bad.
I now how find that I do not have detailed landscape textures outside of cities/instances and in some zones the math comes out wrong and it doesn't scroll to match the player position properly. In instances and cities it works flawlessly.
If I can get all the detailed textures and get all the POIs and raid/party members positions on it then I'll be content with my map.
-
Posted by jnwhiteh on Thu, 14 Apr 2011 08:07:54
The minimap is the most volatile thing in the WoW UI. Unfortunately I cannot help you with it. I suggest you take a look at SexyMap or other map HUDS and see how they accomplish their magic with the minimap if that's what you're trying to do.
-
Posted by cowmonster on Tue, 19 Apr 2011 12:18:37
The minimap is the most volatile thing in the WoW UI. Unfortunately I cannot help you with it. I suggest you take a look at SexyMap or other map HUDS and see how they accomplish their magic with the minimap if that's what you're trying to do.
I'm not trying to skin the minimap. Obviously you misinterpreted my previous posts or I have failed to fully articulate my point.
-
Posted by jnwhiteh on Tue, 19 Apr 2011 13:40:59
The minimap is the most volatile thing in the WoW UI. Unfortunately I cannot help you with it. I suggest you take a look at SexyMap or other map HUDS and see how they accomplish their magic with the minimap if that's what you're trying to do.
I'm not trying to skin the minimap. Obviously you misinterpreted my previous posts or I have failed to fully articulate my point.
No, I think I have a firm grasp on what you are trying to do, but you seem to not understand why I am suggesting SexyMap and using the word 'HUD'. SexyMap has a mode where the minimap is taken and then displayed on top of another area of the screen, producing a 'heads up display' of the information that is normally restricted to the minimap. Certainly SexyMap is able to skin the minimap, but it has more features than that.
Please feel free to clarify, but if your goal is to take the minimap and then overlay it on top of something else, then please follow my original suggestion.
-
Posted by cowmonster on Tue, 19 Apr 2011 19:48:46
Again, I don't think you grasp the concept of precisely what I am trying to do. If I am understanding you, what you are suggesting is placing the minimap in a static position relative to another frame. What I am doing is more complicated than that. Repositioning the minimap relative to another frame is simple and done with one line of code. What I am trying to do is position the minimap in a static position, yes, but then I want to scroll another frame relative to the center point of the minimap so that a specified point on the second frame lines up with the center point on the minimap. Specifically the point is a reference to player position and the second frame is a zone map. The zone map is a scroll child and the minimap is positioned dead center of the parent of the scroll child. Now after playing with the math some more and looking at what the numbers were and what I needed them to be, I discovered what was missing in my formula.
local unitX, unitY = GetPlayerMapPosition("player") MapFrame:SetHorizontalScroll(((unitX*(MapFrameSC:GetWidth()*MapFrameSC:GetScale()))-(MapFrame:GetWidth()/2))/MapFrameSC:GetScale()) MapFrame:SetVerticalScroll(((unitY*(MapFrameSC:GetHeight()*MapFrameSC:GetScale()))-(MapFrame:GetHeight()/2))/MapFrameSC:GetScale())
The problem was not with the Minimap frame it was with scrolling the other frame relative to the minimap.
-
Posted by jnwhiteh on Tue, 19 Apr 2011 19:50:44
Okay. Sorry I couldn't be of more help, but its difficult to view something opaque from the outside and have insight into it. It was never quite clear to me what you were attempting to accomplish.
-
Posted by cowmonster on Thu, 21 Apr 2011 02:16:39
Hey, you tried and that is more than I can say for a lot of people.