Exemplo n.º 1
0
static void open_note_tab_continued(int id)
{
	int tf_x = 10;
	int tf_y = 45;
	int tf_width = notepad_win_x_len - 20;
	int tf_height = notepad_win_y_len - 80;
	int tab;

	note_list[id].window = tab_add (notepad_win, note_tabcollection_id, note_list[id].name, 0, 1, 0);
	widget_set_color (notepad_win, note_list[id].window, 0.77f, 0.57f, 0.39f);

	// input text field
	note_list[id].input = text_field_add_extended(note_list[id].window, note_widget_id++, NULL, tf_x, tf_y, tf_width, tf_height, TEXT_FIELD_BORDER|TEXT_FIELD_EDITABLE|TEXT_FIELD_CAN_GROW|TEXT_FIELD_SCROLLBAR, note_zoom, 0.77f, 0.57f, 0.39f, &note_list[id].text, 1, FILTER_ALL, 5, 5);

	// remove button
	note_list[id].button = button_add (note_list[id].window, NULL, button_remove_category, 20, 8);
	widget_set_OnClick(note_list[id].window, note_list[id].button, notepad_remove_category);
	widget_set_color(note_list[id].window, note_list[id].button, 0.77f, 0.57f, 0.39f);
	widget_set_OnMouseover(note_list[id].window, note_list[id].button, mouseover_remove_handler);

	set_window_handler (note_list[id].window, ELW_HANDLER_DESTROY, note_tab_destroy);

	tab = tab_collection_get_tab_nr (notepad_win, note_tabcollection_id, note_list[id].window);
	tab_collection_select_tab (notepad_win, note_tabcollection_id, tab);
}
Exemplo n.º 2
0
int display_buddy_add(void)
{
	if(buddy_add_win < 0)
	{
		int label_id = 100, input_id = 101, button_id = 102;
		window_info *win = NULL;
		int label_width = 0;
		int win_x_len = 0;
		int win_y_len = 0;

		/* Create the window */
		buddy_add_win = create_window(buddy_add_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT);
		if (buddy_add_win <=0 || buddy_add_win >= windows_list.num_windows)
			return -1;
		win = &windows_list.window[buddy_add_win];

		/* Add name input and label */
		label_id = label_add_extended(buddy_add_win, label_id, NULL,
			buddy_border_space, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_str);
		label_width = widget_get_width(buddy_add_win, label_id);
		input_id = pword_field_add_extended(buddy_add_win, input_id, NULL,
			2 * buddy_border_space + label_width, buddy_border_space,
			MAX_USERNAME_LENGTH * win->default_font_len_x, win->default_font_len_y + buddy_border_space,
			P_TEXT, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_buffer, MAX_USERNAME_LENGTH);
		widget_set_OnMouseover(buddy_add_win, label_id, name_onmouseover_handler);
		widget_set_OnMouseover(buddy_add_win, input_id, name_onmouseover_handler);
		widget_set_OnKey(buddy_add_win, input_id, name_input_keypress_handler);

		/* Add "Add buddy" button */
		button_id = button_add_extended(buddy_add_win, button_id, NULL, 0, 0, 0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_add_str);
		widget_set_OnClick(buddy_add_win, button_id, click_add_buddy_handler);

		/* Resize window and centre button */
		win_x_len = 3 * buddy_border_space + label_width + widget_get_width(buddy_add_win, input_id) + win->box_size;
		win_y_len = 3 * buddy_border_space + widget_get_height(buddy_add_win, input_id) + widget_get_height(buddy_add_win, button_id);
		resize_window(buddy_add_win, win_x_len, win_y_len);
		widget_move(buddy_add_win, button_id, (win_x_len - widget_get_width(buddy_add_win, button_id)) / 2, 3 * buddy_border_space + win->default_font_len_y);

		return buddy_add_win;
	}
	else
	{
		toggle_window(buddy_add_win);
		return buddy_add_win;
	}
}
Exemplo n.º 3
0
void display_manufacture_menu()
{
	if(manufacture_win < 0){
		static int clear_button_id=100;
		static int mixone_button_id=101;
		static int mixall_button_id=102;

		int our_root_win = -1;
			
		if (!windows_on_top) {
			our_root_win = game_root_win;
		}
		manufacture_win= create_window(win_manufacture, our_root_win, 0, manufacture_menu_x, manufacture_menu_y, manufacture_menu_x_len, manufacture_menu_y_len, ELW_WIN_DEFAULT);
		set_window_handler(manufacture_win, ELW_HANDLER_DISPLAY, &display_manufacture_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_CLICK, &click_manufacture_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_MOUSEOVER, &mouseover_manufacture_slot_handler );

		mixone_button_id=button_add_extended(manufacture_win, mixone_button_id,
			NULL, 33*6+15+10, manufacture_menu_y_len-36, 43, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">");
		widget_set_OnClick(manufacture_win, mixone_button_id, mixone_handler);
		widget_set_OnMouseover(manufacture_win, mixone_button_id, mouseover_mixone_handler);
		
		mixall_button_id=button_add_extended(manufacture_win, mixall_button_id,
			NULL, 33*8+10, manufacture_menu_y_len-36, 43, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">>");
		widget_set_OnClick(manufacture_win, mixall_button_id, mixall_handler);
		widget_set_OnMouseover(manufacture_win, mixall_button_id, mouseover_mixall_handler);
		
		clear_button_id=button_add_extended(manufacture_win, clear_button_id, NULL, 33*9+18+10, manufacture_menu_y_len-36, 70, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, clear_str);
		widget_set_OnClick(manufacture_win, clear_button_id, clear_handler);

		//Create a child window to show recipes in a dropdown panel
		recipe_win= create_window("w_recipe", manufacture_win, 0, 2, manufacture_menu_y_len-2, 33*6, SHOW_MAX_RECIPE*33, 
			ELW_TITLE_NONE|ELW_SHOW|ELW_USE_BACKGROUND|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE|ELW_USE_BORDER);
		set_window_handler(recipe_win, ELW_HANDLER_DISPLAY, &recipe_dropdown_draw);
		set_window_handler(recipe_win, ELW_HANDLER_CLICK, &recipe_dropdown_click_handler );
		set_window_handler(recipe_win, ELW_HANDLER_MOUSEOVER, &mouseover_recipe_handler );
		hide_window(recipe_win); //start hidden
	} else {
		show_window(manufacture_win);
		if (!recipes_shown) hide_window(recipe_win);
		else show_window(recipe_win);
		select_window(manufacture_win);
	}
}
Exemplo n.º 4
0
void fill_session_win(void)
{
	int reset_button_id = -1;
	set_window_handler(session_win, ELW_HANDLER_DISPLAY, &display_session_handler);

	reset_button_id=button_add_extended(session_win, reset_button_id, NULL, 450, 3, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, reset_str);
	widget_set_OnClick(session_win, reset_button_id, session_reset_handler);
	widget_set_OnMouseover(session_win, reset_button_id, mouseover_session_reset_handler);
	
}
Exemplo n.º 5
0
void fill_session_win(int window_id)
{
	set_window_handler(window_id, ELW_HANDLER_DISPLAY, &display_session_handler);
	set_window_handler(window_id, ELW_HANDLER_CLICK, &click_session_handler );
	set_window_handler(window_id, ELW_HANDLER_MOUSEOVER, &mouseover_session_handler );
	set_window_handler(window_id, ELW_HANDLER_RESIZE, &resize_session_handler );

	reset_button_id=button_add_extended(window_id, reset_button_id, NULL, 0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, reset_str);
	widget_set_OnClick(window_id, reset_button_id, session_reset_handler);
	widget_set_OnMouseover(window_id, reset_button_id, mouseover_session_reset_handler);
}
Exemplo n.º 6
0
void fill_session_win(void)
{
	int reset_button_id = -1;
	set_window_handler(session_win, ELW_HANDLER_DISPLAY, &display_session_handler);
	set_window_handler(session_win, ELW_HANDLER_CLICK, &click_session_handler );
	set_window_handler(session_win, ELW_HANDLER_MOUSEOVER, &mouseover_session_handler );

	reset_button_id=button_add_extended(session_win, reset_button_id, NULL, 450, 280, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, reset_str);
	widget_set_OnClick(session_win, reset_button_id, session_reset_handler);
	widget_set_OnMouseover(session_win, reset_button_id, mouseover_session_reset_handler);
	
}
Exemplo n.º 7
0
/* fill the URL window created as a tab. */
void fill_url_window(void)
{
	const Uint32 scroll_width = 20;
	const Uint32 cross_height = 20;
	int clear_all_button = 101;
	widget_list *widget;

	/* create the main window */
	url_win_x_len = INFO_TAB_WIDTH;
	url_win_y_len = INFO_TAB_HEIGHT;
	url_win_max_string_width = url_win_x_len - (2*url_win_sep + scroll_width);
	set_window_handler(url_win, ELW_HANDLER_DISPLAY, &display_url_handler );
	set_window_handler(url_win, ELW_HANDLER_CLICK, &click_url_handler );

	/* create the clear all button */
	clear_all_button = button_add_extended (url_win, clear_all_button, NULL,
		url_win_sep, url_win_sep, 0, 0, 0, 0.75, 0.77f, 0.57f, 0.39f, "CLEAR ALL ");
	widget_set_OnClick(url_win, clear_all_button, url_win_click_clear_all);
	widget = widget_find(url_win, clear_all_button);
	widget_set_OnMouseover(url_win, clear_all_button, url_win_mouseover_clear_all);
	
	/* calc text and help postions from size of other stuff */
	url_win_text_start_y = 2*url_win_sep + ((widget->len_y > cross_height) ?widget->len_y :cross_height);
	url_win_line_step = (int)(3 + DEFAULT_FONT_Y_LEN * url_win_text_zoom);
	url_win_text_len_y = 12 * url_win_line_step;
	url_win_full_url_y_len = url_win_sep + 3 * SMALL_FONT_Y_LEN;
	url_win_y_len = url_win_text_start_y + url_win_text_len_y + url_win_sep + url_win_full_url_y_len;
	url_win_help_x = widget->len_x + 2 * url_win_sep;
	url_win_url_y_start = url_win_y_len - url_win_full_url_y_len - url_win_sep/2;
	resize_window (url_win, url_win_x_len, url_win_y_len);
	
	/* create the scroll bar */
	url_scroll_id = vscrollbar_add_extended(url_win, url_scroll_id, NULL, 
		url_win_x_len - scroll_width, url_win_text_start_y, scroll_width,
		url_win_text_len_y, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, have_url_count);
	widget_set_OnDrag(url_win, url_scroll_id, url_win_scroll_drag);
	widget_set_OnClick(url_win, url_scroll_id, url_win_scroll_click);
}
Exemplo n.º 8
0
void display_manufacture_menu()
{
	if(manufacture_win < 0){
		int our_root_win = -1;

		if (!windows_on_top) {
			our_root_win = game_root_win;
		}
		manufacture_win= create_window(win_manufacture, our_root_win, 0, manufacture_menu_x,
			manufacture_menu_y, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT);

		set_window_handler(manufacture_win, ELW_HANDLER_DISPLAY, &display_manufacture_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_CLICK, &click_manufacture_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_MOUSEOVER, &mouseover_manufacture_slot_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_KEYPRESS, &keypress_manufacture_handler );
		set_window_handler(manufacture_win, ELW_HANDLER_UI_SCALE, &ui_scale_manufacture_handler );

		mixone_button_id=button_add_extended(manufacture_win, mixone_button_id, NULL,
			0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">");
		widget_set_OnClick(manufacture_win, mixone_button_id, mixone_handler);
		widget_set_OnMouseover(manufacture_win, mixone_button_id, mouseover_mixone_handler);

		mixall_button_id=button_add_extended(manufacture_win, mixall_button_id, NULL,
			0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">>");
		widget_set_OnClick(manufacture_win, mixall_button_id, mixall_handler);
		widget_set_OnMouseover(manufacture_win, mixall_button_id, mouseover_mixall_handler);

		clear_button_id=button_add_extended(manufacture_win, clear_button_id, NULL,
			0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, clear_str);
		widget_set_OnClick(manufacture_win, clear_button_id, clear_handler);

		if ((manufacture_win > -1) && (manufacture_win < windows_list.num_windows))
		{
			cm_add(windows_list.window[manufacture_win].cm_id, cm_manuwin_menu_str, NULL);
			cm_bool_line(windows_list.window[manufacture_win].cm_id, ELW_CM_MENU_LEN+1, &disable_manuwin_keypress, NULL);
		}

		//Create a child window to show recipes in a dropdown panel
		recipe_win= create_window("w_recipe", manufacture_win, 0, 0, 0, 0, 0,
			ELW_USE_UISCALE|ELW_TITLE_NONE|ELW_SHOW|ELW_USE_BACKGROUND|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE|ELW_USE_BORDER|ELW_RESIZEABLE);
		set_window_handler(recipe_win, ELW_HANDLER_DISPLAY, &recipe_dropdown_draw);
		set_window_handler(recipe_win, ELW_HANDLER_CLICK, &recipe_dropdown_click_handler );
		set_window_handler(recipe_win, ELW_HANDLER_MOUSEOVER, &mouseover_recipe_handler );
		set_window_handler(recipe_win, ELW_HANDLER_RESIZE, &resize_recipe_handler );
		set_window_handler(recipe_win, ELW_HANDLER_KEYPRESS, keypress_recipe_handler );

		recipe_win_scroll_id = vscrollbar_add_extended(recipe_win, 1, NULL, 0,
			0, 0, 0, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, num_recipe_entries-num_displayed_recipes);

		if ((manufacture_win > -1) && (manufacture_win < windows_list.num_windows))
			ui_scale_manufacture_handler(&windows_list.window[manufacture_win]);

		// context menu
		cm_recipewin = cm_create(cm_recipe_menu_str, context_recipe_handler);
		cm_add_window(cm_recipewin, recipe_win);
		cm_set_pre_show_handler(cm_recipewin, context_recipe_pre_show_handler);

		hide_window(recipe_win); //start hidden
		build_manufacture_list();
	} else {
		show_window(manufacture_win);
		if (!recipes_shown) hide_window(recipe_win);
		else show_window(recipe_win);
		select_window(manufacture_win);
	}
}
Exemplo n.º 9
0
static int display_buddy_change(_buddy *buddy)
{
	int label_id = 100, name_id = 101, type_label_id = 102, checkbox_id = 103, checkbox_label_id = 104, change_button_id = 105;
	int buddy_change_x_len = 0;
	int buddy_change_y_len = 0;
	window_info *win = NULL;
	int tmp_width = 0;

	buddy_to_change = buddy->name;
	if(buddy_change_win >= 0) {
		/* Destroy the window to make sure everything's set up. */
		destroy_window(buddy_change_win);
		buddy_change_win = -1;
		buddy_delete = 0;
	}

	/* Create the window */
	buddy_change_win = create_window(buddy_change_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT);
	if (buddy_change_win <=0 || buddy_change_win >= windows_list.num_windows)
		return -1;
	win = &windows_list.window[buddy_change_win];

	/* Add name label and name */
	label_id = label_add_extended(buddy_change_win, label_id, NULL,
		buddy_border_space, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_str);
	tmp_width = widget_get_width(buddy_change_win, label_id);
	name_id = label_add_extended(buddy_change_win, name_id, NULL,
		2 * buddy_border_space + tmp_width, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_to_change);

	buddy_change_x_len = 3 * buddy_border_space + tmp_width + MAX_USERNAME_LENGTH * win->default_font_len_x + win->box_size;
	buddy_change_y_len = 2 * buddy_border_space + widget_get_height(buddy_change_win, name_id);

	buddy_type_input_id = -1;
	if (buddy->type < 0xFE)
	{
		size_t i;
		const size_t num_type_labels = 5;
		char * type_labels_text[] = {buddy_white_str, buddy_red_str, buddy_green_str, buddy_blue_str, buddy_yellow_str};

		/* Add type label and input widget */
		type_label_id = label_add_extended(buddy_change_win, type_label_id, NULL,
			buddy_border_space, buddy_change_y_len, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_type_str);
		tmp_width = widget_get_width(buddy_change_win, type_label_id);

		buddy_type_input_id = multiselect_add(buddy_change_win, NULL,
			2 * buddy_border_space + tmp_width, buddy_change_y_len, buddy_change_x_len - tmp_width - 3 * buddy_border_space);
		for (i=0; i<num_type_labels; i++)
			multiselect_button_add_extended(buddy_change_win, buddy_type_input_id,
				0, i * 25 * win->current_scale, 0, type_labels_text[i], DEFAULT_SMALL_RATIO * win->current_scale, i==0);
		multiselect_set_selected(buddy_change_win, buddy_type_input_id, buddy->type);

		widget_set_OnMouseover(buddy_change_win, label_id, type_onmouseover_handler);
		widget_set_OnMouseover(buddy_change_win, buddy_type_input_id, type_onmouseover_handler);

		if ((3 * buddy_border_space + tmp_width + widget_get_width(buddy_change_win, buddy_type_input_id)) > buddy_change_x_len)
			buddy_change_x_len = 3 * buddy_border_space + tmp_width + widget_get_width(buddy_change_win, buddy_type_input_id);
		buddy_change_y_len += buddy_border_space + multiselect_get_height(buddy_change_win, buddy_type_input_id);
	}

	/* Delete buddy checkbox and label */
	checkbox_id = checkbox_add(buddy_change_win, NULL, 0, 0, win->default_font_len_y, win->default_font_len_y, &buddy_delete);
	checkbox_label_id = label_add_extended(buddy_change_win, checkbox_label_id, NULL,
		0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_delete_str);
	widget_set_OnClick(buddy_change_win, checkbox_label_id, click_delete_checkbox_label);
	widget_set_OnMouseover(buddy_change_win, checkbox_label_id, delete_onmouseover_handler);
	tmp_width = widget_get_width(buddy_change_win, checkbox_id) + buddy_border_space + widget_get_width(buddy_change_win, checkbox_label_id);
	widget_move(buddy_change_win, checkbox_id, (buddy_change_x_len - tmp_width) / 2, buddy_change_y_len);
	widget_move(buddy_change_win, checkbox_label_id,
		buddy_change_x_len - ((buddy_change_x_len - tmp_width) / 2) - widget_get_width(buddy_change_win, checkbox_label_id), buddy_change_y_len);
	buddy_change_y_len += buddy_border_space + widget_get_height(buddy_change_win, checkbox_id);

	/* Change button */
	change_button_id = button_add_extended(buddy_change_win, change_button_id, NULL,
		0, 0, 0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_change_str);
	widget_set_OnClick(buddy_change_win, change_button_id, click_change_buddy_handler);
	widget_move(buddy_change_win, change_button_id,
		(buddy_change_x_len - widget_get_width(buddy_change_win, change_button_id)) / 2, buddy_change_y_len);
	buddy_change_y_len += buddy_border_space + widget_get_height(buddy_change_win, change_button_id);

	resize_window(buddy_change_win, buddy_change_x_len, buddy_change_y_len);

	return buddy_change_win;
}