Make the connect/disconnect a lot nicer.
This commit is contained in:
@@ -11,6 +11,7 @@ NetworkSyncManager::~NetworkSyncManager () { }
|
||||
void NetworkSyncManager::CloseConnection() { }
|
||||
void NetworkSyncManager::PostStartUp(const CString& ServerIP ) { }
|
||||
bool NetworkSyncManager::Connect(const CString& addy, unsigned short port) { return false; }
|
||||
CString NetworkSyncManager::GetServerName() { }
|
||||
void NetworkSyncManager::ReportNSSOnOff(int i) { }
|
||||
void NetworkSyncManager::ReportTiming(float offset, int PlayerNumber) { }
|
||||
void NetworkSyncManager::ReportScore(int playerID, int step, int score, int combo) { }
|
||||
@@ -256,6 +257,11 @@ void NetworkSyncManager::ReportNSSOnOff(int i)
|
||||
NetPlayerClient->SendPack((char*)m_packet.Data, m_packet.Position);
|
||||
}
|
||||
|
||||
CString NetworkSyncManager::GetServerName()
|
||||
{
|
||||
return m_ServerName;
|
||||
}
|
||||
|
||||
void NetworkSyncManager::ReportTiming(float offset, int PlayerNumber)
|
||||
{
|
||||
m_lastOffset[PlayerNumber] = offset;
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
void ReportStyle(); //Report to server the style, players, and names
|
||||
void ReportNSSOnOff(int i); //Report song selection screen on/off
|
||||
void StartRequest(short position); //Request a start. Block until granted.
|
||||
CString GetServerName();
|
||||
|
||||
//SMOnline stuff
|
||||
void SendSMOnline( PacketFunctions &PackData );
|
||||
|
||||
@@ -318,7 +318,6 @@ void PrefsManager::Init()
|
||||
m_sMemoryCardProfileSubdir = PRODUCT_NAME;
|
||||
m_iProductID = 1;
|
||||
|
||||
|
||||
FOREACH_CONST( IPreference*, *g_pvpSubscribers, p ) (*p)->LoadDefault();
|
||||
}
|
||||
|
||||
@@ -584,6 +583,10 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
|
||||
ini.GetValue( "Debug", "LogCheckpoints", m_bLogCheckpoints );
|
||||
ini.GetValue( "Debug", "ShowLoadingWindow", m_bShowLoadingWindow );
|
||||
|
||||
#if defined (WITHOUT_NETWORKING)
|
||||
#else
|
||||
ini.GetValue( "Options", "LastConnectedServer", m_sLastServer );
|
||||
#endif
|
||||
|
||||
FOREACH( IPreference*, *g_pvpSubscribers, p ) (*p)->ReadFrom( ini );
|
||||
}
|
||||
@@ -830,6 +833,11 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
||||
ini.SetValue( "Debug", "LogCheckpoints", m_bLogCheckpoints );
|
||||
ini.SetValue( "Debug", "ShowLoadingWindow", m_bShowLoadingWindow );
|
||||
|
||||
#if defined (WITHOUT_NETWORKING)
|
||||
#else
|
||||
ini.SetValue( "Options", "LastConnectedServer", m_sLastServer );
|
||||
#endif
|
||||
|
||||
FOREACH_CONST( IPreference*, *g_pvpSubscribers, p ) (*p)->WriteTo( ini );
|
||||
|
||||
ini.WriteFile( STEPMANIA_INI_PATH );
|
||||
|
||||
@@ -283,6 +283,13 @@ public:
|
||||
|
||||
void ResetToFactoryDefaults();
|
||||
|
||||
#if defined (WITHOUT_NETWORKING)
|
||||
#else
|
||||
/* Network Info */
|
||||
CString m_sLastServer;
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// For self-registering prefs
|
||||
//
|
||||
|
||||
@@ -12,18 +12,12 @@
|
||||
#include "ScreenPrompt.h"
|
||||
#include "NetworkSyncServer.h"
|
||||
|
||||
|
||||
enum {
|
||||
PO_CONNECTION,
|
||||
PO_SERVER,
|
||||
NUM_NETWORK_OPTIONS_LINES
|
||||
};
|
||||
|
||||
enum {
|
||||
NO_DISCONNECT=0,
|
||||
NO_CONNECT
|
||||
};
|
||||
|
||||
enum {
|
||||
NO_STOP_SERVER=0,
|
||||
NO_START_SERVER
|
||||
@@ -41,15 +35,18 @@ ScreenNetworkOptions::ScreenNetworkOptions( CString sClassName ) : ScreenOptions
|
||||
{
|
||||
LOG->Trace( "ScreenNetworkOptions::ScreenNetworkOptions()" );
|
||||
|
||||
m_sClassName = sClassName;
|
||||
|
||||
g_NetworkOptionsLines[PO_CONNECTION].choices.clear();
|
||||
g_NetworkOptionsLines[PO_CONNECTION].choices.push_back("Disconnect");
|
||||
g_NetworkOptionsLines[PO_CONNECTION].choices.push_back("Connect...");
|
||||
if ( NSMAN->useSMserver )
|
||||
g_NetworkOptionsLines[PO_CONNECTION].choices.push_back("Disconnect from "+NSMAN->GetServerName());
|
||||
else
|
||||
g_NetworkOptionsLines[PO_CONNECTION].choices.push_back("Connect...");
|
||||
|
||||
g_NetworkOptionsLines[PO_SERVER].choices.clear();
|
||||
g_NetworkOptionsLines[PO_SERVER].choices.push_back("Stop");
|
||||
g_NetworkOptionsLines[PO_SERVER].choices.push_back("Start...");
|
||||
|
||||
|
||||
Init(
|
||||
INPUTMODE_SHARE_CURSOR,
|
||||
g_NetworkOptionsLines,
|
||||
@@ -79,6 +76,11 @@ void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
|
||||
CString sNewName = ScreenTextEntry::s_sLastAnswer;
|
||||
NSMAN->PostStartUp(sNewName);
|
||||
NSMAN->DisplayStartupStatus();
|
||||
UpdateConnectStatus( );
|
||||
#if defined( WITHOUT_NETWORKING )
|
||||
#else
|
||||
PREFSMAN->m_sLastServer = ScreenTextEntry::s_sLastAnswer;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SM_ServerNameEnter:
|
||||
@@ -103,18 +105,17 @@ void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
|
||||
|
||||
void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
#if defined( WITHOUT_NETWORKING )
|
||||
#else
|
||||
switch( GetCurrentRow() )
|
||||
{
|
||||
case PO_CONNECTION:
|
||||
switch (m_Rows[GetCurrentRow()]->GetOneSharedSelection())
|
||||
{
|
||||
case NO_CONNECT:
|
||||
SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", "", NULL );
|
||||
break;
|
||||
case NO_DISCONNECT:
|
||||
if ( !NSMAN->useSMserver )
|
||||
SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", PREFSMAN->m_sLastServer );
|
||||
else {
|
||||
NSMAN->CloseConnection();
|
||||
SCREENMAN->SystemMessage("Disconnected from server.");
|
||||
break;
|
||||
UpdateConnectStatus( );
|
||||
}
|
||||
break;
|
||||
case PO_SERVER:
|
||||
@@ -135,17 +136,16 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
|
||||
default:
|
||||
ScreenOptions::MenuStart( pn, type );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScreenNetworkOptions::ImportOptions()
|
||||
void ScreenNetworkOptions::ImportOptions() { }
|
||||
void ScreenNetworkOptions::ExportOptions() { }
|
||||
|
||||
void ScreenNetworkOptions::UpdateConnectStatus( )
|
||||
{
|
||||
|
||||
SCREENMAN->SetNewScreen( m_sClassName );
|
||||
}
|
||||
void ScreenNetworkOptions::ExportOptions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,6 +18,10 @@ private:
|
||||
|
||||
void GoToNextState();
|
||||
void GoToPrevState();
|
||||
|
||||
void UpdateConnectStatus();
|
||||
|
||||
CString m_sClassName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user