Simplify, so I don't have to wrap every call to Mode.
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
void ArrowBackdrop::BeginDraw()
|
||||
{
|
||||
BGAnimation::BeginDraw();
|
||||
GAMESTATE->m_Position->BeginDrawBackdrop(m_PlayerNumber);
|
||||
g_NoteFieldMode[m_PlayerNumber].BeginDrawTrack(-1);
|
||||
}
|
||||
|
||||
void ArrowBackdrop::EndDraw()
|
||||
{
|
||||
GAMESTATE->m_Position->EndDrawBackdrop(m_PlayerNumber);
|
||||
g_NoteFieldMode[m_PlayerNumber].EndDrawTrack(-1);
|
||||
BGAnimation::EndDraw();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void GhostArrowRow::DrawPrimitives()
|
||||
{
|
||||
for( int c=0; c<m_iNumCols; c++ )
|
||||
{
|
||||
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].BeginDrawTrack(c);
|
||||
|
||||
float fX = ArrowGetXPos( m_PlayerNumber, c, 0 );
|
||||
m_GhostArrowRow[c].SetX( fX );
|
||||
@@ -73,7 +73,7 @@ void GhostArrowRow::DrawPrimitives()
|
||||
m_GhostArrowRowBright[c].Draw();
|
||||
m_HoldGhostArrowRow[c].Draw();
|
||||
|
||||
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].EndDrawTrack(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,14 +59,14 @@ void GrayArrowRow::DrawPrimitives()
|
||||
{
|
||||
for( int c=0; c<m_iNumCols; c++ )
|
||||
{
|
||||
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].BeginDrawTrack(c);
|
||||
|
||||
// set arrow X
|
||||
float fX = ArrowGetXPos( m_PlayerNumber, c, 0 );
|
||||
m_GrayArrow[c].SetX( fX );
|
||||
m_GrayArrow[c].Draw();
|
||||
|
||||
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].EndDrawTrack(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ void NoteField::DrawPrimitives()
|
||||
|
||||
for( int c=0; c<GetNumTracks(); c++ ) // for each arrow column
|
||||
{
|
||||
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].BeginDrawTrack(c);
|
||||
|
||||
/////////////////////////////////
|
||||
// Draw all HoldNotes in this column (so that they appear under the tap notes)
|
||||
@@ -414,7 +414,7 @@ void NoteField::DrawPrimitives()
|
||||
m_NoteDisplay[c].DrawTap( c, NoteRowToBeat(i), bHoldNoteBeginsOnThisBeat, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail );
|
||||
}
|
||||
|
||||
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
|
||||
g_NoteFieldMode[m_PlayerNumber].EndDrawTrack(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,14 +13,19 @@
|
||||
#include "Style.h"
|
||||
#include "GameDef.h"
|
||||
|
||||
/* Copies of the current mode. Update this by calling Load. */
|
||||
NoteFieldMode g_NoteFieldMode[NUM_PLAYERS];
|
||||
|
||||
NoteFieldPositioning::Mode::Mode()
|
||||
NoteFieldMode::NoteFieldMode()
|
||||
{
|
||||
m_fFov = 0;
|
||||
m_fFirstPixelToDrawScale = m_fLastPixelToDrawScale = 1.0f;
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::Mode::BeginDrawTrack(int tn)
|
||||
void NoteFieldMode::BeginDrawTrack(int tn)
|
||||
{
|
||||
DISPLAY->PushMatrix();
|
||||
|
||||
/* It's useful to be able to use Actors like this, functioning only
|
||||
* for a transformation. However, this is a big waste of matrix
|
||||
* stack space, as each of these will push. Profile this. XXX */
|
||||
@@ -38,7 +43,7 @@ void NoteFieldPositioning::Mode::BeginDrawTrack(int tn)
|
||||
m_PositionTrack[tn].BeginDraw();
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::Mode::EndDrawTrack(int tn)
|
||||
void NoteFieldMode::EndDrawTrack(int tn)
|
||||
{
|
||||
if(tn == -1)
|
||||
m_PositionBackdrop.EndDraw();
|
||||
@@ -52,6 +57,8 @@ void NoteFieldPositioning::Mode::EndDrawTrack(int tn)
|
||||
if(tn != -1)
|
||||
m_CenterTrack[tn].EndDraw();
|
||||
m_Center.EndDraw();
|
||||
|
||||
DISPLAY->PopMatrix();
|
||||
}
|
||||
|
||||
NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
||||
@@ -62,7 +69,7 @@ NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
||||
|
||||
for(IniFile::const_iterator i = ini.begin(); i != ini.end(); ++i)
|
||||
{
|
||||
Mode m;
|
||||
NoteFieldMode m;
|
||||
|
||||
const IniFile::key &k = i->second;
|
||||
IniFile::key::const_iterator val;
|
||||
@@ -126,7 +133,7 @@ NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
||||
}
|
||||
}
|
||||
|
||||
bool NoteFieldPositioning::Mode::MatchesCurrentGame() const
|
||||
bool NoteFieldMode::MatchesCurrentGame() const
|
||||
{
|
||||
if(Styles.empty())
|
||||
return true;
|
||||
@@ -137,6 +144,31 @@ bool NoteFieldPositioning::Mode::MatchesCurrentGame() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::Load(PlayerNumber pn)
|
||||
{
|
||||
NoteFieldMode &mode = g_NoteFieldMode[pn];
|
||||
const int ModeNum = GetID(GAMESTATE->m_PlayerOptions[pn].m_sPositioning);
|
||||
if(ModeNum != -1)
|
||||
{
|
||||
/* We have a custom mode; copy it. */
|
||||
mode = Modes[ModeNum];
|
||||
return;
|
||||
}
|
||||
|
||||
/* No transformation is enabled, so use the one defined in the style
|
||||
* table. */
|
||||
mode = NoteFieldMode(); /* reset */
|
||||
|
||||
const StyleDef *s = GAMESTATE->GetCurrentStyleDef();
|
||||
|
||||
/* Set the m_PositionTrack[] value for each track. */
|
||||
for(int tn = 0; tn < MAX_NOTE_TRACKS; ++tn)
|
||||
{
|
||||
const float fPixelXOffsetFromCenter = s->m_ColumnInfo[pn][tn].fXOffset;
|
||||
mode.m_PositionTrack[tn].SetX(fPixelXOffsetFromCenter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get the unique ID of the given name, for the current game/style. If it
|
||||
* doesn't exist, return "". */
|
||||
@@ -156,11 +188,6 @@ int NoteFieldPositioning::GetID(const CString &name) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
int NoteFieldPositioning::GetID(PlayerNumber pn) const
|
||||
{
|
||||
return GetID(GAMESTATE->m_PlayerOptions[pn].m_sPositioning);
|
||||
}
|
||||
|
||||
|
||||
/* Get all arrow modifier names for the current game. */
|
||||
void NoteFieldPositioning::GetNamesForCurrentGame(vector<CString> &IDs)
|
||||
@@ -174,61 +201,3 @@ void NoteFieldPositioning::GetNamesForCurrentGame(vector<CString> &IDs)
|
||||
IDs.push_back(Modes[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: Lots of GetID calls, which do a bunch of string compares; profile this. */
|
||||
CString NoteFieldPositioning::GetBackdropBGA(PlayerNumber pn) const
|
||||
{
|
||||
const int mode = GetID(pn);
|
||||
if(mode == -1)
|
||||
return ""; /* none */
|
||||
LOG->Trace("bd %s", Modes[mode].Backdrop.c_str() );
|
||||
return Modes[mode].Backdrop;
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::BeginDrawBackdrop(PlayerNumber pn)
|
||||
{
|
||||
const int mode = GetID(pn);
|
||||
if(mode == -1)
|
||||
return;
|
||||
|
||||
DISPLAY->PushMatrix();
|
||||
Modes[mode].BeginDrawTrack(-1);
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::EndDrawBackdrop(PlayerNumber pn)
|
||||
{
|
||||
const int mode = GetID(pn);
|
||||
if(mode == -1)
|
||||
return;
|
||||
|
||||
Modes[mode].EndDrawTrack(-1);
|
||||
DISPLAY->PopMatrix();
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn)
|
||||
{
|
||||
const int mode = GetID(pn);
|
||||
|
||||
DISPLAY->PushMatrix();
|
||||
|
||||
if(mode == -1)
|
||||
{
|
||||
/* No transformation is enabled, so use the one defined in the style
|
||||
* table. */
|
||||
const StyleDef *s = GAMESTATE->GetCurrentStyleDef();
|
||||
const float fPixelXOffsetFromCenter = s->m_ColumnInfo[pn][tn].fXOffset;
|
||||
DISPLAY->Translate(fPixelXOffsetFromCenter, 0, 0);
|
||||
} else {
|
||||
Modes[mode].BeginDrawTrack(tn);
|
||||
}
|
||||
}
|
||||
|
||||
void NoteFieldPositioning::EndDrawTrack(PlayerNumber pn, int tn)
|
||||
{
|
||||
const int mode = GetID(pn);
|
||||
|
||||
if(mode != -1)
|
||||
Modes[mode].EndDrawTrack(tn);
|
||||
|
||||
DISPLAY->PopMatrix();
|
||||
}
|
||||
|
||||
@@ -9,49 +9,43 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
class NoteFieldPositioning
|
||||
struct NoteFieldMode
|
||||
{
|
||||
struct Mode
|
||||
{
|
||||
Mode();
|
||||
bool MatchesCurrentGame() const;
|
||||
NoteFieldMode();
|
||||
bool MatchesCurrentGame() const;
|
||||
|
||||
void BeginDrawTrack(int tn);
|
||||
void EndDrawTrack(int tn);
|
||||
void BeginDrawTrack(int tn);
|
||||
void EndDrawTrack(int tn);
|
||||
|
||||
CString name;
|
||||
set<Style> Styles;
|
||||
CString name;
|
||||
set<Style> Styles;
|
||||
|
||||
Actor m_Center;
|
||||
Actor m_CenterTrack[MAX_NOTE_TRACKS];
|
||||
Actor m_Center;
|
||||
Actor m_CenterTrack[MAX_NOTE_TRACKS];
|
||||
|
||||
/* 0 = no perspective */
|
||||
float m_fFov;
|
||||
Actor m_Position;
|
||||
Actor m_PositionTrack[MAX_NOTE_TRACKS];
|
||||
/* 0 = no perspective */
|
||||
float m_fFov;
|
||||
Actor m_Position;
|
||||
Actor m_PositionTrack[MAX_NOTE_TRACKS];
|
||||
|
||||
CString Backdrop;
|
||||
Actor m_PositionBackdrop;
|
||||
};
|
||||
|
||||
vector<Mode> Modes;
|
||||
|
||||
public:
|
||||
NoteFieldPositioning(CString fn);
|
||||
|
||||
/* Get the mode number for the given positioning type (for the current
|
||||
* game and style). */
|
||||
int GetID(const CString &name) const;
|
||||
int GetID(PlayerNumber pn) const;
|
||||
|
||||
void BeginDrawTrack(PlayerNumber pn, int tn);
|
||||
void EndDrawTrack(PlayerNumber pn, int tn);
|
||||
|
||||
CString GetBackdropBGA(PlayerNumber pn) const;
|
||||
void BeginDrawBackdrop(PlayerNumber pn);
|
||||
void EndDrawBackdrop(PlayerNumber pn);
|
||||
|
||||
void GetNamesForCurrentGame(vector<CString> &IDs);
|
||||
float m_fFirstPixelToDrawScale, m_fLastPixelToDrawScale;
|
||||
CString Backdrop;
|
||||
Actor m_PositionBackdrop;
|
||||
};
|
||||
|
||||
class NoteFieldPositioning
|
||||
{
|
||||
public:
|
||||
NoteFieldPositioning(CString fn);
|
||||
void Load(PlayerNumber pn);
|
||||
|
||||
void GetNamesForCurrentGame(vector<CString> &IDs);
|
||||
|
||||
private:
|
||||
vector<NoteFieldMode> Modes;
|
||||
int GetID(const CString &name) const;
|
||||
};
|
||||
|
||||
extern NoteFieldMode g_NoteFieldMode[NUM_PLAYERS];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,9 @@ void Player::Load( PlayerNumber pn, NoteData* pNoteData, LifeMeter* pLM, ScoreDi
|
||||
m_pInventory = pInventory;
|
||||
m_pScoreKeeper = pScoreKeeper;
|
||||
|
||||
/* Ensure that this is up-to-date. */
|
||||
GAMESTATE->m_Position->Load(pn);
|
||||
|
||||
const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef();
|
||||
|
||||
// init scoring
|
||||
@@ -136,7 +139,7 @@ void Player::Load( PlayerNumber pn, NoteData* pNoteData, LifeMeter* pLM, ScoreDi
|
||||
int iStopDrawingAtPixels = GAMESTATE->m_bEditing ? 400 : STOP_DRAWING_AT_PIXELS;
|
||||
|
||||
m_ArrowBackdrop.Unload();
|
||||
CString BackdropName = GAMESTATE->m_Position->GetBackdropBGA(pn);
|
||||
CString BackdropName = g_NoteFieldMode[pn].Backdrop;
|
||||
if( !BackdropName.empty() )
|
||||
m_ArrowBackdrop.LoadFromAniDir( THEME->GetPathToB( BackdropName ) );
|
||||
m_NoteField.Load( (NoteData*)this, pn, iStartDrawingAtPixels, iStopDrawingAtPixels );
|
||||
|
||||
Reference in New Issue
Block a user