Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Adds archaeology dig site blobs to Carbonite.
- local me = CreateFrame( "ArchaeologyDigSiteFrame" );
- do
- -- Note: Must be parented to Frame so handlers run in the right order.
- local Updater, Width = CreateFrame( "Frame", nil, me ), 1;
- Updater:SetPoint( "TOPLEFT" );
- Updater:SetSize( Width, 1 );
- local ArchaeologyMapUpdateAll = ArchaeologyMapUpdateAll;
- local ArcheologyGetVisibleBlobID = ArcheologyGetVisibleBlobID;
- --- Renders blobs after the layout engine is ready.
- -- Attempting to DrawBlob right after changing a blob's size will render using the previous size.
- -- This handler fires after OnUpdates but before the screen is painted.
- local function OnSizeChanged ( self )
- self:SetScript( "OnSizeChanged", nil );
- if ( me:IsVisible() ) then
- me:DrawNone();
- for Index = 1, ArchaeologyMapUpdateAll() do
- me:DrawBlob( ArcheologyGetVisibleBlobID( Index ), true );
- end
- end
- end
- --- Repaints all blobs in their new locations.
- function me:DrawBlobs ()
- Updater:SetScript( "OnSizeChanged", OnSizeChanged );
- Width = Width % 2 + 1; -- 2,1,2,1
- return Updater:SetWidth( Width ); -- Force the handler to run
- end
- end
- --- Moves the frame with Carbonite's map.
- function me:OnUpdate ()
- return self.Carbonite:CZF( self.Carbonite.Con, self.Carbonite.Zon, self, 1 );
- end
- --- Re-draws blobs if the canvas moves.
- function me:OnPositionChanged ()
- return self:GetParent():DrawBlobs();
- end
- --- Shows blobs when combat ends.
- function me:PLAYER_REGEN_ENABLED ()
- self:SetParent( self.Carbonite.TSF:GetScrollChild() );
- self:Show();
- end
- --- Hides blobs in combat since they're protected.
- function me:PLAYER_REGEN_DISABLED ()
- self:Hide();
- self:SetParent( nil );
- self:ClearAllPoints();
- end
- me.WORLD_MAP_UPDATE = me.DrawBlobs;
- me.ARTIFACT_DIG_SITE_UPDATED = me.DrawBlobs;
- me:Hide();
- me:SetSize( WorldMapButton:GetSize() );
- me:SetFillAlpha( 255 * 0.25 );
- me:SetFillTexture( [[Interface\WorldMap\UI-ArchaeologyBlob-Inside]] );
- me:SetBorderTexture( [[Interface\WorldMap\UI-ArchaeologyBlob-Outside]] );
- me:SetBorderScalar( 0.15 );
- me:SetBorderAlpha( 255 * 0.75 );
- me:SetScript( "OnShow", me.DrawBlobs );
- me:SetScript( "OnSizeChanged", me.DrawBlobs );
- me:SetScript( "OnUpdate", me.OnUpdate );
- me:SetScript( "OnEvent", _DevPad.Frame.OnEvent );
- me:RegisterEvent( "WORLD_MAP_UPDATE" );
- me:RegisterEvent( "ARTIFACT_DIG_SITE_UPDATED" );
- -- Makeshift "OnPositionChanged" handler
- local BottomLeft = CreateFrame( "Frame", nil, me );
- BottomLeft:SetPoint( "BOTTOMLEFT", nil );
- BottomLeft:SetPoint( "TOPRIGHT", me, "BOTTOMLEFT" );
- BottomLeft:SetScript( "OnSizeChanged", me.OnPositionChanged );
- local AddOnInit = _DevPad( "Libs", "AddOnInit" )();
- AddOnInit:Register( "Carbonite", function ()
- me.Carbonite = NxMap1.NxM1;
- me:RegisterEvent( "PLAYER_REGEN_ENABLED" );
- me:RegisterEvent( "PLAYER_REGEN_DISABLED" );
- if ( not InCombatLockdown() ) then
- return me:PLAYER_REGEN_ENABLED();
- end
- end );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement