Skip to content

Commit

Permalink
Framework update and small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jan 18, 2021
1 parent e47b117 commit 778cfba
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 46 deletions.
9 changes: 7 additions & 2 deletions .vscode/bookmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
"path": "$ROOTPATH$\\WorldQuestTracker_Tracker.lua",
"bookmarks": [
{
"line": 778,
"line": 783,
"column": 41,
"label": ""
},
{
"line": 825,
"line": 830,
"column": 1,
"label": ""
}
Expand Down Expand Up @@ -196,6 +196,11 @@
"line": 1065,
"column": 2,
"label": ""
},
{
"line": 1242,
"column": 6,
"label": ""
}
]
}
Expand Down
14 changes: 14 additions & 0 deletions WorldQuestTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,20 @@ function MicroButtonAlert_OnHide2(self)
end


----------------------------------------------------------------------------------------------------------------------------------------------------------------
local p = CreateFrame("frame")
p:RegisterEvent("TALKINGHEAD_REQUESTED")
p:SetScript("OnEvent", function (self, event, arg1)
if (event == "TALKINGHEAD_REQUESTED") then
local displayInfo, cameraID, vo, duration, lineNumber, numLines, name, text, isNewTalkingHead = C_TalkingHead.GetCurrentLineInfo()
if (WorldQuestTracker.db.profile.talking_heads[vo]) then
C_Timer.After(0.1, TalkingHeadFrame_CloseImmediately)
else
WorldQuestTracker.db.profile.talking_heads[vo] = true
end
end
end)

----------------------------------------------------------------------------------------------------------------------------------------------------------------
--> faction bounty

Expand Down
2 changes: 1 addition & 1 deletion WorldQuestTracker_GroupFinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ local GetDistance_Point = DF.GetDistance_Point


--leave group big button
local leaveButtonSolo = CreateFrame("button", "$parentLeaveButtonSolo", ff, "BackdropTemplate", "BackdropTemplate")
local leaveButtonSolo = CreateFrame("button", "$parentLeaveButtonSolo", ff, "BackdropTemplate")
DF:ApplyStandardBackdrop(leaveButtonSolo)
leaveButtonSolo:SetPoint("top", ff, "top", 0, ff.topLevelY)
leaveButtonSolo:Hide()
Expand Down
2 changes: 2 additions & 0 deletions WorldQuestTracker_Initialize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ do
tracker_scale = 1,
tracker_show_time = false,
tracker_textsize = 12,

talking_heads = {},

show_faction_frame = true,

