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
|
||||
id: showPrivateMessagesInConsole
|
||||
!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,
|
||||
showTimestampsInConsole = true,
|
||||
showLevelsInConsole = true,
|
||||
showPrivateMessagesInConsole = false }
|
||||
showPrivateMessagesInConsole = false,
|
||||
showPrivateMessagesOnScreen = true }
|
||||
local generalPanel
|
||||
local graphicsPanel
|
||||
|
||||
|
|
|
@ -87,10 +87,13 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
|||
speaktype = SpeakTypes[speaktype]
|
||||
if speaktype.hideInConsole then return end
|
||||
|
||||
message = applyMessagePrefixies(name, level, message)
|
||||
local composedMessage = applyMessagePrefixies(name, level, message)
|
||||
|
||||
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
|
||||
local channel = tr('Default')
|
||||
if not defaultMessage then
|
||||
|
@ -98,7 +101,7 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
|||
end
|
||||
|
||||
if channel then
|
||||
Console.addText(message, speaktype, channel, name)
|
||||
Console.addText(composedMessage, speaktype, channel, name)
|
||||
elseif channelId ~= 0 then
|
||||
-- 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')
|
||||
|
@ -350,7 +353,7 @@ function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatur
|
|||
|
||||
local privateTab = Console.getTab(name)
|
||||
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'))
|
||||
else
|
||||
privateTab = Console.addTab(name, focus)
|
||||
|
|
|
@ -8,16 +8,18 @@ local MessageTypes = {
|
|||
consoleRed = { color = '#F55E5E', consoleTab = tr('Default') },
|
||||
consoleOrange = { color = '#FE6500', consoleTab = tr('Default') },
|
||||
consoleBlue = { color = '#9F9DFD', consoleTab = tr('Default') },
|
||||
warning = { color = '#F55E5E', consoleTab = tr('Server Log'), labelId = 'centerWarning', wrap = true },
|
||||
infoDescription = { color = '#00EB00', consoleTab = tr('Server Log'), labelId = 'centerInfo', consoleOption = 'showInfoMessagesInConsole', wrap = true },
|
||||
eventAdvance = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'centerAdvance', consoleOption = 'showEventMessagesInConsole', wrap = true },
|
||||
warning = { color = '#F55E5E', consoleTab = tr('Server Log'), labelId = 'centerWarning' },
|
||||
infoDescription = { color = '#00EB00', consoleTab = tr('Server Log'), labelId = 'centerInfo', consoleOption = 'showInfoMessagesInConsole' },
|
||||
eventAdvance = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'centerAdvance', consoleOption = 'showEventMessagesInConsole' },
|
||||
eventDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showEventMessagesInConsole' },
|
||||
statusDefault = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'bottomStatus', consoleOption = 'showStatusMessagesInConsole' },
|
||||
statusSmall = { color = '#FFFFFF', labelId = 'bottomStatus' },
|
||||
private = { color = '#5FF7F7', labelId = 'centerPrivate' }
|
||||
}
|
||||
|
||||
local centerTextMessagePanel
|
||||
local bottomStatusLabel
|
||||
local privateLabel
|
||||
|
||||
-- private functions
|
||||
local function displayMessage(msgtype, msg, time)
|
||||
|
@ -35,13 +37,6 @@ local function displayMessage(msgtype, msg, time)
|
|||
label:setText(msg)
|
||||
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
|
||||
time = math.max(#msg * 100, 4000)
|
||||
else
|
||||
|
@ -53,15 +48,10 @@ local function displayMessage(msgtype, msg, time)
|
|||
end
|
||||
end
|
||||
|
||||
local function createTextMessageLabel(id, parent)
|
||||
local label = createWidget('UILabel', parent)
|
||||
local function createTextMessageLabel(id, parent, class)
|
||||
local label = createWidget(class, parent)
|
||||
label:setFont('verdana-11px-rounded')
|
||||
label:setTextAlign(AlignCenter)
|
||||
label:setId(id)
|
||||
label:setMarginBottom(2)
|
||||
label:setTextWrap(true)
|
||||
label:setTextAutoResize(true)
|
||||
label:setVisible(false)
|
||||
return label
|
||||
end
|
||||
|
||||
|
@ -80,15 +70,12 @@ function TextMessage.init()
|
|||
centerTextMessagePanel:setWidth(360)
|
||||
centerTextMessagePanel:centerIn('parent')
|
||||
|
||||
createTextMessageLabel('centerWarning', centerTextMessagePanel)
|
||||
createTextMessageLabel('centerAdvance', centerTextMessagePanel)
|
||||
createTextMessageLabel('centerInfo', centerTextMessagePanel)
|
||||
createTextMessageLabel('centerWarning', centerTextMessagePanel, 'CenterLabel')
|
||||
createTextMessageLabel('centerAdvance', centerTextMessagePanel, 'CenterLabel')
|
||||
createTextMessageLabel('centerInfo', centerTextMessagePanel, 'CenterLabel')
|
||||
|
||||
bottomStatusLabel = createTextMessageLabel('bottomStatus', GameInterface.getMapPanel())
|
||||
bottomStatusLabel:setHeight(16)
|
||||
bottomStatusLabel:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
||||
bottomStatusLabel:addAnchor(AnchorLeft, 'parent', AnchorLeft)
|
||||
bottomStatusLabel:addAnchor(AnchorRight, 'parent', AnchorRight)
|
||||
privateLabel = createTextMessageLabel('centerPrivate', GameInterface.getMapPanel(), 'TopCenterLabel')
|
||||
bottomStatusLabel = createTextMessageLabel('bottomStatus', GameInterface.getMapPanel(), 'BottomLabel')
|
||||
end
|
||||
|
||||
function TextMessage.terminate()
|
||||
|
@ -98,11 +85,14 @@ function TextMessage.terminate()
|
|||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerWarning').hideEvent)
|
||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerAdvance').hideEvent)
|
||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerInfo').hideEvent)
|
||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('centerPrivate').hideEvent)
|
||||
removeEvent(GameInterface.getMapPanel():recursiveGetChildById('bottomStatus').hideEvent)
|
||||
centerTextMessagePanel:destroy()
|
||||
centerTextMessagePanel = nil
|
||||
bottomStatusLabel:destroy()
|
||||
privateLabel:destroy()
|
||||
centerTextMessagePanel = nil
|
||||
bottomStatusLabel = nil
|
||||
privateLabel = nil
|
||||
TextMessage = nil
|
||||
end
|
||||
|
||||
|
@ -110,6 +100,7 @@ function TextMessage.clearMessages()
|
|||
GameInterface.getMapPanel():recursiveGetChildById('centerWarning'):hide()
|
||||
GameInterface.getMapPanel():recursiveGetChildById('centerAdvance'):hide()
|
||||
GameInterface.getMapPanel():recursiveGetChildById('centerInfo'):hide()
|
||||
GameInterface.getMapPanel():recursiveGetChildById('centerPrivate'):hide()
|
||||
GameInterface.getMapPanel():recursiveGetChildById('bottomStatus'):hide()
|
||||
end
|
||||
|
||||
|
@ -121,6 +112,10 @@ function TextMessage.displayEventAdvance(msg, time)
|
|||
displayMessage(MessageTypes.eventAdvance, msg, time)
|
||||
end
|
||||
|
||||
function TextMessage.displayPrivate(msg, time)
|
||||
displayMessage(MessageTypes.private, msg, time)
|
||||
end
|
||||
|
||||
function TextMessage.display(msgtypedesc, msg)
|
||||
local msgtype = MessageTypes[msgtypedesc]
|
||||
if msgtype then
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
CenterLabel < GameLabel
|
||||
CenterLabel < UILabel
|
||||
font: verdana-11px-rounded
|
||||
height: 64
|
||||
text-align: center
|
||||
text-wrap: true
|
||||
anchors.centerIn: parent
|
||||
size: 360 264
|
||||
|
||||
BottomLabel < GameLabel
|
||||
font: verdana-11px-rounded
|
||||
height: 16
|
||||
text-align: center
|
||||
text-auto-resize: true
|
||||
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
|
||||
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)
|
||||
{
|
||||
if(m_font)
|
||||
if(m_font) {
|
||||
m_text = m_font->wrapText(m_text, maxWidth);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,10 +148,10 @@ void FrameBuffer::internalRelease()
|
|||
|
||||
// restore screen original content
|
||||
if(m_backuping) {
|
||||
Painter::CompositionMode oldComposition = g_painter->getCompositionMode();
|
||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
||||
glDisable(GL_BLEND);
|
||||
g_painter->setColor(Color::white);
|
||||
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
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
// face culling may improve performance
|
||||
/*
|
||||
glCullFace(GL_BACK);
|
||||
glFrontFace(GL_CW);
|
||||
glEnable(GL_CULL_FACE);
|
||||
*/
|
||||
|
||||
// determine max texture size
|
||||
GLint maxTextureSize = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
|
|
|
@ -162,9 +162,8 @@ void Painter::updateGlCompositionMode()
|
|||
case CompositionMode_Normal:
|
||||
if(g_graphics.canUseBlendFuncSeparate())
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
else {
|
||||
else
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
break;
|
||||
case CompositionMode_Multiply:
|
||||
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;
|
||||
Rect srcRect = Rect(drawOffset, srcSize);
|
||||
|
||||
g_painter->saveState();
|
||||
g_painter->setColor(Color::white);
|
||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
||||
glDisable(GL_BLEND);
|
||||
#if 0
|
||||
// debug source area
|
||||
g_painter->saveAndResetState();
|
||||
|
@ -140,7 +139,7 @@ void MapView::draw(const Rect& rect)
|
|||
#else
|
||||
m_framebuffer->draw(rect, srcRect);
|
||||
#endif
|
||||
g_painter->restoreSavedState();
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
//g_painter->resetShaderProgram();
|
||||
|
||||
|
|
|
@ -55,11 +55,10 @@ void UIMap::drawSelf(Fw::DrawPane drawPane)
|
|||
g_painter->drawBoundingRect(m_mapRect.expanded(1));
|
||||
|
||||
if(drawPane != Fw::BothPanes) {
|
||||
g_painter->saveState();
|
||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
||||
glDisable(GL_BLEND);
|
||||
g_painter->setColor(Color::alpha);
|
||||
g_painter->drawFilledRect(m_mapRect);
|
||||
g_painter->restoreSavedState();
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue