diff --git a/IIfA/IIfABackpack.lua b/IIfA/IIfABackpack.lua index c9472b1..31f536d 100644 --- a/IIfA/IIfABackpack.lua +++ b/IIfA/IIfABackpack.lua @@ -160,6 +160,11 @@ local function DoesInventoryMatchList(locationName, location) end end end +--@Baetram: +--Made the function global to be used in other addons like FCOItemSaver +function IIfA:DoesInventoryMatchList(locationName, location) + return DoesInventoryMatchList(locationName, location) +end local function matchCurrentInventory(locationName) -- if locationName == "attributes" then return false end @@ -466,7 +471,7 @@ local function fillLine(curLine, curItem) --Show the FCOIS marker icons at the line, if enabled in the settings (create them if needed) -> File plugins/FCOIS/IIfA_FCOIS.lua if IIfA.UpdateFCOISMarkerIcons ~= nil then local showFCOISMarkerIcons = IIfA:GetSettings().FCOISshowMarkerIcons - IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, showFCOISMarkerIcons, -1) + IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, false, -1) end end end @@ -632,6 +637,7 @@ function IIfA:GetAccountInventoryList() end end + --house banks if IIfA.data.b_collectHouses then -- table.insert(accountInventories, "All Houses") -- 4-11-18 AM - removed duplicate entry, it's in the dropdownLocNames already for idx, houseName in pairs(IIfA:GetTrackedHouseNames()) do @@ -728,7 +734,6 @@ end -- general note for popup menus -- example here http://www.esoui.com/downloads/info1146-LibCustomMenu.html -- AddCustomSubMenuItem(mytext, entries, myfont, normalColor, highlightColor, itemYPad) - function IIfA:SetupBackpack() local function createInventoryDropdown() diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua index 2f4f935..5634ec1 100644 --- a/IIfA/IIfADataCollection.lua +++ b/IIfA/IIfADataCollection.lua @@ -435,6 +435,19 @@ function IIfA:TableCount(tbl) return cnt end +--@Baetram: +-- Added for other addons like FCOItemSaver to get the item instance or the unique ID +-->Returns itemInstance or uniqueId as 1st return value +-->Returns a boolean value as 2nd retun value: true if the bagId should build an itemInstance or unique ID / false if not +local function getItemInstanceOrUniqueId(bagId, slotIndex, itemLink) + local itemInstanceOrUniqueId = 0 + local isBagToBuildItemInstanceOrUniqueId = false + if FCOIS == nil then return 0, false end + --Call function within addon FCOItemSaver, file FCOIS_OtherAddons.lua -> IIfA section + itemInstanceOrUniqueId, isBagToBuildItemInstanceOrUniqueId = FCOIS.getItemInstanceOrUniqueId(bagId, slotIndex, itemLink) + return itemInstanceOrUniqueId, isBagToBuildItemInstanceOrUniqueId +end + function IIfA:EvalBagItem(bagId, slotId, fromXfer, qty, itemLink, itemName, locationID) if not IIfA.trackedBags[bagId] then return end @@ -463,6 +476,13 @@ function IIfA:EvalBagItem(bagId, slotId, fromXfer, qty, itemLink, itemName, loca local itemCount = qty or getItemCount(bagId, slotId, itemLink) + --@Baetram: + --Item instance/unique id (needed for other addons like FCOItemSaver to (un)mark items via that id) + local itemInstanceOrUniqueId, isBagToBuildItemInstanceOrUniqueId = getItemInstanceOrUniqueId(bagId, slotId, itemLink) + if isBagToBuildItemInstanceOrUniqueId then + p("[EvalBagItem]Item instance or unique ID: <<1>>", itemInstanceOrUniqueId) + end + --p("trying to save <<1>> x<<2>>", itemLink, itemCount) local itemQuality = GetItemLinkQuality(itemLink) @@ -523,7 +543,12 @@ function IIfA:EvalBagItem(bagId, slotId, fromXfer, qty, itemLink, itemName, loca DBitem.locations[location].bagSlot = {} DBitem.locations[location].bagSlot[slotId] = itemCount end - end + end + --@Baetram: + --Added for other addons like FCOItemSaver. Only needed for non-account wide bags! + if isBagToBuildItemInstanceOrUniqueId then + DBitem.itemInstanceOrUniqueId = itemInstanceOrUniqueId + end else DBv3[itemKey] = {} DBv3[itemKey].filterType = itemFilterType @@ -534,6 +559,11 @@ function IIfA:EvalBagItem(bagId, slotId, fromXfer, qty, itemLink, itemName, loca DBv3[itemKey].locations[location].bagID = bagId DBv3[itemKey].locations[location].bagSlot = {} DBv3[itemKey].locations[location].bagSlot[slotId] = itemCount + --@Baetram: + --Added for other addons like FCOItemSaver. Only needed for non-account wide bags! + if isBagToBuildItemInstanceOrUniqueId then + DBv3[itemKey].itemInstanceOrUniqueId = itemInstanceOrUniqueId + end DBitem = DBv3[itemKey] end diff --git a/IIfA/plugins/FCOIS/IIfA_FCOIS.lua b/IIfA/plugins/FCOIS/IIfA_FCOIS.lua index db03eea..e914b48 100644 --- a/IIfA/plugins/FCOIS/IIfA_FCOIS.lua +++ b/IIfA/plugins/FCOIS/IIfA_FCOIS.lua @@ -16,7 +16,7 @@ FCOIS_IIfA_TEXTURE_CONTROL_NAME = "_IIfA_" --> showFCOISMarkerIcons (boolean): [true= Show the texture controls / false= Hide the texture controls] --> createFCOISMarkerIcons (boolean|nilable): [true= Create the texture controls if not already there/ false= Do not create the texture controls]. Can be nil and will be set to false then --> iconId (integer or table|nilable): Integer (icon Id or -1 for all) or a table which contains the FCOIS marker icons to create the textures for. Can be nil = Process "all" marker icon textures. ----> integer or table: key = integer or string, value = iconId (can be a number or the constant from the addon FCOItemSaver file FCOIS_Constants.lua, e.g. FCOIS_CON_ICON_LOCK ... +---> integer or table: key = integer or string, value = iconId (can be a number or the constant from the addon FCOItemSaver file FCOIS_Constants.lua, e.g. FCOIS_CON_ICON_LOCK, ... -- iconIds = { -- [1] = 1, -- ["test"] = FCOIS_CON_ICON_GEAR_1, @@ -26,7 +26,7 @@ FCOIS_IIfA_TEXTURE_CONTROL_NAME = "_IIfA_" function IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, createFCOISMarkerIcons, iconId) --d("[IIfA]UpdateFCOISMarkerIcons - curLine: " ..tostring(curLine:GetName()) .. ", showFCOISMarkerIcons: " .. tostring(showFCOISMarkerIcons) .. ", createFCOISMarkerIcons: " ..tostring(createFCOISMarkerIcons)) --Only do if FCOItemSaver is loaded - if FCOIS == nil then return false end + if FCOIS == nil or FCOIS.MyGetItemInstanceIdForIIfA == nil then return false end if curLine == nil or showFCOISMarkerIcons == nil then return false end createFCOISMarkerIcons = createFCOISMarkerIcons or false @@ -63,10 +63,12 @@ function IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, createFCOISM else return false end - local iconSettings = FCOIS.settingsVars.settings.icon + local iconSettings = settings.icon local markerTextureVars = FCOIS.textureVars.MARKER_TEXTURES + -------------------------------------------------------------------------------------------------------------------- --Function to create the texture control CT_TEXTURE now and anchor it to the parent's line + -------------------------------------------------------------------------------------------------------------------- local function UpdateAndAnchorMarkerControl(parent, markerIconId, pWidth, pHeight, pTexture, pCreateControlIfNotThere, pHideControl) --No parent? Abort here if parent == nil then return nil end @@ -76,25 +78,27 @@ function IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, createFCOISM local control = FCOIS.GetItemSaverControl(parent, markerIconId, false, FCOIS_IIfA_TEXTURE_CONTROL_NAME) local doHide = pHideControl - --Should the control not be hidden? Then check it's marker settings and if a marker is set + --Should the control shown (not hidden)? Then check it's marker settings and if a marker is set if not doHide then --Marker control for a disabled icon? Hide the icon then if not settings.isIconEnabled[markerIconId] then - --Do not hide the texture anymore but do not create it to save memory - --doHide = true - return false + --Do not hide the texture and do not create it to save memory + return nil else --Control should be shown - local itemInstanceOrUniqueId, bagId, slotIndex = FCOIS.MyGetItemInstanceIdForIIfA(parent, false) + --Get the data of the currentLine and check by help of the itemInstanceId if the item should be marked + --itemInstanceOrUniqueId, bagId, slotIndex, itemFoundAtLocationTableCharactersAndWornBag, itemFoundAtLocationTableAllOtherBags = FCOIS.MyGetItemInstanceIdForIIfA(control, signItemInstanceOrUniqueId) + local itemInstanceOrUniqueId = FCOIS.MyGetItemInstanceIdForIIfA(parent, false) local isItemProtectedWithMarkerIcon = FCOIS.checkIfItemIsProtected(markerIconId, itemInstanceOrUniqueId) + --Hide the control if the item is not protected doHide = not isItemProtectedWithMarkerIcon end end if doHide == nil then doHide = false end - --It does not exist yet, so create it now - if(control == parent or not control) then - --Abort here if control should be hiden and is not created yet + --Control for marker icon does not exist yet, so create it now + if(control == parent or control == nil) then + --Abort here if control should be hidden and is not created yet if doHide == true and pCreateControlIfNotThere == false then ZO_Tooltips_HideTextTooltip() return @@ -104,36 +108,61 @@ function IIfA:UpdateFCOISMarkerIcons(curLine, showFCOISMarkerIcons, createFCOISM --Important: Add the constant FCOIS_IIfA_TEXTURE_CONTROL_NAME to the name for textures created within IIfA inventory frame! control = WINDOW_MANAGER:CreateControl(parent:GetName() .. addonName .. FCOIS_IIfA_TEXTURE_CONTROL_NAME .. tostring(markerIconId), parent, CT_TEXTURE) end - --Control did already exist or was created now + --Control did already exist or was created if control ~= nil then --Hide or show the control now control:SetHidden(doHide) - + --Should the control not be hidden (should be shown shown)? if not doHide then + --Update the dimensions, texture file etc. control:SetDimensions(pWidth, pHeight) control:SetTexture(pTexture) local iconSettingsColor = settings.icon[markerIconId].color control:SetColor(iconSettingsColor.r, iconSettingsColor.g, iconSettingsColor.b, iconSettingsColor.a) control:SetDrawTier(DT_HIGH) control:ClearAnchors() - local iconOffset = settings.iconPosition + --local iconOffset = settings.iconPosition --control:SetAnchor(LEFT, parent, LEFT, iconOffset.x, iconOffset.y) control:SetAnchor(TOPRIGHT, parent, TOPLEFT, 0, 0) - --<Anchor point="TOPRIGHT" relativeTo="$(parent)Button" relativePoint="TOPLEFT" /> - + --Set the tooltip if wished + if FCOIS.CreateToolTip ~= nil then + --Set the "calledByExternalAddon" flag to "IIfA" + -->See file AddOns/FCOItemSaver/FCOIS_MarkerIcons.lua + --Check if item is worn and/or stolen and add the text to the FCOIS tooltip! +--d("stolen hidden: " ..tostring(parent.stolen:IsHidden()) .. " worn hidden: " ..tostring(parent.worn:IsHidden())) + local isStolen = (parent.stolen ~= nil and not parent.stolen:IsHidden()) or false + local isWorn = (parent.worn ~= nil and not parent.worn:IsHidden()) or false +--d("stolen: " ..tostring(isStolen) .. " worn: " ..tostring(isWorn)) + local stolenTTText = "" + local wornTTText = "" + local addTTText = "" + if isStolen then + stolenTTText = GetString(SI_INVENTORY_STOLEN_ITEM_TOOLTIP) --Stolen item + end + if isWorn then + wornTTText = GetString(SI_CHARACTER_EQUIP_TITLE) --Equipped + end + if stolenTTText ~= "" then + addTTText = stolenTTText + end + if wornTTText ~= "" then + if addTTText ~= "" then + addTTText = addTTText .. "\n" .. wornTTText + else + addTTText = wornTTText + end + end + FCOIS.CreateToolTip(control, markerIconId, doHide, false, false, "IIfA", addTTText) + end end -- if not doHide then - --Set the tooltip if wished - if FCOIS.CreateToolTip ~= nil then - --Set the "calledByExternalAddon" flag to "IIfA" - FCOIS.CreateToolTip(control, markerIconId, doHide, false, false, "IIfA") - end return control else return nil end end + -------------------------------------------------------------------------------------------------------------------- - --Create textures in IIfA inventory frame for each marker icon ID in iconsToCheck + --Create FCOItemSaver marker texture controls in IIfA inventory frame (at current row) for each FCOIS marker icon ID in iconsToCheck for _, markerIconId in ipairs(iconsToCheck) do UpdateAndAnchorMarkerControl(curLine, markerIconId, iconSettings[markerIconId].size, iconSettings[markerIconId].size, markerTextureVars[iconSettings[markerIconId].texture], createFCOISMarkerIcons, not showFCOISMarkerIcons) end