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 1
Expand file tree
/
Copy pathFasterLootPlus-UI-Assignee.lua
More file actions
149 lines (124 loc) · 5.46 KB
/
FasterLootPlus-UI-Assignee.lua
File metadata and controls
149 lines (124 loc) · 5.46 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
------------------------------------------------------------------------------------------------
-- FasterLootPlus ver. @project-version@
-- Authored by Chimpy Evans, Chrono Syz -- Entity-US / Wildstar
-- Based on FasterLoot by Chimpy Evans -- Entity-US / Wildstar
-- Build @project-hash@
-- Copyright (c) Chronosis. All rights reserved
--
-- https://github.com/chronosis/FasterLootPlus
------------------------------------------------------------------------------------------------
-- FasterLoot-UI-Assignee.lua
------------------------------------------------------------------------------------------------
require "Window"
local FasterLootPlus = Apollo.GetAddon("FasterLootPlus")
local Info = Apollo.GetAddonInfo("FasterLootPlus")
---------------------------------------------------------------------------------------------------
-- FasterLootPlus EditLootRuleWindow-Assignee UI Functions
---------------------------------------------------------------------------------------------------
function FasterLootPlus:OnAddLootAssignee( wndHandler, wndControl, eMouseButton )
self:CreateEditAssigneeWindow(nil)
end
function FasterLootPlus:OnAssigneeItemSelected( wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY, bDoubleClick, bStopPropagation )
if eMouseButton == 0 and bDoubleClick then -- Double Left Click
-- Open the Loot Rule Window for this loot rule.
self:CreateEditAssigneeWindow(wndHandler)
end
end
function FasterLootPlus:OnEditAssignee( wndHandler, wndControl, eMouseButton )
local par = wndHandler:GetParent()
self:CreateEditAssigneeWindow(par)
end
function FasterLootPlus:OnDeleteListAssignee( wndHandler, wndControl, eMouseButton )
local par = wndHandler:GetParent()
local idx = par:GetData()
table.remove(self.state.currentAssignees, idx)
self:RebuildAssigneeItems()
end
function FasterLootPlus:CreateEditAssigneeWindow( wndHandler )
if self.state.windows.editAssignee == nil then
self.state.windows.editAssignee = Apollo.LoadForm(self.xmlDoc, "EditAssigneeWindow", nil, self)
self.state.windows.editAssignee:Show(true)
if wndHandler ~= nil then
-- Get Parent List item and associated item data.
local idx = wndHandler:GetData()
local item = self.state.currentAssignees[idx]
self.state.windows.editAssignee:SetData(idx)
self.state.windows.editAssignee:FindChild("AssigneeName"):FindChild("Text"):SetText(item)
end
end
end
---------------------------------------------------------------------------------------------------
-- EditAssigneeWindow Functions
---------------------------------------------------------------------------------------------------
function FasterLootPlus:OnEditAssigneeSave( wndHandler, wndControl, eMouseButton )
-- Do save logic
local item = self.state.windows.editAssignee:FindChild("AssigneeName"):FindChild("Text"):GetText()
local idx = self.state.windows.editAssignee:GetData()
if idx then
-- Update Existing Item
self.state.currentAssignees[idx] = item
else
-- Add New Item
table.insert(self.state.currentAssignees, item)
end
self:CloseEditAssignee()
self:RebuildAssigneeItems()
end
function FasterLootPlus:OnEditAssigneeCancel( wndHandler, wndControl, eMouseButton )
self:CloseEditAssignee()
end
function FasterLootPlus:OnEditAssigneeClosed( wndHandler, wndControl )
self:CloseEditAssignee()
end
function FasterLootPlus:CloseEditAssignee()
self.state.windows.editAssignee:Show(false)
self.state.windows.editAssignee:Destroy()
self.state.windows.editAssignee = nil
end
function FasterLootPlus:OnMoveAssigneeDown( wndHandler, wndControl, eMouseButton )
local size = #self.state.currentAssignees
local par = wndHandler:GetParent()
local idx = par:GetData()
if idx < size then
local temp = deepcopy(self.state.currentAssignees[idx])
self.state.currentAssignees[idx] = deepcopy(self.state.currentAssignees[idx+1])
self.state.currentAssignees[idx+1] = deepcopy(temp)
self:RebuildAssigneeItems()
end
end
function FasterLootPlus:OnMoveAssigneeUp( wndHandler, wndControl, eMouseButton )
local size = #self.state.currentAssignees
local par = wndHandler:GetParent()
local idx = par:GetData()
if idx > 1 then
local temp = deepcopy(self.state.currentAssignees[idx])
self.state.currentAssignees[idx] = deepcopy(self.state.currentAssignees[idx-1])
self.state.currentAssignees[idx-1] = deepcopy(temp)
self:RebuildAssigneeItems()
end
end
---------------------------------------------------------------------------------------------------
-- FasterLootPlus UI Maintenance Functions
---------------------------------------------------------------------------------------------------
function FasterLootPlus:ClearAssigneeItems()
self:DestroyWindowList(self.state.listItems.assignees)
end
function FasterLootPlus:AddAssigneeItem(index, item)
local wnd = Apollo.LoadForm(self.xmlDoc, "AssigneeListItem", self.state.windows.assigneeList, self)
wnd:SetData(index)
wnd:SetText(item)
table.insert(self.state.listItems.assignees, wnd)
end
function FasterLootPlus:RebuildAssigneeItems()
-- Only rebuild if the Assignee list is showing
local vScrollPos = self.state.windows.assigneeList:GetVScrollPos()
self:SaveLocation()
if self.state.windows.assigneeList then
self:ClearAssigneeItems()
for idx,item in ipairs(self.state.currentAssignees) do
self:AddAssigneeItem(idx, item)
end
self.state.windows.assigneeList:ArrangeChildrenVert()
end
self.state.windows.assigneeList:SetVScrollPos(vScrollPos)
end