Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drop-in Playlist support #586

Open
wants to merge 2 commits into
base: itgmania-beta
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ local input = function(event)
MESSAGEMAN:Broadcast('Sort', { order = focus.sort_by })
MESSAGEMAN:Broadcast('ResetHeaderText')
overlay:queuecommand("DirectInputToEngine")

-- the player wants to change modes, for example from ITG to FA+
elseif focus.kind == "Playlist" then
local path = THEME:GetPathO("", "Playlists/" .. focus.new_overlay .. ".txt")
SONGMAN:SetPreferredSongs(path, --[[isAbsolute=]]true);
if SONGMAN:GetPreferredSortSongs() then
overlay:queuecommand("DirectInputToEngine")
SCREENMAN:GetTopScreen():GetMusicWheel():ChangeSort("SortOrder_Preferred")
end
-- the player wants to change modes, for example from ITG to FA+
elseif focus.kind == "ChangeMode" then
SL.Global.GameMode = focus.change
for player in ivalues(GAMESTATE:GetHumanPlayers()) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ return {
end

local toptext = self.kind ~= "" and THEME:GetString("ScreenSelectMusic", self.kind) or ""
local bottomtext = THEME:GetString(self.kind == "ChangeMode" and "ScreenSelectPlayMode" or "ScreenSelectMusic", info[2])
local bottomtext = self.kind == "Playlist" and info[2] or THEME:GetString(self.kind == "ChangeMode" and "ScreenSelectPlayMode" or "ScreenSelectMusic", info[2])

self.top_text:settext(toptext)
self.bottom_text:settext(bottomtext)
Expand Down
56 changes: 47 additions & 9 deletions BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,35 @@ local function AddPlayerSortOptions()
local player_sort_options = {}
for player in ivalues(GAMESTATE:GetHumanPlayers()) do
if PROFILEMAN:IsPersistentProfile(player) then
SM("Adding player sort options")
table.insert(player_sort_options, {"SortBy", "Top" .. ToEnumShortString(player) .. "Grades"})
table.insert(player_sort_options, {"SortBy", "Recent" .. ToEnumShortString(player) .. "Played"})
end
end
return player_sort_options
end

local function AddPlaylists()
local player_sort_options = {}
-- Get the name of every file in the Other/Playlists directory
local files = FILEMAN:GetDirListing(THEME:GetCurrentThemeDirectory().."Other/Playlists/")
-- Add each file to the wheel options
for i=1, #files do
local file = files[i]
if file:match("%.txt$") then
local playlist = file:gsub("%.txt$", "")
table.insert(player_sort_options, {{"Playlist", playlist}})
end
end

for player in ivalues(GAMESTATE:GetHumanPlayers()) do
local path = getFavoritesPath(player)
if FILEMAN:DoesFileExist(path) then
table.insert(player_sort_options, {{"MixTape", "Preferred"}})
break
end
end

return player_sort_options
end
local function GetChangeableStyles(style)
local available_styles = {}
-- Allow players to switch from single to double and from double to single
Expand Down Expand Up @@ -245,7 +266,8 @@ local wheel_options = {
-- Conditions:
-- These determine whether or not the option will be displayed.
-- For instance: { {"SortBy", "Group"}, GAMESTATE:IsCourseMode() } will only display the Group option in CourseMode.
-- You can use any Lua expression that returns a boolean value here.
-- You can use any Lua expression that equates to a boolean value here.
-- Alternatively, you may provide a function that returns a boolean value for more complex and timely conditions.

-- Submenus:
-- We can create categories within the SortMenu by providing a table as the second element
Expand Down Expand Up @@ -274,9 +296,9 @@ local wheel_options = {
{"", "CategoryAdvanced"},
{
{ {"FeelingSalty", "TestInput"}, GAMESTATE:IsEventMode() },
{ {"HardTime", "PracticeMode"}, GAMESTATE:IsEventMode() and GAMESTATE:GetCurrentSong() ~= nil and ThemePrefs.Get("KeyboardFeatures")},
{ {"HardTime", "PracticeMode"}, function() return GAMESTATE:IsEventMode() and GAMESTATE:GetCurrentSong() ~= nil and ThemePrefs.Get("KeyboardFeatures") end },
{ {"TakeABreather", "LoadNewSongs"} },
{ {"NeedMoreRam", "ViewDownloads"}, DownloadsExist() },
{ {"NeedMoreRam", "ViewDownloads"}, DownloadsExist },
{ {"WhereforeArtThou", "SongSearch"}, not GAMESTATE:IsCourseMode() and ThemePrefs.Get("KeyboardFeatures") },
{ {"NextPlease", "SwitchProfile"}, ThemePrefs.Get("AllowScreenSelectProfile") },
{ {"SetSummaryText", "SetSummary"}, SL.Global.Stages.PlayedThisGame > 0 },
Expand All @@ -288,6 +310,10 @@ local wheel_options = {
GetChangeableStyles(style),
}
},
{
{"", "CategoryPlaylists"},
AddPlaylists()
},
{ {"SortBy", "Group"} },
{ {"SortBy", "Title"} },
{ {"SortBy", "Recent"} },
Expand All @@ -299,9 +325,9 @@ local wheel_options = {
-- It's technically not possible to reach the sort menu in Casual Mode, but juuust in case let's still
-- include the check.
{ {"ChangeMode", "Casual"}, SL.Global.Stages.PlayedThisGame == 0 and SL.Global.GameMode ~= "Casual" },
{ {"ImLovinIt", "AddFavorite"}, GAMESTATE:GetCurrentSong() ~= nil },
{ {"ImLovinIt", "AddFavorite"}, function() return GAMESTATE:GetCurrentSong() ~= nil end},
AddFavorites(),
{ {"GrooveStats", "Leaderboard"}, IsServiceAllowed(SL.GrooveStats.Leaderboard) and GAMESTATE:GetCurrentSong() ~= nil },
{ {"GrooveStats", "Leaderboard"}, function() return IsServiceAllowed(SL.GrooveStats.Leaderboard) and GAMESTATE:GetCurrentSong() ~= nil end },
}


Expand Down Expand Up @@ -331,7 +357,11 @@ local t = Def.ActorFrame {
local sub_options = {}
for j=1, #option[2] do
local sub_option = option[2][j]
if sub_option[2] == nil or sub_option[2] == true then
if type(sub_option[2]) == "function" then
if sub_option[2]() then
table.insert(filtered_wheel_options, sub_option[1])
end
elseif sub_option[2] == nil or sub_option[2] == true then
table.insert(filtered_wheel_options, sub_option[1])
end
end
Expand Down Expand Up @@ -428,13 +458,21 @@ local t = Def.ActorFrame {
local sub_options = {}
for j=1, #option[2] do
local sub_option = option[2][j]
if sub_option[2] == nil or sub_option[2] == true then
if type(sub_option[2]) == "function" then
if sub_option[2]() then
table.insert(sub_options, sub_option)
end
elseif sub_option[2] == nil or sub_option[2] == true then
table.insert(sub_options, sub_option)
end
end
if #sub_options > 0 then
table.insert(filtered_wheel_options, {option[1][1], option[1][2]})
end
elseif type(option[2]) == "function" then
if option[2]() then
table.insert(filtered_wheel_options, {option[1][1], option[1][2]})
end
elseif option[2] == nil or option[2] == true then
table.insert(filtered_wheel_options, {option[1][1], option[1][2]})
end
Expand Down
2 changes: 2 additions & 0 deletions Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ CategorySorts=Sorts...
#CategoryModes=Modes...
CategoryStyles=Styles...
CategoryAdvanced=Options...
CategoryPlaylists=Playlists...
Playlist=Playlist

# SortMenu choices
# SortMenu "Sort By" choices
Expand Down