BetterCC

1 - Mod conflicts

What is the issue?

Please provide any additional information below.

Currently, your mod somehow conflicts with both BetterCC and Wikki's Cooldown Pulse.  Not sure why, but sure makes using the mods frustrating!

User When Change
oamer Mon, 27 Oct 2008 00:48:17 Create

You must login to post a comment. Don't have an account? Register to get one!

  • 2 comments
  • Avatar of Thrae Thrae Wed, 05 Nov 2008 00:33:24

    How to fix BetterCC:

    - Open up BetterCC.lua
    - Replace with contents below:

    --[[--------------------------------------------------------------------------------------------------------------
    Copyright (c) 2008 Brad Bates
    
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use,
    copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following
    conditions:
    
    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.
    --]]--------------------------------------------------------------------------------------------------------------
    BetterCC = 
    {
    	COOLDOWN_GRANULARITY = 0.1,
    }
    
    local uiscale = InterfaceCore.GetScale()
    local pulses = {}
    local activePulses = {}
    
    local DAY, HOUR, MINUTE, SHORT = 86400, 3600, 60, 5 --values for time
    local floor = math.floor
    local min, max = math.min, math.max
    
    local OrigUpdateCooldownAnimation
    function BetterCC.Initialize()
            OrigUpdateCooldownAnimation = ActionButton.UpdateCooldownAnimation or false
    	ActionButton.UpdateCooldownAnimation = BetterCC.BetterCCAnim
    	
    end
    
    function BetterCC.BetterCCAnim(self, timeElapsed, updateCooldown, ...)
    	local BASE_ICON         = 0
    	local BUTTON_TEXT       = 1
    	local COOLDOWN          = 2
    	local COOLDOWN_TIMER    = 3
    	local FLASH_ANIM        = 4
    	local ACTIVE_ANIM       = 5
    	local GLOW_ANIM         = 6
    	local STACK_COUNT_TEXT  = 7
    		
    	local cooldownFrame     = self.m_Windows[COOLDOWN]
    	local timerFrame        = self.m_Windows[COOLDOWN_TIMER]
    	local updateCooldown    = updateCooldown or self.m_RequiresFullUpdate
    		
            local m_Cooldown, m_MaxCooldown, isShown = self.m_Cooldown, self.m_MaxCooldown, cooldownFrame:IsShowing()
            if OrigUpdateCooldownAnimation then
                OrigUpdateCooldownAnimation(self, timeElapsed, updateCooldown, ...)
            end
            self.m_Cooldown, self.m_MaxCooldown = m_Cooldown, m_MaxCooldown
            cooldownFrame:Show(isShown)
    
    	if (updateCooldown) then
    		self.m_Cooldown, self.m_MaxCooldown = GetHotbarCooldown(self:GetSlot())
    	end
    		
    	if ((self.m_Cooldown > 0) and (self.m_MaxCooldown > 2)) then 
    		local oldTime       = TimeUtils.FormatRoundedSeconds(self.m_Cooldown, BetterCC.COOLDOWN_GRANULARITY)
    		local updateLabel   = false
    			
    		self.m_Cooldown = self.m_Cooldown - timeElapsed
    			
    		if (TimeUtils.FormatRoundedSeconds(self.m_Cooldown, BetterCC.COOLDOWN_GRANULARITY) < oldTime) then
    	        updateLabel = true
    	    end
    			
    		if (updateLabel or updateCooldown) then
    			local labelTime
    
    			if(self.m_Cooldown >= DAY)then
    				labelTime = string.format("%dd", floor(self.m_Cooldown/DAY + 0.5))
    			elseif(self.m_Cooldown >= HOUR)then
    				labelTime = string.format("%dh", floor(self.m_Coodlown/HOUR + 0.5))
    			elseif(self.m_Cooldown >= MINUTE)then	
    				labelTime = string.format("%d:%02d", floor(self.m_Cooldown/60), self.m_Cooldown % MINUTE)
    			else
    				labelTime = string.format("%d", floor(self.m_Cooldown + 0.5))
    			end
    	            
    			timerFrame:SetText(labelTime)
    			timerFrame:SetFont("font_clear_medium_bold", WindowUtils.FONT_DEFAULT_TEXT_LINESPACING)
    			timerFrame:SetTextColor(255, 255, 0)
    			if(self.m_Cooldown <= 10)then
    				timerFrame:SetTextColor(255, 0, 0)
    			end
    		end
    			
    	    local newAlpha  = 0.5 
    	            
    	    cooldownFrame:SetAlpha(newAlpha)			
    	    cooldownFrame:Show(true)
    	elseif (self.m_Cooldown <= 1 and cooldownFrame:IsShowing()) then
    		cooldownFrame:SetAlpha(0)
    		cooldownFrame:Show(false)
    	        
    		self.m_Cooldown     = 0
    		self.m_MaxCooldown  = 0
    		BetterCC.StartPulseAnimation(self, self.m_Cooldown)
    	end
    end
    
    function BetterCC.CreateCooldownPulse(frame, parent)
    	local pulse = frame
    	
    	
    	pulses[parent] = pulse
    	
    	return (pulse)
    end
    
    function BetterCC.StartPulseAnimation(info, timer)
    	--d(info)
    	local texture, x, y, disabledTexture = GetIconData(info.m_IconNum)
    	
    	if(texture)then
    		local pulse = pulses[info.m_Name] or BetterCC.CreateCooldownPulse(info, info.m_Name)
    		if(pulse) then
    			pulse.scale = 1
    			
    			activePulses[pulse] = true
    			pulse:Show(true)		
    		end
    	end
    end
    
    function BetterCC.UpdateAll(timePassed)
    	if(next(activePulses))then
    		for k in pairs(activePulses) do
    			BetterCC.UpdatePulse(k, timePassed)
    		end
    	end
    end
    
    function BetterCC.UpdatePulse(pulse, timePassed)
    	local windowName = pulse.m_Name.."ActionIcon"
    	local windowScale = WindowGetScale(pulse.m_Name)
    	
    	if pulse.scale >= 2 then
    		pulse.dec = 1
    	end
    
    	pulse.scale = max(min(pulse.scale + (pulse.dec and -1 or 1) * pulse.scale * (timePassed/0.5), 2), 1)
    	
    	if pulse.scale <= 1 then
    		activePulses[pulse] = nil
    		pulse.dec = nil
    		WindowSetAlpha(windowName, 1)
    		WindowClearAnchors(windowName)
    		WindowSetParent(windowName, pulse.m_Name)
    		WindowAddAnchor(windowName, "center", pulse.m_Name, "center", 0, 0)
    		WindowSetLayer(windowName, 0)
    		WindowSetScale(windowName, windowScale)
    	else
    		WindowSetAlpha(windowName, 0.5)
    		WindowClearAnchors(windowName)
    		WindowSetParent(windowName, "Root")
    		WindowAddAnchor(windowName, "center", pulse.m_Name, "center", 0, 0)
    		WindowSetLayer(windowName, 4)
    		WindowSetScale(windowName, pulse.scale * windowScale)
    	end
    end
    

    I take no ownership or responsibility for these edits.

  • Avatar of wikki wikki Mon, 27 Oct 2008 18:07:35

    Heya, I was the one that found the conflict, when I was looking into an issue one of my users was reporting.

    When you replace the function ActionButton.UpdateCooldownAnimation in this call: ActionButton.UpdateCooldownAnimation = BetterCC.BetterCCAnim

    You never store the original function to be called later on. This becomes an issue when your addon is loaded as the last addon to overwrite this function.

    I would suggest something similar to this that I use in Aura: AuraEngine.__ActionButton_UpdateCooldownAnimation = ActionButton.UpdateCooldownAnimation ActionButton.UpdateCooldownAnimation = AuraEngine.UpdateAbilityCooldownTimer

    I store the old function, replace the old with mine. As a note, the old function doesnt necessarily have to be the default UI one, it could very well be yours, or any other addon that overwrites it.


    Then when the function gets called:

    function AuraEngine.UpdateAbilityCooldownTimer( self, timeElapsed, updateCooldown )

    -- Call the original function

    AuraEngine.__ActionButton_UpdateCooldownAnimation( self, timeElapsed, updateCooldown )

    -- Do our work here

    The other thing to note when doing this is to not modify data that other addons could use to process their work.

  • 2 comments

Facts

Reported on
27 Oct 2008
Status
New - Issue has not had initial review yet.
Type
Other - Some other kind of issue
Priority
Medium - Normal priority.

Reported by

Possible assignees