Add Chat / Pastes / Formatting (#682)

* Initial fixes for ContainerSetSlotPacket and CraftItemPacket

* Chat: paste, history, § formatting, 1-9 block when open (Windows64)

Made-with: Cursor

* static_cast refactor
This commit is contained in:
Kevin
2026-03-06 09:52:28 -06:00
committed by GitHub
parent 1755cd58be
commit ea65542c1b
16 changed files with 456 additions and 150 deletions

View File

@@ -22,6 +22,9 @@
#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\ClientConnection.h"
#include "..\Minecraft.h"
#include "..\ChatScreen.h"
#include "KeyboardMouseInput.h"
#include "..\User.h"
#include "..\..\Minecraft.World\Socket.h"
#include "..\..\Minecraft.World\ThreadName.h"
@@ -572,14 +575,28 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CHAR:
// Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player
if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter
g_KBMInput.OnChar((wchar_t)wParam);
g_KBMInput.OnChar(static_cast<wchar_t>(wParam));
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
{
int vk = (int)wParam;
if (lParam & 0x40000000) break; // ignore auto-repeat
int vk = static_cast<int>(wParam);
if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK)
break;
#ifdef _WINDOWS64
Minecraft* pm = Minecraft::GetInstance();
ChatScreen* chat = pm && pm->screen ? dynamic_cast<ChatScreen*>(pm->screen) : nullptr;
if (chat)
{
if (vk == 'V' && (GetKeyState(VK_CONTROL) & 0x8000))
{ chat->handlePasteRequest(); break; }
if ((vk == VK_UP || vk == VK_DOWN) && !(lParam & 0x40000000))
{ if (vk == VK_UP) chat->handleHistoryUp(); else chat->handleHistoryDown(); break; }
if (vk >= '1' && vk <= '9') // Prevent hotkey conflicts
break;
}
#endif
if (vk == VK_SHIFT)
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
else if (vk == VK_CONTROL)
@@ -592,7 +609,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYUP:
case WM_SYSKEYUP:
{
int vk = (int)wParam;
int vk = static_cast<int>(wParam);
if (vk == VK_SHIFT)
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
else if (vk == VK_CONTROL)
@@ -1612,6 +1629,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
}
// Open chat
if (g_KBMInput.IsKeyPressed('T') && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL)
{
g_KBMInput.ClearCharBuffer();
pMinecraft->setScreen(new ChatScreen());
SetFocus(g_hWnd);
}
#if 0
// has the game defined profile data been changed (by a profile load)
if(app.uiGameDefinedDataChangedBitmask!=0)