Search added to options panel

This commit is contained in:
Tercio Jose
2021-10-07 21:49:15 -03:00
parent 1c20f166cb
commit 9e25e245d4
9 changed files with 173 additions and 49 deletions
+32 -18
View File
@@ -1,6 +1,6 @@
local dversion = 275
local dversion = 277
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
@@ -4280,27 +4280,32 @@ end
-----------------------------------------------------------------------------------------------------------------------------------------------------------
--> pool
do
do
local get = function(self)
local object = tremove(self.notUse, #self.notUse)
if (object) then
tinsert(self.inUse, object)
if (self.onAcquire) then
local result, errortext = pcall(self.onAcquire, object)
end
return object, false
else
--need to create the new object
local newObject = self.newObjectFunc(self, unpack(self.payload))
if (newObject) then
tinsert(self.inUse, newObject)
if (self.onAcquire) then
local result, errortext = pcall(self.onAcquire, object)
end
return newObject, true
end
end
end
local get_all_inuse = function(self)
return self.inUse;
end
local release = function(self, object)
for i = #self.inUse, 1, -1 do
if (self.inUse[i] == object) then
@@ -4308,35 +4313,39 @@ do
tinsert(self.notUse, object)
break
end
end
end
end
local reset = function(self)
for i = #self.inUse, 1, -1 do
local object = tremove(self.inUse, i)
tinsert(self.notUse, object)
end
if (self.onReset) then
local result, errortext = pcall(self.onReset, object)
end
end
end
--only hide objects in use, do not disable them
local hide = function(self)
for i = #self.inUse, 1, -1 do
self.inUse[i]:Hide()
end
end
end
--only show objects in use, do not enable them
local show = function(self)
for i = #self.inUse, 1, -1 do
self.inUse[i]:Show()
end
end
end
end
--return the amount of objects
local getamount = function(self)
return #self.notUse + #self.inUse, #self.notUse, #self.inUse
end
local poolMixin = {
Get = get,
GetAllInUse = get_all_inuse,
@@ -4347,25 +4356,30 @@ do
Hide = hide,
Show = show,
GetAmount = getamount,
SetOnReset = function(self, func)
self.onReset = func
end,
SetOnAcquire = function(self, func)
self.onAcquire = func
end,
}
function DF:CreatePool(func, ...)
local t = {}
DetailsFramework:Mixin(t, poolMixin)
t.inUse = {}
t.notUse = {}
t.newObjectFunc = func
t.payload = {...}
return t
end
--alias
function DF:CreateObjectPool(func, ...)
return DF:CreatePool(func, ...)
end
end
+100 -7
View File
@@ -16,6 +16,16 @@ local loadstring = loadstring --> lua local
local IS_WOW_PROJECT_MAINLINE = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_NOT_MAINLINE = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_CLASSIC_ERA = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IS_WOW_PROJECT_CLASSIC_TBC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
local UnitCastingInfo = UnitCastingInfo
local UnitChannelInfo = UnitChannelInfo
if IS_WOW_PROJECT_CLASSIC_ERA then
UnitCastingInfo = CastingInfo
UnitChannelInfo = ChannelInfo
end
local PixelUtil = PixelUtil or DFPixelUtil
@@ -7233,7 +7243,7 @@ DF.StatusBarFunctions = {
{"UNIT_HEALTH", true},
{"UNIT_MAXHEALTH", true},
{(IS_WOW_PROJECT_NOT_MAINLINE) and "UNIT_HEALTH_FREQUENT", true}, -- this one is classic-only...
{(IS_WOW_PROJECT_MAINLINE) and "UNIT_HEAL_PREDICTION", true},
{"UNIT_HEAL_PREDICTION", true},
{(IS_WOW_PROJECT_MAINLINE) and "UNIT_ABSORB_AMOUNT_CHANGED", true},
{(IS_WOW_PROJECT_MAINLINE) and "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", true},
}
@@ -7264,8 +7274,8 @@ DF.StatusBarFunctions = {
--> check for settings and update some events
if (not self.Settings.ShowHealingPrediction) then
self:UnregisterEvent ("UNIT_HEAL_PREDICTION")
if IS_WOW_PROJECT_MAINLINE then
self:UnregisterEvent ("UNIT_HEAL_PREDICTION")
self:UnregisterEvent ("UNIT_HEAL_ABSORB_AMOUNT_CHANGED")
end
self.incomingHealIndicator:Hide()
@@ -7365,7 +7375,6 @@ DF.StatusBarFunctions = {
--health and absorbs prediction
healthBarMetaFunctions.UpdateHealPrediction = function (self)
if IS_WOW_PROJECT_NOT_MAINLINE then return end
local currentHealth = self.currentHealth
local currentHealthMax = self.currentHealthMax
local healthPercent = currentHealth / currentHealthMax
@@ -7381,7 +7390,7 @@ DF.StatusBarFunctions = {
--incoming heal on the unit from all sources
local unitHealIncoming = self.displayedUnit and UnitGetIncomingHeals (self.displayedUnit) or 0
--heal absorbs
local unitHealAbsorb = self.displayedUnit and UnitGetTotalHealAbsorbs (self.displayedUnit) or 0
local unitHealAbsorb = IS_WOW_PROJECT_MAINLINE and self.displayedUnit and UnitGetTotalHealAbsorbs (self.displayedUnit) or 0
if (unitHealIncoming > 0) then
--calculate what is the percent of health incoming based on the max health the player has
@@ -7405,7 +7414,7 @@ DF.StatusBarFunctions = {
end
end
if (self.Settings.ShowShields) then
if (self.Settings.ShowShields and IS_WOW_PROJECT_MAINLINE) then
--damage absorbs
local unitDamageAbsorb = self.displayedUnit and UnitGetTotalAbsorbs (self.displayedUnit) or 0
@@ -8360,7 +8369,7 @@ DF.CastFrameFunctions = {
UpdateCastingInfo = function (self, unit)
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID
if IS_WOW_PROJECT_MAINLINE then
if not IS_WOW_PROJECT_CLASSIC_TBC then
name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo (unit)
else
name, text, texture, startTime, endTime, isTradeSkill, castID, spellID = UnitCastingInfo (unit)
@@ -8428,7 +8437,7 @@ DF.CastFrameFunctions = {
UpdateChannelInfo = function (self, unit, ...)
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID
if IS_WOW_PROJECT_MAINLINE then
if not IS_WOW_PROJECT_CLASSIC_TBC then
name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID = UnitChannelInfo (unit)
else
name, text, texture, startTime, endTime, isTradeSkill, spellID = UnitChannelInfo (unit)
@@ -8651,6 +8660,90 @@ DF.CastFrameFunctions = {
}
-- for classic era use LibClassicCasterino:
local LibCC = LibStub ("LibClassicCasterino", true)
if IS_WOW_PROJECT_CLASSIC_ERA and LibCC then
local fCast = CreateFrame("frame")
local getCastBar = function (unitId)
local plateFrame = C_NamePlate.GetNamePlateForUnit (unitId)
if (not plateFrame) then
return
end
local castBar = plateFrame.unitFrame and plateFrame.unitFrame.castBar
if (not castBar) then
return
end
return castBar
end
local triggerCastEvent = function (castBar, event, unitId, ...)
if (castBar and castBar.OnEvent) then
castBar.OnEvent (castBar, event, unitId)
end
end
local funcCast = function (event, unitId, ...)
local castBar = getCastBar (unitId)
if (castBar) then
triggerCastEvent (castBar, event, unitId)
end
end
fCast.UNIT_SPELLCAST_START = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_STOP = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_DELAYED = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_FAILED = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_INTERRUPTED = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_START = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_UPDATE = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_STOP = function (self, event, unitId, ...)
triggerCastEvent (getCastBar (unitId), event, unitId)
end
if LibCC then
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_START", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_DELAYED", funcCast) -- only for player
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_STOP", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_FAILED", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_INTERRUPTED", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_START", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_UPDATE", funcCast) -- only for player
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_STOP", funcCast)
UnitCastingInfo = function(unit)
return LibCC:UnitCastingInfo (unit)
end
UnitChannelInfo = function(unit)
return LibCC:UnitChannelInfo (unit)
end
end
end -- end classic era
-- ~castbar
function DF:CreateCastBar (parent, name, settingsOverride)