From 21167ea316d06dc18fb13d2b13b510f44cd59bad Mon Sep 17 00:00:00 2001 From: Boshi Lian Date: Fri, 8 May 2020 01:08:42 -0700 Subject: [PATCH] db click to send to chat --- gui.lua | 28 ++++++++++++++++++++++++---- utils.lua | 29 ++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/gui.lua b/gui.lua index 8cc6233..6b9e234 100644 --- a/gui.lua +++ b/gui.lua @@ -1638,8 +1638,6 @@ function GUI:Init() self.lootLogFrame.frame:SetPoint("TOPLEFT", f, "TOPLEFT", 30, -50) self.lootLogFrame:RegisterEvents({ - - ["OnClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, sttable, button, ...) clearAllFocus() local entry, idx = GetEntryFromUI(rowFrame, cellFrame, data, cols, row, realrow, column, sttable) @@ -1677,6 +1675,17 @@ function GUI:Init() ChatEdit_InsertLink(entry["detail"]["item"]) end end, + + ["OnDoubleClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, sttable, button, ...) + local item, idx = GetEntryFromUI(rowFrame, cellFrame, data, cols, row, realrow, column, sttable) + + if not item then + return + end + + SendChatMessage(ADDONSELF.GenExportLine(item, item["costcache"], true), f.reportopt.channel) + + end, }) end @@ -1713,6 +1722,8 @@ function GUI:Init() filterzero = false, } + f.reportopt = optctx + local setReportChannel = function(self) optctx.channel = self.arg1 b:SetText(self.value) @@ -1858,6 +1869,15 @@ function GUI:Init() end, notCheckable = true, }, + { + text = L["Expense"], + func = function() + GenReport(Database:GetCurrentLedger()["items"], GUI:GetSplitNumber(), optctx.channel, { + expenseonly = true, + }) + end, + notCheckable = true, + }, { isTitle = true, text = OPTIONS, @@ -1920,13 +1940,13 @@ function GUI:Init() b:SetScript("OnClick", function() if exportEditbox:GetParent():IsShown() then lootLogFrame:Show() - countEdit:Show() + countEdit:Enable() hidelockedCheck:Show() exportEditbox:GetParent():Hide() b:SetText(L["Export as text"]) else lootLogFrame:Hide() - countEdit:Hide() + countEdit:Disable() hidelockedCheck:Hide() exportEditbox:GetParent():Show() b:SetText(L["Close text export"]) diff --git a/utils.lua b/utils.lua index 59e7d69..cf928ee 100644 --- a/utils.lua +++ b/utils.lua @@ -162,7 +162,7 @@ end ADDONSELF.calcavg = calcavg -local function GenExportLine(item, c) +local function GenExportLine(item, c, uselink) local l = item["beneficiary"] or L["[Unknown]"] local i = item["detail"]["item"] or "" local cnt = item["detail"]["count"] or 1 @@ -170,15 +170,23 @@ local function GenExportLine(item, c) local t = item["type"] local ct = item["costtype"] - local n = GetItemInfo(i) or d - n = n ~= "" and n or nil - n = n or L["Other"] + local n, link = GetItemInfo(i) + if uselink then + n = link + end + n = n or d + n = n ~= "" and n or L["Other"] if t == "DEBIT" then n = d or L["Compensation"] end - local s = "[" .. n .. "] " .. " (" .. cnt .. ") " .. l .. " " .. GetMoneyStringL(c) + if not uselink then + n = "[" .. n .. "]" + end + + + local s = n .. " (" .. cnt .. ") " .. l .. " " .. GetMoneyStringL(c) if ct == "PROFIT_PERCENT" then s = s .. " (" .. (item["cost"] or 0) .. " % " .. L["Net Profit"] .. ")" @@ -191,6 +199,8 @@ local function GenExportLine(item, c) return s end +ADDONSELF.GenExportLine = GenExportLine + local function sendchat(lines, channel) local SendToChat = SendToCurrrentChannel if channel then @@ -356,6 +366,10 @@ ADDONSELF.genreport = function(items, n, channel, conf) end end + if conf.expenseonly then + wipe(lines) + end + if expense > 0 then table.insert(lines, "RaidLedger:.... " .. L["Debit"] .. " ....") @@ -370,6 +384,11 @@ ADDONSELF.genreport = function(items, n, channel, conf) end end + if conf.expenseonly then + sendchat(lines, channel) + return + end + if conf.short then wipe(lines) end