View Single Post
04-12-20, 05:31 AM   #3
Shokarta
A Deviate Faerie Dragon
Join Date: Jan 2008
Posts: 11
I'm not exactly sure what you're asking. Can you elaborate more on what you're trying to do?
- basicaly every time I open the map is to populate it with icons based on some logis statement, and when closing the map remove all of them, because everytime I open the map, the amount and positions (and overall settings) of those icons will be different, thats why its better OnHide() of worldmap to always delete them all, and create new ones on OnShow()

You're creating a button and storing it in MapQuestIconFrame, but are giving it the name TextureBasics, which also stores it in that global. Why not skip assigning the global and just name it MapQuestIconFrame?
- yes, sorry this was my mistake, Button was an error, it should be just Frame

When you call WorldMapFrame:SetScript(), you're breaking WorldMapFrame by replacing any existing function there. Use WorldMapFrame:HookScript() instead.
- I was not aware im breaking it the original script, so I used HookScript() instead

Every time MapQuestIconShow() is called, you're running MapQuestIconFrame:CreateTexture(), which keeps creating a new UI object every time you open WorldMapFrame.
- yes, I am not this far, but my ultimate goal is something like this (dont know how to syntax it yet):

Code:
MapQuestIconFrame = CreateFrame("Frame", "MapQuestIconFrame")
MapQuestIconFrame:SetFrameStrata("Tooltip")
MapQuestIconFrame:SetFrameLevel(0)
MapQuestIconFrame:SetWidth(WorldMapDetailFrame:GetWidth() * WorldMapDetailFrame:GetEffectiveScale())
MapQuestIconFrame:SetHeight(WorldMapDetailFrame:GetHeight() * WorldMapDetailFrame:GetEffectiveScale())
MapQuestIconFrame:SetAlpha(1)
MapQuestIconFrame:SetPoint("TOPLEFT", WorldMapDetailFrame, "TOPLEFT")
MapQuestIconFrame:Hide() -- because without this line, it automaticaly shows the frame on loadup, but I want to show it only when wordlmap opens

-- Map Opened
WorldMapFrame:HookScript("OnShow",
	function(self)
		MapQuestIconFrame.Show()
		
		for icon = 1, amount_to_be_decided do
			if (logic_to_be_decided) then
				local ("QuestIcon"..icon) = MapQuestIconFrame:CreateTexture("Texture", "Background")
				("QuestIcon"..icon):SetTexture("Interface\\AddOns\\MapTest\\AvailableQuestIcon.blp")
				("QuestIcon"..icon):SetDrawLayer("Background", 0)
				("QuestIcon"..icon):SetWidth(16 * WorldMapDetailFrame:GetEffectiveScale())
				("QuestIcon"..icon):SetHeight(16 * WorldMapDetailFrame:GetEffectiveScale())
				("QuestIcon"..icon):SetPoint("CENTER", MapQuestIconFrame, "TOPLEFT", (Xcoord/100)*WorldMapDetailFrame:GetWidth(), (-Ycoord/100)*WorldMapDetailFrame:GetHeight())
			end
		end
	end
)

-- Map Closed
WorldMapFrame:HookScript("OnHide",
	function(self)
		for each frames as QuestIcon in MapQuestIconFrame do
			DeleteFrame(QuestIcon)
		end
		MapQuestIconFrame:Hide()
	end
)

-- Map Resized
WorldMapFrame:HookScript("OnSizeChanged",
	function(self)
		-- scale all MapQUestIconFrame and all QuestIconN in it, how?
	end
)
  Reply With Quote