-
Notifications
You must be signed in to change notification settings - Fork 9
/
FurCControlBridge.lua
258 lines (208 loc) · 6.29 KB
/
FurCControlBridge.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
FurC.Visible = false
local LAM = LibAddonMenu2
function FurC.LoadFrameInfo(calledFrom)
local settings = FurC.settings.gui
FurCGui:ClearAnchors()
FurCGui:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, settings.lastX, settings.lastY)
FurCGui:SetWidth(settings.width)
FurCGui:SetHeight(settings.height)
zo_callLater(function()
FurC.UpdateInventoryScroll()
end, 100)
end
function FurC.SaveFrameInfo(calledFrom)
local settings = FurC.settings["gui"]
settings.lastX = FurCGui:GetLeft()
settings.lastY = FurCGui:GetTop()
settings.width = FurCGui:GetWidth()
settings.height = FurCGui:GetHeight()
FurC.UpdateInventoryScroll()
end
function FurC.OnResizeStop()
FurC.SaveFrameInfo()
FurC.UpdateLineVisibility()
FurC.UpdateInventoryScroll()
end
function FurC.ChangeTemplateFromButton(value)
local control = FurCGui_Header_Bar1_TemplateLarge
local otherControl = FurCGui_Header_Bar1_TemplateTiny
if value then
otherControl = FurCGui_Header_Bar1_TemplateLarge
control = FurCGui_Header_Bar1_TemplateTiny
end
control:SetHidden(true)
otherControl:SetHidden(false)
FurC.SetTinyUi(value)
end
function FurC.GUIButtonHideOnMouseUp()
FurCGui:SetHidden(true)
end
local function forceRefresh()
FurC.WipeDatabase()
end
function FurC.GUIButtonRefreshOnMouseUp(control, mouseButton)
if mouseButton == 1 then
FurC.ScanRecipes(false, true)
elseif mouseButton == 2 then
FurC.ScanRecipes(true, false)
elseif mouseButton == 3 then
if LAM and LAM.util then
LAM.util.ShowConfirmationDialog(
GetString(SI_FURC_DIALOGUE_RESET_DB_HEADER),
GetString(SI_FURC_DIALOGUE_RESET_DB_BODY),
forceRefresh
)
end
end
end
function FurC.GuiShowTooltip(control, tooltiptext, reAnchor)
InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0, 0)
InformationTooltip:SetHidden(false)
InformationTooltip:ClearLines()
InformationTooltip:AddLine(tooltiptext)
if reAnchor then
InformationTooltip:ClearAnchors()
InformationTooltip:SetAnchor(TOPRIGHT, control, TOPLEFT, -10, 0)
end
end
function FurC.GuiHideTooltip(control)
InformationTooltip:ClearLines()
InformationTooltip:SetHidden(true)
end
function FurC.GetRumourTooltip()
return GetString((FurC.GetShowRumours() and SI_FURC_FILTER_RUMOUR_HIDE_TT) or SI_FURC_SHOW_RUMOUR_TT)
end
function FurC.GetCrownTooltip()
return GetString((FurC.GetShowCrownstore() and SI_FURC_FILTER_CROWN_HIDE_TT) or SI_FURC_SHOW_CROWN_TT)
end
function FurC.GuiOnSearchBoxClick(control, mouseButton, doubleClick)
if mouseButton == 2 or doubleClick then
control:SetDefaultText("")
end
end
function FurC.GuiOnScroll(control, delta)
if not delta then
return
end
if delta == 0 then
return
end
local slider = FurCGui_ListHolder_Slider
-- slider.locked = true
-- negative delta means scrolling down
local value = (FurCGui_ListHolder.dataOffset - delta)
local total = #FurCGui_ListHolder.dataLines - FurCGui_ListHolder.maxLines
if value < 0 then
value = 0
end
if value > total then
value = total
end
FurCGui_ListHolder.dataOffset = value
FurC.UpdateInventoryScroll()
slider:SetValue(FurCGui_ListHolder.dataOffset)
FurC.GuiLineOnMouseEnter(moc())
end
function FurC.GuiOnSliderUpdate(slider, value)
if not value or slider and slider.locked then
return
end
local relativeValue = math.floor(FurCGui_ListHolder.dataOffset - value)
FurC.GuiOnScroll(slider, relativeValue)
end
function FurC.GuiShowFilterTooltip(control, label)
label = control.tooltip or label
FurC.GuiShowTooltip(control, label)
end
local currentLink, currentId
function FurC.GuiLineOnMouseEnter(lineControl)
currentLink, currentId = nil, nil
if not lineControl or not lineControl.itemLink or lineControl.itemLink == "" then
return
end
currentLink = lineControl.itemLink
currentId = lineControl.itemId
if nil == currentLink then
return
end
InitializeTooltip(ItemTooltip, lineControl, LEFT, 0, 0, 0)
ItemTooltip:SetLink(currentLink)
end
function FurC.GuiLineOnMouseExit(lineControl)
ItemTooltip:SetHidden(true)
end
function FurC.Donate(control, mouseButton)
local amount = 2000
if mouseButton == 2 then
amount = 10000
elseif mouseButton == 3 then
amount = 25000
end
SCENE_MANAGER:Show("mailSend")
zo_callLater(function()
ZO_MailSendToField:SetText("@BerylBones")
ZO_MailSendSubjectField:SetText("Thank you for Furniture Catalogue!")
QueueMoneyAttachment(amount)
ZO_MailSendBodyField:TakeFocus()
end, 200)
end
function FurC.OnControlDoubleClick(control)
FurC.ToChat(control.itemLink)
end
function FurC.GuiVirtualMouseOver(control)
FurC.GuiShowTooltip(control, control.tooltip)
end
function FurC.GuiVirtualMouseOut(control)
FurC.GuiHideTooltip(control)
end
function FurC.GuiQualityMouseUp(control, button)
if button == 2 then
FurC.SetFilterQuality(0)
end
FurC.SetFilterQuality(control.quality)
end
function FurC.GuiCraftingTypeMouseUp(control)
FurC.SetFilterCraftingType(control.craftingType)
end
local sortBy = nil
local sortDirection = "down"
local function getButtonTex(key)
if key ~= sortBy then
return "esoui/art/miscellaneous/list_sortheader_icon_neutral.dds"
end
return "esoui/art/miscellaneous/list_sortheader_icon_sort" .. sortDirection .. ".dds"
end
function FurC.GetSortParams()
return sortBy, sortDirection
end
function FurC.GuiOnSort(key)
-- set icon texture
if sortBy and sortBy == key then
sortDirection = ((sortDirection == "up" and "down") or "up")
else
sortBy = key
sortDirection = "up"
end
FurCGui_Header_SortBar_Name_Button:SetNormalTexture(getButtonTex("itemName"))
FurCGui_Header_SortBar_Quality_Button:SetNormalTexture(getButtonTex("itemQuality"))
FurC.UpdateGui()
end
function FurC.UpdateDropdownChoice(dropdownName, value)
if nil == dropdownName then
FurC.UpdateDropdownChoice("Version", value)
FurC.UpdateDropdownChoice("Character", value)
FurC.UpdateDropdownChoice("Source", value)
return
end
InformationTooltip:SetHidden(true)
value = value or FurC.GetDropdownChoiceTextual(dropdownName)
local controlName = "FurC_Dropdown" .. dropdownName
local control = _G[controlName]
if nil == control then
return
end
control:GetNamedChild("SelectedItemText"):SetText(value)
end
function FurC.RefreshCounter()
FurC_RecipeCount:SetText(tostring(#FurCGui_ListHolder.dataLines))
end