Пример #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;
}
Пример #2
0
static int dialog_loadgame_load(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data)
{
    int slot = saveload_selected;

    if (get_slots() & (1 << slot))
    {
        set_pgn_slot(slot);
        set_set_loading(TRUE);
        gg_dialog_close();
        gg_dialog_close();
    }
    return 1;
}
Пример #3
0
static int dialog_close_cb(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data) {
	option_t *option = config_get_option("first_engine");
	free(option->string);
	option->string = strdup(gg_entry_get_text(GG_ENTRY(entry)));
	config_save();
	gg_dialog_close();
	return 1;
}
Пример #4
0
static int dialog_saveload_change(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data)
{
    gg_widget_t *select = GG_WIDGET(extra_data);
    saveload_selected=GG_OPTION(select)->sel;

    gg_dialog_close();
    changing_slot=TRUE;
    gg_dialog_open(dialog_saveload_create(gg_widget_find_dialog(widget)->parent_dialog, change_saving));
    changing_slot=FALSE;
    return 1;
}
Пример #5
0
int gg_dialog_input(gg_widget_t *widget, gg_event_t event)
{
	gg_dialog_t *dialog = GG_DIALOG(widget);
	gg_widget_t *child = gg_bin_get_child(GG_BIN(widget));
	int x, y;

	if (dialog->flags & GG_DIALOG_HIDDEN)
		return 0;

	if (!dialog->modal && event.type == GG_EVENT_KEY && event.key == GG_KEY_ESCAPE )
		gg_dialog_close();

	if (!dialog->modal && event.type == GG_EVENT_MOUSE && event.mouse.type == GG_MOUSE_BUTTON_DOWN &&
		event.mouse.button == 2 )
		gg_dialog_close();

	gg_dialog_get_screen_pos(dialog, &x, &y);

	if (event.type == GG_EVENT_MOUSE)
	{
		int size = 0;

		event.mouse.x -= x;
		event.mouse.y -= y;

		if (dialog->style.textured)
			gg_system_get_image_size(dialog->style.border.image[0], &size, NULL);

		if (event.mouse.type == GG_MOUSE_BUTTON_DOWN
			&& event.mouse.button == 0)
		{
			if (dialog->title)
			{
				int text_height;
				int titlebar_height;
				gg_system_get_string_size(dialog->title, NULL, &text_height);
				titlebar_height = text_height * GG_DIALOG_TITLE_FACT;

				dialog->dialog_state |= GG_DIALOG_LEFT_BUTTON;

				/* Mouse click outside of dialog */
				if (event.mouse.y >= dialog->height || event.mouse.y < 0
					|| event.mouse.x >= dialog->width || event.mouse.x < 0)
					return 0;

				gg_dialog_set_active(dialog);

				/* Title bar click */
				if (event.mouse.y >= dialog->height - size - titlebar_height
					&& event.mouse.y < dialog->height - size
					&& event.mouse.x >= size
					&& event.mouse.x < dialog->width - size)
				{
					dialog->dialog_state |= GG_DIALOG_MOVING;
					dialog->movement_org_x = event.mouse.x;
					dialog->movement_org_y = event.mouse.y;
					return 1;
				}
			}
		}
		else if (event.mouse.type == GG_MOUSE_BUTTON_UP
			&& event.mouse.button == 0)
		{
			if (dialog->title)
			{
				dialog->dialog_state &= ~GG_DIALOG_LEFT_BUTTON;
				if (dialog->dialog_state & GG_DIALOG_MOVING)
				{
					dialog->dialog_state &= ~GG_DIALOG_MOVING;
					return 1;
				}
			}
		}

		if ((event.mouse.type == GG_MOUSE_MOVE)
			&& (dialog->dialog_state & GG_DIALOG_MOVING))
		{
			int xoff = dialog->width * dialog->pos.x_align;
			int yoff = dialog->height * dialog->pos.y_align;

			gg_dialog_set_position(dialog, x + event.mouse.x - dialog->movement_org_x + xoff,
								   y + event.mouse.y - dialog->movement_org_y + yoff,
								   dialog->pos.x_align, dialog->pos.y_align);
		}

		event.mouse.x -= size + dialog->style.hor_pad;
		event.mouse.y -= size + dialog->style.vert_pad;

		if (!(event.mouse.type == GG_MOUSE_MOVE
			&& dialog->dialog_state & GG_DIALOG_LEFT_BUTTON))
		{
			gg_widget_t *child = gg_bin_get_child(GG_BIN(dialog));

			if (event.mouse.x >= 0 && event.mouse.x < child->width_a
				&& event.mouse.y >= 0 && event.mouse.y < child->height_a)
				dialog->set_focus_pos(GG_WIDGET(dialog), event.mouse.x, event.mouse.y);
		}
	}

	if (child->input)
		return child->input(child, event);

	return 0;
}
Пример #6
0
static int dialog_close_cb(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data)
{
    gg_dialog_close();
    return 1;
}