local addonName, addon = ...
if not addon.healthCheck then return end
local L = addon.L
-- Updates the total bug count and so forth.
local lastState = nil
local function updateSackDisplay(forceRefresh)
if state ~= lastState then forceRefresh = true end
lastState = state
window:SetFrameStrata("DIALOG")
window:SetWidth(500)
window:SetHeight(310)
window:SetPoint("CENTER")
window:SetMovable(true)
window:EnableMouse(true)
window:RegisterForDrag("LeftButton")
window:SetScript("OnDragStart", window.StartMoving)
window:SetScript("OnDragStop", window.StopMovingOrSizing)
window:SetScript("OnShow", function()
PlaySound(844) -- SOUNDKIT.IG_QUEST_LOG_OPEN
end)
window:SetScript("OnHide", function()
currentErrorObject = nil
currentSackSession = nil
currentSackContents = nil
PlaySound(845) -- SOUNDKIT.IG_QUEST_LOG_CLOSE
end)
local titlebg = window:CreateTexture(nil, "BORDER")
titlebg:SetTexture(251966) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Title-Background"
titlebg:SetPoint("TOPLEFT", 9, -6)
titlebg:SetPoint("BOTTOMRIGHT", window, "TOPRIGHT", -28, -24)
local dialogbg = window:CreateTexture(nil, "BACKGROUND")
dialogbg:SetTexture(136548) --"Interface\\PaperDollInfoFrame\\UI-Character-CharacterTab-L1"
dialogbg:SetPoint("TOPLEFT", 8, -12)
dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
dialogbg:SetTexCoord(0.255, 1, 0.29, 1)
local topleft = window:CreateTexture(nil, "BORDER")
topleft:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
topleft:SetWidth(64)
topleft:SetHeight(64)
topleft:SetPoint("TOPLEFT")
topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
local topright = window:CreateTexture(nil, "BORDER")
topright:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
topright:SetWidth(64)
topright:SetHeight(64)
topright:SetPoint("TOPRIGHT")
topright:SetTexCoord(0.625, 0.75, 0, 1)
local top = window:CreateTexture(nil, "BORDER")
top:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
top:SetHeight(64)
top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
top:SetTexCoord(0.25, 0.369140625, 0, 1)
local bottomleft = window:CreateTexture(nil, "BORDER")
bottomleft:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
bottomleft:SetWidth(64)
bottomleft:SetHeight(64)
bottomleft:SetPoint("BOTTOMLEFT")
bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
local bottomright = window:CreateTexture(nil, "BORDER")
bottomright:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
bottomright:SetWidth(64)
bottomright:SetHeight(64)
bottomright:SetPoint("BOTTOMRIGHT")
bottomright:SetTexCoord(0.875, 1, 0, 1)
local bottom = window:CreateTexture(nil, "BORDER")
bottom:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
bottom:SetHeight(64)
bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
local left = window:CreateTexture(nil, "BORDER")
left:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
left:SetWidth(64)
left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
left:SetTexCoord(0.001953125, 0.125, 0, 1)
local right = window:CreateTexture(nil, "BORDER")
right:SetTexture(251963) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Border"
right:SetWidth(64)
right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
local close = CreateFrame("Button", nil, window, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", 2, 1)
close:SetScript("OnClick", addon.CloseSack)
countLabel = window:CreateFontString(nil, "ARTWORK", "GameFontNormal")
countLabel:SetPoint("TOPRIGHT", titlebg, -6, -3)
countLabel:SetJustifyH("RIGHT")
countLabel:SetTextColor(1, 1, 1, 1)
sessionLabel = CreateFrame("Button", nil, window)
sessionLabel:SetNormalFontObject("GameFontNormalLeft")
sessionLabel:SetHighlightFontObject("GameFontHighlightLeft")
sessionLabel:SetPoint("TOPLEFT", titlebg, 6, -1)
sessionLabel:SetPoint("BOTTOMRIGHT", titlebg, "BOTTOMRIGHT", -26, 1)
sessionLabel:SetScript("OnHide", function()
window:StopMovingOrSizing()
end)
--[[sessionLabel:SetScript("OnMouseUp", function()
window:StopMovingOrSizing()
end)
sessionLabel:SetScript("OnMouseDown", function()
window:StartMoving()
end)]]
sessionLabel:SetScript("OnDoubleClick", function()
sessionLabel:Hide()
searchLabel:Show()
searchBox:Show()
searchThrough = currentSackContents
end)
local quickTips = "|cff44ff44Double-click|r to filter bug reports. After you are done with the search results, return to the full sack by selecting a tab at the bottom. |cff44ff44Left-click|r and drag to move the window. |cff44ff44Right-click|r to close the sack and open the interface options for BugSack."
sessionLabel:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", -8, 8)
GameTooltip:AddLine("Quick tips")
GameTooltip:AddLine(quickTips, 1, 1, 1, 1)
GameTooltip:Show()
end)
sessionLabel:SetScript("OnLeave", function(self)
if GameTooltip:IsOwned(self) then
GameTooltip:Hide()
end
end)
searchLabel = window:CreateFontString(nil, "ARTWORK", "GameFontNormal")
searchLabel:SetText("Filter:")
searchLabel:SetJustifyH("LEFT")
searchLabel:SetPoint("TOPLEFT", titlebg, 6, -3)
searchLabel:SetTextColor(1, 1, 1, 1)
searchLabel:Hide()
searchBox = CreateFrame("EditBox", nil, window)
searchBox:SetTextInsets(4, 4, 0, 0)
searchBox:SetMaxLetters(50)
searchBox:SetFontObject("ChatFontNormal")
searchBox:SetBackdrop({
edgeFile = nil,
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
insets = { left = 0, right = 0, top = 0, bottom = 0 },
tile = true,
tileSize = 16,
edgeSize = 0,
})
searchBox:SetBackdropColor(0, 0, 0, 0.5)
searchBox:SetScript("OnShow", function(self)
self:SetFocus()
end)
searchBox:SetScript("OnHide", function(self)
self:ClearFocus()
self:SetText("")
end)
searchBox:SetScript("OnEscapePressed", clearSearch)
searchBox:SetScript("OnTextChanged", filterSack)
searchBox:SetAutoFocus(false)
searchBox:SetPoint("TOPLEFT", searchLabel, "TOPRIGHT", 6, 1)
searchBox:SetPoint("BOTTOMRIGHT", titlebg, "BOTTOMRIGHT", -26, 1)
searchBox:Hide()
nextButton = CreateFrame("Button", "BugSackNextButton", window, "UIPanelButtonTemplate")
nextButton:SetPoint("BOTTOMRIGHT", window, -11, 16)
nextButton:SetFrameStrata("FULLSCREEN")
nextButton:SetWidth(130)
nextButton:SetText(L["Next >"])
nextButton:SetScript("OnClick", function()
if IsShiftKeyDown() then
currentErrorIndex = #currentSackContents
else
currentErrorIndex = currentErrorIndex + 1
end
updateSackDisplay()
end)
prevButton = CreateFrame("Button", "BugSackPrevButton", window, "UIPanelButtonTemplate")
prevButton:SetPoint("BOTTOMLEFT", window, 14, 16)
prevButton:SetFrameStrata("FULLSCREEN")
prevButton:SetWidth(130)
prevButton:SetText(L["< Previous"])
prevButton:SetScript("OnClick", function()
if IsShiftKeyDown() then
currentErrorIndex = 1
else
currentErrorIndex = currentErrorIndex - 1
end
updateSackDisplay()
end)
if addon.Serialize then
sendButton = CreateFrame("Button", "BugSackSendButton", window, "UIPanelButtonTemplate")
sendButton:SetPoint("LEFT", prevButton, "RIGHT")
sendButton:SetPoint("RIGHT", nextButton, "LEFT")
sendButton:SetFrameStrata("FULLSCREEN")
sendButton:SetText(L["Send bugs"])
sendButton:SetScript("OnClick", function()
local eo = currentSackContents[currentErrorIndex]
local popup = StaticPopup_Show("BugSackSendBugs", eo.session)
popup.data = eo.session
window:Hide()
end)
end
local scroll = CreateFrame("ScrollFrame", "BugSackScroll", window, "UIPanelScrollFrameTemplate")
scroll:SetPoint("TOPLEFT", window, "TOPLEFT", 16, -36)
scroll:SetPoint("BOTTOMRIGHT", nextButton, "TOPRIGHT", -24, 8)
textArea = CreateFrame("EditBox", "BugSackScrollText", scroll)
textArea:SetTextColor(.5, .5, .5, 1)
textArea:SetAutoFocus(false)
textArea:SetMultiLine(true)
textArea:SetFontObject(_G[addon.db.fontSize] or GameFontHighlightSmall)
textArea:SetMaxLetters(99999)
textArea:EnableMouse(true)
textArea:SetScript("OnEscapePressed", textArea.ClearFocus)
textArea:SetWidth(450)
scroll:SetScrollChild(textArea)
local all = CreateFrame("Button", "BugSackTabAll", window, "CharacterFrameTabButtonTemplate")
all:SetFrameStrata("FULLSCREEN")
all:SetPoint("TOPLEFT", window, "BOTTOMLEFT", 0, 8)
all:SetText(L["All bugs"])
all:SetScript("OnLoad", nil)
all:SetScript("OnShow", nil)
all:SetScript("OnClick", setActiveMethod)
all.bugs = "all"
local session = CreateFrame("Button", "BugSackTabSession", window, "CharacterFrameTabButtonTemplate")
session:SetFrameStrata("FULLSCREEN")
session:SetPoint("LEFT", all, "RIGHT")
session:SetText(L["Current session"])
session:SetScript("OnLoad", nil)
session:SetScript("OnShow", nil)
session:SetScript("OnClick", setActiveMethod)
session.bugs = "currentSession"
local last = CreateFrame("Button", "BugSackTabLast", window, "CharacterFrameTabButtonTemplate")
last:SetFrameStrata("FULLSCREEN")
last:SetPoint("LEFT", session, "RIGHT")
last:SetText(L["Previous session"])
last:SetScript("OnLoad", nil)
last:SetScript("OnShow", nil)
last:SetScript("OnClick", setActiveMethod)
last.bugs = "previousSession"
tabs = {all, session, last}
local size = 500 / 3
for i, t in next, tabs do
PanelTemplates_TabResize(t, nil, size, size)
if i == 1 then
PanelTemplates_SelectTab(t)
else
PanelTemplates_DeselectTab(t)
end
end