Code to be used for in-game scoreboard
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
NetworkSyncManager *NSMAN;
|
||||
|
||||
#if defined(WITHOUT_NETWORKING)
|
||||
NetworkSyncManager::NetworkSyncManager() { }
|
||||
NetworkSyncManager::NetworkSyncManager() { useSMServer=false }
|
||||
NetworkSyncManager::~NetworkSyncManager () { }
|
||||
void NetworkSyncManager::CloseConnection() { }
|
||||
void NetworkSyncManager::PostStartUp( CString ServerIP ) { }
|
||||
@@ -15,7 +15,7 @@ void NetworkSyncManager::ReportSongOver() { }
|
||||
void NetworkSyncManager::StartRequest(short position) { }
|
||||
void NetworkSyncManager::DisplayStartupStatus() { }
|
||||
void NetworkSyncManager::Update( float fDeltaTime ) { }
|
||||
|
||||
bool NetworkSyncManager::ChangedScoreboard() {}
|
||||
#else
|
||||
#include "ezsockets.h"
|
||||
#include "ProfileManager.h"
|
||||
@@ -364,7 +364,12 @@ void NetworkSyncManager::ProcessInput()
|
||||
case 2: //This is already taken care of by the blocking code earlier on
|
||||
case 3: //This is taken care of by the blocking start code
|
||||
case 4: //Undefined
|
||||
case 5: //Undefined
|
||||
case 5: //Scoreboard Update
|
||||
{
|
||||
int ColumnNumber=Read1(m_packet);
|
||||
m_Scoreboard[ColumnNumber] = ReadNT(m_packet);
|
||||
m_scoreboardchange[ColumnNumber]=true;
|
||||
}
|
||||
break;
|
||||
case 6: //System message from server
|
||||
CString SysMSG = ReadNT(m_packet);
|
||||
@@ -374,6 +379,13 @@ void NetworkSyncManager::ProcessInput()
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkSyncManager::ChangedScoreboard(int Column)
|
||||
{
|
||||
if (!m_scoreboardchange[Column])
|
||||
return false;
|
||||
m_scoreboardchange[Column]=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
uint8_t NetworkSyncManager::Read1(NetPacket &Packet)
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
const int NETPROTOCOLVERSION=1;
|
||||
const int NETMAXBUFFERSIZE=1020; //1024 - 4 bytes for EzSockets
|
||||
|
||||
enum NSScoreBoardColumn
|
||||
{
|
||||
NSSB_NAMES=0,
|
||||
NSSB_COMBO,
|
||||
NSSB_GRADE,
|
||||
NUM_NSSB_CATEGORIES
|
||||
};
|
||||
#define FOREACH_NSScoreBoardColumn( sc ) FOREACH_ENUM( NSScoreBoardColumn, NUM_NSSB_CATEGORIES, sc )
|
||||
|
||||
class EzSockets;
|
||||
|
||||
class NetworkSyncManager
|
||||
@@ -33,6 +42,12 @@ public:
|
||||
|
||||
void Update(float fDeltaTime);
|
||||
|
||||
bool useSMserver;
|
||||
|
||||
|
||||
//Used togeather for
|
||||
bool ChangedScoreboard(int Column); //If scoreboard changed since this function last called, then true.
|
||||
CString m_Scoreboard[NUM_NSSB_CATEGORIES];
|
||||
private:
|
||||
#if !defined(WITHOUT_NETWORKING)
|
||||
|
||||
@@ -50,9 +65,9 @@ private:
|
||||
|
||||
int m_startupStatus; //Used to see if attempt was sucessful or not.
|
||||
|
||||
CString m_ServerName;
|
||||
bool m_scoreboardchange[NUM_NSSB_CATEGORIES];
|
||||
|
||||
bool useSMserver;
|
||||
CString m_ServerName;
|
||||
|
||||
EzSockets *NetPlayerClient;
|
||||
|
||||
|
||||
@@ -423,8 +423,28 @@ void ScreenGameplay::Init()
|
||||
break;
|
||||
}
|
||||
|
||||
//the following is only used in SMLAN/SMOnline
|
||||
if (NSMAN->useSMserver)
|
||||
{
|
||||
int i=-1;
|
||||
FOREACH_PlayerNumber(p)
|
||||
if (!GAMESTATE->IsPlayerEnabled(p))
|
||||
i=p;
|
||||
|
||||
|
||||
if (i!=-1)
|
||||
{
|
||||
FOREACH_NSScoreBoardColumn (i2)
|
||||
{
|
||||
m_Scoreboard[i2].LoadFromFont( THEME->GetPathF(m_sName,"scoreboard") );
|
||||
m_Scoreboard[i2].SetShadowLength( 0 );
|
||||
m_Scoreboard[i2].SetName( ssprintf("ScoreboardC%iP%i",i2+1,i+1) );
|
||||
SET_XY( m_Scoreboard[i2] );
|
||||
this->AddChild( &m_Scoreboard[i2] );
|
||||
m_Scoreboard[i2].SetText(NSMAN->m_Scoreboard[i2]);
|
||||
m_Scoreboard[i2].SetVertAlign(align_top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_textSongTitle.LoadFromFont( THEME->GetPathF(m_sName,"song title") );
|
||||
m_textSongTitle.SetShadowLength( 0 );
|
||||
@@ -1551,18 +1571,16 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
CLAMP( fPercentPositionSong, 0, 1 );
|
||||
m_meterSongPosition.SetPercent( fPercentPositionSong );
|
||||
|
||||
|
||||
//FIXED!!!!
|
||||
//I figured it out!
|
||||
//The problem was the pn is already taken.
|
||||
//Sorry, I wasn't too smart about the way I handled it.
|
||||
FOREACH_EnabledPlayer( pn2 )
|
||||
{
|
||||
if( m_pLifeMeter[pn2] )
|
||||
NSMAN->m_playerLife[pn2] = int(m_pLifeMeter[pn2]->GetLife()*10000);
|
||||
if (NSMAN->useSMserver) {
|
||||
FOREACH_EnabledPlayer( pn2 )
|
||||
{
|
||||
if( m_pLifeMeter[pn2] )
|
||||
NSMAN->m_playerLife[pn2] = int(m_pLifeMeter[pn2]->GetLife()*10000);
|
||||
}
|
||||
FOREACH_NSScoreBoardColumn (cn)
|
||||
if (NSMAN->ChangedScoreboard(cn))
|
||||
m_Scoreboard[cn].SetText(NSMAN->m_Scoreboard[cn]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ScreenGameplay::AbortGiveUp()
|
||||
@@ -2345,6 +2363,10 @@ void ScreenGameplay::TweenOnScreen()
|
||||
ON_COMMAND( m_DifficultyIcon[p] );
|
||||
ON_COMMAND( m_DifficultyMeter[p] );
|
||||
}
|
||||
|
||||
FOREACH_NSScoreBoardColumn( sc )
|
||||
ON_COMMAND( m_Scoreboard[sc] );
|
||||
|
||||
m_Overlay.PlayCommand("On");
|
||||
}
|
||||
|
||||
@@ -2384,6 +2406,9 @@ void ScreenGameplay::TweenOffScreen()
|
||||
}
|
||||
m_Overlay.PlayCommand("Off");
|
||||
|
||||
FOREACH_NSScoreBoardColumn( sc )
|
||||
OFF_COMMAND( m_Scoreboard[sc] );
|
||||
|
||||
m_textDebug.StopTweening();
|
||||
m_textDebug.BeginTweening( 1/8.f );
|
||||
m_textDebug.SetDiffuse( RageColor(1,1,1,0) );
|
||||
|
||||
@@ -24,6 +24,7 @@ class Inventory;
|
||||
#include "Attack.h"
|
||||
#include "MeterDisplay.h"
|
||||
#include "ActiveAttackList.h"
|
||||
#include "NetworkSyncManager.h"
|
||||
|
||||
// messages sent by Combo
|
||||
const ScreenMessage SM_PlayToasty = ScreenMessage(SM_User+104);
|
||||
@@ -124,6 +125,7 @@ protected:
|
||||
BitmapText m_textPlayerOptions[NUM_PLAYERS];
|
||||
BitmapText m_textSongOptions;
|
||||
ActiveAttackList m_ActiveAttackList[NUM_PLAYERS];
|
||||
BitmapText m_Scoreboard[NUM_NSSB_CATEGORIES]; // for NSMAN, so we can have a scoreboard
|
||||
|
||||
BitmapText m_textDebug;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user