Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Seerah-7 | --localize |
2 | Seerah-7 | --add queuing system for multiple items |
|
3 | Seerah-7 | --collect all enchant ids & remove need for dropdown |
|
4 | Seerah-7 | ||
5 | Seerah-7 | -- ESOutpost © ZAM Network LLC |
|
6 | Seerah-7 | -- All Rights Reserved |
|
7 | Seerah-7 | ||
8 | Seerah-7 | local wm = GetWindowManager() |
|
9 | Seerah-7 | local strformat = string.format |
|
10 | Seerah-7 | local IsItemBound = IsItemBound |
|
11 | Seerah-7 | local ZO_Alert = ZO_Alert |
|
12 | Seerah-7 | local M = ESOutpostMaps |
|
13 | Seerah-7 | local gui = ESOutpostGUI |
|
14 | Seerah-7 | local dataForString = {} |
|
15 | Seerah-7 | local server |
|
16 | Seerah-7 | ||
17 | Seerah-7 | ||
18 | Seerah-7 | local function strsplit(inputstr, sep) |
|
19 | 5 | Seerah-7 | local t, i = {}, 1 |
20 | Seerah-7 | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do |
|
21 | Seerah-7 | t[i] = str |
|
22 | Seerah-7 | i = i + 1 |
|
23 | Seerah-7 | end |
|
24 | 2 | Seerah-7 | |
25 | 5 | Seerah-7 | return t |
26 | 2 | Seerah-7 | end |
27 | Seerah-7 | ||
28 | Seerah-7 | local function RGBPercToHex(r,g,b) |
|
29 | Seerah-7 | r = r <= 1 and r >= 0 and r or 0 |
|
30 | Seerah-7 | g = g <= 1 and g >= 0 and g or 0 |
|
31 | Seerah-7 | b = b <= 1 and b >= 0 and b or 0 |
|
32 | Seerah-7 | return string.format("%02x%02x%02x", r*255, g*255, b*255) |
|
33 | Seerah-7 | end |
|
34 | Seerah-7 | ||
35 | Seerah-7 | local function wipe(tbl) |
|
36 | Seerah-7 | for k,v in pairs(tbl) do |
|
37 | Seerah-7 | k = nil |
|
38 | Seerah-7 | end |
|
39 | Seerah-7 | end |
|
40 | Seerah-7 | ||
41 | Seerah-7 | local function DataIsComplete() |
|
42 | Seerah-7 | local missingText = "|cC5C29EESO|rutpost: Your data is not complete." |
|
43 | Seerah-7 | local isComplete |
|
44 | Seerah-7 | if not gui.lvlNum:IsHidden() and gui.lvlNum:GetText() == "" then |
|
45 | Seerah-7 | --d("missing level") |
|
46 | Seerah-7 | isComplete = false |
|
47 | Seerah-7 | elseif not gui.traitValuebg:IsHidden() and gui.traitValue:GetText() == "" then |
|
48 | Seerah-7 | --d("missing traitvalue") |
|
49 | Seerah-7 | isComplete = false |
|
50 | Seerah-7 | elseif not gui.enchant:IsHidden() and gui.enchant.dropdown:GetSelectedItem() == "Select Enchant" then |
|
51 | Seerah-7 | --d("missing enchant") |
|
52 | Seerah-7 | isComplete = false |
|
53 | Seerah-7 | elseif (not gui.enchantValueXbg:IsHidden() and gui.enchantValueX:GetText() == "") or (not gui.enchantValueYbg:IsHidden() and gui.enchantValueY:GetText() == "") then |
|
54 | Seerah-7 | --d("missing enchantvalue") |
|
55 | Seerah-7 | isComplete = false |
|
56 | Seerah-7 | else |
|
57 | Seerah-7 | --d("data complete!") |
|
58 | Seerah-7 | isComplete = true |
|
59 | Seerah-7 | end |
|
60 | Seerah-7 | if isComplete then |
|
61 | Seerah-7 | return true |
|
62 | Seerah-7 | else |
|
63 | Seerah-7 | ZO_Alert(nil, SOUNDS.SKILL_GAINED, missingText) |
|
64 | Seerah-7 | return false |
|
65 | Seerah-7 | end |
|
66 | Seerah-7 | end |
|
67 | Seerah-7 | ||
68 | Seerah-7 | local function GenerateString() |
|
69 | Seerah-7 | if not DataIsComplete() then |
|
70 | Seerah-7 | return |
|
71 | Seerah-7 | else |
|
72 | Seerah-7 | gui.genstring:SetText("Generating String") |
|
73 | Seerah-7 | ||
74 | Seerah-7 | dataForString[5] = (gui.lvlNum.vr and "VR" or "")..gui.lvlNum:GetText() |
|
75 | 8 | Seerah-7 | dataForString[12] = gui.traitValue:GetText() |
76 | Seerah-7 | dataForString[13] = gui.enchant.hash |
|
77 | Seerah-7 | dataForString[14] = gui.enchantValueX:GetText() |
|
78 | Seerah-7 | dataForString[15] = gui.enchantValueY:GetText() |
|
79 | 2 | Seerah-7 | |
80 | Seerah-7 | gui.genstring:SetText(table.concat(dataForString, ":")) |
|
81 | Seerah-7 | gui.copy:SetEnabled(true) |
|
82 | Seerah-7 | end |
|
83 | Seerah-7 | end |
|
84 | Seerah-7 | gui.generate:SetHandler("OnClicked", GenerateString) |
|
85 | Seerah-7 | ||
86 | Seerah-7 | local function ItemTraitToggle(hasTrait, hasStatValue, stat) |
|
87 | Seerah-7 | gui.trait:ClearAnchors() |
|
88 | Seerah-7 | if not hasStatValue then |
|
89 | Seerah-7 | gui.trait:SetAnchor(LEFT, gui.statValue, LEFT) |
|
90 | Seerah-7 | else |
|
91 | Seerah-7 | gui.trait:SetAnchor(LEFT, gui.statValue, RIGHT, 20, 0) |
|
92 | Seerah-7 | end |
|
93 | Seerah-7 | gui.traitValue:Clear() |
|
94 | Seerah-7 | gui.traitValuebg:SetHidden(not hasTrait) |
|
95 | Seerah-7 | end |
|
96 | Seerah-7 | ||
97 | Seerah-7 | local canShowEnchants = {[ITEMTYPE_WEAPON] = true, [ITEMTYPE_ARMOR] = true, [ITEMTYPE_GLYPH_WEAPON] = true, [ITEMTYPE_GLYPH_JEWELRY] = true, [ITEMTYPE_GLYPH_ARMOR] = true} |
|
98 | Seerah-7 | local function EnchantToggle(rawItemType, weaponType, equipType, isLocked) |
|
99 | Seerah-7 | if canShowEnchants[rawItemType] then |
|
100 | Seerah-7 | gui.enchant:SetHidden(false) |
|
101 | Seerah-7 | gui.enchant.dropdown:ClearItems() |
|
102 | Seerah-7 | local enchants |
|
103 | Seerah-7 | if equipType == EQUIP_TYPE_RING or equipType == EQUIP_TYPE_NECK or rawItemType == ITEMTYPE_GLYPH_JEWELRY then |
|
104 | Seerah-7 | enchants = M.jewelryEnchants |
|
105 | Seerah-7 | elseif rawItemType == ITEMTYPE_ARMOR or weaponType == "shield" or rawItemType == ITEMTYPE_GLYPH_ARMOR then |
|
106 | Seerah-7 | enchants = M.armorEnchants |
|
107 | Seerah-7 | else |
|
108 | Seerah-7 | enchants = M.weaponEnchants |
|
109 | Seerah-7 | end |
|
110 | Seerah-7 | for i=1,#enchants do |
|
111 | Seerah-7 | local entry = gui.enchant.dropdown:CreateItemEntry(enchants[i].text, gui.enchant.callback) |
|
112 | Seerah-7 | entry.vars = enchants[i].vars |
|
113 | Seerah-7 | entry.hash = enchants[i].hash |
|
114 | Seerah-7 | gui.enchant.dropdown:AddItem(entry, ZO_COMBOBOX_SUPRESS_UPDATE) |
|
115 | Seerah-7 | end |
|
116 | Seerah-7 | else |
|
117 | Seerah-7 | gui.enchant:SetHidden(true) |
|
118 | Seerah-7 | end |
|
119 | Seerah-7 | gui.enchant.dropdown:SetSelectedItem("Select Enchant") |
|
120 | Seerah-7 | gui.enchantValueX:Clear() |
|
121 | Seerah-7 | gui.enchantValueY:Clear() |
|
122 | Seerah-7 | gui.enchantValueXbg:SetHidden(true) |
|
123 | Seerah-7 | gui.enchantValueYbg:SetHidden(true) |
|
124 | Seerah-7 | gui.enchant.type = "" |
|
125 | Seerah-7 | gui.enchant.hash = "" |
|
126 | Seerah-7 | if isLocked then |
|
127 | Seerah-7 | gui.locked:SetDimensions(16, 16) |
|
128 | Seerah-7 | else |
|
129 | Seerah-7 | gui.locked:SetDimensions(0, 0) |
|
130 | Seerah-7 | end |
|
131 | Seerah-7 | end |
|
132 | Seerah-7 | ||
133 | Seerah-7 | local function CanCollectData(control, silent) |
|
134 | Seerah-7 | if control == GuiRoot then return end |
|
135 | Seerah-7 | if not M.server[server] then |
|
136 | Seerah-7 | if not silent then |
|
137 | Seerah-7 | ZO_Alert(nil, SOUNDS.SKILL_GAINED, "|cC5C29EESO|rutpost: You must be on either the NA or EU Megaserver to sell an item through |cC5C29EESO|rutpost.") |
|
138 | Seerah-7 | end |
|
139 | Seerah-7 | return false |
|
140 | Seerah-7 | elseif control.bagId == 0 then |
|
141 | Seerah-7 | if not silent then |
|
142 | Seerah-7 | ZO_Alert(nil, SOUNDS.SKILL_GAINED, "|cC5C29EESO|rutpost: You cannot appraise an item that is equipped.") |
|
143 | Seerah-7 | end |
|
144 | Seerah-7 | return false |
|
145 | Seerah-7 | elseif control:GetParent() == ZO_BuyBackListContents or control:GetParent() == ZO_StoreWindowListContents then |
|
146 | Seerah-7 | if not silent then |
|
147 | Seerah-7 | ZO_Alert(nil, SOUNDS.SKILL_GAINED, "|cC5C29EESO|rutpost: You cannot appraise an item from this window.") |
|
148 | Seerah-7 | end |
|
149 | Seerah-7 | return false |
|
150 | Seerah-7 | elseif not control.dataEntry or not control.dataEntry.data or not control.dataEntry.data.bagId then |
|
151 | Seerah-7 | return false |
|
152 | Seerah-7 | elseif IsItemBound(control.dataEntry.data.bagId, control.dataEntry.data.slotIndex) then |
|
153 | Seerah-7 | if not silent then |
|
154 | Seerah-7 | ZO_Alert(nil, SOUNDS.SKILL_GAINED, "|cC5C29EESO|rutpost: You cannot sell that item.") |
|
155 | Seerah-7 | end |
|
156 | Seerah-7 | return false |
|
157 | Seerah-7 | else |
|
158 | Seerah-7 | return true |
|
159 | Seerah-7 | end |
|
160 | Seerah-7 | end |
|
161 | Seerah-7 | ||
162 | Seerah-7 | function CollectESOutpostItemData() --global - keybound function |
|
163 | Seerah-7 | local control = moc() |
|
164 | Seerah-7 | if control.outpostBtn then control = control.row end |
|
165 | Seerah-7 | if not CanCollectData(control) then return end |
|
166 | Seerah-7 | ||
167 | Seerah-7 | local controlData = control.dataEntry.data |
|
168 | Seerah-7 | local bagId = controlData.bagId |
|
169 | Seerah-7 | local slotIndex = controlData.slotIndex |
|
170 | Seerah-7 | ||
171 | Seerah-7 | gui.tooltip:ClearLines() |
|
172 | Seerah-7 | gui.tooltip:SetBagItem(bagId, slotIndex) |
|
173 | Seerah-7 | wipe(dataForString) |
|
174 | Seerah-7 | gui.genstring:Clear() |
|
175 | Seerah-7 | gui.copy:SetEnabled(false) |
|
176 | Seerah-7 | ||
177 | 5 | Seerah-7 | local link = GetItemLink(bagId, slotIndex) |
178 | Seerah-7 | local itemLinkData = strsplit(link, ":") |
|
179 | 2 | Seerah-7 | local icon, stack, _, _, locked, equipType, itemStyle, quality = GetItemInfo(bagId, slotIndex) |
180 | Seerah-7 | local soundCat = GetItemSoundCategory(bagId, slotIndex) |
|
181 | Seerah-7 | ||
182 | Seerah-7 | PlayItemSound(soundCat, ITEM_SOUND_ACTION_SLOT) |
|
183 | Seerah-7 | ||
184 | Seerah-7 | gui.icon.texture:SetTexture(icon) |
|
185 | Seerah-7 | ||
186 | Seerah-7 | local name = controlData.name |
|
187 | Seerah-7 | gui.name:SetText(strformat("%s|c%s%s", stack>1 and "x"..stack.." " or "", RGBPercToHex(GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, quality)), name)) |
|
188 | Seerah-7 | ||
189 | Seerah-7 | local level = tonumber(itemLinkData[5]) |
|
190 | Seerah-7 | local isVeteran = level > 49 |
|
191 | Seerah-7 | gui.lvl:SetText(isVeteran and "|t32:32:EsoUI\\Art\\UnitFrames\\target_veteranrank_icon.dds|tRank" or "Level") |
|
192 | Seerah-7 | gui.lvlNum:SetText(isVeteran and GetItemLevel(bagId, slotIndex)-50-quality or level or 0) |
|
193 | Seerah-7 | gui.lvlNum.vr = isVeteran |
|
194 | Seerah-7 | ||
195 | Seerah-7 | local rawItemType = GetItemType(bagId, slotIndex) or "none" |
|
196 | Seerah-7 | local weaponType, armorType, itemType |
|
197 | Seerah-7 | if rawItemType == ITEMTYPE_WEAPON then |
|
198 | 6 | Seerah-7 | weaponType = GetItemWeaponType(bagId, slotIndex) |
199 | 5 | Seerah-7 | itemType = GetString("SI_WEAPONTYPE", weaponType) or "Weapon" |
200 | 2 | Seerah-7 | elseif rawItemType == ITEMTYPE_ARMOR then |
201 | 6 | Seerah-7 | armorType = GetItemArmorType(bagId, slotIndex) |
202 | 5 | Seerah-7 | itemType = GetString("SI_ARMORTYPE", armorType) |
203 | Seerah-7 | itemType = itemType and itemType.." Armor" or "Armor" |
|
204 | 2 | Seerah-7 | else |
205 | Seerah-7 | itemType = GetString("SI_ITEMTYPE", rawItemType) |
|
206 | Seerah-7 | end |
|
207 | Seerah-7 | local equipTypeText = GetString("SI_EQUIPTYPE", equipType) or "" |
|
208 | Seerah-7 | gui.type:SetText(strformat("%s%s", itemType, equipTypeText=="" and "" or " ("..equipTypeText..")")) |
|
209 | Seerah-7 | ||
210 | Seerah-7 | local statValue = controlData.statValue --or 0 |
|
211 | Seerah-7 | local rawTrait = GetItemTrait(bagId, slotIndex) |
|
212 | Seerah-7 | local trait = GetString("SI_ITEMTRAITTYPE", rawTrait) |
|
213 | Seerah-7 | gui.statValue:SetText(statValue>0 and strformat("%s %d", (weaponType == "shield" and "Armor") or (rawItemType == ITEMTYPE_WEAPON and "Damage") or (rawItemType == ITEMTYPE_ARMOR and "Armor"), statValue) or "") |
|
214 | Seerah-7 | gui.trait:SetText(rawTrait>0 and trait or "") |
|
215 | Seerah-7 | ItemTraitToggle(rawTrait>0, statValue>0, statValue) |
|
216 | Seerah-7 | ||
217 | Seerah-7 | EnchantToggle(rawItemType, weaponType, equipType, locked) |
|
218 | Seerah-7 | ||
219 | Seerah-7 | dataForString = { |
|
220 | Seerah-7 | [1] = name:gsub(":", [[\58]]), |
|
221 | Seerah-7 | [2] = M.itemQuality[quality], |
|
222 | Seerah-7 | [3] = stack, |
|
223 | Seerah-7 | [4] = icon:sub(18, -5), --only the file name of the icon, not the whole path |
|
224 | Seerah-7 | [5] = "", --placeholder for level - double-check this number before generating the string |
|
225 | Seerah-7 | [6] = M.itemType[rawItemType] or "", |
|
226 | 5 | Seerah-7 | [7] = weaponType and M.weaponType[weaponType] or armorType and M.armorType[armorType] or "", |
227 | 2 | Seerah-7 | [8] = "", --"None" - placeholder for staffType |
228 | Seerah-7 | [9] = M.equipType[equipType] or "", |
|
229 | Seerah-7 | [10] = statValue or "", |
|
230 | Seerah-7 | [11] = M.traitType[rawTrait], |
|
231 | Seerah-7 | [12] = "", --placeholder for traitValue |
|
232 | Seerah-7 | [13] = "", --placeholder for enchant |
|
233 | Seerah-7 | [14] = "", --placeholder for enchant valueX |
|
234 | Seerah-7 | [15] = "", --placeholder for enchant valueY |
|
235 | Seerah-7 | [16] = locked and "l" or "u", |
|
236 | Seerah-7 | [17] = M.itemStyle[itemStyle] or "", |
|
237 | Seerah-7 | [18] = itemLinkData[3], --itemID |
|
238 | Seerah-7 | [19] = M.server[server] or "" |
|
239 | Seerah-7 | } |
|
240 | Seerah-7 | ||
241 | Seerah-7 | gui:SetHidden(false) |
|
242 | Seerah-7 | end |
|
243 | Seerah-7 | ||
244 | Seerah-7 | EVENT_MANAGER:RegisterForEvent("ESOutpost", EVENT_ADD_ON_LOADED, function(event, addon) |
|
245 | Seerah-7 | if addon == "ESOutpost" then |
|
246 | Seerah-7 | ZO_CreateStringId("SI_BINDING_NAME_ESOUTPOST_LINK", "Get ESOutpost Link") |
|
247 | Seerah-7 | ||
248 | Seerah-7 | local keybindStripDescriptor = { |
|
249 | Seerah-7 | alignment = KEYBIND_STRIP_ALIGN_RIGHT, |
|
250 | Seerah-7 | order = 1000, |
|
251 | Seerah-7 | name = "ESOutpost", |
|
252 | Seerah-7 | keybind = "ESOUTPOST_LINK", |
|
253 | Seerah-7 | callback = function(descriptor) CollectESOutpostItemData() end, |
|
254 | Seerah-7 | icon = "ESOutpost\\ESO-Outpost-Logo-Small.dds", |
|
255 | Seerah-7 | } |
|
256 | Seerah-7 | local keybindAdded |
|
257 | Seerah-7 | local function KeybindVisibility() |
|
258 | Seerah-7 | if CanCollectData(moc(), true) then |
|
259 | Seerah-7 | if not keybindAdded then |
|
260 | Seerah-7 | KEYBIND_STRIP:AddKeybindButton(keybindStripDescriptor) |
|
261 | Seerah-7 | keybindAdded = true |
|
262 | Seerah-7 | end |
|
263 | Seerah-7 | else |
|
264 | Seerah-7 | if keybindAdded then |
|
265 | Seerah-7 | KEYBIND_STRIP:RemoveKeybindButton(keybindStripDescriptor) |
|
266 | Seerah-7 | keybindAdded = false |
|
267 | Seerah-7 | end |
|
268 | Seerah-7 | end |
|
269 | Seerah-7 | end |
|
270 | 8 | Seerah-7 | KEYBIND_STRIP.keybinds["ESOUTPOST_LINK"] = nil --not sure why this is needed... |
271 | 2 | Seerah-7 | ZO_PlayerInventory:SetHandler("OnShow", function() |
272 | Seerah-7 | EVENT_MANAGER:RegisterForUpdate("ESOutpostKeybindVisibility", 100, KeybindVisibility) |
|
273 | Seerah-7 | end) |
|
274 | Seerah-7 | ZO_PlayerInventory:SetHandler("OnHide", function() |
|
275 | Seerah-7 | EVENT_MANAGER:RegisterForUpdate("ESOutpostKeybindVisibility") |
|
276 | Seerah-7 | end) |
|
277 | 8 | Seerah-7 | |
278 | 2 | Seerah-7 | gui:CreateInventoryButtons() |
279 | Seerah-7 | ||
280 | Seerah-7 | server = GetCVar("LastRealm") |
|
281 | Seerah-7 | end |
|
282 | Seerah-7 | end) |