show private message on screen
* disable GL blending in some situations to speedup on older hardware * fix wrap size in CachedText
This commit is contained in:
parent
205aefe12f
commit
1a2e97bb5e
|
@ -26,3 +26,7 @@ Panel
|
||||||
OptionCheckBox
|
OptionCheckBox
|
||||||
id: showPrivateMessagesInConsole
|
id: showPrivateMessagesInConsole
|
||||||
!text: tr('Show private messages in console')
|
!text: tr('Show private messages in console')
|
||||||
|
|
||||||
|
OptionCheckBox
|
||||||
|
id: showPrivateMessagesOnScreen
|
||||||
|
!text: tr('Show private messages on screen')
|
||||||
|
|
|
@ -12,7 +12,8 @@ local options = { vsync = false,
|
||||||
showInfoMessagesInConsole = true,
|
showInfoMessagesInConsole = true,
|
||||||
showTimestampsInConsole = true,
|
showTimestampsInConsole = true,
|
||||||
showLevelsInConsole = true,
|
showLevelsInConsole = true,
|
||||||
showPrivateMessagesInConsole = false }
|
showPrivateMessagesInConsole = false,
|
||||||
|
showPrivateMessagesOnScreen = true }
|
||||||
local generalPanel
|
local generalPanel
|
||||||
local graphicsPanel
|
local graphicsPanel
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
menu:addOption(tr('Rule Violation'), function() RuleViolation.show(creatureThing:getName()) end)
|
menu:addOption(tr('Rule Violation'), function() RuleViolation.show(creatureThing:getName()) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
|
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,13 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
||||||
speaktype = SpeakTypes[speaktype]
|
speaktype = SpeakTypes[speaktype]
|
||||||
if speaktype.hideInConsole then return end
|
if speaktype.hideInConsole then return end
|
||||||
|
|
||||||
message = applyMessagePrefixies(name, level, message)
|
local composedMessage = applyMessagePrefixies(name, level, message)
|
||||||
|
|
||||||
if speaktype.private then
|
if speaktype.private then
|
||||||
Console.addPrivateText(message, speaktype, name, false, name)
|
Console.addPrivateText(composedMessage, speaktype, name, false, name)
|
||||||
|
if Options.getOption('showPrivateMessagesOnScreen') then
|
||||||
|
TextMessage.displayPrivate(name .. ':\n' .. message)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local channel = tr('Default')
|
local channel = tr('Default')
|
||||||
if not defaultMessage then
|
if not defaultMessage then
|
||||||
|
@ -98,7 +101,7 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
||||||
end
|
end
|
||||||
|
|
||||||
if channel then
|
if channel then
|
||||||
Console.addText(message, speaktype, channel, name)
|
Console.addText(composedMessage, speaktype, channel, name)
|
||||||
elseif channelId ~= 0 then
|
elseif channelId ~= 0 then
|
||||||
-- server sent a message on a channel that is not open
|
-- server sent a message on a channel that is not open
|
||||||
warning('message in channel id ' .. channelId .. ' which is unknown, this is a server bug, relogin if you want to see messages in this channel')
|
warning('message in channel id ' .. channelId .. ' which is unknown, this is a server bug, relogin if you want to see messages in this channel')
|
||||||
|
@ -350,7 +353,7 @@ function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatur
|
||||||
|
|
||||||
local privateTab = Console.getTab(name)
|
local privateTab = Console.getTab(name)
|
||||||
if privateTab == nil then
|
if privateTab == nil then
|
||||||
if Options['showPrivateMessagesInConsole'] or (isPrivateCommand and not privateTab) then
|
if (Options.getOption('showPrivateMessagesInConsole') and not focus) or (isPrivateCommand and not privateTab) then
|
||||||
privateTab = Console.getTab(tr('Default'))
|
privateTab = Console.getTab(tr('Default'))
|
||||||
else
|
else
|
||||||
privateTab = Console.addTab(name, focus)
|
privateTab = Console.addTab(name, focus)
|
||||||
|
@ -383,7 +386,7 @@ function Console.addTabText(text, speaktype, tab, creatureName)
|
||||||
consoleTabBar:blinkTab(tab)
|
consoleTabBar:blinkTab(tab)
|
||||||
|
|
||||||
label.onMouseRelease = function (self, mousePos, mouseButton) Console.popupMenu(mousePos, mouseButton, creatureName, text) end
|
label.onMouseRelease = function (self, mousePos, mouseButton) Console.popupMenu(mousePos, mouseButton, creatureName, text) end
|
||||||
|
|
||||||
if consoleBuffer:getChildCount() > MAX_LINES then
|
if consoleBuffer:getChildCount() > MAX_LINES then
|
||||||
consoleBuffer:getFirstChild():destroy()
|
consoleBuffer:getFirstChild():destroy()
|
||||||
end
|
end
|
||||||
|
@ -469,7 +472,7 @@ function Console.sendCurrentMessage()
|
||||||
tab = Console.getTab(tr('Default'))
|
tab = Console.getTab(tr('Default'))
|
||||||
name = tr('Default')
|
name = tr('Default')
|
||||||
end
|
end
|
||||||
|
|
||||||
local speaktypedesc
|
local speaktypedesc
|
||||||
if (tab.channelId or name == tr('Default')) and not chatCommandPrivateReady then
|
if (tab.channelId or name == tr('Default')) and not chatCommandPrivateReady then
|
||||||
if name == tr('Default') then
|
if name == tr('Default') then
|
||||||
|
|
|
@ -8,16 +8,18 @@ local MessageTypes = {
|
||||||
consoleRed = { color = '#F55E5E', consoleTab = tr('Default') },
|
consoleRed = { color = '#F55E5E', consoleTab = tr('Default') },
|
||||||
consoleOrange = { color = '#FE6500', consoleTab = tr('Default') },
|
consoleOrange = { color = '#FE6500', consoleTab = tr('Default') },
|
||||||
consoleBlue = { color = '#9F9DFD', consoleTab = tr('Default') },
|
consoleBlue = { color = '#9F9DFD', consoleTab = tr('Default') },
|
||||||
warning = { color = '#F55E5E', consoleTab = tr('Server Log'), labelId = 'centerWarning', wrap = true },
|
warning = { color = '#F55E5E', consoleTab = tr('Server Log'), labelId = 'centerWarning' },
|
||||||
infoDescription = { color = '#00EB00', consoleTab = tr('Server Log'), labelId = 'centerInfo', consoleOption = 'showInfoMessagesInConsole', wrap = true },
|
infoDescription = { color = '#00EB00', consoleTab = tr('Server Log'), labelId = 'centerInfo', consoleOption = 'showInfoMessagesInConsole' },
|
||||||
eventAdvance = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'centerAdvance', consoleOption = 'showEventMessagesInConsole', wrap = true },
|
eventAdvance = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'centerAdvance', consoleOption = 'showEventMessagesInConsole' },
|
||||||
eventDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showEventMessagesInConsole' },
|
eventDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showEventMessagesInConsole' },
|
||||||
statusDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showStatusMessagesInConsole' },
|
statusDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showStatusMessagesInConsole' },
|
||||||
statusSmall = { color = '#FFFFFF', labelId = 'bottomStatus' },
|
statusSmall = { color = '#FFFFFF', labelId = 'bottomStatus' },
|
||||||
|
private = { color = '#5FF7F7', labelId = 'centerPrivate' }
|
||||||
}
|
}
|
||||||
|
|
||||||
local centerTextMessagePanel
|
local centerTextMessagePanel
|
||||||
local bottomStatusLabel
|
local bottomStatusLabel
|
||||||
|
local privateLabel
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function displayMessage(msgtype, msg, time)
|
local function displayMessage(msgtype, msg, time)
|
||||||
|
@ -35,13 +37,6 @@ local function displayMessage(msgtype, msg, time)
|
||||||
label:setText(msg)
|
label:setText(msg)
|
||||||
label:setColor(msgtype.color)
|
label:setColor(msgtype.color)
|
||||||
|
|
||||||
if msgtype.wrap then
|
|
||||||
label:setWidth(label:getParent():getWidth())
|
|
||||||
label:setHeight(label:getTextSize().height)
|
|
||||||
else
|
|
||||||
label:resizeToText()
|
|
||||||
end
|
|
||||||
|
|
||||||
if not time then
|
if not time then
|
||||||
time = math.max(#msg * 100, 4000)
|
time = math.max(#msg * 100, 4000)
|
||||||
else
|
else
|
||||||
|
@ -53,15 +48,10 @@ local function displayMessage(msgtype, msg, time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function createTextMessageLabel(id, parent)
|
local function createTextMessageLabel(id, parent, class)
|
||||||
local label = createWidget('UILabel', parent)
|
local label = createWidget(class, parent)
|
||||||
label:setFont('verdana-11px-rounded')
|
label:setFont('verdana-11px-rounded')
|
||||||
label:setTextAlign(AlignCenter)
|
|
||||||
label:setId(id)
|
label:setId(id)
|
||||||
label:setMarginBottom(2)
|
|
||||||
label:setTextWrap(true)
|
|
||||||
label:setTextAutoResize(true)
|
|
||||||
label:setVisible(false)
|
|
||||||
return label
|
return label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,15 +70,12 @@ function TextMessage.init()
|
||||||
centerTextMessagePanel:setWidth(360)
|
centerTextMessagePanel:setWidth(360)
|
||||||
centerTextMessagePanel:centerIn('parent')
|
centerTextMessagePanel:centerIn('parent')
|
||||||
|
|
||||||
createTextMessageLabel('centerWarning', centerTextMessagePanel)
|
createTextMessageLabel('centerWarning', centerTextMessagePanel, 'CenterLabel')
|
||||||
createTextMessageLabel('centerAdvance', centerTextMessagePanel)
|
createTextMessageLabel('centerAdvance', centerTextMessagePanel, 'CenterLabel')
|
||||||
createTextMessageLabel('centerInfo', centerTextMessagePanel)
|
createTextMessageLabel('centerInfo', centerTextMessagePanel, 'CenterLabel')
|
||||||
|
|
||||||
bottomStatusLabel = createTextMessageLabel('bottomStatus', GameInterface.getMapPanel())
|
privateLabel = createTextMessageLabel('centerPrivate', GameInterface.getMapPanel(), 'TopCenterLabel')
|
||||||
bottomStatusLabel:setHeight(16)
|
bottomStatusLabel = createTextMessageLabel('bottomStatus', GameInterface.getMapPanel(), 'BottomLabel')
|
||||||
bottomStatusLabel:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
|
||||||
bottomStatusLabel:addAnchor(AnchorLeft, 'parent', AnchorLeft)
|
|
||||||
bottomStatusLabel:addAnchor(AnchorRight, 'parent', AnchorRight)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextMessage.terminate()
|
function TextMessage.terminate()
|
||||||
|
@ -98,11 +85,14 @@ function TextMessage.terminate()
|
||||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerWarning').hideEvent)
|
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerWarning').hideEvent)
|
||||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerAdvance').hideEvent)
|
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerAdvance').hideEvent)
|
||||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerInfo').hideEvent)
|
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerInfo').hideEvent)
|
||||||
|
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerPrivate').hideEvent)
|
||||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('bottomStatus').hideEvent)
|
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('bottomStatus').hideEvent)
|
||||||
centerTextMessagePanel:destroy()
|
centerTextMessagePanel:destroy()
|
||||||
centerTextMessagePanel = nil
|
|
||||||
bottomStatusLabel:destroy()
|
bottomStatusLabel:destroy()
|
||||||
|
privateLabel:destroy()
|
||||||
|
centerTextMessagePanel = nil
|
||||||
bottomStatusLabel = nil
|
bottomStatusLabel = nil
|
||||||
|
privateLabel = nil
|
||||||
TextMessage = nil
|
TextMessage = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,6 +100,7 @@ function TextMessage.clearMessages()
|
||||||
GameInterface.getMapPanel():recursiveGetChildById('centerWarning'):hide()
|
GameInterface.getMapPanel():recursiveGetChildById('centerWarning'):hide()
|
||||||
GameInterface.getMapPanel():recursiveGetChildById('centerAdvance'):hide()
|
GameInterface.getMapPanel():recursiveGetChildById('centerAdvance'):hide()
|
||||||
GameInterface.getMapPanel():recursiveGetChildById('centerInfo'):hide()
|
GameInterface.getMapPanel():recursiveGetChildById('centerInfo'):hide()
|
||||||
|
GameInterface.getMapPanel():recursiveGetChildById('centerPrivate'):hide()
|
||||||
GameInterface.getMapPanel():recursiveGetChildById('bottomStatus'):hide()
|
GameInterface.getMapPanel():recursiveGetChildById('bottomStatus'):hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,6 +112,10 @@ function TextMessage.displayEventAdvance(msg, time)
|
||||||
displayMessage(MessageTypes.eventAdvance, msg, time)
|
displayMessage(MessageTypes.eventAdvance, msg, time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TextMessage.displayPrivate(msg, time)
|
||||||
|
displayMessage(MessageTypes.private, msg, time)
|
||||||
|
end
|
||||||
|
|
||||||
function TextMessage.display(msgtypedesc, msg)
|
function TextMessage.display(msgtypedesc, msg)
|
||||||
local msgtype = MessageTypes[msgtypedesc]
|
local msgtype = MessageTypes[msgtypedesc]
|
||||||
if msgtype then
|
if msgtype then
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
CenterLabel < GameLabel
|
CenterLabel < UILabel
|
||||||
font: verdana-11px-rounded
|
font: verdana-11px-rounded
|
||||||
height: 64
|
|
||||||
text-align: center
|
text-align: center
|
||||||
text-wrap: true
|
text-wrap: true
|
||||||
anchors.centerIn: parent
|
text-auto-resize: true
|
||||||
size: 360 264
|
|
||||||
|
|
||||||
BottomLabel < GameLabel
|
|
||||||
font: verdana-11px-rounded
|
|
||||||
height: 16
|
|
||||||
text-align: center
|
|
||||||
margin-bottom: 2
|
margin-bottom: 2
|
||||||
anchors.bottom: parent.bottom
|
visible: false
|
||||||
|
|
||||||
|
TopCenterLabel < UILabel
|
||||||
|
font: verdana-11px-rounded
|
||||||
|
text-align: center
|
||||||
|
text-wrap: true
|
||||||
|
visible: false
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: centerTextMessagePanel.top
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
width: 360
|
||||||
|
|
||||||
|
BottomLabel < CenterLabel
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
|
@ -55,6 +55,8 @@ void CachedText::update()
|
||||||
|
|
||||||
void CachedText::wrapText(int maxWidth)
|
void CachedText::wrapText(int maxWidth)
|
||||||
{
|
{
|
||||||
if(m_font)
|
if(m_font) {
|
||||||
m_text = m_font->wrapText(m_text, maxWidth);
|
m_text = m_font->wrapText(m_text, maxWidth);
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,10 +148,10 @@ void FrameBuffer::internalRelease()
|
||||||
|
|
||||||
// restore screen original content
|
// restore screen original content
|
||||||
if(m_backuping) {
|
if(m_backuping) {
|
||||||
Painter::CompositionMode oldComposition = g_painter->getCompositionMode();
|
glDisable(GL_BLEND);
|
||||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
g_painter->setColor(Color::white);
|
||||||
g_painter->drawTexturedRect(screenRect, m_screenBackup, screenRect);
|
g_painter->drawTexturedRect(screenRect, m_screenBackup, screenRect);
|
||||||
g_painter->setCompositionMode(oldComposition);
|
glEnable(GL_BLEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,13 +79,6 @@ void Graphics::init()
|
||||||
// blending is always enabled
|
// blending is always enabled
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
// face culling may improve performance
|
|
||||||
/*
|
|
||||||
glCullFace(GL_BACK);
|
|
||||||
glFrontFace(GL_CW);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// determine max texture size
|
// determine max texture size
|
||||||
GLint maxTextureSize = 0;
|
GLint maxTextureSize = 0;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
|
@ -162,9 +162,8 @@ void Painter::updateGlCompositionMode()
|
||||||
case CompositionMode_Normal:
|
case CompositionMode_Normal:
|
||||||
if(g_graphics.canUseBlendFuncSeparate())
|
if(g_graphics.canUseBlendFuncSeparate())
|
||||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||||
else {
|
else
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CompositionMode_Multiply:
|
case CompositionMode_Multiply:
|
||||||
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
|
@ -125,9 +125,8 @@ void MapView::draw(const Rect& rect)
|
||||||
drawOffset.y += (srcVisible.height() - srcSize.height()) / 2;
|
drawOffset.y += (srcVisible.height() - srcSize.height()) / 2;
|
||||||
Rect srcRect = Rect(drawOffset, srcSize);
|
Rect srcRect = Rect(drawOffset, srcSize);
|
||||||
|
|
||||||
g_painter->saveState();
|
|
||||||
g_painter->setColor(Color::white);
|
g_painter->setColor(Color::white);
|
||||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
glDisable(GL_BLEND);
|
||||||
#if 0
|
#if 0
|
||||||
// debug source area
|
// debug source area
|
||||||
g_painter->saveAndResetState();
|
g_painter->saveAndResetState();
|
||||||
|
@ -140,7 +139,7 @@ void MapView::draw(const Rect& rect)
|
||||||
#else
|
#else
|
||||||
m_framebuffer->draw(rect, srcRect);
|
m_framebuffer->draw(rect, srcRect);
|
||||||
#endif
|
#endif
|
||||||
g_painter->restoreSavedState();
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
//g_painter->resetShaderProgram();
|
//g_painter->resetShaderProgram();
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,10 @@ void UIMap::drawSelf(Fw::DrawPane drawPane)
|
||||||
g_painter->drawBoundingRect(m_mapRect.expanded(1));
|
g_painter->drawBoundingRect(m_mapRect.expanded(1));
|
||||||
|
|
||||||
if(drawPane != Fw::BothPanes) {
|
if(drawPane != Fw::BothPanes) {
|
||||||
g_painter->saveState();
|
glDisable(GL_BLEND);
|
||||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
|
||||||
g_painter->setColor(Color::alpha);
|
g_painter->setColor(Color::alpha);
|
||||||
g_painter->drawFilledRect(m_mapRect);
|
g_painter->drawFilledRect(m_mapRect);
|
||||||
g_painter->restoreSavedState();
|
glEnable(GL_BLEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue