diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-08-04 18:23:26 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-08-04 18:23:26 +0000 |
| commit | 1eadf9942ad07ba3c60f9a027cf232a351fa9b05 (patch) | |
| tree | 0c513cbd05f37049c40c2a199d44020202134f73 /src/game | |
| parent | c89e2d0dc89fec398f111807013b1091322f6f51 (diff) | |
| download | zcatch-1eadf9942ad07ba3c60f9a027cf232a351fa9b05.tar.gz zcatch-1eadf9942ad07ba3c60f9a027cf232a351fa9b05.zip | |
fixed handling of versions. added error messages when disconnected. updated the connecting gui. fixed no streched clouds
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/game_client.cpp | 72 | ||||
| -rw-r--r-- | src/game/client/menu.cpp | 85 |
2 files changed, 147 insertions, 10 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index 57618202..8fdf9ade 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -127,7 +127,7 @@ void select_sprite(int id, int flags=0, int sx=0, int sy=0) select_sprite(&data->sprites[id], flags, sx, sy); } -static void draw_sprite(float x, float y, float size) +void draw_sprite(float x, float y, float size) { gfx_quads_draw(x, y, size*sprite_w_scale, size*sprite_h_scale); } @@ -830,7 +830,7 @@ static void render_tee(animstate *anim, int skin, vec2 dir, vec2 pos) gfx_quads_end(); } -static void draw_round_rect(float x, float y, float w, float h, float r) +void draw_round_rect(float x, float y, float w, float h, float r) { int num = 8; for(int i = 0; i < num; i+=2) @@ -1194,7 +1194,7 @@ void ingamemenu_render() } -void modc_render() +void render_game() { animstate idlestate; anim_eval(&data->animations[ANIM_BASE], 0, &idlestate); @@ -1394,8 +1394,8 @@ void modc_render() { float parallax_amount = 0.55f; select_sprite(cloud_sprites[i]); - gfx_quads_drawTL((cloud_pos[i].x+fmod(client_localtime()*cloud_speed[i]+i*100.0f, 1700.0f))+screen_x*parallax_amount, - cloud_pos[i].y+screen_y*parallax_amount, 300, 300); + draw_sprite((cloud_pos[i].x+fmod(client_localtime()*cloud_speed[i]+i*100.0f, 1700.0f))+screen_x*parallax_amount, + cloud_pos[i].y+screen_y*parallax_amount, 300); } gfx_quads_end(); @@ -1829,6 +1829,68 @@ void modc_render() } } +void modc_render() +{ + // this should be moved around abit + if(client_state() == CLIENTSTATE_ONLINE) + { + render_game(); + } + else // if (client_state() != CLIENTSTATE_CONNECTING && client_state() != CLIENTSTATE_LOADING) + { + //netaddr4 server_address; + if(modmenu_render() == -1) + client_quit(); + + } + /* + else if (client_state() == CLIENTSTATE_CONNECTING || client_state() == CLIENTSTATE_LOADING) + { + static int64 start = time_get(); + static int tee_texture; + static int connecting_texture; + static bool inited = false; + + // TODO: ugly, remove this + if (!inited) + { + tee_texture = gfx_load_texture("data/gui_tee.png"); + connecting_texture = gfx_load_texture("data/gui_connecting.png"); + + inited = true; + } + + gfx_mapscreen(0,0,400.0f,300.0f); + + float t = (time_get() - start) / (double)time_freq(); + + float speed = 2*sin(t); + + speed = 1.0f; + + float x = 208 + sin(t*speed) * 32; + float w = sin(t*speed + 3.149) * 64; + + ui_do_image(tee_texture, x, 95, w, 64); + ui_do_image(connecting_texture, 88, 150, 256, 64); + + if(inp_key_down(input::esc)) + client_disconnect(); + }*/ +} + + +void menu_do_disconnected(); +void menu_do_connecting(); + +void modc_statechange(int state, int old) +{ + if(state == CLIENTSTATE_OFFLINE) + menu_do_disconnected(); + if(state == CLIENTSTATE_CONNECTING) + menu_do_connecting(); +} + void modc_message(int msg) { if(msg == MSG_CHAT) diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index d74282ff..41ef9307 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -143,6 +143,7 @@ extern pretty_font *current_font; extern void render_sun(float x, float y); extern void select_sprite(int id, int flags=0, int sx=0, int sy=0); +extern void draw_sprite(float x, float y, float size); void draw_background(float t) { @@ -156,11 +157,11 @@ void draw_background(float t) gfx_texture_set(data->images[IMAGE_CLOUDS].id); gfx_quads_begin(); select_sprite(SPRITE_CLOUD1); - gfx_quads_drawTL(3500 - fmod(t * 20 + 2000, 4524), 0, 512, 512); + draw_sprite(3500 - fmod(t * 20 + 2000, 4524), 250, 512); select_sprite(SPRITE_CLOUD2); - gfx_quads_drawTL(3000 - fmod(t * 50 + 2000, 4024), 150, 512, 512); + draw_sprite(3000 - fmod(t * 50 + 2000, 4024), 150+250, 512); select_sprite(SPRITE_CLOUD3); - gfx_quads_drawTL(4000 - fmod(t * 60 + 500, 4512), 300, 256, 256); + draw_sprite(4000 - fmod(t * 60 + 500, 4512), 300+130, 256); gfx_quads_end(); gfx_texture_set(data->images[IMAGE_MENU_BACKGROUND].id); @@ -681,6 +682,8 @@ static int do_server_list(float x, float y, int *scroll_index, int *selected_ind enum { SCREEN_MAIN, + SCREEN_DISCONNECTED, + SCREEN_CONNECTING, SCREEN_SETTINGS_GENERAL, SCREEN_SETTINGS_CONTROLS, SCREEN_SETTINGS_VIDEO, @@ -704,6 +707,8 @@ const float row5_y = row4_y + 40; const float row6_y = row5_y + 40; const float row7_y = row6_y + 40; +static char address[128] = "localhost:8303"; + static int main_render() { static bool inited = false; @@ -718,8 +723,6 @@ static int main_render() int last_selected_index = selected_index; do_server_list(20, 160, &scoll_index, &selected_index, 8); - static char address[32] = "localhost:8303"; - ui_do_edit_box(address, 280, 425, 300, 36, address, sizeof(address)); if (last_selected_index != selected_index && selected_index != -1) @@ -1176,6 +1179,74 @@ static int kerning_render() return 0; } +extern void draw_round_rect(float x, float y, float w, float h, float r); + +static int render_popup(const char *caption, const char *text, const char *button_text) +{ + float tw; + + float w = 700; + float h = 300; + float x = 800/2-w/2; + float y = 600/2-h/2; + + gfx_blend_normal(); + + gfx_texture_set(-1); + gfx_quads_begin(); + gfx_quads_setcolor(0,0,0,0.50f); + draw_round_rect(x, y, w, h, 40.0f); + gfx_quads_end(); + + tw = gfx_pretty_text_width(48.0f, caption); + ui_do_label(x+w/2-tw/2, y+20, caption, 48.0f); + + tw = gfx_pretty_text_width(32.0f, text); + ui_do_label(x+w/2-tw/2, y+130, text, 32.0f); + + static int back_button = 0; + if(ui_do_button(&back_button, button_text, 0, x+w/2-100, y+220, 200, 48, draw_teewars_button)) + return 1; + + return 0; +} + +static int disconnected_render() +{ + if(strlen(client_error_string()) == 0) + screen = SCREEN_MAIN; + else + { + if(render_popup("Disconnected", client_error_string(), "Back")) + screen = SCREEN_MAIN; + } + return 0; +} + +static int connecting_render() +{ + char buf[256]; + sprintf(buf, "Server: %s", address); + if(render_popup("Connecting", buf, "Abort")) + { + client_disconnect(); + screen = SCREEN_MAIN; + } + return 0; +} + + +void menu_do_disconnected() +{ + screen = SCREEN_DISCONNECTED; +} + + +void menu_do_connecting() +{ + screen = SCREEN_CONNECTING; +} + static int menu_render() { // background color @@ -1201,6 +1272,8 @@ static int menu_render() switch (screen) { case SCREEN_MAIN: return main_render(); + case SCREEN_DISCONNECTED: return disconnected_render(); + case SCREEN_CONNECTING: return connecting_render(); case SCREEN_SETTINGS_GENERAL: case SCREEN_SETTINGS_CONTROLS: case SCREEN_SETTINGS_VIDEO: @@ -1282,6 +1355,8 @@ int modmenu_render() input::clear_char(); input::clear_key(); + + //if(r) return r; } |