Fixed first version of menu synchronisation.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2223 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
78f8c60934
commit
e8f6f0f708
@ -40,6 +40,7 @@
|
|||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
|
#include "network_manager.hpp"
|
||||||
|
|
||||||
GameManager* game_manager = 0;
|
GameManager* game_manager = 0;
|
||||||
|
|
||||||
@ -103,6 +104,7 @@ void GameManager::run()
|
|||||||
music_on = true;
|
music_on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network_manager->update(dt);
|
||||||
if (race_manager->raceIsActive())
|
if (race_manager->raceIsActive())
|
||||||
{
|
{
|
||||||
music_on = false;
|
music_on = false;
|
||||||
|
@ -393,6 +393,7 @@ void CharSel::select()
|
|||||||
|
|
||||||
if(network_manager->getMode()==NetworkManager::NW_CLIENT)
|
if(network_manager->getMode()==NetworkManager::NW_CLIENT)
|
||||||
{
|
{
|
||||||
|
menu_manager->pushMenu(MENUID_START_RACE_FEEDBACK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -17,22 +17,28 @@
|
|||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
|
#include "start_race_feedback.hpp"
|
||||||
#include "widget_manager.hpp"
|
#include "widget_manager.hpp"
|
||||||
#include "race_manager.hpp"
|
#include "race_manager.hpp"
|
||||||
#include "translation.hpp"
|
#include "translation.hpp"
|
||||||
|
#include "network_manager.hpp"
|
||||||
#include "start_race_feedback.hpp"
|
|
||||||
|
|
||||||
enum WidgetTokens
|
enum WidgetTokens
|
||||||
{
|
{
|
||||||
WTOK_MSG
|
WTOK_MSG
|
||||||
};
|
};
|
||||||
|
|
||||||
StartRaceFeedback::StartRaceFeedback() : m_updated( false )
|
StartRaceFeedback::StartRaceFeedback()
|
||||||
{
|
{
|
||||||
|
m_state = network_manager->getMode()==NetworkManager::NW_NONE ? SRF_LOADING : SRF_NETWORK;
|
||||||
|
|
||||||
//Add some feedback so people know they are going to start the race
|
//Add some feedback so people know they are going to start the race
|
||||||
widget_manager->reset();
|
widget_manager->reset();
|
||||||
widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Loading race...") );
|
if(m_state==SRF_NETWORK)
|
||||||
|
widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Synchronising network...") );
|
||||||
|
else
|
||||||
|
widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Loading race...") );
|
||||||
|
|
||||||
widget_manager->layout(WGT_AREA_ALL);
|
widget_manager->layout(WGT_AREA_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +54,19 @@ void StartRaceFeedback::update(float DELTA)
|
|||||||
{
|
{
|
||||||
widget_manager->update(0.0f);
|
widget_manager->update(0.0f);
|
||||||
|
|
||||||
//I consider that in this case, a static variable is cleaner than a
|
// Now the text is being displayed,
|
||||||
//member variable of this class. -Coz
|
if(m_state==SRF_NETWORK)
|
||||||
if( m_updated == true ) race_manager->startNew();
|
{
|
||||||
else m_updated = true;
|
if(network_manager->getMode()==NetworkManager::NW_SERVER)
|
||||||
|
network_manager->sendRaceInformationToClients();
|
||||||
|
else
|
||||||
|
network_manager->waitForRaceInformation();
|
||||||
|
m_state = SRF_LOADING;
|
||||||
|
widget_manager->setWgtText(WTOK_MSG, _("Loading race...") );
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool updated=false;
|
||||||
|
if( updated == true ) race_manager->startNew();
|
||||||
|
else updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
|
|
||||||
class StartRaceFeedback: public BaseGUI
|
class StartRaceFeedback: public BaseGUI
|
||||||
{
|
{
|
||||||
bool m_updated;
|
enum {SRF_NETWORK, SRF_LOADING} m_state;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StartRaceFeedback();
|
StartRaceFeedback();
|
||||||
~StartRaceFeedback();
|
~StartRaceFeedback();
|
||||||
|
@ -126,6 +126,7 @@ void cmdLineHelp (char* invocation)
|
|||||||
int handleCmdLine(int argc, char **argv)
|
int handleCmdLine(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
char s[80];
|
||||||
for(int i=1; i<argc; i++)
|
for(int i=1; i<argc; i++)
|
||||||
{
|
{
|
||||||
if(argv[i][0] != '-') continue;
|
if(argv[i][0] != '-') continue;
|
||||||
@ -172,9 +173,10 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
network_manager->setPort(n);
|
network_manager->setPort(n);
|
||||||
}
|
}
|
||||||
else if( sscanf(argv[i], "--numclients=%d", &n) )
|
else if( sscanf(argv[i], "--client=%s", s) )
|
||||||
{
|
{
|
||||||
network_manager->setNumClients(n);
|
network_manager->setMode(NetworkManager::NW_CLIENT);
|
||||||
|
network_manager->setServerIP(s);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
||||||
@ -531,7 +533,8 @@ int main(int argc, char *argv[] )
|
|||||||
|
|
||||||
if(!network_manager->initialiseConnections())
|
if(!network_manager->initialiseConnections())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Problems initialising network connections, aborting.\n");
|
fprintf(stderr, "Problems initialising network connections,\n"
|
||||||
|
"Running in non-network mode.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not replaying
|
// Not replaying
|
||||||
|
@ -125,7 +125,7 @@ bool NetworkManager::initClient()
|
|||||||
if (enet_host_service (m_host, & event, 5000) > 0 &&
|
if (enet_host_service (m_host, & event, 5000) > 0 &&
|
||||||
event.type == ENET_EVENT_TYPE_CONNECT)
|
event.type == ENET_EVENT_TYPE_CONNECT)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Connection to %s:%d succeeded.",
|
fprintf(stderr, "Connection to %s:%d succeeded.\n",
|
||||||
m_server_address.c_str(), m_port);
|
m_server_address.c_str(), m_port);
|
||||||
enet_host_service(m_host, &event, 1000);
|
enet_host_service(m_host, &event, 1000);
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ bool NetworkManager::initClient()
|
|||||||
/* had run out without any significant event. */
|
/* had run out without any significant event. */
|
||||||
enet_peer_reset (peer);
|
enet_peer_reset (peer);
|
||||||
|
|
||||||
fprintf(stderr, "Connection to '%s:%d' failed.",
|
fprintf(stderr, "Connection to '%s:%d' failed.\n",
|
||||||
m_server_address.c_str(), m_port);
|
m_server_address.c_str(), m_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,12 +207,14 @@ void NetworkManager::update(float dt)
|
|||||||
*/
|
*/
|
||||||
void NetworkManager::sendKartsInformationToServer()
|
void NetworkManager::sendKartsInformationToServer()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "Client sending kart information to server\n");
|
||||||
} // sendKartsInformationToServer
|
} // sendKartsInformationToServer
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Receive and store the information from sendKartsInformation()
|
/** Receive and store the information from sendKartsInformation()
|
||||||
*/
|
*/
|
||||||
void NetworkManager::waitForKartsInformation()
|
void NetworkManager::waitForKartsInformation()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "Server receiving all kart information\n");
|
||||||
} // waitForKartsInformation
|
} // waitForKartsInformation
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -220,6 +222,7 @@ void NetworkManager::waitForKartsInformation()
|
|||||||
*/
|
*/
|
||||||
void NetworkManager::sendRaceInformationToClients()
|
void NetworkManager::sendRaceInformationToClients()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "server sending race_manager information to all clients\n");
|
||||||
} // sendRaceInformationToClients
|
} // sendRaceInformationToClients
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -227,5 +230,6 @@ void NetworkManager::sendRaceInformationToClients()
|
|||||||
*/
|
*/
|
||||||
void NetworkManager::waitForRaceInformation()
|
void NetworkManager::waitForRaceInformation()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "Client waiting for race information\n");
|
||||||
} // waitForRaceInformation
|
} // waitForRaceInformation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user