Expand Down
5 changes: 5 additions & 0 deletions WorldQuestTracker_Tracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ local WorldQuestTrackerHeader = CreateFrame ("frame", "WorldQuestTrackerQuestsHe
WorldQuestTrackerHeader.Text:SetText ("World Quest Tracker")
local minimizeButton = CreateFrame ("button", "WorldQuestTrackerQuestsHeaderMinimizeButton", WorldQuestTrackerFrame, "BackdropTemplate")
local minimizeButtonText = minimizeButton:CreateFontString (nil, "overlay", "GameFontNormal")

--hide the default minimize button from the blizz template
WorldQuestTrackerHeader.MinimizeButton:Hide()

minimizeButtonText:SetText (L["S_WORLDQUESTS"])
minimizeButtonText:SetPoint ("right", minimizeButton, "left", -3, 1)
minimizeButtonText:Hide()
Expand All @@ -343,6 +347,7 @@ minimizeButton:SetScript ("OnClick", function()
minimizeButtonText:SetText ("World Quest Tracker")
end
end)

minimizeButton:SetNormalTexture ([[Interface\Buttons\UI-Panel-QuestHideButton]])
minimizeButton:GetNormalTexture():SetTexCoord (0, 0.5, 0.5, 1)
minimizeButton:SetPushedTexture ([[Interface\Buttons\UI-Panel-QuestHideButton]])
Expand Down
7 changes: 4 additions & 3 deletions libs/DF/addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
--when the player logout or reloadUI
local addonUnload = function(addonFrame, event, ...)
--close saved tables

DF.SavedVars.CloseSavedTable(addonFrame.db)
end

local addonEvents = {
Expand All @@ -46,8 +46,8 @@ local addonOnEvent = function(addonFrame, event, ...)
func(addonFrame, event, ...)
else
--might be a registered event from the user
if (addonFrame.event) then
DF:CoreDispatch(addonFrame.__name, addonFrame.event, addonFrame, event, ...)
if (addonFrame[event]) then
DF:CoreDispatch(addonFrame.__name, addonFrame[event], addonFrame, event, ...)
end
end
end
Expand All @@ -66,6 +66,7 @@ function DF:CreateNewAddOn(addonName, globalSavedVariablesName, savedVarsTemplat

newAddon:RegisterEvent("ADDON_LOADED")
newAddon:RegisterEvent("PLAYER_LOGIN")
newAddon:RegisterEvent("PLAYER_LOGOUT")
newAddon:SetScript("OnEvent", addonOnEvent)

return newAddon
Expand Down
7 changes: 5 additions & 2 deletions libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 223
local dversion = 230

local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
Expand Down Expand Up @@ -486,6 +486,7 @@ function DF:GroupIterator (func, ...)
for i = 1, GetNumGroupMembers() - 1 do
DF:QuickDispatch (func, "party" .. i, ...)
end
DF:QuickDispatch (func, "player", ...)

else
DF:QuickDispatch (func, "player", ...)
Expand Down Expand Up @@ -3549,7 +3550,7 @@ function DF:GetCharacterRaceList (fullList)

local alliedRaceInfo = C_AlliedRaces.GetRaceInfoByID (i)
if (alliedRaceInfo and DF.AlliedRaceList [alliedRaceInfo.raceID]) then
tinsert (DF.RaceCache, {Name = alliedRaceInfo.name, FileString = alliedRaceInfo.raceFileString})
tinsert (DF.RaceCache, {Name = alliedRaceInfo.maleName, FileString = alliedRaceInfo.raceFileString})
end
end

Expand Down Expand Up @@ -4237,3 +4238,5 @@ end
_G.setfenv(func, newEnvironment)
end


-----------------------------------------------------------------------------------------------------------------------------------------------------------
33 changes: 18 additions & 15 deletions libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5139,7 +5139,7 @@ DF.IconRowFunctions = {
newIconFrame.CountdownText:SetPoint (self.options.text_anchor or "center", newIconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0)
newIconFrame.CountdownText:Hide()

newIconFrame.StackText = cooldownFrame:CreateFontString (nil, "overlay", "GameFontNormal")
newIconFrame.StackText = newIconFrame:CreateFontString (nil, "overlay", "GameFontNormal")
--newIconFrame.StackText:SetPoint ("bottomright")
newIconFrame.StackText:SetPoint (self.options.stack_text_anchor or "center", newIconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
newIconFrame.StackText:Hide()
Expand Down Expand Up @@ -6080,7 +6080,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
canCheckTalents = false

for _, specID in ipairs (specsForThisClass) do
if (loadTable.spec [specID]) then
if (loadTable.spec [specID] or loadTable.spec [specID..""]) then
--theres a talent for this class
canCheckTalents = true
break
Expand All @@ -6092,7 +6092,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local specIndex = DetailsFramework.GetSpecialization()
if (specIndex) then
local specID = DetailsFramework.GetSpecializationInfo (specIndex)
if (not loadTable.spec [specID]) then
if not specID or (not loadTable.spec [specID] and not loadTable.spec [specID..""]) then
return false
end
else
Expand All @@ -6114,7 +6114,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local talentsInUse = DF:GetCharacterTalents (false, true)
local hasTalent
for talentID, _ in pairs (talentsInUse) do
if (loadTable.talent [talentID]) then
if talentID and (loadTable.talent [talentID] or loadTable.talent [talentID .. ""]) then
hasTalent = true
break
end
Expand All @@ -6129,7 +6129,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local talentsInUse = DF:GetCharacterPvPTalents (false, true)
local hasTalent
for talentID, _ in pairs (talentsInUse) do
if (loadTable.pvptalent [talentID]) then
if talentID and (loadTable.pvptalent [talentID] or loadTable.pvptalent [talentID .. ""]) then
hasTalent = true
break
end
Expand Down Expand Up @@ -6171,7 +6171,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local level, affixes, wasEnergized = C_ChallengeMode.GetActiveKeystoneInfo()
local hasAffix = false
for _, affixID in ipairs (affixes) do
if (loadTable.affix [affixID]) then
if affixID and (loadTable.affix [affixID] or loadTable.affix [affixID .. ""]) then
hasAffix = true
break
end
Expand Down Expand Up @@ -6285,7 +6285,10 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
f.OnRadioCheckboxClick = function (self, key, value)
--hierarchy: DBKey ["class"] key ["HUNTER"] value TRUE
local DBKey = self:GetParent().DBKey
f.OptionsTable [DBKey] [key] = value and true or nil
f.OptionsTable [DBKey] [key and key .. ""] = value and true or nil
if not value then -- cleanup "number" type values
f.OptionsTable [DBKey] [key] = nil
end
f.OnRadioStateChanged (self:GetParent(), f.OptionsTable [DBKey])
f.RunCallback()
end
Expand Down Expand Up @@ -6316,7 +6319,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = specName,
set = f.OnRadioCheckboxClick,
param = specID,
get = function() return f.OptionsTable.spec [specID] end,
get = function() return f.OptionsTable.spec [specID] or f.OptionsTable.spec [specID..""] end,
texture = specIcon,
})
end
Expand Down Expand Up @@ -6347,7 +6350,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = f.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return f.OptionsTable.talent [talentTable.ID] end,
get = function() return f.OptionsTable.talent [talentTable.ID] or f.OptionsTable.talent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down Expand Up @@ -6445,7 +6448,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = f.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return f.OptionsTable.pvptalent [talentTable.ID] end,
get = function() return f.OptionsTable.pvptalent [talentTable.ID] or f.OptionsTable.pvptalent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down Expand Up @@ -6543,7 +6546,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = groupTable.Name,
set = f.OnRadioCheckboxClick,
param = groupTable.ID,
get = function() return f.OptionsTable.group [groupTable.ID] end,
get = function() return f.OptionsTable.group [groupTable.ID] or f.OptionsTable.group [groupTable.ID .. ""] end,
})
end
local groupTypesGroup = DF:CreateRadionGroup (f, groupTypes, name, {width = 200, height = 200, title = "Group Types"})
Expand All @@ -6558,7 +6561,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = roleTable.Texture .. " " .. roleTable.Name,
set = f.OnRadioCheckboxClick,
param = roleTable.ID,
get = function() return f.OptionsTable.role [roleTable.ID] end,
get = function() return f.OptionsTable.role [roleTable.ID] or f.OptionsTable.role [roleTable.ID .. ""] end,
})
end
local roleTypesGroup = DF:CreateRadionGroup (f, roleTypes, name, {width = 200, height = 200, title = "Role Types"})
Expand All @@ -6575,7 +6578,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = affixName,
set = f.OnRadioCheckboxClick,
param = i,
get = function() return f.OptionsTable.affix [i] end,
get = function() return f.OptionsTable.affix [i] or f.OptionsTable.affix [i .. ""] end,
texture = texture,
})
end
Expand Down Expand Up @@ -6643,7 +6646,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID] end,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID] or DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand All @@ -6657,7 +6660,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID] end,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID] or DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down
53 changes: 44 additions & 9 deletions libs/DF/savedvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ function DF.SavedVars.CreateNewSavedTable(dbTable, savedTableName)
end

function DF.SavedVars.GetOrCreateAddonSavedTablesPlayerList(addonFrame)
local addonGlobalSavedTable = _G[addonFrame.savedVarsName]
local addonGlobalSavedTable = _G[addonFrame.__savedVarsName]

--player list
local playerList = addonGlobalSavedTable.__savedVarsByGUID
if (not playerList) then
addonGlobalSavedTable.__savedVarsByGUID = {}
end

--saved variables table
if (not addonGlobalSavedTable.__savedVars) then
addonGlobalSavedTable.__savedVars = {}
end

return addonGlobalSavedTable.__savedVarsByGUID
end

Expand Down Expand Up @@ -51,23 +58,50 @@ function DF.SavedVars.LoadSavedVarsForPlayer(addonFrame)
savedTable = addonFrame.db:CreateNewSavedTable(playerSavedTableName)
end

addonFrame.db.profile = savedTable
addonFrame.db.currentSavedTableName = playerSavedTableName

DF.SavedVars.SetSavedTable(dbTable, playerSavedTableName, true, true)
return savedTable
end

function DF.SavedVars.TableCleanUpRecursive(t, default)
for key, value in pairs(t) do
if (type(value) == "table") then
DF.SavedVars.TableCleanUpRecursive(value, default[key])
else
if (value == default[key]) then
t[key] = nil
end
end
end
end

function DF.SavedVars.CloseSavedTable(dbTable)
local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName())

local default = dbTable.defaultSavedVars
if (type(currentSavedTable) == "table") then
DF.SavedVars.TableCleanUpRecursive(currentSavedTable, default)

--save
local addonGlobalSavedTable = _G[dbTable.addonFrame.__savedVarsName]
addonGlobalSavedTable.__savedVars[dbTable:GetCurrentSavedTableName()] = currentSavedTable
end
end

--base functions
function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant)
function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant, isFromInit)
local savedTableToBeApplied = dbTable:GetSavedTable(savedTableName)

if (savedTableToBeApplied) then
--callback unload profile table
local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName())
dbTable:TriggerCallback("OnProfileUnload", currentSavedTable)
if (not isFromInit) then
--callback unload profile table
local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName())
dbTable:TriggerCallback("OnProfileUnload", currentSavedTable)
DF.SavedVars.CloseSavedTable(dbTable, currentSavedTable)
end

dbTable.profile = savedTableToBeApplied
dbTable.currentSavedTableName = savedTableName

dbTable:TriggerCallback("OnProfileLoad", savedTableToBeApplied)

else
Expand All @@ -77,10 +111,11 @@ function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant
--callback unload profile table
local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName())
dbTable:TriggerCallback("OnProfileUnload", currentSavedTable)
DF.SavedVars.CloseSavedTable(dbTable, currentSavedTable)

dbTable.profile = newSavedTable
dbTable.currentSavedTableName = savedTableName
dbTable:TriggerCallback("OnProfileLoad", newSavedTable)

else
DF:Msg("profile does not exists", savedTableName)
return
Expand Down
2 changes: 1 addition & 1 deletion libs/DF/slider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ local SwitchOnClick = function (self, button, forced_value, value)

local success, errorText = xpcall (slider.OnSwitch, geterrorhandler(), slider, slider.FixedValue, value)
if (not success) then
error ("Details! Framework: OnSwitch() " .. (button.GetName and button:GetName() or "-NONAME-") .. " error: " .. (errorText or ""))
return
end

--> trigger hooks
Expand Down
Loading

0 comments on commit 778cfba

Please sign in to comment.