From a3bbf6d21da49665c3b9d36853956e586975fd5e Mon Sep 17 00:00:00 2001 From: Dolgubon Date: Sat, 2 May 2020 20:01:19 -0400 Subject: [PATCH] Add Multicrafting Fix Favourites selecting wrong weight class Remove N/A for style for jewelry items Add request to chat option Add option to hide favourites window API Bump --- .gitignore | 2 ++ Crafter.lua | 59 ++++++++++++++++++++++++++----------- DolgubonsLazySetCrafter.txt | 4 +-- Favourites.lua | 10 ++++--- Lang/en.lua | 45 ++++++++++++++-------------- Mail.lua | 50 +++++-------------------------- RightClick.lua | 38 ++++++++++++++++++++++++ SetCrafter.lua | 7 +++-- SetCrafterXMLUI.xml | 12 +++++++- SettingsMenu.lua | 11 +++++++ SetupDropdowns.lua | 5 ++-- SetupScrollLists.lua | 56 +++++++++++++++++++++++++++++++++-- Templates.xml | 7 +++-- 13 files changed, 207 insertions(+), 99 deletions(-) create mode 100644 .gitignore create mode 100644 RightClick.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03a576d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.zip diff --git a/Crafter.lua b/Crafter.lua index 322e2c1..9d1ec3c 100644 --- a/Crafter.lua +++ b/Crafter.lua @@ -268,17 +268,27 @@ local function addRequirements(returnedTable, addAmounts) local parity = -1 if addAmounts then parity = 1 end local requirements = LazyCrafter:getMatRequirements(returnedTable) - for itemId, amount in pairs(requirements) do local link = getItemLinkFromItemId(itemId) local bag, bank, craft = GetItemLinkStacks(link) + if GetItemLinkCraftingSkillType(link) == CRAFTING_TYPE_ENCHANTING then + if returnedTable.type=="improvement" then + amount = 0 + else + amount = amount*parity + end + else + amount = amount*parity*(returnedTable.smithingQuantity or 1) + end if DolgubonSetCrafter.materialList[itemId] then - DolgubonSetCrafter.materialList[itemId]["Amount"] = DolgubonSetCrafter.materialList[itemId]["Amount"] + amount*parity + DolgubonSetCrafter.materialList[itemId]["Amount"] = DolgubonSetCrafter.materialList[itemId]["Amount"] + amount DolgubonSetCrafter.materialList[itemId]["Current"] = bag + bank + craft else - DolgubonSetCrafter.materialList[itemId] = {["Name"] = link ,["Amount"] = amount*parity,["Current"] = bag + bank + craft } + DolgubonSetCrafter.materialList[itemId] = {["Name"] = link ,["Amount"] = amount,["Current"] = bag + bank + craft } + end + if DolgubonSetCrafter.materialList[itemId]["Amount"] <= 0 then + DolgubonSetCrafter.materialList[itemId] = nil end - if DolgubonSetCrafter.materialList[itemId]["Amount"] <= 0 then DolgubonSetCrafter.materialList[itemId] = nil end end end @@ -293,7 +303,7 @@ function DolgubonSetCrafter.recompileMatRequirements() for station, stationQueue in pairs( LazyCrafter.personalQueue) do for queuePosition, request in pairs(stationQueue) do - if not (station == CRAFTING_TYPE_ENCHANTING and not request.equipCreated) then + if (request.smithingQuantity == 0) or not (station == CRAFTING_TYPE_ENCHANTING ) then addRequirements(request, true) end end @@ -328,7 +338,7 @@ local function addToQueue(requestTable, craftMultiplier ) -- double checking one final time if pattern and isCP ~= nil and level and (styleIndex or station == CRAFTING_TYPE_JEWELRYCRAFTING) and trait and station and setIndex and quality then craftMultiplier = math.max(math.floor(craftMultiplier), 1) -- Make it an integer, also make it minimum of 1 - for i = 1, craftMultiplier do + -- for i = 1, craftMultiplier do -- First, create a deep(er) copy. Tables only go down one deep so that's max depth we need to copy local requestTableCopy = oneDeepCopy(requestTable) -- increment counter for unique reference @@ -348,6 +358,11 @@ local function addToQueue(requestTable, craftMultiplier ) quality, DolgubonSetCrafter:GetAutocraft(), requestTableCopy["Reference"], + nil, + nil, + nil, + craftMultiplier + } local returnedTable = LazyCrafter:CraftSmithingItemByLevel(unpack(CraftRequestTable)) @@ -358,9 +373,9 @@ local function addToQueue(requestTable, craftMultiplier ) requestTable["Enchant"][1], requestTable["EnchantQuality"] , DolgubonSetCrafter:GetAutocraft(), requestTableCopy["Reference"], returnedTable) - table.insert(CraftRequestTable,enchantRequestTable.potencyItemID) - table.insert(CraftRequestTable,enchantRequestTable.essenceItemID) - table.insert(CraftRequestTable,enchantRequestTable.aspectItemID) + CraftRequestTable[12] = enchantRequestTable.potencyItemID + CraftRequestTable[13] = enchantRequestTable.essenceItemID + CraftRequestTable[14] = enchantRequestTable.aspectItemID else requestTableCopy["Enchant"] = "" requestTableCopy["EnchantQuality"] =1 @@ -385,7 +400,7 @@ local function addToQueue(requestTable, craftMultiplier ) queue[#queue+1] = requestTableCopy end end - end + -- end end local function addPatternToQueue(patternButton,i) @@ -484,6 +499,7 @@ local function addPatternToQueue(patternButton,i) -- Some names are just so long, we need to shorten it shortenNames(requestTable) local craftMultiplier = DolgubonSetCrafter:GetMultiplier() + requestTable["Quantity"] = {craftMultiplier, tostring(craftMultiplier).."x"} addToQueue(requestTable, craftMultiplier) end local weaponTypes={ @@ -703,7 +719,7 @@ function DolgubonSetCrafter.craftConfirm() DolgubonSetCrafterConfirm:SetHidden(false) end -function DolgubonSetCrafter.removeFromScroll(reference, resultTable) +function DolgubonSetCrafter.removeFromScroll(reference, removeFromLLC, resultTable) local requestTable = LazyCrafter:findItemByReference(reference)[1] or resultTable @@ -720,12 +736,18 @@ function DolgubonSetCrafter.removeFromScroll(reference, resultTable) for k, v in pairs(queue) do if v.Reference == reference then - table.remove(queue,k) + if (v.Quantity and v.Quantity[1] or 1) >1 then + v.Quantity[1] = v.Quantity[1] - 1 + v.Quantity[2] = v.Quantity[1].."x" + else + table.remove(queue,k) + end end end if removalFunction then removalFunction() - else + end + if removeFromLLC then LazyCrafter:cancelItemByReference(reference) end @@ -734,21 +756,20 @@ function DolgubonSetCrafter.removeFromScroll(reference, resultTable) end -local function LLCCraftCompleteHandler(event, station, resultTable) +local function LLCCraftCompleteHandler(event, station, resultTable) if event ==LLC_CRAFT_SUCCESS then if resultTable.type == "improvement" then resultTable.station = GetRearchLineInfoFromRetraitItem(BAG_BACKPACK, resultTable.ItemSlotID) end - DolgubonSetCrafter.removeFromScroll(resultTable.reference, resultTable) + DolgubonSetCrafter.removeFromScroll(resultTable.reference,false, resultTable) elseif event == LLC_INITIAL_CRAFT_SUCCESS or event == LLC_CRAFT_PARTIAL_IMPROVEMENT then - -- DolgubonSetCrafter.recompileMatRequirements() DolgubonSetCrafter.updateList() end end function DolgubonSetCrafter.clearQueue() for i = #queue, 1, -1 do - DolgubonSetCrafter.removeFromScroll(queue[i].Reference) + DolgubonSetCrafter.removeFromScroll(queue[i].Reference, true) end end @@ -887,7 +908,9 @@ end function DolgubonSetCrafter.isRequestInProgressByReference(referenceId) local requestTable = LazyCrafter:findItemByReference(referenceId) - return requestTable and requestTable[1] and (requestTable[1].equipCreated or requestTable[1].glyphCreated) + local equipInProgress = requestTable[1].equipInfo and #requestTable[1].equipInfo > 0 + local glyphInProgress = requestTable[1].glyphInfo and #requestTable[1].glyphInfo > 0 + return requestTable and requestTable[1] and (equipInProgress or glyphInProgress) end function DolgubonSetCrafter.AddSmithingRequestWithReference(pattern, isCP, level, styleIndex, traitIndex, useUniversalStyleItem, station, setIndex, quality, autocraft, optionalReference, optionalCraftingObject) diff --git a/DolgubonsLazySetCrafter.txt b/DolgubonsLazySetCrafter.txt index 167faf9..84e852e 100644 --- a/DolgubonsLazySetCrafter.txt +++ b/DolgubonsLazySetCrafter.txt @@ -5,12 +5,12 @@ ; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms ## Title: Dolgubon's Lazy Set Crafter v2.5.0 -## APIVersion: 100030 +## APIVersion: 100030 100031 ## Author: Dolgubon ## Version: 2.5.0 ## SavedVariables: dolgubonslazysetcraftersavedvars ## DependsOn: LibLazyCrafting LibAddonMenu-2.0 -## OptionalDependsOn: pChat LibFeedback LibCustomMenu LibPrice LibStub +## OptionalDependsOn: pChat LibFeedback LibCustomMenu LibPrice LibStub ; Libraries diff --git a/Favourites.lua b/Favourites.lua index 13661da..f9b7dba 100644 --- a/Favourites.lua +++ b/Favourites.lua @@ -61,7 +61,6 @@ local function addFavourite() table.insert(faveTable.selectedPatterns, {name = DolgubonSetCrafter.patternButtons[i].tooltip, id = i}) end end - local comboBoxes = DolgubonSetCrafter.ComboBox addComboBoxValueToFavourite(faveTable, "set", comboBoxes.Set) @@ -89,10 +88,13 @@ local function addFavourite() end - local weightId = DolgubonSetCrafter.armourTypes.weight - + local weightId = DolgubonSetCrafter:GetWeight() + if weightId == 1 then + weightId = 3 + elseif weightId == 3 then + weightId = 1 + end faveTable.weight = {name = DolgubonSetCrafter.armourTypes[weightId].tooltip, id = weightId} - faveTable.id = GetTimeStamp() -- Will get a unique ID based on time. table.insert(DolgubonSetCrafter.savedvars.faves, faveTable) diff --git a/Lang/en.lua b/Lang/en.lua index e1968c2..9ca7208 100644 --- a/Lang/en.lua +++ b/Lang/en.lua @@ -63,24 +63,25 @@ DolgubonSetCrafter.localizedStrings.SettingsStrings.useCharacterSettingsTooltip DolgubonSetCrafter.localizedStrings.SettingsStrings.showToggleButton = "Always show toggle button" DolgubonSetCrafter.localizedStrings.SettingsStrings.showToggleButtonTooltip = "Show the UI toggle button at all times" - +DolgubonSetCrafter.localizedStrings.SettingsStrings.showFavourites = "Favourites Window" +DolgubonSetCrafter.localizedStrings.SettingsStrings.showFavouritesTooltip = "Show the Favourites Window when the Set Crafter UI is visible" DolgubonSetCrafter.localizedStrings.weaponNames = { - "Axe", "Mace", "Sword", "Battle Axe", "Maul", "Greatsword", "Dagger", "Bow", "Fire Staff", "Ice Staff", "Lightning Staff", "Restoration Staff", "Shield" + "Axe", "Mace", "Sword", "Battle Axe", "Maul", "Greatsword", "Dagger", "Bow", "Fire Staff", "Ice Staff", "Lightning Staff", "Restoration Staff", "Shield" } DolgubonSetCrafter.localizedStrings.pieceNames = { - "Chest","Feet","Hands","Head","Legs","Shoulders","Belt","Jerkin", + "Chest","Feet","Hands","Head","Legs","Shoulders","Belt","Jerkin", } DolgubonSetCrafter.localizedStrings.jewelryNames = { - "Ring" , "Ring", "Necklace", + "Ring" , "Ring", "Necklace", } DolgubonSetCrafter.localizedStrings.armourTypes = { - "Heavy", "Medium", "Light" + "Heavy", "Medium", "Light" } ZO_CreateStringId("SI_BINDING_NAME_SET_CRAFTER_OPEN", "Open/close the Set Crafter") @@ -95,27 +96,27 @@ ZO_CreateStringId("SI_BINDING_NAME_SET_CRAFTER_OPEN", "Open/close the Set Crafte -- Number of items in queue --[[ function FurC.LoadFrameInfo() - local settings = FurC.settings["gui"] + local settings = FurC.settings["gui"] - FurC_GUI:ClearAnchors() - FurC_GUI:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, settings["lastX"], settings["lastY"]) + FurC_GUI:ClearAnchors() + FurC_GUI:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, settings["lastX"], settings["lastY"]) - FurC_GUI:SetWidth(settings["width"]) - FurC_GUI:SetHeight(settings["height"]) + FurC_GUI:SetWidth(settings["width"]) + FurC_GUI:SetHeight(settings["height"]) - zo_callLater(function() FurC.UpdateInventoryScroll() end, 100) + zo_callLater(function() FurC.UpdateInventoryScroll() end, 100) end function FurC.SaveFrameInfo() - local settings = FurC.settings["gui"] + local settings = FurC.settings["gui"] - settings["lastX"] = FurC_GUI:GetLeft() - settings["lastY"] = FurC_GUI:GetTop() - settings["width"] = FurC_GUI:GetWidth() - settings["height"] = FurC_GUI:GetHeight() + settings["lastX"] = FurC_GUI:GetLeft() + settings["lastY"] = FurC_GUI:GetTop() + settings["width"] = FurC_GUI:GetWidth() + settings["height"] = FurC_GUI:GetHeight() - FurC.UpdateInventoryScroll() + FurC.UpdateInventoryScroll() end @@ -123,12 +124,12 @@ manavortex @manavortex 04:40 The suggestion was to clear the two "clear xx" buttons away in favour of a little x in a circle or so And it's resizeable because ]] diff --git a/Mail.lua b/Mail.lua index 0b114b9..11f1f62 100644 --- a/Mail.lua +++ b/Mail.lua @@ -104,19 +104,22 @@ function DolgubonSetCrafter.mailAllMats(destinationOverride) end -- Convert the current request to a readable format -local function convertRequest(curReq) +function DolgubonSetCrafter.convertRequestToText(curReq) local pattern = curReq["Pattern"] and curReq["Pattern"][2] or "N/A" local level = curReq["Level"] and curReq["Level"][2] or "N/A" if not curReq.CraftRequestTable[2] then level = "lvl "..level end - local style = curReq["Style"] and curReq["Style"][2] or "N/A" + local style = curReq["Style"] and curReq["Style"][2] or "" local trait = curReq["Trait"] and curReq["Trait"][2] or "N/A" local quality = curReq["Quality"] and curReq["Quality"][2] or "N/A" local itemLink = curReq.Link - - return itemLink.." | "..level.." | "..style.." | "..trait.." | "..quality + if style == "" then + return itemLink..", "..level..", "..trait..", "..quality + else + return itemLink..", "..level..", "..style..", "..trait..", "..quality + end end -- Reads mail. If it contain the right format, give a button to import it. @@ -174,11 +177,9 @@ function DolgubonSetCrafter.MailAsRequest(destinationOverride) sets[setName] = {} table.insert(setTypes, setName) -- Save this index of this set's name end - table.insert(sets[setName], convertRequest(request)) -- Store the readable crafting information + table.insert(sets[setName], convertRequestToText(request)) -- Store the readable crafting information end for setName, requestInfos in pairs(sets) do - -- local setHeader = "-- "..setName.." --" - -- table.insert(mailInfo, {text=setHeader.."\n"..requestInfos[1], set=setName}) for i = 1, #requestInfos do table.insert(mailInfo, {text=requestInfos[i], set=setName}) end @@ -191,41 +192,6 @@ function DolgubonSetCrafter.MailAsRequest(destinationOverride) if true then return end - - local DSC = DolgubonSetCrafter - - - -- Constants - local SUBJECT = 'Crafting Request' - - local bodyText = "" -- Holds the message for the mail - - for i, setName in ipairs(setTypes) do - local setHeader = "-- "..setName.." --" - - -- Each set's header being appended - if bodyText == "" then - bodyText = setHeader - else - bodyText = bodyText.."\n\n"..setHeader - end - - -- Each item under a specific set name - for _, item in pairs(sets[setName]) do - if #bodyText + 1 + #item >700 then end - bodyText = bodyText.."\n"..item - end - end - RequestOpenMailbox() - SendMail(destination, SUBJECT, bodyText) - zo_callLater(CloseMailbox, 300) - -- Prep the mailbox - -- SCENE_MANAGER:Show('mailSend') - -- zo_callLater(function() - -- ZO_MailSendToField:SetText(destination) - -- ZO_MailSendSubjectField:SetText(SUBJECT) - -- ZO_MailSendBodyField:SetText(bodyText) - -- ZO_MailSendBodyField:TakeFocus() end, 200) end diff --git a/RightClick.lua b/RightClick.lua new file mode 100644 index 0000000..9698ec6 --- /dev/null +++ b/RightClick.lua @@ -0,0 +1,38 @@ + + + + +DolgubonSetCrafter = DolgubonSetCrafter or {} + + +function DolgubonSetCrafter.InventorySlot_ShowContextMenu(rowControl) + local bag, slot = ZO_Inventory_GetBagAndIndex(rowControl) + + local link = GetItemLink(bag, slot) + + if link then + zo_callLater(function () + AddCustomMenuItem("Improve Item", function () + CHAT_SYSTEM:AddMessage(GetItemLink(bag, slot) .. " is located at bag #"..bag.." and slot #"..slot) + + end, MENU_ADD_OPTION_LABEL) + ShowMenu(self) + end, 50) + end +end + +function DolgubonSetCrafter.InitializeRightClick() + ZO_PreHook('ZO_InventorySlot_ShowContextMenu', function (rowControl) DolgubonSetCrafter.InventorySlot_ShowContextMenu(rowControl) end) +end + + + + + + + + + + + + diff --git a/SetCrafter.lua b/SetCrafter.lua index f909c21..d190061 100644 --- a/SetCrafter.lua +++ b/SetCrafter.lua @@ -34,6 +34,7 @@ DolgubonSetCrafter.default = { ['width'] = DolgubonSetCrafter.defaultWidth, ['height'] = DolgubonSetCrafter.defaultHeight, ['faves'] = {}, + ['showFavourites'] = true, } @@ -111,14 +112,14 @@ function DolgubonSetCrafter:Initialize() DolgubonSetCrafter.initializeFunctions.setupUI() --DolgubonSetCrafter.initializeFeedbackWindow() - LibFeedback = LibStub:GetLibrary("LibFeedback") + local LibFeedback = LibStub:GetLibrary("LibFeedback") local button, window = LibFeedback:initializeFeedbackWindow(DolgubonSetCrafter, "Dolgubon's Lazy Set Crafter",DolgubonSetCrafterWindow, "@Dolgubon", {TOPLEFT , DolgubonSetCrafterWindow , TOPLEFT , 10, 10}, {0,5000,50000, "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7CZ3LW6E66NAU"}, "If you found a bug, have a request or a suggestion, or wish to donate, you can send me a mail here.") window:SetHidden(true) - local currentAPIVersionOfAddon = 100030 + local currentAPIVersionOfAddon = 100031 if GetAPIVersion() > currentAPIVersionOfAddon and GetWorldName()~="PTS" then d("Update your addons!") @@ -136,8 +137,10 @@ function DolgubonSetCrafter:Initialize() if DolgubonSetCrafter.savedvars.debug then DolgubonSetCrafterWindow:SetHidden(false) DolgubonSetCrafterWindowRightInputBox:SetText("@Dolgubonn") + DolgubonSetCrafter.updateList() end DolgubonSetCrafter.initializeMailButtons() + DolgubonSetCrafterWindowFavourites:SetHidden(not DolgubonSetCrafter:GetSettings().showFavourites) end local function closeWindow (optionalOverride) diff --git a/SetCrafterXMLUI.xml b/SetCrafterXMLUI.xml index a71d5d3..dd1191c 100644 --- a/SetCrafterXMLUI.xml +++ b/SetCrafterXMLUI.xml @@ -43,6 +43,7 @@ Created by Dolgubon (Joseph Heinzle)