2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-03-19 07:09:49 +00:00
|
|
|
|
2004-05-31 21:35:31 +00:00
|
|
|
/*
|
|
|
|
|
* Styles define a set of columns for each player, and information about those
|
|
|
|
|
* columns, like what Instruments are used play those columns and what track
|
|
|
|
|
* to use to populate the column's notes.
|
|
|
|
|
* A "track" is the term used to descibe a particular vertical sting of note
|
|
|
|
|
* in NoteData.
|
|
|
|
|
* A "column" is the term used to describe the vertical string of notes that
|
|
|
|
|
* a player sees on the screen while they're playing. Column notes are
|
|
|
|
|
* picked from a track, but columns and tracks don't have a 1-to-1
|
|
|
|
|
* correspondance. For example, dance-versus has 8 columns but only 4 tracks
|
|
|
|
|
* because two players place from the same set of 4 tracks.
|
|
|
|
|
*/
|
2002-03-19 07:09:49 +00:00
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
#include "Style.h"
|
2002-05-01 19:14:55 +00:00
|
|
|
#include "RageLog.h"
|
2002-04-01 02:04:43 +00:00
|
|
|
#include "RageUtil.h"
|
2004-07-25 17:07:32 +00:00
|
|
|
#include "Game.h"
|
2002-08-20 21:00:56 +00:00
|
|
|
#include "GameState.h"
|
2002-12-17 21:49:14 +00:00
|
|
|
#include "NoteData.h"
|
2005-03-29 19:10:42 +00:00
|
|
|
#include <float.h>
|
2002-03-19 07:09:49 +00:00
|
|
|
|
|
|
|
|
|
2004-10-23 17:43:49 +00:00
|
|
|
void Style::GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData& original, NoteData& noteDataOut ) const
|
2002-05-01 19:14:55 +00:00
|
|
|
{
|
2005-08-23 20:49:30 +00:00
|
|
|
ASSERT( pn >=0 && pn <= NUM_PLAYERS );
|
|
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
int iNewToOriginalTrack[MAX_COLS_PER_PLAYER];
|
2002-05-01 19:14:55 +00:00
|
|
|
for( int col=0; col<m_iColsPerPlayer; col++ )
|
|
|
|
|
{
|
2002-09-04 03:49:08 +00:00
|
|
|
ColumnInfo colInfo = m_ColumnInfo[pn][col];
|
2006-09-15 08:05:15 +00:00
|
|
|
iNewToOriginalTrack[col] = colInfo.track;
|
2002-05-01 19:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
2004-10-23 17:43:49 +00:00
|
|
|
noteDataOut.LoadTransformed( original, m_iColsPerPlayer, iNewToOriginalTrack );
|
2002-07-31 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-13 09:12:51 +00:00
|
|
|
GameInput Style::StyleInputToGameInput( int iCol, PlayerNumber pn ) const
|
2002-07-31 19:40:40 +00:00
|
|
|
{
|
2006-09-13 09:12:51 +00:00
|
|
|
ASSERT_M( pn < NUM_PLAYERS && iCol < MAX_COLS_PER_PLAYER,
|
|
|
|
|
ssprintf("P%i C%i", pn, iCol) );
|
2006-06-24 04:01:18 +00:00
|
|
|
bool bUsingOneSide = m_StyleType != ONE_PLAYER_TWO_SIDES && m_StyleType != TWO_PLAYERS_SHARED_SIDES;
|
2004-12-03 21:47:57 +00:00
|
|
|
|
|
|
|
|
FOREACH_GameController(gc)
|
|
|
|
|
{
|
2006-09-13 00:09:00 +00:00
|
|
|
if( bUsingOneSide && gc != (int) pn )
|
2004-12-06 05:34:40 +00:00
|
|
|
continue;
|
|
|
|
|
|
2004-12-03 21:47:57 +00:00
|
|
|
for( int i = 0; i < m_pGame->m_iButtonsPerController && m_iInputColumn[gc][i] != END_MAPPING; ++i )
|
2006-09-13 09:12:51 +00:00
|
|
|
if( m_iInputColumn[gc][i] == iCol )
|
2004-12-03 21:47:57 +00:00
|
|
|
return GameInput( gc, i );
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-13 09:12:51 +00:00
|
|
|
FAIL_M( ssprintf("Invalid column %i,%i", pn, iCol) );
|
2002-07-31 19:40:40 +00:00
|
|
|
};
|
|
|
|
|
|
2006-09-13 09:22:24 +00:00
|
|
|
int Style::GameInputToColumn( const GameInput &GameI ) const
|
2002-07-31 19:40:40 +00:00
|
|
|
{
|
2006-01-12 02:42:57 +00:00
|
|
|
if( m_iInputColumn[GameI.controller][GameI.button] == NO_MAPPING )
|
2006-09-13 09:12:51 +00:00
|
|
|
return Column_INVALID;
|
2006-01-12 02:42:57 +00:00
|
|
|
|
2004-12-04 04:30:39 +00:00
|
|
|
for( int i = 0; i <= GameI.button; ++i )
|
2004-12-03 21:47:57 +00:00
|
|
|
if( m_iInputColumn[GameI.controller][i] == END_MAPPING )
|
2006-09-13 09:12:51 +00:00
|
|
|
return Column_INVALID;
|
2004-12-03 21:47:57 +00:00
|
|
|
|
2006-09-13 09:12:51 +00:00
|
|
|
return m_iInputColumn[GameI.controller][GameI.button];
|
2002-07-31 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
PlayerNumber Style::ControllerToPlayerNumber( GameController controller ) const
|
2002-09-02 21:59:58 +00:00
|
|
|
{
|
|
|
|
|
switch( m_StyleType )
|
|
|
|
|
{
|
2004-11-07 05:49:06 +00:00
|
|
|
case ONE_PLAYER_ONE_SIDE:
|
|
|
|
|
case TWO_PLAYERS_TWO_SIDES:
|
2006-06-22 18:35:11 +00:00
|
|
|
case TWO_PLAYERS_SHARED_SIDES:
|
2002-09-02 21:59:58 +00:00
|
|
|
return (PlayerNumber)controller;
|
2004-11-07 05:49:06 +00:00
|
|
|
case ONE_PLAYER_TWO_SIDES:
|
2002-09-02 21:59:58 +00:00
|
|
|
return GAMESTATE->m_MasterPlayerNumber;
|
2006-09-14 21:02:55 +00:00
|
|
|
DEFAULT_FAIL( m_StyleType );
|
2002-09-02 21:59:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-09-06 08:56:28 +00:00
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
void Style::GetMinAndMaxColX( PlayerNumber pn, float& fMixXOut, float& fMaxXOut ) const
|
2003-02-19 07:59:00 +00:00
|
|
|
{
|
2005-04-07 18:32:19 +00:00
|
|
|
ASSERT( pn != PLAYER_INVALID );
|
|
|
|
|
|
2005-03-29 19:10:42 +00:00
|
|
|
fMixXOut = FLT_MAX;
|
|
|
|
|
fMaxXOut = FLT_MIN;
|
2003-02-19 07:59:00 +00:00
|
|
|
for( int i=0; i<m_iColsPerPlayer; i++ )
|
|
|
|
|
{
|
|
|
|
|
fMixXOut = min( fMixXOut, m_ColumnInfo[pn][i].fXOffset );
|
|
|
|
|
fMaxXOut = max( fMaxXOut, m_ColumnInfo[pn][i].fXOffset );
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-23 03:55:18 +00:00
|
|
|
|
2006-08-18 00:11:30 +00:00
|
|
|
// Lua bindings
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
2006-08-20 04:38:11 +00:00
|
|
|
class LunaStyle: public Luna<Style>
|
2006-08-18 00:11:30 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2006-08-20 04:38:11 +00:00
|
|
|
LunaStyle() { LUA->Register( Register ); }
|
|
|
|
|
|
|
|
|
|
DEFINE_METHOD( GetStyleType, m_StyleType )
|
|
|
|
|
DEFINE_METHOD( GetStepsType, m_StepsType )
|
|
|
|
|
|
|
|
|
|
static void Register(lua_State *L)
|
|
|
|
|
{
|
|
|
|
|
ADD_METHOD( GetStyleType );
|
|
|
|
|
ADD_METHOD( GetStepsType );
|
|
|
|
|
|
|
|
|
|
Luna<T>::Register( L );
|
|
|
|
|
}
|
2006-08-18 00:11:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_CLASS( Style )
|
|
|
|
|
|
2004-05-31 21:35:31 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2001-2002 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|