From 642f06d21069c4fde59799a873ee2b262fdb8790 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Mon, 14 Aug 2006 15:43:45 +0000 Subject: [PATCH] Moved RoomInfoDisplay into its own files --- stepmania/src/RoomWheel.cpp | 171 +----------------------------------- stepmania/src/RoomWheel.h | 51 +---------- 2 files changed, 4 insertions(+), 218 deletions(-) diff --git a/stepmania/src/RoomWheel.cpp b/stepmania/src/RoomWheel.cpp index f9f570fa90..af0d57a521 100644 --- a/stepmania/src/RoomWheel.cpp +++ b/stepmania/src/RoomWheel.cpp @@ -8,6 +8,8 @@ #include "ScreenManager.h" AutoScreenMessage( SM_BackFromRoomName ) +AutoScreenMessage( SM_RoomInfoRetract ) +AutoScreenMessage( SM_RoomInfoDeploy ) ThemeMetric DESC_X; ThemeMetric 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 diff --git a/stepmania/src/RoomWheel.h b/stepmania/src/RoomWheel.h index 6e4cd02dbf..cb0e91393c 100644 --- a/stepmania/src/RoomWheel.h +++ b/stepmania/src/RoomWheel.h @@ -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 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 m_playerList; - - RageTimer m_deployDelay; - - ThemeMetric X; - ThemeMetric Y; - ThemeMetric DEPLOY_DELAY; - ThemeMetric RETRACT_DELAY; - ThemeMetric PLAYERLISTX; - ThemeMetric PLAYERLISTY; - ThemeMetric PLAYERLISTOFFSETX; - ThemeMetric PLAYERLISTOFFSETY; -}; - class RoomWheel : public WheelBase { public: