changeset 2:a6fb0ff113b1

- Added inventory items. - Added alpha animation.
author tercio
date Sat, 23 Aug 2014 18:56:28 -0300
parents 018fc9f0c471
children be6f5d3e0a95
files HotCorners.lua HotCorners.xml
diffstat 2 files changed, 414 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/HotCorners.lua	Sat Aug 09 17:28:04 2014 -0300
+++ b/HotCorners.lua	Sat Aug 23 18:56:28 2014 -0300
@@ -1,3 +1,6 @@
+
+-- fazer ele fechar apenas com o HotCornersBackgroundFrame.
+-- assim vai dar + estabilidade sabendo exatamente quando ele esta aberto ou fechado.
 
 LibHotCorners = LibStub ("AceAddon-3.0"):NewAddon ("HotCorners", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
 _G.HotCorners = LibHotCorners
@@ -29,6 +32,9 @@
 	
 end
 
+LibHotCorners.ItemButtons = {}
+LibHotCorners.ItemOnInventory = {}
+
 local refresh_topleft = function()
 	LibHotCorners ["topleft"].is_enabled = LibHotCorners.db.profile.topleft_enabled
 end
@@ -289,7 +295,7 @@
 	function HotCornersBackgroundOnEnter (self)
 		if (LibHotCornersTopLeft and LibHotCornersTopLeft:IsShown()) then
 			if (LibHotCornersTopLeft:GetWidth() > 2) then
-				HotCornersOnLeave (LibHotCornersTopLeft)
+				HotCornersOnLeave (LibHotCornersTopLeft, true)
 			end
 		end
 		self:EnableMouse (false)
@@ -306,7 +312,7 @@
 		
 	--> show tooltip
 		local show_tooltip = function (self)
-			if (self.table.tooltip) then
+			if (self.table and self.table.tooltip) then
 				if (type (self.table.tooltip) == "function") then
 					GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
 					self.table.tooltip (GameTooltip)
@@ -316,8 +322,12 @@
 					GameTooltip:AddLine (self.table.tooltip)
 					GameTooltip:Show()
 				end
-			elseif (self.table.onenter) then
+			elseif (self.table and self.table.onenter) then
 				self.table.onenter (self)
+			elseif (self.isItem) then
+				GameTooltip:SetOwner (self, "ANCHOR_BOTTOMRIGHT")
+				GameTooltip:SetHyperlink (self.itemtable[4])
+				GameTooltip:Show()
 			end
 		end
 		
@@ -326,6 +336,100 @@
 			return t1[1] > t2[1]
 		end
 
+		LibHotCorners.BackPackItemList = {
+
+			--> alchemy
+				[76086] = true, -- Flask of Falling Leaves
+				[76084] = true, -- Flask of Spring Blossoms
+				[76085] = true, -- Flask of the Warm Sun
+				[76087] = true, -- Flask of the Earth
+				[76088] = true, -- Flask of Winter's Bite
+			
+				[76081] = true, -- Elixir of Mirrors
+				[76079] = true, -- Elixir of Peace
+				[76080] = true, -- Elixir of Perfection
+				[76078] = true, --  Elixir of the Rapids
+				[76077] = true, -- Elixir of Weaponry
+				[70676] = true, -- Mad Hozen Elixir
+				[76075] = true, -- Mantid Elixir
+				[76083] = true, -- Monk's Elixir
+			
+				[76094] = true, -- Alchemist's Rejuvenation
+				[96096] = true, -- Darkwater Potion
+				[75218] = true, -- Electrified Oil
+				[76097] = true, -- Master Healing Potion
+				[76098] = true, -- Master Mana Potion
+				[76092] = true, -- Potion of Focus
+				[76093] = true, -- Potion of the Jade Serpent
+				[76095] = true, -- Potion of Mogu Power
+				[76090] = true, -- Potion of the Mountains
+				[76091] = true, -- Greater Potion of Luck
+				[76089] = true, -- Virmen's Bite
+			
+			--> cooking
+						
+				 --Way of the Grill: Strength
+				[74642] = true, -- Charbroiled Tiger Steak
+				[74645] = true, -- Eternal Blossom Fish
+				[74646] = true, -- Black Pepper Ribs and Shrimp
+
+				--Way of the Oven: Stamina
+				[74654] = true, -- Wildfowl Roast
+				[74655] = true, -- Twin Fish Platter
+				[74656] = true, -- Chun Tian Spring Rolls
+
+				--Way of the Pot: Intellect
+
+				[74644] = true, -- Swirling Mist Soup
+				[74649] = true, -- Braised Turtle
+				[74650] = true, -- Mogu Fish Stew
+
+				--Way of the Steamer: Spirit
+
+				[74651] = true, -- Shrimp Dumplings
+				[74652] = true, -- Fire Spirit Salmon
+				[74653] = true, -- Steamed Crab Surprise
+
+				--Way of the Wok: Agility
+
+				[74643] = true, -- Sauteed Carrots
+				[74647] = true, -- Valley Stir Fry
+				[74648] = true, -- Sea Mist Rice Noodles
+
+				--Way of the Brew: Headaches and Grandeur
+
+				[74626] = true, -- Ginseng Tea
+				[74637] = true, -- Jade Witch Brew
+				[74638] = true, -- Mad Brewer's Breakfast
+
+				--General Cooking
+			
+				[74641] = true, -- Fish Cake
+				[74636] = true, -- Golden Carp Consomme
+				[86070] = true, -- Wildfowl Ginseng Soup
+				[86069] = true, -- Rice Pudding
+				[86074] = true, -- Spicy Vegetable Chips
+				[86073] = true, -- Spicy Salmon
+			
+				--5.4 Recipes
+			
+				[145308] = true, -- Mango Ice
+				[145309] = true, -- Farmer's Delight
+				[145311] = true, -- Fluffy Silkfeather Omelet
+				[145310] = true, -- Stuffed Lushrooms
+				[145307] = true, -- Spiced Blossom Soup
+				[145305] = true, -- Seasoned Pomfruit Slices
+			
+				--Cart Kits
+				[101630] = true, -- Noodle Cart Kit
+				[101661] = true, -- Deluxe Noodle Cart Kit
+				[101662] = true, -- Pandaren Treasure Noodle Cart Kit
+				
+				[101618] = true, -- Pandaren Treasure Noodle Soup
+				[101617] = true, -- Deluxe Noodle Soup
+				[101616] = true, -- Noodle Soup
+		}
+		
 		function HotCornersOnEnter (self)
 			
 			if (not LibHotCorners.db.profile.is_enabled) then
@@ -336,9 +440,14 @@
 				return
 			end
 	
+			if (self:GetWidth() < 1.1 and self:GetHeight() < 1.1) then
+				--print ("abrindo...")
+			end
+	
 			set_size (self)
 			
 			HotCornersBackgroundFrame:EnableMouse (true)
+			self.item_frame:Show()
 			
 			local i = 1
 			
@@ -363,10 +472,13 @@
 				
 				if (not disabled [button_table.name] and not button_table.optionstable.hide) then
 					if (self.position == "topleft" or self.position == "topright") then
+						
 						local y = i * 35 * -1
-						button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
+						--button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
 						button_table.widget.y = y
-					else
+						HotCornersStartAnimOnShow (button_table.widget, "y")
+						
+					else --bottom left /  bottom right
 						local x = i * 35
 						button_table.widget:SetPoint ("topleft", self, "topleft", x, -4)
 						button_table.widget.x = x
@@ -386,18 +498,105 @@
 			OptionsButton:SetPoint ("top", self, "top", 0, y)
 			OptionsButton:Show()
 			
+			--item frame
+			LibHotCorners:RefereshItems (self)
+			
 		end
 
+	function LibHotCorners:RefereshItems (self)
+		
+		if (not self) then
+			return LibHotCorners:ScheduleTimer ("RefereshItems", 1, LibHotCornersTopLeft)
+		end
+		
+		if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
+			for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
+				itemTable [1] = 0
+			end
+		
+			for bagID = 0, 4 do
+				local numItems = GetContainerNumSlots (bagID)
+				for slot = 1, numItems do
+					local itemId = GetContainerItemID (bagID, slot)
+					if (LibHotCorners.BackPackItemList [itemId]) then
+						local texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo (bagID, slot)
+						if (not LibHotCorners.ItemOnInventory [itemId]) then
+							LibHotCorners.ItemOnInventory [itemId] = {itemCount, texture, quality, itemLink, itemId}
+						else
+							LibHotCorners.ItemOnInventory [itemId] [1] = LibHotCorners.ItemOnInventory [itemId] [1] + itemCount
+						end
+					end
+				end
+			end
+			
+			local index = 1
+			for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
+				local itemCount, texture, quality, itemLink = unpack (itemTable)
+				
+				local item_button = LibHotCorners:GetItemButton (index, self)
+				if (item_button) then
+					item_button:SetNormalTexture (texture)
+					item_button:SetHighlightTexture (texture)
+					item_button:SetPushedTexture (texture)
+
+					item_button.item_count:SetText (itemCount or 0)
+					item_button:SetAttribute ("macrotext", "/use " .. GetItemInfo (itemId) .. ";\n/script HotCorners:RefereshItems()")
+					
+					item_button.itemtable = itemTable
+					
+					if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
+						HotCornersStartAnimOnShow (item_button, "item_topleft")
+					end
+				end
+				index = index + 1	
+			end
+
+		end
+		
+		--/run local itemid=GetContainerItemID (0, 1);print (itemid)
+		--UseContainerItem(bagID, slot[, onSelf])
+	end		
+		
+	function LibHotCorners:GetItemButton (index, parent)
+		local button = LibHotCorners.ItemButtons [index]
+		if (not button) then
+			button = CreateFrame ("button", "HotCornersItemButton" .. index, parent.item_frame, "HotCornersUseItemButtonTemplate")
+			button.isItem = true
+			
+			if (parent.position == "topleft") then
+				local x = (index-1) * 33
+				button:SetPoint ("topleft", parent.item_frame, "topleft", x, -2)
+				button.x = x
+			elseif (parent.position == "topright") then
+				local x = (index-1) * 33
+				button:SetPoint ("topright", parent.item_frame, "topright", -x, -2)
+			end
+			
+			LibHotCorners.ItemButtons [index] = button
+		end
+		return button
+	end
+		
 	--> corner frame on leave
-		function HotCornersOnLeave (self)
+		function HotCornersOnLeave (self, from_background)
+			if (not from_background) then
+				return
+			end
+			
 			self:SetSize (1, 1)
 			for index, button_table in ipairs (LibHotCorners [self.position]) do 
 				if (button_table.widget) then
 					button_table.widget:Hide()
 				end
 			end
+			for _, button in pairs (LibHotCorners.ItemButtons) do 
+				button:Hide()
+			end
+			
 			local OptionsButton = LibHotCorners [self.position].optionsbutton
 			OptionsButton:Hide()
+			
+			self.item_frame:Hide()
 		end
 		
 	--> quick corner on click
@@ -436,51 +635,87 @@
 	
 	--> button onenter
 		function HotCornersButtonOnEnter (self)
-			set_size (self:GetParent())
-			for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do 
-				if (not LibHotCorners.db.profile.disabled [button_table.name]) then
-					button_table.widget:Show()
-				end
-			end
+			--set_size (self:GetParent())
+			--for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do 
+			--	if (not LibHotCorners.db.profile.disabled [button_table.name] and button_table.widget) then
+			--		button_table.widget:Show()
+			--	end
+			--end
 			show_tooltip (self)
-			local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
-			OptionsButton:Show()
+			--local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
+			--OptionsButton:Show()
 		end
 	
 	--> button onleave
 		function HotCornersButtonOnLeave (self)
 			GameTooltip:Hide()
-			if (self.table.onleave) then
+			if (self.table and self.table.onleave) then
 				self.table.onleave (self)
 			end
-			self:GetParent():GetScript("OnLeave")(self:GetParent())
-			local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
-			OptionsButton:Hide()
+			--self:GetParent():GetScript("OnLeave")(self:GetParent())
+			--local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
+			--OptionsButton:Hide()
 		end
 
 	--> button onmousedown
 		function HotCornersButtonOnMouseDown (self, button)
-			if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
-				self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
+			if (self.isItem) then
+				if (self:GetParent():GetParent().position == "topleft") then
+					self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -3)
+				end
 			else
