Skip to content

Commit

Permalink
Merge pull request #892 from AntlerForce/battleListFontTweaks
Browse files Browse the repository at this point in the history
Take 2: Add a filter option to hide games with any AIs, including PvE
  • Loading branch information
AntlerForce authored Jan 22, 2025
2 parents 01c3a7d + ec5faf7 commit 4c88a63
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 43 deletions.
97 changes: 61 additions & 36 deletions LuaMenu/widgets/chobby/components/battle/battle_list_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ local IMG_BATTLE_RUNNING = LUA_DIRNAME .. "images/ingame.png"
local IMG_LOCK = LUA_DIRNAME .. "images/lock.png"
local IMG_KEY = LUA_DIRNAME .. "images/key.png"

local myFont1 = WG.Chobby.Configuration:GetFont(1)
local myFont2 = WG.Chobby.Configuration:GetFont(2)
local myFont3 = WG.Chobby.Configuration:GetFont(3)
local myHintFont = WG.Chobby.Configuration:GetFont(11)


function BattleListWindow:init(parent)

Expand All @@ -18,8 +23,8 @@ function BattleListWindow:init(parent)
height = 37,
hint = i18n("searchbar_hint"),
text = "",
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideHintFont = WG.Chobby.Configuration:GetFont(11),
objectOverrideFont = myFont3,
objectOverrideHintFont = myHintFont,
useIME = false,
parent = self.window,
OnTextModified = {
Expand All @@ -42,7 +47,7 @@ function BattleListWindow:init(parent)
width = 160,
height = 45,
caption = i18n("open_mp_game"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
classname = "option_button",
parent = self.window,
OnClick = {
Expand Down Expand Up @@ -82,21 +87,21 @@ function BattleListWindow:init(parent)
right = 5,
bottom = 15,
height = 20,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
caption = "Filter out:",
parent = self.window
}

local checkPassworded = Checkbox:New {
x = 110,
x = "15%",
width = 21,
bottom = 8,
height = 30,
boxalign = "left",
boxsize = 20,
caption = " Passworded",
checked = Configuration.battleFilterPassworded2 or false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
Configuration:SetConfigValue("battleFilterPassworded2", newState)
Expand All @@ -107,15 +112,15 @@ function BattleListWindow:init(parent)
tooltip = "Hides all battles that require a password to join",
}
local checkNonFriend = Checkbox:New {
x = 280,
x = "33%",
width = 21,
bottom = 8,
height = 30,
boxalign = "left",
boxsize = 20,
caption = " Non-friend",
checked = Configuration.battleFilterNonFriend or false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
Configuration:SetConfigValue("battleFilterNonFriend", newState)
Expand All @@ -126,15 +131,15 @@ function BattleListWindow:init(parent)
tooltip = "Hides all battles that don't have your friends in them",
}
local checkRunning = Checkbox:New {
x = 435,
x = "50%",
width = 21,
bottom = 8,
height = 30,
boxalign = "left",
boxsize = 20,
caption = " Running",
checked = Configuration.battleFilterRunning or false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
Configuration:SetConfigValue("battleFilterRunning", newState)
Expand All @@ -144,17 +149,35 @@ function BattleListWindow:init(parent)
parent = self.window,
tooltip = "Hides all battles that are in progress",
}

local checkVsAI = Checkbox:New {
x = "65%",
width = 21,
bottom = 8,
height = 30,
boxalign = "left",
boxsize = 20,
caption = " Vs AI",
checked = Configuration.battleFilterLocked or false,
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
Configuration:SetConfigValue("battleFilterVsAI", newState)
self:SoftUpdate()
end
},
parent = self.window,
tooltip = "Hides all battles with AIs, including PvE",
}
local checkLocked = Checkbox:New {
x = 575,
x = "77%",
width = 21,
bottom = 8,
height = 30,
boxalign = "left",
boxsize = 20,
caption = " Locked",
checked = Configuration.battleFilterLocked or false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
Configuration:SetConfigValue("battleFilterLocked", newState)
Expand Down Expand Up @@ -420,7 +443,7 @@ function BattleListWindow:MakeWatchBattle(battleID, battle)
right = 0,
height = 20,
valign = 'center',
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
caption = (battle.title or "") .. " - Click to watch",
parent = parentButton,
OnResize = {
Expand Down Expand Up @@ -472,7 +495,7 @@ function BattleListWindow:MakeWatchBattle(battleID, battle)
y = 20,
height = 15,
valign = 'center',
objectOverrideFont = WG.Chobby.Configuration:GetFont(1),
objectOverrideFont = myFont1,
caption = playerCount .. ((playerCount == 1 and " player on " ) or " players on ") .. battle.mapName:gsub("_", " "),
parent = parentButton,
}
Expand All @@ -494,7 +517,7 @@ function BattleListWindow:MakeWatchBattle(battleID, battle)
y = 36,
height = 15,
valign = 'center',
objectOverrideFont = WG.Chobby.Configuration:GetFont(1),
objectOverrideFont = myFont1,
caption = modeName,
parent = parentButton,
}
Expand Down Expand Up @@ -561,7 +584,7 @@ function BattleListWindow:MakeJoinBattle(battleID, battle)
height = 20,
align = "left",
valign = 'center',
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
--caption = battle.title .. " | " .. battle.mapName:gsub("_", " "),
caption = battle.title,
parent = parentButton,
Expand Down Expand Up @@ -606,7 +629,7 @@ function BattleListWindow:MakeJoinBattle(battleID, battle)
--align = "right",
valign = 'center',
caption = battle.mapName:gsub("_", " "),
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
parent = parentButton,
OnResize = {
function (obj, xSize, ySize)
Expand Down Expand Up @@ -670,7 +693,7 @@ function BattleListWindow:MakeJoinBattle(battleID, battle)
height = 20,
align = "right",
valign = 'center',
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
caption = lobby:GetBattlePlayerCount(battleID) .. "/" .. battle.maxPlayers,
parent = parentButton,
}
Expand Down Expand Up @@ -737,6 +760,10 @@ function BattleListWindow:ItemInFilter(id)
return false
end

if Configuration.battleFilterVsAI and (string.find(battle.title, "vs AI") or string.find(battle.title, "vs Scavengers") or string.find(battle.title, "vs Raptors")) then
return false
end

if Configuration.battleFilterRedundant then
return self:FilterRedundantBattle(battle, id)
end
Expand Down Expand Up @@ -1358,7 +1385,7 @@ function BattleListWindow:OpenHostWindow()
height = 35,
align = "center",
caption = i18n("open_mp_game"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
parent = hostBattleWindow,
}

Expand All @@ -1373,8 +1400,8 @@ function BattleListWindow:OpenHostWindow()
--text = "You can host a game by requesting an empty battle room. You can lock the battle rooms (!lock) to prevent anyone from joining, otherwise anyone can join your game.",--i18n("game_name") .. ":",
text = "Choose whether you want a public or a private custom battle where you are the boss and only you may change game settings. Only the boss leaving the room can unboss them. Anyone may join public battles, but private battles are password protected.",
--i18n("game_name") .. ":",
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideHintFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
objectOverrideHintFont = myFont2,
parent = hostBattleWindow,
}

