daily pastebin goal
61%
SHARE
TWEET

Carbonite Dig Sites

Saiket May 28th, 2011 271 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- Adds archaeology dig site blobs to Carbonite.
  2. local me = CreateFrame( "ArchaeologyDigSiteFrame" );
  3.  
  4.  
  5.  
  6.  
  7. do
  8.   -- Note: Must be parented to Frame so handlers run in the right order.
  9.   local Updater, Width = CreateFrame( "Frame", nil, me ), 1;
  10.   Updater:SetPoint( "TOPLEFT" );
  11.   Updater:SetSize( Width, 1 );
  12.   local ArchaeologyMapUpdateAll = ArchaeologyMapUpdateAll;
  13.   local ArcheologyGetVisibleBlobID = ArcheologyGetVisibleBlobID;
  14.   --- Renders blobs after the layout engine is ready.
  15.   -- Attempting to DrawBlob right after changing a blob's size will render using the previous size.
  16.   -- This handler fires after OnUpdates but before the screen is painted.
  17.   local function OnSizeChanged ( self )
  18.     self:SetScript( "OnSizeChanged", nil );
  19.     if ( me:IsVisible() ) then
  20.       me:DrawNone();
  21.       for Index = 1, ArchaeologyMapUpdateAll() do
  22.         me:DrawBlob( ArcheologyGetVisibleBlobID( Index ), true );
  23.       end
  24.     end
  25.   end
  26.   --- Repaints all blobs in their new locations.
  27.   function me:DrawBlobs ()
  28.     Updater:SetScript( "OnSizeChanged", OnSizeChanged );
  29.     Width = Width % 2 + 1; -- 2,1,2,1
  30.     return Updater:SetWidth( Width ); -- Force the handler to run
  31.   end
  32. end
  33.  
  34.  
  35. --- Moves the frame with Carbonite's map.
  36. function me:OnUpdate ()
  37.   return self.Carbonite:CZF( self.Carbonite.Con, self.Carbonite.Zon, self, 1 );
  38. end
  39. --- Re-draws blobs if the canvas moves.
  40. function me:OnPositionChanged ()
  41.   return self:GetParent():DrawBlobs();
  42. end
  43. --- Shows blobs when combat ends.
  44. function me:PLAYER_REGEN_ENABLED ()
  45.   self:SetParent( self.Carbonite.TSF:GetScrollChild() );
  46.   self:Show();
  47. end
  48. --- Hides blobs in combat since they're protected.
  49. function me:PLAYER_REGEN_DISABLED ()
  50.   self:Hide();
  51.   self:SetParent( nil );
  52.   self:ClearAllPoints();
  53. end
  54. me.WORLD_MAP_UPDATE = me.DrawBlobs;
  55. me.ARTIFACT_DIG_SITE_UPDATED = me.DrawBlobs;
  56.  
  57.  
  58.  
  59.  
  60. me:Hide();
  61. me:SetSize( WorldMapButton:GetSize() );
  62. me:SetFillAlpha( 255 * 0.25 );
  63. me:SetFillTexture( [[Interface\WorldMap\UI-ArchaeologyBlob-Inside]] );
  64. me:SetBorderTexture( [[Interface\WorldMap\UI-ArchaeologyBlob-Outside]] );
  65. me:SetBorderScalar( 0.15 );
  66. me:SetBorderAlpha( 255 * 0.75 );
  67. me:SetScript( "OnShow", me.DrawBlobs );
  68. me:SetScript( "OnSizeChanged", me.DrawBlobs );
  69. me:SetScript( "OnUpdate", me.OnUpdate );
  70. me:SetScript( "OnEvent", _DevPad.Frame.OnEvent );
  71. me:RegisterEvent( "WORLD_MAP_UPDATE" );
  72. me:RegisterEvent( "ARTIFACT_DIG_SITE_UPDATED" );
  73.  
  74. -- Makeshift "OnPositionChanged" handler
  75. local BottomLeft = CreateFrame( "Frame", nil, me );
  76. BottomLeft:SetPoint( "BOTTOMLEFT", nil );
  77. BottomLeft:SetPoint( "TOPRIGHT", me, "BOTTOMLEFT" );
  78. BottomLeft:SetScript( "OnSizeChanged", me.OnPositionChanged );
  79.  
  80.  
  81. local AddOnInit = _DevPad( "Libs", "AddOnInit" )();
  82. AddOnInit:Register( "Carbonite", function ()
  83.     me.Carbonite = NxMap1.NxM1;
  84.    
  85.     me:RegisterEvent( "PLAYER_REGEN_ENABLED" );
  86.     me:RegisterEvent( "PLAYER_REGEN_DISABLED" );
  87.     if ( not InCombatLockdown() ) then
  88.       return me:PLAYER_REGEN_ENABLED();
  89.     end
  90. end );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top