diff --git a/include/menu/ncc/ItemVariable.hpp b/include/menu/ncc/ItemVariable.hpp index f06a1965..6678e482 100644 --- a/include/menu/ncc/ItemVariable.hpp +++ b/include/menu/ncc/ItemVariable.hpp @@ -23,6 +23,7 @@ public: ItemVariable(CatVar &variable); void Change(float amount); + void PutChar(char ch); virtual void Update() override; virtual bool ConsumesKey(ButtonCode_t key) override; diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index d299508e..7b717c3b 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -288,10 +288,11 @@ static CatVar crypt_chat( CV_SWITCH, "chat_crypto", "1", "Crypto chat", "Start message with !! and it will be only visible to cathook users"); static CatVar chat_filter(CV_STRING, "chat_censor", "", + "Censor words", "Spam Chat with newlines if the chosen words are " "said, seperate with commas"); static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0", - "enable censor"); + "Enable censor"); bool SendNetMsg_hook(void *_this, INetMessage &msg, bool bForceReliable = false, bool bVoice = false) diff --git a/src/menu/ncc/ItemVariable.cpp b/src/menu/ncc/ItemVariable.cpp index 551f7b98..c09970c0 100644 --- a/src/menu/ncc/ItemVariable.cpp +++ b/src/menu/ncc/ItemVariable.cpp @@ -24,7 +24,7 @@ void ItemVariable::Update() Item::Update(); if (!catvar.desc_long.empty()) if (catvar.desc_long.length() && IsHovered() && - catvar.desc_long != "no description") + catvar.desc_long != "no description") ShowTooltip(catvar.desc_long); } @@ -66,7 +66,8 @@ bool ItemVariable::ConsumesKey(ButtonCode_t key) if (capturing) return true; if (key == ButtonCode_t::MOUSE_WHEEL_DOWN || - key == ButtonCode_t::MOUSE_WHEEL_UP || key == ButtonCode_t::MOUSE_FIRST) + key == ButtonCode_t::MOUSE_WHEEL_UP || + key >= ButtonCode_t::KEY_FIRST && key <= ButtonCode_t::KEY_BACKSPACE) return true; return false; } @@ -84,11 +85,16 @@ void ItemVariable::OnFocusLose() capturing = false; } +void ItemVariable::PutChar(char ch) +{ + catvar.SetValue(catvar.GetString() + std::string(1, ch)); +} + void ItemVariable::OnKeyPress(ButtonCode_t key, bool repeat) { if (capturing) { - if (key == 70) + if (key == ButtonCode_t::KEY_ESCAPE) key = (ButtonCode_t) 0; catvar = (int) key; capturing = false; @@ -101,33 +107,69 @@ void ItemVariable::OnKeyPress(ButtonCode_t key, bool repeat) { case CV_ENUM: case CV_SWITCH: - change = 1.0f; - break; + case CV_STRING: + { + if (key == ButtonCode_t::KEY_BACKSPACE) + { + std::string val = catvar.GetString(); + if (val.length() > 0) + catvar.SetValue(val.substr(0, val.length() - 1)); + return; + } + else if (key == ButtonCode_t::KEY_SPACE) + { + PutChar(' '); + return; + } + else + { + char ch = 0; + if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LSHIFT) || + g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_RSHIFT)) + ch = GetUpperChar(key); + else + ch = GetChar(key); + if (ch) + PutChar(ch); + } + } case CV_INT: case CV_FLOAT: { if (catvar.restricted) - { change = float(catvar.max - catvar.min) / 50.0f; - } else - { change = 1.0f; - } } } + if (catvar.type == CV_STRING) + { + } if (change < 1.0f && catvar.type == CV_INT) change = 1.0f; - if ((catvar.type == CV_SWITCH && key == ButtonCode_t::MOUSE_FIRST) || - key == ButtonCode_t::MOUSE_WHEEL_UP) + if (key == ButtonCode_t::MOUSE_WHEEL_UP) { - Change(change); + if (catvar.type == CV_FLOAT && + g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LSHIFT)) + Change(change * 2); + else if (catvar.type == CV_FLOAT && + g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LCONTROL)) + Change(change / 4); + else + Change(change); } else if (key == ButtonCode_t::MOUSE_WHEEL_DOWN) { - Change(-change); + if (catvar.type == CV_FLOAT && + g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LSHIFT)) + Change(-change * 2); + else if (catvar.type == CV_FLOAT && + g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LCONTROL)) + Change(-change / 4); + else + Change(-change); } } diff --git a/src/menu/ncc/Menu.cpp b/src/menu/ncc/Menu.cpp index e13762d4..4f7d6c97 100644 --- a/src/menu/ncc/Menu.cpp +++ b/src/menu/ncc/Menu.cpp @@ -627,6 +627,7 @@ static const std::string list_tf2 = R"( "Chat Settings Menu" "spam" "killsay" + "killsay_file" "spam_teamname" "spam_voicecommand" "chat_newlines" @@ -643,6 +644,7 @@ static const std::string list_tf2 = R"( "Uberspam" [ "Uberspam Menu" "uberspam" + "uberspam_file" "uberspam_team" "uberspam_build" "uberspam_ended" @@ -652,6 +654,8 @@ static const std::string list_tf2 = R"( ] "Misc" [ "Misc Menu" + "name" + "disconnect_reason" "pure_bypass" "nolerp" "info"