Skip to content

Commit

Permalink
ChatOverlay improvements
Browse files Browse the repository at this point in the history
-Works more like a tab, does not intersect with songwheel
-topbar takes up very little space
-tab notifications on recieved message (needs more work)
-"Server" tab name
-tip about insert shortcut
-uhhhh other stuff probably
  • Loading branch information
Ulti-FD committed Aug 13, 2021
1 parent 3d33a11 commit 1efb16b
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 55 deletions.
2 changes: 2 additions & 0 deletions Themes/Til Death/BGAnimations/_PlayerInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ t[#t + 1] =
self:queuecommand("Set")
end,
SetCommand = function(self)
local online = IsNetSMOnline() and IsSMOnlineLoggedIn(PLAYER_1) and NSMAN:IsETTP()
self:y(AvatarY + 41 - (online and 18 or 0))
self:settextf("%s: %s", translated_info["Judge"], GetTimingDifficulty())
end
},
Expand Down
194 changes: 140 additions & 54 deletions Themes/_fallback/BGAnimations/ScreenChatOverlay overlay.lua
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
local width, height = SCREEN_WIDTH, SCREEN_HEIGHT * 0.035
local maxlines = 5
local lineNumber = 5
local width, height = SCREEN_WIDTH - capWideScale(get43size(350), 350) - 10, SCREEN_HEIGHT * 0.035
local maxlines = 20
local lineNumber = 20
local inputLineNumber = 2
local tabHeight = 1
local maxTabs = 10
local x, y = 0, SCREEN_HEIGHT - height * (maxlines + inputLineNumber + tabHeight)
local maxTabs = 5
local x, y = 5, SCREEN_HEIGHT - height * (maxlines + inputLineNumber + tabHeight)
local moveY = 0
local scale = 0.4
local minimised = false
local minimised = true
local typing = false
local typingText = ""
local transparency = 0.667
local curmsgh = 0
local closeTabSize = 10
local tweentime = 0.25
local tipshown = false
local topbaroffset = capWideScale(6,0)
local Colors = {
background = color("#333333"),
background = getMainColor("tabs"),
input = color("#888888"),
activeInput = color("#9977BB"),
activeInput = Brightness(getMainColor("positive"),0.2),
chatSent = ColorMultiplier(getMainColor("positive"),1.5),
output = color("#545454"),
bar = color("#666666"),
tab = color("#555555"),
activeTab = color("#999999")
}
local translated_info = {
WindowTitle = THEME:GetString("MultiPlayer", "ChatTitle"),
LobbyName = THEME:GetString("MultiPlayer", "LobbyName")
LobbyTab = THEME:GetString("MultiPlayer", "LobbyTabName"),
ServerTab = THEME:GetString("MultiPlayer", "ServerTabName"),
ToggleTip = THEME:GetString("MultiPlayer", "InsertTip")
}
local chats = {}
chats[0] = {}
Expand Down Expand Up @@ -60,14 +66,21 @@ local show = true
local online = IsNetSMOnline() and IsSMOnlineLoggedIn(PLAYER_1) and NSMAN:IsETTP()

