Skip to content

Commit

Permalink
Removed LibToast
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Oct 16, 2020
1 parent abbf526 commit b335b09
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 96 deletions.
4 changes: 0 additions & 4 deletions .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ externals:
ignore:
- README.md
- .luacheckrc
- Libs/LibToast-1.0/LibStub
- Libs/LibToast-1.0/LibToast-1.0.toc
- Libs/LibToast-1.0/lib.xml
- Libs/LibToast-1.0/LibStub
- Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
- Libs/LibBabble-Race-3.0/LibBabble-Race-3.0.toc
- Libs/LibBabble-Race-3.0/lib.xml
Expand Down
1 change: 0 additions & 1 deletion Embeds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Script file="Libs\LibScrollingTable\Core.lua"/>
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
<Script file="Libs\LibToast-1.0\LibToast-1.0.lua"/>
<Script file="Libs\LibQTip-1.0\LibQTip-1.0.lua"/>
<Script file="Libs\LibBabble-Race-3.0\LibBabble-3.0.lua"/>
<Script file="Libs\LibBabble-Race-3.0\LibBabble-Race-3.0.lua"/>
Expand Down
2 changes: 0 additions & 2 deletions Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ L["Prev. season"] = true
L["Current session"] = true

L["Hide minimap button"] = true
L["Enable battleground summary"] = true
L["Display toast with battleground summary after completed match."] = true
L["Display server names"] = true
L["LDB feed display mode"] = true
L["Rating display always compares the values with the previous week."] = true
Expand Down
55 changes: 18 additions & 37 deletions REFlex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local ST = LibStub("ScrollingTable")
local GUI = LibStub("AceGUI-3.0")
local LDB = LibStub("LibDataBroker-1.1")
local LDBI = LibStub("LibDBIcon-1.0")
local TOAST = LibStub("LibToast-1.0")
local QTIP = LibStub("LibQTip-1.0")
local DUMP = LibStub("LibTextDump-1.0")
_G.REFlex = RE
Expand Down Expand Up @@ -59,6 +58,7 @@ local AbbreviateNumbers = _G.AbbreviateNumbers
local UIParentLoadAddOn = _G.UIParentLoadAddOn
local RegisterAddonMessagePrefix = _G.C_ChatInfo.RegisterAddonMessagePrefix
local SendAddonMessage = _G.C_ChatInfo.SendAddonMessage
local PlaySound = _G.PlaySound
local ElvUI = _G.ElvUI

RE.Version = 300
Expand Down Expand Up @@ -200,6 +200,13 @@ function RE:OnLoad(self)
RE.DateDropDown:SetList({[1] = _G.ALL, [2] = _G.HONOR_TODAY, [3] = _G.HONOR_YESTERDAY, [4] = _G.GUILD_CHALLENGES_THIS_WEEK, [5] = L["This month"], [6] = L["This season"], [7] = L["Prev. season"], [8] = _G.CUSTOM})
end

function RE:OnHide(_)
if RE.Tooltip and RE.Tooltip:IsVisible() then
QTIP:Release(RE.Tooltip)
end
PlaySound(_G.SOUNDKIT.IG_CHARACTER_INFO_CLOSE)
end

function RE:OnEvent(_, event, ...)
if event == "ADDON_LOADED" and ... == "REFlex" then
if not _G.REFlexSettings then
Expand Down Expand Up @@ -235,36 +242,6 @@ function RE:OnEvent(_, event, ...)
end
end

TOAST:Register("REFlexToast", function(toast, ...)
toast:SetFormattedTitle("|cFF74D06CRE|r|cFFFFFFFFFlex|r")
toast:SetFormattedText(...)
toast:SetIconTexture([[Interface\PvPRankBadges\PvPRank09]])
toast:MakePersistent()
if RE.PlayerFaction == 0 then
toast:SetSoundFile(565853)
toast:SetPrimaryCallback(_G.HORDE_CHEER, RE.CloseToast)
else
toast:SetSoundFile(566564)
toast:SetPrimaryCallback(_G.ALLIANCE_CHEER, RE.CloseToast)
end
end)
TOAST:Register("REFlexToastArena", function(toast, title, payload)
toast:SetFormattedTitle(title)
toast:SetFormattedText(payload)
toast:SetIconTexture([[Interface\PvPRankBadges\PvPRank09]])
toast:MakePersistent()
if RE.PlayerFaction == 0 then
toast:SetPrimaryCallback(_G.HORDE_CHEER, RE.CloseToast)
else
toast:SetPrimaryCallback(_G.ALLIANCE_CHEER, RE.CloseToast)
end
end)
TOAST:Register("REFlexToastInfo", function(toast, ...)
toast:SetFormattedTitle("|cFF74D06CRE|r|cFFFFFFFFFlex|r")
toast:SetFormattedText(...)
toast:SetIconTexture([[Interface\PvPRankBadges\PvPRank09]])
end)

RE.LDB = LDB:NewDataObject("REFlex", {
type = "data source",
text = "|cFF74D06CRE|rFlex",
Expand Down Expand Up @@ -388,7 +365,7 @@ function RE:OnEvent(_, event, ...)
local messageEx = {strsplit(";", message)}
if messageEx[1] == "Version" then
if not RE.FoundNewVersion and tonumber(messageEx[2]) > RE.Version then
TOAST:Spawn("REFlexToastInfo", L["New version released!"])
print("\124cFF74D06C[REFlex]\124r "..L["New version released!"])
RE.FoundNewVersion = true
end
end
Expand All @@ -408,6 +385,7 @@ function RE:OnEvent(_, event, ...)
if IsInGuild() then
SendAddonMessage("REFlex", "Version;"..RE.Version, "GUILD")
end
_G.REFlexBGFrameText:SetText("")
end
elseif event == "PVP_MATCH_COMPLETE" and not RE.DataSaved then
RE.DataSaved = true
Expand Down Expand Up @@ -610,8 +588,12 @@ function RE:OnBracketChange(_, bracket)
end

function RE:OnArenaStatsClick(self)
_G.CloseDropDownMenus()
_G.EasyMenu(RE.StatsDropDown, _G.REFlexStatsDropDown, self, 0 , 0, "MENU")
if RE.Tooltip and RE.Tooltip:IsVisible() then
QTIP:Release(RE.Tooltip)
else
_G.CloseDropDownMenus()
_G.EasyMenu(RE.StatsDropDown, _G.REFlexStatsDropDown, self, 0 , 0, "MENU")
end
end

function RE:OnDateChange(_, mode)
Expand Down Expand Up @@ -935,11 +917,10 @@ function RE:PVPEnd()
if not RE.MatchData.Hidden then
if RE.MatchData.isArena then
RE:UpdateArenaData(false)
_G.REFlexBGFrameText:SetText("")
else
RE:UpdateBGData(false)
if RE.Settings.Toasts then
TOAST:Spawn("REFlexToast", RE:GetBGToast(#RE.Database))
end
_G.REFlexBGFrameText:SetText(RE:GetBGScoreText(#RE.Database))
end
else
print("\124cFF74D06C[REFlex]\124r "..L["API returned corrupted data. Match will not be recorded."])
Expand Down
20 changes: 19 additions & 1 deletion REFlex.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<OnLoad inherit="prepend">REFlex:OnLoad(self)</OnLoad>
<OnEvent>REFlex:OnEvent(self, event, ...)</OnEvent>
<OnShow>PlaySound(SOUNDKIT.IG_CHARACTER_INFO_OPEN); REFlex:UpdateGUI()</OnShow>
<OnHide>PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE)</OnHide>
<OnHide>REFlex:OnHide(self)</OnHide>
<OnDragStart>self:StartMoving()</OnDragStart>
<OnDragStop>self:StopMovingOrSizing()</OnDragStop>
</Scripts>
Expand Down Expand Up @@ -371,4 +371,22 @@
</Frames>
</Frame>

<Frame name="REFlexBGFrame" frameStrata="DIALOG" toplevel="true" parent="PVPMatchScoreboard">
<Size>
<AbsDimension x="5" y="5"/>
</Size>
<Anchors>
<Anchor point="TOP">
<Offset>
<AbsDimension x="0" y="-25"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer>
<FontString name="$ParentText" justifyH="CENTER" inherits="SystemFont_Shadow_Med1"/>
</Layer>
</Layers>
</Frame>

</Ui>
62 changes: 29 additions & 33 deletions REFlexFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ local _G = _G
local _, RE = ...
local L = LibStub("AceLocale-3.0"):GetLocale("REFlex")
local BR = LibStub("LibBabble-Race-3.0"):GetReverseLookupTable()
local DUMP = LibStub("LibTextDump-1.0")
local TOAST = LibStub("LibToast-1.0")
local ST = LibStub("ScrollingTable")
local QTIP = LibStub("LibQTip-1.0")
local DUMP = LibStub("LibTextDump-1.0")

local tinsert, tsort, tconcat, tremove = _G.table.insert, _G.table.sort, _G.table.concat, _G.table.remove
local mfloor = _G.math.floor
Expand Down Expand Up @@ -314,52 +314,52 @@ function RE:GetMercenaryStatus(databaseID)
return not (RE.Database[databaseID].PlayerSide == RE.PlayerFaction)
end

function RE:GetBGToast(databaseID)
local toast = {}
function RE:GetBGScoreText(databaseID)
local text = {}
local savedFilters = RE.Settings.Filters
RE.Settings.Filters = {["Spec"] = _G.ALL, ["Map"] = RE.Database[databaseID].Map, ["Bracket"] = 1, ["Date"] = {0, 0}, ["Season"] = 0}
local playerData = RE:GetPlayerData(databaseID)
local placeKB, placeHK, placeHonor, placeDamage, placeHealing = unpack(RE.Database[databaseID].BGPlace[2])
local _, topKB, _, topHK, _, topHonor, _, topDamage, _, topHealing = RE:GetStats(1, false, true)
RE.Settings.Filters = savedFilters
tinsert(toast, RE:InsideToast("KB", playerData[2], databaseID, placeKB, topKB))
tinsert(toast, RE:InsideToast("HK", playerData[3], databaseID, placeHK, topHK))
tinsert(toast, RE:InsideToast(_G.HONOR, playerData[5], databaseID, placeHonor, topHonor))
tinsert(toast, RE:InsideToast(_G.DAMAGE, playerData[10], databaseID, placeDamage, topDamage))
tinsert(toast, RE:InsideToast(_G.SHOW_COMBAT_HEALING, playerData[11], databaseID, placeHealing, topHealing))
return tconcat(toast, "")
tinsert(text, RE:ScoreTextParser("KB", playerData[2], databaseID, placeKB, topKB))
tinsert(text, RE:ScoreTextParser("HK", playerData[3], databaseID, placeHK, topHK))
tinsert(text, RE:ScoreTextParser(_G.HONOR, playerData[5], databaseID, placeHonor, topHonor))
tinsert(text, RE:ScoreTextParser(_G.DAMAGE, playerData[10], databaseID, placeDamage, topDamage))
tinsert(text, RE:ScoreTextParser(_G.SHOW_COMBAT_HEALING, playerData[11], databaseID, placeHealing, topHealing))
return tconcat(text, " |cFF808080|||r ")
end

function RE:GetArenaToast(mode)
function RE:GetArenaStatsTooltip(mode)
if #RE.TableArena.filtered > 0 then
local payload = RE:GetArenaTeamStats(mode)
local title = "|cFF74D06CRE|r|cFFFFFFFFFlex|r"
local toast = {}
RE.Tooltip = QTIP:Acquire("REFlexTooltipArena", 1, "CENTER")
RE.Tooltip:SmartAnchorTo(_G.REFlexFrame_StatsButton)
if mode == 1 then
title = title.." "..L["Most common teams"]
RE.Tooltip:AddHeader("|cFF74D06C"..L["Most common teams"].."|r")
elseif mode == 2 then
title = title.." "..L["Easiest teams"]
RE.Tooltip:AddHeader("|cFF74D06C"..L["Easiest teams"].."|r")
else
title = title.." "..L["Hardest teams"]
RE.Tooltip:AddHeader("|cFF74D06C"..L["Hardest teams"].."|r")
end
RE.Tooltip:AddLine()
RE.Tooltip:AddLine()
for _, v in pairs(payload) do
local members = {strsplit(";", v[1])}
for i=1, #members do
local class, spec = strsplit("-", members[i])
tinsert(toast, "|c".._G.RAID_CLASS_COLORS[class]:GenerateHexColor().._G.LOCALIZED_CLASS_NAMES_MALE[class].." "..spec.."|r|n")
RE.Tooltip:AddLine("|c".._G.RAID_CLASS_COLORS[class]:GenerateHexColor().._G.LOCALIZED_CLASS_NAMES_MALE[class].." "..spec.."|r")
end
if mode == 1 then
tinsert(toast, "|cFFFFFFFF"..v[2].."|r | |cFF00FF00"..v[3].."|r - |cFFFF0000"..v[4].."|r|n|n")
RE.Tooltip:AddLine("|cFFFFFFFF"..v[2].."|r | |cFF00FF00"..v[3].."|r - |cFFFF0000"..v[4].."|r")
elseif mode == 2 then
tinsert(toast, "|cFF00FF00"..v[3].."|r - |cFFFF0000"..v[4].."|r | |cFFFFFFFF"..v[2].."|n|n")
RE.Tooltip:AddLine("|cFF00FF00"..v[3].."|r - |cFFFF0000"..v[4].."|r | |cFFFFFFFF"..v[2])
else
tinsert(toast, "|cFFFF0000"..v[4].."|r - |cFF00FF00"..v[3].."|r | |cFFFFFFFF"..v[2].."|n|n")
RE.Tooltip:AddLine("|cFFFF0000"..v[4].."|r - |cFF00FF00"..v[3].."|r | |cFFFFFFFF"..v[2])
end
RE.Tooltip:AddLine()
end
if #toast > 1 then
toast[#toast] = toast[#toast]:gsub("|n|n", "")
TOAST:Spawn("REFlexToastArena", title, tconcat(toast, ""))
end
RE.Tooltip:Show()
end
end

Expand Down Expand Up @@ -653,17 +653,13 @@ function RE:HKBarUpdate()
_G.REFlexFrame_HKBar_I:SetValue(hk)
end

function RE:InsideToast(label, value, databaseID, place, top)
local toast = {}
tinsert(toast, "|cFFC5F3BC"..label..":|r |cFFFFFFFF"..RE:AbbreviateNumbers(value).." - "..place.."/"..RE.Database[databaseID].PlayersNum.."|r")
function RE:ScoreTextParser(label, value, databaseID, place, top)
local text = {}
tinsert(text, "|cFF90EE90"..label..":|r |cFFFFFFFF"..RE:AbbreviateNumbers(value).." - "..place.."/"..RE.Database[databaseID].PlayersNum.."|r")
if value > top then
tinsert(toast, " |cFFFFFFFF-|r |TInterface\\GroupFrame\\UI-Group-LeaderIcon:14:14:0:0|t")
tinsert(text, " |TInterface\\GroupFrame\\UI-Group-LeaderIcon:14:14:0:0|t")
end
tinsert(toast, "|n")
return tconcat(toast, "")
end

function RE:CloseToast()
return tconcat(text, "")
end

function RE:HideEntry(databaseID)
Expand Down
26 changes: 8 additions & 18 deletions REFlexStructures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ local ReloadUI = _G.ReloadUI

RE.DefaultConfig = {
["MiniMapButtonSettings"] = {["hide"] = false},
["Toasts"] = true,
["ShowServerName"] = false,
["CurrentTab"] = 1,
["Filters"] = {["Spec"] = _G.ALL, ["Map"] = 1, ["Bracket"] = 1, ["Date"] = {0, 0}, ["Season"] = 0, ["DateMode"] = 1},
Expand Down Expand Up @@ -183,9 +182,9 @@ for classID=1, _G.MAX_CLASSES do
end

RE.StatsDropDown = {
{ text = L["Most common teams"], notCheckable = true, func = function() RE:GetArenaToast(1) end },
{ text = L["Easiest teams"], notCheckable = true, func = function() RE:GetArenaToast(2) end },
{ text = L["Hardest teams"], notCheckable = true, func = function() RE:GetArenaToast(3) end }
{ text = L["Most common teams"], notCheckable = true, func = function() RE:GetArenaStatsTooltip(1) end },
{ text = L["Easiest teams"], notCheckable = true, func = function() RE:GetArenaStatsTooltip(2) end },
{ text = L["Hardest teams"], notCheckable = true, func = function() RE:GetArenaStatsTooltip(3) end }
}

RE.AceConfig = {
Expand All @@ -199,21 +198,12 @@ RE.AceConfig = {
set = function(_, val) RE.Settings.MiniMapButtonSettings.hide = val; RE:UpdateConfig() end,
get = function(_) return RE.Settings.MiniMapButtonSettings.hide end
},
toasts = {
name = L["Enable battleground summary"],
desc = L["Display toast with battleground summary after completed match."],
type = "toggle",
width = "full",
order = 2,
set = function(_, val) RE.Settings.Toasts = val end,
get = function(_) return RE.Settings.Toasts end
},
servername = {
name = L["Display server names"],
desc = L["Show player server name in match detail tooltip."],
type = "toggle",
width = "full",
order = 3,
order = 2,
set = function(_, val) RE.Settings.ShowServerName = val end,
get = function(_) return RE.Settings.ShowServerName end
},
Expand All @@ -222,7 +212,7 @@ RE.AceConfig = {
desc = L["A minimal number of matches required to be included in arena team composition statistics."],
type = "range",
width = "double",
order = 4,
order = 3,
min = 1,
max = 10,
step = 1,
Expand All @@ -234,7 +224,7 @@ RE.AceConfig = {
desc = L["Rating display always compares the values with the previous week."],
type = "select",
width = "double",
order = 5,
order = 4,
values = {
[1] = L["Current session"],
[2] = _G.HONOR_TODAY,
Expand All @@ -249,7 +239,7 @@ RE.AceConfig = {
type = "execute",
width = "double",
confirm = true,
order = 6,
order = 5,
func = function() _G.REFlexDatabase = {}; _G.REFlexHonorDatabase = {}; ReloadUI() end
},
deleteoldseason = {
Expand All @@ -258,7 +248,7 @@ RE.AceConfig = {
type = "execute",
width = "double",
confirm = true,
order = 7,
order = 6,
func = function() RE:SeasonPurge(); ReloadUI() end
}
}
Expand Down

0 comments on commit b335b09

Please sign in to comment.