fixed up store vendor - changed file loading order

git [07-06-18 - 12:26]
fixed up store vendor - changed file loading order
Filename
FurCContextMenu.lua
FurCData.lua
FurnitureCatalogue.txt
FurnitureCatalogue_DevUtility/ContextMenu.lua
data/Recipes.lua
startup.lua
diff --git a/FurCContextMenu.lua b/FurCContextMenu.lua
index b53e630..b5bb4d7 100644
--- a/FurCContextMenu.lua
+++ b/FurCContextMenu.lua
@@ -2,15 +2,17 @@ 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 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,
@@ -61,14 +63,20 @@ local function addMenuItems(itemLink, recipeArray)
 	if recipeArray.origin ~= FURC_CRAFTING then
 		AddCustomMenuItem(GetString(SI_FURC_POST_ITEMSOURCE),   postItemSource, MENU_ADD_OPTION_LABEL)
 	else
-        local isRecipe
-		if isRecipe then
+
+    -- if it's a recipe: Allow posting item
+		if IsItemLinkFurnitureRecipe(itemLink) then
 			AddCustomMenuItem(GetString(SI_FURC_POST_ITEM),     postRecipeResult, MENU_ADD_OPTION_LABEL)
-		end
-        if isRecipe or recipeArray.blueprint then
-             AddCustomMenuItem(GetString(SI_FURC_POST_RECIPE),   postRecipe, MENU_ADD_OPTION_LABEL)
-        end
+
+    -- if it's not a recipe, but we hold a recipe: allow posting recipe
+		elseif recipeArray.blueprint then
+             AddCustomMenuItem(GetString(SI_FURC_POST_RECIPE),  postRecipe, MENU_ADD_OPTION_LABEL)
+        end
+
+    -- 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
@@ -112,11 +120,11 @@ function FurC_HandleInventoryContextMenu(control)
 	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
+    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)
-    end
-    if st == SLOT_TYPE_TRADING_HOUSE_ITEM_LISTING then
+    elseif st == SLOT_TYPE_TRADING_HOUSE_ITEM_LISTING then
         itemLink = GetTradingHouseListingItemLink(ZO_Inventory_GetSlotIndex(control), linkStyle)
     end

diff --git a/FurCData.lua b/FurCData.lua
index 0f58e72..07522dd 100644
--- a/FurCData.lua
+++ b/FurCData.lua
@@ -451,22 +451,23 @@ local function scanFromFiles(shouldScanCharacter)
 			addDatabaseEntry(itemId, recipeArray)
 		end
 	end
-	FurC.IsLoading(true)
-
-	task:Call(scanRecipeFile)
-	:Then(scanMiscItemFile)
-	:Then(scanVendorFiles)
-	:Then(scanRolis)
-	:Then(scanFestivalFiles)
-	:Then(
-	function()
-		if shouldScanCharacter then
+    local function scanCharacterOrMaybeNot()
+        if shouldScanCharacter then
 			scanCharacter()
 		else
 			startupMessage(GetString(SI_FURC_VERBOSE_STARTUP))
 		end
-	end)
+    end
+
+	FurC.IsLoading(true)
+
+	task:Call(scanMiscItemFile)
 	:Then(scanRumourRecipes)
+	:Then(scanRecipeFile)
+	:Then(scanVendorFiles)
+	:Then(scanRolis)
+	:Then(scanFestivalFiles)
+	:Then(scanCharacterOrMaybeNot)
 	:Then(FurC.UpdateGui)
 	startupMessage(GetString(SI_FURC_VERBOSE_DB_UPTODATE))

@@ -507,7 +508,8 @@ function FurC.ScanRecipes(shouldScanFiles, shouldScanCharacter)								-- return
 end

 function FurC.GetItemDescription(recipeKey, recipeArray, stripColor)
-FurC.settings.emptyItemSources =  FurC.settings.emptyItemSources or {}
+    recipeKey = FurC.GetItemId(recipeKey)
+    FurC.settings.emptyItemSources =  FurC.settings.emptyItemSources or {}
 	recipeArray = recipeArray or FurC.Find(recipeKey, recipeArray)
 	if not recipeArray then return "" end
 	local origin = recipeArray.origin
diff --git a/FurnitureCatalogue.txt b/FurnitureCatalogue.txt
index 498b256..046f2e6 100644
--- a/FurnitureCatalogue.txt
+++ b/FurnitureCatalogue.txt
@@ -1,6 +1,6 @@
 ## Title: FurnitureCatalogue
 ## Author: manavortex
-## Version: 2.5.9
+## Version: 2.5.10
 ## APIVersion: 100023
 ## SavedVariables: FurnitureCatalogue_Settings
 ## OptionalDependsOn: pChat
diff --git a/FurnitureCatalogue_DevUtility/ContextMenu.lua b/FurnitureCatalogue_DevUtility/ContextMenu.lua
index 31e36a0..e689261 100644
--- a/FurnitureCatalogue_DevUtility/ContextMenu.lua
+++ b/FurnitureCatalogue_DevUtility/ContextMenu.lua
@@ -4,8 +4,6 @@ local function whoami()
 end

 local isMana    = string.find(whoami(), "@manavortex") or string.find(whoami(), "@Manorin")