chat.MinimiseMessageCommand = function(self)
self:linear(0.25)
self:decelerate(tweentime)
moveY = minimised and height * (maxlines + inputLineNumber + tabHeight - 1) or 0
self:y(moveY)
end
local i = 0
chat.InitCommand = function(self)
online = IsNetSMOnline() and IsSMOnlineLoggedIn(PLAYER_1) and NSMAN:IsETTP()
self:visible(false)
MESSAGEMAN:Broadcast("Minimise")
end
chat.BeginTextEntryMessageCommand = function(self)
if not minimised then
minimised = not minimised
MESSAGEMAN:Broadcast("Minimise")
end
end
local isGameplay
local isInSinglePlayer
Expand All @@ -83,7 +96,7 @@ chat.ScreenChangedMessageCommand = function(self)
if
oldScreen ~= currentScreen and
(currentScreen == "ScreenSelectMusic" or currentScreen == "ScreenTitleMenu" or
currentScreen == "ScreenOptionsService")
currentScreen == "ScreenOptionsService" or currentScreen == "ScreenInit")
then
isInSinglePlayer = true
end
Expand Down Expand Up @@ -140,7 +153,7 @@ chat[#chat + 1] =
bg = self
self:diffuse(Colors.background)
self:diffusealpha(transparency)
self:stretchto(x, y, width + x, height * (maxlines + inputLineNumber + tabHeight) + y)
self:stretchto(x, y + height, width + x, height * (maxlines + inputLineNumber + tabHeight) + y)
end
}
local minbar
Expand All @@ -151,19 +164,34 @@ chat[#chat + 1] =
minbar = self
self:diffuse(Colors.bar)
self:diffusealpha(transparency)
self:stretchto(x, y, width + x, height + y)
self:stretchto(width * 0.425 + x, y, width * 0.575 + x, height + y)
self:addx(topbaroffset)
end,
ChatMessageCommand = function(self)
if minimised then
self:linear(0.25)
self:diffuse(Colors.activeInput)
ChatMessageCommand = function(self, params)
if minimised and params.tab ~= ""
and not (params.msg:find("System:") and not params.msg:find("The room is now")
and not params.msg:find("Can't start") and not params.msg:find("room operator")
and not params.msg:find("You're not in a room") and not params.msg:find("Starting in")) then
self:linear(tweentime)
self:glowshift()
self:effectcolor1(Colors.chatSent)
self:effectcolor2(Colors.bar)
self:effectperiod(1)
end
end,
MinimiseMessageCommand = function(self)
if not minimised then
self:diffuse(Colors.bar)
if minimised then
self:linear(tweentime)
self:diffuse(Colors.bar):diffusealpha(transparency)
self:stopeffect()
else
self:linear(tweentime)
self:diffuse(Colors.bar):diffusealpha(0)
end
end
end,
StopEffectCommand = function(self)
self:stopeffect()
end,
}
chat[#chat + 1] =
LoadFont("Common Normal") ..
Expand All @@ -175,23 +203,52 @@ chat[#chat + 1] =
self:zoom(0.5)
self:diffuse(color("#000000"))
self:visible(true)
self:xy(x + 4, y + height * 0.5)
self:xy(x + 3 + width * 0.425, y - 0.5 + height * 0.5)
self:addx(topbaroffset)
end,
MinimiseMessageCommand = function(self)
self:accelerate(tweentime):diffusealpha(minimised and 1 or 0)
end
}
chat[#chat + 1] =
LoadFont("Common Normal") ..
{
Name = "BarMinimiseButton",
Name = "BarLabel2",
InitCommand = function(self)
self:settext("-")
self:halign(1):valign(0.5)
self:zoom(0.8)
self:diffuse(color("#000000"))
self:visible(true)
self:xy(x + width - 4, y + 5)
self:xy(x - 3 + width * 0.575, y - 0.5 + height * 0.5)
self:addx(topbaroffset)
end,
MinimiseMessageCommand = function(self)
self:settext(minimised and "+" or "-")
self:y(minimised and y - 1 + height * 0.5 or y - 2.5 + height * 0.5)
self:accelerate(tweentime):diffusealpha(minimised and 1 or 0)
end
}
chat[#chat + 1] =
LoadFont("Common Normal") ..
{
Name = "InsertShortcutTip",
InitCommand = function(self)
self:settext(translated_info["ToggleTip"])
self:halign(0):valign(0.5)
self:zoom(0.5)
self:xy(x + 3 + width * 0.575, y - 0.5 + height * 0.5)
self:addx(topbaroffset)
self:diffusealpha(0)
self:maxwidth((width * 0.425 - 6 - topbaroffset) / 0.5)
self:shadowlength(1)
end,
MinimiseMessageCommand = function(self)
if not minimised and not tipshown then
tipshown = true
self:diffusealpha(1):sleep(3)
self:linear(0.5):diffusealpha(0)
end
end
}

Expand Down Expand Up @@ -230,6 +287,13 @@ chatWindow[#chatWindow + 1] =
MESSAGEMAN:Broadcast("UpdateChatOverlayMsgs")
end
}
chatWindow[#chatWindow + 1] =
Def.Quad { --masking quad, hides any text outside chatwindow
InitCommand = function(self)
self:stretchto(x, -SCREEN_HEIGHT, width + x, height * 2 + y)
self:zwrite(true):blend("BlendMode_NoEffect")
end,
}
chatWindow[#chatWindow + 1] =
LoadColorFont("Common Normal") ..
{
Expand All @@ -242,6 +306,7 @@ chatWindow[#chatWindow + 1] =
self:SetMaxLines(maxlines, 1)
self:wrapwidthpixels((width - 8) / scale)
self:xy(x + 4, y + height * (maxlines + tabHeight) - 4)
self:ztest(true)
end,
UpdateChatOverlayMsgsMessageCommand = function(self)
local t = ""
Expand Down Expand Up @@ -273,49 +338,76 @@ for i = 0, maxTabs - 1 do
Colors.tab
)
self:stretchto(x + tabWidth * i, y + height, x + tabWidth * (i + 1), y + height * (1 + tabHeight))
end
end,
ChatMessageCommand = function(self, params)
if params.tab == self:GetParent():GetChild("TabName"):GetText() and params.tab ~= currentTabName
and not (params.msg:find("System:") and not params.msg:find("The room is now")
and not params.msg:find("Can't start") and not params.msg:find("room operator")
and not params.msg:find("You're not in a room") and not params.msg:find("Starting in")) then
self:decelerate(0.2):diffuse(Colors.chatSent)
end
end,
},
Def.Quad {
InitCommand = function(self)
self:diffuse(Color.Black)
self:diffusealpha(transparency)
self:halign(0.5)
self:stretchto(x + tabWidth * (i + 1) - 1, y + height,x + tabWidth * (i + 1), y + height * (1 + tabHeight))
end,
},
LoadFont("Common Normal") ..
{
Name = "TabName",
InitCommand = function(self)
self:halign(0):valign(0)
self:maxwidth(tabWidth * 2)
self:halign(0):valign(0.5)
self:maxwidth((tabWidth - 5) / scale)
self:zoom(scale)
self:diffuse(color("#000000"))
self:xy(x + tabWidth * i + 4, y + height * (1 + (tabHeight / 4)))
self:xy(x + tabWidth * i + 4 - 1.5, y + height * (1 + (tabHeight / 2.3)))
end,
UpdateChatOverlayMessageCommand = function(self)
if not tabs[i + 1] then
self:settext("")
return
end
if tabs[i + 1][1] == 0 and tabs[i + 1][2] == "" then
self:settext(translated_info["LobbyName"])
self:settext(translated_info["LobbyTab"])
elseif tabs[i + 1][1] ~= 0 and tabs[i + 1][2] == "" then
self:settext(translated_info["ServerTab"])
else
self:settext(tabs[i + 1][2] or "")
end
end
},
LoadFont("Common Normal") ..
{
InitCommand = function(self)
self:halign(0):valign(0)
self:maxwidth(tabWidth)
self:zoom(scale)
self:diffuse(color("#000000"))
self:xy(x + tabWidth * (i + 1) - closeTabSize, y + height * (1 + (tabHeight / 4)))
end,
UpdateChatOverlayMessageCommand = function(self)
if
tabs[i + 1] and
((tabs[i + 1][1] == 0 and tabs[i + 1][2] == "") or
(tabs[i + 1][1] == 1 and tabs[i + 1][2] ~= nil and tabs[i + 1][2] == NSMAN:GetCurrentRoomName()))
then
self:settext("")
then
self:maxwidth((tabWidth - 5) / scale)
else
self:settext("X")
self:maxwidth((tabWidth - 15) / scale)
end
end
},
Def.Sprite {
Texture = THEME:GetPathG("","X.png"),
InitCommand = function(self)
self:halign(0):valign(0.5)
self:zoom(scale - 0.1)
self:diffuse(Color.Red)
self:xy(x + tabWidth * (i + 1) - closeTabSize, y + height * (1 + (tabHeight / 2.1)))
end,
UpdateChatOverlayMessageCommand = function(self)
if
tabs[i + 1] and
((tabs[i + 1][1] == 0 and tabs[i + 1][2] == "") or
(tabs[i + 1][1] == 1 and tabs[i + 1][2] ~= nil and tabs[i + 1][2] == NSMAN:GetCurrentRoomName()))
then
self:visible(false)
else
self:visible(true)
end
end
}
}
end
Expand Down Expand Up @@ -439,13 +531,10 @@ function MPinput(event)
end

-- hard kb toggle
if event.type == "InputEventType_Release" and event.DeviceInput.button == "DeviceButton_insert" then
if event.type == "InputEventType_FirstPress" and event.DeviceInput.button == "DeviceButton_insert" then
minimised = not minimised
MESSAGEMAN:Broadcast("Minimise")
update = true
if not minimize then
typingText = ""
end
end

if event.type == "InputEventType_FirstPress" and event.DeviceInput.button == "DeviceButton_/" then
Expand Down Expand Up @@ -490,12 +579,9 @@ function MPinput(event)
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"
then
elseif (INPUTFILTER:IsBeingPressed("left ctrl") or INPUTFILTER:IsBeingPressed("right ctrl")) and
event.DeviceInput.button == "DeviceButton_v" then
typingText = typingText .. Arch.getClipboard()
update = true
elseif event.DeviceInput.button == "DeviceButton_backspace" then
typingText = typingText:sub(1, -2)
update = true
Expand Down Expand Up @@ -558,9 +644,9 @@ end

return chat
--[[
Untested half done prototype stuff for chart request front end (Probably
Untested half done prototype stuff for chart request front end (Probably
wanna put this in a special tab located at the rightmost possible position)
local chartRequestsConfig = {
numChartReqActors = 4,
padding = 10,
Expand Down
4 changes: 3 additions & 1 deletion Themes/_fallback/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ December=December

[MultiPlayer]
ChatTitle=CHAT
LobbyName=Lobby
LobbyTabName=Lobby
ServerTabName=Server
InsertTip=Press insert to toggle chat
P1=P1
P2=P2
P3=P3
Expand Down

0 comments on commit 1efb16b

Please sign in to comment.