Skip to content

Commit

Permalink
hack in course play for playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 15, 2017
1 parent eb655c0 commit 8bf3b3d
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function scoreBoard(pn,position)
t[#t+1] = LoadFont("Common Large")..{
InitCommand=cmd(xy,frameWidth+frameX,frameY+32;zoom,0.5;halign,1;valign,0;maxwidth,200),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
Se2tCommand=function(self)
local meter = score:GetSkillsetSSR("Overall")
self:settextf("%5.2f", meter)
self:diffuse(ByMSD(meter))
Expand Down Expand Up @@ -213,7 +213,7 @@ function scoreBoard(pn,position)
t[#t+1] = LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX+40,frameY*2.49;zoom,0.25;halign,0),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
Se2tCommand=function(self)
if score:GetChordCohesion() == true then
self:settext("Chord Cohesion: Yes")
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,10 @@ local t = Def.ActorFrame{
}

-- Stuff you probably shouldn't turn off, music rate string display
t[#t+1] = LoadFont("Common Normal")..{InitCommand=cmd(xy,SCREEN_CENTER_X,SCREEN_BOTTOM-10;zoom,0.35;settext,getCurRateDisplayString())}
t[#t+1] = LoadFont("Common Normal")..{
InitCommand=cmd(xy,SCREEN_CENTER_X,SCREEN_BOTTOM-10;zoom,0.35;settext,getCurRateDisplayString()),
DoneLoadingNextSongMessageCommand=cmd(settext,getCurRateDisplayString())
}



Expand Down Expand Up @@ -978,12 +981,18 @@ local p = Def.ActorFrame{
},
LoadFont("Common Normal")..{ -- title
InitCommand=cmd(zoom,0.35;maxwidth,width*2),
BeginCommand=cmd(settext,GAMESTATE:GetCurrentSong():GetDisplayMainTitle())
BeginCommand=cmd(settext,GAMESTATE:GetCurrentSong():GetDisplayMainTitle()),
DoneLoadingNextSongMessageCommand=cmd(settext,GAMESTATE:GetCurrentSong():GetDisplayMainTitle())
},
LoadFont("Common Normal")..{ -- total time
InitCommand=cmd(x,width/2;zoom,0.35;maxwidth,width*2;halign,1),
BeginCommand=function(self)
local ttime = GetPlayableTime()
local ttime = GetPlayableTime()
settext(self,SecondsToMMSS(ttime))
diffuse(self, ByMusicLength(ttime))
end,
DoneLoadingNextSongMessageCommand=function(self)
local ttime = GetPlayableTime()
settext(self,SecondsToMMSS(ttime))
diffuse(self, ByMusicLength(ttime))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ b2[#b2+1] = Def.Quad{
InitCommand=cmd(diffusealpha,buttondiffuse;zoomto,110,20),
MouseLeftClickMessageCommand=function(self)
if ButtonActive(self,0.3) and singleplaylistactive then
pl:PlayAsCourse()
end
end
}
Expand Down
6 changes: 6 additions & 0 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,18 @@ void Player::Load()
for (int i = 0; i <= lastRow; i++)
etarD.push_back(m_Timing->GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(i)));
m_Timing->SetElapsedTimesAtAllRows(etarD);

totalwifescore = m_NoteData.WifeTotalScoreCalc(m_Timing, 0, 1073741824);
curwifescore = 0.f;
maxwifescore = 0.f;

m_NoteData.LogNonEmptyRows();
nerv = m_NoteData.GetNonEmptyRowVector();
vector<float> etaner = m_Timing->BuildAndGetEtaner(nerv);
m_pPlayerStageStats->serializednd = m_NoteData.SerializeNoteData(etaner);



Profile *pProfile = PROFILEMAN->GetProfile(pn);
HighScore* pb = SCOREMAN->GetChartPBAt(GAMESTATE->m_pCurSteps[pn]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
if (pb)
Expand Down
4 changes: 2 additions & 2 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void PlayerStageStats::InternalInit()
m_iPossibleDancePoints = 0;
m_iCurPossibleDancePoints = 0;
m_iActualDancePoints = 0;
m_fWifeScore = 0;
m_fTimingScale = 0;
m_fWifeScore = 0.f;
m_fTimingScale = 0.f;
m_vOffsetVector.clear();
m_vNoteRowVector.clear();
m_iPossibleGradePoints = 0;
Expand Down
41 changes: 35 additions & 6 deletions src/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,11 @@ void ScreenGameplay::Init()
if(LuaHelpers::RunScriptOnStack(L, err, 2, 3, true))
{
RString marge= "Margin value must be a number.";
margins[PLAYER_1][0]= SafeFArg(L, -3, marge, 40);
float center= SafeFArg(L, -2, marge, 80);
margins[PLAYER_1][0]= static_cast<float>(SafeFArg(L, -3, marge, 40));
float center= static_cast<float>(SafeFArg(L, -2, marge, 80));
margins[PLAYER_1][1]= center / 2.0f;
margins[PLAYER_2][0]= center / 2.0f;
margins[PLAYER_2][1]= SafeFArg(L, -1, marge, 40);
margins[PLAYER_2][1]= static_cast<float>(SafeFArg(L, -1, marge, 40));
}
lua_settop(L, 0);
LUA->Release(L);
Expand Down Expand Up @@ -817,6 +817,18 @@ void ScreenGameplay::InitSongQueues()
const PlayerOptions &p = pi->GetPlayerState()->m_PlayerOptions.GetCurrent();
}

if (SONGMAN->playlistcourse != "") {
Playlist& pl = SONGMAN->allplaylists[SONGMAN->playlistcourse];
FOREACH(Chart, pl.chartlist, ch) {
m_apSongsQueue.emplace_back(ch->songptr);
FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi)
{
pi->m_vpStepsQueue.emplace_back(ch->stepsptr);
ratesqueue.emplace_back(ch->rate);
}
}
}

if (GAMESTATE->m_bMultiplayer)
{
for (int i = 0; i<static_cast<int>(m_apSongsQueue.size()); i++)
Expand Down Expand Up @@ -2216,6 +2228,7 @@ void ScreenGameplay::SaveStats()

void ScreenGameplay::SongFinished()
{

FOREACH_EnabledPlayer(pn)
{
if(GAMESTATE->m_pCurSteps[pn])
Expand All @@ -2228,7 +2241,7 @@ void ScreenGameplay::SongFinished()
}

void ScreenGameplay::StageFinished( bool bBackedOut )
{
{
if( bBackedOut )
{
GAMESTATE->CancelStage();
Expand All @@ -2245,7 +2258,6 @@ void ScreenGameplay::StageFinished( bool bBackedOut )
FOREACH_HumanPlayer( pn )
STATSMAN->m_CurStageStats.m_player[pn].CalcAwards( pn, STATSMAN->m_CurStageStats.m_bGaveUp, STATSMAN->m_CurStageStats.m_bUsedAutoplay );
STATSMAN->m_CurStageStats.FinalizeScores( false );

GAMESTATE->CommitStageStats();

// save current stage stats
Expand Down Expand Up @@ -2346,13 +2358,30 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
/* If all players have *really* failed (bFailed, not the life meter or
* bFailedEarlier): */
const bool bAllReallyFailed = STATSMAN->m_CurStageStats.AllFailed();
const bool bIsLastSong = true;
const bool bIsLastSong = m_apSongsQueue.size() == 1;

LOG->Trace( "bAllReallyFailed = %d "
"bIsLastSong = %d, m_gave_up = %d, m_skipped_song = %d",
bAllReallyFailed, bIsLastSong, m_gave_up,
m_skipped_song);

if (m_apSongsQueue.size() > 1) {
m_apSongsQueue.erase(m_apSongsQueue.begin(), m_apSongsQueue.begin() + 1);

FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi)
pi->m_vpStepsQueue.erase(pi->m_vpStepsQueue.begin(), pi->m_vpStepsQueue.begin() + 1);
ratesqueue.erase(ratesqueue.begin(), ratesqueue.begin() + 1);

GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = ratesqueue[0];
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = ratesqueue[0];
GAMESTATE->m_SongOptions.GetStage().m_fMusicRate = ratesqueue[0];
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = ratesqueue[0];

this->StageFinished(false);
STATSMAN->m_CurStageStats.m_player[PLAYER_1].InternalInit();
}


if(!bIsLastSong && m_skipped_song)
{
// Load the next song in the course.
Expand Down
1 change: 1 addition & 0 deletions src/ScreenGameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class ScreenGameplay : public ScreenWithMenuElements
*
* The size can be greater than 1 if playing a course. */
vector<Song*> m_apSongsQueue;
vector<float> ratesqueue;

float m_fTimeSinceLastDancingComment; // this counter is only running while STATE_DANCING

Expand Down
7 changes: 7 additions & 0 deletions src/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,12 @@ class LunaPlaylist : public Luna<Playlist>
MESSAGEMAN->Broadcast(msg);
return 1;
}

static int PlayAsCourse(T* p, lua_State *L)
{
SONGMAN->playlistcourse = p->name;
return 1;
}

DEFINE_METHOD(GetName, GetName());
DEFINE_METHOD(GetNumCharts, GetNumCharts())
Expand All @@ -1557,6 +1563,7 @@ class LunaPlaylist : public Luna<Playlist>
ADD_METHOD(GetSonglist);
ADD_METHOD(GetStepslist);
ADD_METHOD(ChangeRateAtIndex);
ADD_METHOD(PlayAsCourse);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/SongManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class SongManager

map<string, Playlist> allplaylists;
string activeplaylist;
string playlistcourse;
protected:
void LoadStepManiaSongDir( RString sDir, LoadingWindow *ld );
void LoadDWISongDir( const RString &sDir );
Expand Down
1 change: 1 addition & 0 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ void StageStats::FinalizeScores( bool bSummary )
// new score structure -mina
Profile* zzz = PROFILEMAN->GetProfile(PLAYER_1);
SCOREMAN->AddScore(hs);
LOG->Warn("added a scaore");
zzz->SetAnyAchievedGoals(GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate, hs);
}
}
Expand Down
36 changes: 0 additions & 36 deletions src/StatsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,42 +106,6 @@ void StatsManager::CalcAccumPlayedStageStats()
/* This data is added to each player profile, and to the machine profile per-player. */
void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNumber pn )
{
ss.AssertValid( pn );

StyleID sID;
sID.FromStyle( ss.m_player[pn].m_pStyle );

ASSERT( (int) ss.m_vpPlayedSongs.size() == ss.m_player[pn].m_iStepsPlayed );
for( int i=0; i<ss.m_player[pn].m_iStepsPlayed; i++ )
{
Steps *pSteps = ss.m_player[pn].m_vpPossibleSteps[i];

pProfile->m_iNumSongsPlayedByPlayMode[ss.m_playMode]++;
pProfile->m_iNumSongsPlayedByStyle[sID] ++;
pProfile->m_iNumSongsPlayedByDifficulty[pSteps->GetDifficulty()] ++;

int iMeter = clamp( pSteps->GetMeter(), 0, MAX_METER );
pProfile->m_iNumSongsPlayedByMeter[iMeter] ++;
}

pProfile->m_iTotalDancePoints += ss.m_player[pn].m_iActualDancePoints;

if( ss.m_Stage == Stage_Extra1 || ss.m_Stage == Stage_Extra2 )
{
if( ss.m_player[pn].m_bFailed )
++pProfile->m_iNumExtraStagesFailed;
else
++pProfile->m_iNumExtraStagesPassed;
}

// If you fail in a course, you passed all but the final song.
// FIXME: Not true. If playing with 2 players, one player could have failed earlier.
if( !ss.m_player[pn].m_bFailed )
{
pProfile->m_iNumStagesPassedByPlayMode[ss.m_playMode] ++;
pProfile->m_iNumStagesPassedByGrade[ss.m_player[pn].GetGrade()] ++;
}

SCOREMAN->RecalculateSSRs();
SCOREMAN->CalcPlayerRating(pProfile->m_fPlayerRating, pProfile->m_fPlayerSkillsets);
}
Expand Down

0 comments on commit 8bf3b3d

Please sign in to comment.