Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matchmaking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ function MP.UTILS.parse_modlist(mod_entries)
return mods
end

function MP.UTILS.resolve_mod_name_and_version(mod_name, mod_version)
local fullname = mod_name .. "-" .. (mod_version or "")
local new_mod_name, new_mod_version = fullname:match("^(.*)%-([^~]+~.*)$")
mod_name = new_mod_name or mod_name
mod_version = new_mod_version or mod_version
return mod_name, mod_version
end

-- "0.4.0~pre1-DEV" -> "0.4.0". nil if no leading numeric version.
function MP.UTILS.version_prefix(version)
if type(version) ~= "string" then return nil end
Expand Down
4 changes: 4 additions & 0 deletions lib/string_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ function MP.UTILS.string_split(inputstr, sep)
end
return t
end

function MP.UTILS.string_starts(str, prefix)
return str:sub(1, #prefix) == prefix
end
20 changes: 13 additions & 7 deletions ui/game/lobby_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,29 @@ function MP.UI.create_UIBox_player_row(type)
nodes = {
{
n = G.UIT.C,
config = { align = "cm", padding = 0.05, r = 0.1, colour = G.C.BLACK },
config = { align = "cm" },
nodes = {
{
n = G.UIT.C,
config = {
align = "cm",
padding = 0.025,
padding = 0.05,
r = 0.1,
colour = G.C.MULT,
minw = 2,
maxw = 2,
outline = 0.5,
outline_colour = G.C.MULT,
emboss = 0.07,
},
nodes = {
{
n = G.UIT.T,
config = {
text = tostring(lives) .. " " .. localize("k_lives"),
scale = 0.4,
scale = 0.375,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
Expand Down Expand Up @@ -229,26 +232,29 @@ function MP.UI.create_UIBox_player_row(type)
},
{
n = G.UIT.C,
config = { align = "cm", padding = 0.05, colour = G.C.BLACK, r = 0.1 },
config = { align = "cm" },
nodes = {
{
n = G.UIT.C,
config = {
align = "cm",
padding = 0.025,
padding = 0.05,
r = 0.1,
colour = G.C.PURPLE,
minw = 1.75,
maxw = 1.75,
outline = 0.5,
outline_colour = G.C.PURPLE,
emboss = 0.07,
},
nodes = {
{
n = G.UIT.T,
config = {
text = tostring(skips) .. " " .. localize("k_skips"),
scale = 0.4,
scale = 0.375,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
Expand Down Expand Up @@ -294,7 +300,7 @@ function MP.UI.create_UIBox_player_row(type)
n = G.UIT.T,
config = {
text = MP.INSANE_INT.to_string(highest_score),
scale = 0.45,
scale = 0.425,
colour = G.C.FILTER,
shadow = true,
},
Expand Down
71 changes: 63 additions & 8 deletions ui/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,85 @@ end
function MP.UI.modlist_to_view(mods, text_colour)
local t = {}

if not mods then return t end
if not mods then
return t
end

local special_mods_targets = {
"Steamodded",
"Lovely",
"Multiplayer",
"Preview",
}
local special_mods_found = {}
local other_mods = {}
for mod_name, mod_version in pairs(mods) do
local display_text = mod_version and (mod_name .. "-" .. mod_version) or mod_name
local color = MP.BANNED_MODS[mod_name] and G.C.RED or text_colour
local found = false
for _, id in ipairs(special_mods_targets) do
if not special_mods_found[id] and MP.UTILS.string_starts(mod_name, id) then
special_mods_found[id] = { name = mod_name, version = mod_version }
found = true
break
end
end
if not found then
table.insert(other_mods, { name = mod_name, version = mod_version })
end
end

table.sort(other_mods, function(a, b)
return a.name < b.name
end)

local function add_mod_row(mod)
local mod_name, mod_version = MP.UTILS.resolve_mod_name_and_version(mod.name, mod.version)
local color = MP.BANNED_MODS[mod.name] and G.C.RED or text_colour
table.insert(t, {
n = G.UIT.R,
config = {
padding = 0.02,
align = "cm",
padding = 0.025,
},
nodes = {
{
n = G.UIT.T,
config = {
text = display_text,
shadow = true,
scale = 0.4,
text = mod_name,
scale = 0.32,
colour = color,
},
},
mod_version and {
n = G.UIT.T,
config = {
text = " " .. mod_version,
scale = 0.32,
colour = adjust_alpha(color, 0.6),
},
} or nil,
},
})
end
local function add_separator()
table.insert(t, {
n = G.UIT.R,
config = {
minh = 0.025,
colour = adjust_alpha(text_colour, 0.25),
},
})
end

for _, mod in pairs({ special_mods_found.Lovely, special_mods_found.Steamodded }) do
add_mod_row(mod)
end
add_separator()
for _, mod in pairs({ special_mods_found.Multiplayer, special_mods_found.Preview }) do
add_mod_row(mod)
end
add_separator()
for _, mod in ipairs(other_mods) do
add_mod_row(mod)
end
return t
end

Expand Down