mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-13 07:05:12 +01:00
Move ip to str helper to utils, exit menu when selected + various fixes
This commit is contained in:
parent
129bfe26e9
commit
a610759cd0
@ -76,6 +76,7 @@ public:
|
|||||||
TheC64->network_connection_type = CONNECT;
|
TheC64->network_connection_type = CONNECT;
|
||||||
TheC64->network->ConnectToBroker();
|
TheC64->network->ConnectToBroker();
|
||||||
}
|
}
|
||||||
|
Gui::gui->exitMenu();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
printf("Send message NYI\n"); // FIXME! Send message
|
printf("Send message NYI\n"); // FIXME! Send message
|
||||||
|
@ -10,29 +10,6 @@
|
|||||||
|
|
||||||
class NetworkUserView;
|
class NetworkUserView;
|
||||||
|
|
||||||
const char *ip_to_str(uint8 *ip_in)
|
|
||||||
{
|
|
||||||
char *out = (char *)xmalloc(24);
|
|
||||||
int ip[4];
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
char tmp[3];
|
|
||||||
char *endp;
|
|
||||||
|
|
||||||
tmp[0] = ip_in[i * 2];
|
|
||||||
tmp[1] = ip_in[i * 2 + 1];
|
|
||||||
tmp[2] = '\0';
|
|
||||||
ip[i] = strtoul(tmp, &endp, 16);
|
|
||||||
panic_if (endp == (const char*)tmp,
|
|
||||||
"Could not convert ip to str.\n");
|
|
||||||
}
|
|
||||||
sprintf(out, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class PeerInfo
|
class PeerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -53,6 +30,7 @@ public:
|
|||||||
{
|
{
|
||||||
SDL_FreeSurface(this->scr);
|
SDL_FreeSurface(this->scr);
|
||||||
free((void*)this->name);
|
free((void*)this->name);
|
||||||
|
free((void*)this->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *getScreenshot()
|
SDL_Surface *getScreenshot()
|
||||||
@ -193,14 +171,15 @@ public:
|
|||||||
|
|
||||||
this->freePeers();
|
this->freePeers();
|
||||||
this->n_peers = peerList->n_peers;
|
this->n_peers = peerList->n_peers;
|
||||||
messages = (const char **)xmalloc( (peerList->n_peers + 1) *
|
messages = (const char **)xmalloc( (peerList->n_peers + 2) *
|
||||||
sizeof(const char*));
|
sizeof(const char*));
|
||||||
this->peers = (PeerInfo**)xrealloc((void*)this->peers,
|
this->peers = (PeerInfo**)xrealloc((void*)this->peers,
|
||||||
peerList->n_peers * sizeof(PeerInfo*));
|
peerList->n_peers * sizeof(PeerInfo*));
|
||||||
|
|
||||||
|
messages[0] = (const char *)xstrdup("None");
|
||||||
for (unsigned i = 0; i < peerList->n_peers; i++)
|
for (unsigned i = 0; i < peerList->n_peers; i++)
|
||||||
{
|
{
|
||||||
messages[i] = (const char*)xstrdup((char*)ps->name);
|
messages[i + 1] = (const char*)xstrdup((char*)ps->name);
|
||||||
this->peers[i] = new PeerInfo(&peerList->peers[i]);
|
this->peers[i] = new PeerInfo(&peerList->peers[i]);
|
||||||
}
|
}
|
||||||
this->setText(messages);
|
this->setText(messages);
|
||||||
@ -218,16 +197,15 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
TheC64->network->CancelPeerSelection();
|
TheC64->network->CancelPeerSelection();
|
||||||
Gui::gui->popView();
|
Gui::gui->exitMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void hoverCallback(int which)
|
virtual void hoverCallback(int which)
|
||||||
{
|
{
|
||||||
panic_if(which >= (int)this->n_peers,
|
if (which <= 0 || which > (int)this->n_peers)
|
||||||
"Which is impossibly large: %d vs %d\n",
|
return;
|
||||||
which, this->n_peers);
|
|
||||||
|
|
||||||
this->infoBox->setPeerInfo(this->peers[which]);
|
this->infoBox->setPeerInfo(this->peers[which - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void escapeCallback(int which)
|
virtual void escapeCallback(int which)
|
||||||
|
@ -320,3 +320,25 @@ void highlight_background(SDL_Surface *where, Font *font,
|
|||||||
dst = (SDL_Rect){bg_x_end, bg_y_start, 0,0};
|
dst = (SDL_Rect){bg_x_end, bg_y_start, 0,0};
|
||||||
SDL_BlitSurface(bg_right, NULL, where, &dst);
|
SDL_BlitSurface(bg_right, NULL, where, &dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *ip_to_str(uint8_t *ip_in)
|
||||||
|
{
|
||||||
|
char *out = (char *)xmalloc(24);
|
||||||
|
int ip[4];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
char tmp[3];
|
||||||
|
char *endp;
|
||||||
|
|
||||||
|
tmp[0] = ip_in[i * 2];
|
||||||
|
tmp[1] = ip_in[i * 2 + 1];
|
||||||
|
tmp[2] = '\0';
|
||||||
|
ip[i] = strtoul(tmp, &endp, 16);
|
||||||
|
panic_if (endp == (const char*)tmp,
|
||||||
|
"Could not convert ip to str.\n");
|
||||||
|
}
|
||||||
|
sprintf(out, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
@ -84,4 +84,6 @@ void highlight_background(SDL_Surface *where, Font *font,
|
|||||||
SDL_Surface *bg_left, SDL_Surface *bg_middle, SDL_Surface *bg_right,
|
SDL_Surface *bg_left, SDL_Surface *bg_middle, SDL_Surface *bg_right,
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
|
|
||||||
|
const char *ip_to_str(uint8_t *ip_in);
|
||||||
|
|
||||||
#endif /* __UTILS_H__ */
|
#endif /* __UTILS_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user