-				self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
+				if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
+					self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
+				else
+					self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
+				end
 			end
 		end
 		
 	--> button onmouseup
 		function HotCornersButtonOnMouseUp (self, button)
-			if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
-				self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
+			if (self.isItem) then
+				if (self:GetParent():GetParent().position == "topleft") then
+					self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -2)
+				end
 			else
-				self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
+				if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
+					self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
+				else
+					self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
+				end
+				if (self.table.click) then
+					local clicks = LibHotCorners.db.profile.clicks
+					clicks [self.table.name] = clicks [self.table.name] or 0
+					clicks [self.table.name] = clicks [self.table.name] + 1
+					self.table.click (self, button)
+				end
 			end
-			if (self.table.click) then
-				local clicks = LibHotCorners.db.profile.clicks
-				clicks [self.table.name] = clicks [self.table.name] or 0
-				clicks [self.table.name] = clicks [self.table.name] + 1
-				self.table.click (self, button)
+		end
+	
+	--> start show animation
+		function HotCornersStartAnimOnShow (button, axis)
+			if (axis == "y") then
+				--button:SetPoint ("topleft", button:GetParent(), "topleft", -32, button.y)
+				button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
+				button.AnimOnShow:Play()
+				
+			elseif (axis == "item_topleft") then
+				button:Show()
+				button.AnimOnShow:Play()
+				
 			end
 		end
