Ejemplo n.º 1
0
void NAMEPLATES::render_nameplate(
	const NETOBJ_CHARACTER *prev_char,
	const NETOBJ_CHARACTER *player_char,
	const NETOBJ_PLAYER_INFO *player_info
	)
{
	float intratick = client_intratick();
	
	vec2 position = mix(vec2(prev_char->x, prev_char->y), vec2(player_char->x, player_char->y), intratick);
	
	// render name plate
	if(!player_info->local)
	{
		//gfx_text_color
		float a = 1;
		if(config.cl_nameplates_always == 0)
			a = clamp(1-powf(distance(gameclient.controls->target_pos, position)/200.0f,16.0f), 0.0f, 1.0f);
			
		const char *name = gameclient.clients[player_info->cid].name;
		float tw = gfx_text_width(0, 28.0f, name, -1);
		gfx_text_color(1,1,1,a);
		gfx_text(0, position.x-tw/2.0f, position.y-60, 28.0f, name, -1);
		
		if(config.debug) // render client id when in debug aswell
		{
			char buf[128];
			str_format(buf, sizeof(buf),"%d", player_info->cid);
			gfx_text(0, position.x, position.y-90, 28.0f, buf, -1);
		}

		gfx_text_color(1,1,1,1);
	}
}
Ejemplo n.º 2
0
void HUD::render_voting()
{
	if(!gameclient.voting->is_voting())
		return;
	
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.40f);
	draw_round_rect(-10, 60-2, 100+10+4+5, 28, 5.0f);
	gfx_quads_end();

	gfx_text_color(1,1,1,1);

	char buf[512];
	gfx_text(0x0, 5, 60, 6, gameclient.voting->vote_description(), -1);

	str_format(buf, sizeof(buf), "%ds left", gameclient.voting->seconds_left());
	float tw = gfx_text_width(0x0, 6, buf, -1);
	gfx_text(0x0, 5+100-tw, 60, 6, buf, -1);
	

	RECT base = {5, 70, 100, 4};
	gameclient.voting->render_bars(base, false);
	
	const char *yes_key = gameclient.binds->get_key("vote yes");
	const char *no_key = gameclient.binds->get_key("vote no");
	str_format(buf, sizeof(buf), "%s - Vote Yes", yes_key);
	base.y += base.h+1;
	ui_do_label(&base, buf, 6.0f, -1);

	str_format(buf, sizeof(buf), "Vote No - %s", no_key);
	ui_do_label(&base, buf, 6.0f, 1);
}
Ejemplo n.º 3
0
void HUD::render_teambalancewarning()
{
	// render prompt about team-balance
	bool flash = time_get()/(time_freq()/2)%2 == 0;
	if (gameclient.snap.gameobj && (gameclient.snap.gameobj->flags&GAMEFLAG_TEAMS) != 0)
	{	
		if (config.cl_warning_teambalance && !config.cl_clear_all && abs(gameclient.snap.team_size[0]-gameclient.snap.team_size[1]) >= 2)
		{
			const char *text = "Please balance teams!";
			if(flash)
				gfx_text_color(1,1,0.5f,1);
			else
				gfx_text_color(0.7f,0.7f,0.2f,1.0f);
			gfx_text(0x0, 5, 50, 6, text, -1);
			gfx_text_color(1,1,1,1);
		}
	}
}
Ejemplo n.º 4
0
void CONSOLE::possible_commands_render_callback(const char *str, void *user)
{
	RENDERINFO *info = (RENDERINFO *)user;
	
	if(info->enum_count == info->wanted_completion)
	{
		float tw = gfx_text_width(info->cursor.font_set, info->cursor.font_size, str, -1);
		gfx_texture_set(-1);
		gfx_quads_begin();
			gfx_setcolor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
			draw_round_rect(info->cursor.x-3, info->cursor.y, tw+5, info->cursor.font_size+4, info->cursor.font_size/3);
		gfx_quads_end();
		
		gfx_text_color(0.05f, 0.05f, 0.05f,1);
		gfx_text_ex(&info->cursor, str, -1);
	}
	else
	{
		const char *match_start = str_find_nocase(str, info->current_cmd);
		
		if(match_start)
		{
			gfx_text_color(0.5f,0.5f,0.5f,1);
			gfx_text_ex(&info->cursor, str, match_start-str);
			gfx_text_color(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,1);
			gfx_text_ex(&info->cursor, match_start, strlen(info->current_cmd));
			gfx_text_color(0.5f,0.5f,0.5f,1);
			gfx_text_ex(&info->cursor, match_start+strlen(info->current_cmd), -1);
		}
		else
		{
			gfx_text_color(0.75f,0.75f,0.75f,1);
			gfx_text_ex(&info->cursor, str, -1);
		}
	}
	
	info->enum_count++;
	info->cursor.x += 7.0f;
}
Ejemplo n.º 5
0
void CHAT::on_render()
{
	gfx_mapscreen(0,0,300*gfx_screenaspect(),300);
	float x = 10.0f;
	float y = 300.0f-20.0f;
	if(mode != MODE_NONE)
	{
		// render chat input
		TEXT_CURSOR cursor;
		gfx_text_set_cursor(&cursor, x, y, 8.0f, TEXTFLAG_RENDER);
		cursor.line_width = 200.0f;
		
		if(mode == MODE_ALL)
			gfx_text_ex(&cursor, "All: ", -1);
		else if(mode == MODE_TEAM)
			gfx_text_ex(&cursor, "Team: ", -1);
		else
			gfx_text_ex(&cursor, "Chat: ", -1);
			
		gfx_text_ex(&cursor, input.get_string(), input.cursor_offset());
		TEXT_CURSOR marker = cursor;
		gfx_text_ex(&marker, "|", -1);
		gfx_text_ex(&cursor, input.get_string()+input.cursor_offset(), -1);
	}

	y -= 8;

	int i;
	for(i = 0; i < MAX_LINES; i++)
	{
		int r = ((current_line-i)+MAX_LINES)%MAX_LINES;
		if(time_get() > lines[r].time+15*time_freq())
			break;

		float begin = x;
		float fontsize = 7.0f;
		
		// get the y offset
		TEXT_CURSOR cursor;
		gfx_text_set_cursor(&cursor, begin, 0, fontsize, 0);
		cursor.line_width = 200.0f;
		gfx_text_ex(&cursor, lines[r].name, -1);
		gfx_text_ex(&cursor, lines[r].text, -1);
		y -= cursor.y + cursor.font_size;

		// cut off if msgs waste too much space
		if(y < 200.0f)
			break;
		
		// reset the cursor
		gfx_text_set_cursor(&cursor, begin, y, fontsize, TEXTFLAG_RENDER);
		cursor.line_width = 200.0f;

		// render name
		vec3 tcolor;
		gfx_text_color(0.8f,0.8f,0.8f,1);
		if(lines[r].client_id == -1)
			gfx_text_color(1,1,0.5f,1); // system
		else if(lines[r].team)
			gfx_text_color(0.45f,0.9f,0.45f,1); // team message
		else if(lines[r].name_color == 0)
		{
			if(!gameclient.snap.local_info)
				gfx_text_color(1.0f,0.5f,0.5f,1); // red
			else
			{
				tcolor = TeecompUtils::getTeamColor(0, gameclient.snap.local_info->team, config.tc_colored_tees_team1,
						config.tc_colored_tees_team2, config.tc_colored_tees_method);
				gfx_text_color(tcolor.r, tcolor.g, tcolor.b, 1);
			}
		}
		else if(lines[r].name_color == 1)
		{
			if(!gameclient.snap.local_info)
				gfx_text_color(0.7f,0.7f,1.0f,1); // blue
			else
			{
				tcolor = TeecompUtils::getTeamColor(1, gameclient.snap.local_info->team, config.tc_colored_tees_team1,
						config.tc_colored_tees_team2, config.tc_colored_tees_method);
				gfx_text_color(tcolor.r, tcolor.g, tcolor.b, 1);
			}	
		}
		else if(lines[r].name_color == -1)
			gfx_text_color(0.75f,0.5f,0.75f, 1); // spectator
			
		// render name
		gfx_text_ex(&cursor, lines[r].name, -1);

		// render line
		gfx_text_color(1,1,1,1);
		if(lines[r].client_id == -1)
			gfx_text_color(1,1,0.5f,1); // system
		else if(lines[r].team)
			gfx_text_color(0.65f,1,0.65f,1); // team message

		gfx_text_ex(&cursor, lines[r].text, -1);
	}

	gfx_text_color(1,1,1,1);
}
Ejemplo n.º 6
0
void CONSOLE::on_render()
{
    RECT screen = *ui_screen();
	float console_max_height = screen.h*3/5.0f;
	float console_height;

	float progress = (time_now()-(state_change_end-state_change_duration))/float(state_change_duration);

	if (progress >= 1.0f)
	{
		if (console_state == CONSOLE_CLOSING)
			console_state = CONSOLE_CLOSED;
		else if (console_state == CONSOLE_OPENING)
			console_state = CONSOLE_OPEN;

		progress = 1.0f;
	}
		
	if (console_state == CONSOLE_CLOSED)
		return;
		
	if (console_state == CONSOLE_OPEN)
		inp_mouse_mode_absolute();

	float console_height_scale;

	if (console_state == CONSOLE_OPENING)
		console_height_scale = console_scale_func(progress);
	else if (console_state == CONSOLE_CLOSING)
		console_height_scale = console_scale_func(1.0f-progress);
	else //if (console_state == CONSOLE_OPEN)
		console_height_scale = console_scale_func(1.0f);

	console_height = console_height_scale*console_max_height;

	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);

	// do console shadow
	gfx_texture_set(-1);
    gfx_quads_begin();
    gfx_setcolorvertex(0, 0,0,0, 0.5f);
    gfx_setcolorvertex(1, 0,0,0, 0.5f);
    gfx_setcolorvertex(2, 0,0,0, 0.0f);
    gfx_setcolorvertex(3, 0,0,0, 0.0f);
    gfx_quads_drawTL(0,console_height,screen.w,10.0f);
    gfx_quads_end();

	// do background
	gfx_texture_set(data->images[IMAGE_CONSOLE_BG].id);
    gfx_quads_begin();
    gfx_setcolor(0.2f, 0.2f, 0.2f,0.9f);
    if(console_type != 0)
	    gfx_setcolor(0.4f, 0.2f, 0.2f,0.9f);
    gfx_quads_setsubset(0,-console_height*0.075f,screen.w*0.075f*0.5f,0);
    gfx_quads_drawTL(0,0,screen.w,console_height);
    gfx_quads_end();

	// do small bar shadow
	gfx_texture_set(-1);
    gfx_quads_begin();
    gfx_setcolorvertex(0, 0,0,0, 0.0f);
    gfx_setcolorvertex(1, 0,0,0, 0.0f);
    gfx_setcolorvertex(2, 0,0,0, 0.25f);
    gfx_setcolorvertex(3, 0,0,0, 0.25f);
    gfx_quads_drawTL(0,console_height-20,screen.w,10);
    gfx_quads_end();

	// do the lower bar
	gfx_texture_set(data->images[IMAGE_CONSOLE_BAR].id);
    gfx_quads_begin();
    gfx_setcolor(1.0f, 1.0f, 1.0f, 0.9f);
    gfx_quads_setsubset(0,0.1f,screen.w*0.015f,1-0.1f);
    gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f);
    gfx_quads_end();
    
    console_height -= 22.0f;
    
    INSTANCE *console = current_console();

	{
		float font_size = 10.0f;
		float row_height = font_size*1.25f;
		float x = 3;
		float y = console_height - row_height - 2;

		// render prompt		
		TEXT_CURSOR cursor;
		gfx_text_set_cursor(&cursor, x, y, font_size, TEXTFLAG_RENDER);

		RENDERINFO info;
		info.wanted_completion = console->completion_chosen;
		info.enum_count = 0;
		info.current_cmd = console->completion_buffer;
		gfx_text_set_cursor(&info.cursor, x, y+12.0f, font_size, TEXTFLAG_RENDER);

		const char *prompt = "> ";
		if(console_type)
		{
			if(client_state() == CLIENTSTATE_ONLINE)
			{
				if(client_rcon_authed())
					prompt = "rcon> ";
				else
					prompt = "ENTER PASSWORD> ";
			}
			else
				prompt = "NOT CONNECTED> ";
		}

		gfx_text_ex(&cursor, prompt, -1);
		
		// render console input
		gfx_text_ex(&cursor, console->input.get_string(), console->input.cursor_offset());
		TEXT_CURSOR marker = cursor;
		gfx_text_ex(&marker, "|", -1);
		gfx_text_ex(&cursor, console->input.get_string()+console->input.cursor_offset(), -1);
		
		// render version
		char buf[128];
		str_format(buf, sizeof(buf), "v%s", GAME_VERSION);
		float version_width = gfx_text_width(0, font_size, buf, -1);
		gfx_text(0, screen.w-version_width-5, y, font_size, buf, -1);

		// render possible commands
		if(console->input.get_string()[0] != 0)
		{
			console_possible_commands(console->completion_buffer, console->completion_flagmask, possible_commands_render_callback, &info);
			
			if(info.enum_count <= 0)
			{
				if(console->command)
				{
					
					char buf[512];
					str_format(buf, sizeof(buf), "Help: %s ", console->command->help);
					gfx_text_ex(&info.cursor, buf, -1);
					gfx_text_color(0.75f, 0.75f, 0.75f, 1);
					str_format(buf, sizeof(buf), "Syntax: %s %s", console->command->name, console->command->params);
					gfx_text_ex(&info.cursor, buf, -1);
				}
			}
		}
		gfx_text_color(1,1,1,1);

		// render log
		y -= row_height;
		char *entry = (char *)ringbuf_last(console->backlog);
		while (y > 0.0f && entry)
		{
			gfx_text(0, x, y, font_size, entry, -1);
			y -= row_height;

			entry = (char *)ringbuf_prev(console->backlog, entry);
		}
	}	
}
Ejemplo n.º 7
0
void DEBUGHUD::render_tuning()
{
	// render tuning debugging
	if(!config.dbg_tuning)
		return;
		
	TUNING_PARAMS standard_tuning;
		
	gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300);
	
	float y = 50.0f;
	int count = 0;
	for(int i = 0; i < gameclient.tuning.num(); i++)
	{
		char buf[128];
		float current, standard;
		gameclient.tuning.get(i, &current);
		standard_tuning.get(i, &standard);
		
		if(standard == current)
			gfx_text_color(1,1,1,1.0f);
		else
			gfx_text_color(1,0.25f,0.25f,1.0f);

		float w;
		float x = 5.0f;
		
		str_format(buf, sizeof(buf), "%.2f", standard);
		x += 20.0f;
		w = gfx_text_width(0, 5, buf, -1);
		gfx_text(0x0, x-w, y+count*6, 5, buf, -1);

		str_format(buf, sizeof(buf), "%.2f", current);
		x += 20.0f;
		w = gfx_text_width(0, 5, buf, -1);
		gfx_text(0x0, x-w, y+count*6, 5, buf, -1);

		x += 5.0f;
		gfx_text(0x0, x, y+count*6, 5, gameclient.tuning.names[i], -1);
		
		count++;
	}
	
	y = y+count*6;
	
	gfx_texture_set(-1);
	gfx_blend_normal();
	gfx_lines_begin();
	float height = 50.0f;
	float pv = 1;
	for(int i = 0; i < 100; i++)
	{
		float speed = i/100.0f * 3000;
		float ramp = velocity_ramp(speed, gameclient.tuning.velramp_start, gameclient.tuning.velramp_range, gameclient.tuning.velramp_curvature);
		float rampedspeed = (speed * ramp)/1000.0f;
		gfx_lines_draw((i-1)*2, y+height-pv*height, i*2, y+height-rampedspeed*height);
		//gfx_lines_draw((i-1)*2, 200, i*2, 200);
		pv = rampedspeed;
	}
	gfx_lines_end();
	gfx_text_color(1,1,1,1);
}