Skip to content

Commit cf12522

Browse files
authored
Ready button fixes 3 (#203)
* Ready button default to unready; dec font size for ready & start buttons - Fixes "Not Ready" outsizing ready button on default scaling on 1080p displays - Fixes ready button being grey with "Button" caption by default * Update Play / Spectating button styling - Decrease button & font sizes to give ready / start buttons more prominence - Use i18n lib for tooltips - Change tooltip depending on button state - Add `SetButtonStatePlaying()` and `SetButtonStateSpectating()` to avoid duplication of constants throughout the code. - Tooltip/caption values set after button init with `SetButtonStatePlaying()` - Move `button_highlight` style colours to mirror `option_button` colours - Makes use of `suppressButtonReaction` to remove hints that the play/spectating buttons are pressable when they aren't (This won't work until Spring-Chobby/Chobby#547 is merged, due to a typo in the source.)
1 parent 8ab20e3 commit cf12522

File tree

3 files changed

+64
-34
lines changed

3 files changed

+64
-34
lines changed

LuaMenu/widgets/chili/skins/Evolved/skin.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ skin.button_highlight = {
6666
tiles = {32, 32, 32, 32}, --// tile widths: left,top,right,bottom
6767
padding = {20, 20, 20, 20},
6868

69-
backgroundColor = {0.2, 0.2, 0.2, 0.7},
70-
focusColor = {0.375, 0.375, 0.375, 0.5},
71-
borderColor = {1,1,1,0},
69+
backgroundColor = {0.70, 0.70, 0.75, 0.65},
70+
focusColor = {0.72, 0.72, 0.80, 0.9},
71+
borderColor = {0.40, 0.40, 0.50, 0.15},
7272

7373
DrawControl = DrawButton,
7474
}

LuaMenu/widgets/chobby/i18n/chililobby.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,20 @@ return {
138138
skip_tutorial = "Skip Tutorial",
139139
rejoin = "Rejoin",
140140
abandon = "Abandon",
141+
142+
tooltip_is_spectator = "You will spectate this game",
143+
tooltip_become_spectator = "Press to watch the game as a spectator",
141144
spectate = "Spectate",
142145
spectating = "Spectating",
146+
147+
tooltip_is_player = "You will play in this game",
148+
tooltip_become_player = "Press to play in this game",
143149
play = "Play",
150+
playing = "Playing",
151+
144152
watch = "Watch",
145153
matchmaking = "Matchmaking",
146154
customGames = "Custom Games",
147-
playing = "Playing",
148155
pick_map = "Change Map",
149156
add_team = "Add Team",
150157
players = "Players",

LuaMenu/widgets/gui_battle_room_window.lua

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,11 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
699699
bottom = 0,
700700
height = 48,
701701
classname = "ready_button",
702-
font = config:GetFont(4),
703-
disabledFont = config:GetFont(4),
702+
font = config:GetFont(3),
703+
disabledFont = config:GetFont(3),
704704
hasDisabledFont = true,
705-
tooltip = "", -- Set in OnUpdateUserBattleStatus
705+
caption = i18n("unready"),
706+
tooltip = i18n("unready_tooltip"), -- Set in OnUpdateUserBattleStatus
706707
OnClick = {
707708
function(readyButton)
708709
if not readyButton.state.enabled then return end
@@ -713,6 +714,7 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
713714
parent = rightInfo,
714715
}
715716
readyButton:SetEnabled(false)
717+
readyButton:StyleUnready()
716718
end
717719

718720
btnStartBattle = Button:New {
@@ -722,7 +724,7 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
722724
height = 48,
723725
caption = i18n("start"),
724726
classname = "action_button",
725-
font = config:GetFont(4),
727+
font = config:GetFont(3),
726728
tooltip = "Start the game, or call a vote to start multiplayer, or join a running game",
727729
OnClick = {
728730
function()
@@ -758,41 +760,67 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
758760
}
759761

760762
local btnPlay
761-
local btnSpectate = Button:New {
763+
local btnSpectate
764+
765+
local function SetButtonStatePlaying()
766+
ButtonUtilities.SetButtonDeselected(btnSpectate)
767+
ButtonUtilities.SetCaption(btnSpectate, i18n("spectate"))
768+
ButtonUtilities.SetButtonSelected(btnPlay)
769+
ButtonUtilities.SetCaption(btnPlay, i18n("playing"))
770+
771+
btnPlay.suppressButtonReaction = true
772+
btnSpectate.suppressButtonReaction = false
773+
774+
btnPlay.tooltip = i18n("tooltip_is_player")
775+
btnSpectate.tooltip = i18n("tooltip_become_spectator")
776+
777+
end
778+
local function SetButtonStateSpectating()
779+
ButtonUtilities.SetButtonDeselected(btnPlay)
780+
ButtonUtilities.SetCaption(btnPlay, i18n("play"))
781+
ButtonUtilities.SetButtonSelected(btnSpectate)
782+
783+
btnSpectate.suppressButtonReaction = true
784+
btnPlay.suppressButtonReaction = false
785+
786+
btnSpectate.tooltip = i18n("tooltip_is_spectator")
787+
btnPlay.tooltip = i18n("tooltip_become_player")
788+
789+
ButtonUtilities.SetCaption(btnSpectate, i18n("spectating"))
790+
end
791+
792+
btnSpectate = Button:New { -- Some properties set by SetButtonStatePlaying() after both buttons are initialised.
762793
x = "50.5%",
763794
right = 0,
764795
bottom = 51,
765-
height = 48,
796+
height = 32,
766797
classname = "button_highlight",
767-
caption = "\255\66\138\201" .. i18n("spectator") .. "\b",
768-
font = config:GetFont(3),
769-
tooltip = "Watch the game as a spectator",
798+
caption = "",
799+
font = config:GetFont(2),
770800
OnClick = {
771801
function(obj)
772802
battleLobby:SetBattleStatus({
773803
isSpectator = true,
774804
isReady = false
775805
})
776-
ButtonUtilities.SetButtonDeselected(btnPlay)
777-
ButtonUtilities.SetCaption(btnPlay, i18n("play"))
778-
ButtonUtilities.SetButtonSelected(obj)
779-
ButtonUtilities.SetCaption(obj, i18n("spectating"))
806+
807+
SetButtonStateSpectating()
808+
780809
WG.Analytics.SendOnetimeEvent("lobby:multiplayer:custom:spectate")
781810
WG.Chobby.Configuration:SetConfigValue("lastGameSpectatorState", true)
782811
end
783812
},
784813
parent = rightInfo,
785814
}
786815

787-
btnPlay = Button:New {
816+
btnPlay = Button:New { -- Some properties set by SetButtonStatePlaying() after both buttons are initialised.
788817
x = 0,
789818
right = "50.5%",
790819
bottom = 51,
791-
height = 48,
820+
height = 32,
792821
classname = "button_highlight",
793-
caption = "\255\66\138\201" .. i18n("player") .. "\b",
794-
font = config:GetFont(3),
795-
tooltip = "Become a player in this game",
822+
caption = "",
823+
font = config:GetFont(2),
796824
OnClick = {
797825
function(obj)
798826
local unusedTeamID = battleLobby:GetUnusedTeamID()
@@ -802,17 +830,18 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
802830
isReady = false,
803831
side = (WG.Chobby.Configuration.lastFactionChoice or 0),
804832
teamNumber = unusedTeamID})
805-
ButtonUtilities.SetButtonDeselected(btnSpectate)
806-
ButtonUtilities.SetCaption(btnSpectate, i18n("spectate"))
807-
ButtonUtilities.SetButtonSelected(obj)
808-
ButtonUtilities.SetCaption(obj, i18n("playing"))
833+
834+
SetButtonStatePlaying()
835+
809836
WG.Analytics.SendOnetimeEvent("lobby:multiplayer:custom:play")
810837
WG.Chobby.Configuration:SetConfigValue("lastGameSpectatorState", false)
811838
end
812839
},
813840
parent = rightInfo,
814841
}
815842

843+
SetButtonStatePlaying()
844+
816845
rightInfo.OnResize = {
817846
function (obj, xSize, ySize)
818847
if xSize + minimapBottomClearance < ySize then
@@ -1063,17 +1092,11 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
10631092
function externalFunctions.UpdateUserTeamStatus(userName, allyNumber, isSpectator)
10641093
if userName == myUserName then
10651094
if isSpectator then
1066-
ButtonUtilities.SetButtonDeselected(btnPlay)
1067-
ButtonUtilities.SetCaption(btnPlay, i18n("play"))
1068-
ButtonUtilities.SetButtonSelected(btnSpectate)
1069-
ButtonUtilities.SetCaption(btnSpectate, i18n("spectating"))
1095+
SetButtonStateSpectating()
10701096
startBoxPanel:Hide()
10711097
minimapPanel.disableChildrenHitTest = true --omg this is amazing
10721098
else
1073-
ButtonUtilities.SetButtonDeselected(btnSpectate)
1074-
ButtonUtilities.SetCaption(btnSpectate, i18n("spectate"))
1075-
ButtonUtilities.SetButtonSelected(btnPlay)
1076-
ButtonUtilities.SetCaption(btnPlay, i18n("playing"))
1099+
SetButtonStatePlaying()
10771100
startBoxPanel:Show()
10781101
minimapPanel.disableChildrenHitTest = false
10791102
end

0 commit comments

Comments
 (0)