modifer modes update

This commit is contained in:
Glenn Maynard
2003-04-10 08:49:25 +00:00
parent 476de3d690
commit abc65f828f
12 changed files with 193 additions and 107 deletions
+2 -6
View File
@@ -42,8 +42,7 @@ GameState::GameState()
GameState::~GameState()
{
for( int p=0; p<NUM_PLAYERS; p++ )
delete m_Position[p];
delete m_Position;
}
void GameState::Reset()
@@ -88,8 +87,7 @@ void GameState::Reset()
for( p=0; p<NUM_PLAYERS; p++ )
NOTESKIN->SwitchNoteSkin( PlayerNumber(p), PREFSMAN->m_sDefaultNoteSkin );
for( p=0; p<NUM_PLAYERS; p++ )
m_Position[p] = new NoteFieldPositioning;
m_Position = new NoteFieldPositioning("test.ini");
}
void GameState::Update( float fDelta )
@@ -98,8 +96,6 @@ void GameState::Update( float fDelta )
{
m_CurrentPlayerOptions[p].Approach( m_PlayerOptions[p], fDelta );
if(m_Position[p]) m_Position[p]->Update(fDelta);
m_bActiveAttackEndedThisUpdate[p] = false;
for( unsigned s=0; s<NUM_INVENTORY_SLOTS; s++ )
+1 -1
View File
@@ -193,7 +193,7 @@ public:
//
// Arrow positioning
//
NoteFieldPositioning *m_Position[NUM_PLAYERS];
NoteFieldPositioning *m_Position;
};
+2 -2
View File
@@ -62,7 +62,7 @@ void GhostArrowRow::DrawPrimitives()
{
for( int c=0; c<m_iNumCols; c++ )
{
GAMESTATE->m_Position[m_PlayerNumber]->BeginDrawTrack(c);
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, 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[m_PlayerNumber]->EndDrawTrack(c);
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
}
}
+2 -2
View File
@@ -59,14 +59,14 @@ void GrayArrowRow::DrawPrimitives()
{
for( int c=0; c<m_iNumCols; c++ )
{
GAMESTATE->m_Position[m_PlayerNumber]->BeginDrawTrack(c);
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, c);
// set arrow X
float fX = ArrowGetXPos( m_PlayerNumber, c, 0 );
m_GrayArrow[c].SetX( fX );
m_GrayArrow[c].Draw();
GAMESTATE->m_Position[m_PlayerNumber]->EndDrawTrack(c);
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
}
}
+2 -2
View File
@@ -336,7 +336,7 @@ void NoteField::DrawPrimitives()
for( int c=0; c<GetNumTracks(); c++ ) // for each arrow column
{
GAMESTATE->m_Position[m_PlayerNumber]->BeginDrawTrack(c);
GAMESTATE->m_Position->BeginDrawTrack(m_PlayerNumber, c);
/////////////////////////////////
// Draw all HoldNotes in this column (so that they appear under the tap notes)
@@ -404,7 +404,7 @@ void NoteField::DrawPrimitives()
m_NoteDisplay[c].DrawTap( c, NoteRowToBeat(i), bHoldNoteBeginsOnThisBeat, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail );
}
GAMESTATE->m_Position[m_PlayerNumber]->EndDrawTrack(c);
GAMESTATE->m_Position->EndDrawTrack(m_PlayerNumber, c);
}
}
+150 -71
View File
@@ -1,12 +1,20 @@
#include "global.h"
#include "NoteFieldPositioning.h"
#include "RageDisplay.h"
#include "RageDisplayInternal.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "RageMath.h"
#include "GameState.h"
#include "GameManager.h"
#include "IniFile.h"
#include "Game.h"
#include "Style.h"
#include "GameDef.h"
/* This is similar in style to Actor::Command. However, Actors don't store
* matrix stacks; they only store offsets and scales, and compound them into
* a single transformations at once. This makes some things easy, but it's not
@@ -83,16 +91,7 @@ void MatrixCommand(CString sCommandString, RageMatrix &mat)
}
NoteFieldPositioning::NoteFieldPositioning()
{
Init();
}
NoteFieldPositioning::~NoteFieldPositioning()
{
}
void NoteFieldPositioning::Init()
NoteFieldPositioning::Mode::Mode()
{
for( int tn=0; tn<MAX_NOTE_TRACKS; tn++ )
{
@@ -101,76 +100,156 @@ void NoteFieldPositioning::Init()
m_fFov[tn] = 0;
}
}
/*
void NoteFieldPositioning::LoadFromFile(CString fn)
void NoteFieldPositioning::Mode::BeginDrawTrack(int tn) const
{
Init();
}
*/
void NoteFieldPositioning::LoadFromStyleDef(const StyleDef *s, PlayerNumber pn)
{
Init();
for( int t=0; t<MAX_NOTE_TRACKS; t++ )
{
/* Set up the normal position of each track. */
const float fPixelXOffsetFromCenter = s->m_ColumnInfo[pn][t].fXOffset;
RageMatrixTranslation(&m_Position[t], fPixelXOffsetFromCenter, 0, 0);
}
// XXX
FILE *f = fopen("test.dat", "r");
if(f) for(int t = 0; t < MAX_NOTE_TRACKS; ++t)
{
char buf[1000];
if(!fgets(buf, 1000, f)) break;
CString b(buf);
TrimRight(b);
RageMatrixIdentity(&m_Position[t]);
MatrixCommand(b, m_Position[t]);
if(!fgets(buf, 1000, f)) break;
b=buf;
TrimRight(b);
RageMatrixIdentity(&m_PerspPosition[t]);
MatrixCommand(b, m_PerspPosition[t]);
if(!fgets(buf, 1000, f)) break;
sscanf(buf, "%f", &m_fFov[t]);
}
if( f )
fclose(f);
// XXX
}
void NoteFieldPositioning::Update(float fDeltaTime)
{
}
void NoteFieldPositioning::BeginDrawTrack(int tn)
{
DISPLAY->PushMatrix();
glMultMatrixf((float *) m_Position[tn]);
glMultMatrixf((const float *) m_Position[tn]);
if(m_fFov[tn])
DISPLAY->EnterPerspective(m_fFov[tn]);
glMultMatrixf((float *) m_PerspPosition[tn]);
glMultMatrixf((const float *) m_PerspPosition[tn]);
}
void NoteFieldPositioning::EndDrawTrack(int tn)
void NoteFieldPositioning::Mode::EndDrawTrack(int tn) const
{
if(m_fFov[tn])
DISPLAY->ExitPerspective();
}
NoteFieldPositioning::NoteFieldPositioning(CString fn)
{
IniFile ini(fn);
if(!ini.ReadFile())
return;
for(IniFile::const_iterator i = ini.begin(); i != ini.end(); ++i)
{
Mode m;
const IniFile::key &k = i->second;
for(int t = 0; t < MAX_NOTE_TRACKS; ++t)
{
IniFile::key::const_iterator val;
val = k.find("Name");
ASSERT(val != k.end()); /* required */
m.name = val->second;
val = k.find(ssprintf("Track%i", t+1));
if(val != k.end())
MatrixCommand(val->second, m.m_Position[t]);
val = k.find(ssprintf("PTrack%i", t+1));
if(val != k.end())
MatrixCommand(val->second, m.m_PerspPosition[t]);
val = k.find(ssprintf("FOV%i", t+1));
if(val != k.end())
m.m_fFov[t] = float(atof(val->second.c_str()));
CString sGames;
val = k.find("Games");
if(val != k.end())
{
vector<CString> games;
split(val->second, ",", games);
for(unsigned n = 0; n < games.size(); ++n)
{
vector<CString> bits;
split(games[n], "-", bits);
ASSERT(bits.size() == 2);
const Game game = GAMEMAN->StringToGameType( bits[0] );
ASSERT(game != GAME_INVALID);
const Style style = GAMEMAN->GameAndStringToStyle( game, bits[1] );
ASSERT(style != STYLE_INVALID);
m.Styles.insert(style );
}
}
}
Modes.push_back(m);
}
}
bool NoteFieldPositioning::Mode::MatchesCurrentGame() const
{
if(Styles.empty())
return true;
if(Styles.find(GAMESTATE->m_CurStyle) == Styles.end())
return false;
return true;
}
/* Get the unique ID of the given name, for the current game/style. If it
* doesn't exist, return "". */
int NoteFieldPositioning::GetID(const CString &name) const
{
LOG->Trace("look for %s", name.c_str());
for(unsigned i = 0; i < Modes.size(); ++i)
{
if(Modes[i].name.CompareNoCase(name))
continue;
if(!Modes[i].MatchesCurrentGame())
continue;
LOG->Trace("found it");
return i;
}
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)
{ // XXX dupes
/* Iterate over all keys. */
for(unsigned i = 0; i < Modes.size(); ++i)
{
if(!Modes[i].MatchesCurrentGame())
continue;
IDs.push_back(Modes[i].name);
}
}
void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) const
{
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
{
const int mode = GetID(pn);
if(mode != -1)
Modes[mode].EndDrawTrack(tn);
DISPLAY->PopMatrix();
}
+30 -14
View File
@@ -1,31 +1,47 @@
#ifndef NOTEFIELD_POSITIONING_H
#define NOTEFIELD_POSITIONING_H
#include "NoteTypes.h"
#include "RageMath.h"
#include "PlayerNumber.h"
#include "StyleDef.h"
#include "PlayerNumber.h"
#include "Style.h"
#include "RageMath.h"
#include <set>
class NoteFieldPositioning
{
RageMatrix m_Position[MAX_NOTE_TRACKS];
/* 0 = no perspective */
float m_fFov[MAX_NOTE_TRACKS];
RageMatrix m_PerspPosition[MAX_NOTE_TRACKS];
struct Mode
{
Mode();
bool MatchesCurrentGame() const;
void BeginDrawTrack(int tn) const;
void EndDrawTrack(int tn) const;
CString name;
set<Style> Styles;
RageMatrix m_Position[MAX_NOTE_TRACKS];
/* 0 = no perspective */
float m_fFov[MAX_NOTE_TRACKS];
RageMatrix m_PerspPosition[MAX_NOTE_TRACKS];
};
vector<Mode> Modes;
public:
NoteFieldPositioning();
~NoteFieldPositioning();
void Init();
void Update(float fDeltaTime);
NoteFieldPositioning(CString fn);
void LoadFromFile(CString fn);
void LoadFromStyleDef(const StyleDef *s, PlayerNumber pn);
/* 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(int tn);
void EndDrawTrack(int tn);
void BeginDrawTrack(PlayerNumber pn, int tn) const;
void EndDrawTrack(PlayerNumber pn, int tn) const;
void GetNamesForCurrentGame(vector<CString> &IDs);
};
#endif
+1
View File
@@ -28,6 +28,7 @@ void PlayerOptions::Init()
m_bHoldNotes = true;
m_bTimingAssist = false;
m_fPerspectiveTilt = 0;
m_sPositioning = "";
}
void FLOAT_APPROACH( float& val, float other_val, float deltaPercent )
+3
View File
@@ -75,6 +75,9 @@ struct PlayerOptions
bool m_bTimingAssist;
float m_fPerspectiveTilt; // -1 = near, 0 = overhead, +1 = space
/* The current positioning mode, or empty to use the normal positions. */
CString m_sPositioning;
void NextAccel();
void NextEffect();
void NextAppearance();
-2
View File
@@ -272,8 +272,6 @@ ScreenEdit::ScreenEdit()
GAMESTATE->m_PlayerController[PLAYER_1] = HUMAN;
m_Player.SetXY( PLAYER_X, PLAYER_Y );
GAMESTATE->m_Position[PLAYER_1]->LoadFromStyleDef(GAMESTATE->GetCurrentStyleDef(), PLAYER_1);
m_Fade.SetClosed();
m_sprHelp.Load( THEME->GetPathTo("Graphics","ScreenEdit help") );
-5
View File
@@ -477,11 +477,6 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration )
}
for( p=0; p<NUM_PLAYERS; p++ )
{
GAMESTATE->m_Position[p]->LoadFromStyleDef(GAMESTATE->GetCurrentStyleDef(), (PlayerNumber)p);
}
/* LoadNextSong first, since that positions some elements which need to be
* positioned before we TweenOnScreen. */
LoadNextSong();
-2
View File
@@ -64,8 +64,6 @@ ScreenHowToPlay::ScreenHowToPlay() : ScreenAttract("ScreenHowToPlay")
delete pND;
m_fFakeSecondsIntoSong = 0;
GAMESTATE->m_Position[PLAYER_1]->LoadFromStyleDef(GAMESTATE->GetCurrentStyleDef(), PLAYER_1);
}
ScreenHowToPlay::~ScreenHowToPlay()