Expand All @@ -1385,7 +1412,7 @@ function BattleListWindow:OpenHostWindow()
align = "right",
height = 35,
caption = "Geographical region",-- i18n("game_type") .. ":",
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
parent = hostBattleWindow,
}

Expand All @@ -1396,10 +1423,8 @@ function BattleListWindow:OpenHostWindow()
height = 35,
itemHeight = 22,
text = "",
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
text = "",
items = {'Europe', 'North America', 'Australia', 'East Asia'}, -- {'EU','US','AU','EA'}
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
selected = 1,
tooltip = "You may choose any region you wish, BAR is not sensitive to latency.",
parent = hostBattleWindow,
Expand All @@ -1414,7 +1439,7 @@ function BattleListWindow:OpenHostWindow()
boxsize = 20,
caption = "Friends only",
checked = false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
allowFriendsToJoin = newState
Expand All @@ -1437,7 +1462,7 @@ function BattleListWindow:OpenHostWindow()
boxsize = 20,
caption = "Passworded private battle",
checked = false,
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
OnChange = {
function (obj, newState)
userWantsPrivateBattle = newState
Expand All @@ -1461,7 +1486,7 @@ function BattleListWindow:OpenHostWindow()
align = "left",
height = 35,
caption = "",-- i18n("game_type") .. ":",
objectOverrideFont = WG.Chobby.Configuration:GetFont(2),
objectOverrideFont = myFont2,
parent = hostBattleWindow,
}

