From e207279e98c3f5f402d8a2ba248263302a6d3589 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 20 Nov 2017 10:04:59 +0200 Subject: [PATCH] Fix playlists lua errors and goals when goal songs arent loaded (#111) --- .../goaltracker.lua | 22 ++++++++++++++----- .../playlists.lua | 14 +++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua index d2a5b8e79d..0ee3a99f93 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua @@ -158,10 +158,14 @@ local function makescoregoal(i) ck = sg:GetChartKey() goalsong = SONGMAN:GetSongByChartKey(ck) goalsteps = SONGMAN:GetStepsByChartKey(ck) - - local diff = goalsteps:GetDifficulty() - self:settext(getShortDifficulty(diff)) - self:diffuse(byDifficulty(diff)) + if goalsteps and goalsong then + local diff = goalsteps:GetDifficulty() + self:settext(getShortDifficulty(diff)) + self:diffuse(byDifficulty(diff)) + else + self:settext("??") + self:diffuse(getMainColor('negative')) + end self:visible(true) else self:visible(false) @@ -179,7 +183,13 @@ local function makescoregoal(i) SetCommand=function(self) if update then if sg then - self:settextf(goalsong:GetDisplayMainTitle()) + if goalsong then + self:settextf(goalsong:GetDisplayMainTitle()) + self:diffuse(getMainColor('positive')) + else + self:settext("Song not found") + self:diffuse(getMainColor('negative')) + end self:visible(true) else self:visible(false) @@ -315,7 +325,7 @@ local function makescoregoal(i) end, SetCommand=function(self) if update then - if sg then + if sg and goalsteps then local msd = goalsteps:GetMSD(sg:GetRate(), 1) self:settextf("%5.1f", msd) self:diffuse(ByMSD(msd)) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua index 45b6def7e4..82a80b2628 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua @@ -605,8 +605,10 @@ local function PlaylistSelectLabel(i) self:xy(15,row2Yoffset) end, AllDisplayMessageCommand=function(self) - self:diffuse(getMainColor("positive")) - self:settextf("Number of charts: %d", allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetNumCharts()) + if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then + self:diffuse(getMainColor("positive")) + self:settextf("Number of charts: %d", allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetNumCharts()) + end end }, LoadFont("Common Large") .. { @@ -625,9 +627,11 @@ local function PlaylistSelectLabel(i) self:xy(295,row2Yoffset) end, AllDisplayMessageCommand=function(self) - local rating = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetAverageRating() - self:settextf("%.2f", rating) - self:diffuse(ByMSD(rating)) + if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then + local rating = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetAverageRating() + self:settextf("%.2f", rating) + self:diffuse(ByMSD(rating)) + end end }, }