<commit_before>local Button = CreateFrame("Button", "ExtraQuestButton", UIParent, "SecureActionButtonTemplate, SecureHandlerStateTemplate, SecureHandlerAttributeTemplate")
RegisterStateDriver(Button, "visible", "[extrabar] hide; show")
Button:SetAttribute("_onattributechanged", [[
	if(name == "item") then
		if(value and not self:IsShown() and not HasExtraActionBar()) then
			self:Show()
		elseif(not value) then
			self:Hide()
			self:ClearBindings()
		end
	elseif(name == "state-visible") then
		if(value == "show") then
			self:CallMethod("Update")
		else
			self:Hide()
			self:ClearBindings()
		end
	end

	if(self:IsShown() and (name == "item" or name == "binding")) then
		self:ClearBindings()

		local key = GetBindingKey("EXTRAACTIONBUTTON1")
		if(key) then
			self:SetBindingClick(1, key, self, "LeftButton")
		end
	end
]])

Button:RegisterEvent("PLAYER_LOGIN")
Button:SetScript("OnEvent", function(self, event)
	if(event == "BAG_UPDATE_COOLDOWN") then
		if(self:IsShown()) then
			local start, duration, enable = GetItemCooldown(self.itemID)
			if(duration > 0) then
				self.Cooldown:SetCooldown(start, duration)
				self.Cooldown:Show()
			else
				self.Cooldown:Hide()
			end
		end
	elseif(event == "PLAYER_REGEN_ENABLED") then
		self:SetAttribute("item", self.attribute)
		self:UnregisterEvent(event)
	elseif(event == "UPDATE_BINDINGS") then
		if(self:IsShown()) then
			self:SetItem()
			self:SetAttribute("binding", GetTime())
		end
	elseif(event == "PLAYER_LOGIN") then
		self:SetPoint("CENTER", ExtraActionButton1)
		self:SetSize(ExtraActionButton1:GetSize())
		self:SetScale(ExtraActionButton1:GetScale())
		self:SetScript("OnLeave", GameTooltip_Hide)
		self:SetAttribute("type", "item")
		self.updateTimer = 0
		self.rangeTimer = 0
		self:Hide()

		local Icon = self:CreateTexture("$parentIcon", "ARTWORK")
		Icon:SetAllPoints()
		self.Icon = Icon

		local HotKey = self:CreateFontString("$parentHotKey", nil, "NumberFontNormal")
		HotKey:SetPoint("BOTTOMRIGHT", -5, 5)
		self.HotKey = HotKey

		local Cooldown = CreateFrame("Cooldown", "$parentCooldown", self, "CooldownFrameTemplate")
		Cooldown:ClearAllPoints()
		Cooldown:SetPoint("TOPRIGHT", -2, -3)
		Cooldown:SetPoint("BOTTOMLEFT", 2, 1)
		Cooldown:Hide()
		self.Cooldown = Cooldown

		local Artwork = self:CreateTexture("$parentArtwork", "BACKGROUND")
		Artwork:SetPoint("CENTER", -2, 0)
		Artwork:SetSize(256, 128)
		Artwork:SetTexture([[Interface\ExtraButton\ChampionLight]])
		-- Artwork:SetTexture([[Interface\ExtraButton\Smash]])
		self.Artwork = Artwork

		self.Icon:SetTexCoord(.08, .92, .08, .92)
		self:CreateShadow("Background")
		self:StyleButton(true)

		self:RegisterEvent("UPDATE_BINDINGS")
		self:RegisterEvent("UPDATE_EXTRA_ACTIONBAR")
		self:RegisterEvent("BAG_UPDATE_COOLDOWN")
		self:RegisterEvent("BAG_UPDATE_DELAYED")
		self:RegisterEvent("WORLD_MAP_UPDATE")
		self:RegisterEvent("QUEST_LOG_UPDATE")
		self:RegisterEvent("QUEST_POI_UPDATE")
	else
		self:Update()
	end
end)

Button:SetScript("OnEnter", function(self)
	GameTooltip:SetOwner(self, "ANCHOR_LEFT")
	GameTooltip:SetHyperlink(self.itemLink)
end)

