Skip to content

Commit

Permalink
improve mp chat behavior
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MinaciousGrace committed Nov 30, 2018
1 parent 80fc6f0 commit 16754ad
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
46 changes: 44 additions & 2 deletions Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/ScreenNetSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 16754ad

Please sign in to comment.