Ejemplo n.º 1
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);
	}
	
}
Ejemplo n.º 2
0
int MENUS::render_menubar(RECT r)
{
	RECT box = r;
	RECT button;
	
	int active_page = config.ui_page;
	int new_page = -1;
	
	if(client_state() != CLIENTSTATE_OFFLINE)
		active_page = game_page;
	
	if(client_state() == CLIENTSTATE_OFFLINE)
	{
		/* offline menus */
		if(0) // this is not done yet
		{
			ui_vsplit_l(&box, 90.0f, &button, &box);
			static int news_button=0;
			if (ui_do_button(&news_button, localize("News"), active_page==PAGE_NEWS, &button, ui_draw_menu_tab_button, 0))
				new_page = PAGE_NEWS;
			ui_vsplit_l(&box, 30.0f, 0, &box); 
		}

		ui_vsplit_l(&box, 100.0f, &button, &box);
		static int internet_button=0;
		int corners = CORNER_TL;
		if (ui_do_button(&internet_button, localize("Internet"), active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, &corners))
		{
			client_serverbrowse_refresh(BROWSETYPE_INTERNET);
			new_page = PAGE_INTERNET;
		}

		//ui_vsplit_l(&box, 4.0f, 0, &box);
		ui_vsplit_l(&box, 80.0f, &button, &box);
		static int lan_button=0;
		corners = 0;
		if (ui_do_button(&lan_button, localize("LAN"), active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, &corners))
		{
			client_serverbrowse_refresh(BROWSETYPE_LAN);
			new_page = PAGE_LAN;
		}

		//ui_vsplit_l(&box, 4.0f, 0, &box);
		ui_vsplit_l(&box, 110.0f, &button, &box);
		static int favorites_button=0;
		corners = CORNER_TR;
		if (ui_do_button(&favorites_button, localize("Favorites"), active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, &corners))
		{
			client_serverbrowse_refresh(BROWSETYPE_FAVORITES);
			new_page  = PAGE_FAVORITES;
		}
		
		ui_vsplit_l(&box, 4.0f*5, 0, &box);
		ui_vsplit_l(&box, 100.0f, &button, &box);
		static int demos_button=0;
		if (ui_do_button(&demos_button, localize("Demos"), active_page==PAGE_DEMOS, &button, ui_draw_menu_tab_button, 0))
		{
			demolist_populate();
			new_page  = PAGE_DEMOS;
		}		
	}
	else
	{
		/* online menus */
		ui_vsplit_l(&box, 90.0f, &button, &box);
		static int game_button=0;
		if (ui_do_button(&game_button, localize("Game"), active_page==PAGE_GAME, &button, ui_draw_menu_tab_button, 0))
			new_page = PAGE_GAME;

		ui_vsplit_l(&box, 4.0f, 0, &box);
		ui_vsplit_l(&box, 140.0f, &button, &box);
		static int server_info_button=0;
		if (ui_do_button(&server_info_button, localize("Server info"), active_page==PAGE_SERVER_INFO, &button, ui_draw_menu_tab_button, 0))
			new_page = PAGE_SERVER_INFO;

		ui_vsplit_l(&box, 4.0f, 0, &box);
		ui_vsplit_l(&box, 140.0f, &button, &box);
		static int callvote_button=0;
		if (ui_do_button(&callvote_button, localize("Call vote"), active_page==PAGE_CALLVOTE, &button, ui_draw_menu_tab_button, 0))
			new_page = PAGE_CALLVOTE;
			
		ui_vsplit_l(&box, 30.0f, 0, &box);
	}
		
	/*
	ui_vsplit_r(&box, 110.0f, &box, &button);
	static int system_button=0;
	if (ui_do_button(&system_button, "System", config.ui_page==PAGE_SYSTEM, &button, ui_draw_menu_tab_button, 0))
		config.ui_page = PAGE_SYSTEM;
		
	ui_vsplit_r(&box, 30.0f, &box, 0);
	*/
	
	ui_vsplit_r(&box, 90.0f, &box, &button);
	static int quit_button=0;
	if (ui_do_button(&quit_button, localize("Quit"), 0, &button, ui_draw_menu_tab_button, 0))
		popup = POPUP_QUIT;

	ui_vsplit_r(&box, 10.0f, &box, &button);
	ui_vsplit_r(&box, 130.0f, &box, &button);
	static int settings_button=0;
	if (ui_do_button(&settings_button, localize("Settings"), active_page==PAGE_SETTINGS, &button, ui_draw_menu_tab_button, 0))
		new_page = PAGE_SETTINGS;
	
	if(new_page != -1)
	{
		if(client_state() == CLIENTSTATE_OFFLINE)
			config.ui_page = new_page;
		else
			game_page = new_page;
	}
		
	return 0;
}