-- BUG: IsItemInRange() is broken versus friendly npcs (and possibly others)
Button:SetScript("OnUpdate", function(self, elapsed)
	if(self.rangeTimer > TOOLTIP_UPDATE_TIME) then
		local HotKey = self.HotKey
		local Icon = self.Icon
		local inRange = IsItemInRange(self.itemLink, "target")
		if(HotKey:GetText() == RANGE_INDICATOR) then
			if(inRange == false) then
				HotKey:SetTextColor(1, 0.1, 0.1)
				HotKey:Show()
				Icon:SetVertexColor(1, 0.3, 0.1)
			elseif(inRange) then
				HotKey:SetTextColor(1, 1, 1)
				HotKey:Show()
				Icon:SetVertexColor(1, 1, 1)
			else
				HotKey:Hide()
			end
		else
			if(inRange == false) then
				HotKey:SetTextColor(1, 0.1, 0.1)
				Icon:SetVertexColor(1, 0.3, 0.1)
			else
				HotKey:SetTextColor(1, 1, 1)
				Icon:SetVertexColor(1, 1, 1)
			end
		end

		self.rangeTimer = 0
	else
		self.rangeTimer = self.rangeTimer + elapsed
	end

	if(self.updateTimer > 5) then
		self:Update()
		self.updateTimer = 0
	else
		self.updateTimer = self.updateTimer + elapsed
	end
end)

local zoneWide = {
	[14108] = 541,
}

function Button:SetItem(itemLink, texture)
	if(itemLink) then
		if(itemLink == self.itemLink and self:IsShown()) then
			return
		end

		self.Icon:SetTexture(texture)
		self.itemID, self.itemName = string.match(itemLink, "|Hitem:(.-):.-|h%[(.+)%]|h")
		self.itemLink = itemLink
	end

	local HotKey = self.HotKey
	local key = GetBindingKey("EXTRAACTIONBUTTON1")
	if(key) then<commit_msg>ExtraQuestButton样式<commit_after>local Button = CreateFrame("Button", "ExtraQuestButton", UIParent, "SecureActionButtonTemplate, SecureHandlerStateTemplate, SecureHandlerAttributeTemplate")
RegisterStateDriver(Button, "visible", "[extrabar] hide; show")
local DefaultExtraActionStyle = "Interface\\ExtraButton\\ChampionLight"
Button:SetAttribute("_onattributechanged", [[
	if(name == "item") then
		if(value and not self:IsShown() and not HasExtraActionBar()) then
			self:Show()
		elseif(not value) then
			self:Hide()
			self:ClearBindings()
		end
	elseif(name == "state-visible") then
		if(value == "show") then
			self:CallMethod("Update")
		else
			self:Hide()
			self:ClearBindings()
		end
	end

	if(self:IsShown() and (name == "item" or name == "binding")) then
		self:ClearBindings()

		local key = GetBindingKey("EXTRAACTIONBUTTON1")
		if(key) then
			self:SetBindingClick(1, key, self, "LeftButton")
		end
	end
]])

