Moved RoomInfoDisplay into its own files
This commit is contained in:
+2
-169
@@ -8,6 +8,8 @@
|
||||
#include "ScreenManager.h"
|
||||
|
||||
AutoScreenMessage( SM_BackFromRoomName )
|
||||
AutoScreenMessage( SM_RoomInfoRetract )
|
||||
AutoScreenMessage( SM_RoomInfoDeploy )
|
||||
|
||||
ThemeMetric<float> DESC_X;
|
||||
ThemeMetric<float> DESC_Y;
|
||||
@@ -23,8 +25,6 @@ RoomWheel::~RoomWheel()
|
||||
|
||||
void RoomWheel::Load( RString sType )
|
||||
{
|
||||
SetName( sType );
|
||||
|
||||
WheelBase::Load( sType );
|
||||
|
||||
m_offset = 0;
|
||||
@@ -179,173 +179,6 @@ unsigned int RoomWheel::GetNumItems() const
|
||||
return m_CurWheelItemData.size() - m_offset;
|
||||
}
|
||||
|
||||
RoomInfoDisplay::~RoomInfoDisplay()
|
||||
{
|
||||
for (size_t i = 0; i < m_playerList.size(); i++)
|
||||
{
|
||||
this->RemoveChild(m_playerList[i]);
|
||||
SAFE_DELETE(m_playerList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::DeployInfoBox()
|
||||
{
|
||||
if (m_state == CLOSED)
|
||||
{
|
||||
LOG->Info("OPEN");
|
||||
SET_XY_AND_ON_COMMAND( this );
|
||||
m_state = OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::RetractInfoBox()
|
||||
{
|
||||
if (m_state == OPEN)
|
||||
OFF_COMMAND( this );
|
||||
|
||||
m_state = LOCKED;
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::Load( RString sType )
|
||||
{
|
||||
SetName(sType);
|
||||
DEPLOY_DELAY.Load(sType, "DeployDelay");
|
||||
RETRACT_DELAY.Load(sType, "RetractDelay");
|
||||
PLAYERLISTX.Load(sType, "PlayerListElementX");
|
||||
PLAYERLISTY.Load(sType, "PlayerListElementY");
|
||||
PLAYERLISTOFFSETX.Load(sType, "PlayerListElementOffsetX");
|
||||
PLAYERLISTOFFSETY.Load(sType, "PlayerListElementOffsetY");
|
||||
|
||||
m_state = LOCKED;
|
||||
|
||||
m_bg.Load( THEME->GetPathG(m_sName,"Background") );
|
||||
m_bg->SetName("Background");
|
||||
this->AddChild(m_bg);
|
||||
|
||||
m_Title.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_Title.SetName("RoomTitle");
|
||||
m_Title.SetShadowLength( 0 );
|
||||
m_Title.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_Title);
|
||||
this->AddChild(&m_Title);
|
||||
|
||||
m_Desc.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_Desc.SetName("RoomDesc");
|
||||
m_Desc.SetShadowLength( 0 );
|
||||
m_Desc.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_Desc);
|
||||
this->AddChild(&m_Desc);
|
||||
|
||||
m_lastRound.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_lastRound.SetName("LastRound");
|
||||
m_lastRound.SetText("Last Round Info:");
|
||||
m_lastRound.SetShadowLength( 0 );
|
||||
m_lastRound.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_lastRound);
|
||||
this->AddChild(&m_lastRound);
|
||||
|
||||
m_songTitle.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_songTitle.SetName("SongTitle");
|
||||
m_songTitle.SetShadowLength( 0 );
|
||||
m_songTitle.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_songTitle);
|
||||
this->AddChild(&m_songTitle);
|
||||
|
||||
m_songSub.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_songSub.SetName("SongSubTitle");
|
||||
m_songSub.SetShadowLength( 0 );
|
||||
m_songSub.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_songSub);
|
||||
this->AddChild(&m_songSub);
|
||||
|
||||
m_songArtist.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_songArtist.SetName("SongArtist");
|
||||
m_songArtist.SetShadowLength( 0 );
|
||||
m_songArtist.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_songArtist);
|
||||
this->AddChild(&m_songArtist);
|
||||
|
||||
m_players.LoadFromFont( THEME->GetPathF(sType,"text") );
|
||||
m_players.SetName("Players");
|
||||
m_players.SetShadowLength( 0 );
|
||||
m_players.SetHorizAlign( align_left );
|
||||
SET_XY_AND_ON_COMMAND(m_players);
|
||||
this->AddChild(&m_players);
|
||||
|
||||
SET_XY_AND_ON_COMMAND( this );
|
||||
OFF_COMMAND(this);
|
||||
StopTweening();
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::SetRoom( const RoomWheelData* roomData )
|
||||
{
|
||||
RequestRoomInfo(roomData->m_sText);
|
||||
|
||||
m_Title.SetText(ssprintf("Name: %s", roomData->m_sText.c_str()));
|
||||
m_Desc.SetText(ssprintf("Description: %s", roomData->m_sDesc.c_str()));
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::Update( float fDeltaTime )
|
||||
{
|
||||
if ((m_deployDelay.PeekDeltaTime() >= DEPLOY_DELAY) && (m_deployDelay.PeekDeltaTime() < (DEPLOY_DELAY + RETRACT_DELAY)))
|
||||
DeployInfoBox();
|
||||
else if (m_deployDelay.PeekDeltaTime() >= DEPLOY_DELAY + RETRACT_DELAY)
|
||||
RetractInfoBox();
|
||||
|
||||
ActorFrame::Update(fDeltaTime);
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::RequestRoomInfo(const RString& name)
|
||||
{
|
||||
NSMAN->m_SMOnlinePacket.ClearPacket();
|
||||
NSMAN->m_SMOnlinePacket.Write1((uint8_t)3); //Request Room Info
|
||||
NSMAN->m_SMOnlinePacket.WriteNT(name);
|
||||
NSMAN->SendSMOnline( );
|
||||
}
|
||||
|
||||
void RoomInfoDisplay::SetRoomInfo( const RoomInfo& info)
|
||||
{
|
||||
m_songTitle.SetText(ssprintf("Title: %s", info.songTitle.c_str()));
|
||||
m_songSub.SetText(ssprintf("Subtitle: %s", info.songSubTitle.c_str()));
|
||||
m_songArtist.SetText(ssprintf("Artist: %s", info.songArtist.c_str()));
|
||||
m_players.SetText(ssprintf("Players (%d/%d):", info.numPlayers, info.maxPlayers));
|
||||
|
||||
if (m_playerList.size() > info.players.size())
|
||||
{
|
||||
for (size_t i = info.players.size(); i < m_playerList.size(); i++)
|
||||
{
|
||||
//if our old list is larger remove some elements
|
||||
this->RemoveChild(m_playerList[i]);
|
||||
SAFE_DELETE(m_playerList[i]);
|
||||
}
|
||||
m_playerList.resize(info.players.size());
|
||||
}
|
||||
else if (m_playerList.size() < info.players.size())
|
||||
{
|
||||
//add elements if our old list is smaller
|
||||
int oldsize = m_playerList.size();
|
||||
m_playerList.resize(info.players.size());
|
||||
for (size_t i = oldsize; i < m_playerList.size(); i++)
|
||||
{
|
||||
m_playerList[i] = new BitmapText;
|
||||
m_playerList[i]->LoadFromFont( THEME->GetPathF(GetName(),"text") );
|
||||
m_playerList[i]->SetName("PlayerListElement");
|
||||
m_playerList[i]->SetShadowLength( 0 );
|
||||
m_playerList[i]->SetHorizAlign( align_left );
|
||||
m_playerList[i]->SetX(PLAYERLISTX + (i * PLAYERLISTOFFSETX));
|
||||
m_playerList[i]->SetY(PLAYERLISTY + (i * PLAYERLISTOFFSETY));
|
||||
ON_COMMAND(m_playerList[i]);
|
||||
this->AddChild(m_playerList[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_playerList.size(); i++)
|
||||
m_playerList[i]->SetText(info.players[i]);
|
||||
|
||||
m_state = CLOSED;
|
||||
m_deployDelay.Touch();
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2004 Josh Allen
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
/* RoomWheel - A wheel containing data about rooms. */
|
||||
|
||||
#ifndef ROOMWHEEL_H
|
||||
#define ROOMWHEEL_H
|
||||
#ifndef ROOM_WHEEL_H
|
||||
#define ROOM_WHEEL_H
|
||||
|
||||
#include "WheelBase.h"
|
||||
#include "WheelItemBase.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
AutoScreenMessage( SM_RoomInfoRetract )
|
||||
AutoScreenMessage( SM_RoomInfoDeploy )
|
||||
|
||||
struct RoomWheelData : public WheelItemBaseData
|
||||
{
|
||||
RoomWheelData() : m_iFlags(0) { WheelItemBaseData::WheelItemBaseData(); }
|
||||
@@ -45,50 +42,6 @@ struct RoomInfo
|
||||
vector<RString> players;
|
||||
};
|
||||
|
||||
class RoomInfoDisplay : public ActorFrame
|
||||
{
|
||||
public:
|
||||
~RoomInfoDisplay();
|
||||
virtual void Load( RString sType );
|
||||
virtual void Update( float fDeltaTime );
|
||||
void SetRoom( const RoomWheelData* roomData );
|
||||
void SetRoomInfo( const RoomInfo& info);
|
||||
void DeployInfoBox();
|
||||
void RetractInfoBox();
|
||||
private:
|
||||
void RequestRoomInfo(const RString& name);
|
||||
enum RoomInfoDisplayState
|
||||
{
|
||||
OPEN = 0,
|
||||
CLOSED,
|
||||
LOCKED
|
||||
};
|
||||
|
||||
RoomInfoDisplayState m_state;
|
||||
AutoActor m_bg;
|
||||
BitmapText m_Title;
|
||||
BitmapText m_Desc;
|
||||
|
||||
BitmapText m_lastRound;
|
||||
BitmapText m_songTitle;
|
||||
BitmapText m_songSub;
|
||||
BitmapText m_songArtist;
|
||||
|
||||
BitmapText m_players;
|
||||
vector<BitmapText*> m_playerList;
|
||||
|
||||
RageTimer m_deployDelay;
|
||||
|
||||
ThemeMetric<float> X;
|
||||
ThemeMetric<float> Y;
|
||||
ThemeMetric<float> DEPLOY_DELAY;
|
||||
ThemeMetric<float> RETRACT_DELAY;
|
||||
ThemeMetric<float> PLAYERLISTX;
|
||||
ThemeMetric<float> PLAYERLISTY;
|
||||
ThemeMetric<float> PLAYERLISTOFFSETX;
|
||||
ThemeMetric<float> PLAYERLISTOFFSETY;
|
||||
};
|
||||
|
||||
class RoomWheel : public WheelBase
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user