Merge pull request #9 from AssemblerManiac/master

manavortex [02-23-19 - 15:55]
Merge pull request #9 from AssemblerManiac/master

context menu popup using callback instead of ui func overwrite
Filename
.gitignore
FurCContextMenu.lua
startup.lua
diff --git a/.gitignore b/.gitignore
index ba4c541..c85b669 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,4 +26,9 @@ $RECYCLE.BIN/
 # Windows shortcuts
 *.lnk

-# End of https://www.gitignore.io/api/windows
\ No newline at end of file
+# End of https://www.gitignore.io/api/windows
+
+btm/
+btm/*
+.gitattributes
+
diff --git a/FurCContextMenu.lua b/FurCContextMenu.lua
index 43b9f3b..e435840 100644
--- a/FurCContextMenu.lua
+++ b/FurCContextMenu.lua
@@ -2,119 +2,132 @@ FurC_LinkHandlerBackup_OnLinkMouseUp = nil

 local FURC_S_SHOPPINGLIST_1 = GetString(SI_FURC_ONE_TO_SHOPPINGLIST)
 local FURC_S_SHOPPINGLIST_5 = GetString(SI_FURC_FIVE_TO_SHOPPINGLIST)
-local FURC_S_TOGGLE_SL      = GetString(SI_FURC_TOGGLE_SHOPPINGLIST)
+local FURC_S_TOGGLE_SL		= GetString(SI_FURC_TOGGLE_SHOPPINGLIST)

 function AddFurnitureShoppingListMenuEntry(itemId, calledFromFurC)
-
-    if calledFromFurC then
-    if (not FurC.GetEnableShoppingList()) then return end
-    if (nil ==  moc()) or (nil == FurnitureShoppingListAdd) then return end
-    local controlName = moc():GetName() or ""
-    if nil == moc():GetName():match("_ListItem_") then return end
-  end
-
-  local itemLink = FurC.GetItemLink(itemId)
-  if nil == FurC.Find(itemLink) then return end
-  AddCustomMenuItem(FURC_S_SHOPPINGLIST_1,
-    function()
-      FurnitureShoppingListAdd(itemLink)
-    end,
-  MENU_ADD_OPTION_LABEL)
-  AddCustomMenuItem(FURC_S_SHOPPINGLIST_5,
-    function()
-      FurnitureShoppingListAdd(itemLink)
-      FurnitureShoppingListAdd(itemLink)
-      FurnitureShoppingListAdd(itemLink)
-      FurnitureShoppingListAdd(itemLink)
-      FurnitureShoppingListAdd(itemLink)
-    end,
-  MENU_ADD_OPTION_LABEL)
-  AddCustomMenuItem(FURC_S_TOGGLE_SL,
-    function()
-      FurnitureShoppingListWindow_Toggle()
-    end,
-  MENU_ADD_OPTION_LABEL)
+
+	if calledFromFurC then
+		if (not FurC.GetEnableShoppingList()) then return end
+		if (nil ==	moc()) or (nil == FurnitureShoppingListAdd) then return end
+		local controlName = moc():GetName() or ""
+		if nil == moc():GetName():match("_ListItem_") then return end
+	end
+
+	local itemLink = FurC.GetItemLink(itemId)
+	if nil == FurC.Find(itemLink) then return end
+	AddCustomMenuItem(FURC_S_SHOPPINGLIST_1,
+		function()
+			FurnitureShoppingListAdd(itemLink)
+		end,
+	MENU_ADD_OPTION_LABEL)
+	AddCustomMenuItem(FURC_S_SHOPPINGLIST_5,
+		function()
+			FurnitureShoppingListAdd(itemLink)
+			FurnitureShoppingListAdd(itemLink)
+			FurnitureShoppingListAdd(itemLink)
+			FurnitureShoppingListAdd(itemLink)
+			FurnitureShoppingListAdd(itemLink)
+		end,
+	MENU_ADD_OPTION_LABEL)
+	AddCustomMenuItem(FURC_S_TOGGLE_SL,
+		function()
+			FurnitureShoppingListWindow_Toggle()
+		end,
+	MENU_ADD_OPTION_LABEL)

 end

 local cachedItemLink, cachedRecipeArray

-local function toChat()             FurC.ToChat(cachedItemLink) end
-local function fave()               FurC.Fave(cachedItemLink) end
-local function postItemSource()     FurC.ToChat(FurC.GetItemDescription(cachedItemLink, cachedRecipeArray, true, true)) end
-local function postRecipe()         FurC.ToChat(FurC.GetItemLink(cachedRecipeArray.blueprint)) end
-local function postRecipeResult()   FurC.ToChat(GetItemLinkRecipeResultItemLink(cachedItemLink)) end
-local function postMaterial()       FurC.ToChat(FurC.GetMats(cachedItemLink, cachedRecipeArray, true, true)) end
-
+local function toChat()				FurC.ToChat(cachedItemLink) end
+local function fave()				FurC.Fave(cachedItemLink) end
+local function postItemSource()		FurC.ToChat(FurC.GetItemDescription(cachedItemLink, cachedRecipeArray, true, true)) end
+local function postRecipe()			FurC.ToChat(FurC.GetItemLink(cachedRecipeArray.blueprint)) end
+local function postRecipeResult()	FurC.ToChat(GetItemLinkRecipeResultItemLink(cachedItemLink)) end
+local function postMaterial()		FurC.ToChat(FurC.GetMats(cachedItemLink, cachedRecipeArray, true, true))
+end

 local function doNothing() return end

-local S_DIVIDER     = "-"
-local function addMenuItems(itemLink, recipeArray)
-
-  recipeArray = recipeArray or FurC.Find(itemLink)
-  if not recipeArray or recipeArray == {} then return end
-
-    cachedItemLink = itemLink
-    cachedRecipeArray = recipeArray
-
-    if not FurC.GetSkipDivider() then
-        AddCustomMenuItem(S_DIVIDER,    doNothing, MENU_ADD_OPTION_LABEL)
-    end
-
-  AddCustomMenuItem(GetString(SI_FURC_MENU_HEADER), toChat, MENU_ADD_OPTION_LABEL)
-
-
-  local faveText = FurC.IsFavorite(itemLink, recipeArray) and GetString(SI_FURC_REMOVE_FAVE) or GetString(SI_FURC_ADD_FAVE)
-  AddCustomMenuItem(faveText, fave, MENU_ADD_OPTION_LABEL)
-
-  local isRecipe = IsItemLinkFurnitureRecipe(itemLink)
-
-  -- if we hold a recipe: allow posting recipe
-  if not isRecipe and recipeArray.blueprint then
-    AddCustomMenuItem(GetString(SI_FURC_POST_RECIPE),  postRecipe, MENU_ADD_OPTION_LABEL)
-
-    -- if it's a recipe: Allow posting item
-  elseif isRecipe then
-    AddCustomMenuItem(GetString(SI_FURC_POST_ITEM),     postRecipeResult, MENU_ADD_OPTION_LABEL)
-  end
-
-  if recipeArray.origin ~= FURC_CRAFTING then
-    AddCustomMenuItem(GetString(SI_FURC_POST_ITEMSOURCE),   postItemSource, MENU_ADD_OPTION_LABEL)
-  else
-
-    -- post material list
-    AddCustomMenuItem(GetString(SI_FURC_POST_MATERIAL),     postMaterial, MENU_ADD_OPTION_LABEL)
-
-    -- will do nothing if preferences not met
-    AddFurnitureShoppingListMenuEntry(itemLink, true)
-  end
+local S_DIVIDER = "-"
+local function addMenuItems(itemLink, recipeArray, hideSepBar)
+	hideSepBar = hideSepBar or false
+	recipeArray = recipeArray or FurC.Find(itemLink)
+	if not recipeArray or recipeArray == {} then return end
+
+	cachedItemLink = itemLink
+	cachedRecipeArray = recipeArray
+
+	if not FurC.GetSkipDivider() and (not hideSepBar) then
+		AddCustomMenuItem(S_DIVIDER, doNothing, MENU_ADD_OPTION_LABEL)
+	end
+
+	AddCustomMenuItem(GetString(SI_FURC_MENU_HEADER), toChat, MENU_ADD_OPTION_LABEL)
+
+	local faveText = FurC.IsFavorite(itemLink, recipeArray) and GetString(SI_FURC_REMOVE_FAVE) or GetString(SI_FURC_ADD_FAVE)
+	AddCustomMenuItem(faveText, fave, MENU_ADD_OPTION_LABEL)
+
+	local isRecipe = IsItemLinkFurnitureRecipe(itemLink)
+
+	-- if we hold a recipe: allow posting recipe
+	if not isRecipe and recipeArray.blueprint then
+		AddCustomMenuItem(GetString(SI_FURC_POST_RECIPE),	postRecipe, MENU_ADD_OPTION_LABEL)
+
+		-- if it's a recipe: Allow posting item
+	elseif isRecipe then
+		AddCustomMenuItem(GetString(SI_FURC_POST_ITEM),		 postRecipeResult, MENU_ADD_OPTION_LABEL)
+	end
+
+	if recipeArray.origin ~= FURC_CRAFTING then
+		AddCustomMenuItem(GetString(SI_FURC_POST_ITEMSOURCE),	 postItemSource, MENU_ADD_OPTION_LABEL)
+	else
+
+		-- post material list
+		AddCustomMenuItem(GetString(SI_FURC_POST_MATERIAL),		 postMaterial, MENU_ADD_OPTION_LABEL)
+
+		-- will do nothing if preferences not met
+		AddFurnitureShoppingListMenuEntry(itemLink, true)
+	end
 end

-function FurC_HandleClickEvent(itemLink, button, control)    -- button being mouseButton here
-  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
-      FurC_LinkHandlerBackup_OnLinkMouseUp(itemLink, button, control)
-      if (button == 2 and itemLink ~= '') then
-        addMenuItems(itemLink, FurC.Find(itemLink))
-      end
-      ShowMenu(control)
-        end
-    end
+--[[ Original version
+function FurC_HandleClickEvent(itemLink, button, control)		-- button being mouseButton here
+	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
+			FurC_LinkHandlerBackup_OnLinkMouseUp(itemLink, button, control)
+			if (button == 2 and itemLink ~= '') then
+				addMenuItems(itemLink, FurC.Find(itemLink))
+			end
+			ShowMenu(control)
+		end
+	end
+end
+--]]
+function FurC_HandleClickEvent(itemLink, button, _, _, linkType, ...)    -- button being mouseButton here
+	if button == MOUSE_BUTTON_INDEX_RIGHT and
+		linkType == ITEM_LINK_TYPE and
+		type(itemLink) == 'string' and
+		#itemLink > 0 and
+		itemLink ~= '' then
+        zo_callLater(function()
+			addMenuItems(itemLink, FurC.Find(itemLink))
+			ShowMenu()
+		end)
+	end
 end


 function FurC_HandleMouseEnter(inventorySlot)
-  local inventorySlot = moc()
+	local inventorySlot = moc()

-  if nil == inventorySlot or nil == inventorySlot.dataEntry then return end
-  local data = inventorySlot.dataEntry.data
-  if nil == data then return end
+	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
+	local bagId, slotIndex = data.bagId, data.slotIndex
+	FurC.CurrentLink = GetItemLink(bagId, slotIndex)
+	if nil == FurC.CurrentLink then return end

 end

@@ -122,59 +135,58 @@ end
 -- thanks Randactyl for helping me with the handler :)
 function FurC_HandleInventoryContextMenu(control)

-  local st = ZO_InventorySlot_GetType(control)
-    local itemLink = nil
-    if st == SLOT_TYPE_ITEM
-  or st == SLOT_TYPE_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)
-    elseif st == SLOT_TYPE_STORE_BUY then
-        itemLink = GetStoreItemLink(control.index)
-    elseif st == SLOT_TYPE_TRADING_HOUSE_ITEM_RESULT then
-        itemLink = GetTradingHouseSearchResultItemLink(ZO_Inventory_GetSlotIndex(control), linkStyle)
-    elseif 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
-
-  zo_callLater(function()
-    addMenuItems(itemLink, recipeArray)
-    ShowMenu()
-  end, 50)
-
-
+	local st = ZO_InventorySlot_GetType(control)
+	local itemLink = nil
+	if st == SLOT_TYPE_ITEM or
+		st == SLOT_TYPE_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)
+	elseif st == SLOT_TYPE_STORE_BUY then
+		itemLink = GetStoreItemLink(control.index)
+	elseif st == SLOT_TYPE_TRADING_HOUSE_ITEM_RESULT then
+		itemLink = GetTradingHouseSearchResultItemLink(ZO_Inventory_GetSlotIndex(control), linkStyle)
+	elseif 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
+
+	zo_callLater(function()
+		addMenuItems(itemLink, recipeArray)
+		ShowMenu()
+	end, 50)
 end


 function FurC.OnControlMouseUp(control, button)

-  if nil == control then return end
+	if nil == control then return end

-  if button ~= 2 then return end
-  local itemLink = control.itemLink
+	if button ~= 2 then return end
+	local itemLink = control.itemLink

-  if nil == itemLink then return end
-  local recipeArray = FurC.Find(itemLink)
-  if nil == recipeArray then return end
-  zo_callLater(function()
-    ItemTooltip:SetHidden(true)
-    ClearMenu()
-    addMenuItems(itemLink, recipeArray)
-    ShowMenu()
-  end, 50)
+	if nil == itemLink then return end
+	local recipeArray = FurC.Find(itemLink)
+	if nil == recipeArray then return end
+	zo_callLater(function()
+		ItemTooltip:SetHidden(true)
+		ClearMenu()
+		addMenuItems(itemLink, recipeArray, true)
+		ShowMenu()
+	end, 50)

 end

 function FurC.InitRightclickMenu()
-  FurC_LinkHandlerBackup_OnLinkMouseUp = ZO_LinkHandler_OnLinkMouseUp
-  ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control) FurC_HandleClickEvent(itemLink, button, control) end
-  ZO_PreHook('ZO_InventorySlot_OnMouseEnter', FurC_HandleMouseEnter)
-  ZO_PreHook('ZO_InventorySlot_ShowContextMenu', function(rowControl)
-    FurC_HandleInventoryContextMenu(rowControl)
-  end)
+--	FurC_LinkHandlerBackup_OnLinkMouseUp = ZO_LinkHandler_OnLinkMouseUp
+--	ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control) FurC_HandleClickEvent(itemLink, button, control) end
+	LINK_HANDLER:RegisterCallback(LINK_HANDLER.LINK_MOUSE_UP_EVENT, FurC_HandleClickEvent)
+	ZO_PreHook('ZO_InventorySlot_OnMouseEnter', FurC_HandleMouseEnter)
+	ZO_PreHook('ZO_InventorySlot_ShowContextMenu', function(rowControl)
+		FurC_HandleInventoryContextMenu(rowControl)
+	end)
 end
diff --git a/startup.lua b/startup.lua
index 08eee9f..8d59ab0 100644
--- a/startup.lua
+++ b/startup.lua
@@ -1,296 +1,296 @@
-FurnitureCatalogue                = {}
-FurnitureCatalogue.name           = "FurnitureCatalogue"
-FurnitureCatalogue.author         = "manavortex"
-FurnitureCatalogue.version        = 3.1
-FurnitureCatalogue.CharacterName  = nil
-FurnitureCatalogue.settings       = {}
-
-FurC                               = FurnitureCatalogue
-
-FurC.AchievementVendors           = {}
-FurC.LuxuryFurnisher              = {}
-FurC.Recipes                      = {}
-FurC.Rolis                        = {}
-FurC.Faustina                     = {}
-FurC.RolisRecipes                 = {}
-FurC.FaustinaRecipes              = {}
-FurC.Books                        = {}
-FurC.EventItems                   = {}
-FurC.PVP                          = {}
-FurC.MiscItemSources              = {}
-
--- versioning
-FURC_HOMESTEAD            = 2
-FURC_MORROWIND            = 3
-FURC_REACH                = 4
-FURC_CLOCKWORK            = 5
-FURC_DRAGONS              = 6
-FURC_ALTMER               = 7
-FURC_WEREWOLF             = 8
-FURC_SLAVES               = 9
-FURC_WOTL                 = 10
-
-FurC.Const                          = {
-    vendorColor   = "d68957",
-    goldColor     = "e5da40",
-    apColor       = "25C31E",
-    tvColor       = "5EA4FF",
-    voucherColor  = "82BCFF",
-}
-
-local defaults             = {
-
-  hideMats              = true,
-  dontScanTradingHouse  = false,
-  enableDebug           = false,
-
-  data                 = {},
-  filterCraftingType   = {},
-  filterQuality        = {},
-
-  resetDropdownChoice  = false,
-  useTinyUi            = false,
-  useInventoryIcons    = true,
-  fontSize             = 18,
-
-  gui                 = {
-    lastX             = 100,
-    lastY             = 100,
-    width             = 650,
-    height            = 550,
-  },
-
-  dropdownDefaults    = {
-    Source            = 1,
-    Character         = 1,
-    Version           = 1,
-  },
-
-  accountCharacters    = {},
-
-  version              = 2.0,
-
-  -- tooltips
-  disableTooltips      = false,
-  coloredTooltips      = true,
-  hideKnowledge        = false,
-
-  hideBooks            = true,
-  hideDoubtfuls        = true,
-  hideCrownstore       = true,
-  hideRumourEntry      = false,
-  hideCrownStoreEntry  = false,
-  wipeDatabase         = false,
-  startupSilently      = true,
-
-}
-
-FURC_NONE        = 1
-FURC_FAVE         = FURC_NONE +1
-FURC_CRAFTING      = FURC_FAVE +1
-FURC_CRAFTING_KNOWN    = FURC_CRAFTING +1
-FURC_CRAFTING_UNKNOWN  = FURC_CRAFTING_KNOWN +1
-FURC_VENDOR       = FURC_CRAFTING_UNKNOWN +1
-FURC_PVP         = FURC_VENDOR +1
-FURC_CROWN         = FURC_PVP +1
-FURC_RUMOUR       = FURC_CROWN +1
-FURC_LUXURY       = FURC_RUMOUR +1
-FURC_OTHER         = FURC_LUXURY +1
-FURC_ROLIS           = FURC_OTHER +1
-FURC_DROP         = FURC_ROLIS +1
-FURC_WRIT_VENDOR     = FURC_DROP +1
-FURC_JUSTICE       = FURC_WRIT_VENDOR +1
-FURC_FISHING       = FURC_JUSTICE +1
-FURC_GUILDSTORE     = FURC_FISHING +1
-FURC_FESTIVAL_DROP     = FURC_GUILDSTORE +1
-FURC_EMPTY_STRING     = ""
-
-local sourceIndicesKeys = {}
-local function getSourceIndicesKeys()
-  sourceIndicesKeys[FURC_NONE]             = "off"
-  sourceIndicesKeys[FURC_FAVE]             = "favorites"
-  sourceIndicesKeys[FURC_CRAFTING]           = "craft_all"
-  sourceIndicesKeys[FURC_CRAFTING_KNOWN]         = "craft_known"
-  sourceIndicesKeys[FURC_CRAFTING_UNKNOWN]       = "craft_unknown"
-  sourceIndicesKeys[FURC_VENDOR]             = "purch_gold"
-  sourceIndicesKeys[FURC_PVP]             = "purch_ap"
-  sourceIndicesKeys[FURC_CROWN]               = "crownstore"
-  sourceIndicesKeys[FURC_RUMOUR]               = "rumour"
-  sourceIndicesKeys[FURC_LUXURY]               = "luxury"
-  sourceIndicesKeys[FURC_OTHER]             = "other"
-  sourceIndicesKeys[FURC_WRIT_VENDOR]         = "writ_vendor"
-  return sourceIndicesKeys
-end
-FurC.GetSourceIndicesKeys = getSourceIndicesKeys
-
-local choicesSource = {}
-local function getChoicesSource()
-  choicesSource[FURC_NONE]            = GetString(SI_FURC_NONE)
-  choicesSource[FURC_FAVE]             = GetString(SI_FURC_FAVE)
-  choicesSource[FURC_CRAFTING]           = GetString(SI_FURC_CRAFTING)
-  choicesSource[FURC_CRAFTING_KNOWN]         = GetString(SI_FURC_CRAFTING_KNOWN)
-  choicesSource[FURC_CRAFTING_UNKNOWN]       = GetString(SI_FURC_CRAFTING_UNKNOWN)
-  choicesSource[FURC_VENDOR]             = GetString(SI_FURC_VENDOR)
-  choicesSource[FURC_PVP]             = GetString(SI_FURC_PVP)
-  choicesSource[FURC_WRIT_VENDOR]         = GetString(SI_FURC_STRING_WRIT_VENDOR)
-  choicesSource[FURC_CROWN]               = GetString(SI_FURC_CROWN)
-  choicesSource[FURC_RUMOUR]               = GetString(SI_FURC_RUMOUR)
-  choicesSource[FURC_LUXURY]               = GetString(SI_FURC_LUXURY)
-  choicesSource[FURC_OTHER]                 = GetString(SI_FURC_OTHER)
-
-  return choicesSource
-end
-FurC.GetChoicesSource = getChoicesSource
-
-local tooltipsSource = {}
-local function getTooltipsSource()
-  tooltipsSource[FURC_NONE]            = GetString(SI_FURC_NONE_TT)
-  tooltipsSource[FURC_FAVE]             = GetString(SI_FURC_FAVE_TT)
-  tooltipsSource[FURC_CRAFTING]           = GetString(SI_FURC_CRAFTING_TT)
-  tooltipsSource[FURC_CRAFTING_KNOWN]       = GetString(SI_FURC_CRAFTING_KNOWN_TT)
-  tooltipsSource[FURC_CRAFTING_UNKNOWN]       = GetString(SI_FURC_CRAFTING_UNKNOWN_TT)
-  tooltipsSource[FURC_VENDOR]           = GetString(SI_FURC_VENDOR_TT)
-  tooltipsSource[FURC_PVP]             = GetString(SI_FURC_PVP_TT)
-    tooltipsSource[FURC_CROWN]               = GetString(SI_FURC_CROWN_TT)
-  tooltipsSource[FURC_WRIT_VENDOR]         = GetString(SI_FURC_STRING_WRIT_VENDOR_TT)
-    tooltipsSource[FURC_RUMOUR]             = GetString(SI_FURC_RUMOUR_TT)
-    tooltipsSource[FURC_LUXURY]             = GetString(SI_FURC_LUXURY_TT)
-  tooltipsSource[FURC_OTHER]                 = GetString(SI_FURC_OTHER_TT)
-
-  return tooltipsSource
-end
-
-FurnitureCatalogue.DropdownData = {
-  ChoicesVersion  = {
-    [1] = GetString(SI_FURC_FILTER_VERSION_OFF),
-    [2] = GetString(SI_FURC_FILTER_VERSION_HS  ),
-    [3] = GetString(SI_FURC_FILTER_VERSION_M  ),
-    [4] = GetString(SI_FURC_FILTER_VERSION_R  ),
-    [5] = GetString(SI_FURC_FILTER_VERSION_CC  ),
-    [6] = GetString(SI_FURC_FILTER_VERSION_DRAGON),
-    [7] = GetString(SI_FURC_FILTER_VERSION_ALTMER),
-    [8] = GetString(SI_FURC_FILTER_VERSION_SLAVES),
-    [9] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF),
-  },
-  TooltipsVersion  = {
-    [1] =  GetString(SI_FURC_FILTER_VERSION_OFF_TT),
-    [2] =  GetString(SI_FURC_FILTER_VERSION_HS_TT),
-    [3] =  GetString(SI_FURC_FILTER_VERSION_M_TT),
-    [4] =  GetString(SI_FURC_FILTER_VERSION_R_TT),
-    [5] =  GetString(SI_FURC_FILTER_VERSION_CC_TT),
-    [6] =  GetString(SI_FURC_FILTER_VERSION_DRAGON_TT),
-    [7] = GetString(SI_FURC_FILTER_VERSION_ALTMER_TT),
-    [8] = GetString(SI_FURC_FILTER_VERSION_SLAVES_TT),
-    [9] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF_TT),
-  },
-  ChoicesCharacter  = {
-    [1]  = GetString(SI_FURC_FILTER_CHAR_OFF),
-  },
-  TooltipsCharacter = {
-    [1]  = GetString(SI_FURC_FILTER_CHAR_OFF_TT),
-  },
-
-  -- will be set in setupSourceDropdown
-  ChoicesSource  = {},
-  TooltipsSource   = {},
-}
-if GetAPIVersion() == 100026 then
-    FurnitureCatalogue.DropdownData.ChoicesVersion[FURC_WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL)
-    FurnitureCatalogue.DropdownData.TooltipsVersion[FURC_WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL_TT)
-end
-
-local function updateDropdownData()
-  FurnitureCatalogue.DropdownData.ChoicesSource  = getChoicesSource()
-  FurnitureCatalogue.DropdownData.TooltipsSource = getTooltipsSource()
-end
-FurnitureCatalogue.updateDropdownData = updateDropdownData
-
-local function setupSourceDropdown()
-  updateDropdownData()
-  sourceIndices = {}
-
-  for idx, key in ipairs(getSourceIndicesKeys()) do
-    sourceIndices[key] = idx
-  end
-  FurC.SourceIndices = sourceIndices
-end
-
-function FurnitureCatalogue.DebugOut(output, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
-  if not FurC.GetEnableDebug() then return end
-  if a10 then
-    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
-  elseif a9 then
-    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8, a9))
-  elseif a8 then
-    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8))
-  elseif a7 then
-    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7))
-  elseif a6 then
-    d(zo_strformat(output, a1, a2, a3, a4, a5, a6))
-  elseif 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
-
-local function p(...)
-  FurC.DebugOut(...)
-end
-
-function whoami()
-  return FurnitureCatalogue.CharacterName
-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)
-
-  -- setup the "source" dropdown for the menu
-  setupSourceDropdown()
-
-  FurnitureCatalogue.CreateSettings(FurnitureCatalogue.settings, defaults, FurnitureCatalogue)
-
-  FurnitureCatalogue.CharacterName = zo_strformat(GetUnitName('player'))
-
-  FurC.RegisterEvents()
-
-  FurC.InitGui()
-
-  FurnitureCatalogue.CreateTooltips()
-  FurC.InitRightclickMenu()
-
-  FurC.SetupInventoryRecipeIcons()
-
-  local scanFiles = false
-  if FurC.settings.version     < FurC.version then
-      FurC.settings.version     = FurC.version
-    scanFiles = true
-  end
-
-  FurnitureCatalogue.ScanRecipes(scanFiles, not FurC.GetSkipInitialScan())
-  FurC.settings.databaseVersion   = FurC.version
-  SLASH_COMMANDS["/fur"]       = FurnitureCatalogue_Toggle
-
-  FurC.SetFilter(true)
-
-  EVENT_MANAGER:UnregisterForEvent("FurnitureCatalogue", EVENT_ADD_ON_LOADED)
-
-end
-
-ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_FURNITURE_CATALOGUE", "Toggle Furniture Catalogue")
-EVENT_MANAGER:RegisterForEvent("FurnitureCatalogue", EVENT_ADD_ON_LOADED, FurnitureCatalogue_Initialize)
-
+FurnitureCatalogue                = {}
+FurnitureCatalogue.name           = "FurnitureCatalogue"
+FurnitureCatalogue.author         = "manavortex"
+FurnitureCatalogue.version        = 3.1
+FurnitureCatalogue.CharacterName  = nil
+FurnitureCatalogue.settings       = {}
+
+FurC                               = FurnitureCatalogue
+
+FurC.AchievementVendors           = {}
+FurC.LuxuryFurnisher              = {}
+FurC.Recipes                      = {}
+FurC.Rolis                        = {}
+FurC.Faustina                     = {}
+FurC.RolisRecipes                 = {}
+FurC.FaustinaRecipes              = {}
+FurC.Books                        = {}
+FurC.EventItems                   = {}
+FurC.PVP                          = {}
+FurC.MiscItemSources              = {}
+
+-- versioning
+FURC_HOMESTEAD            = 2
+FURC_MORROWIND            = 3
+FURC_REACH                = 4
+FURC_CLOCKWORK            = 5
+FURC_DRAGONS              = 6
+FURC_ALTMER               = 7
+FURC_WEREWOLF             = 8
+FURC_SLAVES               = 9
+FURC_WOTL                 = 10
+
+FurC.Const                          = {
+    vendorColor   = "d68957",
+    goldColor     = "e5da40",
+    apColor       = "25C31E",
+    tvColor       = "5EA4FF",
+    voucherColor  = "82BCFF",
+}
+
+local defaults             = {
+
+  hideMats              = true,
+  dontScanTradingHouse  = false,
+  enableDebug           = false,
+
+  data                 = {},
+  filterCraftingType   = {},
+  filterQuality        = {},
+
+  resetDropdownChoice  = false,
+  useTinyUi            = false,
+  useInventoryIcons    = true,
+  fontSize             = 18,
+
+  gui                 = {
+    lastX             = 100,
+    lastY             = 100,
+    width             = 650,
+    height            = 550,
+  },
+
+  dropdownDefaults    = {
+    Source            = 1,
+    Character         = 1,
+    Version           = 1,
+  },
+
+  accountCharacters    = {},
+
+  version              = 2.0,
+
+  -- tooltips
+  disableTooltips      = false,
+  coloredTooltips      = true,
+  hideKnowledge        = false,
+
+  hideBooks            = true,
+  hideDoubtfuls        = true,
+  hideCrownstore       = true,
+  hideRumourEntry      = false,
+  hideCrownStoreEntry  = false,
+  wipeDatabase         = false,
+  startupSilently      = true,
+
+}
+
+FURC_NONE        = 1
+FURC_FAVE         = FURC_NONE +1
+FURC_CRAFTING      = FURC_FAVE +1
+FURC_CRAFTING_KNOWN    = FURC_CRAFTING +1
+FURC_CRAFTING_UNKNOWN  = FURC_CRAFTING_KNOWN +1
+FURC_VENDOR       = FURC_CRAFTING_UNKNOWN +1
+FURC_PVP         = FURC_VENDOR +1
+FURC_CROWN         = FURC_PVP +1
+FURC_RUMOUR       = FURC_CROWN +1
+FURC_LUXURY       = FURC_RUMOUR +1
+FURC_OTHER         = FURC_LUXURY +1
+FURC_ROLIS           = FURC_OTHER +1
+FURC_DROP         = FURC_ROLIS +1
+FURC_WRIT_VENDOR     = FURC_DROP +1
+FURC_JUSTICE       = FURC_WRIT_VENDOR +1
+FURC_FISHING       = FURC_JUSTICE +1
+FURC_GUILDSTORE     = FURC_FISHING +1
+FURC_FESTIVAL_DROP     = FURC_GUILDSTORE +1
+FURC_EMPTY_STRING     = ""
+
+local sourceIndicesKeys = {}
+local function getSourceIndicesKeys()
+  sourceIndicesKeys[FURC_NONE]             = "off"
+  sourceIndicesKeys[FURC_FAVE]             = "favorites"
+  sourceIndicesKeys[FURC_CRAFTING]           = "craft_all"
+  sourceIndicesKeys[FURC_CRAFTING_KNOWN]         = "craft_known"
+  sourceIndicesKeys[FURC_CRAFTING_UNKNOWN]       = "craft_unknown"
+  sourceIndicesKeys[FURC_VENDOR]             = "purch_gold"
+  sourceIndicesKeys[FURC_PVP]             = "purch_ap"
+  sourceIndicesKeys[FURC_CROWN]               = "crownstore"
+  sourceIndicesKeys[FURC_RUMOUR]               = "rumour"
+  sourceIndicesKeys[FURC_LUXURY]               = "luxury"
+  sourceIndicesKeys[FURC_OTHER]             = "other"
+  sourceIndicesKeys[FURC_WRIT_VENDOR]         = "writ_vendor"
+  return sourceIndicesKeys
+end
+FurC.GetSourceIndicesKeys = getSourceIndicesKeys
+
+local choicesSource = {}
+local function getChoicesSource()
+  choicesSource[FURC_NONE]            = GetString(SI_FURC_NONE)
+  choicesSource[FURC_FAVE]             = GetString(SI_FURC_FAVE)
+  choicesSource[FURC_CRAFTING]           = GetString(SI_FURC_CRAFTING)
+  choicesSource[FURC_CRAFTING_KNOWN]         = GetString(SI_FURC_CRAFTING_KNOWN)
+  choicesSource[FURC_CRAFTING_UNKNOWN]       = GetString(SI_FURC_CRAFTING_UNKNOWN)
+  choicesSource[FURC_VENDOR]             = GetString(SI_FURC_VENDOR)
+  choicesSource[FURC_PVP]             = GetString(SI_FURC_PVP)
+  choicesSource[FURC_WRIT_VENDOR]         = GetString(SI_FURC_STRING_WRIT_VENDOR)
+  choicesSource[FURC_CROWN]               = GetString(SI_FURC_CROWN)
+  choicesSource[FURC_RUMOUR]               = GetString(SI_FURC_RUMOUR)
+  choicesSource[FURC_LUXURY]               = GetString(SI_FURC_LUXURY)
+  choicesSource[FURC_OTHER]                 = GetString(SI_FURC_OTHER)
+
+  return choicesSource
+end
+FurC.GetChoicesSource = getChoicesSource
+
+local tooltipsSource = {}
+local function getTooltipsSource()
+  tooltipsSource[FURC_NONE]            = GetString(SI_FURC_NONE_TT)
+  tooltipsSource[FURC_FAVE]             = GetString(SI_FURC_FAVE_TT)
+  tooltipsSource[FURC_CRAFTING]           = GetString(SI_FURC_CRAFTING_TT)
+  tooltipsSource[FURC_CRAFTING_KNOWN]       = GetString(SI_FURC_CRAFTING_KNOWN_TT)
+  tooltipsSource[FURC_CRAFTING_UNKNOWN]       = GetString(SI_FURC_CRAFTING_UNKNOWN_TT)
+  tooltipsSource[FURC_VENDOR]           = GetString(SI_FURC_VENDOR_TT)
+  tooltipsSource[FURC_PVP]             = GetString(SI_FURC_PVP_TT)
+    tooltipsSource[FURC_CROWN]               = GetString(SI_FURC_CROWN_TT)
+  tooltipsSource[FURC_WRIT_VENDOR]         = GetString(SI_FURC_STRING_WRIT_VENDOR_TT)
+    tooltipsSource[FURC_RUMOUR]             = GetString(SI_FURC_RUMOUR_TT)
+    tooltipsSource[FURC_LUXURY]             = GetString(SI_FURC_LUXURY_TT)
+  tooltipsSource[FURC_OTHER]                 = GetString(SI_FURC_OTHER_TT)
+
+  return tooltipsSource
+end
+
+FurnitureCatalogue.DropdownData = {
+  ChoicesVersion  = {
+    [1] = GetString(SI_FURC_FILTER_VERSION_OFF),
+    [2] = GetString(SI_FURC_FILTER_VERSION_HS  ),
+    [3] = GetString(SI_FURC_FILTER_VERSION_M  ),
+    [4] = GetString(SI_FURC_FILTER_VERSION_R  ),
+    [5] = GetString(SI_FURC_FILTER_VERSION_CC  ),
+    [6] = GetString(SI_FURC_FILTER_VERSION_DRAGON),
+    [7] = GetString(SI_FURC_FILTER_VERSION_ALTMER),
+    [8] = GetString(SI_FURC_FILTER_VERSION_SLAVES),
+    [9] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF),
+  },
+  TooltipsVersion  = {
+    [1] =  GetString(SI_FURC_FILTER_VERSION_OFF_TT),
+    [2] =  GetString(SI_FURC_FILTER_VERSION_HS_TT),
+    [3] =  GetString(SI_FURC_FILTER_VERSION_M_TT),
+    [4] =  GetString(SI_FURC_FILTER_VERSION_R_TT),
+    [5] =  GetString(SI_FURC_FILTER_VERSION_CC_TT),
+    [6] =  GetString(SI_FURC_FILTER_VERSION_DRAGON_TT),
+    [7] = GetString(SI_FURC_FILTER_VERSION_ALTMER_TT),
+    [8] = GetString(SI_FURC_FILTER_VERSION_SLAVES_TT),
+    [9] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF_TT),
+  },
+  ChoicesCharacter  = {
+    [1]  = GetString(SI_FURC_FILTER_CHAR_OFF),
+  },
+  TooltipsCharacter = {
+    [1]  = GetString(SI_FURC_FILTER_CHAR_OFF_TT),
+  },
+
+  -- will be set in setupSourceDropdown
+  ChoicesSource  = {},
+  TooltipsSource   = {},
+}
+if GetAPIVersion() == 100026 then
+    FurnitureCatalogue.DropdownData.ChoicesVersion[FURC_WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL)
+    FurnitureCatalogue.DropdownData.TooltipsVersion[FURC_WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL_TT)
+end
+
+local function updateDropdownData()
+  FurnitureCatalogue.DropdownData.ChoicesSource  = getChoicesSource()
+  FurnitureCatalogue.DropdownData.TooltipsSource = getTooltipsSource()
+end
+FurnitureCatalogue.updateDropdownData = updateDropdownData
+
+local function setupSourceDropdown()
+  updateDropdownData()
+  sourceIndices = {}
+
+  for idx, key in ipairs(getSourceIndicesKeys()) do
+    sourceIndices[key] = idx
+  end
+  FurC.SourceIndices = sourceIndices
+end
+
+function FurnitureCatalogue.DebugOut(output, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
+  if not FurC.GetEnableDebug() then return end
+  if a10 then
+    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
+  elseif a9 then
+    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8, a9))
+  elseif a8 then
+    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7, a8))
+  elseif a7 then
+    d(zo_strformat(output, a1, a2, a3, a4, a5, a6, a7))
+  elseif a6 then
+    d(zo_strformat(output, a1, a2, a3, a4, a5, a6))
+  elseif 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
+
+local function p(...)
+  FurC.DebugOut(...)
+end
+
+function whoami()
+  return FurnitureCatalogue.CharacterName
+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)
+
+  -- setup the "source" dropdown for the menu
+  setupSourceDropdown()
+
+  FurnitureCatalogue.CreateSettings(FurnitureCatalogue.settings, defaults, FurnitureCatalogue)
+
+  FurnitureCatalogue.CharacterName = zo_strformat(GetUnitName('player'))
+
+  FurC.RegisterEvents()
+
+  FurC.InitGui()
+
+  FurnitureCatalogue.CreateTooltips()
+  FurC.InitRightclickMenu()
+
+  FurC.SetupInventoryRecipeIcons()
+
+  local scanFiles = false
+  if FurC.settings.version     < FurC.version then
+      FurC.settings.version     = FurC.version
+    scanFiles = true
+  end
+
+  FurnitureCatalogue.ScanRecipes(scanFiles, not FurC.GetSkipInitialScan())
+  FurC.settings.databaseVersion   = FurC.version
+  SLASH_COMMANDS["/fur"]       = FurnitureCatalogue_Toggle
+
+  FurC.SetFilter(true)
+
+  EVENT_MANAGER:UnregisterForEvent("FurnitureCatalogue", EVENT_ADD_ON_LOADED)
+
+end
+
+ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_FURNITURE_CATALOGUE", "Toggle Furniture Catalogue")
+EVENT_MANAGER:RegisterForEvent("FurnitureCatalogue", EVENT_ADD_ON_LOADED, FurnitureCatalogue_Initialize)
+