mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-29 19:26:23 +01:00
introduce coloured loot message
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user