Skip to content

Commit

Permalink
Search added to options panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Oct 8, 2021
1 parent 1c20f16 commit 9e25e24
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 49 deletions.
50 changes: 32 additions & 18 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 275
local dversion = 277
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)

Expand Down Expand Up @@ -4280,63 +4280,72 @@ 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
tremove(self.inUse, i)
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,
Expand All @@ -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


Expand Down
107 changes: 100 additions & 7 deletions Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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},
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 13 additions & 4 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

local version, build, date, tocversion = GetBuildInfo()

_detalhes.build_counter = 8812
_detalhes.alpha_build_counter = 8812 --if this is higher than the regular counter, use it instead
_detalhes.build_counter = 8888
_detalhes.alpha_build_counter = 8888 --if this is higher than the regular counter, use it instead
_detalhes.bcc_counter = 28
_detalhes.dont_open_news = true
_detalhes.game_version = version
Expand All @@ -33,6 +33,15 @@ do
local Loc = _G.LibStub("AceLocale-3.0"):GetLocale( "Details" )

local news = {

{"v9.1.0.8888.145", "October 7th, 2021"},
"Search has been added into the options panel",
"Improvements on overkill amount of damage",
"Fonts 'Oswald' and 'NuevaStd' enabled again.",
"Added critical hits to Death Log (by C. Raethke)",
"Added settings to change the color on death log, they are within the class colors panel.",
"Don't show TaintWarning frame if MiniMapBattlefieldFrame is hidden (by Flamanis).",

{"v9.1.0.8812.145", "September 5th, 2021"},
"Fonts 'Oswald' and 'NuevaStd' disabled due to some erros on the client side.",
"Death Knight adds now include the icon of the spell whose summoned them.",
Expand Down Expand Up @@ -755,8 +764,8 @@ do
SharedMedia:Register ("border", "Details BarBorder 3", [[Interface\AddOns\Details\images\border_3]])
SharedMedia:Register ("border", "1 Pixel", [[Interface\Buttons\WHITE8X8]])
--misc fonts
--SharedMedia:Register ("font", "Oswald", [[Interface\Addons\Details\fonts\Oswald-Regular.otf]]) --blizz deativated support to .OTF font? (04-Set-2021)
--SharedMedia:Register ("font", "Nueva Std Cond", [[Interface\Addons\Details\fonts\NuevaStd-Cond.otf]])
SharedMedia:Register ("font", "Oswald", [[Interface\Addons\Details\fonts\Oswald-Regular.ttf]])
SharedMedia:Register ("font", "Nueva Std Cond", [[Interface\Addons\Details\fonts\NuevaStd-Cond.ttf]])
SharedMedia:Register ("font", "Accidental Presidency", [[Interface\Addons\Details\fonts\Accidental Presidency.ttf]])
SharedMedia:Register ("font", "TrashHand", [[Interface\Addons\Details\fonts\TrashHand.TTF]])
SharedMedia:Register ("font", "Harry P", [[Interface\Addons\Details\fonts\HARRYP__.TTF]])
Expand Down
Loading

0 comments on commit 9e25e24

Please sign in to comment.