mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-27 05:23:51 +00:00
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/ (ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser, ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager, ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter) - Split 2700-line chat_panel_commands.cpp into 11 command modules - Add GM command handling: 190-command data table, dot-prefix interception, tab-completion, /gmhelp with category filter - Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00); values 0x00-0x1B shared across Vanilla/TBC/WotLK - Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26 - Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat, add 2-frame input cooldown) - Add tests: chat_markup_parser, chat_tab_completer, gm_commands, macro_evaluator Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
This commit is contained in:
parent
09c4a9a04a
commit
42f1bb98ea
54 changed files with 7363 additions and 3856 deletions
95
include/ui/chat/chat_input.hpp
Normal file
95
include/ui/chat/chat_input.hpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace ui {
|
||||
|
||||
/**
|
||||
* Chat input state: buffer, whisper target, sent-history, focus management.
|
||||
*
|
||||
* Extracted from ChatPanel (Phase 1.2 of chat_panel_ref.md).
|
||||
* No UI or network dependencies — pure state management.
|
||||
*/
|
||||
class ChatInput {
|
||||
public:
|
||||
// ---- Buffer access ----
|
||||
char* getBuffer() { return buffer_; }
|
||||
const char* getBuffer() const { return buffer_; }
|
||||
size_t getBufferSize() const { return sizeof(buffer_); }
|
||||
|
||||
char* getWhisperBuffer() { return whisperBuffer_; }
|
||||
const char* getWhisperBuffer() const { return whisperBuffer_; }
|
||||
size_t getWhisperBufferSize() const { return sizeof(whisperBuffer_); }
|
||||
|
||||
void clear() { buffer_[0] = '\0'; }
|
||||
bool isEmpty() const { return buffer_[0] == '\0'; }
|
||||
std::string getText() const { return std::string(buffer_); }
|
||||
void setText(const std::string& text) {
|
||||
strncpy(buffer_, text.c_str(), sizeof(buffer_) - 1);
|
||||
buffer_[sizeof(buffer_) - 1] = '\0';
|
||||
}
|
||||
|
||||
// ---- Whisper target ----
|
||||
std::string getWhisperTarget() const { return std::string(whisperBuffer_); }
|
||||
void setWhisperTarget(const std::string& name) {
|
||||
strncpy(whisperBuffer_, name.c_str(), sizeof(whisperBuffer_) - 1);
|
||||
whisperBuffer_[sizeof(whisperBuffer_) - 1] = '\0';
|
||||
}
|
||||
|
||||
// ---- Sent-message history (Up/Down arrow recall) ----
|
||||
void pushToHistory(const std::string& msg);
|
||||
std::string historyUp();
|
||||
std::string historyDown();
|
||||
void resetHistoryIndex() { historyIdx_ = -1; }
|
||||
int getHistoryIndex() const { return historyIdx_; }
|
||||
const std::vector<std::string>& getSentHistory() const { return sentHistory_; }
|
||||
|
||||
// ---- Focus state ----
|
||||
bool isActive() const { return active_; }
|
||||
void setActive(bool v) { active_ = v; }
|
||||
|
||||
bool shouldFocus() const { return focusRequested_; }
|
||||
void requestFocus() { focusRequested_ = true; }
|
||||
void clearFocusRequest() { focusRequested_ = false; }
|
||||
|
||||
bool shouldMoveCursorToEnd() const { return moveCursorToEnd_; }
|
||||
void requestMoveCursorToEnd() { moveCursorToEnd_ = true; }
|
||||
void clearMoveCursorToEnd() { moveCursorToEnd_ = false; }
|
||||
|
||||
// ---- Chat type selection ----
|
||||
int getSelectedChatType() const { return selectedChatType_; }
|
||||
void setSelectedChatType(int t) { selectedChatType_ = t; }
|
||||
int getLastChatType() const { return lastChatType_; }
|
||||
void setLastChatType(int t) { lastChatType_ = t; }
|
||||
int getSelectedChannelIdx() const { return selectedChannelIdx_; }
|
||||
void setSelectedChannelIdx(int i) { selectedChannelIdx_ = i; }
|
||||
|
||||
// ---- Link insertion (shift-click) ----
|
||||
void insertLink(const std::string& link);
|
||||
|
||||
// ---- Slash key activation ----
|
||||
void activateSlashInput();
|
||||
|
||||
private:
|
||||
char buffer_[512] = "";
|
||||
char whisperBuffer_[256] = "";
|
||||
bool active_ = false;
|
||||
bool focusRequested_ = false;
|
||||
bool moveCursorToEnd_ = false;
|
||||
|
||||
// Chat type dropdown state
|
||||
int selectedChatType_ = 0; // 0=SAY .. 10=CHANNEL
|
||||
int lastChatType_ = 0;
|
||||
int selectedChannelIdx_ = 0;
|
||||
|
||||
// Sent-message history
|
||||
std::vector<std::string> sentHistory_;
|
||||
int historyIdx_ = -1;
|
||||
static constexpr int kMaxHistory = 50;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue