add ControllerStateDisplay
This commit is contained in:
@@ -0,0 +1,88 @@
|
|||||||
|
#include "global.h"
|
||||||
|
#include "ControllerStateDisplay.h"
|
||||||
|
#include "EnumHelper.h"
|
||||||
|
#include "RageUtil.h"
|
||||||
|
#include "RageInputDevice.h"
|
||||||
|
#include "ThemeManager.h"
|
||||||
|
#include "InputMapper.h"
|
||||||
|
#include "InputFilter.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
|
static const char *ControllerStateButtonNames[] = {
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
};
|
||||||
|
XToString( ControllerStateButton, NUM_ControllerStateButton );
|
||||||
|
|
||||||
|
static const DeviceButton ControllerStateButtonToDeviceButton[] = {
|
||||||
|
JOY_UP,
|
||||||
|
JOY_DOWN,
|
||||||
|
JOY_LEFT,
|
||||||
|
JOY_RIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ControllerStateDisplay::ControllerStateDisplay()
|
||||||
|
{
|
||||||
|
m_bIsLoaded = false;
|
||||||
|
|
||||||
|
this->AddChild( &m_sprFrame );
|
||||||
|
FOREACH_ENUM2( ControllerStateButton, b )
|
||||||
|
this->AddChild( &m_Buttons[b].spr );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerStateDisplay::Load( MultiPlayer mp )
|
||||||
|
{
|
||||||
|
m_bIsLoaded = true;
|
||||||
|
|
||||||
|
m_sprFrame.Load( THEME->GetPathG("ControllerStateDisplay", "frame") );
|
||||||
|
|
||||||
|
FOREACH_ENUM2( ControllerStateButton, b )
|
||||||
|
{
|
||||||
|
Button &button = m_Buttons[ b ];
|
||||||
|
|
||||||
|
LOG->Warn( "csd: %d %d", mp, b );
|
||||||
|
|
||||||
|
RString sPath = THEME->GetPathG( "ControllerStateDisplay", ControllerStateButtonToString(b) );
|
||||||
|
button.spr.Load( sPath );
|
||||||
|
|
||||||
|
button.di = DeviceInput( INPUTMAPPER->MultiPlayerToInputDevice(mp), ControllerStateButtonToDeviceButton[b] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerStateDisplay::Update( float fDelta )
|
||||||
|
{
|
||||||
|
FOREACH_ENUM2( ControllerStateButton, b )
|
||||||
|
{
|
||||||
|
Button &button = m_Buttons[ b ];
|
||||||
|
button.spr.SetVisible( INPUTFILTER->IsBeingPressed(button.di) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2001-2004 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.
|
||||||
|
*/
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/* ControllerStateDisplay - Show the button state of a controller. */
|
||||||
|
|
||||||
|
#ifndef ControllerStateDisplay_H
|
||||||
|
#define ControllerStateDisplay_H
|
||||||
|
|
||||||
|
#include "ActorFrame.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
#include "PlayerNumber.h"
|
||||||
|
#include "Sprite.h"
|
||||||
|
#include "RageInput.h"
|
||||||
|
|
||||||
|
enum ControllerStateButton
|
||||||
|
{
|
||||||
|
ControllerStateButton_Up,
|
||||||
|
ControllerStateButton_Down,
|
||||||
|
ControllerStateButton_Left,
|
||||||
|
ControllerStateButton_Right,
|
||||||
|
NUM_ControllerStateButton
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ControllerStateDisplay : public ActorFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ControllerStateDisplay();
|
||||||
|
void Load( MultiPlayer mp );
|
||||||
|
virtual void Update( float fDelta );
|
||||||
|
bool IsLoaded() const { return m_bIsLoaded; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_bIsLoaded;
|
||||||
|
Sprite m_sprFrame;
|
||||||
|
struct Button
|
||||||
|
{
|
||||||
|
Sprite spr;
|
||||||
|
DeviceInput di;
|
||||||
|
};
|
||||||
|
Button m_Buttons[NUM_ControllerStateButton];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2001-2004 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.
|
||||||
|
*/
|
||||||
@@ -257,7 +257,9 @@ Transition.cpp Transition.h
|
|||||||
|
|
||||||
ActorsInMenus = \
|
ActorsInMenus = \
|
||||||
ActiveAttackList.cpp ActiveAttackList.h BPMDisplay.cpp BPMDisplay.h ComboGraph.cpp ComboGraph.h \
|
ActiveAttackList.cpp ActiveAttackList.h BPMDisplay.cpp BPMDisplay.h ComboGraph.cpp ComboGraph.h \
|
||||||
CourseContentsList.cpp CourseContentsList.h CourseEntryDisplay.cpp CourseEntryDisplay.h \
|
ControllerStateDisplay.cpp ControllerStateDisplay.h \
|
||||||
|
CourseContentsList.cpp CourseContentsList.h \
|
||||||
|
CourseEntryDisplay.cpp CourseEntryDisplay.h \
|
||||||
DifficultyDisplay.cpp DifficultyDisplay.h DifficultyList.cpp DifficultyList.h \
|
DifficultyDisplay.cpp DifficultyDisplay.h DifficultyList.cpp DifficultyList.h \
|
||||||
DifficultyMeter.cpp DifficultyMeter.h DifficultyRating.cpp DifficultyRating.h \
|
DifficultyMeter.cpp DifficultyMeter.h DifficultyRating.cpp DifficultyRating.h \
|
||||||
DualScrollBar.cpp DualScrollBar.h \
|
DualScrollBar.cpp DualScrollBar.h \
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ Player::Player( bool bShowNoteField, bool bShowJudgment )
|
|||||||
this->AddChild( m_pJudgment );
|
this->AddChild( m_pJudgment );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pControllerStateDisplay = NULL;
|
||||||
|
if( bShowJudgment )
|
||||||
|
{
|
||||||
|
m_pControllerStateDisplay = new ControllerStateDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
m_pCombo = NULL;
|
m_pCombo = NULL;
|
||||||
if( bShowNoteField )
|
if( bShowNoteField )
|
||||||
{
|
{
|
||||||
@@ -118,6 +124,7 @@ Player::Player( bool bShowNoteField, bool bShowJudgment )
|
|||||||
Player::~Player()
|
Player::~Player()
|
||||||
{
|
{
|
||||||
SAFE_DELETE( m_pJudgment );
|
SAFE_DELETE( m_pJudgment );
|
||||||
|
SAFE_DELETE( m_pControllerStateDisplay );
|
||||||
SAFE_DELETE( m_pCombo );
|
SAFE_DELETE( m_pCombo );
|
||||||
SAFE_DELETE( m_pAttackDisplay );
|
SAFE_DELETE( m_pAttackDisplay );
|
||||||
SAFE_DELETE( m_pNoteField );
|
SAFE_DELETE( m_pNoteField );
|
||||||
@@ -235,6 +242,16 @@ void Player::Init(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load CSD
|
||||||
|
// TODO: Don't reload every song
|
||||||
|
if( GAMESTATE->m_bMultiplayer && m_pControllerStateDisplay && !m_pControllerStateDisplay->IsLoaded() ) // only load the first time
|
||||||
|
{
|
||||||
|
m_pControllerStateDisplay->Load( pPlayerState->m_mp );
|
||||||
|
this->AddChild( m_pControllerStateDisplay );
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SortByDrawOrder();
|
||||||
|
|
||||||
m_pPlayerState = pPlayerState;
|
m_pPlayerState = pPlayerState;
|
||||||
m_pPlayerStageStats = pPlayerStageStats;
|
m_pPlayerStageStats = pPlayerStageStats;
|
||||||
m_pLifeMeter = pLM;
|
m_pLifeMeter = pLM;
|
||||||
@@ -495,6 +512,13 @@ void Player::Update( float fDeltaTime )
|
|||||||
Actor::TweenState::MakeWeightedAverage( m_pJudgment->DestTweenState(), ts1, ts2, fPercentCentered );
|
Actor::TweenState::MakeWeightedAverage( m_pJudgment->DestTweenState(), ts1, ts2, fPercentCentered );
|
||||||
if( m_sprJudgmentFrame.IsLoaded() )
|
if( m_sprJudgmentFrame.IsLoaded() )
|
||||||
Actor::TweenState::MakeWeightedAverage( m_sprJudgmentFrame->DestTweenState(), ts1, ts2, fPercentCentered );
|
Actor::TweenState::MakeWeightedAverage( m_sprJudgmentFrame->DestTweenState(), ts1, ts2, fPercentCentered );
|
||||||
|
if( m_pControllerStateDisplay->IsLoaded() )
|
||||||
|
{
|
||||||
|
Actor::TweenState::MakeWeightedAverage( m_pControllerStateDisplay->DestTweenState(), ts1, ts2, fPercentCentered );
|
||||||
|
|
||||||
|
// temp hack
|
||||||
|
m_pControllerStateDisplay->DestTweenState().pos.x *= 1.35f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -840,6 +864,8 @@ void Player::DrawTapJudgments()
|
|||||||
|
|
||||||
if( m_sprJudgmentFrame.IsLoaded() )
|
if( m_sprJudgmentFrame.IsLoaded() )
|
||||||
m_sprJudgmentFrame->Draw();
|
m_sprJudgmentFrame->Draw();
|
||||||
|
if( m_pControllerStateDisplay )
|
||||||
|
m_pControllerStateDisplay->Draw();
|
||||||
if( m_pJudgment )
|
if( m_pJudgment )
|
||||||
m_pJudgment->Draw();
|
m_pJudgment->Draw();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "RageSound.h"
|
#include "RageSound.h"
|
||||||
#include "AttackDisplay.h"
|
#include "AttackDisplay.h"
|
||||||
#include "NoteData.h"
|
#include "NoteData.h"
|
||||||
|
#include "ControllerStateDisplay.h"
|
||||||
|
|
||||||
class ScoreDisplay;
|
class ScoreDisplay;
|
||||||
class LifeMeter;
|
class LifeMeter;
|
||||||
@@ -94,6 +95,8 @@ protected:
|
|||||||
Judgment *m_pJudgment;
|
Judgment *m_pJudgment;
|
||||||
AutoActor m_sprJudgmentFrame;
|
AutoActor m_sprJudgmentFrame;
|
||||||
|
|
||||||
|
ControllerStateDisplay *m_pControllerStateDisplay;
|
||||||
|
|
||||||
Combo *m_pCombo;
|
Combo *m_pCombo;
|
||||||
|
|
||||||
AttackDisplay *m_pAttackDisplay;
|
AttackDisplay *m_pAttackDisplay;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "LocalizedString.h"
|
#include "LocalizedString.h"
|
||||||
#include "InputEventPlus.h"
|
#include "InputEventPlus.h"
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
#include "ControllerStateDisplay.h"
|
||||||
|
|
||||||
static const char *MultiplayerJudgeLineNames[] = {
|
static const char *MultiplayerJudgeLineNames[] = {
|
||||||
"W1",
|
"W1",
|
||||||
@@ -46,6 +47,7 @@ protected:
|
|||||||
AutoActor m_sprFrame;
|
AutoActor m_sprFrame;
|
||||||
PercentageDisplay m_score;
|
PercentageDisplay m_score;
|
||||||
BitmapText m_textJudgmentNumber[NUM_MultiplayerJudgeLine];
|
BitmapText m_textJudgmentNumber[NUM_MultiplayerJudgeLine];
|
||||||
|
ControllerStateDisplay m_ControllerStateDisplay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiplayerEvalScoreRow( MultiPlayer mp, int iRankIndex )
|
MultiplayerEvalScoreRow( MultiPlayer mp, int iRankIndex )
|
||||||
@@ -93,6 +95,10 @@ public:
|
|||||||
|
|
||||||
PositionItem( expr, &text, i, NUM_MultiplayerJudgeLine );
|
PositionItem( expr, &text, i, NUM_MultiplayerJudgeLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ControllerStateDisplay.Load( mp );
|
||||||
|
this->AddChild( &m_ControllerStateDisplay );
|
||||||
|
PositionItem( expr, &m_ControllerStateDisplay, NUM_MultiplayerJudgeLine, NUM_MultiplayerJudgeLine );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ void ScreenJoinMultiplayer::Init()
|
|||||||
this->AddChild( m_sprPlayer[p] );
|
this->AddChild( m_sprPlayer[p] );
|
||||||
|
|
||||||
LUA->UnsetGlobal( "ThisGameCommand" );
|
LUA->UnsetGlobal( "ThisGameCommand" );
|
||||||
|
|
||||||
|
m_ControllerState[p].Load( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_exprOnCommandFunction.SetFromExpression( THEME->GetMetric(m_sName,"TranformFunction") );
|
m_exprOnCommandFunction.SetFromExpression( THEME->GetMetric(m_sName,"TranformFunction") );
|
||||||
@@ -69,6 +71,11 @@ void ScreenJoinMultiplayer::Init()
|
|||||||
FOREACH_MultiPlayer( p )
|
FOREACH_MultiPlayer( p )
|
||||||
{
|
{
|
||||||
PositionItem( m_sprPlayer[p], p, NUM_MultiPlayer );
|
PositionItem( m_sprPlayer[p], p, NUM_MultiPlayer );
|
||||||
|
PositionItem( &m_ControllerState[p], p, NUM_MultiPlayer );
|
||||||
|
m_ControllerState[p].AddX( -30 );
|
||||||
|
m_ControllerState[p].AddY( 30 );
|
||||||
|
|
||||||
|
this->AddChild( &m_ControllerState[p] );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_soundPlugIn.Load( THEME->GetPathS(m_sName,"PlugIn") );
|
m_soundPlugIn.Load( THEME->GetPathS(m_sName,"PlugIn") );
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "ScreenWithMenuElements.h"
|
#include "ScreenWithMenuElements.h"
|
||||||
#include "RageSound.h"
|
#include "RageSound.h"
|
||||||
|
#include "ControllerStateDisplay.h"
|
||||||
|
|
||||||
enum MultiPlayerStatus
|
enum MultiPlayerStatus
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,7 @@ protected:
|
|||||||
MultiPlayerStatus m_MultiPlayerStatus[NUM_MultiPlayer];
|
MultiPlayerStatus m_MultiPlayerStatus[NUM_MultiPlayer];
|
||||||
|
|
||||||
AutoActor m_sprPlayer[NUM_MultiPlayer];
|
AutoActor m_sprPlayer[NUM_MultiPlayer];
|
||||||
|
ControllerStateDisplay m_ControllerState[NUM_MultiPlayer];
|
||||||
|
|
||||||
LuaExpression m_exprOnCommandFunction; // params: self,itemIndex,numItems
|
LuaExpression m_exprOnCommandFunction; // params: self,itemIndex,numItems
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user