LibKeepTooltip (1.0.0)

Small library for some other addons to change keep tooltip. Also increases overall performance of tooltip but since default tooltip is fast enough, this change noticeable only with ESOProfiler 🙂
If you want to use it, read instructions below.
Structure
All tooltips consist of lines added one by one, starting from header (keep name). This is used by ZOS team by default, but code itself is a big monolith full of checks and indentations, because of that it is hardly modifiable. I redesigned this approach and split entire code to part (separate lines) to be able to add and delete line independently for different keep types. Different lines called ‘ingredients’ and list of ingredients called ‘recipe’.
— all default ingredients
local INGREDIENTS = {
HEADER = 1,
ALLIANCE_OWNER = 2,
GUILD_OWNER = 3,
SIEGES = 4,
ARTIFACT = 5,
TEL_VAR_BONUS = 6,
KEEP_CAPTURE_BONUS = 7,
IS_PASSABLE = 8,
FAST_TRAVEL = 9,
KEEP_UNDER_ATTACK = 10,
RESPAWN = 11,
}
— keep recipe for example
local USUAL_KEEP_TOOLTIP_RECIPE = {
INGRIDIENTS.HEADER,
INGRIDIENTS.ALLIANCE_OWNER,
INGRIDIENTS.GUILD_OWNER,
INGRIDIENTS.SIEGES,
INGRIDIENTS.KEEP_CAPTURE_BONUS,
INGRIDIENTS.FAST_TRAVEL,
INGRIDIENTS.KEEP_UNDER_ATTACK,
INGRIDIENTS.RESPAWN,
}
All tooltips are BACKED based on a recipe. You can change a recipe with API (add or hide some particular lines). This addon fully replaces default LayoutKeepTooltip via PreHook (default function will be executed in case of major error).
API
local LKT = LibKeepTooltip
— be sure to call it in order to actually start to change tooltips. Idempotent
LKT:InitializeChangedTooltips()
— register ingredient first, name must be unique, callback must be callable
LKT:RegisterIngridient(name, callback)
— adds ingredient to particular recipe at particular index
LKT:AddIngridient(recipe, ingredient, index)
— removes ingredient from particular recipe (will not throw error if not found, if successfuly removed – returns index of ingredient removed)
LKT:RemoveIngridient(recipe, ingredient)
— adds ingredient to particular recipe after some other ingredient (throws error if not found)
LKT:AddIngridientAfter(recipe, ingredient, after)
— adds ingredient to particular recipe after some other ingredient (throws error if not found)
LKT:AddIngridientBefore(recipe, ingredient, before)
— get recepie of particular keep
LKT.GetRecipeByKeepType(keepType)
— use it to actually and line to tooltip, each ingredient callback must contain at least one. First parameter must be self.
LKT.AddLine(self, string, lineType)
Simple example
This example will add secret ingredient before fast travel line (last line in almost all recipes).
local LKT = LibKeepTooltip
local function SecretIngredientCallback(self)
LKT.AddLine(self, ‘My new line’, LKT.KEEP_TOOLTIP_NORMAL_LINE)
end
local MY_SECRET_INGREDIENT = LKT:RegisterIngridient(‘SECRET_INGREDIENT’, SecretIngredientCallback)
local USUAL_KEEP_TOOLTIP_RECIPE = LKT.GetRecipeByKeepType(KEEPTYPE_KEEP)
LKT.AddIngridientBefore(USUAL_KEEP_TOOLTIP_RECIPE, MY_SECRET_INGREDIENT, LKT.INGRIDIENTS.FAST_TRAVEL)
Contact me
via Discord (@imPDA)
GitHub