forked from manavortex/DailyAutoShare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DASContextMenu.lua
115 lines (115 loc) · 4.24 KB
/
DASContextMenu.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
local guiHeight = GuiRoot:GetHeight()
local guiWidth = GuiRoot:GetWidth()
local function getAnchorPos(control)
local menuWidth = ZO_Menu:GetWidth()
local menuHeight = ZO_Menu:GetWidth()
local controlRight = control:GetRight()
local controlLeft = control:GetLeft()
local controlTop = control:GetTop()
local isTooHigh = (controlTop + menuHeight) >= guiHeight
if DAS.GetSettings().tooltipRight then
if (controlRight + menuWidth) >= guiWidth then
if isTooHigh then return BOTTOMRIGHT, TOPLEFT end
return TOPRIGHT, TOPLEFT
end
else
if (controlLeft - menuHeight) <= 0 then
if isTooHigh then return TOPLEFT, TOPRIGHT end
return TOPRIGHT, TOPLEFT
end
end
return TOPLEFT, TOPRIGHT
end
local function spamChat(questNameParam, bingoStringParam)
if DAS.GetAutoInvite() then
return DAS.SpamChat(questNameParam, bingoStringParam)
end
if CHAT_SYSTEM.textEntry.editControl:HasFocus() then
CHAT_SYSTEM.textEntry.editControl:Clear()
end
StartChatInput(bingoStringParam, CHAT_CHANNEL_ZONE)
end
local function forceAssist(journalIndex)
if nil == FOCUSED_QUEST_TRACKER then return end
FOCUSED_QUEST_TRACKER:ForceAssist(journalIndex)
end
local function shareQuest(journalIndex)
ShareQuest(journalIndex)
end
local function abandonQuest(journalIndex, questName)
AbandonQuest(journalIndex)
DAS.LogQuest(questName, false)
DAS.questCacheNeedsRefresh = true
DAS.RefreshLabelsWithDelay()
end
local function toggleQuest(control)
DAS.ToggleQuest(control)
DAS.RefreshLabelsWithDelay()
if control:IsChildOf(DasSubList) and DasSubList.dataCurrentList then
DAS.RefreshSubLabels(DasSubList.dataCurrentList)
end
end
local function toggleSubList(control)
local isHidden = DasSubList:IsHidden()
if (isHidden) then
DasSubList.dataCurrentList = control
DAS.SetSubLabels(control.dataQuestList)
end
DasSubList:SetHidden(not isHidden)
if (isHidden) then
DAS.setFontSize(DAS.sublabels)
end
end
function DAS.OnRightClick(control, verbose)
if nil == control then return end
local menuShowing = IsMenuVisible() and GetMenuOwner() == control
ClearMenu()
if not menuShowing then
SetMenuSpacing(3)
SetMenuPad(10)
SetMenuMinimumWidth(185)
if control.dataIsSubList then
AddCustomMenuItem(GetString(DAS_GUI_CTX_SUBLIST),
function() toggleSubList(control) end,
MENU_ADD_OPTION_LABEL
)
else
if control.dataQuestState ~= DAS_STATUS_COMPLETE then
AddCustomMenuItem(GetString(DAS_GUI_CTX_SPAM),
function() spamChat(control.dataQuestName, control.dataBingoString) end,
MENU_ADD_OPTION_LABEL
)
end
if IsValidQuestIndex(control.dataJournalIndex) then
AddCustomMenuItem(GetString(DAS_GUI_CTX_SHARE),
function() shareQuest(control.dataJournalIndex) end,
MENU_ADD_OPTION_LABEL
)
AddCustomMenuItem(GetString(DAS_GUI_CTX_TRACK),
function() forceAssist(control.dataJournalIndex) end,
MENU_ADD_OPTION_LABEL
)
AddCustomMenuItem(GetString(DAS_GUI_CTX_ABANDON),
function() abandonQuest(control.dataJournalIndex, control.dataQuestName) end,
MENU_ADD_OPTION_LABEL
)
else
local key = (control.dataQuestState == DAS_STATUS_OPEN and DAS_GUI_CTX_OPEN_TRUE) or DAS_GUI_CTX_OPEN_FALSE
AddCustomMenuItem(GetString(key),
function() toggleQuest(control) end,
MENU_ADD_OPTION_LABEL
)
end
end
local myAnchor, parentAnchor = getAnchorPos(control)
ZO_Menu:ClearAnchors()
ZO_Menu:SetAnchor(myAnchor, control, parentAnchor, 0, 3)
ShowMenu(control)
end
end
function DAS.InitRightclickMenu()
DAS_LinkHandlerBackup_OnLinkMouseUp = ZO_LinkHandler_OnLinkMouseUp
ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control) DAS_HandleClickEvent(itemLink, button, control) end
ZO_PreHook('ZO_InventorySlot_OnMouseEnter', DAS_HandleMouseEnter)
ZO_PreHook('ZO_InventorySlot_ShowContextMenu', function(rowControl) DAS_HandleInventoryContextMenu(rowControl) end)
end