Expand Down Expand Up @@ -1637,7 +1662,7 @@ function BattleListWindow:OpenHostWindow()
bottom = 1,
height = 70,
caption = i18n("host"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
parent = hostBattleWindow,
classname = "action_button",
tooltip = "Request a hosted battle. Please be patient while the lobby spins up.",
Expand All @@ -1654,7 +1679,7 @@ function BattleListWindow:OpenHostWindow()
bottom = 1,
height = 70,
caption = i18n("cancel"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
parent = hostBattleWindow,
classname = "negative_button",
OnClick = {
Expand Down Expand Up @@ -1739,7 +1764,7 @@ function BattleListWindow:JoinBattle(battle, _, _, joinAsPlayer)
right = 15,
y = 15,
height = 35,
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
caption = i18n("enter_battle_password"),
parent = passwordWindow,
}
Expand All @@ -1751,8 +1776,8 @@ function BattleListWindow:JoinBattle(battle, _, _, joinAsPlayer)
height = 35,
text = "",
hint = i18n("password"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideHintFont = WG.Chobby.Configuration:GetFont(11),
objectOverrideFont = myFont3,
objectOverrideHintFont = myHintFont,
passwordInput = true,
useIME = false,
parent = passwordWindow,
Expand All @@ -1774,7 +1799,7 @@ function BattleListWindow:JoinBattle(battle, _, _, joinAsPlayer)
bottom = 1,
height = 70,
caption = i18n("join"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
classname = "action_button",
OnClick = {
function()
Expand All @@ -1789,7 +1814,7 @@ function BattleListWindow:JoinBattle(battle, _, _, joinAsPlayer)
bottom = 1,
height = 70,
caption = i18n("cancel"),
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
objectOverrideFont = myFont3,
classname = "negative_button",
OnClick = {
function()
Expand Down
12 changes: 5 additions & 7 deletions LuaMenu/widgets/chobby/components/login_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function LoginWindow:init(failFunction, cancelText, windowClassname, params)
return
end
self.emailRequired = (params and params.emailRequired) or false
self.windowHeight = (params and params.windowHeight) or (self.emailRequired and 430+200) or 390+200
self.windowHeight = (params and params.windowHeight) or (self.emailRequired and 460+200) or 420+200
self.loginAfterRegister = (params and params.loginAfterRegister) or false

local registerChildren = {}
Expand Down Expand Up @@ -445,7 +445,7 @@ function LoginWindow:init(failFunction, cancelText, windowClassname, params)
self.txtErrorRegister = TextBox:New {
x = 15,
right = 15,
y = self.windowHeight - 216,
y = self.windowHeight - 246,
height = 90,
text = "",
objectOverrideFont = WG.Chobby.Configuration:GetFont(3),
Expand Down Expand Up @@ -1230,8 +1230,10 @@ function LoginWindow:tryRegister()
local username = self.ebUsernameRegister.text

if username == '' then
self.txtErrorRegister:SetText(Configuration:GetErrorColor() .. "No username provided.")
return
end

local isinValidUserName = isInValidUserName(username)
if isinValidUserName then
self.txtErrorRegister:SetText(Configuration:GetErrorColor() .. isinValidUserName)
Expand All @@ -1258,10 +1260,6 @@ function LoginWindow:tryRegister()

local password = (self.ebPasswordRegister.visible and self.ebPasswordRegister.text) or nil
local email = (self.emailRequired and self.ebEmail.visible and self.ebEmail.text) or nil
if username == '' then
self.txtErrorRegister:SetText(Configuration:GetErrorColor() .. "No username provided.")
return
end

if password == '' then
self.txtErrorRegister:SetText(Configuration:GetErrorColor() .. "No password provided.")
Expand All @@ -1277,7 +1275,7 @@ function LoginWindow:tryRegister()
self.txtErrorRegister:SetText(Configuration:GetErrorColor() .. "Registration error:" .. err)
lobby:RemoveListener("OnRegistrationDenied", self.onRegistrationDenied)
end

lobby:AddListener("OnRegistrationDenied", self.onRegistrationDenied)

if (lobby:GetConnectionStatus() ~= "connected") or self.loginAttempts >= 3 then
Expand Down

0 comments on commit 4c88a63

Please sign in to comment.