From 16754ad174645c1294fbde01af8c988a62889ea3 Mon Sep 17 00:00:00 2001 From: "born a rick, raised a morty, died a jerry" Date: Fri, 30 Nov 2018 00:20:08 -0500 Subject: [PATCH] improve mp chat behavior * ctrl + enter ignored for starting songs in screennetselect * minimize will always clear current message and disable typing * ctrl + enter will unmimize and activate chat input if minimized, or activate chat input if unminimized * insert will hard hard minimize the chat similar to the mouse click toggles, but will activate input automatically * pressing "/" will maximize and activate input as needed and auto place a "/" (for fast commands) * pressing enter while the typingtext is empty will turn off input (basically, double tap enter to disable input) * delete clears the current msg, since we have no cursor it does nothing anyway and hitting escape diabled --- .../ScreenChatOverlay overlay.lua | 46 ++++++++++++++++++- src/ScreenNetSelectMusic.cpp | 5 ++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua b/Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua index 1c87f10da9..be67d39db1 100644 --- a/Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua +++ b/Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua @@ -58,7 +58,7 @@ local show = true local online = IsNetSMOnline() and IsSMOnlineLoggedIn(PLAYER_1) and NSMAN:IsETTP() chat.MinimiseMessageCommand = function(self) - self:linear(0.5) + self:linear(0.25) moveY = minimised and height * (lineNumber + inputLineNumber + tabHeight - 1) or 0 self:y(moveY) end @@ -334,6 +334,8 @@ function overTab(mx, my) end return nil, nil end + + function MPinput(event) if (not show or not online) or isGameplay then return false @@ -345,7 +347,7 @@ function MPinput(event) end typing = false local mx, my = INPUTFILTER:GetMouseX(), INPUTFILTER:GetMouseY() - if isOver(minbar) then + if isOver(minbar) then --hard mouse toggle -mina minimised = not minimised MESSAGEMAN:Broadcast("Minimise") update = true @@ -387,12 +389,37 @@ function MPinput(event) end end + -- hard kb toggle + if event.type == "InputEventType_Release" and event.DeviceInput.button == "DeviceButton_insert" then + minimised = not minimised + MESSAGEMAN:Broadcast("Minimise") + update = true + if not minimize then + typing = true + typingText = "" + end + end + + if not typing and event.type == "InputEventType_Release" then -- keys for auto turning on chat if not already on -mina + if event.DeviceInput.button == "DeviceButton_/" then + typing = true + update = true + if minimised then + minimised = not minimised + MESSAGEMAN:Broadcast("Minimise") + end + typingText = "/" + end + end + if typing then if event.type == "InputEventType_Release" then if event.DeviceInput.button == "DeviceButton_enter" then if typingText:len() > 0 then NSMAN:SendChatMsg(typingText, currentTabType, currentTabName) typingText = "" + elseif typingText == "" then + typing = false -- pressing enter when text is empty to deactive chat is expected behavior -mina end update = true end @@ -403,6 +430,9 @@ function MPinput(event) elseif event.DeviceInput.button == "DeviceButton_space" then typingText = typingText .. " " update = true + elseif event.DeviceInput.button == "DeviceButton_delete" then -- reset msg with delete (since there's no cursor) + typingText = "" + update = true elseif (INPUTFILTER:IsBeingPressed("left ctrl") or INPUTFILTER:IsBeingPressed("right ctrl")) and event.DeviceInput.button == "DeviceButton_v" @@ -444,7 +474,19 @@ function MPinput(event) return true end + -- kb activate chat input if not minimized (has to go after the above enter block) + if event.type == "InputEventType_Release" and INPUTFILTER:IsBeingPressed("left ctrl") then + if event.DeviceInput.button == "DeviceButton_enter" and not minimised then + typing = true + update = true + end + end + if update then + if minimised then -- minimise will be set in the above blocks, disable input and clear text -mina + typing = false + typingText = "" + end MESSAGEMAN:Broadcast("UpdateChatOverlay") end diff --git a/src/ScreenNetSelectMusic.cpp b/src/ScreenNetSelectMusic.cpp index de952b22b6..4c79c05215 100644 --- a/src/ScreenNetSelectMusic.cpp +++ b/src/ScreenNetSelectMusic.cpp @@ -584,6 +584,11 @@ ScreenNetSelectMusic::MenuDown(const InputEventPlus& input) bool ScreenNetSelectMusic::MenuStart(const InputEventPlus& input) { + // dont allow ctrl + enter to select songs... technically if there's enough + // lag for some reason we can hit here from a ctrl+enter input but ctrl may + // be released by now, though this is unlikely to happen -mina + if (INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL))) + return false; return SelectCurrent(); } bool