Streamer plugin downport
This commit is contained in:
@@ -527,6 +527,7 @@ local CreatePluginFrames = function()
|
||||
DetailsRaidCheck:SendMsgToChannel(reportString, "PARTY")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local updateRaidCheckFrame = function(self, deltaTime) --~update
|
||||
|
||||
@@ -335,27 +335,31 @@ local function CreatePluginFrames()
|
||||
end
|
||||
|
||||
function StreamOverlay:UpdateCooldownFrame(square, inCooldown, startTime, endTime, castInfo)
|
||||
|
||||
if (castInfo and castInfo.Interrupted and castInfo.InterruptedPct) then
|
||||
CooldownFrame_SetDisplayAsPercentage(square.cooldown, abs(castInfo.InterruptedPct - 1))
|
||||
local _, curDuration = square.cooldown:GetCooldownTimes()
|
||||
local duration = abs(castInfo.InterruptedPct - 1)
|
||||
if not square.cooldown:IsPaused() and duration * 1000 ~= curDuration then
|
||||
CooldownFrame_SetDisplayAsPercentage(square.cooldown, duration)
|
||||
end
|
||||
--square.interruptedTexture:Show()
|
||||
return
|
||||
else
|
||||
square.cooldown:Resume()
|
||||
end
|
||||
|
||||
if (endTime and endTime < GetTime()) then
|
||||
if (not endTime or endTime < GetTime()) then
|
||||
CooldownFrame_Clear(square.cooldown)
|
||||
square.cooldown:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
if (inCooldown) then
|
||||
local duration = endTime - startTime
|
||||
CooldownFrame_Set(square.cooldown, startTime, duration, duration > 0, true)
|
||||
square.cooldown:Show()
|
||||
|
||||
local curStart, curDuration = square.cooldown:GetCooldownTimes()
|
||||
if curStart ~= startTime or duration * 1000 ~= curDuration then
|
||||
CooldownFrame_Set(square.cooldown, startTime, duration, duration > 0, true)
|
||||
end
|
||||
else
|
||||
CooldownFrame_Clear(square.cooldown)
|
||||
square.cooldown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -378,8 +382,8 @@ local function CreatePluginFrames()
|
||||
local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", newSquare, "CooldownFrameTemplate, BackdropTemplate")
|
||||
cooldownFrame:SetAllPoints()
|
||||
cooldownFrame:EnableMouse(false)
|
||||
cooldownFrame:SetHideCountdownNumbers(true)
|
||||
newSquare.cooldown = cooldownFrame
|
||||
|
||||
|
||||
StreamOverlay.squares[#StreamOverlay.squares+1] = newSquare
|
||||
newSquare.in_use = 1
|
||||
@@ -456,7 +460,6 @@ local function CreatePluginFrames()
|
||||
end
|
||||
|
||||
FauxScrollFrame_Update(autoscroll, StreamOverlay.total_lines, StreamOverlay.total_lines, 20)
|
||||
|
||||
for index = 1, StreamOverlay.total_lines do
|
||||
--> here gets the bar and the table with the information to shown on the bar
|
||||
local data = StreamOverlay.battle_content [index]
|
||||
@@ -539,12 +542,16 @@ local function CreatePluginFrames()
|
||||
if (castinfo.Success) then
|
||||
line.spark:SetVertexColor(1, 1, 1, 0.4)
|
||||
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0)
|
||||
line.statusbar_texture:SetVertexColor(0, 1, 0, 0.4)
|
||||
|
||||
elseif (castinfo.Interrupted) then
|
||||
line.spark:SetVertexColor(1, 0, 0, 0.4)
|
||||
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0)
|
||||
line.statusbar_texture:SetVertexColor(1, 0, 0, 0.4)
|
||||
else
|
||||
line.statusbar_texture:SetVertexColor(unpack(StreamOverlay.db.row_color))
|
||||
end
|
||||
|
||||
|
||||
line.in_use = data.CastStart
|
||||
StreamOverlay:RefreshInUse (line)
|
||||
else
|
||||
@@ -562,7 +569,9 @@ local function CreatePluginFrames()
|
||||
|
||||
--CastStart from the cast_send
|
||||
table.insert (StreamOverlay.battle_content, 1, {icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, CastID = ID, CastStart = CastStart, startTime = startTime, endTime = endTime})
|
||||
table.remove (StreamOverlay.battle_content, StreamOverlay.total_lines+1)
|
||||
while #StreamOverlay.battle_content > StreamOverlay.total_lines do
|
||||
table.remove (StreamOverlay.battle_content, StreamOverlay.total_lines+1)
|
||||
end
|
||||
|
||||
if (StreamOverlay.db.use_square_mode) then
|
||||
StreamOverlay:UpdateSquares()
|
||||
@@ -1049,9 +1058,9 @@ function StreamOverlay:CastStart (castGUID)
|
||||
else
|
||||
color2 = DefaultColor
|
||||
end
|
||||
|
||||
|
||||
target = parse_target_name (target)
|
||||
|
||||
|
||||
StreamOverlay:NewText (spellicon, spellname, color1, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castGUID, caststart, startTime, endTime)
|
||||
end
|
||||
|
||||
@@ -1090,7 +1099,6 @@ function StreamOverlay:CastFinished (castid)
|
||||
end
|
||||
|
||||
target = parse_target_name (target)
|
||||
|
||||
StreamOverlay:NewText (spellicon, spellname, nil, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castid, caststart, GetTime(), GetTime()+1.2)
|
||||
end
|
||||
end
|
||||
@@ -1113,12 +1121,14 @@ eventFrame.track_spell_cast = function()
|
||||
castinfo.Percent = 100
|
||||
line.statusbar:SetValue (100)
|
||||
line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0)
|
||||
line.statusbar_texture:SetVertexColor(0, 1, 0, 0.4)
|
||||
--line.spark:Hide()
|
||||
|
||||
elseif (castinfo.Interrupted) then
|
||||
--> has been interrupted
|
||||
castinfo.Done = true
|
||||
line.spark:SetVertexColor (1, 0.7, 0)
|
||||
line.statusbar_texture:SetVertexColor(1, 0, 0, 0.4)
|
||||
|
||||
elseif (castinfo.IsChanneled) then
|
||||
--> casting a channeled spell
|
||||
@@ -1143,10 +1153,10 @@ eventFrame.track_spell_cast = function()
|
||||
line.spark:SetVertexColor(1, 1, 1, 1)
|
||||
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
|
||||
end
|
||||
|
||||
line.statusbar_texture:SetVertexColor(unpack(StreamOverlay.db.row_color))
|
||||
else
|
||||
--> still casting
|
||||
local spell, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo("player")
|
||||
local spell, rank, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo("player")
|
||||
if (spell) then
|
||||
startTime = startTime / 1000
|
||||
endTime = endTime / 1000
|
||||
@@ -1165,6 +1175,7 @@ eventFrame.track_spell_cast = function()
|
||||
line.spark:SetVertexColor(1, 1, 1, 1)
|
||||
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
|
||||
end
|
||||
line.statusbar_texture:SetVertexColor(unpack(StreamOverlay.db.row_color))
|
||||
end
|
||||
|
||||
else
|
||||
@@ -1174,6 +1185,7 @@ eventFrame.track_spell_cast = function()
|
||||
castinfo.Percent = 100
|
||||
line.statusbar:SetValue (100)
|
||||
line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0)
|
||||
line.statusbar_texture:SetVertexColor(0, 1, 0, 0.4)
|
||||
--line.spark:Hide()
|
||||
else
|
||||
local startTime = castinfo.CastStart
|
||||
@@ -1194,6 +1206,7 @@ eventFrame.track_spell_cast = function()
|
||||
|
||||
line.spark:SetVertexColor (1, 1, 1, 1)
|
||||
line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
|
||||
line.statusbar_texture:SetVertexColor(unpack(StreamOverlay.db.row_color))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1243,7 +1256,7 @@ eventFrame.track_spell_cast = function()
|
||||
|
||||
else
|
||||
--> still casting
|
||||
local spell, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo ("player")
|
||||
local spell, rank, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo ("player")
|
||||
if (spell) then
|
||||
startTime = startTime / 1000
|
||||
endTime = endTime / 1000
|
||||
@@ -1278,7 +1291,7 @@ eventFrame.track_spell_cast = function()
|
||||
|
||||
elseif (castinfo.Done and line) then
|
||||
if (castinfo.Interrupted and castinfo.InterruptedPct) then
|
||||
StreamOverlay:UpdateCooldownFrame(line, true, castinfo.CastTimeStart, castinfo.InterruptedTime, castinfo)
|
||||
StreamOverlay:UpdateCooldownFrame(line, true, castinfo.CastStart, castinfo.InterruptedTime, castinfo)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1297,11 +1310,6 @@ function eventFrame:RegisterMyEvents()
|
||||
eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP")
|
||||
eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE")
|
||||
eventFrame:RegisterEvent ("UNIT_SPELLCAST_STOP")
|
||||
|
||||
if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then
|
||||
eventFrame:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE")
|
||||
eventFrame:RegisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
|
||||
end
|
||||
end
|
||||
|
||||
function eventFrame:UnregisterMyEvents()
|
||||
@@ -1316,14 +1324,9 @@ function eventFrame:UnregisterMyEvents()
|
||||
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP")
|
||||
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE")
|
||||
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_STOP")
|
||||
|
||||
if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then
|
||||
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE")
|
||||
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
|
||||
end
|
||||
end
|
||||
|
||||
local lastspell, lastcastid, lastchannelid, ischanneling, lastspellID
|
||||
local lastspell, lastcastid, lastchannelid, ischanneling, lastspellID, lastCastSentTime, lastTarget
|
||||
local channelspells = {}
|
||||
local lastChannelSpell = ""
|
||||
|
||||
@@ -1340,7 +1343,10 @@ APM_FRAME:RegisterEvent ("PLAYER_STOPPED_MOVING")
|
||||
APM_FRAME:SetScript ("OnEvent", function()
|
||||
ACTIONS = ACTIONS + 1
|
||||
end)
|
||||
|
||||
local GetSpellID = function (spellName, spellRank)
|
||||
local spellID = tonumber(string.match(GetSpellLink(spellName, spellRank) or "", "Hspell:(%d+)"))
|
||||
return spellID
|
||||
end
|
||||
eventFrame:SetScript ("OnEvent", function (self, event, ...)
|
||||
if (event ~= "UNIT_SPELLCAST_SENT" and event ~= "UNIT_SPELLCAST_SUCCEEDED" and ACTIONS_EVENT_TIME [event] ~= GetTime()) then
|
||||
ACTIONS = ACTIONS + 1
|
||||
@@ -1348,36 +1354,34 @@ eventFrame:SetScript ("OnEvent", function (self, event, ...)
|
||||
end
|
||||
|
||||
if (event == "UNIT_SPELLCAST_SENT") then
|
||||
local unitID, target, castGUID, spellID = ...
|
||||
--local unitID, spell, rank, target, id = ...
|
||||
local spell = GetSpellInfo (spellID)
|
||||
|
||||
local unitID, spellName, spellRank, target = ...
|
||||
if (unitID == "player") then
|
||||
CastsTable [castGUID] = {Target = target or "", Id = castGUID, CastStart = GetTime()}
|
||||
lastChannelSpell = castGUID
|
||||
lastspell = spell
|
||||
lastspellID = spellID
|
||||
lastcastid = castGUID
|
||||
local spellID = GetSpellID(spellName, spellRank)
|
||||
if spellID then
|
||||
lastTarget = target
|
||||
lastspellID = spellID
|
||||
lastchannelid = spellID
|
||||
lastCastSentTime = GetTime()
|
||||
end
|
||||
end
|
||||
|
||||
elseif (event == "UNIT_SPELLCAST_START") then
|
||||
--spell, rank, id,
|
||||
local unitID, castGUID, spellID = ...
|
||||
|
||||
if (unitID == "player" and CastsTable [castGUID]) then
|
||||
CastsTable [castGUID].SpellId = spellID
|
||||
CastsTable [castGUID].HasCastTime = true
|
||||
local unitID, spellName, spellRank, castGUID = ...
|
||||
local spellID = GetSpellID(spellName, spellRank)
|
||||
if (unitID == "player" and lastspellID == spellID) then
|
||||
CastsTable [castGUID] = {Target = lastTarget or "", Id = castGUID, SpellId = spellID, CastStart = lastCastSentTime, HasCastTime = true}
|
||||
lastChannelSpell = castGUID
|
||||
lastspell = spell
|
||||
lastcastid = castGUID
|
||||
|
||||
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo("player")
|
||||
local name, rank, displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo("player")
|
||||
CastsTable [castGUID].CastTimeStart = startTime / 1000
|
||||
CastsTable [castGUID].CastTimeEnd = endTime / 1000
|
||||
|
||||
StreamOverlay:CastStart(castGUID)
|
||||
end
|
||||
|
||||
elseif (event == "UNIT_SPELLCAST_INTERRUPTED") then
|
||||
--local unitID, spell, rank, id, spellID = ...
|
||||
local unitID, castGUID, spellID = ...
|
||||
local unitID, spellName, spellRank, castGUID = ...
|
||||
|
||||
if (unitID == "player" and CastsTable [castGUID]) then
|
||||
CastsTable [castGUID].Interrupted = true
|
||||
@@ -1386,8 +1390,7 @@ eventFrame:SetScript ("OnEvent", function (self, event, ...)
|
||||
|
||||
--> channels isn't passing the CastID / cast id for channels is always Zero.
|
||||
elseif (event == "UNIT_SPELLCAST_CHANNEL_STOP") then
|
||||
--local unitID, spell, rank, id, spellID = ...
|
||||
local unitID, castGUID, spellID = ...
|
||||
local unitID, spellName, spellRank, castGUID = ...
|
||||
|
||||
if (unitID == "player") then
|
||||
castGUID = lastchannelid
|
||||
@@ -1406,10 +1409,10 @@ eventFrame:SetScript ("OnEvent", function (self, event, ...)
|
||||
|
||||
elseif (event == "UNIT_SPELLCAST_CHANNEL_START") then
|
||||
|
||||
local unitID, castGUID, spellID = ...
|
||||
|
||||
local unitID, spellName, spellRank = ...
|
||||
local spellID = GetSpellID(spellName, spellRank)
|
||||
if (unitID == "player" and (CastsTable [castGUID] or spellID == lastspellID)) then
|
||||
if (castGUID == "" or not castGUID) then
|
||||
if (not castGUID) then
|
||||
castGUID = lastcastid
|
||||
end
|
||||
|
||||
@@ -1441,19 +1444,18 @@ eventFrame:SetScript ("OnEvent", function (self, event, ...)
|
||||
|
||||
elseif (event == "UNIT_SPELLCAST_SUCCEEDED") then
|
||||
--local unitID, spell, rank, id, spellID = ...
|
||||
local unitID, castGUID, spellID = ...
|
||||
local spell = GetSpellInfo (spellID)
|
||||
|
||||
if (unitID == "player" and CastsTable[castGUID] and not channelspells [spell]) then
|
||||
if (CastsTable[castGUID].HasCastTime and not CastsTable[castGUID].IsChanneled) then
|
||||
--> a cast (non channeled) just successful finished
|
||||
CastsTable [castGUID].Success = true
|
||||
StreamOverlay:CastFinished (castGUID)
|
||||
|
||||
elseif (not CastsTable[castGUID].HasCastTime) then
|
||||
--> instant cast finished
|
||||
CastsTable [castGUID].SpellId = spellID
|
||||
CastsTable [castGUID].Success = true
|
||||
local unitID, spellName, spellRank, castGUID = ...
|
||||
local spellID = GetSpellID(spellName, spellRank)
|
||||
if (unitID == "player" and lastspellID == spellID and not channelspells [spellName]) then
|
||||
if (CastsTable[castGUID]) then
|
||||
if (CastsTable[castGUID].HasCastTime and not CastsTable[castGUID].IsChanneled) then
|
||||
--> a cast (non channeled) just successful finished
|
||||
CastsTable [castGUID].Success = true
|
||||
StreamOverlay:CastFinished (castGUID)
|
||||
end
|
||||
else
|
||||
--> instant cast
|
||||
CastsTable [castGUID] = {Target = lastTarget or "", Id = castGUID, SpellId = spellID, CastStart = lastCastSentTime, HasCastTime = false, Success = true }
|
||||
StreamOverlay:CastFinished (castGUID)
|
||||
end
|
||||
end
|
||||
@@ -1465,16 +1467,15 @@ local format_time = function (v) return "-" .. format ("%.2f", v) end
|
||||
|
||||
--when the player die, show the events before the death
|
||||
function StreamOverlay.OnDeath (_, token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, death_table, last_cooldown, death_at_combattime, max_health)
|
||||
|
||||
if (alvo_serial ~= UnitGUID ("player")) then
|
||||
return
|
||||
end
|
||||
|
||||
StreamOverlay:ClearAll()
|
||||
|
||||
for i = 1, #death_table do
|
||||
local ev = death_table [i]
|
||||
if (ev and type (ev) == "table" and ev[1] and type (ev[1]) == "boolean") then
|
||||
local lastEvents = death_table[1]
|
||||
for i = #lastEvents, 1, -1 do
|
||||
local ev = lastEvents[i]
|
||||
if (ev and type (ev) == "table" and type(ev[1]) == "boolean") then
|
||||
--> it's a damage
|
||||
local spellid = ev[2]
|
||||
local amount = ev[3]
|
||||
@@ -1525,7 +1526,7 @@ function StreamOverlay.OnDeath (_, token, time, who_serial, who_name, who_flags,
|
||||
|
||||
--adds the text to the line
|
||||
StreamOverlay:NewText (spellicon, at .. " | " .. damage_color .. StreamOverlay:ToK2 (amount) .. "|r (" .. spellname .. ")", {1, 1, 1, 1}, classIcon, {l, r, t, b}, source, {r=1, g=1, b=1}, {1, 1, 1, 0.6}, {0, 0, 0}, CastInfoIndex, GetTime())
|
||||
|
||||
break
|
||||
-- :NewText (icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, ID, CastStart)
|
||||
end
|
||||
end
|
||||
@@ -2435,13 +2436,6 @@ function StreamOverlay:OnEvent (_, event, ...)
|
||||
|
||||
if (StreamOverlay.db.is_first_run and not Details:GetTutorialCVar ("STREAMER_PLUGIN_FIRSTRUN")) then
|
||||
local show_frame = function()
|
||||
|
||||
if ("Don't Show The Welcome Screen") then
|
||||
StreamOverlay.db.is_first_run = false
|
||||
Details:DisablePlugin ("DETAILS_PLUGIN_STREAM_OVERLAY")
|
||||
return
|
||||
end
|
||||
|
||||
if ((DetailsWelcomeWindow and DetailsWelcomeWindow:IsShown()) or not StreamOverlay.db.is_first_run) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -7,8 +7,4 @@
|
||||
|
||||
## X-Wago-ID: VBNB9MGx
|
||||
|
||||
#@no-lib-strip@
|
||||
embeds.xml
|
||||
#@end-no-lib-strip@
|
||||
|
||||
Details_Streamer.lua
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
|
||||
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
|
||||
-- LibStub is hereby placed in the Public Domain
|
||||
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
|
||||
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
|
||||
local LibStub = _G[LIBSTUB_MAJOR]
|
||||
|
||||
-- Check to see is this version of the stub is obsolete
|
||||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
LibStub = LibStub or {libs = {}, minors = {} }
|
||||
_G[LIBSTUB_MAJOR] = LibStub
|
||||
LibStub.minor = LIBSTUB_MINOR
|
||||
|
||||
-- LibStub:NewLibrary(major, minor)
|
||||
-- major (string) - the major version of the library
|
||||
-- minor (string or number ) - the minor version of the library
|
||||
--
|
||||
-- returns nil if a newer or same version of the lib is already present
|
||||
-- returns empty library object or old library object if upgrade is needed
|
||||
function LibStub:NewLibrary(major, minor)
|
||||
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
|
||||
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
|
||||
|
||||
local oldminor = self.minors[major]
|
||||
if oldminor and oldminor >= minor then return nil end
|
||||
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
|
||||
return self.libs[major], oldminor
|
||||
end
|
||||
|
||||
-- LibStub:GetLibrary(major, [silent])
|
||||
-- major (string) - the major version of the library
|
||||
-- silent (boolean) - if true, library is optional, silently return nil if its not found
|
||||
--
|
||||
-- throws an error if the library can not be found (except silent is set)
|
||||
-- returns the library object if found
|
||||
function LibStub:GetLibrary(major, silent)
|
||||
if not self.libs[major] and not silent then
|
||||
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
|
||||
end
|
||||
return self.libs[major], self.minors[major]
|
||||
end
|
||||
|
||||
-- LibStub:IterateLibraries()
|
||||
--
|
||||
-- Returns an iterator for the currently registered libraries
|
||||
function LibStub:IterateLibraries()
|
||||
return pairs(self.libs)
|
||||
end
|
||||
|
||||
setmetatable(LibStub, { __call = LibStub.GetLibrary })
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
## Interface: 40200
|
||||
## Title: Lib: LibStub
|
||||
## Notes: Universal Library Stub
|
||||
## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
|
||||
## X-Website: http://www.wowace.com/addons/libstub/
|
||||
## X-Category: Library
|
||||
## X-License: Public Domain
|
||||
## X-Curse-Packaged-Version: r95
|
||||
## X-Curse-Project-Name: LibStub
|
||||
## X-Curse-Project-ID: libstub
|
||||
## X-Curse-Repository-ID: wow/libstub/mainline
|
||||
|
||||
LibStub.lua
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
|
||||
assert(lib) -- should return the library table
|
||||
assert(not oldMinor) -- should not return the old minor, since it didn't exist
|
||||
|
||||
-- the following is to create data and then be able to check if the same data exists after the fact
|
||||
function lib:MyMethod()
|
||||
end
|
||||
local MyMethod = lib.MyMethod
|
||||
lib.MyTable = {}
|
||||
local MyTable = lib.MyTable
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
|
||||
assert(newLib) -- library table
|
||||
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
|
||||
assert(newOldMinor == 1) -- should return the minor version of the previous version
|
||||
|
||||
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
|
||||
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib) -- library table
|
||||
assert(newOldMinor == 2) -- previous version was 2
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
|
||||
@@ -1,27 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib doesn't exist yet, by iterating through all the libraries
|
||||
assert(major ~= "MyLib")
|
||||
end
|
||||
|
||||
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
|
||||
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
|
||||
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
|
||||
assert(lib) -- check it exists
|
||||
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
|
||||
|
||||
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
|
||||
|
||||
local count=0
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
|
||||
if major == "MyLib" then -- we found it!
|
||||
count = count +1
|
||||
assert(rawequal(library, lib)) -- verify that the references are equal
|
||||
end
|
||||
end
|
||||
assert(count == 1) -- verify that we actually found it, and only once
|
||||
@@ -1,14 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local proxy = newproxy() -- non-string
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
|
||||
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
|
||||
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
|
||||
|
||||
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
|
||||
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
|
||||
assert(LibStub.minor)
|
||||
LibStub.minor = LibStub.minor - 0.0001
|
||||
LibStub.IterateLibraries = nil
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(type(LibStub.IterateLibraries)=="function")
|
||||
|
||||
|
||||
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
|
||||
LibStub.IterateLibraries = 123
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
|
||||
LibStub.minor = LibStub.minor + 0.0001
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Again with a huge number
|
||||
LibStub.minor = LibStub.minor + 1234567890
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
print("OK")
|
||||
@@ -1,6 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
|
||||
<Script file="Libs\LibStub\LibStub.lua"/>
|
||||
|
||||
</Ui>
|
||||
Reference in New Issue
Block a user