mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-04-22 09:51:24 +02:00
Implement the user interface for the network support. You can now
connect from the menu as well and also abort connections.
This commit is contained in:
parent
4e2de3ac50
commit
34359ec7bb
@ -80,15 +80,10 @@ void C64::c64_ctor1(void)
|
||||
|
||||
if (fixme_tmp_network_server) {
|
||||
int i;
|
||||
this->peer = new Network("localhost", this->server_port, true);
|
||||
this->peer = new Network(this->server_hostname, this->server_port, true);
|
||||
this->network_connection_type = MASTER;
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
printf("Waiting for connection, try %d of 20\n", i+1);
|
||||
if (this->peer->Connect() == true)
|
||||
break;
|
||||
}
|
||||
if (i == 20)
|
||||
printf("Waiting for connection\n");
|
||||
if (this->peer->Connect() == false)
|
||||
{
|
||||
printf("No client connected. Bye\n");
|
||||
delete this->peer;
|
||||
@ -100,7 +95,12 @@ void C64::c64_ctor1(void)
|
||||
strcpy(this->server_hostname, fixme_tmp_network_client);
|
||||
this->peer = new Network(this->server_hostname, this->server_port, false);
|
||||
this->network_connection_type = CLIENT;
|
||||
this->peer->Connect();
|
||||
if (this->peer->Connect() == false)
|
||||
{
|
||||
printf("Could not connect to server. Bye\n");
|
||||
delete this->peer;
|
||||
this->peer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,15 +345,17 @@ void C64::networking_menu(Prefs *np)
|
||||
this->server_port = atoi(m);
|
||||
}
|
||||
}
|
||||
else if (opt == 0) {
|
||||
else if (opt == 3 || opt == 4) {
|
||||
bool master = (opt == 3);
|
||||
|
||||
this->peer = new Network(this->server_hostname,
|
||||
this->server_port, true);
|
||||
this->network_connection_type = MASTER;
|
||||
}
|
||||
else if (opt == 3) {
|
||||
this->peer = new Network(this->server_hostname,
|
||||
this->server_port, false);
|
||||
this->network_connection_type = CLIENT;
|
||||
this->server_port, master);
|
||||
this->network_connection_type = master ? MASTER : CLIENT;
|
||||
if (this->peer->Connect() == false)
|
||||
{
|
||||
delete this->peer;
|
||||
this->peer = NULL;
|
||||
}
|
||||
}
|
||||
} while (opt == 1 || opt == 2);
|
||||
|
||||
|
@ -970,8 +970,29 @@ bool Network::ConnectFSM()
|
||||
|
||||
bool Network::Connect()
|
||||
{
|
||||
for (int i = 0; i < this->is_master ? 120 : 10; i++ )
|
||||
while (1)
|
||||
{
|
||||
SDL_FillRect(real_screen, 0, SDL_MapRGB(real_screen->format,
|
||||
0x00, 0x80, 0x80));
|
||||
menu_print_font(real_screen, 255,255,0, 20, 20,
|
||||
"Connecting... Hold Esc or 1 to abort");
|
||||
SDL_Flip(real_screen);
|
||||
#if defined(GEKKO)
|
||||
WPADData *wpad, *wpad_other;
|
||||
|
||||
WPAD_ScanPads();
|
||||
|
||||
wpad = WPAD_Data(WPAD_CHAN_0);
|
||||
wpad_other = WPAD_Data(WPAD_CHAN_1);
|
||||
remote_keys = wpad->btns_d | wpad_other->btns_d;
|
||||
|
||||
if (remote_keys & WPAD_BUTTON_1)
|
||||
return false;
|
||||
#endif
|
||||
SDL_PumpEvents();
|
||||
if (SDL_GetKeyState(NULL)[SDLK_ESCAPE])
|
||||
return false;
|
||||
|
||||
if (this->network_connection_state == CONN_CONNECTED)
|
||||
return true;
|
||||
/* Run the state machine */
|
||||
|
Loading…
x
Reference in New Issue
Block a user