diff --git a/Common.lua b/Common.lua index 67885a5..34b4d14 100644 --- a/Common.lua +++ b/Common.lua @@ -7,49 +7,27 @@ local BACKPACK = ZO_PlayerInventoryBackpack local BANK = ZO_PlayerBankBackpack local GUILD_BANK = ZO_GuildBankBackpack -local COOKING_RANK_1 = [[SousChef/media/One.dds]] -local COOKING_RANK_2 = [[SousChef/media/Two.dds]] -local COOKING_RANK_3 = [[SousChef/media/Three.dds]] -local COOKING_RANK_4 = [[SousChef/media/Four.dds]] -local COOKING_RANK_5 = [[SousChef/media/Five.dds]] -local COOKING_RANK_6 = [[SousChef/media/Six.dds]] -local COOKING_FLAVOUR = [[SousChef/media/Flavour.dds]] -local COOKING_SPICE = [[SousChef/media/Spice.dds]] -local COOKING_RANK_1B = [[SousChef/media/One_flat.dds]] -local COOKING_RANK_2B = [[SousChef/media/Two_flat.dds]] -local COOKING_RANK_3B = [[SousChef/media/Three_flat.dds]] -local COOKING_RANK_4B = [[SousChef/media/Four_flat.dds]] -local COOKING_RANK_5B = [[SousChef/media/Five_flat.dds]] -local COOKING_RANK_6B = [[SousChef/media/Six_flat.dds]] -local COOKING_FLAVOURB = [[SousChef/media/flavour_flat.dds]] -local COOKING_SPICEB = [[SousChef/media/Spice_Flat.dds]] - -local GRILLED = [[/esoui/art/treeicons/provisioner_indexicon_meat_down.dds]] -local BREADPIE = [[/esoui/art/treeicons/provisioner_indexicon_baked_down.dds]] -local SOUPSTEW = [[/esoui/art/treeicons/provisioner_indexicon_stew_down.dds]] -local BEER = [[/esoui/art/treeicons/provisioner_indexicon_beer_down.dds]] -local SPIRITS = [[/esoui/art/treeicons/provisioner_indexicon_spirits_down.dds]] -local WINE = [[/esoui/art/treeicons/provisioner_indexicon_wine_down.dds]] -local GENERAL_DRINK = [[/esoui/art/inventory/inventory_quest_tabicon_active.dds]] -local FRUIT = [[//esoui/art/progression/progression_indexicon_race_down.dds]] -local VEGGIES = [[/esoui/art/compass/ava_farm_neutral.dds]] -local TONICS = [[/esoui/art/crafting/alchemy_tabicon_solvent_down.dds]] - --- 1-food spice, 2-drink flavoring, 3-meat, 4-fruit, 5-veg, 6-booze, 7-teas, 8-tonics, 9-general foods, 10-general drinks -m.COOKING = {COOKING_SPICE, COOKING_FLAVOUR, GRILLED, FRUIT, VEGGIES, SPIRITS, BEER, TONICS, SOUPSTEW, GENERAL_DRINK} ---m.COOKINGB = {COOKING_SPICEB, COOKING_FLAVOURB, GRILLED, SOUPSTEW, BREADPIE, BEER, SPIRITS, WINE, COOKING_RANK_1B, COOKING_RANK_2B} - ---m.COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6, COOKING_FLAVOUR, COOKING_SPICE, GRILLED, BREADPIE, SOUPSTEW, BEER, SPIRITS, WINE} ---m.COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B, COOKING_FLAVOURB, COOKING_SPICEB, GRILLED, BREADPIE, SOUPSTEW, BEER, SPIRITS, WINE} +m.COOKING = { + [[SousChef/media/Spice.dds]], --food spice + [[SousChef/media/Flavour.dds]], -- drink flavouring + [[/esoui/art/treeicons/provisioner_indexicon_meat_down.dds]], -- meat + [[//esoui/art/progression/progression_indexicon_race_down.dds]], -- fruit + [[/esoui/art/compass/ava_farm_neutral.dds]], -- veggies + [[/esoui/art/treeicons/provisioner_indexicon_spirits_down.dds]], -- booze + [[/esoui/art/treeicons/provisioner_indexicon_beer_down.dds]], -- teas + [[/esoui/art/crafting/alchemy_tabicon_solvent_down.dds]], -- tonics + [[/esoui/art/treeicons/provisioner_indexicon_stew_down.dds]], -- general foods + [[/esoui/art/inventory/inventory_quest_tabicon_active.dds]] -- general drinks +} m.CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]] local INVENTORIES = { - [PLAYER_INVENTORY.inventories[1].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Backpack - [PLAYER_INVENTORY.inventories[3].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Bank - [PLAYER_INVENTORY.inventories[4].listView] = {GetItemLink, "bagId", "slotIndex"}, -- GuildBank - [LOOT_WINDOW.list] = {GetLootItemLink, "lootId", nil}, -- LootWindow - [STORE_WINDOW.list] = {GetStoreItemLink, "slotIndex", nil}, -- Store + [PLAYER_INVENTORY.inventories[1].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Backpack + [PLAYER_INVENTORY.inventories[3].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Bank + [PLAYER_INVENTORY.inventories[4].listView] = {GetItemLink, "bagId", "slotIndex"}, -- GuildBank + [LOOT_WINDOW.list] = {GetLootItemLink, "lootId", nil}, -- LootWindow + [STORE_WINDOW.list] = {GetStoreItemLink, "slotIndex", nil}, -- Vendor } local rowClicked = {} @@ -74,8 +52,8 @@ function SousChef.HookInventory() ZO_ScrollList_RefreshVisible(BANK) ZO_ScrollList_RefreshVisible(GUILD_BANK) if not SousChef.settings.showOnClick then - ZO_PreHookHandler(ItemTooltip, "OnShow", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 500) end) - ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() return SousChef.AddDetails(moc()) end) + ZO_PreHookHandler(ItemTooltip, "OnShow", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 500) return false end) + ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 500) return false end) ZO_PreHookHandler(ItemTooltip, "OnHide", function() rowClicked = nil return false end ) end end @@ -89,6 +67,7 @@ function SousChef.getIcon(row) ZO_PreHookHandler(row, "OnMouseDown", SousChef.AddDetails) ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked = nil return false end ) end + rankIcon:SetMouseEnabled(true) end return rankIcon end @@ -109,6 +88,7 @@ local function CalculateHowManyCouldBeCreated(recipeListIndex, recipeIndex, numI return minCount or 0 end +-- add details to the item tooltip function SousChef.AddDetails(row) if not row.dataEntry or not row.dataEntry.data or rowClicked == row then return false end rowClicked = row @@ -121,18 +101,25 @@ function SousChef.AddDetails(row) slotIndex = nil end local itemLink = (slotIndex and GetItemLink(bagId, slotIndex)) - or (rowInfo.lootId and GetLootItemLink(bagId)) + or (LOOT_WINDOW_FRAGMENT.state == "shown" and GetLootItemLink(bagId)) -- If there are no search results present in memory, GetTradingHouseSearchResultItemLink will crash to desktop or (TRADING_HOUSE:IsAtTradingHouse() and TRADING_HOUSE.m_numItemsOnPage ~= nil and TRADING_HOUSE.m_numItemsOnPage ~= 0 and GetTradingHouseSearchResultItemLink(bagId)) - or (GetStoreItemLink(bagId)) + or (GetTradingHouseListingItemLink(bagId)) + or (GetGuildSpecificItemLink(bagId)) + or (TRADE_FRAGMENT.state == "shown" and GetTradeItemLink(bagId)) + or (STORE_FRAGMENT.state == "shown" and GetStoreItemLink(bagId)) + or (BUY_BACK_FRAGMENT.state == "shown" and GetBuybackItemLink(bagId)) + or (MAIL_INBOX_FRAGMENT.state == "shown" and MAIL_INBOX.GetOpenMailId() and GetAttachedItemLink(MAIL_INBOX.GetOpenMailId(), bagId)) if itemLink == "" then return false end -- item is a recipe if GetItemLinkItemType(itemLink) == ITEMTYPE_RECIPE then ZO_Tooltip_AddDivider(ItemTooltip) - ItemTooltip:AddLine(zo_strformat(str.TOOLTIP_CREATES, GetItemLinkRequiredLevel(GetItemLinkRecipeResultItemLink(itemLink)), GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink))), "ZoFontWinH5", 1, 1, 1, BOTTOM) + local resultLink = GetItemLinkRecipeResultItemLink(itemLink) + local level = GetLevelOrVeteranRankString(GetItemLinkRequiredLevel(resultLink), GetItemLinkRequiredVeteranRank(resultLink), 20) + ItemTooltip:AddLine(zo_strformat(str.TOOLTIP_CREATES, level, GetItemLinkName(resultLink)), "ZoFontWinH5", 1, 1, 1, BOTTOM) if SousChef.settings.showAltKnowledge then - local knownBy = SousChef.settings.Cookbook[u.CleanString(GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink)))] + local knownBy = SousChef.settings.Cookbook[u.CleanString(GetItemLinkName(resultLink))] if knownBy then ItemTooltip:AddLine(str.TOOLTIP_KNOWN_BY, "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE) ItemTooltip:AddLine(u.TableKeyConcat(knownBy)) diff --git a/Inventory.lua b/Inventory.lua index e442149..77eebb1 100644 --- a/Inventory.lua +++ b/Inventory.lua @@ -2,6 +2,7 @@ local SousChef = SousChef local u = SousChef.Utility local m = SousChef.Media local LibSort = LibStub:GetLibrary("LibSort-1.0") +local str = SousChef.Strings[SousChef.lang] function SousChef.AddRankToSlot(row, funcs) local idFunc = funcs[1] @@ -24,7 +25,9 @@ function SousChef.AddRankToSlot(row, funcs) end rankIcon:SetHidden(true) - + rankIcon:SetHandler("OnMouseEnter", nil) + rankIcon:SetHandler("OnMouseExit", nil) + --Are we gold or soulgem slot? Stay hidden and go away if not bagId or not slot.name or slot.name == "" then return end @@ -41,12 +44,14 @@ function SousChef.AddRankToSlot(row, funcs) if SousChef.settings.showAltIngredientKnowledge then texture = SousChef.settings.Pantry[id] end if texture then rankIcon:SetHidden(false) - - if SousChef.settings.boldIcon then - rankIcon:SetTexture(m.COOKINGB[texture]) - else - rankIcon:SetTexture(m.COOKING[texture]) - end + rankIcon:SetTexture(m.COOKING[texture]) + -- add tooltips + rankIcon:SetHandler("OnMouseEnter", function(self) + ZO_Tooltips_ShowTextTooltip(self, TOP, str.TOOLTIP_INGREDIENT_TYPES[texture]) + end) + rankIcon:SetHandler("OnMouseExit", function(self) + ZO_Tooltips_HideTextTooltip() + end) if SousChef:IsOnShoppingList(id) then rankIcon:SetColor(SousChef.settings.shoppingColour[1], SousChef.settings.shoppingColour[2], SousChef.settings.shoppingColour[3]) diff --git a/Provisioning.lua b/Provisioning.lua index bc12e4d..a66ea84 100644 --- a/Provisioning.lua +++ b/Provisioning.lua @@ -84,6 +84,7 @@ function SousChef:AddNotifier(control, marked) end function SousChef:IsOnShoppingList(id) + if SousChef.settings.ReverseCookbook[id] == nil then return false end for i,v in ipairs(SousChef.settings.ReverseCookbook[id]) do if type(SousChef.settings.shoppingList[v]) == "table" and next(SousChef.settings.shoppingList[v]) then if SousChef.settings.showAltShopping then diff --git a/SousChef.lua b/SousChef.lua index 1242806..7d22ea6 100644 --- a/SousChef.lua +++ b/SousChef.lua @@ -187,6 +187,68 @@ local function AutoJunker() end end +-- removes a character from SousChef's saved variables +local function DeleteCharacter(charName) + -- remove any of the character's recipes from the shopping list + for recipe, people in pairs(SousChef.settings.shoppingList) do + people[charName] = nil + if NonContiguousCount(people) == 0 then SousChef.settings.shoppingList[recipe] = nil end + end + + -- record all the recipes that only the deleted character knows + local soloRecipes = {} + -- remove the character from the cookbook + for recipe, people in pairs(SousChef.settings.Cookbook) do + people[charName] = nil + if NonContiguousCount(people) == 0 then + table.insert(soloRecipes, recipe) + SousChef.settings.Cookbook[recipe] = nil + end + end + + -- record any ingredients that only the deleted character could use + local soloIngredients = {} + -- if we're removing any recipes, remove them from the reverse cookbook + -- first, get the removed recipe info from the cookbook index + for recipe, recipeInfo in pairs(SousChef.settings.CookbookIndex[charName]) do + for i, delRecipe in ipairs(soloRecipes) do + if (u.CleanString(string.sub(recipe, 9, -3))) == delRecipe then + for j = 1, recipeInfo.numIngredients, 1 do + local ingrNum = u.GetItemID(GetRecipeIngredientItemLink(recipeInfo.listIndex, recipeInfo.recipeIndex, j)) + for k, rName in pairs(SousChef.settings.ReverseCookbook[ingrNum]) do + if rName == recipe then + SousChef.settings.ReverseCookbook[ingrNum][k] = nil + if NonContiguousCount(SousChef.settings.ReverseCookbook[ingrNum]) == 0 then + table.insert(soloIngredients, ingrNum) + SousChef.settings.ReverseCookbook[ingrNum] = nil + end + end + end + end + end + end + end + + -- remove any ingredients from the pantry that we no longer know how to use + for i, ingredient in ipairs(soloIngredients) do + SousChef.settings.Pantry[ingredient] = nil + end + + -- remove the character from the cookbook index + SousChef.settings.CookbookIndex[charName] = nil + + -- remove the character from the list of known characters + for k, v in pairs(SousChef.settings.knownChars) do + if v == charName then + table.remove(SousChef.settings.knownChars, k) + break + end + end + + -- and finally, refresh the data currently in memory + ChangeMainChar() +end + -- SousChefCreateSettings() creates the configuration menu for the add-on local function SousChefCreateSettings() local str = SousChef.Strings[SousChef.lang] @@ -384,6 +446,31 @@ local function SousChefCreateSettings() SousChef.RefreshViews() end, }) + local charList = { " " } + for k, v in pairs(SousChef.settings.knownChars) do + if v ~= "(current)" then table.insert(charList, v) end + end + local charToDelete = " " + table.insert(optionsMenu, { + type = "submenu", + name = str.MENU_DELETE_CHAR, + controls = { + [1] = { + type = "dropdown", + name = str.MENU_DELETE_CHAR, + tooltip = str.MENU_DELETE_CHAR_TOOLTIP, + choices = charList, + getFunc = function() return charToDelete end, + setFunc = function(value) charToDelete = value end, + }, + [2] = { + type = "button", + name = str.MENU_DELETE_CHAR_BUTTON, + tooltip = str.MENU_DELETE_CHAR_WARNING, + func = function() DeleteCharacter(charToDelete) end, + }, + } + }) LAM:RegisterOptionControls("SousChefSettings", optionsMenu) end diff --git a/SousChef.txt b/SousChef.txt index 7c404cc..5f41cf4 100644 --- a/SousChef.txt +++ b/SousChef.txt @@ -1,7 +1,7 @@ ## Title: Sous Chef by Wobin, CrazyDutchGuy & KatKat42 ## Author: Wobin & CrazyDutchGuy & KatKat42 ## Version: @project-version@ -## APIVersion: 100011 +## APIVersion: 100012 ## SavedVariables: SousChef_Settings ## OptionalDependsOn: LibStub LibSort LibAddonMenu-2.0 diff --git a/Strings.lua b/Strings.lua index d743cb3..408a66d 100644 --- a/Strings.lua +++ b/Strings.lua @@ -13,6 +13,7 @@ SousChef.Strings = { -- Menu items MENU_MAIN_CHAR = "Main Provisioner Character", MENU_MAIN_CHAR_TOOLTIP = "Select the character whose knowledge you want shown by the indicators", + MENU_RECIPE_HEADER = "Recipe Indicators", MENU_PROCESS_RECIPES = "Display Recipe Indicators", MENU_PROCESS_RECIPES_TOOLTIP = "Do you want Sous Chef to display indicators for recipes in the inventory view?", @@ -49,6 +50,12 @@ SousChef.Strings = { MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!", MENU_SORT_INGREDIENTS = "Sort Ingredients in Inventory", MENU_SORT_INGREDIENTS_TOOLTIP = "Will sort known ingredients by rank", + + MENU_DELETE_CHAR = "Delete a Character", + MENU_DELETE_CHAR_TOOLTIP = "Select a character to delete from Sous Chef's records, then press the \"Delete Character\" button.", + MENU_DELETE_CHAR_BUTTON = "Delete Character", + MENU_DELETE_CHAR_WARNING = "You are about to delete a character from Sous Chef's records. This can only be undone by logging into the deleted character!", + MENU_RELOAD = "Requires UI Reload", -- keybinding label @@ -62,6 +69,18 @@ SousChef.Strings = { TOOLTIP_KNOWN_BY = "Known by ", TOOLTIP_USED_IN = "Used in:", TOOLTIP_CREATES = "Creates a Level <<1>> <<t:2>>", -- where <<1>> is the level and <<2>> is the result name + TOOLTIP_INGREDIENT_TYPES = { + "Food Spice", + "Drink Flavoring", + "Meat", + "Fruit", + "Vegetable", + "Alcohol", + "Tea", + "Tonic", + "Food Ingredient", + "Drink Ingredient", + }, }, -- Thanks to sirinsidiator for the German translations here! @@ -119,6 +138,11 @@ SousChef.Strings = { MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!", MENU_SORT_INGREDIENTS = "Zutaten im Inventar sortieren", MENU_SORT_INGREDIENTS_TOOLTIP = "Zutaten im Inventar werden nach Rang sortiert", + + MENU_DELETE_CHAR = "Delete a Character", + MENU_DELETE_CHAR_TOOLTIP = "Select a character to delete from Sous Chef's records, then press the \"Delete Character\" button.", + MENU_DELETE_CHAR_BUTTON = "Delete Character", + MENU_RELOAD = "Ben\195\182tigt das Neuladen der Benutzeroberfl\195\164che (/reloadui)", -- keybinding label @@ -132,6 +156,18 @@ SousChef.Strings = { TOOLTIP_KNOWN_BY = "Gelernt von ", TOOLTIP_USED_IN = "Verwendet in:", TOOLTIP_CREATES = "Creates a Level <<1>> <<t:2>>", -- where <<1>> is the level and <<2>> is the result name + TOOLTIP_INGREDIENT_TYPES = { + "Gew\195\188rz ", + "Geschmackstr\195\164ger", + "Fleisch", + "Frucht", + "Gem\195\188se", + "Alkohol", + "Tee", + "Tonik", + "Nahrungsmaterial", + "Getr\195\164nksmaterial", + }, }, --Thanks to Ayantir for the French translations here! @@ -189,6 +225,11 @@ SousChef.Strings = { MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!", MENU_SORT_INGREDIENTS = "Trier les ingrédients dans les sacs", MENU_SORT_INGREDIENTS_TOOLTIP = "Cette option activée, les ingrédients seront triés par rang dans les sacs", + + MENU_DELETE_CHAR = "Delete a Character", + MENU_DELETE_CHAR_TOOLTIP = "Select a character to delete from Sous Chef's records, then press the \"Delete Character\" button.", + MENU_DELETE_CHAR_BUTTON = "Delete Character", + MENU_RELOAD = "Nécessite de recharger l'interface (ReloadUI)", -- keybinding label @@ -202,5 +243,17 @@ SousChef.Strings = { TOOLTIP_KNOWN_BY = "Connue par ", TOOLTIP_USED_IN = "Utilisé par :", TOOLTIP_CREATES = "Creates a Level <<1>> <<t:2>>", -- where <<1>> is the level and <<2>> is the result name + TOOLTIP_INGREDIENT_TYPES = { + "Food Spice", + "Drink Flavoring", + "Meat", + "Fruit", + "Vegetable", + "Alcohol", + "Tea", + "Tonic", + "Food Ingredient", + "Drink Ingredient", + }, }, } \ No newline at end of file diff --git a/media/Five.dds b/media/Five.dds deleted file mode 100644 index 500fc87..0000000 Binary files a/media/Five.dds and /dev/null differ diff --git a/media/Four.dds b/media/Four.dds deleted file mode 100644 index 906b145..0000000 Binary files a/media/Four.dds and /dev/null differ diff --git a/media/One.dds b/media/One.dds deleted file mode 100644 index 2986149..0000000 Binary files a/media/One.dds and /dev/null differ diff --git a/media/Six.dds b/media/Six.dds deleted file mode 100644 index 6a4f795..0000000 Binary files a/media/Six.dds and /dev/null differ diff --git a/media/Spice_Flat.dds b/media/Spice_Flat.dds deleted file mode 100644 index d299093..0000000 Binary files a/media/Spice_Flat.dds and /dev/null differ diff --git a/media/Three.dds b/media/Three.dds deleted file mode 100644 index 2dc56ab..0000000 Binary files a/media/Three.dds and /dev/null differ diff --git a/media/Two.dds b/media/Two.dds deleted file mode 100644 index e56a48c..0000000 Binary files a/media/Two.dds and /dev/null differ diff --git a/media/five_flat.dds b/media/five_flat.dds deleted file mode 100644 index eb71e43..0000000 Binary files a/media/five_flat.dds and /dev/null differ diff --git a/media/flavour_flat.dds b/media/flavour_flat.dds deleted file mode 100644 index fb57fd3..0000000 Binary files a/media/flavour_flat.dds and /dev/null differ diff --git a/media/four_flat.dds b/media/four_flat.dds deleted file mode 100644 index bc61ef3..0000000 Binary files a/media/four_flat.dds and /dev/null differ diff --git a/media/one_flat.dds b/media/one_flat.dds deleted file mode 100644 index dbfa18c..0000000 Binary files a/media/one_flat.dds and /dev/null differ diff --git a/media/six_flat.dds b/media/six_flat.dds deleted file mode 100644 index ac2e11d..0000000 Binary files a/media/six_flat.dds and /dev/null differ diff --git a/media/three_flat.dds b/media/three_flat.dds deleted file mode 100644 index 37a938b..0000000 Binary files a/media/three_flat.dds and /dev/null differ diff --git a/media/two_flat.dds b/media/two_flat.dds deleted file mode 100644 index 22f5336..0000000 Binary files a/media/two_flat.dds and /dev/null differ