From 36229efea51499505358ab69dc9fa3c118d282a4 Mon Sep 17 00:00:00 2001 From: LIghty Date: Sat, 24 Mar 2018 11:32:30 +0100 Subject: [PATCH 1/5] added text input --- include/menu/ncc/ItemVariable.hpp | 1 + src/menu/ncc/ItemVariable.cpp | 69 +++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 13 deletions(-) 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/menu/ncc/ItemVariable.cpp b/src/menu/ncc/ItemVariable.cpp index 551f7b98..67fe395d 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,9 @@ 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_LSHIFT || key == ButtonCode_t::KEY_LCONTROL || + key >= ButtonCode_t::KEY_FIRST && key <= ButtonCode_t::KEY_BACKSPACE) return true; return false; } @@ -84,11 +86,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 +108,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); } } From 448857b133c169c9c3091bfbb586ff4196c0940b Mon Sep 17 00:00:00 2001 From: LIghty Date: Sat, 24 Mar 2018 11:37:32 +0100 Subject: [PATCH 2/5] rename to fit menu --- src/hooks/others.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index d299508e..d2d1b44a 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) From ae403bc36a91a826a657b1eb5e5975767c205dbb Mon Sep 17 00:00:00 2001 From: LIghty Date: Sat, 24 Mar 2018 12:08:52 +0100 Subject: [PATCH 3/5] add missing items --- src/menu/ncc/Menu.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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" From c58f2a466a0febbae8a1a6607d9e64c2036f8dd8 Mon Sep 17 00:00:00 2001 From: LIghty Date: Sat, 24 Mar 2018 12:09:36 +0100 Subject: [PATCH 4/5] . --- src/menu/ncc/ItemVariable.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/menu/ncc/ItemVariable.cpp b/src/menu/ncc/ItemVariable.cpp index 67fe395d..c09970c0 100644 --- a/src/menu/ncc/ItemVariable.cpp +++ b/src/menu/ncc/ItemVariable.cpp @@ -67,7 +67,6 @@ bool ItemVariable::ConsumesKey(ButtonCode_t key) return true; if (key == ButtonCode_t::MOUSE_WHEEL_DOWN || key == ButtonCode_t::MOUSE_WHEEL_UP || - key == ButtonCode_t::KEY_LSHIFT || key == ButtonCode_t::KEY_LCONTROL || key >= ButtonCode_t::KEY_FIRST && key <= ButtonCode_t::KEY_BACKSPACE) return true; return false; From 9ee1e8379412e6a46d8ce07517953482c424b976 Mon Sep 17 00:00:00 2001 From: LIghty Date: Sat, 24 Mar 2018 12:13:50 +0100 Subject: [PATCH 5/5] forgot a comma --- src/hooks/others.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index d2d1b44a..7b717c3b 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -288,7 +288,7 @@ 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" + "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",