Allow to use emoji ingame

This commit is contained in:
Benau 2019-06-20 10:34:47 +08:00
parent d6aa111f16
commit d0fac726d3
2 changed files with 22 additions and 3 deletions

View File

@ -3,8 +3,10 @@
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
<div x="1%" width="98%" height="fit" layout="horizontal-row">
<textbox id="chat" proportion="1"/>
<spacer width="3%" height="10"/>
<button id="send" width="20%" height="fit" align="center" I18N="In the network lobby" text="Send"/>
<spacer width="2%" height="10"/>
<button id="send" width="10%" height="fit" align="center" text=""/>
<spacer width="1%" height="10"/>
<button id="emoji" width="10%" height="fit" align="center" text=""/>
</div>
<spacer width="20" height="2%" />

View File

@ -22,8 +22,10 @@
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "config/user_config.hpp"
#include "guiengine/emoji_keyboard.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/CGUIEditBox.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "io/file_manager.hpp"
@ -64,7 +66,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
}
else
{
loadFromFile("network_ingame_dialog.stkgui");
loadFromFile("online/network_ingame_dialog.stkgui");
}
GUIEngine::RibbonWidget* back_btn = getWidget<RibbonWidget>("backbtnribbon");
@ -76,16 +78,22 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
SFXManager::get()->pauseAll();
m_text_box->clearListeners();
m_text_box->setTextBoxType(TBT_CAP_SENTENCES);
// Unicode enter arrow
getWidget("send")->setText(L"\u21B2");
// Unicode smile emoji
getWidget("emoji")->setText(L"\u263A");
if (UserConfigParams::m_lobby_chat)
{
m_text_box->setActive(true);
getWidget("send")->setVisible(true);
getWidget("emoji")->setVisible(true);
m_text_box->addListener(this);
auto cl = LobbyProtocol::get<ClientLobby>();
if (cl && !cl->serverEnabledChat())
{
m_text_box->setActive(false);
getWidget("send")->setActive(false);
getWidget("emoji")->setActive(false);
}
}
else
@ -94,6 +102,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
m_text_box->setText(
_("Chat is disabled, enable in options menu."));
getWidget("send")->setVisible(false);
getWidget("emoji")->setVisible(false);
}
}
else
@ -175,6 +184,14 @@ GUIEngine::EventPropagation
onEnterPressed(m_text_box->getText());
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "emoji" && m_text_box &&
!ScreenKeyboard::isActive())
{
EmojiKeyboard* ek = new EmojiKeyboard(1.0f, 0.40f,
m_text_box->getIrrlichtElement<CGUIEditBox>());
ek->init();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "backbtnribbon")
{
// unpausing is done in the destructor so nothing more to do here