Added Icon modifier markup and colorization of BoC completion on 8 icon view
This commit is contained in:
1 parent
dac1233ac5
commit
ce320f5062
3 files changed
+41
-17
No files matched your search
+35
-15
@@ -542,7 +542,14 @@ function EID:getIcon(str)
|
|||||||
end
|
end
|
||||||
local strTrimmed = string.gsub(str,"{{(.-)}}",function(a) return a end )
|
local strTrimmed = string.gsub(str,"{{(.-)}}",function(a) return a end )
|
||||||
if #strTrimmed <= #str then
|
if #strTrimmed <= #str then
|
||||||
return EID:createItemIconObject(strTrimmed) or EID.InlineIcons[strTrimmed] or EID.InlineIcons["ERROR"]
|
local itemIconObj = EID:createItemIconObject(strTrimmed)
|
||||||
|
if itemIconObj then return itemIconObj end
|
||||||
|
|
||||||
|
if type(EID.InlineIcons[strTrimmed]) == "function" then
|
||||||
|
return EID.InlineIcons[strTrimmed](str) or EID.InlineIcons["ERROR"]
|
||||||
|
end
|
||||||
|
|
||||||
|
return EID.InlineIcons[strTrimmed] or EID.InlineIcons["ERROR"]
|
||||||
else
|
else
|
||||||
return EID.InlineIcons["ERROR"]
|
return EID.InlineIcons["ERROR"]
|
||||||
end
|
end
|
||||||
@@ -612,9 +619,14 @@ function EID:filterIconMarkup(text, textPosX, textPosY)
|
|||||||
local spriteTable = {}
|
local spriteTable = {}
|
||||||
for word in string.gmatch(text, "{{.-}}") do
|
for word in string.gmatch(text, "{{.-}}") do
|
||||||
local textposition = string.find(text, word)
|
local textposition = string.find(text, word)
|
||||||
|
|
||||||
|
local callback = EID._NextIconModifier
|
||||||
|
EID._NextIconModifier = nil
|
||||||
|
|
||||||
local lookup = EID:getIcon(word)
|
local lookup = EID:getIcon(word)
|
||||||
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EID.Scale
|
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EID.Scale
|
||||||
table.insert(spriteTable, {lookup, preceedingTextWidth})
|
|
||||||
|
table.insert(spriteTable, {lookup, preceedingTextWidth, callback})
|
||||||
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
|
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
|
||||||
end
|
end
|
||||||
return text, spriteTable
|
return text, spriteTable
|
||||||
@@ -627,21 +639,26 @@ function EID:renderInlineIcons(spriteTable, posX, posY)
|
|||||||
local Xoffset = sprite[1][5] or -1
|
local Xoffset = sprite[1][5] or -1
|
||||||
local Yoffset = sprite[1][6] or 0
|
local Yoffset = sprite[1][6] or 0
|
||||||
local spriteObj = (type(sprite[1][7]) == "function" and sprite[1][7]()) or sprite[1][7] or EID.InlineIconSprite
|
local spriteObj = (type(sprite[1][7]) == "function" and sprite[1][7]()) or sprite[1][7] or EID.InlineIconSprite
|
||||||
if sprite[1][2] >=0 then
|
if sprite[1][2] >= 0 then
|
||||||
spriteObj:SetFrame(sprite[1][1], sprite[1][2])
|
spriteObj:SetFrame(sprite[1][1], sprite[1][2])
|
||||||
elseif not spriteObj:IsPlaying(sprite[1][1]) or spriteObj:IsFinished(sprite[1][1]) then
|
elseif not spriteObj:IsPlaying(sprite[1][1]) or spriteObj:IsFinished(sprite[1][1]) then
|
||||||
spriteObj:Play(sprite[1][1],true)
|
spriteObj:Play(sprite[1][1],true)
|
||||||
else
|
else
|
||||||
spriteObj:Update()
|
spriteObj:Update()
|
||||||
end
|
end
|
||||||
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale)
|
|
||||||
|
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale, sprite[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- helper function to render Icons in specific EID settins
|
-- helper function to render Icons in specific EID settins
|
||||||
function EID:renderIcon(spriteObj, posX, posY)
|
function EID:renderIcon(spriteObj, posX, posY, callback)
|
||||||
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
|
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
|
||||||
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
|
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
|
||||||
|
if callback then
|
||||||
|
callback(spriteObj)
|
||||||
|
end
|
||||||
|
|
||||||
spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
|
spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -921,13 +938,18 @@ end
|
|||||||
-- Converts a given table into a string containing the crafting icons of the table
|
-- Converts a given table into a string containing the crafting icons of the table
|
||||||
-- Example input: {1,2,3,4,5,6,7,8}
|
-- Example input: {1,2,3,4,5,6,7,8}
|
||||||
-- Result: "{{Crafting1}}{{Crafting2}}{{Crafting3}}{{Crafting4}}{{Crafting5}}{{Crafting6}}{{Crafting7}}{{Crafting8}}"
|
-- Result: "{{Crafting1}}{{Crafting2}}{{Crafting3}}{{Crafting4}}{{Crafting5}}{{Crafting6}}{{Crafting7}}{{Crafting8}}"
|
||||||
function EID:tableToCraftingIconsFull(craftTable, sortTable)
|
local emptyPickupTable = {}
|
||||||
if (sortTable == nil) then sortTable = true end
|
for i=1,29 do emptyPickupTable[i] = 0 end
|
||||||
|
function EID:tableToCraftingIconsFull(craftTable, indicateCompleteContent)
|
||||||
local sortedList = {table.unpack(craftTable)}
|
local sortedList = {table.unpack(craftTable)}
|
||||||
if (sortTable) then table.sort(sortedList, function(a, b) return a < b end) end
|
table.sort(sortedList, function(a, b) return a < b end)
|
||||||
|
local visitedItemCount = {table.unpack(emptyPickupTable)}
|
||||||
|
|
||||||
local iconString = ""
|
local iconString = ""
|
||||||
for _,nr in ipairs(sortedList) do
|
for _,nr in ipairs(sortedList) do
|
||||||
iconString = iconString.."{{Crafting"..nr.."}}"
|
visitedItemCount[nr] = visitedItemCount[nr] + 1
|
||||||
|
local completedColoring = indicateCompleteContent and EID:bagContainsItem(nr, visitedItemCount[nr], false) and "{{IconGreenTint}}" or ""
|
||||||
|
iconString = iconString..completedColoring.."{{Crafting"..nr.."}}"
|
||||||
end
|
end
|
||||||
return iconString
|
return iconString
|
||||||
end
|
end
|
||||||
@@ -935,32 +957,30 @@ end
|
|||||||
-- Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag
|
-- Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag
|
||||||
-- Example input: {1,1,1,2,2,3,3,3}
|
-- Example input: {1,1,1,2,2,3,3,3}
|
||||||
-- Result: "3{{Crafting1}}2{{Crafting2}}3{{Crafting3}}"
|
-- Result: "3{{Crafting1}}2{{Crafting2}}3{{Crafting3}}"
|
||||||
local emptyPickupTable = {}
|
|
||||||
for i=1,29 do emptyPickupTable[i] = 0 end
|
|
||||||
function EID:tableToCraftingIconsMerged(craftTable, indicateCompleteContent)
|
function EID:tableToCraftingIconsMerged(craftTable, indicateCompleteContent)
|
||||||
local sortedList = {table.unpack(craftTable)}
|
local sortedList = {table.unpack(craftTable)}
|
||||||
local filteredList = {table.unpack(emptyPickupTable)}
|
local filteredList = {table.unpack(emptyPickupTable)}
|
||||||
for _,nr in ipairs(sortedList) do
|
for _,nr in ipairs(sortedList) do
|
||||||
filteredList[nr] = filteredList[nr] +1
|
filteredList[nr] = filteredList[nr] + 1
|
||||||
end
|
end
|
||||||
local iconString = ""
|
local iconString = ""
|
||||||
for nr,count in ipairs(filteredList) do
|
for nr,count in ipairs(filteredList) do
|
||||||
if (count > 0) then
|
if (count > 0) then
|
||||||
local completedColoring = indicateCompleteContent and EID:bagContainsItem(nr, count) and "{{ColorBagComplete}}" or ""
|
local completedColoring = indicateCompleteContent and EID:bagContainsItem(nr, count, true) and "{{ColorBagComplete}}" or ""
|
||||||
iconString = iconString..completedColoring..count.."{{Crafting"..nr.."}}{{CR}}"
|
iconString = iconString..completedColoring..count.."{{Crafting"..nr.."}}{{CR}}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return iconString
|
return iconString
|
||||||
end
|
end
|
||||||
|
|
||||||
function EID:bagContainsItem(itemID, itemCount)
|
function EID:bagContainsItem(itemID, itemCount, checkExactAmount)
|
||||||
local foundCount = 0
|
local foundCount = 0
|
||||||
for _, bagItem in ipairs(EID.BagItems) do
|
for _, bagItem in ipairs(EID.BagItems) do
|
||||||
if bagItem == itemID then
|
if bagItem == itemID then
|
||||||
foundCount = foundCount + 1
|
foundCount = foundCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return foundCount == itemCount
|
return checkExactAmount and foundCount == itemCount or itemCount <= foundCount
|
||||||
end
|
end
|
||||||
|
|
||||||
function EID:handleHUDElement(hudElement)
|
function EID:handleHUDElement(hudElement)
|
||||||
|
|||||||
@@ -762,8 +762,6 @@ local function getFloorItemsString(showPreviews, roomItems)
|
|||||||
end
|
end
|
||||||
local bagDesc = EID:getDescriptionEntry("CraftingBagContent")
|
local bagDesc = EID:getDescriptionEntry("CraftingBagContent")
|
||||||
floorString = floorString .. bagDesc.. EID:tableToCraftingIconsMerged(EID.BagItems).."#"
|
floorString = floorString .. bagDesc.. EID:tableToCraftingIconsMerged(EID.BagItems).."#"
|
||||||
--debug the bag order
|
|
||||||
--EID:appendToDescription(customDescObj, EID:tableToCraftingIconsFull(EID.BagItems, false).."#")
|
|
||||||
end
|
end
|
||||||
if #roomItems >0 then
|
if #roomItems >0 then
|
||||||
if showPreviews and #roomItems == 8 then
|
if showPreviews and #roomItems == 8 then
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ EID.InlineIcons = {
|
|||||||
["ArrowDown"] = {"ArrowDown", 0, 8, 9},
|
["ArrowDown"] = {"ArrowDown", 0, 8, 9},
|
||||||
["Warning"] = {"Warning", 0, 4, 9},
|
["Warning"] = {"Warning", 0, 4, 9},
|
||||||
["Blank"] = {"Blank", 0, 0, 0},
|
["Blank"] = {"Blank", 0, 0, 0},
|
||||||
|
["IconGreenTint"] = function(_)
|
||||||
|
EID._NextIconModifier = function(sprite)
|
||||||
|
sprite.Color = Color(1, 1, 1, EID.Config["Transparency"] * 0.5, 0, 0.5, 0)
|
||||||
|
end
|
||||||
|
return {"Blank", 0, 0, 0}
|
||||||
|
end,
|
||||||
-- Numbers
|
-- Numbers
|
||||||
["0"] = {"numbers", 0, 4, 7},
|
["0"] = {"numbers", 0, 4, 7},
|
||||||
["1"] = {"numbers", 1, 4, 7, -2},
|
["1"] = {"numbers", 1, 4, 7, -2},
|
||||||
|
|||||||
Reference in new issue
Block a user