Exemplo n.º 1
0
int popup_layer(RECT view)
{
	// remove layer button
	RECT button;
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int delete_button = 0;
	
	// don't allow deletion of game layer
	if(editor.map.game_layer != editor.get_selected_layer(0) &&
		do_editor_button(&delete_button, "Delete Layer", 0, &button, draw_editor_button, 0, "Deletes the layer"))
	{
		editor.map.groups[editor.selected_group]->delete_layer(editor.selected_layer);
		return 1;
	}

	ui_hsplit_b(&view, 10.0f, &view, 0);
	
	LAYERGROUP *current_group = editor.map.groups[editor.selected_group];
	LAYER *current_layer = editor.get_selected_layer(0);
	
	enum
	{
		PROP_GROUP=0,
		PROP_ORDER,
		PROP_HQ,
		NUM_PROPS,
	};
	
	PROPERTY props[] = {
		{"Group", editor.selected_group, PROPTYPE_INT_STEP, 0, editor.map.groups.len()-1},
		{"Order", editor.selected_layer, PROPTYPE_INT_STEP, 0, current_group->layers.len()},
		{"Detail", current_layer->flags&LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1},
		{0},
	};
	
	static int ids[NUM_PROPS] = {0};
	int new_val = 0;
	int prop = editor.do_properties(&view, props, ids, &new_val);		
	
	if(prop == PROP_ORDER)
		editor.selected_layer = current_group->swap_layers(editor.selected_layer, new_val);
	else if(prop == PROP_GROUP && current_layer->type != LAYERTYPE_GAME)
	{
		if(new_val >= 0 && new_val < editor.map.groups.len())
		{
			current_group->layers.remove(current_layer);
			editor.map.groups[new_val]->layers.add(current_layer);
			editor.selected_group = new_val;
			editor.selected_layer = editor.map.groups[new_val]->layers.len()-1;
		}
	}
	else if(prop == PROP_HQ)
	{
		current_layer->flags &= ~LAYERFLAG_DETAIL;
		if(new_val)
			current_layer->flags |= LAYERFLAG_DETAIL;
	}
		
	return current_layer->render_properties(&view);
}
Exemplo n.º 2
0
void MENUS::render_demolist(RECT main_view)
{
	static int inited = 0;
	if(!inited)
		demolist_populate();
	inited = 1;
	
	// render background
	ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f);
	ui_margin(&main_view, 10.0f, &main_view);
	
	RECT buttonbar;
	ui_hsplit_b(&main_view, button_height+5.0f, &main_view, &buttonbar);
	ui_hsplit_t(&buttonbar, 5.0f, 0, &buttonbar);
	
	static int selected_item = -1;
	static int num_items = 0;
	static int demolist_id = 0;
	
	ui_do_listbox_start(&demolist_id, &main_view, 17.0f, "Demos", num_items, selected_item);
	for(int i = 0; i < num_demos; i++)
	{
		LISTBOXITEM item = ui_do_listbox_nextitem((void*)(10+i));
		if(item.visible)
			ui_do_label(&item.rect, demos[i].name, item.rect.h*fontmod_height, -1);
	}
	selected_item = ui_do_listbox_end();

	if(selected_item >= 0 && selected_item < num_demos && inp_mouse_doubleclick())
	{
		ui_set_active_item(0);
		client_demoplayer_play(demos[selected_item].filename);
	}
	
	RECT refresh_rect, play_rect;
	ui_vsplit_r(&buttonbar, 250.0f, &buttonbar, &refresh_rect);
	ui_vsplit_r(&refresh_rect, 130.0f, &refresh_rect, &play_rect);
	ui_vsplit_r(&play_rect, 120.0f, 0x0, &play_rect);
	
	static int refresh_button = 0;
	if(ui_do_button(&refresh_button, "Refresh", 0, &refresh_rect, ui_draw_menu_button, 0))
	{
		demolist_populate();
	}	
	
	static int play_button = 0;
	if(ui_do_button(&play_button, "Play", 0, &play_rect, ui_draw_menu_button, 0))
	{
		if(selected_item >= 0 && selected_item < num_demos)
			client_demoplayer_play(demos[selected_item].filename);
	}
	
}
Exemplo n.º 3
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;	
}
Exemplo n.º 4
0
int popup_group(RECT view)
{
	// remove group button
	RECT button;
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int delete_button = 0;
	
	// don't allow deletion of game group
	if(editor.map.game_group != editor.get_selected_group() &&
		do_editor_button(&delete_button, "Delete Group", 0, &button, draw_editor_button, 0, "Delete group"))
	{
		editor.map.delete_group(editor.selected_group);
		return 1;
	}

	// new tile layer
	ui_hsplit_b(&view, 10.0f, &view, &button);
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int new_quad_layer_button = 0;
	if(do_editor_button(&new_quad_layer_button, "Add Quads Layer", 0, &button, draw_editor_button, 0, "Creates a new quad layer"))
	{
		LAYER *l = new LAYER_QUADS;
		editor.map.groups[editor.selected_group]->add_layer(l);
		editor.selected_layer = editor.map.groups[editor.selected_group]->layers.len()-1;
		return 1;
	}

	// new quad layer
	ui_hsplit_b(&view, 5.0f, &view, &button);
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int new_tile_layer_button = 0;
	if(do_editor_button(&new_tile_layer_button, "Add Tile Layer", 0, &button, draw_editor_button, 0, "Creates a new tile layer"))
	{
		LAYER *l = new LAYER_TILES(50, 50);
		editor.map.groups[editor.selected_group]->add_layer(l);
		editor.selected_layer = editor.map.groups[editor.selected_group]->layers.len()-1;
		return 1;
	}
	
	enum
	{
		PROP_ORDER=0,
		PROP_POS_X,
		PROP_POS_Y,
		PROP_PARA_X,
		PROP_PARA_Y,
		PROP_USE_CLIPPING,
		PROP_CLIP_X,
		PROP_CLIP_Y,
		PROP_CLIP_W,
		PROP_CLIP_H,
		NUM_PROPS,
	};
	
	PROPERTY props[] = {
		{"Order", editor.selected_group, PROPTYPE_INT_STEP, 0, editor.map.groups.len()-1},
		{"Pos X", -editor.map.groups[editor.selected_group]->offset_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Pos Y", -editor.map.groups[editor.selected_group]->offset_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Para X", editor.map.groups[editor.selected_group]->parallax_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Para Y", editor.map.groups[editor.selected_group]->parallax_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},

		{"Use Clipping", editor.map.groups[editor.selected_group]->use_clipping, PROPTYPE_BOOL, 0, 1},
		{"Clip X", editor.map.groups[editor.selected_group]->clip_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Clip Y", editor.map.groups[editor.selected_group]->clip_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Clip W", editor.map.groups[editor.selected_group]->clip_w, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Clip H", editor.map.groups[editor.selected_group]->clip_h, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{0},
	};
	
	static int ids[NUM_PROPS] = {0};
	int new_val = 0;
	
	// cut the properties that isn't needed
	if(editor.get_selected_group()->game_group)
		props[PROP_POS_X].name = 0;
		
	int prop = editor.do_properties(&view, props, ids, &new_val);
	if(prop == PROP_ORDER)
		editor.selected_group = editor.map.swap_groups(editor.selected_group, new_val);
		
	// these can not be changed on the game group
	if(!editor.get_selected_group()->game_group)
	{
		if(prop == PROP_PARA_X) editor.map.groups[editor.selected_group]->parallax_x = new_val;
		else if(prop == PROP_PARA_Y) editor.map.groups[editor.selected_group]->parallax_y = new_val;
		else if(prop == PROP_POS_X) editor.map.groups[editor.selected_group]->offset_x = -new_val;
		else if(prop == PROP_POS_Y) editor.map.groups[editor.selected_group]->offset_y = -new_val;
		else if(prop == PROP_USE_CLIPPING) editor.map.groups[editor.selected_group]->use_clipping = new_val;
		else if(prop == PROP_CLIP_X) editor.map.groups[editor.selected_group]->clip_x = new_val;
		else if(prop == PROP_CLIP_Y) editor.map.groups[editor.selected_group]->clip_y = new_val;
		else if(prop == PROP_CLIP_W) editor.map.groups[editor.selected_group]->clip_w = new_val;
		else if(prop == PROP_CLIP_H) editor.map.groups[editor.selected_group]->clip_h = new_val;
	}
	
	return 0;
}
Exemplo n.º 5
0
int popup_quad(RECT view)
{
	QUAD *quad = editor.get_selected_quad();

	RECT button;
	
	// delete button
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int delete_button = 0;
	if(do_editor_button(&delete_button, "Delete", 0, &button, draw_editor_button, 0, "Deletes the current quad"))
	{
		LAYER_QUADS *layer = (LAYER_QUADS *)editor.get_selected_layer_type(0, LAYERTYPE_QUADS);
		if(layer)
		{
			layer->quads.removebyindex(editor.selected_quad);
			editor.selected_quad--;
		}
		return 1;
	}

	// square button
	ui_hsplit_b(&view, 10.0f, &view, &button);
	ui_hsplit_b(&view, 12.0f, &view, &button);
	static int sq_button = 0;
	if(do_editor_button(&sq_button, "Square", 0, &button, draw_editor_button, 0, "Squares the current quad"))
	{
		int top = quad->points[0].y;
		int left = quad->points[0].x;
		int bottom = quad->points[0].y;
		int right = quad->points[0].x;
		
		for(int k = 1; k < 4; k++)
		{
			if(quad->points[k].y < top) top = quad->points[k].y;
			if(quad->points[k].x < left) left = quad->points[k].x;
			if(quad->points[k].y > bottom) bottom = quad->points[k].y;
			if(quad->points[k].x > right) right = quad->points[k].x;
		}
		
		quad->points[0].x = left; quad->points[0].y = top;
		quad->points[1].x = right; quad->points[1].y = top;
		quad->points[2].x = left; quad->points[2].y = bottom;
		quad->points[3].x = right; quad->points[3].y = bottom;
		return 1;
	}


	enum
	{
		PROP_POS_ENV=0,
		PROP_POS_ENV_OFFSET,
		PROP_COLOR_ENV,
		PROP_COLOR_ENV_OFFSET,
		NUM_PROPS,
	};
	
	PROPERTY props[] = {
		{"Pos. Env", quad->pos_env, PROPTYPE_INT_STEP, -1, editor.map.envelopes.len()},
		{"Pos. TO", quad->pos_env_offset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{"Color Env", quad->color_env, PROPTYPE_INT_STEP, -1, editor.map.envelopes.len()},
		{"Color TO", quad->color_env_offset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		
		{0},
	};
	
	static int ids[NUM_PROPS] = {0};
	int new_val = 0;
	int prop = editor.do_properties(&view, props, ids, &new_val);		
	
	if(prop == PROP_POS_ENV) quad->pos_env = clamp(new_val, -1, editor.map.envelopes.len()-1);
	if(prop == PROP_POS_ENV_OFFSET) quad->pos_env_offset = new_val;
	if(prop == PROP_COLOR_ENV) quad->color_env = clamp(new_val, -1, editor.map.envelopes.len()-1);
	if(prop == PROP_COLOR_ENV_OFFSET) quad->color_env_offset = new_val;
	
	return 0;
}
Exemplo n.º 6
0
int MENUS::render()
{
    RECT screen = *ui_screen();
	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);

	static bool first = true;
	if(first)
	{
		if(config.ui_page == PAGE_INTERNET)
			client_serverbrowse_refresh(0);
		else if(config.ui_page == PAGE_LAN)
			client_serverbrowse_refresh(1);
		first = false;
	}
	
	if(client_state() == CLIENTSTATE_ONLINE)
	{
		color_tabbar_inactive = color_tabbar_inactive_ingame;
		color_tabbar_active = color_tabbar_active_ingame;
	}
	else
	{
		render_background();
		color_tabbar_inactive = color_tabbar_inactive_outgame;
		color_tabbar_active = color_tabbar_active_outgame;
	}
	
	RECT tab_bar;
	RECT main_view;

	// some margin around the screen
	ui_margin(&screen, 10.0f, &screen);
	
	if(popup == POPUP_NONE)
	{
		// do tab bar
		ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view);
		ui_vmargin(&tab_bar, 20.0f, &tab_bar);
		render_menubar(tab_bar);
		
		// news is not implemented yet
		if(config.ui_page <= PAGE_NEWS || config.ui_page > PAGE_SETTINGS || (client_state() == CLIENTSTATE_OFFLINE && config.ui_page >= PAGE_GAME && config.ui_page <= PAGE_CALLVOTE))
		{
			client_serverbrowse_refresh(BROWSETYPE_INTERNET);
			config.ui_page = PAGE_INTERNET;
		}
		
		// render current page
		if(client_state() != CLIENTSTATE_OFFLINE)
		{
			if(game_page == PAGE_GAME)
				render_game(main_view);
			else if(game_page == PAGE_SERVER_INFO)
				render_serverinfo(main_view);
			else if(game_page == PAGE_CALLVOTE)
				render_servercontrol(main_view);
			else if(game_page == PAGE_SETTINGS)
				render_settings(main_view);
		}
		else if(config.ui_page == PAGE_NEWS)
			render_news(main_view);
		else if(config.ui_page == PAGE_INTERNET)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_LAN)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_DEMOS)
			render_demolist(main_view);
		else if(config.ui_page == PAGE_FAVORITES)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_SETTINGS)
			render_settings(main_view);
//		else if(config.ui_page == PAGE_TEE-NG)
//			renger_settings(main_teeng);
	}
	else
	{
		// make sure that other windows doesn't do anything funnay!
		//ui_set_hot_item(0);
		//ui_set_active_item(0);
		char buf[128];
		const char *title = "";
		const char *extra_text = "";
		const char *button_text = "";
		int extra_align = 0;
		
		if(popup == POPUP_MESSAGE)
		{
			title = message_topic;
			extra_text = message_body;
			button_text = message_button;
		}
		else if(popup == POPUP_CONNECTING)
		{
			title = localize("Connecting to");
			extra_text = config.ui_server_address;  // TODO: query the client about the address
			button_text = localize("Abort");
			if(client_mapdownload_totalsize() > 0)
			{
				title = localize("Downloading map");
				str_format(buf, sizeof(buf), "%d/%d KiB", client_mapdownload_amount()/1024, client_mapdownload_totalsize()/1024);
				extra_text = buf;
			}
		}
		else if(popup == POPUP_DISCONNECTED)
		{

			title = localize("Disconnected");
			extra_text = client_error_string();
			button_text = localize("Ok");
			extra_align = -1;
		}
		else if(popup == POPUP_PURE)
		{
			title = localize("Disconnected");
			extra_text = localize("The server is running a non-standard tuning on a pure game type.");
			button_text = localize("Ok");
			extra_align = -1;
		}
		else if(popup == POPUP_PASSWORD)
		{
			title = localize("Password Incorrect");
			extra_text = client_error_string();
			button_text = localize("Try again");
		}
		else if(popup == POPUP_QUIT)
		{
			title = localize("Quit");
			extra_text = localize("Are you sure that you want to quit?");
		}
		else if(popup == POPUP_FIRST_LAUNCH)
		{
			title = localize("Welcome to Teeworlds");
			extra_text = localize("As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server.");
			button_text = localize("Ok");
			extra_align = -1;
		}
		
		RECT box, part;
		box = screen;
		ui_vmargin(&box, 150.0f, &box);
		ui_hmargin(&box, 150.0f, &box);
		
		// render the box
		ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f);
		 
		ui_hsplit_t(&box, 20.f, &part, &box);
		ui_hsplit_t(&box, 24.f, &part, &box);
		ui_do_label(&part, title, 24.f, 0);
		ui_hsplit_t(&box, 20.f, &part, &box);
		ui_hsplit_t(&box, 24.f, &part, &box);
		ui_vmargin(&part, 20.f, &part);
		
		if(extra_align == -1)
			ui_do_label(&part, extra_text, 20.f, -1, (int)part.w);
		else
			ui_do_label(&part, extra_text, 20.f, 0, -1);

		if(popup == POPUP_QUIT)
		{
			RECT yes, no;
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			ui_vsplit_mid(&part, &no, &yes);
			
			ui_vmargin(&yes, 20.0f, &yes);
			ui_vmargin(&no, 20.0f, &no);

			static int button_abort = 0;
			if(ui_do_button(&button_abort, localize("No"), 0, &no, ui_draw_menu_button, 0) || escape_pressed)
				popup = POPUP_NONE;

			static int button_tryagain = 0;
			if(ui_do_button(&button_tryagain, localize("Yes"), 0, &yes, ui_draw_menu_button, 0) || enter_pressed)
				client_quit();
		}
		else if(popup == POPUP_PASSWORD)
		{
			RECT label, textbox, tryagain, abort;
			
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			ui_vsplit_mid(&part, &abort, &tryagain);
			
			ui_vmargin(&tryagain, 20.0f, &tryagain);
			ui_vmargin(&abort, 20.0f, &abort);
			
			static int button_abort = 0;
			if(ui_do_button(&button_abort, localize("Abort"), 0, &abort, ui_draw_menu_button, 0) || escape_pressed)
			{
				if(config.cl_autoconnect)
				config.cl_autoconnect == 0;
				else
				popup = POPUP_NONE;
			}

			static int button_tryagain = 0;
			if(ui_do_button(&button_tryagain, localize("Try again"), 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed)
			{
				client_connect(config.ui_server_address);
			}
			
			ui_hsplit_b(&box, 60.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			
			ui_vsplit_l(&part, 60.0f, 0, &label);
			ui_vsplit_l(&label, 100.0f, 0, &textbox);
			ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
			ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
			ui_do_label(&label, localize("Password"), 20, -1);
			ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true);
		}
		else if(popup == POPUP_FIRST_LAUNCH)
		{
			RECT label, textbox;
			
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			static int enter_button = 0;
			if(ui_do_button(&enter_button, localize("Enter"), 0, &part, ui_draw_menu_button, 0) || enter_pressed)
				popup = POPUP_NONE;
			
			ui_hsplit_b(&box, 40.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			
			ui_vsplit_l(&part, 60.0f, 0, &label);
			ui_vsplit_l(&label, 100.0f, 0, &textbox);
			ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
			ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
			ui_do_label(&label, localize("Nickname"), 20, -1);
			ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f);
		}
		else
		{
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 120.0f, &part);

			static int button = 0;
			if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed)
			{
				if(popup == POPUP_CONNECTING)
					client_disconnect();
				popup = POPUP_NONE;
			}
		}
	}
	
	return 0;
}
Exemplo n.º 7
0
void MENUS::render_demoplayer(RECT main_view)
{
	const DEMOPLAYBACK_INFO *info = client_demoplayer_getinfo();
	
	const float seekbar_height = 15.0f;
	const float buttonbar_height = 20.0f;
	const float margins = 5.0f;
	float total_height;
	
	if(menu_active)
	{
		total_height = seekbar_height+buttonbar_height+margins*3;
	/*
	else
		total_height = seekbar_height+margins*2;
	*/
	
		ui_hsplit_b(&main_view, total_height, 0, &main_view);
		ui_vsplit_l(&main_view, 250.0f, 0, &main_view);
		ui_vsplit_r(&main_view, 250.0f, &main_view, 0);
	
		ui_draw_rect(&main_view, color_tabbar_active, CORNER_T, 10.0f);
		
		ui_margin(&main_view, 5.0f, &main_view);
	}
	
	RECT seekbar, buttonbar;
	
	if(menu_active)
	{
		ui_hsplit_t(&main_view, seekbar_height, &seekbar, &buttonbar);
		ui_hsplit_t(&buttonbar, margins, 0, &buttonbar);
	}
	/*
	else
		seekbar = main_view;
	*/
	
	// do seekbar
	if(menu_active)
	{
		static int seekbar_id = 0;
		void *id = &seekbar_id;
		char buffer[128];
		
		ui_draw_rect(&seekbar, vec4(0,0,0,0.5f), CORNER_ALL, 5.0f);
		
		int current_tick = info->current_tick - info->first_tick;
		int total_ticks = info->last_tick - info->first_tick;
		
		float amount = current_tick/(float)total_ticks;
		
		RECT filledbar = seekbar;
		filledbar.w = 10.0f + (filledbar.w-10.0f)*amount;
		
		ui_draw_rect(&filledbar, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f);
		
		str_format(buffer, sizeof(buffer), "%d:%02d / %d:%02d",
			current_tick/SERVER_TICK_SPEED/60, (current_tick/SERVER_TICK_SPEED)%60,
			total_ticks/SERVER_TICK_SPEED/60, (total_ticks/SERVER_TICK_SPEED)%60);
		ui_do_label(&seekbar, buffer, seekbar.h*0.70f, 0);

		// do the logic
	    int inside = ui_mouse_inside(&seekbar);
			
		if(ui_active_item() == id)
		{
			if(!ui_mouse_button(0))
				ui_set_active_item(0);
			else
			{
				float amount = (ui_mouse_x()-seekbar.x)/(float)seekbar.w;
				if(amount > 0 && amount < 1.0f)
				{
					gameclient.on_reset();
					gameclient.suppress_events = true;
					client_demoplayer_setpos(amount);
					gameclient.suppress_events = false;
				}
			}
		}
		else if(ui_hot_item() == id)
		{
			if(ui_mouse_button(0))
				ui_set_active_item(id);
		}		
		
		if(inside)
			ui_set_hot_item(id);
	}	
	

	if(menu_active)
	{
		// do buttons
		RECT button;

		// pause button
		ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar);
		static int pause_button = 0;
		if(ui_do_button(&pause_button, "| |", info->paused, &button, ui_draw_demoplayer_button, 0))
			client_demoplayer_setpause(!info->paused);
		
		// play button
		ui_vsplit_l(&buttonbar, margins, 0, &buttonbar);
		ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar);
		static int play_button = 0;
		if(ui_do_button(&play_button, ">", !info->paused, &button, ui_draw_demoplayer_button, 0))
		{
			client_demoplayer_setpause(0);
			client_demoplayer_setspeed(1.0f);
		}

		// slowdown
		ui_vsplit_l(&buttonbar, margins, 0, &buttonbar);
		ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar);
		static int slowdown_button = 0;
		if(ui_do_button(&slowdown_button, "<<", 0, &button, ui_draw_demoplayer_button, 0))
		{
			if(info->speed > 4.0f) client_demoplayer_setspeed(4.0f);
			else if(info->speed > 2.0f) client_demoplayer_setspeed(2.0f);
			else if(info->speed > 1.0f) client_demoplayer_setspeed(1.0f);
			else if(info->speed > 0.5f) client_demoplayer_setspeed(0.5f);
			else client_demoplayer_setspeed(0.05f);
		}
		
		// fastforward
		ui_vsplit_l(&buttonbar, margins, 0, &buttonbar);
		ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar);
		static int fastforward_button = 0;
		if(ui_do_button(&fastforward_button, ">>", 0, &button, ui_draw_demoplayer_button, 0))
		{
			if(info->speed < 0.5f) client_demoplayer_setspeed(0.5f);
			else if(info->speed < 1.0f) client_demoplayer_setspeed(1.0f);
			else if(info->speed < 2.0f) client_demoplayer_setspeed(2.0f);
			else if(info->speed < 4.0f) client_demoplayer_setspeed(4.0f);
			else client_demoplayer_setspeed(8.0f);
		}

		// speed meter
		ui_vsplit_l(&buttonbar, margins*3, 0, &buttonbar);
		char buffer[64];
		if(info->speed >= 1.0f)
			str_format(buffer, sizeof(buffer), "x%.0f", info->speed);
		else
			str_format(buffer, sizeof(buffer), "x%.1f", info->speed);
		ui_do_label(&buttonbar, buffer, button.h*0.7f, -1);

		// exit button
		ui_vsplit_r(&buttonbar, buttonbar_height*3, &buttonbar, &button);
		static int exit_button = 0;
		if(ui_do_button(&exit_button, "Exit", 0, &button, ui_draw_demoplayer_button, 0))
			client_disconnect();
	}
}