Skip to content

Fix text chat functionality#8

Open
urbanawakening wants to merge 1 commit intoMinecraft-Community-Edition:mainfrom
urbanawakening:main
Open

Fix text chat functionality#8
urbanawakening wants to merge 1 commit intoMinecraft-Community-Edition:mainfrom
urbanawakening:main

Conversation

@urbanawakening
Copy link

@urbanawakening urbanawakening commented Mar 7, 2026

What does this PR do?

Fixes the in-game chat system + reimplements the chat renderer.

Input layer:

  • Adds Screen::injectKeyPressed() public wrapper so the Win64 WndProc can forward key events into the active screen's protected keyPressed() handler.
  • Routes WM_CHAR (printable characters, Enter) and WM_KEYDOWN (Escape, Backspace, arrows, Tab) from WndProc to the active screen, returning 0 to consume handled events before they reach gameplay input (g_KBMInput).
  • Adds KeyboardConstFromVK() helper to map Win32 virtual key codes back to Keyboard::KEY_* constants.
  • Fixes the chat-open hotkey (T) to use edge detection (s_chatKeyWasDown) so it only fires on key-down, not while held.

Text editing:

  • Adds caretPos member to ChatScreen with full caret-based editing: insert at position, backspace at caret, left/right arrow navigation, and blinking cursor in render.
  • Fixes a static initialization order bug where ChatScreen::allowedChars was an empty copy of SharedConstants::acceptableLetters — now references the source string directly at runtime.

Networking:

  • Re-enables PlayerConnection::handleChat (was #if 0): formats messages as <PlayerName> text and broadcasts via PlayerList::broadcastAll().
  • Adds explicit case ChatPacket::e_ChatCustom in ClientConnection::handleChat to display incoming raw chat messages.

Rendering:

  • Re-enables the OpenGL chat message renderer in Gui::render() (was #if 0), repositioned from overlapping the health bar to 40px above the toolbar.
  • Disables the duplicate Iggy/flash chat labels in UIScene_HUD::handleTimerComplete() by zeroing all m_labelChatText opacities, consolidating chat display into the single Gui.cpp path.

Why?

The Win64 port had no working chat. Pressing T would basically softlock you.

How to test

  • Launch a singleplayer world, press T, chat input bar appears at screen bottom with blinking cursor
  • Type a message, verify characters appear and caret moves correctly
  • Use Backspace to delete, Left/Right arrows to move cursor, then press Enter to send
  • Verify the sent message appears in the chat history above the toolbar with dark gray background
  • Press Escape while chat is open, chat closes, pause menu does NOT open
  • Verify chat messages fade out after ~10 seconds when not actively chatting

Checklist

  • Builds without errors
  • Tested in-game
  • No new warnings

This comment was marked as abuse.

@coah80
Copy link
Contributor

coah80 commented Mar 8, 2026

i did not mean to click dat shit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants