Definition in file MainMultiplay.cpp.
#include "Network.h"
#include "Sound.h"
#include "Typer.h"
#include "..\AEngine\AEngine.h"
#include "Overhead.h"
#include "MainFuncs.h"
#include "Globals.h"
Include dependency graph for MainMultiplay.cpp:

Go to the source code of this file.
Namespaces | |
| namespace | Steps |
Functions | |
| Box | butMultiName (0.117f, 0.168f, 0.466f, 0.229f) |
| Box | butMultiHost (0.120f, 0.258f, 0.324f, 0.305f) |
| Box | butMultiJoin (0.119f, 0.349f, 0.325f, 0.402f) |
| Box | butMultiIP (0.375f, 0.345f, 0.723f, 0.405f) |
| Box | butMultiChatMsg (0.394f, 0.845f, 0.825f, 0.905f) |
| Box | butMultiChat (0.852f, 0.845f, 0.953f, 0.900f) |
| Box | butMultiLaunch (0.332f, 0.921f, 0.588f, 0.981f) |
| Box | butMultiAbort (0.667f, 0.921f, 0.794f, 0.981f) |
| void | switchToMultiplayMenu () |
| void | processIncomingMessages () |
| void | updateMultiplayMenu () |
| void | renderMultiplayMenu () |
Variables | |
| Typer * | pTyper |
| Typer | typerName |
| Typer | typerIP |
| Typer | typerChatMsg |
| int | step |
| list< string > | chatLog |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
||||||||||||||||||||
|
Referenced by renderMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 71 of file MainMultiplay.cpp. References chatLog, NetworkMessages::COMMAND_CHAT(), NetworkMessages::COMMAND_START_GAME(), NetworkSubsystem::enQueueMsg(), net_recv(), Overhead::overhead_init(), step, and sys_setRandSeed(). Referenced by updateMultiplayMenu().
00072 {
00073 if( step != Steps::readyToLaunch ) return; // no network connection yet
00074
00075 string cmd;
00076 while( (cmd=net_recv()).length() > 0 )
00077 {
00078 istringstream strm(cmd.c_str());
00079
00080 string action;
00081 strm >> action;
00082 if (action == COMMAND_START_GAME)
00083 {
00084 string tmp;
00085 strm >> tmp; //commitTime string
00086 strm >> tmp; //commitTime int
00087 strm >> tmp; //RANDOM_SEED_VALUE
00088 int seed;
00089 strm >> seed;
00090 sys_setRandSeed(seed);
00091
00092 overhead_init(); // switch to overhead
00093 mode = MainModes::overhead;
00094 }
00095 else if (action == COMMAND_CHAT) // a chat msg
00096 {
00097 string msg;
00098 getline(strm,msg);
00099 chatLog.push_back( msg );
00100 }
00101 else
00102 NetworkSubsystem::enQueueMsg(cmd);
00103 }
00104 }
|
|
|
Definition at line 192 of file MainMultiplay.cpp. References Globals::artWork, butMultiAbort(), butMultiChat(), butMultiChatMsg(), butMultiHost(), butMultiIP(), butMultiJoin(), butMultiLaunch(), butMultiName(), chatLog, drawBox(), Typer::getString(), input_getMouseX(), input_getMouseY(), Box::isContain(), Box::left, net_getAllPlayers(), overlay_image(), overlay_text(), overlay_textOut(), pTyper, step, Box::top, typerChatMsg, typerIP, typerName, UINT, and Vec2D. Referenced by main_render().
00193 {
00194 Vec2D mouse( input_getMouseX(), input_getMouseY() ); // Mouse Cursor
00195 overlay_image( Globals::artWork->mouse, mouse+Vec2D(0.025f,0.025f), Vec2D(0.05f,0.05f), BlendModes::KEY );
00196
00197 // main menu screen
00198 overlay_image( artWork->main_multiplayTex, Vec2D(0.5f,0.5f), Vec2D(1.0f,1.0f) );
00199
00200 // highlight the button that the mouse is currently over
00201 if( butMultiName.isContain(mouse) ) drawBox( butMultiName, Colors::gray );
00202 if( butMultiHost.isContain(mouse) ) drawBox( butMultiHost, Colors::yellow );
00203 if( butMultiJoin.isContain(mouse) ) drawBox( butMultiJoin, Colors::yellow );
00204 if( butMultiIP.isContain(mouse) ) drawBox( butMultiIP, Colors::gray );
00205 if( butMultiChatMsg.isContain(mouse) ) drawBox( butMultiChatMsg, Colors::gray );
00206 if( butMultiChat.isContain(mouse) ) drawBox( butMultiChat, Colors::yellow );
00207 if( butMultiLaunch.isContain(mouse) ) drawBox( butMultiLaunch, Colors::yellow );
00208 if( butMultiAbort.isContain(mouse) ) drawBox( butMultiAbort, Colors::yellow );
00209
00210 // typer strings
00211 overlay_text() << typerName.getString();
00212 overlay_textOut( Vec2D( butMultiName.left+0.008f, butMultiName.top+0.017f), 1.0f, Colors::white );
00213 overlay_text() << typerIP.getString();
00214 overlay_textOut( Vec2D( butMultiIP.left+0.008f, butMultiIP.top+0.017f), 1.0f, Colors::white );
00215 overlay_text() << typerChatMsg.getString();
00216 overlay_textOut( Vec2D( butMultiChatMsg.left+0.008f, butMultiChatMsg.top+0.017f), 1.0f, Colors::white );
00217
00218 // selected typer
00219 if( pTyper==&typerName ) drawBox( butMultiName, Colors::white );
00220 if( pTyper==&typerIP ) drawBox( butMultiIP, Colors::white );
00221 if( pTyper==&typerChatMsg ) drawBox( butMultiChatMsg, Colors::white );
00222
00223 // player list
00224 if( step==Steps::readyToLaunch )
00225 {
00226 vector<string> &playersList = net_getAllPlayers();
00227 for( UINT i=0; i<playersList.size(); i++ )
00228 overlay_text() << playersList[i] << endl;
00229 overlay_textOut( Vec2D(0.065f, 0.522f) );
00230 }
00231
00232 // chat log
00233 while( chatLog.size()>9 ) chatLog.pop_front();
00234 for( list<string>::iterator iter=chatLog.begin(); iter!=chatLog.end(); iter++ )
00235 overlay_text() << (*iter) << endl;
00236 overlay_textOut( Vec2D( 0.440f, 0.527f ), 1.0f, Colors::white );
00237 }
|
|
|
Definition at line 59 of file MainMultiplay.cpp. References pTyper, step, typerChatMsg, typerIP, and typerName. Referenced by updateMainMenu().
|
|
|
Definition at line 106 of file MainMultiplay.cpp. References butMultiAbort(), butMultiChat(), butMultiChatMsg(), butMultiHost(), butMultiIP(), butMultiJoin(), butMultiLaunch(), butMultiName(), chatLog, NetworkMessages::COMMAND_CHAT(), NetworkMessages::COMMAND_START_GAME(), NetworkMessages::COMMIT_TIME(), Globals::currGameTick, Typer::getString(), Typer::input(), input_getMouseX(), input_getMouseY(), input_isKeyPressed(), input_isMouseLBClicked(), Box::isContain(), net_acceptMorePlayers(), net_amIServer(), net_connectToServer(), net_finalizeGame(), net_getSelfIP(), net_runAsServer(), net_send(), processIncomingMessages(), pTyper, NetworkMessages::RANDOM_SEED_VALUE(), step, switchToMainMenu(), sys_randInt(), typerChatMsg, typerIP, typerName, and Vec2D. Referenced by main_update().
00107 {
00108 Vec2D mouse( input_getMouseX(), input_getMouseY() );
00109 if( input_isMouseLBClicked() )
00110 {
00111 if( butMultiAbort.isContain(mouse) ) // abort
00112 {
00113 //net_disconnect();
00114 switchToMainMenu();
00115 step = Steps::enterName;
00116 return;
00117 }
00118
00119 // select typer
00120 if( butMultiName.isContain(mouse) ) pTyper = &typerName;
00121 if( butMultiIP.isContain(mouse) ) pTyper = &typerIP;
00122 if( butMultiChatMsg.isContain(mouse) ) pTyper = &typerChatMsg;
00123
00124 // host or join
00125 if(step==Steps::enterName && typerName.getString() != "Your Name") step = Steps::hostOrJoin;
00126 if( step==Steps::hostOrJoin )
00127 {
00128 if( butMultiHost.isContain(mouse) ) // Host Game
00129 {
00130 step = Steps::readyToLaunch;
00131 net_runAsServer( net_getSelfIP(), typerName.getString(), 8 );
00132 chatLog.push_back( "Hosting Process Complete. IP = " + net_getSelfIP() );
00133 }
00134
00135 if( butMultiJoin.isContain(mouse) ) // Join Game
00136 {
00137 if( !net_connectToServer( typerIP.getString(), typerName.getString() ))
00138 {
00139 chatLog.push_back( "Cannot Join with That Host" );
00140 return;
00141 }
00142 chatLog.push_back( "Joining Process Complete." );
00143 step = Steps::readyToLaunch;
00144 }
00145 }
00146
00147 // launch
00148 if( step==Steps::readyToLaunch && butMultiLaunch.isContain(mouse) )
00149 if( net_amIServer() )
00150 {
00151 currGameTick = 0;
00152 stringstream sstr;
00153
00154 if( net_amIServer() ) net_finalizeGame();
00155
00156 sstr << COMMAND_START_GAME << " " << COMMIT_TIME << " " << currGameTick << " " << RANDOM_SEED_VALUE << " " << sys_randInt();
00157 net_send(sstr.str());
00158 }
00159
00160 // chat by clicking Chat button
00161 if( step==Steps::readyToLaunch && butMultiChat.isContain(mouse) )
00162 {
00163 ostringstream strm;
00164 strm << COMMAND_CHAT << " [" << typerName.getString() << "] " << typerChatMsg.getString();
00165 net_send(strm.str());
00166 typerChatMsg = Typer();
00167 }
00168 }
00169
00170 // type to InputString Typer Box
00171 if( step==Steps::enterName || step==Steps::hostOrJoin ) // type name or ip
00172 if( pTyper==&typerName || pTyper==&typerIP )
00173 pTyper->input();
00174 if( step==Steps::readyToLaunch && pTyper==&typerChatMsg ) // type chat
00175 pTyper->input();
00176
00177 // chat by pressing enter while chat box is active
00178 if( step==Steps::readyToLaunch && input_isKeyPressed(KeyCodes::key_RETURN) && pTyper==&typerChatMsg )
00179 {
00180 ostringstream strm;
00181 strm << COMMAND_CHAT << " [" << typerName.getString() << "] " << typerChatMsg.getString();
00182 net_send(strm.str());
00183 typerChatMsg = Typer();
00184 }
00185
00186 // check for more players
00187 if( step==Steps::readyToLaunch ) net_acceptMorePlayers();
00188
00189 processIncomingMessages();
00190 }
|
|
|
Definition at line 56 of file MainMultiplay.cpp. Referenced by processIncomingMessages(), renderMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 35 of file MainMultiplay.cpp. Referenced by renderMultiplayMenu(), switchToMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 47 of file MainMultiplay.cpp. Referenced by processIncomingMessages(), renderMultiplayMenu(), switchToMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 36 of file MainMultiplay.cpp. Referenced by renderMultiplayMenu(), switchToMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 36 of file MainMultiplay.cpp. Referenced by renderMultiplayMenu(), switchToMultiplayMenu(), and updateMultiplayMenu(). |
|
|
Definition at line 36 of file MainMultiplay.cpp. Referenced by renderMultiplayMenu(), switchToMultiplayMenu(), and updateMultiplayMenu(). |
1.3-rc2