- made SnD module work for non-english clients

- added a toggleable option to make the bar show as a percentage of the maximum attainable slice and dice time (with set bonuses and talents accounted for) instead of going from full to empty no matter the duration
This commit is contained in:
Parnic
2008-05-01 01:21:12 +00:00
parent 43c16be9e1
commit 76f8774a34

View File

@ -2,6 +2,17 @@ local AceOO = AceLibrary("AceOO-2.0")
local SliceAndDice = AceOO.Class(IceUnitBar) local SliceAndDice = AceOO.Class(IceUnitBar)
local NetherbladeItemIdList = {29044, 29045, 29046, 29047, 29048}
local NetherbladeEquipLocList = {"HeadSlot", "ShoulderSlot", "ChestSlot", "LegsSlot", "HandsSlot"}
local baseTime = 9
local gapPerComboPoint = 3
local netherbladeBonus = 3
local impSndTalentPage = 2
local impSndTalentIdx = 4
local impSndBonusPerRank = 0.15
local maxComboPoints = 5
-- Constructor -- -- Constructor --
function SliceAndDice.prototype:init() function SliceAndDice.prototype:init()
SliceAndDice.super.prototype.init(self, "SliceAndDice", "player") SliceAndDice.super.prototype.init(self, "SliceAndDice", "player")
@ -40,9 +51,10 @@ function SliceAndDice.prototype:GetDefaultSettings()
settings["shouldAnimate"] = false settings["shouldAnimate"] = false
settings["desiredLerpTime"] = nil settings["desiredLerpTime"] = nil
settings["lowThreshold"] = 0 settings["lowThreshold"] = 0
settings["side"] = IceCore.Side.Right settings["side"] = IceCore.Side.Right
settings["offset"] = 4 settings["offset"] = 4
settings["upperText"]="SnD:#" settings["upperText"]="SnD:#"
settings["showAsPercentOfMax"] = true
return settings return settings
end end
@ -59,6 +71,22 @@ function SliceAndDice.prototype:GetOptions()
opts["textSettings"].args["upperTextString"]["desc"] = "The text to display under this bar. # will be replaced with the number of Slice and Dice seconds remaining." opts["textSettings"].args["upperTextString"]["desc"] = "The text to display under this bar. # will be replaced with the number of Slice and Dice seconds remaining."
opts["textSettings"].args["lockLowerFontAlpha"] = nil opts["textSettings"].args["lockLowerFontAlpha"] = nil
opts["showAsPercentOfMax"] =
{
type = 'toggle',
name = 'Show bar as % of maximum',
desc = 'If this is checked, then the SnD buff time shows as a percent of the maximum attainable (taking set bonuses and talents into account). Otherwise, the bar always goes from full to empty when applying SnD no matter the duration.',
get = function()
return self.moduleSettings.showAsPercentOfMax
end,
set = function(v)
self.moduleSettings.showAsPercentOfMax = v
end,
disabled = function()
return not self.moduleSettings.enabled
end
}
return opts return opts
end end
@ -69,7 +97,7 @@ function _GetBuffDuration(unitName, buffName)
local buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i) local buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i)
while buff do while buff do
if (buff == buffName) then if (texture and string.match(texture, buffName)) then
return duration, remaining return duration, remaining
end end
@ -82,11 +110,11 @@ function _GetBuffDuration(unitName, buffName)
end end
function SliceAndDice.prototype:UpdateSliceAndDice() function SliceAndDice.prototype:UpdateSliceAndDice()
local duration, remaining = _GetBuffDuration("player", "Slice and Dice") local duration, remaining = _GetBuffDuration("player", "Ability_Rogue_SliceDice")
if (duration ~= nil) and (remaining ~= nil) then if (duration ~= nil) and (remaining ~= nil) then
self:Show(true) self:Show(true)
self:UpdateBar(remaining / duration, "SliceAndDice") self:UpdateBar(remaining / (self.moduleSettings.showAsPercentOfMax and self:GetMaxBuffTime() or duration), "SliceAndDice")
formatString = self.moduleSettings.upperText or '' formatString = self.moduleSettings.upperText or ''
self:SetBottomText1(string.gsub(formatString, "#", tostring(floor(remaining)))) self:SetBottomText1(string.gsub(formatString, "#", tostring(floor(remaining))))
else else
@ -94,6 +122,66 @@ function SliceAndDice.prototype:UpdateSliceAndDice()
end end
end end
function SliceAndDice.prototype:GetMaxBuffTime()
local maxduration
maxduration = baseTime + (maxComboPoints * gapPerComboPoint)
if self:HasNetherbladeBonus() then
maxduration = maxduration + netherbladeBonus
end
_, _, _, _, rank = GetTalentInfo(impSndTalentPage, impSndTalentIdx)
maxduration = maxduration * (1 + (rank * impSndBonusPerRank))
return maxduration
end
function SliceAndDice.prototype:HasNetherbladeBonus()
local numPieces
local linkStr, itemId
numPieces = 0
-- run through all the possible equip locations of a netherblade piece
for i=1,#NetherbladeEquipLocList do
-- pull the link string for the item in this equip loc
linkStr = GetInventoryItemLink(self.unit, GetInventorySlotInfo(NetherbladeEquipLocList[i]))
-- get the item id out of that link string
itemId = self:GetItemIdFromItemLink(linkStr)
-- check if the item id in that slot is part of the netherblade item id list
if self:IsItemIdInList(itemId, NetherbladeItemIdList) then
-- increment the fact that we have this piece of netherblade
numPieces = numPieces + 1
-- check if we've met the set bonus for slice and dice
if numPieces >= 2 then
return true
end
end
end
end
function SliceAndDice.prototype:GetItemIdFromItemLink(linkStr)
local itemId
_, itemId, _, _, _, _, _, _, _ = strsplit(":", linkStr)
return itemId
end
function SliceAndDice.prototype:IsItemIdInList(itemId, list)
for i=1,#list do
if string.match(itemId, list[i]) then
return true
end
end
return false
end
local _, unitClass = UnitClass("player") local _, unitClass = UnitClass("player")
-- Load us up -- Load us up
if unitClass == "ROGUE" then if unitClass == "ROGUE" then