From 66b578869fa200000074f5bd9b320fe61d422dfc Mon Sep 17 00:00:00 2001 From: xtreme8000 Date: Sun, 16 Jun 2019 23:10:18 +0200 Subject: [PATCH] See desc * write server name to window title * color bullets black (and not blue, did affect shotgun) --- src/hud.c | 19 +++++++++++-------- src/model.c | 2 ++ src/particle.c | 2 +- src/window.c | 22 ++++++++++++++++++++++ src/window.h | 1 + 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/hud.c b/src/hud.c index 22ca582..f7df770 100644 --- a/src/hud.c +++ b/src/hud.c @@ -1775,6 +1775,7 @@ static int serverlist_news_exists = 0; static void hud_serverlist_init() { ping_stop(); network_disconnect(); + window_title(NULL); window_mousemode(WINDOW_CURSOR_ENABLED); @@ -2203,17 +2204,19 @@ static void hud_serverlist_scroll(double yoffset) { } } -static void server_c(char* s) { - if(file_exists(s)) { - map_vxl_load(file_load(s),map_colors); +static void server_c(char* address, char* name) { + if(file_exists(address)) { + map_vxl_load(file_load(address),map_colors); chunk_rebuild_all(); camera_mode = CAMERAMODE_FPS; players[local_player_id].pos.x = map_size_x/2.0F; players[local_player_id].pos.y = map_size_y-1.0F; players[local_player_id].pos.z = map_size_z/2.0F; + window_title(address); hud_change(&hud_ingame); } else { - hud_change(network_connect_string(s)?&hud_ingame:&hud_serverlist); + window_title(name); + hud_change(network_connect_string(address)?&hud_ingame:&hud_serverlist); } } @@ -2228,7 +2231,7 @@ static void hud_serverlist_mouseclick(double x, double y, int button, int action } if(serverlist_hover>=0) { pthread_mutex_lock(&serverlist_lock); - server_c(serverlist[serverlist_hover].identifier); + server_c(serverlist[serverlist_hover].identifier,serverlist[serverlist_hover].name); pthread_mutex_unlock(&serverlist_lock); } @@ -2257,7 +2260,7 @@ static void hud_serverlist_mouseclick(double x, double y, int button, int action //texture_draw(&texture_ui_join,settings.window_width/2.0F+90*scaley,485*scaley,32*scaley,32*scaley); if(is_inside(x,settings.window_height-y,settings.window_width/2.0F+90*scaley,(485-32)*scaley,32*scaley,32*scaley) && strlen(chat[0][0])>0) - server_c(chat[0][0]); + server_c(chat[0][0],NULL); if(is_inside(x,settings.window_height-y,settings.window_width/2.0F+130*scaley,(485-32)*scaley,32*scaley,32*scaley)) hud_change(&hud_serverlist); @@ -2288,7 +2291,7 @@ static void hud_serverlist_mouseclick(double x, double y, int button, int action if(serverlist_news_hover) { if(!strncmp("aos://",serverlist_news_hover->url,6)) - server_c(serverlist_news_hover->url); + server_c(serverlist_news_hover->url,serverlist_news_hover->caption); else file_url(serverlist_news_hover->url); } @@ -2336,7 +2339,7 @@ static void hud_serverlist_keyboard(int key, int action, int mods, int internal) chat[0][0][text_len-1] = 0; } if(key==WINDOW_KEY_ENTER && strlen(chat[0][0])>0) - server_c(chat[0][0]); + server_c(chat[0][0],NULL); } } diff --git a/src/model.c b/src/model.c index 28aa754..fdc2785 100644 --- a/src/model.c +++ b/src/model.c @@ -236,6 +236,8 @@ static int kv6_program = -1; void kv6_render(struct kv6_t* kv6, unsigned char team) { if(!kv6) return; + if(team==TEAM_SPECTATOR) + team = 2; if(!settings.voxlap_models) { if(!kv6->has_display_list) { int size = kv6->voxel_count*6; diff --git a/src/particle.c b/src/particle.c index d8717cd..6d6ab27 100644 --- a/src/particle.c +++ b/src/particle.c @@ -198,7 +198,7 @@ static void particle_render_single(int k, int* vertex_index, int* color_index) { matrix_pointAt(particles[k].ox,particles[k].oy*max(1.0F-(window_time()-particles[k].fade)/0.5F,0.0F),particles[k].oz); matrix_rotate(90.0F,0.0F,1.0F,0.0F); matrix_upload(); - kv6_render(casing,TEAM_1); + kv6_render(casing,TEAM_SPECTATOR); matrix_pop(); } } diff --git a/src/window.c b/src/window.c index 272409a..4229023 100644 --- a/src/window.c +++ b/src/window.c @@ -120,6 +120,16 @@ void window_swapping(int value) { glfwSwapInterval(value); } +void window_title(char* suffix) { + if(suffix) { + char title[128]; + snprintf(title,sizeof(title)-1,"BetterSpades %s - %s",BETTERSPADES_VERSION,suffix); + glfwSetWindowTitle(hud_window->impl,title); + } else { + glfwSetWindowTitle(hud_window->impl,"BetterSpades "BETTERSPADES_VERSION); + } +} + void window_init() { static struct window_instance i; hud_window = &i; @@ -280,7 +290,9 @@ void window_init() { SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); + #ifdef OPENGL_ES SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_PROFILE_ES); + #endif SDL_GLContext* ctx = SDL_GL_CreateContext(hud_window->impl); memset(fingers,0,sizeof(fingers)); @@ -439,6 +451,16 @@ int window_closed() { return quit; } +void window_title(char* suffix) { + if(suffix) { + char title[128]; + snprintf(title,sizeof(title)-1,"BetterSpades %s - %s",BETTERSPADES_VERSION,suffix); + SDL_SetWindowTitle(hud_window->impl,title); + } else { + SDL_SetWindowTitle(hud_window->impl,"BetterSpades "BETTERSPADES_VERSION); + } +} + #endif int window_cpucores() { diff --git a/src/window.h b/src/window.h index 990a5af..479143c 100644 --- a/src/window.h +++ b/src/window.h @@ -122,3 +122,4 @@ void window_deinit(void); void window_update(void); int window_closed(void); int window_cpucores(); +void window_title(char* suffix);