Button:RegisterEvent("PLAYER_LOGIN")
Button:SetScript("OnEvent", function(self, event)
	if(event == "BAG_UPDATE_COOLDOWN") then
		if(self:IsShown()) then
			local start, duration, enable = GetItemCooldown(self.itemID)
			if(duration > 0) then
				self.Cooldown:SetCooldown(start, duration)
				self.Cooldown:Show()
			else
				self.Cooldown:Hide()
			end
		end
	elseif(event == "PLAYER_REGEN_ENABLED") then
		self:SetAttribute("item", self.attribute)
		self:UnregisterEvent(event)
	elseif(event == "UPDATE_BINDINGS") then
		if(self:IsShown()) then
			self:SetItem()
			self:SetAttribute("binding", GetTime())
		end
	elseif(event == "PLAYER_LOGIN") then
		self:SetPoint("CENTER", ExtraActionButton1)
		self:SetSize(ExtraActionButton1:GetSize())
		self:SetScale(ExtraActionButton1:GetScale())
		self:SetScript("OnLeave", GameTooltip_Hide)
		self:SetAttribute("type", "item")
		self.updateTimer = 0
		self.rangeTimer = 0
		self:Hide()

		local Icon = self:CreateTexture("$parentIcon", "ARTWORK")
		Icon:SetAllPoints()
		self.Icon = Icon

		local HotKey = self:CreateFontString("$parentHotKey", nil, "NumberFontNormal")
		HotKey:SetPoint("BOTTOMRIGHT", -5, 5)
		self.HotKey = HotKey

		local Cooldown = CreateFrame("Cooldown", "$parentCooldown", self, "CooldownFrameTemplate")
		Cooldown:ClearAllPoints()
		Cooldown:SetPoint("TOPRIGHT", -2, -3)
		Cooldown:SetPoint("BOTTOMLEFT", 2, 1)
		Cooldown:Hide()
		self.Cooldown = Cooldown

		local Artwork = self:CreateTexture("$parentArtwork", "BACKGROUND")
		Artwork:SetPoint("CENTER", -2, 0)
		Artwork:SetSize(256, 128)
		Artwork:SetTexture(GetOverrideBarSkin() or DefaultExtraActionStyle)
		-- Artwork:SetTexture([[Interface\ExtraButton\Smash]])
		self.Artwork = Artwork

		self.Icon:SetTexCoord(.08, .92, .08, .92)
		self:CreateShadow("Background")
		self:StyleButton(true)

		self:RegisterEvent("UPDATE_BINDINGS")
		self:RegisterEvent("UPDATE_EXTRA_ACTIONBAR")
		self:RegisterEvent("BAG_UPDATE_COOLDOWN")
		self:RegisterEvent("BAG_UPDATE_DELAYED")
		self:RegisterEvent("WORLD_MAP_UPDATE")
		self:RegisterEvent("QUEST_LOG_UPDATE")
		self:RegisterEvent("QUEST_POI_UPDATE")
	else
		self:Update()
	end
end)

Button:SetScript("OnEnter", function(self)
	GameTooltip:SetOwner(self, "ANCHOR_LEFT")
	GameTooltip:SetHyperlink(self.itemLink)
end)

-- BUG: IsItemInRange() is broken versus friendly npcs (and possibly others)
Button:SetScript("OnUpdate", function(self, elapsed)
	if(self.rangeTimer > TOOLTIP_UPDATE_TIME) then
		local HotKey = self.HotKey
		local Icon = self.Icon
		local inRange = IsItemInRange(self.itemLink, "target")
		if(HotKey:GetText() == RANGE_INDICATOR) then
			if(inRange == false) then
				HotKey:SetTextColor(1, 0.1, 0.1)
				HotKey:Show()
				Icon:SetVertexColor(1, 0.3, 0.1)
			elseif(inRange) then
				HotKey:SetTextColor(1, 1, 1)
				HotKey:Show()
				Icon:SetVertexColor(1, 1, 1)
			else
				HotKey:Hide()
			end
		else
			if(inRange == false) then
				HotKey:SetTextColor(1, 0.1, 0.1)
				Icon:SetVertexColor(1, 0.3, 0.1)
			else
				HotKey:SetTextColor(1, 1, 1)
				Icon:SetVertexColor(1, 1, 1)
			end
		end

		self.rangeTimer = 0
	else
		self.rangeTimer = self.rangeTimer + elapsed
	end

	if(self.updateTimer > 5) then
		self:Update()
		self.updateTimer = 0
	else
		self.updateTimer = self.updateTimer + elapsed
	end
end)

local zoneWide = {
	[14108] = 541,
}

function Button:SetItem(itemLink, texture)
	if(itemLink) then
		if(itemLink == self.itemLink and self:IsShown()) then
			return
		end

		self.Icon:SetTexture(texture)
		self.Artwork:SetTexture(GetOverrideBarSkin() or DefaultExtraActionStyle)
		self.itemID, self.itemName = string.match(itemLink, "|Hitem:(.-):.-|h%[(.+)%]|h")
		self.itemLink = itemLink
	end

	local HotKey = self.HotKey
	local key = GetBindingKey("EXTRAACTIONBUTTON1")
	if(key) then
{'fraction_non_alphanumeric': 0.1372485399091499, 'fraction_numerical': 0.01600692191217824, 'mean_word_length': 5.372846312887663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '138106', 'n_tokens_mistral': 3717, 'n_tokens_neox': 3308, 'n_words': 625}