-if not isMana   then return end
-


 FurCDevControl_LinkHandlerBackup_OnLinkMouseUp  = nil
@@ -24,34 +22,48 @@ local p = this.p
 local cachedItemIds = {}

 local function showTextbox()
+    if not isMana   then return end
     this.textbox:GetParent():SetHidden(false)
     this.textbox:SetHidden(false)
 end
 function this.clearControl()
+    if not isMana   then return end
     this.textbox:Clear()
     ZO_ClearTable(cachedItemIds)
 end

 function this.selectEntireTextbox()
+    if not isMana   then return end
     if this.control:IsHidden() then return end
     local text = textbox:GetText() or ""
     textbox:SetSelection(0, #text)
 end

-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 defaultDebugString = "[%d] = GetString(SI_FURC_EXISITING_ITEMSOURCE_UNKNOWN_YET), -- %s"
+local debugStringWithPrice = "[%d] = { -- %s\n   itemPrice = %d, \n},"
+local debugStringWithAchievement = "[%d] = {--%s\n    itemPrice = %d,\n   --achievement = 0, \n},"
+local debugStringForRecipe = "%d, -- %s"
+
+local function makeOutput()
+    if not isMana   then return end

-    local debugString = defaultDebugString
+    local debugString
+    local isRecipe = IsItemLinkFurnitureRecipe(cachedItemLink)

-    if cachedPrice and 0 < cachedPrice then
-        debugString = debugStringWithPrice
-    else
+    cachedPrice = cachedPrice or 0
+    cachedName = cachedName or GetItemLinkName(cachedItemLink)

+    if isRecipe then
+         debugString = debugStringForRecipe
+    elseif 0 < cachedPrice then
+        debugString = debugStringWithPrice
+    elseif not cachedCanBuy then
+        debugString = debugStringWithAchievement
+    else
+        debugString = defaultDebugString
     end
-    if not cachedCanBuy then debugString = debugStringWithAchievement end
-    return zo_strformat(debugString, FurC.GetItemId(cachedItemLink), cachedPrice, cachedName)
+
+    return string.format(debugString, FurC.GetItemId(cachedItemLink), cachedName, cachedPrice)
 end

 local function isItemIdCached()
@@ -63,6 +75,7 @@ end

 local linebreak = "\n"
 local function concatToTextbox()
+    if not isMana   then return end
     if isItemIdCached() then return end
     local textSoFar = this.textbox:GetText() or ""
     textSoFar = (#textSoFar > 0 and textSoFar .. linebreak) or textSoFar
@@ -71,13 +84,15 @@ local function concatToTextbox()
 end

 local S_ADD_TO_BOX = "Add data to textbox"
-local function addMenuItems()
+local function addMenuItems()
 	AddCustomMenuItem(S_ADD_TO_BOX, concatToTextbox, MENU_ADD_OPTION_LABEL)
 end

 function FurCDevControl_HandleClickEvent(itemLink, button, control)		-- button being mouseButton here
-   cachedItemLink = itemLink
-    cachedControl = control
+    if not isMana   then return end
+    cachedItemLink  = itemLink
+    cachedControl   = control
+    cachedName      = GetItemLinkName(cachedItemLink)
     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
@@ -95,6 +110,7 @@ end

 -- thanks Randactyl for helping me with the handler :)
 function FurCDevControl_HandleInventoryContextMenu(control)
+    if not isMana   then return end
     control = control or moc()
     local name, price, meetsRequirementsToBuy, currencyQuantity1, currencyQuantity2

@@ -133,6 +149,7 @@ end


 function FurCDevUtility.OnControlMouseUp(control, button)
+    if not isMana   then return end

 	if (not control) or button ~= 2 then return end

@@ -151,6 +168,7 @@ function FurCDevUtility.OnControlMouseUp(control, button)
 end

 function FurCDevUtility.InitRightclickMenu()
+    if not isMana   then return end
 	FurCDevControl_LinkHandlerBackup_OnLinkMouseUp = ZO_LinkHandler_OnLinkMouseUp
 	ZO_LinkHandler_OnLinkMouseUp = function(itemLink, button, control)
         FurCDevControl_HandleClickEvent(itemLink, button, control)
diff --git a/data/Recipes.lua b/data/Recipes.lua
index 1a64b23..42fe140 100644
--- a/data/Recipes.lua
+++ b/data/Recipes.lua
@@ -1,6 +1,7 @@
 FurC.Recipes = FurC.Recipes or {}

 FurC.Recipes[FURC_ALTMER] = {
+
     139573, --Sketch: Figurine, the Fish and the Unicorn
     139571, --Sketch: Figurine, the Sea-Monster's Surprise
     139572, --Sketch: Figurine, the Taming of the Gryphon
diff --git a/startup.lua b/startup.lua
index c60c22d..a4d19d1 100644
--- a/startup.lua
+++ b/startup.lua
@@ -1,7 +1,7 @@
 FurnitureCatalogue 					= {}
 FurnitureCatalogue.name				= "FurnitureCatalogue"
 FurnitureCatalogue.author			= "manavortex"
-FurnitureCatalogue.version          = "2.5.9"
+FurnitureCatalogue.version          = "2.5.10"
 FurnitureCatalogue.CharacterName	= nil
 FurnitureCatalogue.settings			= {}