mirror of
https://github.com/celisej567/mcpe.git
synced 2025-12-31 17:49:17 +03:00
* Improve the Chat Screen
This commit is contained in:
@@ -501,6 +501,22 @@ void Minecraft::handleCharInput(char chr)
|
||||
m_pScreen->charInput(chr);
|
||||
}
|
||||
|
||||
void Minecraft::sendMessage(const std::string& message)
|
||||
{
|
||||
if (isOnlineClient())
|
||||
{
|
||||
// send the server a message packet
|
||||
MessagePacket mp(message);
|
||||
m_pRakNetInstance->send(&mp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fake the server having received a packet
|
||||
MessagePacket mp(message);
|
||||
m_pNetEventCallback->handle(m_pRakNetInstance->m_pRakPeerInterface->GetMyGUID(), &mp);
|
||||
}
|
||||
}
|
||||
|
||||
void Minecraft::_levelGenerated()
|
||||
{
|
||||
if (m_pNetEventCallback)
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
void locateMultiplayer();
|
||||
void tickMouse();
|
||||
void handleCharInput(char chr);
|
||||
void sendMessage(const std::string& message);
|
||||
|
||||
virtual void onGraphicsReset();
|
||||
virtual void update() override;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Minecraft.hpp"
|
||||
#include "client/gui/screens/IngameBlockSelectionScreen.hpp"
|
||||
#include "client/gui/screens/ChatScreen.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -384,6 +385,15 @@ void Gui::handleKeyPressed(int keyCode)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AKEYCODE_T:
|
||||
{
|
||||
if (m_pMinecraft->m_pScreen)
|
||||
break;
|
||||
|
||||
m_pMinecraft->setScreen(new ChatScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,18 +411,23 @@ void Gui::renderMessages(bool bShowAll)
|
||||
|
||||
int bkgdColor = 0x7F000000, textColor = 0xFFFFFFFF;
|
||||
|
||||
float fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
|
||||
if (fade <= 0.0f)
|
||||
continue;
|
||||
|
||||
if (fade < 1.0f)
|
||||
float fade = 1.0f;
|
||||
|
||||
if (!bShowAll)
|
||||
{
|
||||
int x = int(fade * fade * 255.0f);
|
||||
if (x == 0)
|
||||
fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
|
||||
if (fade <= 0.0f)
|
||||
continue;
|
||||
|
||||
bkgdColor = (x / 2) << 24;
|
||||
textColor = (x << 24) + 0xFFFFFF;
|
||||
if (fade < 1.0f)
|
||||
{
|
||||
int x = int(fade * fade * 255.0f);
|
||||
if (x == 0)
|
||||
continue;
|
||||
|
||||
bkgdColor = (x / 2) << 24;
|
||||
textColor = (x << 24) + 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
fill(2, topEdge, 322, topEdge + 9, bkgdColor);
|
||||
|
||||
@@ -22,14 +22,21 @@ void ChatScreen::buttonClicked(Button* pButton)
|
||||
|
||||
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 - 60;
|
||||
m_textChat.m_width = m_width - m_btnSend.m_width;
|
||||
m_textChat.m_height = 20;
|
||||
m_btnSend.m_height = 20;
|
||||
m_btnSend.m_width = 60;
|
||||
m_btnSend.m_yPos = m_textChat.m_yPos;
|
||||
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()
|
||||
@@ -57,7 +64,7 @@ void ChatScreen::keyPressed(int keyCode)
|
||||
|
||||
void ChatScreen::sendMessageAndExit()
|
||||
{
|
||||
m_pMinecraft->m_gui.addMessage(m_textChat.m_text);
|
||||
m_pMinecraft->sendMessage(m_textChat.m_text);
|
||||
|
||||
m_pMinecraft->setScreen(nullptr);
|
||||
}
|
||||
|
||||
@@ -164,6 +164,11 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int type)
|
||||
selectSlotAndClose();
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::removed()
|
||||
{
|
||||
m_pMinecraft->m_gui.inventoryUpdated();
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::selectSlotAndClose()
|
||||
{
|
||||
Inventory* pInv = getInventory();
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
virtual void render(int x, int y, float f) override;
|
||||
virtual void mouseClicked(int x, int y, int type) override;
|
||||
virtual void mouseReleased(int x, int y, int type) override;
|
||||
virtual void removed() override;
|
||||
|
||||
private:
|
||||
int m_selectedSlot = 0;
|
||||
|
||||
@@ -113,6 +113,11 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke
|
||||
m_pRakNetPeer->Send(&appbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, true);
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID&, MessagePacket* packet)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, MovePlayerPacket* packet)
|
||||
{
|
||||
//not in the original
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
void onNewClient(const RakNet::RakNetGUID&) override;
|
||||
void onDisconnect(const RakNet::RakNetGUID&) override;
|
||||
void handle(const RakNet::RakNetGUID&, LoginPacket*) override;
|
||||
void handle(const RakNet::RakNetGUID&, MessagePacket*) override;
|
||||
void handle(const RakNet::RakNetGUID&, MovePlayerPacket*) override;
|
||||
void handle(const RakNet::RakNetGUID&, PlaceBlockPacket*) override;
|
||||
void handle(const RakNet::RakNetGUID&, RemoveBlockPacket*) override;
|
||||
|
||||
Reference in New Issue
Block a user