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); } }
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); }
void HUD::render_connectionwarning() { if(client_connection_problems()) { const char *text = "Connection Problems..."; float w = gfx_text_width(0, 24, text, -1); gfx_text(0, 150*gfx_screenaspect()-w/2, 50, 24, text, -1); } }
void HUD::render_fps() { if(config.cl_showfps && !config.cl_clear_all && !config.cl_clear_hud) { char buf[512]; str_format(buf, sizeof(buf), "%d", (int)(1.0f/client_frametime())); gfx_text(0, width-10-gfx_text_width(0,12,buf,-1), 5, 12, buf, -1); } }
void BROADCAST::on_render() { gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300); if(time_get() < broadcast_time) { float w = gfx_text_width(0, 14, broadcast_text, -1); gfx_text(0, 150*gfx_screenaspect()-w/2, 35, 14, broadcast_text, -1); } }
void MENUS::render_loading(float percent) { static int64 last_load_render = 0; // make sure that we don't render for each little thing we load // because that will slow down loading if we have vsync if(time_get()-last_load_render < time_freq()/60) return; last_load_render = time_get(); // need up date this here to get correct vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f)); gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f); RECT screen = *ui_screen(); gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); render_background(); float tw; float w = 700; float h = 200; float x = screen.w/2-w/2; float y = screen.h/2-h/2; gfx_blend_normal(); gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(0,0,0,0.50f); draw_round_rect(x, y, w, h, 40.0f); gfx_quads_end(); const char *caption = localize("Loading"); tw = gfx_text_width(0, 48.0f, caption, -1); RECT r; r.x = x; r.y = y+20; r.w = w; r.h = h; ui_do_label(&r, caption, 48.0f, 0, -1); gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(1,1,1,0.75f); draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f); gfx_quads_end(); gfx_swap(); }
void BROADCAST::on_render() { if(!config.cl_render_broadcast || config.cl_clear_all) return; gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300); if(time_get() < broadcast_time) { float w = gfx_text_width(0, 14, broadcast_text, -1); gfx_text(0, 150*gfx_screenaspect()-w/2, 35, 14, broadcast_text, -1); } }
void SCOREBOARD::render_goals(float x, float y, float w) { float h = 50.0f; gfx_blend_normal(); gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(0,0,0,0.5f); draw_round_rect(x-10.f, y-10.f, w, h, 10.0f); gfx_quads_end(); // render goals //y = ystart+h-54; float tw = 0.0f; if(gameclient.snap.gameobj && gameclient.snap.gameobj->score_limit) { char buf[64]; str_format(buf, sizeof(buf), "Score Limit: %d", gameclient.snap.gameobj->score_limit); gfx_text(0, x+20.0f, y, 22.0f, buf, -1); tw += gfx_text_width(0, 22.0f, buf, -1); } if(gameclient.snap.gameobj && gameclient.snap.gameobj->time_limit) { char buf[64]; str_format(buf, sizeof(buf), "Time Limit: %d min", gameclient.snap.gameobj->time_limit); gfx_text(0, x+220.0f, y, 22.0f, buf, -1); tw += gfx_text_width(0, 22.0f, buf, -1); } if(gameclient.snap.gameobj && gameclient.snap.gameobj->round_num && gameclient.snap.gameobj->round_current) { char buf[64]; str_format(buf, sizeof(buf), "Round %d/%d", gameclient.snap.gameobj->round_current, gameclient.snap.gameobj->round_num); gfx_text(0, x+450.0f, y, 22.0f, buf, -1); /*[48c3fd4c][game/scoreboard]: timelimit x:219.428558 [48c3fd4c][game/scoreboard]: round x:453.142822*/ } }
static void update_display(setting_render_internal_t* renderer) { // Render it out vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgSetfv(VG_CLEAR_COLOR, 4, renderer->definition.background_colour); vgClear(renderer->definition.x, renderer->definition.y, renderer->definition.width, renderer->definition.height); vgSetiv(VG_SCISSOR_RECTS, 4, &renderer->definition.x); vgSeti(VG_SCISSORING, VG_TRUE); vgTranslate(renderer->definition.x, renderer->definition.y); vgSeti(VG_RENDERING_QUALITY, renderer->definition.text_quality); vgSetPaint(renderer->state.text_paint, VG_FILL_PATH); gfx_render_text(renderer->definition.text_x_offset, renderer->definition.text_y_offset, renderer->definition.text, &gfx_font_sans, renderer->definition.text_size); VGfloat text_width = gfx_text_width(renderer->definition.text, &gfx_font_sans, renderer->definition.text_size); const size_t buffer_size = 512; char setting_text_buffer[buffer_size]; setting_t* setting = renderer->definition.setting; switch(setting->type) { case SETTING_TYPE_INT: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_int(setting)); break; } case SETTING_TYPE_FLOAT: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_float(setting)); break; } case SETTING_TYPE_ENUM: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_enum(setting)); break; } default: snprintf(setting_text_buffer, buffer_size - 1, "ILLEGAL SETTING TYPE: %d", (int)setting->type); break; } setting_text_buffer[buffer_size - 1] = 0; gfx_render_text(text_width + 2 + renderer->definition.text_x_offset, renderer->definition.text_y_offset, setting_text_buffer, &gfx_font_sans, renderer->definition.text_size); vgSeti(VG_SCISSORING, VG_FALSE); }
void HUD::render_speed() { if(!config.tc_speedmeter) return; // We calculate the speed instead of getting it from character.velocity cause it's buggy when // walking in front of a wall or when using the ninja sword static float speed; static vec2 oldpos; static const int SMOOTH_TABLE_SIZE = 16; static const int ACCEL_THRESHOLD = 25; static float smooth_table[SMOOTH_TABLE_SIZE]; static int smooth_index = 0; smooth_table[smooth_index] = distance(gameclient.local_character_pos, oldpos)/client_frametime(); if(demorec_isplaying()) { float mult = client_demoplayer_getinfo()->speed; smooth_table[smooth_index] /= mult; } smooth_index = (smooth_index + 1) % SMOOTH_TABLE_SIZE; oldpos = gameclient.local_character_pos; speed = 0; for(int i=0; i<SMOOTH_TABLE_SIZE; i++) speed += smooth_table[i]; speed /= SMOOTH_TABLE_SIZE; int t = (gameclient.snap.gameobj->flags & GAMEFLAG_TEAMS)? -1 : 1; int last_index = smooth_index - 1; if(last_index < 0) last_index = SMOOTH_TABLE_SIZE - 1; gfx_blend_normal(); gfx_texture_set(-1); gfx_quads_begin(); if(config.tc_speedmeter_accel && speed - smooth_table[last_index] > ACCEL_THRESHOLD) gfx_setcolor(0.6f, 0.1f, 0.1f, 0.25f); else if(config.tc_speedmeter_accel && speed - smooth_table[last_index] < -ACCEL_THRESHOLD) gfx_setcolor(0.1f, 0.6f, 0.1f, 0.25f); else gfx_setcolor(0.1, 0.1, 0.1, 0.25); draw_round_rect(width-40, 245+t*20, 50, 18, 5.0f); gfx_quads_end(); char buf[16]; str_format(buf, sizeof(buf), "%.0f", speed); gfx_text(0, width-5-gfx_text_width(0,12,buf,-1), 246+t*20, 12, buf, -1); }
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; }
void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const char *title) { //float ystart = y; float h = 750.0f; gfx_blend_normal(); gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(0,0,0,0.5f); draw_round_rect(x-10.f, y-10.f, w, h, 17.0f); gfx_quads_end(); // render title if(!title) { if(gameclient.snap.gameobj->game_over) title = "Game Over"; else title = "Score Board"; } float tw = gfx_text_width(0, 48, title, -1); if(team == -1) { gfx_text(0, x+w/2-tw/2, y, 48, title, -1); } else { gfx_text(0, x+10, y, 48, title, -1); if(gameclient.snap.gameobj) { char buf[128]; int score = team ? gameclient.snap.gameobj->teamscore_blue : gameclient.snap.gameobj->teamscore_red; str_format(buf, sizeof(buf), "%d", score); tw = gfx_text_width(0, 48, buf, -1); gfx_text(0, x+w-tw-30, y, 48, buf, -1); } } y += 54.0f; // find players const NETOBJ_PLAYER_INFO *players[MAX_CLIENTS] = {0}; int num_players = 0; for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++) { SNAP_ITEM item; const void *data = snap_get_item(SNAP_CURRENT, i, &item); if(item.type == NETOBJTYPE_PLAYER_INFO) { const NETOBJ_PLAYER_INFO *info = (const NETOBJ_PLAYER_INFO *)data; if(info->team == team) { players[num_players] = info; num_players++; } } } // sort players for(int k = 0; k < num_players; k++) // ffs, bubblesort { for(int i = 0; i < num_players-k-1; i++) { if(players[i]->score < players[i+1]->score) { const NETOBJ_PLAYER_INFO *tmp = players[i]; players[i] = players[i+1]; players[i+1] = tmp; } } } // render headlines gfx_text(0, x+10, y, 24.0f, "Score", -1); gfx_text(0, x+125, y, 24.0f, "Name", -1); gfx_text(0, x+w-70, y, 24.0f, "Ping", -1); y += 29.0f; float font_size = 35.0f; float line_height = 50.0f; float tee_sizemod = 1.0f; float tee_offset = 0.0f; if(num_players > 13) { font_size = 30.0f; line_height = 40.0f; tee_sizemod = 0.8f; tee_offset = -5.0f; } // render player scores for(int i = 0; i < num_players; i++) { const NETOBJ_PLAYER_INFO *info = players[i]; // make sure that we render the correct team char buf[128]; if(info->local) { // background so it's easy to find the local player gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(1,1,1,0.25f); draw_round_rect(x, y, w-20, line_height*0.95f, 17.0f); gfx_quads_end(); } str_format(buf, sizeof(buf), "%4d", info->score); gfx_text(0, x+60-gfx_text_width(0, font_size,buf,-1), y, font_size, buf, -1); if(config.cl_scoreboard_client_id) { str_format(buf, sizeof(buf), "%d | %s", info->cid, gameclient.clients[info->cid].name); gfx_text(0, x+128, y, font_size, buf, -1); } else { gfx_text(0, x+128, y, font_size, gameclient.clients[info->cid].name, -1); } str_format(buf, sizeof(buf), "%4d", info->latency); float tw = gfx_text_width(0, font_size, buf, -1); gfx_text(0, x+w-tw-35, y, font_size, buf, -1); // render avatar if((gameclient.snap.flags[0] && gameclient.snap.flags[0]->carried_by == info->cid) || (gameclient.snap.flags[1] && gameclient.snap.flags[1]->carried_by == info->cid)) { gfx_blend_normal(); if(config.tc_colored_flags) gfx_texture_set(data->images[IMAGE_GAME_GRAY].id); else gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); if(info->team == 0) select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); else select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); if(config.tc_colored_flags) { vec3 col = TeecompUtils::getTeamColor(1-info->team, gameclient.snap.local_info->team, config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method); gfx_setcolor(col.r, col.g, col.b, 1.0f); } float size = 64.0f; gfx_quads_drawTL(x+55, y-15, size/2, size); gfx_quads_end(); } TEE_RENDER_INFO teeinfo = gameclient.clients[info->cid].render_info; teeinfo.size *= tee_sizemod; render_tee(ANIMSTATE::get_idle(), &teeinfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+tee_offset)); y += line_height; } }
void SCOREBOARD::on_render() { bool do_scoreboard = false; // if we activly wanna look on the scoreboard if(active) do_scoreboard = true; if(gameclient.snap.local_info && gameclient.snap.local_info->team != -1) { // we are not a spectator, check if we are ead if(!gameclient.snap.local_character || gameclient.snap.local_character->health < 0) do_scoreboard = true; } // if we the game is over if(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over) do_scoreboard = true; // we're looking at the stats, don't show the scoreboard if(gameclient.teecomp_stats->is_active()) do_scoreboard = false; if(!do_scoreboard) return; // if the score board is active, then we should clear the motd message aswell if(active) gameclient.motd->clear(); float width = 400*3.0f*gfx_screenaspect(); float height = 400*3.0f; gfx_mapscreen(0, 0, width, height); float w = 650.0f; if(gameclient.snap.gameobj && !(gameclient.snap.gameobj->flags&GAMEFLAG_TEAMS)) { render_scoreboard(width/2-w/2, 150.0f, w, 0, 0); //render_scoreboard(gameobj, 0, 0, -1, 0); } else { char text[32]; if(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over) { str_copy(text, "DRAW!", sizeof(text)); if(gameclient.snap.gameobj->teamscore_red > gameclient.snap.gameobj->teamscore_blue) { if(gameclient.snap.local_info->team == 1 && config.tc_colored_tees_method == 1) str_format(text, sizeof(text), "%s Team Wins!", TeecompUtils::rgb_to_name(config.tc_colored_tees_team2)); else str_format(text, sizeof(text), "%s Team Wins!", TeecompUtils::rgb_to_name(config.tc_colored_tees_team1)); } else if(gameclient.snap.gameobj->teamscore_blue > gameclient.snap.gameobj->teamscore_red) { if(gameclient.snap.local_info->team == 1 && config.tc_colored_tees_method == 1) str_format(text, sizeof(text), "%s Team Wins!", TeecompUtils::rgb_to_name(config.tc_colored_tees_team1)); else str_format(text, sizeof(text), "%s Team Wins!", TeecompUtils::rgb_to_name(config.tc_colored_tees_team2)); } float w = gfx_text_width(0, 92.0f, text, -1); gfx_text(0, width/2-w/2, 45, 92.0f, text, -1); } if(gameclient.snap.local_info && gameclient.snap.local_info->team == 1 && config.tc_colored_tees_method == 1) str_format(text, sizeof(text), "%s Team", TeecompUtils::rgb_to_name(config.tc_colored_tees_team2)); else str_format(text, sizeof(text), "%s Team", TeecompUtils::rgb_to_name(config.tc_colored_tees_team1)); render_scoreboard(width/2-w-20, 150.0f, w, 0, text); if(gameclient.snap.local_info && gameclient.snap.local_info->team == 1 && config.tc_colored_tees_method == 1) str_format(text, sizeof(text), "%s Team", TeecompUtils::rgb_to_name(config.tc_colored_tees_team1)); else str_format(text, sizeof(text), "%s Team", TeecompUtils::rgb_to_name(config.tc_colored_tees_team2)); render_scoreboard(width/2 + 20, 150.0f, w, 1, text); } render_goals(width/2-w/2, 150+750+25, w); render_spectators(width/2-w/2, 150+750+25+50+25, w); }
int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, unsigned str_size, float font_size, bool hidden) { int inside = ui_mouse_inside(rect); int r = 0; static int at_index = 0; if(ui_last_active_item() == id) { int len = strlen(str); if (inside && ui_mouse_button(0)) { int mx_rel = (int)(ui_mouse_x() - rect->x); for (int i = 1; i <= len; i++) { if (gfx_text_width(0, font_size, str, i) + 10 > mx_rel) { at_index = i - 1; break; } if (i == len) at_index = len; } } for(int i = 0; i < num_inputevents; i++) { len = strlen(str); LINEINPUT::manipulate(inputevents[i], str, str_size, &len, &at_index); } } bool just_got_active = false; if(ui_active_item() == id) { if(!ui_mouse_button(0)) ui_set_active_item(0); } else if(ui_hot_item() == id) { if(ui_mouse_button(0)) { if (ui_last_active_item() != id) just_got_active = true; ui_set_active_item(id); } } if(inside) ui_set_hot_item(id); RECT textbox = *rect; ui_draw_rect(&textbox, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f); ui_vmargin(&textbox, 5.0f, &textbox); const char *display_str = str; char stars[128]; if(hidden) { unsigned s = strlen(str); if(s >= sizeof(stars)) s = sizeof(stars)-1; memset(stars, '*', s); stars[s] = 0; display_str = stars; } ui_do_label(&textbox, display_str, font_size, -1); if (ui_last_active_item() == id && !just_got_active) { float w = gfx_text_width(0, font_size, display_str, at_index); textbox.x += w*ui_scale(); ui_do_label(&textbox, "_", font_size, -1); } return r; }
void HUD::render_goals() { // TODO: split this up into these: // render_gametimer // render_suddendeath // render_scorehud // render_warmuptimer int gameflags = gameclient.snap.gameobj->flags; float whole = 300*gfx_screenaspect(); float half = whole/2.0f; gfx_mapscreen(0,0,300*gfx_screenaspect(),300); if(!gameclient.snap.gameobj->sudden_death) { char buf[32]; int time = 0; if(gameclient.snap.gameobj->time_limit) { time = gameclient.snap.gameobj->time_limit*60 - ((client_tick()-gameclient.snap.gameobj->round_start_tick)/client_tickspeed()); if(gameclient.snap.gameobj->game_over) time = 0; } else time = (client_tick()-gameclient.snap.gameobj->round_start_tick)/client_tickspeed(); if(config.cl_render_time && !config.cl_clear_hud && !config.cl_clear_all) { str_format(buf, sizeof(buf), "%d:%02d", time /60, time %60); float w = gfx_text_width(0, 16, buf, -1); gfx_text(0, half-w/2, 2, 16, buf, -1); } } if((config.cl_render_time && !config.cl_clear_hud && !config.cl_clear_all) && gameclient.snap.gameobj->sudden_death) { const char *text = "Sudden Death"; float w = gfx_text_width(0, 16, text, -1); gfx_text(0, half-w/2, 2, 16, text, -1); } // render small score hud if((config.cl_render_score && !config.cl_clear_hud && !config.cl_clear_all) && !(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over) && (gameflags&GAMEFLAG_TEAMS)) { for(int t = 0; t < 2; t++) { gfx_blend_normal(); gfx_texture_set(-1); gfx_quads_begin(); if(!config.tc_hud_match) { if(t == 0) gfx_setcolor(1,0,0,0.25f); else gfx_setcolor(0,0,1,0.25f); } else { vec3 col = TeecompUtils::getTeamColor(t, gameclient.snap.local_info->team, config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method); gfx_setcolor(col.r, col.g, col.b, 0.25f); } draw_round_rect(whole-40, 300-40-15+t*20, 50, 18, 5.0f); gfx_quads_end(); char buf[32]; str_format(buf, sizeof(buf), "%d", t?gameclient.snap.gameobj->teamscore_blue:gameclient.snap.gameobj->teamscore_red); float w = gfx_text_width(0, 14, buf, -1); if(gameflags&GAMEFLAG_FLAGS) { gfx_text(0, whole-20-w/2+5, 300-40-15+t*20, 14, buf, -1); if(gameclient.snap.flags[t]) { if(gameclient.snap.flags[t]->carried_by == -2 || (gameclient.snap.flags[t]->carried_by == -1 && ((client_tick()/10)&1))) { gfx_blend_normal(); if(config.tc_colored_flags) gfx_texture_set(data->images[IMAGE_GAME_GRAY].id); else gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); if(t == 0) select_sprite(SPRITE_FLAG_RED); else select_sprite(SPRITE_FLAG_BLUE); if(config.tc_colored_flags) { vec3 col = TeecompUtils::getTeamColor(t, gameclient.snap.local_info->team, config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method); gfx_setcolor(col.r, col.g, col.b, 1.0f); } float size = 16; gfx_quads_drawTL(whole-40+5, 300-40-15+t*20+1, size/2, size); gfx_quads_end(); } else if(gameclient.snap.flags[t]->carried_by >= 0) { int id = gameclient.snap.flags[t]->carried_by%MAX_CLIENTS; const char *name = gameclient.clients[id].name; float w = gfx_text_width(0, 10, name, -1); gfx_text(0, whole-40-5-w, 300-40-15+t*20+2, 10, name, -1); TEE_RENDER_INFO info = gameclient.clients[id].render_info; info.size = 18.0f; render_tee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0), vec2(whole-40+10, 300-40-15+9+t*20+1)); } } } else gfx_text(0, whole-20-w/2, 300-40-15+t*20, 14, buf, -1); } } // render warmup timer if((config.cl_render_warmup && !config.cl_clear_all) && gameclient.snap.gameobj->warmup) { char buf[256]; float w = gfx_text_width(0, 24, "Warmup", -1); gfx_text(0, 150*gfx_screenaspect()+-w/2, 50, 24, "Warmup", -1); int seconds = gameclient.snap.gameobj->warmup/SERVER_TICK_SPEED; if(seconds < 5) str_format(buf, sizeof(buf), "%d.%d", seconds, (gameclient.snap.gameobj->warmup*10/SERVER_TICK_SPEED)%10); else str_format(buf, sizeof(buf), "%d", seconds); w = gfx_text_width(0, 24, buf, -1); gfx_text(0, 150*gfx_screenaspect()+-w/2, 75, 24, buf, -1); } }
void KILLMESSAGES::on_render() { if(config.cl_render_kill && !config.cl_clear_all) { float width = 400*3.0f*gfx_screenaspect(); float height = 400*3.0f; gfx_mapscreen(0, 0, width*1.5f, height*1.5f); float startx = width*1.5f-10.0f; float y = 20.0f; for(int i = 0; i < killmsg_max; i++) { int r = (killmsg_current+i+1)%killmsg_max; if(client_tick() > killmsgs[r].tick+50*10) continue; float font_size = 36.0f; float killername_w = gfx_text_width(0, font_size, gameclient.clients[killmsgs[r].killer].name, -1); float victimname_w = gfx_text_width(0, font_size, gameclient.clients[killmsgs[r].victim].name, -1); float x = startx; // render victim name x -= victimname_w; gfx_text(0, x, y, font_size, gameclient.clients[killmsgs[r].victim].name, -1); // render victim tee x -= 24.0f; if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS) { if(killmsgs[r].mode_special&1) { gfx_blend_normal(); if(config.tc_colored_flags) gfx_texture_set(data->images[IMAGE_GAME_GRAY].id); else gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); if(gameclient.clients[killmsgs[r].victim].team == 0) select_sprite(SPRITE_FLAG_BLUE); else select_sprite(SPRITE_FLAG_RED); if(config.tc_colored_flags) { vec3 col = TeecompUtils::getTeamColor(1-gameclient.clients[killmsgs[r].victim].team, gameclient.snap.local_info->team, config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method); gfx_setcolor(col.r, col.g, col.b, 1.0f); } float size = 56.0f; gfx_quads_drawTL(x, y-16, size/2, size); gfx_quads_end(); } } // anti rainbow TEE_RENDER_INFO victim = gameclient.clients[killmsgs[r].victim].render_info; if(config.cl_anti_rainbow && (gameclient.clients[killmsgs[r].victim].color_change_count > config.cl_anti_rainbow_count)) { if(config.tc_force_skin_team1) victim.texture = gameclient.skins->get(max(0, gameclient.skins->find(config.tc_forced_skin1)))->org_texture; else victim.texture = gameclient.skins->get(gameclient.clients[killmsgs[r].victim].skin_id)->org_texture; victim.color_body = vec4(1,1,1,1); victim.color_feet = vec4(1,1,1,1); } render_tee(ANIMSTATE::get_idle(), &victim, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); x -= 32.0f; // render weapon x -= 44.0f; if (killmsgs[r].weapon >= 0) { gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); select_sprite(data->weapons.id[killmsgs[r].weapon].sprite_body); draw_sprite(x, y+28, 96); gfx_quads_end(); } x -= 52.0f; if(killmsgs[r].victim != killmsgs[r].killer) { if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS) { if(killmsgs[r].mode_special&2) { gfx_blend_normal(); if(config.tc_colored_flags) gfx_texture_set(data->images[IMAGE_GAME_GRAY].id); else gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); if(gameclient.clients[killmsgs[r].killer].team == 0) select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); else select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); if(config.tc_colored_flags) { vec3 col = TeecompUtils::getTeamColor(1-gameclient.clients[killmsgs[r].killer].team, gameclient.snap.local_info->team, config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method); gfx_setcolor(col.r, col.g, col.b, 1.0f); } float size = 56.0f; gfx_quads_drawTL(x-56, y-16, size/2, size); gfx_quads_end(); } } // anti rainbow TEE_RENDER_INFO killer = gameclient.clients[killmsgs[r].killer].render_info; if(config.cl_anti_rainbow && (gameclient.clients[killmsgs[r].killer].color_change_count > config.cl_anti_rainbow_count)) { if(config.tc_force_skin_team1) killer.texture = gameclient.skins->get(max(0, gameclient.skins->find(config.tc_forced_skin1)))->org_texture; else killer.texture = gameclient.skins->get(gameclient.clients[killmsgs[r].killer].skin_id)->org_texture; killer.color_body = vec4(1,1,1,1); killer.color_feet = vec4(1,1,1,1); } // render killer tee x -= 24.0f; render_tee(ANIMSTATE::get_idle(), &killer, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); x -= 32.0f; // render killer name x -= killername_w; gfx_text(0, x, y, font_size, gameclient.clients[killmsgs[r].killer].name, -1); } y += 44; } } }
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, ¤t); 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); }
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); } } }