diff --git a/FurCData.lua b/FurCData.lua index 550c612..1d23474 100644 --- a/FurCData.lua +++ b/FurCData.lua @@ -41,13 +41,6 @@ local function getItemLink(itemId) end FurC.GetItemLink = getItemLink -local function trySaveDevDebug(recipeArray) - if not (FurC.AccountName == "@manavortex" or FurC.AccountName == "@Manorin") then return end - if recipeArray.origin ~= FURC_DROP then return end - itemLink = (nil ~= recipeArray.blueprintLink and recipeArray.blueprintLink) or recipeArray.itemId - FurnitureCatalogue.devSettings[itemLink] = "true, -- " .. GetItemLinkName(itemLink) -end - local function addDatabaseEntry(recipeKey, recipeArray) if recipeKey and recipeArray and {} ~= recipeArray then FurC.settings.data[recipeKey] = recipeArray diff --git a/FurnitureCatalogue.txt b/FurnitureCatalogue.txt index 68b9540..ba1b680 100644 --- a/FurnitureCatalogue.txt +++ b/FurnitureCatalogue.txt @@ -1,6 +1,6 @@ ## Title: FurnitureCatalogue ## Author: manavortex -## Version: 2.4.81 +## Version: 2.5.0 ## APIVersion: 100023 ## SavedVariables: FurnitureCatalogue_Settings ## OptionalDependsOn: pChat diff --git a/FurnitureCatalogue_DevUtility/00_startup.lua b/FurnitureCatalogue_DevUtility/00_startup.lua index 092da3c..eb9e5a8 100644 --- a/FurnitureCatalogue_DevUtility/00_startup.lua +++ b/FurnitureCatalogue_DevUtility/00_startup.lua @@ -3,18 +3,40 @@ local function whoami() return GetUnitDisplayName(UNITTAG_PLAYER) end -local isMana = whoami() == "@manavortex" or whoami() == "@Manorin" -if not isMana then return end +local isMana = string.find(whoami(), "@manavortex") or string.find(whoami(), "@Manorin") +if not isMana then return end + local control = FurCDevControl FurCDevUtility = {} local this = FurCDevUtility -this.name = "FurCDevUtility" +this.name = "FurnitureCatalogue_DevUtility" this.control = control this.textbox = FurCDevControlBox - local active = string.find(GetWorldName(), "PTS") + +local function p(output, a1, a2, a3, a4, a5) + + if a5 then + d(zo_strformat(output, a1, a2, a3, a4, a5)) + elseif a4 then + d(zo_strformat(output, a1, a2, a3, a4)) + elseif a3 then + d(zo_strformat(output, a1, a2, a3)) + elseif a2 then + d(zo_strformat(output, a1, a2)) + elseif a1 then + d(zo_strformat(output, a1)) + elseif output then + d(zo_strformat(output)) + else + d("\n") + end +end +this.p = p + + local function set_active(status) if nil == status then status = not this.active end this.active = status @@ -27,12 +49,6 @@ local function setHidden(status) end FurCDevUtility.setHidden = setHidden -local function clearControl() - control:GetNamedChild("_textbox"):Clear() -end -FurCDevUtility.clearControl = clearControl - - local activeStr = "active" local showStr = "show" local hideStr = "hide" @@ -45,7 +61,7 @@ function slash_cmd(arg1) elseif arg1 == hideStr then setHidden(true) else - d("set active") + d("/furcdev -> active to set active, show to show, hide to hide") end end SLASH_COMMANDS["/furcdev"] = slash_cmd @@ -53,12 +69,17 @@ SLASH_COMMANDS["/furcdev"] = slash_cmd function FurCDevUtility_Initialize(eventCode, addonName) if addonName ~= this.name then return end - this.textbox = FurCDevControlBox - FurCDevControl.InitRightclickMenu() + this.textbox:SetMaxInputChars(3000) + this.InitRightclickMenu() EVENT_MANAGER:UnregisterForEvent("FurCDevUtility", EVENT_ADD_ON_LOADED) end +function FurnitureCatalogueDevUtility_AddToTextbox() + FurCDevControl_HandleInventoryContextMenu(moc()) +end + +ZO_CreateStringId("FURC_CONCAT_TO_TEXTBOX", "Add to FurC Dev utility control") EVENT_MANAGER:RegisterForEvent("FurCDevUtility", EVENT_ADD_ON_LOADED, FurCDevUtility_Initialize) diff --git a/FurnitureCatalogue_DevUtility/Bindings.xml b/FurnitureCatalogue_DevUtility/Bindings.xml new file mode 100644 index 0000000..26c8274 --- /dev/null +++ b/FurnitureCatalogue_DevUtility/Bindings.xml @@ -0,0 +1,11 @@ +<Bindings> + <Layer name="SI_KEYBINDINGS_CATEGORY_GENERAL"> + <Category name="Furniture Catalogue Dev"> + <Action name="FURC_CONCAT_TO_TEXTBOX"> + <Down> + FurnitureCatalogueDevUtility_AddToTextbox() + </Down> + </Action> + </Category> + </Layer> +</Bindings> \ No newline at end of file diff --git a/FurnitureCatalogue_DevUtility/ContextMenu.lua b/FurnitureCatalogue_DevUtility/ContextMenu.lua index 05838f8..463ebfc 100644 --- a/FurnitureCatalogue_DevUtility/ContextMenu.lua +++ b/FurnitureCatalogue_DevUtility/ContextMenu.lua @@ -1,12 +1,25 @@ FurCDevControl_LinkHandlerBackup_OnLinkMouseUp = nil local this = FurCDevUtility -local S_ADD_TO_BOX = "Add to textbox" -local S_SET_TO_BOX = "Set textbox to" this.textbox = this.textbox or FurCDevControlBox local textbox = this.textbox -function this.clearTextbox() +local cachedItemLink +local cachedControl +local cachedName +local cachedPrice +local cachedCanBuy + +local p = this.p + +local cachedItemIds = {} + +local function showTextbox() + this.textbox:GetParent():SetHidden(false) + this.textbox:SetHidden(false) +end +function this.clearControl() this.textbox:Clear() + ZO_ClearTable(cachedItemIds) end function this.selectEntireTextbox() @@ -15,65 +28,53 @@ function this.selectEntireTextbox() textbox:SetSelection(0, #text) end -local defaultDebugString = "[<<1>>] = <<2>>, -- <<3>>" -local debugStringWithPrice = "[<<1>>] = { -- <<3>>\n\titemPrice = <<2>>,\n\t--achievement = 0, \n}," -local function makeOutput(itemLink, control) - if not this.active or not FurC.Find(itemLink) then return end - local itemId = FurC.GetItemId(itemLink) - local price = 0 - control = control or moc() +local defaultDebugString = "[<<1>>] = GetString(SI_FURC_EXISITING_ITEMSOURCE_UNKNOWN_YET), -- <<3>>" +local debugStringWithPrice = "[<<1>>] = { -- <<3>>\n\titemPrice = <<2>>, \n}," +local debugStringWithAchievement = "[<<1>>] = { -- <<3>>\n\titemPrice = <<2>>,\n\t--achievement = 0, \n}," +local function makeOutput() + local debugString = defaultDebugString - if control and control.dataEntry then - local data = control.dataEntry.data or {} - if 0 == data.currencyQuantity1 then - price = data.stackBuyPrice - debugString = debugStringWithPrice - else - price = data.currencyQuantity1 - end + + if cachedPrice and 0 < cachedPrice then + debugString = debugStringWithPrice + else + end - return zo_strformat(debugString, itemId, price, GetItemLinkName(itemLink)) + if not cachedCanBuy then debugString = debugStringWithAchievement end + return zo_strformat(debugString, FurC.GetItemId(cachedItemLink), cachedPrice, cachedName) end -local linebreak = "\n" -local function concatToTextbox(itemLink, control) - local textSoFar = this.textbox:GetText() - local entry = linebreak .. makeOutput(itemLink, control) - this.textbox:SetText(textSoFar .. entry) +local function isItemIdCached() + local itemId = FurC.GetItemId(cachedItemLink) + if cachedItemIds[itemId] then return true end + cachedItemIds[itemId] = true + return false end -local function setTextboxTo(itemLink, control) - this.textbox:Clear() - this.textbox.setText(makeOutput(itemLink, control)) +local linebreak = "\n" +local function concatToTextbox() + if isItemIdCached() then return end + local textSoFar = this.textbox:GetText() or "" + textSoFar = (#textSoFar > 0 and textSoFar .. linebreak) or textSoFar + this.textbox:SetText(textSoFar .. makeOutput()) + showTextbox() end - -local function addMenuItems(itemLink, control) - - recipeArray = recipeArray or FurC.Find(itemLink) - if (nil == recipeArray) then return end - -- ClearMenu() - - AddCustomMenuItem(S_SET_TO_BOX, - function() concatToTextbox(itemLink, control) end, - MENU_ADD_OPTION_LABEL - ) - - AddCustomMenuItem(S_SET_TO_BOX, - function() setTextboxTo(itemLink, control) end, - MENU_ADD_OPTION_LABEL - ) - - +local S_ADD_TO_BOX = "Add data to textbox" +local function addMenuItems() + AddCustomMenuItem(S_ADD_TO_BOX, concatToTextbox, MENU_ADD_OPTION_LABEL) end function FurCDevControl_HandleClickEvent(itemLink, button, control) -- button being mouseButton here - if (type(itemLink) == 'string' and #itemLink > 0) then + cachedItemLink = itemLink + cachedControl = control + if (type(itemLink) == 'string' and #itemLink > 0) then local handled = LINK_HANDLER:FireCallbacks(LINK_HANDLER.LINK_MOUSE_UP_EVENT, itemLink, button, ZO_LinkHandler_ParseLink(itemLink)) if (not handled) then FurCDevControl_LinkHandlerBackup_OnLinkMouseUp(itemLink, button, control) + -- end if (button == 2 and itemLink and #itemLink > 0) then - addMenuItems(itemLink, control) + addMenuItems() end ShowMenu(control) end @@ -81,45 +82,38 @@ function FurCDevControl_HandleClickEvent(itemLink, button, control) -- button b end -function FurCDevControl_HandleMouseEnter(inventorySlot) - local inventorySlot = moc() - - if nil == inventorySlot or nil == inventorySlot.dataEntry then return end - local data = inventorySlot.dataEntry.data - if nil == data then return end - - local bagId, slotIndex = data.bagId, data.slotIndex - FurC.CurrentLink = GetItemLink(bagId, slotIndex) - if nil == FurC.CurrentLink then return end - -end - -- thanks Randactyl for helping me with the handler :) function FurCDevControl_HandleInventoryContextMenu(control) - + control = control or moc() + local name, price, meetsRequirementsToBuy, currencyQuantity1, currencyQuantity2 + local st = ZO_InventorySlot_GetType(control) - local itemLink = nil + cachedItemLink = nil if st == SLOT_TYPE_ITEM or st == SLOT_TYPE_BANK_ITEM - or st == SLOT_TYPE_GUILD_BANK_ITEM + or st == SLOT_TYPE_GUILD_BANK_ITEM or st == SLOT_TYPE_TRADING_HOUSE_POST_ITEM then local bagId, slotId = ZO_Inventory_GetBagAndIndex(control) - itemLink = GetItemLink(bagId, slotId, linkStyle) - end - if st == SLOT_TYPE_TRADING_HOUSE_ITEM_RESULT then - itemLink = GetTradingHouseSearchResultItemLink(ZO_Inventory_GetSlotIndex(control), linkStyle) + cachedItemLink = GetItemLink(bagId, slotId, linkStyle) + name = GetItemLinkName(cachedItemLink) + price = nil + elseif st == SLOT_TYPE_STORE_BUY then + local storeEntryIndex = control.index or 0 + _, name, _, price, _, meetsRequirementsToBuy, _, _, _, + _, currencyQuantity1, _, currencyQuantity2 = GetStoreEntryInfo(storeEntryIndex) + cachedItemLink = GetStoreItemLink(storeEntryIndex) end - if st == SLOT_TYPE_TRADING_HOUSE_ITEM_LISTING then - itemLink = GetTradingHouseListingItemLink(ZO_Inventory_GetSlotIndex(control), linkStyle) - end - - local recipeArray = FurC.Find(itemLink) - -- d(recipeArray) - if nil == recipeArray then return end - + + cachedControl = control + cachedName = name + cachedPrice = price + cachedCanBuy = meetsRequirementsToBuy + + if not FurC.Find(cachedItemLink) then return end + zo_callLater(function() - addMenuItems(itemLink, recipeArray) + addMenuItems() ShowMenu() end, 50) @@ -127,29 +121,30 @@ function FurCDevControl_HandleInventoryContextMenu(control) end -function FurC.OnControlMouseUp(control, button) - - if nil == control then return end - if button ~= 2 then return end - local itemLink = control.itemLink +function FurCDevUtility.OnControlMouseUp(control, button) + + if (not control) or button ~= 2 then return end - if nil == itemLink then return end - local recipeArray = FurC.Find(itemLink) - if nil == recipeArray then return end + if not control.itemLink or #control.itemLink == 0 then return end + + cachedItemLink = control.itemLink + cachedControl = control + zo_callLater(function() ItemTooltip:SetHidden(true) ClearMenu() - addMenuItems(itemLink, recipeArray) + addMenuItems() ShowMenu() end, 50) end -function FurC.InitRightclickMenu() +function FurCDevUtility.InitRightclickMenu() FurCDevControl_LinkHandlerBackup_OnLinkMouseUp = ZO_LinkHandler_OnLinkMouseUp - ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control) FurCDevControl_HandleClickEvent(itemLink, button, control) end - ZO_PreHook('ZO_InventorySlot_OnMouseEnter', FurCDevControl_HandleMouseEnter) + ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control) + FurCDevControl_HandleClickEvent(itemLink, button, control) + end ZO_PreHook('ZO_InventorySlot_ShowContextMenu', function(rowControl) FurCDevControl_HandleInventoryContextMenu(rowControl) end) diff --git a/FurnitureCatalogue_DevUtility/FurnitureCatalogue_DevUtility.txt b/FurnitureCatalogue_DevUtility/FurnitureCatalogue_DevUtility.txt index d817da8..8eb4dd7 100644 --- a/FurnitureCatalogue_DevUtility/FurnitureCatalogue_DevUtility.txt +++ b/FurnitureCatalogue_DevUtility/FurnitureCatalogue_DevUtility.txt @@ -1,10 +1,11 @@ ## Title: FurnitureCatalogue_DevUtility ## Author: manavortex -## Description: This is a utility addon that helps me generate text entries for the data files. It won't even activate if you're not me, so feel free to unload it. +## Description: This is a utility addon that helps me generate text entries for the data files. It won't do anything if you're not me, so feel free to unload it.\nYou're welcome to get in touch if you want to use this, then I can add you to the list. ## Version: 1.0.0 ## APIVersion: 100023 ## DependsOn: FurnitureCatalogue +Bindings.xml xml.xml 00_startup.lua ContextMenu.lua \ No newline at end of file diff --git a/FurnitureCatalogue_DevUtility/xml.xml b/FurnitureCatalogue_DevUtility/xml.xml index 6186ea3..5ba27ef 100644 --- a/FurnitureCatalogue_DevUtility/xml.xml +++ b/FurnitureCatalogue_DevUtility/xml.xml @@ -7,7 +7,7 @@ <Backdrop name="$(parent)_BG" inherits="ZO_DefaultBackdrop"><AnchorFill/></Backdrop> <Button name="$(parent)_hide" inherits="ZO_ButtonBehaviorClickSound" > <OnClicked>FurCDevUtility.setHidden(true)</OnClicked> - <Dimensions x="40" y="40" /> + <Dimensions x="30" y="30" /> <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="10" offsetY="10" /> <Textures normal ="/esoui/art/buttons/decline_up.dds" @@ -19,7 +19,7 @@ <Button name="$(parent)_clear" inherits="ZO_ButtonBehaviorClickSound" > <OnClicked>FurCDevUtility.clearControl()</OnClicked> <Dimensions x="40" y="40" /> - <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-10" offsetY="-10" /> + <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-10" offsetY="10" /> <Textures normal ="/esoui/art/help/help_tabicon_feedback_up.dds" pressed ="/esoui/art/help/help_tabicon_feedback_down.dds " @@ -27,7 +27,7 @@ /> </Button> - <EditBox name="$(parent)Box" inherits="ZO_DefaultEditForBackdrop ZO_EditDefaultText" > + <EditBox name="$(parent)Box" inherits="ZO_DefaultEditMultiLine ZO_DefaultEditForDarkBackdrop" > <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="50" offsetY="50"/> <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="BOTTOMRIGHT" offsetX="50"/> diff --git a/startup.lua b/startup.lua index 33291c2..74fd646 100644 --- a/startup.lua +++ b/startup.lua @@ -1,7 +1,7 @@ FurnitureCatalogue = {} FurnitureCatalogue.name = "FurnitureCatalogue" FurnitureCatalogue.author = "manavortex" -FurnitureCatalogue.version = "2.4.81" +FurnitureCatalogue.version = "2.5.0" FurnitureCatalogue.CharacterName = nil FurnitureCatalogue.settings = {} @@ -251,26 +251,12 @@ function whoami() end -function FurnitureCatalogue_ToggleDev(arg) - if arg == 0 or arg == "true" then - FurC.DevDebug = true - else - FurC.DevDebug = false - end -end - -- initialization stuff function FurnitureCatalogue_Initialize(eventCode, addOnName) if (addOnName ~= FurnitureCatalogue.name) then return end FurnitureCatalogue.settings = ZO_SavedVars:NewAccountWide("FurnitureCatalogue_Settings", 2, nil, defaults) - - if FurC.AccountName == "@manavortex" or FurC.AccountName == "@Manorin" then - FurnitureCatalogue.devSettings = ZO_SavedVars:NewAccountWide("_FurC_DevData", 2, nil, {}) - SLASH_COMMANDS["/furc_dev"] = FurnitureCatalogue_ToggleDev - end - -- initialise setting, also setup the "source" dropdown for the menu FurC.settings.data = FurC.settings.data or {} FurC.settings.filterCraftingType = {} @@ -307,12 +293,6 @@ function FurnitureCatalogue_Initialize(eventCode, addOnName) end -if "@manavortex" == FurC.AccountName or "@Manorin" == FurC.AccountName then - SLASH_COMMANDS["/furc_debug"] = function() - FurC.DevDebug = not FurC.DevDebug - end -end - ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_FURNITURE_CATALOGUE", "Toggle Furniture Catalogue") EVENT_MANAGER:RegisterForEvent("FurnitureCatalogue", EVENT_ADD_ON_LOADED, FurnitureCatalogue_Initialize)