Skip to content

Commit

Permalink
Save profile after playlist changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Mar 27, 2018
1 parent 97a0b5a commit 27ac631
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,18 @@ int SongManager::GetSongRank(Song* pSong)
const int index = FindIndex( m_pPopularSongs.begin(), m_pPopularSongs.end(), pSong );
return index; // -1 means we didn't find it
}

void makePlaylist(const RString& answer)
{
Playlist pl;
pl.name = answer;
if (pl.name != "") {
SONGMAN->GetPlaylists().emplace(pl.name, pl);
SONGMAN->activeplaylist = pl.name;
Message msg("DisplayAll");
MESSAGEMAN->Broadcast(msg);
PROFILEMAN->SaveProfile(PLAYER_1);
}
}
// lua start
#include "LuaBinding.h"

Expand Down Expand Up @@ -1487,7 +1498,7 @@ class LunaSongManager : public Luna<SongManager>

static int NewPlaylist(T* p, lua_State *L)
{
ScreenTextEntry::TextEntry(SM_BackFromNamePlaylist, "Name Playlist", "", 128);
ScreenTextEntry::TextEntry(SM_None, "Name Playlist", "", 128, nullptr, makePlaylist);
return 1;
}

Expand All @@ -1507,6 +1518,7 @@ class LunaSongManager : public Luna<SongManager>
static int DeletePlaylist(T* p, lua_State *L)
{
p->DeletePlaylist(SArg(1));
PROFILEMAN->SaveProfile(PLAYER_1);
return 1;
}

Expand Down Expand Up @@ -1595,12 +1607,14 @@ class LunaPlaylist : public Luna<Playlist>
static int AddChart(T* p, lua_State *L)
{
p->AddChart(SArg(1));
PROFILEMAN->SaveProfile(PLAYER_1);
return 1;
}

static int DeleteChart(T* p, lua_State *L)
{
p->DeleteChart(IArg(1) - 1);
PROFILEMAN->SaveProfile(PLAYER_1);
return 1;
}

Expand Down Expand Up @@ -1638,6 +1652,7 @@ class LunaChart : public Luna<Chart>
{
p->rate += FArg(1);
CLAMP(p->rate, 0.7f, 3.f);
PROFILEMAN->SaveProfile(PLAYER_1);
return 1;
}

Expand Down

0 comments on commit 27ac631

Please sign in to comment.