forked from Randactyl/ItemSaver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.lua
More file actions
126 lines (105 loc) · 3.88 KB
/
API.lua
File metadata and controls
126 lines (105 loc) · 3.88 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
local IS = ItemSaver
local util = IS.util
local settings = IS.settings
--returns true if the set was successfully registered.
--returns false if the set name is an empty string or already in use.
function ItemSaver_AddSet(setName, setData)
return settings.AddSet(setName, setData)
end
--returns the default set name
function ItemSaver_GetDefaultSet()
return settings.GetDefaultSet()
end
--if the given set exists, returns a table with the following keys: store,
--deconstruction, research, guildStore, mail, trade.
--each will have a value of true if they are filtered or false if they are not.
--if the set does not exist, returns nil
function ItemSaver_GetFilters(setName)
return settings.GetFilters(setName)
end
--returns preferred anchor position for markers.
function ItemSaver_GetMarkerAnchor()
return settings.GetMarkerAnchor()
end
--returns texturePath, r, g, b if the item is saved.
--returns nil if the item is not saved.
function ItemSaver_GetMarkerInfo(bagId, slotIndex)
return settings.GetMarkerInfo(bagId, slotIndex)
end
--returns array of the names of available markers.
function ItemSaver_GetMarkerOptions()
return util.markerOptions
end
--returns table with key/value pairs of markerName/markerPath
function ItemSaver_GetMarkerTextures()
return util.markerTextures
end
--returns an alphabetically sorted array of the names of available save sets.
function ItemSaver_GetSaveSets()
return settings.GetSaveSets()
end
--[[
returns a table with the full info of the provided set name.
returns nil if the set doesn't exist.
example:
setData = {
["markerColor"] = "ff0000",
["filterMail"] = true,
["filterResearch"] = true,
["filterGuildStore"] = true,
["filterDeconstruction"] = true,
["filterTrade"] = true,
["filterStore"] = true,
["markerTexture"] = "Two-Handed",
}
]]
function ItemSaver_GetSetData(setName)
return settings.GetSetData(setName)
end
--returns the string set name if the supplied index is 1 - 5
--returns nil if the supplied index is out of range or if no set has been
--assigned to that index
function ItemSaver_GetSetNameByKeybindIndex(index)
return settings.GetSetNameByKeybindIndex(index)
end
--returns true and the string set name if the item is saved. Returns false if
--the item is not saved.
function ItemSaver_IsItemSaved(bagId, slotIndex)
return settings.IsItemSaved(bagId, slotIndex)
end
--returns true and the maximum number of sets that will be shown without a
--submenu if submenu creation is deferred.
--returns false if submenu creation is not deferred.
function ItemSaver_IsSubmenuDeferred()
return settings.IsSubmenuDeferred()
end
--returns true if the marker was successfully registered, false if it was not.
function ItemSaver_RegisterMarker(markerInformation)
local markerName = markerInformation.markerName
if util.markerTextures[markerName] then
return false
end
util.markerTextures[markerName] = markerInformation.texturePath
table.insert(util.markerOptions, markerName)
return true
end
--returns true if item was saved successfully. Returns false if item was
--unsaved.
--if setName is a number from 1 - 5, the set corresponding to that keybind index
--will be used.
--if setName is nil, the default set will be used.
function ItemSaver_ToggleItemSave(setName, bagId, slotIndex)
if bagId == nil then --keybind
local mouseOverControl = WINDOW_MANAGER:GetMouseOverControl()
bagId, slotIndex = util.GetInfoFromRowControl(mouseOverControl)
if not bagId then
mouseOverControl = mouseOverControl:GetParent()
bagId, slotIndex = util.GetInfoFromRowControl(mouseOverControl)
end
end
if bagId then
local returnVal = settings.ToggleItemSave(setName, bagId, slotIndex)
util.RefreshAll()
return returnVal
end
end