Skip to content

Commit

Permalink
finish adding wiferecord functions and make combo graph display curre…
Browse files Browse the repository at this point in the history
…nt wife% over time (for now)
  • Loading branch information
MinaciousGrace committed May 3, 2017
1 parent 4eaa892 commit 859116f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GraphDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void GraphDisplay::Set( const StageStats &ss, const PlayerStageStats &pss )
float fTotalStepSeconds = ss.GetTotalPossibleStepsSeconds();

m_Values.resize( VALUE_RESOLUTION );
pss.GetLifeRecord( &m_Values[0], VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() );
pss.GetWifeRecord( &m_Values[0], VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() );
for( unsigned i=0; i<ARRAYLEN(m_Values); i++ )
CLAMP( m_Values[i], 0.f, 1.f );

Expand Down
11 changes: 11 additions & 0 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void Player::Init(
{
float fLife = m_pLifeMeter->GetLife();
m_pPlayerStageStats->SetLifeRecordAt( fLife, STATSMAN->m_CurStageStats.m_fStepsSeconds );
m_pPlayerStageStats->SetWifeRecordAt( 0.f, STATSMAN->m_CurStageStats.m_fStepsSeconds);
}

// TODO: Remove use of PlayerNumber.
Expand Down Expand Up @@ -1671,6 +1672,7 @@ void Player::ChangeLife( TapNoteScore tns )
m_pCombinedLifeMeter->ChangeLife( pn, tns );

ChangeLifeRecord();
ChangeWifeRecord();

switch( tns )
{
Expand All @@ -1695,6 +1697,7 @@ void Player::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
m_pCombinedLifeMeter->ChangeLife( pn, hns, tns );

ChangeLifeRecord();
ChangeWifeRecord();
}

void Player::ChangeLife(float delta)
Expand All @@ -1714,6 +1717,7 @@ void Player::ChangeLife(float delta)
m_pCombinedLifeMeter->ChangeLife(pn, delta);
}
ChangeLifeRecord();
ChangeWifeRecord();
}

void Player::SetLife(float value)
Expand All @@ -1733,6 +1737,7 @@ void Player::SetLife(float value)
m_pCombinedLifeMeter->SetLife(pn, value);
}
ChangeLifeRecord();
ChangeWifeRecord();
}

void Player::ChangeLifeRecord()
Expand All @@ -1754,6 +1759,12 @@ void Player::ChangeLifeRecord()
m_pPlayerStageStats->SetLifeRecordAt( fLife, STATSMAN->m_CurStageStats.m_fStepsSeconds );
}

// seemsgood
void Player::ChangeWifeRecord() {
if (m_pPlayerStageStats)
m_pPlayerStageStats->SetLifeRecordAt(curwifescore / maxwifescore, STATSMAN->m_CurStageStats.m_fStepsSeconds);
}

int Player::GetClosestNoteDirectional( int col, int iStartRow, int iEndRow, bool bAllowGraded, bool bForward ) const
{
NoteData::const_iterator begin, end;
Expand Down
2 changes: 2 additions & 0 deletions src/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class Player: public ActorFrame
void ChangeLife( HoldNoteScore hns, TapNoteScore tns );
void ChangeLifeRecord();

void ChangeWifeRecord();

int GetClosestNoteDirectional( int col, int iStartRow, int iMaxRowsAhead, bool bAllowGraded, bool bForward ) const;
int GetClosestNote( int col, int iNoteRow, int iMaxRowsAhead, int iMaxRowsBehind, bool bAllowGraded ) const;
int GetClosestNonEmptyRowDirectional( int iStartRow, int iMaxRowsAhead, bool bAllowGraded, bool bForward ) const;
Expand Down
26 changes: 26 additions & 0 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,31 @@ class LunaPlayerStageStats: public Luna<PlayerStageStats>
return 1;
}

static int GetWifeRecord(T* p, lua_State *L)
{
float last_second = FArg(1);
int samples = 100;
if (lua_gettop(L) >= 2 && !lua_isnil(L, 2))
{
samples = IArg(2);
if (samples <= 0)
{
LOG->Trace("PlayerStageStats:GetLifeRecord requires an integer greater than 0. Defaulting to 100.");
samples = 100;
}
}
lua_createtable(L, samples, 0);
for (int i = 0; i < samples; ++i)
{
// The scale from range is [0, samples-1] because that is i's range.
float from = SCALE(i, 0, static_cast<float>(samples) - 1.0f, 0.0f, last_second);
float curr = p->GetLifeRecordLerpAt(from);
lua_pushnumber(L, curr);
lua_rawseti(L, -2, i + 1);
}
return 1;
}

static int GetRadarPossible( T* p, lua_State *L ) { p->m_radarPossible.PushSelf(L); return 1; }
static int GetRadarActual( T* p, lua_State *L ) { p->m_radarActual.PushSelf(L); return 1; }
static int SetScore( T* p, lua_State *L )
Expand Down Expand Up @@ -1058,6 +1083,7 @@ class LunaPlayerStageStats: public Luna<PlayerStageStats>
ADD_METHOD( GetPossibleSteps );
ADD_METHOD( GetComboList );
ADD_METHOD( GetLifeRecord );
ADD_METHOD( GetWifeRecord );
ADD_METHOD( GetAliveSeconds );
ADD_METHOD( GetPercentageOfTaps );
ADD_METHOD( GetTotalTaps );
Expand Down

0 comments on commit 859116f

Please sign in to comment.