-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display.lua
109 lines (90 loc) · 3.08 KB
/
Display.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---@class WBL
local WBL = LibStub("AceAddon-3.0"):GetAddon("Warband-Bank-Log")
WBL_API = {}
WBL.Display = {}
function WBL:CreateDisplay()
local frame = CreateFrame("Frame", "WarbandBankLog_BaseFrame", UIParent, "WBLBaseFrameTemplate")
frame:SetDontSavePosition(true)
frame:ClearAllPoints()
frame:SetPoint(
WBL.db.profile.relativePoint,
UIParent,
WBL.db.profile.xPos,
WBL.db.profile.yPos
)
frame:SetSize(WBL.db.profile.width, WBL.db.profile.height)
frame.ResizeButton:SetOnResizeStoppedCallback(function()
WBL.db.profile.width, WBL.db.profile.height = frame:GetSize()
end)
function frame:stoppedMoving()
local rel, _, _, xPos, yPos = self:GetPoint()
WBL.db.profile.xPos = xPos
WBL.db.profile.yPos = yPos
WBL.db.profile.relativePoint = rel
end
frame.SearchBox.clearButton:SetScript("OnClick", function() WBL:ClearSearch() end)
WBL.Display.BaseFrame = frame
local ScrollBox = frame.Container.ScrollBox
local ScrollBar = frame.Container.ScrollBar
WBL.DataProvider = CreateDataProvider()
local ScrollView = CreateScrollBoxListLinearView()
WBL.ScrollView = ScrollView
ScrollView:SetDataProvider(WBL.DataProvider)
ScrollUtil.InitScrollBoxListWithScrollBar(ScrollBox, ScrollBar, ScrollView)
local function Initializer(frame, logData)
frame:SetPropagateMouseMotion(true)
local changeType = ""
if logData.changeType == "added" then
changeType = "|cff4bd04d" .. logData.changeType .. "|r"
else
changeType = "|cffd06057" .. logData.changeType .. "|r"
end
local message =
"|cff979797[" ..
date(WBL.timeFormats[WBL.db.profile.timeFormat], logData.timeStamp) ..
"]|r " ..
logData.name ..
" " ..
changeType ..
" " ..
logData.link
frame.text:SetText(message)
function frame:GetTooltipAnchor()
local x = self:GetRight() / GetScreenWidth() > 0.8
return x and 'ANCHOR_LEFT' or 'ANCHOR_RIGHT'
end
end
ScrollView:SetElementInitializer("WBLItemListObjectTemplate", Initializer)
WBL:InitializeDataProvider()
end
function WBL:CreateBankButton()
local WBLButton = CreateFrame("Button", "WBLBlizzardButton", AccountBankPanel, "UIPanelButtonTemplate")
WBLButton:SetPoint("BOTTOMLEFT", 2, 6)
WBLButton:SetSize(105, 21)
WBLButton:SetFrameLevel(700)
WBLButton:SetText("Log")
WBLButton:SetScript("OnClick", function()
WBL_API:Toggle()
end)
WBL.Display.Button = WBLButton
end
function WBL:InitializeDataProvider()
if #WBL.Logs == 0 then
return
end
WBL.DataProvider:InsertTable(WBL.Logs)
end
function WBL_API:Open()
WBL.Display.BaseFrame:Show()
WBL.Display.BaseFrame.Container.ScrollBox:SetScrollPercentage(100)
end
function WBL_API:Close()
WBL.Display.BaseFrame:Hide()
end
function WBL_API:Toggle()
if WBL.Display.BaseFrame:IsVisible() then
WBL_API:Close()
else
WBL_API:Open()
end
end