+		
+	--> on start / finish show animation
+		function HotCornersAnimOnShowStarted (button)
+			
+		end
+		function HotCornersAnimOnShowFinished (button)
+			--button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
+			button:Show()
+			--button:SetPoint ("topleft", button:GetParent(), "topleft", -4, button.y)
+		end
 
 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 --> create top left corner
--- a/HotCorners.xml	Sat Aug 09 17:28:04 2014 -0300
+++ b/HotCorners.xml	Sat Aug 23 18:56:28 2014 -0300
@@ -30,12 +30,31 @@
 
 		<Scripts>
 			<OnEnter>
-				HotCornersOnEnter (self);
+				<!-- HotCornersOnEnter (self); -->
 			</OnEnter>
 			<OnLeave>
 				HotCornersOnLeave (self);
 			</OnLeave>
 		</Scripts>
+		
+		<Frames>
+			<Frame name="$parentItemListFrame" frameStrata="FULLSCREEN" parentKey="item_frame" hidden="true" EnableMouse="true">
+				<Size x="100" y="40"/>
+				<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" tile="true">
+					<TileSize>
+						<AbsValue val="40"/>
+					</TileSize>
+					<BackgroundInsets>
+						<AbsInset left="0" right="0" top="0" bottom="0"/>
+					</BackgroundInsets>
+				</Backdrop>
+				<Anchors>
+					<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPRIGHT" x="0" y="0"/>
+					<Anchor point="TOPRIGHT" relativeTo="UIParent" relativePoint="TOPRIGHT" x="0" y="0"/>
+					<!--<Anchor point="CENTER" relativeTo="UIParent" relativePoint="CENTER" x="0" y="40"/>-->
+				</Anchors>
+			</Frame>
+		</Frames>
 	</Frame>
 	
 	<Frame name="HotCornersQuickCornerButtonTemplate" frameStrata="FULLSCREEN" virtual="true">
