introduce coloured loot message

This commit is contained in:
ErikasKontenis
2022-08-09 19:59:44 +03:00
parent 1c35d04337
commit eed5309ed0
11 changed files with 89 additions and 14 deletions

View File

@@ -646,7 +646,12 @@ function addTabText(text, speaktype, tab, creatureName)
label:setColoredText(highlightData)
end
end
if tab == serverTab then
local highlightText = toHighlightedText(text, speaktype.color)
label:setColoredText(highlightText)
end
label.name = creatureName
consoleBuffer.onMouseRelease = function(self, mousePos, mouseButton)
processMessageMenu(mousePos, mouseButton, nil, nil, nil, tab)

View File

@@ -92,12 +92,20 @@ function displayMessage(mode, text)
end
if msgtype.screenTarget then
local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget)
label:setText(text)
label:setColor(msgtype.color)
label:setVisible(true)
removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget)
if mode == 20 then
local highlightData = toHighlightedText(text, msgtype.color)
label:setColoredText(highlightData)
label:setVisible(true)
removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
else
label:setText(text)
label:setColor(msgtype.color)
label:setVisible(true)
removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
end
end
end

View File

@@ -8,4 +8,33 @@ function dirtostring(dir)
return k
end
end
end
function toHighlightedText(text, color)
local tmpData = {}
for i, part in ipairs(text:split("[")) do
if i == 1 then
table.insert(tmpData, part)
table.insert(tmpData, color)
else
for j, part2 in ipairs(part:split("]")) do
if j == 1 then
local text = part2:split(":")
if #text == 2 then
table.insert(tmpData, part2:split(":")[2])
table.insert(tmpData, part2:split(":")[1])
else
table.insert(tmpData, '[' .. part2 .. ']')
table.insert(tmpData, color)
end
else
table.insert(tmpData, part2)
table.insert(tmpData, color)
end
end
end
end
return tmpData
end