Files
mcpe/source/client/gui/screens/ChatScreen.cpp
Brent 2e55f99a54 Options Logic Cleanup (#71)
* Output/Logging Overhaul
* Added StandardOut class
* Renamed LOGX macros to LOG_X
* Removed LogMsg macros in favor of LOG_X
* Added console window for debug Windows builds

* Options Refactor
* Moved options loading code from AppPlatform classes to Options class
* Added AppPlatform::singleton()
* Minecraft::m_options is now only accessible via Minecraft::getOptions() (as it should be)
* Making this work with SDL2 next

* Options Cleanup for SDL2

* Added AppPlatform::hasFileSystemAccess()
* Options won't try to load if hasFileSystemAccess returns false. Emscripten build will be happy.

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
2023-09-04 12:11:36 +03:00

75 lines
1.8 KiB
C++

/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "ChatScreen.hpp"
// @NOTE: This is unused.
ChatScreen::ChatScreen(bool slash) : m_textChat(1, 0, 0), m_btnSend(2, 0, 0, "Send")
{
if (slash)
m_textChat.m_text = "/";
}
void ChatScreen::buttonClicked(Button* pButton)
{
if (pButton->m_buttonId == m_btnSend.m_buttonId)
sendMessageAndExit();
}
void ChatScreen::init()
{
m_btnSend.m_height = 20;
m_btnSend.m_width = 40;
m_textChat.m_xPos = 0;
m_textChat.m_yPos = m_height - 20;
m_textChat.m_width = m_width - m_btnSend.m_width;
m_textChat.m_height = 20;
m_btnSend.m_yPos = m_height - 20;
m_btnSend.m_xPos = m_textChat.m_xPos + m_textChat.m_width;
// set focus directly on the chat text box
m_textChat.init(m_pFont);
m_textChat.setFocused(true);
m_buttons.push_back(&m_btnSend);
m_textInputs.push_back(&m_textChat);
}
void ChatScreen::removed()
{
// Now let them be rendered.
m_pMinecraft->m_gui.m_bRenderMessages = true;
}
void ChatScreen::render(int mouseX, int mouseY, float f)
{
renderBackground();
// override the default behavior of rendering chat messages
m_pMinecraft->m_gui.m_bRenderMessages = false;
m_pMinecraft->m_gui.renderMessages(true);
Screen::render(mouseX, mouseY, f);
}
void ChatScreen::keyPressed(int keyCode)
{
if (m_pMinecraft->getOptions()->isKey(KM_MENU_OK, keyCode))
sendMessageAndExit();
Screen::keyPressed(keyCode);
}
void ChatScreen::sendMessageAndExit()
{
m_pMinecraft->sendMessage(m_textChat.m_text);
m_pMinecraft->setScreen(nullptr);
}