@@ -57,8 +76,96 @@
 		</Scripts>
 	</Frame>
 	
+	<Button name="HotCornersUseItemButtonTemplate" frameStrata="FULLSCREEN" hidden="true" virtual="true" inherits="SecureActionButtonTemplate">
+		<Size x="32" y="32"/>
+		
+		<Attributes>
+			<Attribute name="type" type="string" value="macro"/>
+		</Attributes>
+		
+		<Layers>
+			<Layer level="OVERLAY" textureSubLevel="1">
+				<Texture name="$parentBGItemCount" parentKey="bg_item_count">
+					<Size>
+						<AbsDimension x="20" y="12"/>
+					</Size>
+					<Color r="0" g="0" b="0" a=".5"/>
+					<Anchors>
+						<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" x="0" y="0"/>
+					</Anchors>
+				</Texture>
+			</Layer>
+			<Layer level="OVERLAY" textureSubLevel="2">
+				<FontString text="0" name="$parentItemCount" inherits="GameFontNormal" parentKey="item_count">
+					<Anchors>
+						<Anchor point="CENTER" relativeTo="$parentBGItemCount" relativePoint="CENTER" x="0" y="0"/>
+					</Anchors>
+					<Color r="1" g="1" b="1" a="1"/>
+				</FontString>
+			</Layer>
+		</Layers>
+		
+		<Animations>
+			<AnimationGroup name="$parentOnShow" parentKey="AnimOnShow" looping="NONE">
+				<!-- hide -->
+				<Alpha change="-1" duration="0" order="1"/>
+				<!-- show with alpha 
+				<Translation offsetX="32" offsetY="0" duration="0.3" order="2"/>
+				-->
+				<Alpha change="1" duration="0.3" order="2"/>
+				<Scripts>
+					<OnPlay>
+						HotCornersAnimOnShowStarted (self:GetParent())
+					</OnPlay>
+					<OnFinished>
+						HotCornersAnimOnShowFinished (self:GetParent())
+					</OnFinished>
+				</Scripts>
+			</AnimationGroup>
+		</Animations>
+		
+		<Scripts>
+			<OnLoad>
+				self:SetFrameLevel (self:GetParent():GetFrameLevel()+2);
+			</OnLoad>
+			<OnEnter>
+				HotCornersButtonOnEnter (self);
+			</OnEnter>
+			<OnLeave>
+				HotCornersButtonOnLeave (self);
+			</OnLeave>
+			<OnMouseDown>
+				HotCornersButtonOnMouseDown (self, button);
+			</OnMouseDown>
+			<OnMouseUp>
+				HotCornersButtonOnMouseUp (self, button);
+			</OnMouseUp>
+		</Scripts>
+		
+	</Button>
+	
 	<Frame name="HotCornersButtonTemplate" frameStrata="FULLSCREEN" hidden="true" virtual="true">
 		<Size x="32" y="32"/>
+		
+		<Animations>
+			<AnimationGroup name="$parentOnShow" parentKey="AnimOnShow" looping="NONE">
+				<!-- hide -->
+				<Alpha change="-1" duration="0" order="1"/>
+				<!-- show with alpha 
+				<Translation offsetX="32" offsetY="0" duration="0.3" order="2"/>
+				-->
+				<Alpha change="1" duration="0.3" order="2"/>
+				<Scripts>
+					<OnPlay>
+						HotCornersAnimOnShowStarted (self:GetParent())
+					</OnPlay>
+					<OnFinished>
+						HotCornersAnimOnShowFinished (self:GetParent())
+					</OnFinished>
+				</Scripts>
+			</AnimationGroup>
+		</Animations>
+		
 		<Scripts>
 			<OnLoad>
 				self:SetFrameLevel (self:GetParent():GetFrameLevel()+2);
@@ -114,6 +221,48 @@
 		</Scripts>
 	</Button>
 
+	<Frame name="ATest" frameStrata="FULLSCREEN" parent="UIParent">
+		
+		<Size x="32" y="32"/>
+		
+		<Anchors>
+			<Anchor point="CENTER" relativeTo="$parent" relativePoint="CENTER" x="0" y="0"/>
+		</Anchors>
+		
+		<Layers>
+			<Layer level="OVERLAY">
+				<Texture name="$parentTexture" parentKey="texture">
+					<Size>
+						<AbsDimension x="32" y="32"/>
+					</Size>
+					<Color r="1" g="1" b="1" a="1"/>
+					<Anchors>
+						<Anchor point="CENTER" relativeTo="$parent" relativePoint="CENTER" x="0" y="0"/>
+					</Anchors>
+				</Texture>
+			</Layer>
+		</Layers>
+		
+		<Animations>
+			<AnimationGroup name="$parentGo" parentKey="go">
+			
+				<Alpha change="-1" duration="0" order="1" startDelay="3"/>
+				
+				<Translation offsetX="32" offsetY="0" duration="5" order="2"/>
+				<Alpha startDelay="0" change="1" duration="5" order="2"/>
+				
+			</AnimationGroup>
+		</Animations>
+		
+		<Scripts>
+			<OnLoad>
+				self.go:Play()
+				self:Hide()
+			</OnLoad>
+		</Scripts>
+		
+	</Frame>
+
 	<Script file="HotCorners.lua"/>
 	
 </Ui>
\ No newline at end of file