diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor/editor.cpp | 6 | ||||
| -rw-r--r-- | src/engine/client/ec_client.c | 2 | ||||
| -rw-r--r-- | src/engine/client/ec_font.c | 20 | ||||
| -rw-r--r-- | src/engine/client/ec_font.h | 2 | ||||
| -rw-r--r-- | src/engine/client/ec_gfx.c | 58 | ||||
| -rw-r--r-- | src/engine/client/ec_inp.c | 3 | ||||
| -rw-r--r-- | src/engine/e_config_variables.h | 1 | ||||
| -rw-r--r-- | src/engine/e_interface.h | 7 | ||||
| -rw-r--r-- | src/game/client/gc_client.cpp | 38 | ||||
| -rw-r--r-- | src/game/client/gc_mapres_image.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/gc_menu.cpp | 191 | ||||
| -rw-r--r-- | src/game/client/gc_skin.cpp | 4 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 2 |
13 files changed, 237 insertions, 99 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index 43ee1651..33175f7f 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -365,7 +365,7 @@ static int tilesets_set_img(int index, int w, int h, void *data) if(tilesets[index].img.data) mem_free(tilesets[index].img.data); tilesets[index].img.data = data; - tilesets[index].tex_id = gfx_load_texture_raw(w, h, IMG_RGBA, data); + tilesets[index].tex_id = gfx_load_texture_raw(w, h, IMG_RGBA, data, IMG_RGBA); return index; } @@ -1360,8 +1360,8 @@ extern "C" void editor_update_and_render() extern "C" void editor_init() { // reset and start - font_texture = gfx_load_texture("data/debug_font.png"); - checker_texture = gfx_load_texture("data/checker.png"); + font_texture = gfx_load_texture("data/debug_font.png", IMG_AUTO); + checker_texture = gfx_load_texture("data/checker.png", IMG_AUTO); editor_reset(); layer *l = layers_get(layers_new(50, 50)); diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c index 1b9b0120..d35121de 100644 --- a/src/engine/client/ec_client.c +++ b/src/engine/client/ec_client.c @@ -442,7 +442,7 @@ void client_disconnect() static int client_load_data() { - debug_font = gfx_load_texture("data/debug_font.png"); + debug_font = gfx_load_texture("data/debug_font.png", IMG_AUTO); return 1; } diff --git a/src/engine/client/ec_font.c b/src/engine/client/ec_font.c index 92ba3cb7..04f8b954 100644 --- a/src/engine/client/ec_font.c +++ b/src/engine/client/ec_font.c @@ -1,6 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include <stdarg.h> #include <stdio.h> +#include <string.h> #include <engine/e_system.h> #include "ec_font.h" @@ -86,7 +87,8 @@ int font_load(FONT *font, const char *filename) return -1; } -int gfx_load_texture(const char *filename); +int gfx_load_texture(const char *filename, int store_format); +#define IMG_ALPHA 2 int font_set_load(FONT_SET *font_set, const char *font_filename, const char *text_texture_filename, const char *outline_texture_filename, int fonts, ...) { @@ -117,8 +119,8 @@ int font_set_load(FONT_SET *font_set, const char *font_filename, const char *tex } font->size = size; - font->text_texture = gfx_load_texture(composed_text_texture_filename); - font->outline_texture = gfx_load_texture(composed_outline_texture_filename); + font->text_texture = gfx_load_texture(composed_text_texture_filename, IMG_ALPHA); + font->outline_texture = gfx_load_texture(composed_outline_texture_filename, IMG_ALPHA); } va_end(va); @@ -130,16 +132,24 @@ float font_text_width(FONT *font, const char *text, float size, int length) float width = 0.0f; const unsigned char *c = (unsigned char *)text; + int chars_left; + if (length == -1) + chars_left = strlen(text); + else + chars_left = length; - while (*c) + while (chars_left--) { float tex_x0, tex_y0, tex_x1, tex_y1; float char_width, char_height; float x_offset, y_offset, x_advance; + float advance; font_character_info(font, *c, &tex_x0, &tex_y0, &tex_x1, &tex_y1, &char_width, &char_height, &x_offset, &y_offset, &x_advance); - width += x_advance; + advance = x_advance + font_kerning(font, *c, *(c+1)); + + width += advance; c++; } diff --git a/src/engine/client/ec_font.h b/src/engine/client/ec_font.h index a68a8452..e38b11b7 100644 --- a/src/engine/client/ec_font.h +++ b/src/engine/client/ec_font.h @@ -28,7 +28,7 @@ typedef struct typedef struct { int font_count; - FONT fonts[8]; + FONT fonts[14]; } FONT_SET; int font_load(FONT *font, const char *filename); diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c index e72fdfa7..0562a24f 100644 --- a/src/engine/client/ec_gfx.c +++ b/src/engine/client/ec_gfx.c @@ -208,7 +208,8 @@ int gfx_init() glfwOpenWindowHint(GLFW_REFRESH_RATE, config.gfx_refresh_rate); /* no resizing allowed */ - /* glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, 1); */ + if (!config.gfx_debug_resizable) + glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, 1); /* open window */ if(config.gfx_fullscreen) @@ -281,13 +282,13 @@ int gfx_init() inp_init(); /* create null texture, will get id=0 */ - gfx_load_texture_raw(4,4,IMG_RGBA,null_texture_data); + gfx_load_texture_raw(4,4,IMG_RGBA,null_texture_data,IMG_RGBA); /* set vsync as needed */ gfx_set_vsync(config.gfx_vsync); /* UGLY as hell, please remove */ - current_font->font_texture = gfx_load_texture("data/big_font.png"); + current_font->font_texture = gfx_load_texture("data/big_font.png", IMG_AUTO); return 1; } @@ -410,12 +411,13 @@ static unsigned char sample(int w, int h, const unsigned char *data, int u, int data[((v+1)*w+u+1)*4+offset])/4; } -int gfx_load_texture_raw(int w, int h, int format, const void *data) +int gfx_load_texture_raw(int w, int h, int format, const void *data, int store_format) { int mipmap = 1; unsigned char *texdata = (unsigned char *)data; unsigned char *tmpdata = 0; int oglformat = 0; + int store_oglformat = 0; int tex = 0; /* don't waste memory on texture if we are stress testing */ @@ -455,36 +457,52 @@ int gfx_load_texture_raw(int w, int h, int format, const void *data) if(config.debug) dbg_msg("gfx", "%d = %dx%d", tex, w, h); + + oglformat = GL_RGBA; + if(format == IMG_RGB) + oglformat = GL_RGB; + else if(format == IMG_ALPHA) + oglformat = GL_ALPHA; /* upload texture */ if(config.gfx_texture_compression) { - oglformat = GL_COMPRESSED_RGBA_ARB; - if(format == IMG_RGB) - oglformat = GL_COMPRESSED_RGB_ARB; + store_oglformat = GL_COMPRESSED_RGBA_ARB; + if(store_format == IMG_RGB) + store_oglformat = GL_COMPRESSED_RGB_ARB; + else if(store_format == IMG_ALPHA) + store_oglformat = GL_COMPRESSED_ALPHA_ARB; } else { - oglformat = GL_RGBA; - if(format == IMG_RGB) - oglformat = GL_RGB; + store_oglformat = GL_RGBA; + if(store_format == IMG_RGB) + store_oglformat = GL_RGB; + else if(store_format == IMG_ALPHA) + store_oglformat = GL_ALPHA; } glGenTextures(1, &textures[tex].tex); glBindTexture(GL_TEXTURE_2D, textures[tex].tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - gluBuild2DMipmaps(GL_TEXTURE_2D, oglformat, w, h, oglformat, GL_UNSIGNED_BYTE, texdata); + gluBuild2DMipmaps(GL_TEXTURE_2D, store_oglformat, w, h, oglformat, GL_UNSIGNED_BYTE, texdata); /* calculate memory usage */ - textures[tex].memsize = w*h*4; + int pixel_size = 4; + if(store_format == IMG_RGB) + pixel_size = 3; + else if(store_format == IMG_ALPHA) + pixel_size = 1; + + textures[tex].memsize = w*h*pixel_size; if(mipmap) { while(w > 2 && h > 2) { w>>=1; h>>=1; - textures[tex].memsize += w*h*4; + textures[tex].memsize += w*h*pixel_size; } } @@ -523,7 +541,7 @@ int gfx_load_mip_texture_raw(int w, int h, int format, const void *data) */ /* simple uncompressed RGBA loaders */ -int gfx_load_texture(const char *filename) +int gfx_load_texture(const char *filename, int store_format) { int l = strlen(filename); IMAGE_INFO img; @@ -531,7 +549,10 @@ int gfx_load_texture(const char *filename) return 0; if(gfx_load_png(&img, filename)) { - int id = gfx_load_texture_raw(img.width, img.height, img.format, img.data); + if (store_format == IMG_AUTO) + store_format = img.format; + + int id = gfx_load_texture_raw(img.width, img.height, img.format, img.data, store_format); mem_free(img.data); return id; } @@ -1052,8 +1073,9 @@ float gfx_pretty_text_raw(float x, float y, float size, const char *text_, int l void gfx_pretty_text(float x, float y, float size, const char *text, int max_width) { - /*gfx_text(gfx_font_set, x, y, 0.8*size, text, max_width); - return;*/ + gfx_text(gfx_font_set, x, y, size, text, max_width); + return; + if(max_width == -1) gfx_pretty_text_raw(x, y, size, text, -1); else @@ -1078,7 +1100,7 @@ void gfx_pretty_text(float x, float y, float size, const char *text, int max_wid float gfx_pretty_text_width(float size, const char *text_, int length) { - /*return gfx_text_width(gfx_font_set, 0.8*size, text_, length);*/ + return gfx_text_width(gfx_font_set, size, text_, length); const float spacing = 0.05f; float w = 0.0f; diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c index 59b54a2f..154342f4 100644 --- a/src/engine/client/ec_inp.c +++ b/src/engine/client/ec_inp.c @@ -147,7 +147,8 @@ void inp_mouse_mode_absolute() void inp_mouse_mode_relative() { - glfwDisable(GLFW_MOUSE_CURSOR); + //if (!config.gfx_debug_resizable) + //glfwDisable(GLFW_MOUSE_CURSOR); } int inp_mouse_doubleclick() diff --git a/src/engine/e_config_variables.h b/src/engine/e_config_variables.h index ff6f686a..99c10c4b 100644 --- a/src/engine/e_config_variables.h +++ b/src/engine/e_config_variables.h @@ -36,6 +36,7 @@ MACRO_CONFIG_INT(gfx_high_detail, 1, 0, 1) MACRO_CONFIG_INT(gfx_texture_quality, 1, 0, 1) MACRO_CONFIG_INT(gfx_fsaa_samples, 0, 0, 16) MACRO_CONFIG_INT(gfx_refresh_rate, 0, 0, 0) +MACRO_CONFIG_INT(gfx_debug_resizable, 0, 0, 0) MACRO_CONFIG_INT(key_screenshot, 267, 32, 512) MACRO_CONFIG_INT(inp_mousesens, 100, 5, 100000) diff --git a/src/engine/e_interface.h b/src/engine/e_interface.h index a4f3baa9..3f14745c 100644 --- a/src/engine/e_interface.h +++ b/src/engine/e_interface.h @@ -20,8 +20,10 @@ enum SNAP_CURRENT=0, SNAP_PREV=1, + IMG_AUTO=-1, IMG_RGB=0, IMG_RGBA=1, + IMG_ALPHA=2, MASK_NONE=0, MASK_SET, @@ -149,6 +151,7 @@ int gfx_window_open(); Arguments: filename - Null terminated string to the file to load. + store_format - What format to store on gfx card as. Returns: An ID to the texture. -1 on failure. @@ -156,7 +159,7 @@ int gfx_window_open(); See Also: <gfx_unload_texture> */ -int gfx_load_texture(const char *filename); +int gfx_load_texture(const char *filename, int store_format); /* Function: gfx_load_texture_raw @@ -177,7 +180,7 @@ int gfx_load_texture(const char *filename); See Also: <gfx_unload_texture> */ -int gfx_load_texture_raw(int w, int h, int format, const void *data); +int gfx_load_texture_raw(int w, int h, int format, const void *data, int store_format); /*int gfx_load_mip_texture_raw(int w, int h, int format, const void *data);*/ /* diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 5e769d69..5598c44f 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -574,7 +574,7 @@ extern "C" void modc_init() for(int i = 0; i < data->num_images; i++) { render_loading(current/total); - data->images[i].id = gfx_load_texture(data->images[i].filename); + data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO); current++; } @@ -1916,13 +1916,13 @@ void render_goals(float x, float y, float w) { char buf[64]; sprintf(buf, "Time Limit: %d min", gameobj->time_limit); - gfx_pretty_text(x+w/2, y, 32, buf, -1); + gfx_pretty_text(x+w/2, y, 24.0f, buf, -1); } if(gameobj && gameobj->score_limit) { char buf[64]; sprintf(buf, "Score Limit: %d", gameobj->score_limit); - gfx_pretty_text(x+40, y, 32, buf, -1); + gfx_pretty_text(x+40, y, 24.0f, buf, -1); } } @@ -1987,26 +1987,26 @@ void render_scoreboard(float x, float y, float w, int team, const char *title) title = "Score Board"; } - float tw = gfx_pretty_text_width( 64, title, -1); + float tw = gfx_pretty_text_width(48, title, -1); if(team == -1) { - gfx_pretty_text(x+w/2-tw/2, y, 64, title, -1); + gfx_pretty_text(x+w/2-tw/2, y, 48, title, -1); } else { - gfx_pretty_text(x+10, y, 64, title, -1); + gfx_pretty_text(x+10, y, 48, title, -1); if(gameobj) { char buf[128]; sprintf(buf, "%d", gameobj->teamscore[team&1]); - tw = gfx_pretty_text_width(64, buf, -1); - gfx_pretty_text(x+w-tw-40, y, 64, buf, -1); + tw = gfx_pretty_text_width(48, buf, -1); + gfx_pretty_text(x+w-tw-30, y, 48, buf, -1); } } - y += 64.0f; + y += 54.0f; /* if(team) @@ -2047,10 +2047,10 @@ void render_scoreboard(float x, float y, float w, int team, const char *title) } // render headlines - gfx_pretty_text(x+10, y, 32, "Score", -1); - gfx_pretty_text(x+125, y, 32, "Name", -1); - gfx_pretty_text(x+w-70, y, 32, "Ping", -1); - y += 38.0f; + gfx_pretty_text(x+10, y, 24.0f, "Score", -1); + gfx_pretty_text(x+125, y, 24.0f, "Name", -1); + gfx_pretty_text(x+w-70, y, 24.0f, "Ping", -1); + y += 29.0f; // render player scores for(int i = 0; i < num_players; i++) @@ -2062,7 +2062,7 @@ void render_scoreboard(float x, float y, float w, int team, const char *title) continue; char buf[128]; - float font_size = 46.0f; + float font_size = 35.0f; if(info->local) { // background so it's easy to find the local player @@ -2788,11 +2788,11 @@ void render_game() sprintf(buf, "Rcon: %s_", chat_input); else sprintf(buf, "Chat: %s_", chat_input); - gfx_pretty_text(x, y, 10.0f, buf, 380); + gfx_pretty_text(x, y, 8.0f, buf, 380); starty = y; } - y -= 10; + y -= 8; int i; for(i = 0; i < chat_max_lines; i++) @@ -2819,7 +2819,7 @@ void render_game() // render line int lines = int(gfx_pretty_text_width(10, chat_lines[r].text, -1)) / 300 + 1; - gfx_pretty_text(begin, y - 8 * (lines - 1), 10, chat_lines[r].name, -1); + gfx_pretty_text(begin, y - 8 * (lines - 1), 8, chat_lines[r].name, -1); begin += gfx_pretty_text_width(10, chat_lines[r].name, -1); gfx_pretty_text_color(1,1,1,1); @@ -2828,8 +2828,8 @@ void render_game() else if(chat_lines[r].team) gfx_pretty_text_color(0.65f,1,0.65f,1); // team message - gfx_pretty_text(begin, y - 8 * (lines - 1), 10, chat_lines[r].text, 300); - y -= 8 * lines; + gfx_pretty_text(begin, y - 8 * (lines - 1), 8, chat_lines[r].text, 300); + y -= 6 * lines; } gfx_pretty_text_color(1,1,1,1); diff --git a/src/game/client/gc_mapres_image.cpp b/src/game/client/gc_mapres_image.cpp index cc9a8143..d8de8a1e 100644 --- a/src/game/client/gc_mapres_image.cpp +++ b/src/game/client/gc_mapres_image.cpp @@ -106,7 +106,7 @@ int img_init() mapres_image *img = (mapres_image *)map_get_item(start+i, 0, 0); void *data = map_get_data(img->image_data); //calc_mipmaps(data, img->width, img->height, data_res); - map_textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data); + map_textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data, IMG_RGBA); map_unload_data(img->image_data); } diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index 2eaefe00..9101fc93 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -369,14 +369,14 @@ static void ui2_draw_browse_icon(int what, const RECT *r) static void ui2_draw_menu_button(const void *id, const char *text, int checked, const RECT *r, void *extra) { ui2_draw_rect(r, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f); - ui2_do_label(r, text, 24, 0); + ui2_do_label(r, text, 18.0f, 0); } static void ui2_draw_keyselect_button(const void *id, const char *text, int checked, const RECT *r, void *extra) { ui2_draw_rect(r, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f); - ui2_do_label(r, text, 18, 0); + ui2_do_label(r, text, 14.0f, 0); } static void ui2_draw_menu_tab_button(const void *id, const char *text, int checked, const RECT *r, void *extra) @@ -385,7 +385,7 @@ static void ui2_draw_menu_tab_button(const void *id, const char *text, int check ui2_draw_rect(r, color_tabbar_active, CORNER_T, 10.0f); else ui2_draw_rect(r, color_tabbar_inactive, CORNER_T, 10.0f); - ui2_do_label(r, text, 26, 0); + ui2_do_label(r, text, 22.0f, 0); } @@ -395,7 +395,7 @@ static void ui2_draw_settings_tab_button(const void *id, const char *text, int c ui2_draw_rect(r, color_tabbar_active, CORNER_R, 10.0f); else ui2_draw_rect(r, color_tabbar_inactive, CORNER_R, 10.0f); - ui2_do_label(r, text, 24, 0); + ui2_do_label(r, text, 20.0f, 0); } static void ui2_draw_grid_header(const void *id, const char *text, int checked, const RECT *r, void *extra) @@ -406,7 +406,7 @@ static void ui2_draw_grid_header(const void *id, const char *text, int checked, // ui2_draw_rect(r, vec4(1,1,1,0.1f), CORNER_T, 5.0f); RECT t; ui2_vsplit_l(r, 5.0f, 0, &t); - ui2_do_label(&t, text, 18, -1); + ui2_do_label(&t, text, 14.0f, -1); } /* static void ui2_draw_grid_cell_l(const void *id, const char *text, int checked, const RECT *r, void *extra) @@ -427,7 +427,7 @@ static void ui2_draw_list_row(const void *id, const char *text, int checked, con ui2_margin(&sr, 1.5f, &sr); ui2_draw_rect(&sr, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f); } - ui2_do_label(r, text, 18, -1); + ui2_do_label(r, text, 14.0f, -1); } static void ui2_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const RECT *r) @@ -441,8 +441,9 @@ static void ui2_draw_checkbox_common(const void *id, const char *text, const cha ui2_margin(&c, 2.0f, &c); ui2_draw_rect(&c, vec4(1,1,1,0.25f), CORNER_ALL, 3.0f); - ui2_do_label(&c, boxtext, 16, 0); - ui2_do_label(&t, text, 18, -1); + c.y += 2; + ui2_do_label(&c, boxtext, 12.0f, 0); + ui2_do_label(&t, text, 14.0f, -1); } static void ui2_draw_checkbox(const void *id, const char *text, int checked, const RECT *r, void *extra) @@ -475,7 +476,7 @@ int ui2_do_edit_box(void *id, const RECT *rect, char *str, int str_size, bool hi for (int i = 1; i <= len; i++) { - if (gfx_pretty_text_width(18.0f, str, i) + 10 > mx_rel) + if (gfx_pretty_text_width(14.0f, str, i) + 10 > mx_rel) { at_index = i - 1; break; @@ -563,13 +564,13 @@ int ui2_do_edit_box(void *id, const RECT *rect, char *str, int str_size, bool hi display_str = stars; } - ui2_do_label(&textbox, display_str, 18, -1); + ui2_do_label(&textbox, display_str, 14, -1); if (ui_last_active_item() == id && !just_got_active) { - float w = gfx_pretty_text_width(18.0f, display_str, at_index); + float w = gfx_pretty_text_width(14.0f, display_str, at_index); textbox.x += w*ui2_scale(); - ui2_do_label(&textbox, "_", 18, -1); + ui2_do_label(&textbox, "_", 14, -1); } return r; @@ -850,8 +851,11 @@ void render_loading(float percent) if (first) { - font_set_load(&font_set, "fonts/tahoma%d.tfnt", "fonts/tahoma%d.png", "fonts/tahoma%d_b.png", 8, 6, 8, 10, 12, 14, 16, 20, 24); + int before = gfx_memory_usage(); + font_set_load(&font_set, "fonts/default_font%d.tfnt", "fonts/default_font%d.png", "fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36); first = false; + int after = gfx_memory_usage(); + dbg_msg("font", "gfx memory usage: %d", after-before); } } @@ -904,11 +908,18 @@ static void menu2_render_serverbrowser(RECT main_view) RECT filters; RECT status; RECT toolbox; - + RECT server_details; + RECT server_scoreboard; + //ui2_hsplit_t(&view, 20.0f, &status, &view); - ui2_hsplit_t(&view, 20.0f, &headers, &view); ui2_hsplit_b(&view, 90.0f, &view, &filters); - ui2_hsplit_b(&view, 5.0f, &view, 0); + + // split off a piece for details and scoreboard + ui2_vsplit_r(&view, 200.0f, &view, &server_details); + + // server list + ui2_hsplit_t(&view, 20.0f, &headers, &view); + ui2_hsplit_b(&view, 5.0f, &view, 0x0); ui2_hsplit_b(&view, 20.0f, &view, &status); //ui2_vsplit_r(&filters, 300.0f, &filters, &toolbox); @@ -956,9 +967,9 @@ static void menu2_render_serverbrowser(RECT main_view) {COL_MAP, BROWSESORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}}, {COL_PLAYERS, BROWSESORT_NUMPLAYERS, "Players", 1, 60.0f, 0, {0}, {0}}, {-1, -1, " ", 1, 10.0f, 0, {0}, {0}}, - {COL_VERSION, -1, "Ver", 1, 45.0f, FIXED, {0}, {0}}, + //{COL_VERSION, -1, "Ver", 1, 45.0f, FIXED, {0}, {0}}, {-1, -1, " ", 1, 5.0f, 0, {0}, {0}}, - {COL_PROGRESS, BROWSESORT_PROGRESSION, "%", 1, 20.0f, FIXED, {0}, {0}}, + //{COL_PROGRESS, BROWSESORT_PROGRESSION, "%", 1, 20.0f, FIXED, {0}, {0}}, {COL_PING, BROWSESORT_PING, "Ping", 1, 40.0f, FIXED, {0}, {0}}, }; @@ -1050,7 +1061,6 @@ static void menu2_render_serverbrowser(RECT main_view) //int r = -1; int new_selected = selected_index; - for (int i = 0; i < num_servers; i++) { @@ -1097,8 +1107,8 @@ static void menu2_render_serverbrowser(RECT main_view) ui2_vsplit_l(&player_name, 10.0f, 0, &player_name); char buf[32]; sprintf(buf, "%d", item->player_scores[p+a]); - ui2_do_label(&player_score, buf, 16.0f, 1); - ui2_do_label(&player_name, item->player_names[p+a], 16.0f, -1); + ui2_do_label(&player_score, buf, 12.0f, 1); + ui2_do_label(&player_name, item->player_names[p+a], 12.0f, -1); } } @@ -1153,18 +1163,18 @@ static void menu2_render_serverbrowser(RECT main_view) ui2_draw_browse_icon(0x100, &button); } else if(id == COL_NAME) - ui2_do_label(&button, item->name, 20.0f, -1); + ui2_do_label(&button, item->name, 15.0f, -1); else if(id == COL_MAP) - ui2_do_label(&button, item->map, 20.0f, -1); + ui2_do_label(&button, item->map, 15.0f, -1); else if(id == COL_PLAYERS) { sprintf(temp, "%i/%i", item->num_players, item->max_players); - ui2_do_label(&button, temp, 20.0f, 1); + ui2_do_label(&button, temp, 15.0f, 1); } else if(id == COL_PING) { sprintf(temp, "%i", item->latency); - ui2_do_label(&button, temp, 20.0f, 1); + ui2_do_label(&button, temp, 15.0f, 1); } else if(id == COL_PROGRESS) { @@ -1177,7 +1187,7 @@ static void menu2_render_serverbrowser(RECT main_view) const char *version = item->version; if(strcmp(version, "0.3 e2d7973c6647a13c") == 0) // TODO: remove me later on version = "0.3.0"; - ui2_do_label(&button, version, 20.0f, 1); + ui2_do_label(&button, version, 15.0f, 1); } else if(id == COL_GAMETYPE) { @@ -1185,7 +1195,7 @@ static void menu2_render_serverbrowser(RECT main_view) if(item->game_type == GAMETYPE_DM) type = "DM"; else if(item->game_type == GAMETYPE_TDM) type = "TDM"; else if(item->game_type == GAMETYPE_CTF) type = "CTF"; - ui2_do_label(&button, type, 20.0f, 0); + ui2_do_label(&button, type, 15.0f, 0); } /* if(s) @@ -1200,12 +1210,104 @@ static void menu2_render_serverbrowser(RECT main_view) ui2_clip_disable(); selected_index = new_selected; + + + SERVER_INFO *selected_server = client_serverbrowse_sorted_get(selected_index); + RECT server_header; + + ui2_vsplit_l(&server_details, 10.0f, 0x0, &server_details); + + // split off a piece to use for scoreboard + ui2_hsplit_t(&server_details, 140.0f, &server_details, &server_scoreboard); + ui2_hsplit_b(&server_details, 10.0f, &server_details, 0x0); + + // server details + ui2_hsplit_t(&server_details, 20.0f, &server_header, &server_details); + ui2_draw_rect(&server_header, vec4(1,1,1,0.25f), CORNER_T, 4.0f); + ui2_draw_rect(&server_details, vec4(0,0,0,0.15f), CORNER_B, 4.0f); + ui2_vsplit_l(&server_header, 8.0f, 0x0, &server_header); + ui2_do_label(&server_header, "Server Details: ", 14.0f, -1); + + ui2_vsplit_l(&server_details, 5.0f, 0x0, &server_details); + + ui2_margin(&server_details, 3.0f, &server_details); + + if (selected_server) + { + const float row_height = 18.0f; + RECT row; + static char *labels[] = { "Version:", "Game Type:", "Progression:", "Ping:" }; + + ui2_hsplit_t(&server_details, row_height, &row, &server_details); + ui2_do_label(&row, selected_server->name, 15.0f, -1); + + ui2_hsplit_t(&server_details, row_height, &row, &server_details); + ui2_vsplit_l(&row, 1.0f, 0x0, &row); + ui2_do_label(&row, selected_server->address, 14.0f, -1); + + RECT left_column; + RECT right_column; + ui2_vsplit_l(&server_details, 5.0f, 0x0, &server_details); + ui2_vsplit_l(&server_details, 80.0f, &left_column, &right_column); + + for (int i = 0; i < 4; i++) + { + ui2_hsplit_t(&left_column, 15.0f, &row, &left_column); + ui2_do_label(&row, labels[i], 13.0f, -1); + } + + ui2_hsplit_t(&right_column, 15.0f, &row, &right_column); + ui2_do_label(&row, selected_server->version, 13.0f, -1); + + ui2_hsplit_t(&right_column, 15.0f, &row, &right_column); + static char *game_types[] = { "DM", "TDM", "CTF" }; + if (selected_server->game_type >= 0 && selected_server->game_type < (int)(sizeof(game_types)/sizeof(*game_types))) + ui2_do_label(&row, game_types[selected_server->game_type], 13.0f, -1); + + char temp[16]; + + sprintf(temp, "%d%%", selected_server->progression); + ui2_hsplit_t(&right_column, 15.0f, &row, &right_column); + ui2_do_label(&row, temp, 13.0f, -1); + + sprintf(temp, "%d", selected_server->latency); + ui2_hsplit_t(&right_column, 15.0f, &row, &right_column); + ui2_do_label(&row, temp, 13.0f, -1); + } + + // server scoreboard + ui2_hsplit_b(&server_scoreboard, 10.0f, &server_scoreboard, 0x0); + ui2_hsplit_t(&server_scoreboard, 20.0f, &server_header, &server_scoreboard); + ui2_draw_rect(&server_header, vec4(1,1,1,0.25f), CORNER_T, 4.0f); + ui2_draw_rect(&server_scoreboard, vec4(0,0,0,0.15f), CORNER_B, 4.0f); + ui2_vsplit_l(&server_header, 8.0f, 0x0, &server_header); + ui2_do_label(&server_header, "Scoreboard: ", 14.0f, -1); + + ui2_vsplit_l(&server_scoreboard, 5.0f, 0x0, &server_scoreboard); + + ui2_margin(&server_scoreboard, 3.0f, &server_scoreboard); + + if (selected_server) + { + for (int i = 0; i < selected_server->num_players; i++) + { + RECT row; + char temp[16]; + ui2_hsplit_t(&server_scoreboard, 16.0f, &row, &server_scoreboard); + + sprintf(temp, "%d", selected_server->player_scores[i]); + ui2_do_label(&row, temp, 14.0f, -1); + + ui2_vsplit_l(&row, 25.0f, 0x0, &row); + ui2_do_label(&row, selected_server->player_names[i], 14.0f, -1); + } + } // render quick search RECT button; ui2_hsplit_t(&filters, 20.0f, &button, &filters); - ui2_do_label(&button, "Quick search: ", 18, -1); + ui2_do_label(&button, "Quick search: ", 14.0f, -1); ui2_vsplit_l(&button, 95.0f, 0, &button); ui2_do_edit_box(&config.b_filter_string, &button, config.b_filter_string, sizeof(config.b_filter_string)); @@ -1222,13 +1324,12 @@ static void menu2_render_serverbrowser(RECT main_view) if (ui2_do_button(&config.b_filter_pw, "Is not password protected", config.b_filter_pw, &button, ui2_draw_checkbox, 0)) config.b_filter_pw ^= 1; - // render status ui2_draw_rect(&status, vec4(1,1,1,0.25f), CORNER_B, 5.0f); ui2_vmargin(&status, 50.0f, &status); char buf[128]; sprintf(buf, "%d of %d servers", client_serverbrowse_sorted_num(), client_serverbrowse_num()); - ui2_do_label(&status, buf, 18.0f, -1); + ui2_do_label(&status, buf, 14.0f, -1); // render toolbox { @@ -1254,7 +1355,7 @@ static void menu2_render_serverbrowser(RECT main_view) } ui2_hsplit_t(&toolbox, 20.0f, &button, &toolbox); - ui2_do_label(&button, "Host address:", 18, -1); + ui2_do_label(&button, "Host address:", 14.0f, -1); ui2_vsplit_l(&button, 100.0f, 0, &button); ui2_do_edit_box(&config.ui_server_address, &button, config.ui_server_address, sizeof(config.ui_server_address)); } @@ -1272,7 +1373,7 @@ static void menu2_render_settings_player(RECT main_view) // render settings { ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui2_do_label(&button, "Name:", 18.0, -1); + ui2_do_label(&button, "Name:", 14.0, -1); ui2_vsplit_l(&button, 80.0f, 0, &button); ui2_vsplit_l(&button, 180.0f, &button, 0); ui2_do_edit_box(config.player_name, &button, config.player_name, sizeof(config.player_name)); @@ -1319,7 +1420,7 @@ static void menu2_render_settings_player(RECT main_view) RECT text; ui2_hsplit_t(&main_view, 20.0f, &text, &main_view); ui2_vsplit_l(&text, 15.0f, 0, &text); - ui2_do_label(&text, parts[i], 18, -1); + ui2_do_label(&text, parts[i], 14.0f, -1); int prevcolor = *colors[i]; int color = 0; @@ -1336,7 +1437,7 @@ static void menu2_render_settings_player(RECT main_view) k = ui2_do_scrollbar_h(&color_slider[i][s], &button, k); color <<= 8; color += clamp((int)(k*255), 0, 255); - ui2_do_label(&text, labels[s], 20, -1); + ui2_do_label(&text, labels[s], 15.0f, -1); } @@ -1411,7 +1512,7 @@ static void menu2_render_settings_player(RECT main_view) config_set_player_skin(&config, s->name); ui2_hsplit_t(&text, 12.0f, 0, &text); // some margin from the top - ui2_do_label(&text, buf, 24, 0); + ui2_do_label(&text, buf, 18.0f, 0); ui2_hsplit_t(&icon, 5.0f, 0, &icon); // some margin from the top render_tee(&state, &info, 0, vec2(1, 0), vec2(icon.x+icon.w/2, icon.y+icon.h/2)); @@ -1430,7 +1531,7 @@ static void menu2_render_settings_controls(RECT main_view) RECT button, label; ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); ui2_vsplit_l(&button, 110.0f, &label, &button); - ui2_do_label(&label, "Mouse sens.", 18.0f, -1); + ui2_do_label(&label, "Mouse sens.", 14.0f, -1); ui2_hmargin(&button, 2.0f, &button); config.inp_mousesens = (int)(ui2_do_scrollbar_h(&config.inp_mousesens, &button, config.inp_mousesens/500.0f)*500.0f); //*key.key = ui2_do_key_reader(key.key, &button, *key.key); @@ -1473,7 +1574,7 @@ static void menu2_render_settings_controls(RECT main_view) ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); ui2_vsplit_l(&button, 110.0f, &label, &button); - ui2_do_label(&label, key.name, 18.0f, -1); + ui2_do_label(&label, key.name, 14.0f, -1); *key.key = ui2_do_key_reader(key.key, &button, *key.key); ui2_hsplit_t(&main_view, 5.0f, 0, &main_view); } @@ -1506,14 +1607,14 @@ static void menu2_render_settings_graphics(RECT main_view) // draw header ui2_hsplit_t(&modelist, 20, &header, &modelist); ui2_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui2_do_label(&header, "Display Modes", 18.0f, 0); + ui2_do_label(&header, "Display Modes", 14.0f, 0); // draw footers ui2_hsplit_b(&modelist, 20, &modelist, &footer); sprintf(buf, "Current: %dx%d %d bit", config.gfx_screen_width, config.gfx_screen_height, config.gfx_color_depth); ui2_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); ui2_vsplit_l(&footer, 10.0f, 0, &footer); - ui2_do_label(&footer, buf, 18.0f, -1); + ui2_do_label(&footer, buf, 14.0f, -1); // modes ui2_draw_rect(&modelist, vec4(0,0,0,0.15f), 0, 0); @@ -1613,7 +1714,7 @@ static void menu2_render_settings_graphics(RECT main_view) ui2_hsplit_t(&main_view, 20.0f, 0, &main_view); ui2_hsplit_t(&main_view, 20.0f, &text, &main_view); //ui2_vsplit_l(&text, 15.0f, 0, &text); - ui2_do_label(&text, "UI Color", 18, -1); + ui2_do_label(&text, "UI Color", 14.0f, -1); const char *labels[] = {"Hue", "Sat.", "Lht.", "Alpha"}; int *color_slider[4] = {&config.ui_color_hue, &config.ui_color_sat, &config.ui_color_lht, &config.ui_color_alpha}; @@ -1629,7 +1730,7 @@ static void menu2_render_settings_graphics(RECT main_view) float k = (*color_slider[s]) / 255.0f; k = ui2_do_scrollbar_h(color_slider[s], &button, k); *color_slider[s] = (int)(k*255.0f); - ui2_do_label(&text, labels[s], 20, -1); + ui2_do_label(&text, labels[s], 15.0f, -1); } } @@ -1653,7 +1754,7 @@ static void menu2_render_settings_sound(RECT main_view) char buf[64]; sprintf(buf, "%d", config.snd_rate); ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui2_do_label(&button, "Sample Rate", 18.0, -1); + ui2_do_label(&button, "Sample Rate", 14.0f, -1); ui2_vsplit_l(&button, 110.0f, 0, &button); ui2_vsplit_l(&button, 180.0f, &button, 0); ui2_do_edit_box(&config.snd_rate, &button, buf, sizeof(buf)); @@ -1674,7 +1775,7 @@ static void menu2_render_settings_sound(RECT main_view) ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); ui2_vsplit_l(&button, 110.0f, &label, &button); ui2_hmargin(&button, 2.0f, &button); - ui2_do_label(&label, "Sound Volume", 18.0f, -1); + ui2_do_label(&label, "Sound Volume", 14.0f, -1); config.snd_volume = (int)(ui2_do_scrollbar_h(&config.snd_volume, &button, config.snd_volume/100.0f)*100.0f); ui2_hsplit_t(&main_view, 20.0f, 0, &main_view); } @@ -1688,7 +1789,7 @@ static void menu2_render_settings_network(RECT main_view) { ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui2_do_label(&button, "Rcon Password", 18.0, -1); + ui2_do_label(&button, "Rcon Password", 14.0, -1); ui2_vsplit_l(&button, 110.0f, 0, &button); ui2_vsplit_l(&button, 180.0f, &button, 0); ui2_do_edit_box(&config.rcon_password, &button, config.rcon_password, sizeof(config.rcon_password), true); @@ -1738,7 +1839,7 @@ static void menu2_render_settings(RECT main_view) { RECT restart_warning; ui2_hsplit_b(&main_view, 40, &main_view, &restart_warning); - ui2_do_label(&restart_warning, "You must restart Teewars for all settings to take effect.", 20, -1, 220); + ui2_do_label(&restart_warning, "You must restart Teewars for all settings to take effect.", 15.0f, -1, 220); } } diff --git a/src/game/client/gc_skin.cpp b/src/game/client/gc_skin.cpp index cc5699e4..ea215edd 100644 --- a/src/game/client/gc_skin.cpp +++ b/src/game/client/gc_skin.cpp @@ -31,7 +31,7 @@ static void skinscan(const char *name, int is_dir, void *user) return; } - skins[num_skins].org_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data); + skins[num_skins].org_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format); // create colorless version unsigned char *d = (unsigned char *)info.data; @@ -82,7 +82,7 @@ static void skinscan(const char *name, int is_dir, void *user) } } - skins[num_skins].color_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data); + skins[num_skins].color_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format); mem_free(info.data); // set skin data diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index b8c31798..3648788d 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -1417,7 +1417,7 @@ bool player::take_damage(vec2 force, int dmg, int from, int weapon) damage_taken_tick = server_tick(); // do damage hit sound - if(from >= 0) + if(from >= 0 && from != client_id) create_sound(get_player(from)->pos, SOUND_HIT, cmask_one(from)); // check for death |