You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

969 lines
34 KiB

4 years ago
3 years ago
local Loc = LibStub("AceLocale-3.0"):GetLocale("Details")
4 years ago
local Details = _G.Details
3 years ago
local gump = Details.gump
local _
4 years ago
3 years ago
--details API functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
3 years ago
function Details:FastReportWindow(window)
4 years ago
if (not DetailsReportWindow) then
gump:CriaJanelaReport()
DetailsReportWindow:Hide()
end
3 years ago
local instance = Details:GetInstance(window)
4 years ago
if (instance) then
if (instance.atributo == 1) then
3 years ago
Details.report_lines = 14
4 years ago
elseif (instance.atributo == 2) then
3 years ago
Details.report_lines = 6
4 years ago
else
3 years ago
Details.report_lines = max(10, instance.rows_fit_in_window)
4 years ago
end
3 years ago
4 years ago
if (IsInRaid()) then
3 years ago
Details.report_where = "RAID"
4 years ago
elseif (GetNumSubgroupMembers() > 0) then
3 years ago
Details.report_where = "PARTY"
4 years ago
else
3 years ago
Details.report_where = "SAY"
4 years ago
end
3 years ago
4 years ago
instance:monta_relatorio()
else
3 years ago
Details:Msg(Loc ["STRING_WINDOW_NOTFOUND"])
4 years ago
end
end
3 years ago
function Details.ReportFromLatest(_, _, index)
local reportTable = Details.latest_report_table[index]
if (reportTable) then
4 years ago
if (not DetailsReportWindow) then
gump:CriaJanelaReport()
DetailsReportWindow:Hide()
end
3 years ago
local id, attribute, subattribute, amt, report_where = unpack(reportTable)
local instance = Details:GetInstance(id)
Details.report_lines = amt
Details.report_where = report_where
4 years ago
local cattribute, csubattribute = instance:GetDisplay()
3 years ago
instance:SetDisplay(nil, attribute, subattribute)
4 years ago
instance:monta_relatorio()
3 years ago
instance:SetDisplay(nil, cattribute, csubattribute)
4 years ago
GameCooltip:Hide()
end
end
3 years ago
function Details:SendReportLines(lines)
if (type(lines) == "string") then
4 years ago
lines = {lines}
end
3 years ago
return Details:envia_relatorio(lines, true)
4 years ago
end
3 years ago
function Details:SendReportWindow(func, current, inverse, slider)
if (type(func) ~= "function") then
return
4 years ago
end
3 years ago
if (not Details.janela_report) then
Details.janela_report = gump:CriaJanelaReport()
4 years ago
end
3 years ago
if (current) then
_G["Details_Report_CB_1"]:Enable()
_G["Details_Report_CB_1Text"]:SetTextColor(1, 1, 1, 1)
4 years ago
else
3 years ago
_G["Details_Report_CB_1"]:Disable()
_G["Details_Report_CB_1Text"]:SetTextColor(.5, .5, .5, 1)
4 years ago
end
3 years ago
if (inverse) then
_G["Details_Report_CB_2"]:Enable()
_G["Details_Report_CB_2Text"]:SetTextColor(1, 1, 1, 1)
4 years ago
else
3 years ago
_G["Details_Report_CB_2"]:Disable()
_G["Details_Report_CB_2Text"]:SetTextColor(.5, .5, .5, 1)
4 years ago
end
3 years ago
if (slider) then
Details.janela_report.slider:Enable()
Details.janela_report.slider.lockTexture:Hide()
Details.janela_report.slider.amt:Show()
4 years ago
else
3 years ago
Details.janela_report.slider:Disable()
Details.janela_report.slider.lockTexture:Show()
Details.janela_report.slider.amt:Hide()
4 years ago
end
3 years ago
if (Details.janela_report.ativa) then
Details.janela_report:Flash(0.2, 0.2, 0.4, true, 0, 0, "NONE")
4 years ago
end
3 years ago
Details.janela_report.ativa = true
Details.janela_report.enviar:SetScript("OnClick", function() func(_G["Details_Report_CB_1"]:GetChecked(), _G["Details_Report_CB_2"]:GetChecked(), Details.report_lines) end)
Details.FadeHandler.Fader(Details.janela_report, 0)
4 years ago
return true
end
3 years ago
function Details:SendReportTextWindow(lines)
if (not Details.copypasteframe) then
Details.copypasteframe = CreateFrame("frame", "DetailsCopyPasteFrame2", UIParent, "BackdropTemplate")
Details.copypasteframe:SetFrameStrata("TOOLTIP")
Details.copypasteframe:SetPoint("CENTER", UIParent, "CENTER", 0, 50)
table.insert(UISpecialFrames, "DetailsCopyPasteFrame2")
3 years ago
Details.copypasteframe:SetSize(400, 400)
Details.copypasteframe:Hide()
DetailsFramework:ApplyStandardBackdrop(Details.copypasteframe)
DetailsFramework:CreateTitleBar(Details.copypasteframe, "Export Text")
local editBox = CreateFrame("editbox", nil, Details.copypasteframe)
editBox:SetPoint("topleft", Details.copypasteframe, "topleft", 2, -26)
editBox:SetPoint("bottomright", Details.copypasteframe, "bottomright", -2, 2)
editBox:SetAutoFocus(false)
editBox:SetMultiLine(true)
editBox:SetFontObject("GameFontHighlightSmall")
editBox:SetScript("OnEditFocusGained", function() editBox:HighlightText() end)
editBox:SetScript("OnEditFocusLost", function() Details.copypasteframe:Hide() end)
editBox:SetScript("OnEscapePressed", function() editBox:SetFocus(false); Details.copypasteframe:Hide() end)
editBox:SetScript("OnChar", function() editBox:SetFocus(false); Details.copypasteframe:Hide() end)
Details.copypasteframe.EditBox = editBox
4 years ago
end
3 years ago
local reportString = ""
for _, line in ipairs(lines) do
reportString = reportString .. line .. "\n"
end
4 years ago
3 years ago
Details.copypasteframe:Show()
Details.copypasteframe.EditBox:SetText(reportString)
Details.copypasteframe.EditBox:HighlightText()
Details.copypasteframe.EditBox:SetFocus(true)
end
4 years ago
3 years ago
--internal details report functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function Details:Reportar(param2, options, arg3, id)
4 years ago
GameCooltip2:Hide()
3 years ago
if (not Details.janela_report) then
Details.janela_report = gump:CriaJanelaReport()
4 years ago
end
3 years ago
4 years ago
if (options and options.meu_id) then
self = options
end
3 years ago
if (type(param2) == "string") then
4 years ago
id = param2
end
3 years ago
if (Details.last_report_id and id and Details.last_report_id == id) then
Details.last_report_id = nil
Details.janela_report.fechar:Click()
4 years ago
return
end
3 years ago
Details.last_report_id = id
4 years ago
if (options and options._no_current) then
3 years ago
_G["Details_Report_CB_1"]:Disable()
_G["Details_Report_CB_1Text"]:SetTextColor(.5, .5, .5, 1)
4 years ago
else
3 years ago
_G["Details_Report_CB_1"]:Enable()
_G["Details_Report_CB_1Text"]:SetTextColor(1, 1, 1, 1)
4 years ago
end
3 years ago
4 years ago
if (options and options._no_inverse) then
3 years ago
_G["Details_Report_CB_2"]:Disable()
_G["Details_Report_CB_2Text"]:SetTextColor(.5, .5, .5, 1)
4 years ago
else
3 years ago
_G["Details_Report_CB_2"]:Enable()
_G["Details_Report_CB_2Text"]:SetTextColor(1, 1, 1, 1)
4 years ago
end
3 years ago
Details.janela_report.slider:Enable()
Details.janela_report.slider.lockTexture:Hide()
Details.janela_report.slider.amt:Show()
4 years ago
if (options) then
local bIsCustom = true
Details.janela_report.enviar:SetScript("OnClick", function() self:monta_relatorio(param2, bIsCustom) end)
4 years ago
else
3 years ago
Details.janela_report.enviar:SetScript("OnClick", function() self:monta_relatorio(param2) end)
4 years ago
end
3 years ago
if (Details.janela_report.ativa) then
Details.janela_report:Flash(0.2, 0.2, 0.4, true, 0, 0, "NONE")
4 years ago
end
3 years ago
Details.janela_report.ativa = true
Details.FadeHandler.Fader(Details.janela_report, 0)
4 years ago
end
3 years ago
--build report frame gump -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--script
local savepos = function(self)
local xofs, yofs = self:GetCenter()
4 years ago
local scale = self:GetEffectiveScale()
local UIscale = UIParent:GetScale()
xofs = xofs * scale - GetScreenWidth() * UIscale / 2
yofs = yofs * scale - GetScreenHeight() * UIscale / 2
local x = xofs / UIscale
local y = yofs / UIscale
3 years ago
Details.report_pos[1] = x
Details.report_pos[2] = y
4 years ago
end
3 years ago
local restorepos = function(self)
local x, y = Details.report_pos[1], Details.report_pos[2]
local scale = self:GetEffectiveScale()
4 years ago
local UIscale = UIParent:GetScale()
x = x * UIscale / scale
y = y * UIscale / scale
self:ClearAllPoints()
3 years ago
self:SetPoint("center", UIParent, "center", x, y)
4 years ago
end
3 years ago
local function setScripts(este_gump)
--Janela
este_gump:SetScript("OnMouseDown", function(self, botao)
if (botao == "LeftButton") then
self:StartMoving()
self.isMoving = true
elseif (botao == "RightButton") then
if (self.isMoving) then
self:StopMovingOrSizing()
savepos(self)
self.isMoving = false
end
self:Hide()
end
end)
este_gump:SetScript("OnMouseUp", function(self)
if (self.isMoving) then
self:StopMovingOrSizing()
savepos (self)
self.isMoving = false
end
end)
4 years ago
end
3 years ago
local iconsAndColors = {
4 years ago
["PARTY"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {0.66, 0.65, 1}},
["RAID"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {1, 0.49, 0}},
["GUILD"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.98, 0.25}},
["OFFICER"] = {label = Loc ["STRING_REPORTFRAME_OFFICERS"], icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.74, 0.25}},
["WHISPER"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}},
["SAY"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0390625, 0.203125, 0.09375, 0.375}, color = {1, 1, 1}},
["COPY"] = {icon = [[Interface\Buttons\UI-GuildButton-PublicNote-Disabled]], coords = {0, 1, 0, 1}, color = {1, 1, 1}},
}
3 years ago
function Details.GetReportIconAndColor(reportWhere)
local key = reportWhere:gsub((".*|"), "")
return iconsAndColors[key]
end
4 years ago
3 years ago
local createDropdown = function(thisFrame)
4 years ago
local iconsize = {16, 16}
local baseChannels = {
{Loc ["STRING_REPORTFRAME_PARTY"], "PARTY", function() return GetNumSubgroupMembers() > 0 end, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {0.66, 0.65, 1}}},
3 years ago
{Loc ["STRING_REPORTFRAME_RAID"], "RAID", IsInRaid, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {1, 0.49, 0}}},
{Loc ["STRING_REPORTFRAME_GUILD"], "GUILD", IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.98, 0.25}}},
{Loc ["STRING_REPORTFRAME_OFFICERS"], "OFFICER", IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.74, 0.25}}},
4 years ago
{Loc ["STRING_REPORTFRAME_WHISPER"], "WHISPER", nil, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}}},
3 years ago
{Loc ["STRING_REPORTFRAME_WHISPERTARGET"], "WHISPER2", nil, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}}},
4 years ago
{Loc ["STRING_REPORTFRAME_SAY"], "SAY", IsInInstance, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0390625, 0.203125, 0.09375, 0.375}, color = {1, 1, 1}}},
{Loc ["STRING_REPORTFRAME_COPY"], "COPY", nil, {iconsize = iconsize, icon = [[Interface\Buttons\UI-GuildButton-PublicNote-Disabled]], coords = {0, 1, 0, 1}, color = {1, 1, 1}}},
}
3 years ago
local onClick = function(self, fixedParam, selectedOutput)
Details.report_where = selectedOutput
end
4 years ago
3 years ago
local buildList = function()
local reportChannelsTable = {}
for index, channelInfo in ipairs(baseChannels) do
if (not channelInfo[3] or channelInfo[3]()) then
reportChannelsTable[#reportChannelsTable + 1] = {iconsize = channelInfo[4].iconsize, value = channelInfo[2], label = channelInfo[1], onclick = onClick, icon = channelInfo[4].icon, texcoord = channelInfo[4].coords, iconcolor = channelInfo[4].color}
4 years ago
end
3 years ago
end
local channels = {GetChannelList()} --coloca o resultado em uma tabela .. {id1, canal1, id2, canal2}
--09/august/2018: GetChannelList passed to return 3 values for each channel instead of 2
for i = 1, #channels, 3 do --total de canais
reportChannelsTable[#reportChannelsTable + 1] = {iconsize = iconsize, value = "CHANNEL|" .. channels[i+1], label = channels[i] .. ". " .. channels[i+1], onclick = onClick, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], texcoord = {0.3046875, 0.4453125, 0.109375, 0.390625}, iconcolor = {149/255, 112/255, 112/255}}
end
if (not DetailsFramework.IsTimewalkWoW()) then
local _, numBNetOnline = BNGetNumFriends()
for i = 1, numBNetOnline do
local accountInfo = C_BattleNet.GetFriendAccountInfo(i)
local gameAccountInfo = accountInfo and accountInfo.gameAccountInfo
if (gameAccountInfo) then
local isOnline = gameAccountInfo.isOnline
if (isOnline) then
local bTag = accountInfo.battleTag
local bTagNoNumber = bTag:gsub("#.*", "")
reportChannelsTable[#reportChannelsTable + 1] = {iconsize = iconsize, value = "REALID|" .. accountInfo.bnetAccountID, label = bTagNoNumber, onclick = onClick, icon = [[Interface\FriendsFrame\Battlenet-Battleneticon]], texcoord = {0.125, 0.875, 0.125, 0.875}, iconcolor = {1, 1, 1}}
4 years ago
end
end
end
end
3 years ago
return reportChannelsTable
end
thisFrame.dropdown_func = buildList
local selectOutputChannel = gump:NewDropDown(thisFrame, _, "$parentOutputDropdown", "select", 185, 20, buildList, 1)
selectOutputChannel:SetPoint("topleft", thisFrame, "topleft", 107, -55)
thisFrame.select = selectOutputChannel.widget
thisFrame.dropdown = selectOutputChannel
function selectOutputChannel:CheckValid()
local lastSelected = Details.report_where
local checkFunc
for i, channelTable in ipairs(baseChannels) do
if (channelTable[2] == lastSelected) then
checkFunc = channelTable[3]
break
4 years ago
end
3 years ago
end
if (checkFunc) then
local isShown = checkFunc()
if (isShown) then
selectOutputChannel:Select(lastSelected)
else
if (IsInRaid()) then
selectOutputChannel:Select("RAID")
elseif (GetNumSubgroupMembers() > 0) then
selectOutputChannel:Select("PARTY")
elseif (IsInGuild()) then
selectOutputChannel:Select("GUILD")
4 years ago
else
3 years ago
selectOutputChannel:Select("SAY")
4 years ago
end
end
3 years ago
else
selectOutputChannel:Select(lastSelected)
4 years ago
end
3 years ago
end
selectOutputChannel:CheckValid()
4 years ago
end
3 years ago
--slider
local createSlider = function(thisFrame)
thisFrame.linhas_amt = thisFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
thisFrame.linhas_amt:SetText(Loc ["STRING_REPORTFRAME_LINES"])
thisFrame.linhas_amt:SetTextColor(.9, .9, .9, 1)
thisFrame.linhas_amt:SetPoint("bottomleft", thisFrame, "bottomleft", 58, 12)
Details:SetFontSize(thisFrame.linhas_amt, 10)
local slider = CreateFrame("Slider", "Details_Report_Slider", thisFrame, "BackdropTemplate")
thisFrame.slider = slider
slider:SetPoint("bottomleft", thisFrame, "bottomleft", 58, -7)
slider.thumb = slider:CreateTexture(nil, "artwork")
slider.thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
slider.thumb:SetSize(30, 24)
slider.thumb:SetAlpha(0.7)
local lockTexture = slider:CreateTexture(nil, "overlay")
lockTexture:SetPoint("center", slider.thumb, "center", -1, -1)
lockTexture:SetTexture("Interface\\Buttons\\CancelButton-Up")
lockTexture:SetWidth(29)
lockTexture:SetHeight(24)
4 years ago
lockTexture:Hide()
slider.lockTexture = lockTexture
3 years ago
slider:SetThumbTexture(slider.thumb)
slider:SetOrientation("HORIZONTAL")
slider:SetMinMaxValues(1.0, 25.0)
slider:SetValueStep(1.0)
slider:SetWidth(232)
slider:SetHeight(20)
local lastValue = Details.report_lines or 5
slider:SetValue(floor(lastValue))
slider.amt = slider:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
4 years ago
local amt = slider:GetValue()
if (amt < 10) then
3 years ago
amt = "0" .. amt
4 years ago
end
3 years ago
slider.amt:SetText(amt)
slider.amt:SetTextColor(.8, .8, .8, 1)
slider.amt:SetPoint("center", slider.thumb, "center")
slider:SetScript("OnValueChanged", function(self)
local amt = math.floor(self:GetValue())
Details.report_lines = amt
4 years ago
if (amt < 10) then
3 years ago
amt = "0" .. amt
4 years ago
end
3 years ago
self.amt:SetText(amt)
4 years ago
end)
3 years ago
slider:SetScript("OnEnter", function(self)
slider.thumb:SetAlpha(1)
end)
slider:SetScript("OnLeave", function(self)
slider.thumb:SetAlpha(0.7)
4 years ago
end)
end
3 years ago
--whisper taget field
local createWisperField = function(thisFrame)
thisFrame.wisp_who = thisFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
thisFrame.wisp_who:SetText(Loc ["STRING_REPORTFRAME_WHISPER"] .. ":")
thisFrame.wisp_who:SetTextColor(1, 1, 1, 1)
thisFrame.wisp_who:SetPoint("topleft", thisFrame.select, "topleft", 14, -30)
4 years ago
3 years ago
Details:SetFontSize(thisFrame.wisp_who, 10)
4 years ago
--editbox
3 years ago
local editbox = CreateFrame("EditBox", nil, thisFrame, "BackdropTemplate")
thisFrame.editbox = editbox
editbox:SetAutoFocus(false)
editbox:SetFontObject("GameFontHighlightSmall")
editbox:SetPoint("TOPLEFT", thisFrame.select, "TOPLEFT", 64, -28)
editbox:SetHeight(14)
editbox:SetWidth(120)
editbox:SetJustifyH("center")
4 years ago
editbox:EnableMouse(true)
3 years ago
editbox:SetBackdrop({
4 years ago
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
tile = true, edgeSize = 1, tileSize = 5,
})
editbox:SetBackdropColor(0, 0, 0, 0.0)
editbox:SetBackdropBorderColor(0.0, 0.0, 0.0, 0.0)
3 years ago
local lastValue = Details.report_to_who or ""
editbox:SetText(lastValue)
4 years ago
editbox.perdeu_foco = nil
editbox.focus = false
3 years ago
editbox:SetScript("OnEnterPressed", function()
local texto = Details:trim(editbox:GetText())
if (string.len(texto) > 0) then
Details.report_to_who = texto
editbox:AddHistoryLine(texto)
editbox:SetText(texto)
else
Details.report_to_who = ""
editbox:SetText("")
end
editbox.perdeu_foco = true --isso aqui pra quando estiver editando e clicar em outra caixa
4 years ago
editbox:ClearFocus()
end)
3 years ago
editbox:SetScript("OnEscapePressed", function()
editbox:SetText("")
Details.report_to_who = ""
4 years ago
editbox.perdeu_foco = true
3 years ago
editbox:ClearFocus()
4 years ago
end)
3 years ago
editbox:SetScript("OnEnter", function()
editbox.mouse_over = true
4 years ago
if (editbox:GetText() == "" and not editbox.focus) then
3 years ago
editbox:SetText(Loc ["STRING_REPORTFRAME_INSERTNAME"])
end
4 years ago
end)
3 years ago
editbox:SetScript("OnLeave", function()
editbox.mouse_over = false
if (not editbox:HasFocus()) then
4 years ago
if (editbox:GetText() == Loc ["STRING_REPORTFRAME_INSERTNAME"]) then
3 years ago
editbox:SetText("")
end
end
4 years ago
end)
3 years ago
editbox:SetScript("OnEditFocusGained", function()
4 years ago
if (editbox:GetText() == Loc ["STRING_REPORTFRAME_INSERTNAME"]) then
3 years ago
editbox:SetText("")
4 years ago
end
3 years ago
4 years ago
if (editbox:GetText() ~= "") then
3 years ago
editbox:HighlightText(0, editbox:GetNumLetters())
4 years ago
end
3 years ago
4 years ago
editbox.focus = true
end)
3 years ago
editbox:SetScript("OnEditFocusLost", function()
4 years ago
if (editbox.perdeu_foco == nil) then
3 years ago
local text = Details:trim(editbox:GetText())
if (string.len(text) > 0) then
Details.report_to_who = text
4 years ago
else
3 years ago
Details.report_to_who = ""
editbox:SetText("")
end
4 years ago
else
editbox.perdeu_foco = nil
end
3 years ago
4 years ago
editbox.focus = false
end)
end
3 years ago
--both check buttons
local createCheckButtons = function(thisFrame)
local checkbox = CreateFrame("CheckButton", "Details_Report_CB_1", thisFrame, "ChatConfigCheckButtonTemplate,BackdropTemplate")
checkbox:SetPoint("topleft", thisFrame.wisp_who, "bottomleft", -25, -4)
_G[checkbox:GetName().."Text"]:SetText(Loc ["STRING_REPORTFRAME_CURRENT"])
Details:SetFontSize(_G[checkbox:GetName().."Text"], 10)
4 years ago
checkbox.tooltip = Loc ["STRING_REPORTFRAME_CURRENTINFO"]
3 years ago
checkbox:SetHitRectInsets(0, -35, 0, 0)
local checkbox2 = CreateFrame("CheckButton", "Details_Report_CB_2", thisFrame, "ChatConfigCheckButtonTemplate,BackdropTemplate")
checkbox2:SetPoint("topleft", thisFrame.wisp_who, "bottomleft", 35, -4)
_G[checkbox2:GetName().."Text"]:SetText(Loc ["STRING_REPORTFRAME_REVERT"])
Details:SetFontSize(_G[checkbox2:GetName().."Text"], 10)
4 years ago
checkbox2.tooltip = Loc ["STRING_REPORTFRAME_REVERTINFO"]
3 years ago
checkbox2:SetHitRectInsets(0, -35, 0, 0)
4 years ago
end
3 years ago
--frame creation function
local defaultSkin = function()
4 years ago
local window = DetailsReportWindow
local anchorX = 10
3 years ago
local recentReportButtonOnEnter = function(self)
self:SetBackdropColor(0.4, 0.4, 0.4, 0.6)
self.icon:SetBlendMode("ADD")
Details:SetFontColor(self.text, "yellow")
4 years ago
end
3 years ago
local recentReportButtonOnLeave = function(self)
self:SetBackdropColor(0, 0, 0, 0.3)
self.icon:SetBlendMode("BLEND")
Details:SetFontColor(self.text, "white")
4 years ago
end
3 years ago
window.last_reported_label:SetPoint("topleft", window, "topleft", 5, -28)
gump:SetFontSize(window.last_reported_label, 10)
4 years ago
for i = 1, 9 do --window.max_last_buttons
3 years ago
local recentReportButton = window.recently_report_buttons[i]
recentReportButton:SetSize(150, 16)
recentReportButton:SetPoint("topleft", window, "topleft", 5, -28 + (i * 17 * -1))
recentReportButton:Show()
recentReportButton:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16,
4 years ago
insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
recentReportButton:SetBackdropColor(0, 0, 0, 0.3)
recentReportButton.text:SetTextColor(1, 1, 1, 1)
Details:SetFontSize(recentReportButton.text, 9)
recentReportButton:SetScript("OnEnter", recentReportButtonOnEnter)
recentReportButton:SetScript("OnLeave", recentReportButtonOnLeave)
4 years ago
end
3 years ago
window.fechar:SetWidth(20)
window.fechar:SetHeight(20)
window.fechar:SetPoint("TOPRIGHT", window, "TOPRIGHT", 0, -3)
4 years ago
window.fechar:Show()
3 years ago
window.fechar:GetNormalTexture():SetDesaturated(true)
local recentReportButton = window.recently_report_buttons[10]
recentReportButton:Hide()
4 years ago
window.dropdown:ClearAllPoints()
3 years ago
window.dropdown:SetWidth(155)
window.dropdown:SetPoint("topleft", window, "topleft", anchorX, -30)
window.dropdown:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true,
4 years ago
tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
window.dropdown:SetBackdropBorderColor(0, 0, 0, 0.5)
window.dropdown:SetBackdropColor(0, 0, 0, 0.1)
4 years ago
window.wisp_who:ClearAllPoints()
window.editbox:ClearAllPoints()
3 years ago
window.wisp_who:SetPoint("topleft", window.dropdown.widget, "bottomleft", 0, -10)
window.editbox:SetPoint("topleft", window.wisp_who, "bottomleft", 0, -3)
window.editbox:SetWidth(155)
window.editbox:SetHeight(20)
window.editbox:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true,
4 years ago
tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
window.editbox:SetBackdropBorderColor(0, 0, 0, 0.5)
window.editbox:SetBackdropColor(0, 0, 0, 0.3)
4 years ago
window.linhas_amt:ClearAllPoints()
3 years ago
window.linhas_amt:SetPoint("topleft", window.editbox, "bottomleft", 0, -10)
4 years ago
window.slider:ClearAllPoints()
3 years ago
window.slider:SetWidth(155)
window.slider:SetPoint("topleft", window.linhas_amt, "bottomleft", 0, -3)
window.slider:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true,
4 years ago
tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
window.slider:SetBackdropBorderColor(0, 0, 0, 0.5)
window.slider:SetBackdropColor(0, 0, 0, 0.3)
window.slider.thumb:SetTexture([[Interface\AddOns\Details\images\icons2]])
window.slider.thumb:SetTexCoord(482/512, 492/512, 104/512, 120/512)
window.slider.thumb:SetSize(16, 16)
window.slider.thumb:SetVertexColor(0.6, 0.6, 0.6, 0.95)
4 years ago
Details_Report_CB_1:Hide()
local reverse_checkbox = Details_Report_CB_2
reverse_checkbox:Show()
reverse_checkbox:ClearAllPoints()
3 years ago
reverse_checkbox:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true,
4 years ago
tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
reverse_checkbox:SetBackdropBorderColor(0, 0, 0, 0.5)
reverse_checkbox:SetBackdropColor(0, 0, 0, 0.3)
reverse_checkbox:SetPoint("topleft", window.slider, "bottomleft", 0, -8)
reverse_checkbox:SetSize(14, 14)
reverse_checkbox:SetNormalTexture("")
reverse_checkbox:SetPushedTexture("")
reverse_checkbox:SetHighlightTexture("")
_G[reverse_checkbox:GetName().."Text"]:ClearAllPoints()
_G[reverse_checkbox:GetName().."Text"]:SetPoint("left", reverse_checkbox, "right", 2, 0)
4 years ago
window.enviar:ClearAllPoints()
3 years ago
window.enviar:SetPoint("bottom", window, "bottom", 0, 10)
window.enviar:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true,
4 years ago
tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}})
3 years ago
window.enviar:SetBackdropBorderColor(0, 0, 0, 0.5)
window.enviar:SetBackdropColor(0, 0, 0, 0.3)
window.enviar:SetSize(342/2 - 15, 20)
window:SetWidth(342/2 + 5)
window:SetHeight(195)
--window:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
--window:SetBackdropColor(1, 1, 1, 1)
--window:SetBackdropBorderColor(0, 0, 0, 1)
3 years ago
if (not window.widgets) then
window.widgets = {}
local titlebar = CreateFrame("frame", window:GetName() .. "TitleBar", window, "BackdropTemplate")
titlebar:SetPoint("topleft", window, "topleft", 2, -3)
titlebar:SetPoint("topright", window, "topright", -2, -3)
titlebar:SetHeight(20)
--titlebar:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
--titlebar:SetBackdropColor(.5, .5, .5, 1)
--titlebar:SetBackdropBorderColor(0, 0, 0, 1)
table.insert(window.all_widgets, titlebar)
table.insert(window.widgets, titlebar)
4 years ago
end
window.title:ClearAllPoints()
3 years ago
window.title:SetPoint("center", window, "center")
window.title:SetPoint("top", window, "top", 0, -7)
window.title:SetParent(_G[window:GetName() .. "TitleBar"])
window.title:SetTextColor(.8, .8, .8, 1)
4 years ago
window.title:Show()
3 years ago
window:SetClampedToScreen(true)
for _, widget in ipairs(window.widgets) do
4 years ago
widget:Show()
end
end
3 years ago
function Details:UpdateRecentlyReported()
4 years ago
DetailsReportWindow:RefreshRecentlyReported()
end
3 years ago
function Details:DelayUpdateReportWindowRecentlyReported()
4 years ago
if (DetailsReportWindow) then
3 years ago
Details:ScheduleTimer("UpdateRecentlyReported", 0.5)
4 years ago
end
end
3 years ago
function Details:CheckLastReportsIntegrity()
local lastReports = Details.latest_report_table or {}
if (#lastReports > 0) then
4 years ago
local i = 1
3 years ago
for index = #lastReports, 1, -1 do
local report = lastReports[index]
local instance_id, atributo, sub_atributo, amt, where, custom_name = unpack(report)
4 years ago
if (atributo == 5) then
if (not custom_name) then
3 years ago
tremove(lastReports, index)
4 years ago
else
local found
3 years ago
for _, custom in ipairs(Details.custom) do
4 years ago
if (custom.name == custom_name) then
found = true
break
end
end
if (not found) then
3 years ago
tremove(lastReports, index)
4 years ago
end
end
end
end
end
end
3 years ago
4 years ago
function gump:CriaJanelaReport()
3 years ago
--window
local window = CreateFrame("Frame", "DetailsReportWindow", UIParent, "BackdropTemplate")
table.insert(UISpecialFrames, "DetailsReportWindow")
3 years ago
window:SetPoint("CENTER", UIParent, "CENTER")
window:SetFrameStrata("DIALOG")
window.skins = {}
window.all_widgets = {}
window.max_last_buttons = 10
window:EnableMouse(true)
window:SetResizable(false)
window:SetMovable(true)
restorepos(window)
Details.janela_report = window
Details:InstallRPSkin("defaultSkin", defaultSkin)
DetailsFramework:AddRoundedCornersToFrame(window, Details.PlayerBreakdown.RoundedCornerPreset)
3 years ago
--recently reported:
window.recently_report_buttons = {}
local historyBlockBackground = window:CreateTexture(nil, "background")
historyBlockBackground:SetColorTexture(0, 0, 0, .3)
historyBlockBackground:SetSize(160, 158)
historyBlockBackground:SetPoint("topleft", window, "topleft", 3, -25)
local separator = window:CreateTexture(nil, "border")
separator:SetColorTexture(0, 0, 0, .6)
separator:SetSize(2, 158)
separator:SetPoint("topleft", historyBlockBackground, "topright", 0, 0)
function window:RefreshRecentlyReported()
for i = 1, window.max_last_buttons do
local b = window.recently_report_buttons[i]
b.icon:SetTexture("")
b:Hide()
end
4 years ago
3 years ago
Details:CheckLastReportsIntegrity()
local lastReports = Details.latest_report_table
if (#lastReports > 0) then
local i = 1
for index = 1, min(#lastReports, 8) do
local recentReportButton = window.recently_report_buttons[i]
local report = lastReports[index]
local instanceId, attribute, subAttribute, amt, reportWhere = unpack(report)
local name = Details:GetSubAttributeName(attribute, subAttribute)
local artwork = Details.GetReportIconAndColor(reportWhere)
recentReportButton.text:SetText(name .. " (#" .. amt .. ")")
recentReportButton.index = index
if (artwork) then
recentReportButton.icon:SetTexture(artwork.icon)
recentReportButton.icon:SetTexCoord(artwork.coords[1], artwork.coords[2], artwork.coords[3], artwork.coords[4])
recentReportButton.icon:SetVertexColor(unpack(artwork.color or {}))
4 years ago
end
3 years ago
recentReportButton:Hide()
i = i + 1
4 years ago
end
end
3 years ago
end
local recentlyButtonOnClick = function(self)
if (self.index) then
return Details.ReportFromLatest(_, _, self.index)
4 years ago
end
3 years ago
end
local lastReportedLabel = window:CreateFontString(nil, "overlay", "GameFontNormal")
window.last_reported_label = lastReportedLabel
window.last_reported_label:SetText(Loc ["STRING_REPORTHISTORY"] .. ":") --this string could be removed from localization
for i = 1, window.max_last_buttons do
local button = CreateFrame("button", "DetailsReportWindowRRB" .. i, window, "BackdropTemplate")
local icon = button:CreateTexture(nil, "overlay")
icon:SetPoint("left", button, "left")
icon:SetSize(16, 16)
local text = button:CreateFontString(nil, "overlay", "GameFontNormal")
text:SetPoint("left", icon, "right", 2, 0)
button.icon = icon
button.text = text
button:SetScript("OnClick", recentlyButtonOnClick)
table.insert(window.recently_report_buttons, button)
3 years ago
end
historyBlockBackground:Hide()
separator:Hide()
window.last_reported_label:Hide()
--scritps
local flashTexture = window:CreateTexture(nil, "background")
flashTexture:SetColorTexture(1, 1, 1)
flashTexture:SetPoint("topleft", window, "topleft", -2, 2)
flashTexture:SetPoint("bottomright", window, "bottomright", 2, -2)
3 years ago
local onShowAnimation = DetailsFramework:CreateAnimationHub(flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end)
DetailsFramework:CreateAnimation(onShowAnimation, "ALPHA", 1, .4, 0, .90)
DetailsFramework:CreateAnimation(onShowAnimation, "ALPHA", 2, .4, .90, 0)
3 years ago
window:SetScript("OnShow", function(self)
local dropdown = window.select.MyObject
local where = Details.report_where
local list = window.dropdown_func()
local found
onShowAnimation:Play()
for index, option in ipairs(list) do
if (option.value == where) then
dropdown:Select(where)
found = true
break
4 years ago
end
3 years ago
end
if (not found) then
if (IsInRaid()) then
dropdown:Select("RAID")
Details.report_where = "RAID"
elseif (GetNumSubgroupMembers() > 0) then
dropdown:Select("PARTY")
Details.report_where = "PARTY"
elseif (IsInGuild()) then
dropdown:Select("GUILD")
Details.report_where = "GUILD"
else
dropdown:Select("SAY")
Details.report_where = "SAY"
4 years ago
end
3 years ago
end
window:RefreshRecentlyReported()
window:SetColor(unpack(Details.frame_background_color))
3 years ago
end)
window:SetScript("OnHide", function(self)
Details.janela_report.ativa = false
Details.last_report_id = nil
end)
--close button
window.fechar = CreateFrame("Button", nil, window, "UIPanelCloseButton")
window.fechar:SetScript("OnClick", function()
Details.FadeHandler.Fader(window, 1)
Details.janela_report.ativa = false
end)
--title
window.title = window:CreateFontString(nil, "OVERLAY", "GameFontHighlightLeft")
window.title:SetText(Loc ["STRING_REPORTFRAME_WINDOW_TITLE"])
setScripts(window)
createDropdown(window)
createSlider(window)
createWisperField(window)
createCheckButtons(window)
window.enviar = CreateFrame("Button", nil, window, "BackdropTemplate")
window.enviar:SetPoint("topleft", window.editbox, "topleft", 61, -19)
window.enviar:SetWidth(60)
window.enviar:SetHeight(15)
DetailsFramework:ApplyStandardBackdrop(window.enviar)
local sendButtonLabel = window.enviar:CreateFontString(nil, "overlay", "GameFontNormal")
sendButtonLabel:SetPoint("center", 0, 0)
sendButtonLabel:SetText(Loc ["STRING_REPORTFRAME_SEND"])
Details.FadeHandler.Fader(window, 1)
gump:CreateFlashAnimation(window)
4 years ago
--apply the current skin
3 years ago
Details:ApplyRPSkin()
4 years ago
return window
end
3 years ago
function Details:InstallRPSkin(skinName, func)
4 years ago
if (not DetailsReportWindow) then
gump:CriaJanelaReport()
DetailsReportWindow:Hide()
end
3 years ago
if (not skinName) then
return false
elseif (DetailsReportWindow.skins[skinName]) then
return false
4 years ago
end
3 years ago
DetailsReportWindow.skins[skinName] = func
4 years ago
return true
end
3 years ago
function Details:ApplyRPSkin(skinName)
4 years ago
if (not DetailsReportWindow) then
gump:CriaJanelaReport()
DetailsReportWindow:Hide()
end
3 years ago
if (not skinName) then
skinName = Details.player_details_window.skin
if (not DetailsReportWindow.skins[skinName]) then
skinName = "defaultSkin"
4 years ago
end
end
3 years ago
local skin = DetailsReportWindow.skins[skinName]
4 years ago
if (skin) then
3 years ago
for _, widget in ipairs(DetailsReportWindow.all_widgets) do
4 years ago
widget:Hide()
end
3 years ago
local successful, errortext = pcall(skin)
4 years ago
if (not successful) then
3 years ago
Details:Msg("error occurred on report window skin call():", errortext)
pcall(DetailsReportWindow.skins["defaultSkin"])
4 years ago
end
end
end