This repository was archived by the owner on Nov 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSLootTracker-UI-EditItem.lua
More file actions
150 lines (130 loc) · 6 KB
/
FSLootTracker-UI-EditItem.lua
File metadata and controls
150 lines (130 loc) · 6 KB
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
require "Window"
local FSLootTracker = Apollo.GetAddon("FSLootTracker")
local Info = Apollo.GetAddonInfo("FSLootTracker")
local Chronology = Apollo.GetPackage("Chronology").tPackage
local Utils = Apollo.GetPackage("SimpleUtils").tPackage
---------------------------------------------------------------------------------------------------
-- ListItem Functions
---------------------------------------------------------------------------------------------------
function FSLootTracker:CreateEditWindow( wndHandler )
-- Get Parent List item and associated item data.
local idx = wndHandler:GetData()
local data = self.state.listItems.items[idx]
-- Load the item edit panel
if self.state.windows.edit then
self.state.windows.edit:Destroy()
end
self.state.windows.edit = Apollo.LoadForm(self.xmlDoc, "ItemEditWindow", nil, self)
self.state.windows.edit:Show(true)
local itemData = self.state.cache.ItemCache:GetValue(data.itemID)
local iQuality = itemData.quality
-- give it a piece of data to refer to
local wndItemILvl = self.state.windows.edit:FindChild("ItemILvl")
if wndItemILvl then -- make sure the text wnd exist
wndItemILvl:SetText("iLvl: " .. itemData.iLvl)
end
-- give it a piece of data to refer to
local wndItemPower = self.state.windows.edit:FindChild("ItemNumber")
if wndItemPower then -- make sure the text wnd exist
wndItemPower:SetText("Item #: " .. data.itemID)
end
-- give it a piece of data to refer to
local wndItemText = self.state.windows.edit:FindChild("ItemText")
if wndItemText then -- make sure the text wnd exist
wndItemText:SetText(itemData.name)
wndItemText:SetTextColor(self.tItemQuality[iQuality].Color)
end
-- give it a piece of data to refer to
local wndItemType = self.state.windows.edit:FindChild("ItemType")
if wndItemType then -- make sure the text wnd exist
wndItemType:SetText(itemData.type)
end
-- give it a piece of data to refer to
local wndItemCount = self.state.windows.edit:FindChild("ItemCount")
if wndItemCount then -- make sure the text wnd exist
wndItemCount:SetText(data.count)
end
-- give it a piece of data to refer to
local wndItemCost = self.state.windows.edit:FindChild("ItemCost")
if wndItemCost then -- make sure the text wnd exist
wndItemCost:SetText(data.cost)
end
-- give it a piece of data to refer to
local wndItemPlayer = self.state.windows.edit:FindChild("ItemLooter")
if wndItemPlayer then -- make sure the text wnd exist
local strLooter = self.state.cache.LooterCache:GetKeyFromValue(data.looter)
if strLooter then
wndItemPlayer:SetText(strLooter)
end
end
-- give it a piece of data to refer to
local wndItemTimestamp = self.state.windows.edit:FindChild("ItemTimestamp")
if wndItemTimestamp then -- make sure the text wnd exist
local strFormat = self.tTimeStampFormats[self.settings.options.timeFormat]
wndItemTimestamp:SetText("Looted at " .. Chronology:GetFormattedDateTime(data.timeReported, strFormat))
wndItemTimestamp:SetTextColor(kcrNormalText)
end
-- give it a piece of data to refer to
local wndItemBorder = self.state.windows.edit:FindChild("ItemBorder")
if wndItemBorder then -- make sure the text wnd exist
wndItemBorder:SetSprite(self.tItemQuality[iQuality].SquareSprite)
local wndItemIcon = wndItemBorder:FindChild("ItemIcon")
if wndItemIcon then
wndItemIcon:SetSprite(itemData.icon)
wndItemIcon:SetData(idx)
end
end
self.state.windows.edit:SetData(idx)
end
function FSLootTracker:OnGenerateTooltip( wndHandler, wndControl, eToolTipType, x, y )
--if wndControl ~= wndHandler then return end
wndControl:SetTooltipDoc(nil)
local data = wndHandler:GetData()
if data then
local itemID = self.state.listItems.items[data].itemID
local item = Item.GetDataFromId(tonumber(itemID))
local itemEquipped = item:GetEquippedItemForItemType()
Tooltip.GetItemTooltipForm(self, wndControl, item, {bPrimary = true, bSelling = false, itemCompare = itemEquipped})
-- Tooltip.GetItemTooltipForm(self, wndControl, itemEquipped, {bPrimary = false, bSelling = false, itemCompare = item})
end
end
function FSLootTracker:OnLinkItem( wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY, bDoubleClick, bStopPropagation )
-- Get Parent List item and associated item data.
local itemID = self.state.listItems.items[wndHandler:GetData()].itemID
local oItem = Item.GetDataFromId(tonumber(itemID))
-- Shift Right click
if Apollo.IsShiftKeyDown() and eMouseButton == 1 then
Event_FireGenericEvent("ItemLink", oItem)
end
end
---------------------------------------------------------------------------------------------------
-- ItemEditWindow Functions
---------------------------------------------------------------------------------------------------
function FSLootTracker:OnEditCloseButton( wndHandler, wndControl, eMouseButton )
self.state.windows.edit:Show(false)
self.state.windows.edit:Destroy()
end
function FSLootTracker:OnEditSaveButton( wndHandler, wndControl, eMouseButton )
-- Get the index, set the values for this tItem index
idx = wndHandler:GetParent():GetData()
-- give it a piece of data to refer to
local wndItemCount = self.state.windows.edit:FindChild("ItemCount")
if wndItemCount then -- make sure the text wnd exist
self.state.listItems.items[idx].count = wndItemCount:GetText()
end
-- give it a piece of data to refer to
local wndItemCost = self.state.windows.edit:FindChild("ItemCost")
if wndItemCost then -- make sure the text wnd exist
self.state.listItems.items[idx].cost = wndItemCost:GetText()
end
-- give it a piece of data to refer to
local wndItemPlayer = self.state.windows.edit:FindChild("ItemLooter")
if wndItemPlayer then -- make sure the text wnd exist
local strLooter = "" .. wndItemPlayer:GetText() .. ""
local looterID = self.state.cache.LooterCache:GetAddValue(strLooter)
self.state.listItems.items[idx].looter = looterID
end
self:RebuildLists()
self.state.windows.edit:Show(false)
self.state.windows.edit:Destroy()
end