Example #1
0
void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, const char *title, int num_items, int selected_index)
{
	RECT scroll, row;
	RECT view = *rect;
	RECT header, footer;
	
	// draw header
	ui_hsplit_t(&view, listheader_height, &header, &view);
	ui_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); 
	ui_do_label(&header, title, header.h*fontmod_height, 0);

	// draw footers
	ui_hsplit_b(&view, listheader_height, &view, &footer);
	ui_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); 
	ui_vsplit_l(&footer, 10.0f, 0, &footer);

	// background
	ui_draw_rect(&view, vec4(0,0,0,0.15f), 0, 0);

	// prepare the scroll
	ui_vsplit_r(&view, 15, &view, &scroll);

	// setup the variables	
	listbox_originalview = view;
	listbox_selected_index = selected_index;
	listbox_new_selected = selected_index;
	listbox_itemindex = 0;
	listbox_rowheight = row_height;
	//int num_servers = client_serverbrowse_sorted_num();


	// do the scrollbar
	ui_hsplit_t(&view, listbox_rowheight, &row, 0);

	int num = (int)(listbox_originalview.h/row.h);
	static float scrollvalue = 0;
	ui_hmargin(&scroll, 5.0f, &scroll);
	scrollvalue = ui_do_scrollbar_v(id, &scroll, scrollvalue);

	int start = (int)(num*scrollvalue);
	if(start < 0)
		start = 0;
	
	// the list
	listbox_view = listbox_originalview;
	ui_vmargin(&listbox_view, 5.0f, &listbox_view);
	ui_clip_enable(&listbox_view);
	listbox_view.y -= scrollvalue*num*row.h;	
}
Example #2
0
	ui_vsplit_l(&footer, 10.0f, 0, &footer);

	// modes
	ui_draw_rect(&skinselection, vec4(0,0,0,0.15f), 0, 0);

	RECT scroll;
	ui_vsplit_r(&skinselection, 15, &skinselection, &scroll);

	RECT list = skinselection;
	ui_hsplit_t(&list, 50, &button, &list);
	
	int num = (int)(skinselection.h/button.h);
	static float scrollvalue = 0;
	static int scrollbar = 0;
	ui_hmargin(&scroll, 5.0f, &scroll);
	scrollvalue = ui_do_scrollbar_v(&scrollbar, &scroll, scrollvalue);

	int start = (int)((gameclient.skins->num()-num)*scrollvalue);
	if(start < 0)
		start = 0;
		
	for(int i = start; i < start+num && i < gameclient.skins->num(); i++)
	{
		const SKINS::SKIN *s = gameclient.skins->get(i);
		
		// no special skins
		if(s->name[0] == 'x' && s->name[1] == '_')
		{
			num++;
			continue;
		}