Added the menu function quit

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-05-17 16:54:16 +00:00
parent a25364a98c
commit 7fd61053ae
4 changed files with 19 additions and 1 deletions

View File

@ -591,3 +591,17 @@ wmud_client_send(wmudClient *client, const gchar *fmt, ...)
g_string_free(buf, TRUE); g_string_free(buf, TRUE);
} }
void
wmud_client_quitanswer(wmudClient *client, gboolean answer)
{
if (answer)
{
wmud_client_send(client, "Borgo sad... :(\r\n");
wmud_client_close(client, TRUE);
}
else
{
wmud_client_send(client, "Good boy!\r\n");
client->state = WMUD_CLIENT_STATE_MENU;
}
}

View File

@ -64,5 +64,6 @@ extern GSList *clients;
gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err); gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err);
void wmud_client_send(wmudClient *client, const gchar *fmt, ...); void wmud_client_send(wmudClient *client, const gchar *fmt, ...);
void wmud_client_quitanswer(wmudClient *client, gboolean answer);
#endif #endif

View File

@ -302,6 +302,7 @@ wmud_interpret_game_command(wmudClient *client)
WMUD_COMMAND(quit) WMUD_COMMAND(quit)
{ {
wmud_client_send(client, "Are you sure you want to get back to that freaky other reality? [y/N] "); wmud_client_send(client, "Are you sure you want to get back to that freaky other reality? [y/N] ");
client->state = WMUD_CLIENT_STATE_QUITWAIT; client->state = WMUD_CLIENT_STATE_YESNO;
client->yesNoCallback = wmud_client_quitanswer;
} }

View File

@ -183,7 +183,9 @@ WMUD_MENU_COMMAND(change_name)
WMUD_MENU_COMMAND(quit) WMUD_MENU_COMMAND(quit)
{ {
client->state = WMUD_CLIENT_STATE_YESNO;
wmud_client_send(client, "Are you sure you want to get back to the real world? [y/N] "); wmud_client_send(client, "Are you sure you want to get back to the real world? [y/N] ");
client->yesNoCallback = wmud_client_quitanswer;
} }
WMUD_MENU_COMMAND(redisplay_menu) WMUD_MENU_COMMAND(redisplay_menu)