Ejemplo n.º 1
0
static int dialog_savegame_save(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data)
{
    int save_good=TRUE;

    /* Close the dialogs.. */
    gg_dialog_close();
    gg_dialog_close();

    if (!game_save( saveload_selected ))
    {
        write_save_xml( saveload_selected );
    }
    else
        save_good=FALSE;

#ifdef _arch_dreamcast
    if (dc_store_savegames())
        save_good=FALSE;
#endif

    if ( save_good )
        show_message_dialog( "Save successful" );
    else
        show_message_dialog( "Save failed" );

    return 1;
}
Ejemplo n.º 2
0
void on_receive (int fd)
{
	struct message msg;

	while (1)
	{
		ssize_t len = get_message (&msg);
		if (len < 0)
		{
			break;
		}
		else if (len == 0)
		{
			show_message_dialog (GTK_MESSAGE_ERROR, "服务器掉线了\n");
			exit (-1);
		}
		else
		{
			g_print ("on_recive: msgtype = %d\n",msg.type);
			gdk_threads_enter ();
			services[msg.type] (fd, &msg);
			gdk_threads_leave ();
		}
	}
}
Ejemplo n.º 3
0
void on_join_room (int fd, struct message *msg)
{
	printf ("on_join_room\n");
	if (msg->buff[0] == 2)
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "房间不存在");
		return ;
	}
	if (msg->buff[0] == 1)
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "房间人满");
		return ;
	}
	hide_main_dialog ();
	show_room_dialog ();
	init_room_dialog (msg->buff+1);
}
Ejemplo n.º 4
0
void on_register (int fd, struct message *msg)
{
	printf ("on_register\n");
	printf ("msg.type = %d\n", msg->type);
	printf ("msg.buff = %d\n", msg->buff[0]);

	if (msg->buff[0] == 0)
	{
		show_message_dialog (GTK_MESSAGE_INFO, "注册成功!");
		hide_register_dialog ();
		show_login_dialog ();
	}
	else
	{
		show_message_dialog (GTK_MESSAGE_ERROR,  "该用户名已被注册,请选择其他用户");
	}
}
Ejemplo n.º 5
0
void on_exit_room (int fd, struct message *msg)
{
	printf ("on_exit_room\n");
	if (get_color () == BLACK)
	{
		struct message msg;
		msg.type = EXIT_ROOM;
		sprintf (msg.buff, "%s", get_room_number ());
		send_message (&msg);

		show_message_dialog (GTK_MESSAGE_ERROR, "游戏已被房主解散");
		hide_room_dialog ();
		show_main_dialog ();
	}
	else
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "对方已经退出房间");
		opp_exit_room ();
	}
}
Ejemplo n.º 6
0
void on_create_room (int fd, struct message *msg)
{
	printf ("on_create_room\n");
	if (msg->buff[0])
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "没有空闲的房间!\n");
		return ;
	}
	hide_main_dialog ();
	show_room_dialog ();
	init_room_dialog (msg->buff+1);
}
Ejemplo n.º 7
0
void on_quick_start_game (int fd, struct message *msg)
{
	printf ("on_quick_start_game\n");
	if (msg->buff[0] == 0)
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "系统找不到匹配的房间");
		return;
	}
	hide_main_dialog ();
	show_room_dialog ();
	init_room_dialog (msg->buff+1);
	start_game ();
}
Ejemplo n.º 8
0
static GtkDialog *
show_ok_dialog (const char *primary_text,
		const char *secondary_text,
		GtkMessageType type,
		GtkWindow *parent)
{  
	GtkDialog *dialog;

	dialog = show_message_dialog (primary_text, secondary_text, type,
				      GTK_BUTTONS_OK, NULL, parent);
	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
	
	return dialog;
}
Ejemplo n.º 9
0
void on_login (int fd, struct message *msg)
{
	printf ("on_login\n");
	printf ("msg.type = %d\n", msg->type);
	printf ("msg.buff = %d\n", msg->buff[0]);
	if (msg->buff[0] == 0)
	{
		hide_login_dialog ();
		create_main_dialog ();
		show_main_dialog ();
		msg->type = GET_ROOM_INFO;
		send_message (msg);
		//play_sound ("sound/bg.mp3",0);
	}
	else if (msg->buff[0] == 1)
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "密码错误!");
	}
	else
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "用户不存在!");
	}
}
Ejemplo n.º 10
0
void on_draw_game_feedback (int fd, struct message *msg)
{
	printf ("on_draw_game_feedback \n");
	int result;
	char number[32];
	sscanf (msg->buff, "%s %d", number, &result);
	if (result == 1)
	{
		/*  对方同意和棋 */
		game_draw ();
	}
	else 
		show_message_dialog (GTK_MESSAGE_ERROR, "对方拒绝您的请求");
}
Ejemplo n.º 11
0
void on_regret_feedback (int fd, struct message *msg)
{
	printf ("on_regret_feedback\n");
	int result;
	char number[32];
	sscanf (msg->buff, "%s %d", number, &result);
	if (result == 1)
	{
		/*  对方同意悔棋,把棋盘恢复到上一步的局面 */
		set_turn ();
		restore_chessbord ();
		min_step ();
	}
	else 
		show_message_dialog (GTK_MESSAGE_ERROR, "对方拒绝您的请求");
}
Ejemplo n.º 12
0
GtkDialog *
eel_show_error_dialog_with_details (const char *primary_text,
				    const char *secondary_text,
				    const char *detailed_error_message,
				    GtkWindow *parent)
{
	GtkDialog *dialog;

	g_return_val_if_fail (primary_text != NULL, NULL);
	g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);

	if (detailed_error_message == NULL
	    || strcmp (primary_text, detailed_error_message) == 0) {
		return eel_show_error_dialog (primary_text, secondary_text, parent);
	}
	
	dialog = show_message_dialog (primary_text, 
				      secondary_text,
				      GTK_MESSAGE_ERROR,
				      GTK_BUTTONS_OK, detailed_error_message,
				      parent);
	return dialog;
}
Ejemplo n.º 13
0
GtkDialog *
eel_show_info_dialog_with_details (const char *primary_text,
				   const char *secondary_text,
				   const char *detailed_info,
				   GtkWindow *parent)
{
	GtkDialog *dialog;

	if (detailed_info == NULL
	    || strcmp (primary_text, detailed_info) == 0) {
		return eel_show_info_dialog (primary_text, secondary_text, parent);
	}

	dialog = show_message_dialog (primary_text,
				      secondary_text,
				      GTK_MESSAGE_INFO, 
				      GTK_BUTTONS_OK,
				      detailed_info,
				      parent);

	return dialog;

}