-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVMainGUI.lua
171 lines (142 loc) · 5.67 KB
/
VMainGUI.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
VAuction_EventFrame = _G["VossiAuctionScanFrame"]
VAuction_ScanName = _G["VScanName"]
VAuction_TimePredictText = _G["VTimePredictText"]
VAuction_TimeSpentText = _G["VTimeSpentText"]
VAuction_ScanText = _G["VScanText"]
VAuction_VScansCount = _G["VScansCount"]
VStoredScansCount=0
function createStatusbar()
statusbar = CreateFrame("StatusBar", nil, VAuction_EventFrame)
statusbar:SetPoint("TOP", VAuction_EventFrame, "TOP", 0, -70)
statusbar:SetWidth(280)
statusbar:SetHeight(20)
statusbar:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
statusbar:GetStatusBarTexture():SetHorizTile(false)
statusbar:GetStatusBarTexture():SetVertTile(false)
statusbar:SetMinMaxValues(0, 100.0)
statusbar:SetStatusBarColor(0, 0.65, 0)
statusbar:SetValue(0)
statusbar.bg = statusbar:CreateTexture(nil, "BACKGROUND")
statusbar.bg:SetTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
statusbar.bg:SetAllPoints(true)
statusbar.bg:SetVertexColor(0, 0.35, 0)
statusbar.value = statusbar:CreateFontString(nil, "OVERLAY")
statusbar.value:SetPoint("CENTER", statusbar, "CENTER", 4, 0)
statusbar.value:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
statusbar.value:SetJustifyH("CENTER")
statusbar.value:SetShadowOffset(1, -1)
statusbar.value:SetTextColor(0, 1, 0)
statusbar.value:SetText("0%")
end
function initializeStatus()
VAuction_ScanName:SetText("Scan Snapshot Name: -")
VAuction_TimePredictText:SetText("")
VAuction_TimeSpentText:SetText("")
VAuction_ScanText:SetText("scan not started yet")
statusbar:SetValue(0)
statusbar.value:SetText("0%")
scanBtn = _G["VScanButton"]
enableStartScan(true)
end
function ScanButtonClick()
scanBtn = _G["VScanButton"]
if (scanInProgress) then
-- scan running, cancel it and reset button text
CancelScan()
StoreScan()
scanBtn:SetText("Start scan")
else
ScanAuctionHouse()
scanBtn:SetText("Cancel Scan")
end
end
function enableStartScan(enable)
scanBtn = _G["VScanButton"]
if (VStoredScansCount<10 and enable) then
scanBtn:SetEnabled(true)
else
scanBtn:SetEnabled(false)
end
end
function StoreScan()
local itemCount = table.getn(VCurrentScan)
if (itemCount>0) then
StoreScan()
pprint('Stored Snapshot: '..scanTimestamp.." with "..itemCount.." items")
ListScans()
end
end
function ListScans()
scanFrame = _G["VScansFrame"]
scanFrameHeight = scanFrame:GetHeight()
scanFrameWidth = scanFrame:GetWidth()
dprint("Scan List Frame Height/Width: "..scanFrameHeight.."/"..scanFrameWidth)
-- clean up UI Elements not used anymore
for i=1,10 do
scanFrameName = "ScansListItem"..i
if (scanFrame[scanFrameName]) then
scanFrame[scanFrameName]:Hide()
end
scanFrameButton = "ScansListButton"..i
if (scanFrame[scanFrameButton]) then
scanFrame[scanFrameButton]:Hide()
end
end
i=0
lineHeight=20
marginOffset=15
deleteButtonSize=30
deleteButtonWidth=50
topOffset = 5
-- create a table sorted by date - key of they array
local tkeys = {}
for k in pairs(VossiScanTable) do table.insert(tkeys, k) end
table.sort(tkeys)
-- loop over sorted keys
for _,sortedKey in pairs(tkeys) do
-- assign values as if looping normally over pairs to k,v
k=sortedKey
v=VossiScanTable[sortedKey]
i=i+1
scanCount = table.getn(v)
--dprint(k)
scanFrameName = "ScansListItem"..i
if (not scanFrame[scanFrameName]) then
scanFrame[scanFrameName] = scanFrame:CreateFontString(scanFrameName, "OVERLAY", "GameFontWhite")
end
scanFrame[scanFrameName]:SetPoint("TOPLEFT", scanFrame, "TOPLEFT", marginOffset+0, 0+(-lineHeight*i)+topOffset)
scanFrame[scanFrameName]:SetJustifyH("LEFT")
scanFrame[scanFrameName]:SetShadowOffset(1, -1)
--scanFrame[scanFrameName]:SetTextColor(0, 1, 0)
scanFrame[scanFrameName]:SetText("["..i .. "] "..k.." - "..scanCount.." items")
scanFrame[scanFrameName]:SetWidth(scanFrameWidth-deleteButtonWidth)
scanFrame[scanFrameName]:SetHeight(lineHeight)
scanFrame[scanFrameName]:Show()
scanFrameButton = "ScansListButton"..i
if (not scanFrame[scanFrameButton]) then
scanFrame[scanFrameButton] = CreateFrame("Button", scanFrameButton, scanFrame)
end
deleteButtonOffset = deleteButtonSize-lineHeight
deleteTopOffset = -5
scanFrame[scanFrameButton]:SetPoint("TOPRIGHT", scanFrame, "TOPRIGHT", -marginOffset+0, 0+(-lineHeight*i)+deleteButtonOffset+deleteTopOffset+topOffset)
scanFrame[scanFrameButton]:SetSize(deleteButtonSize,deleteButtonSize)
scanFrame[scanFrameButton]:SetNormalTexture("Interface\\Buttons\\CancelButton-Up")
scanFrame[scanFrameButton]:SetPushedTexture("Interface\\Buttons\\CancelButton-Down")
scanFrame[scanFrameButton]:SetHighlightTexture("Interface\\Buttons\\CancelButton-Down")
scanFrame[scanFrameButton]:SetScript("OnClick", ScanMouseClickHandle)
scanFrame[scanFrameButton].scanId = i
scanFrame[scanFrameButton].scanTimestamp = k
scanFrame[scanFrameButton]:Show()
end
VStoredScansCount = i
VAuction_VScansCount:SetText("Scans stored: "..VStoredScansCount.."/10")
end
function ScanMouseClickHandle(s,ev)
DeleteScan(s.scanTimestamp)
end
function DeleteScan(scanTimestamp)
pprint("Removing scan: "..scanTimestamp)
table.removekey(VossiScanTable, scanTimestamp)
ListScans()
enableStartScan(true)
end