diff options
| author | Alfred Eriksson <somerunce@gmail.com> | 2008-09-07 08:30:49 +0000 |
|---|---|---|
| committer | Alfred Eriksson <somerunce@gmail.com> | 2008-09-07 08:30:49 +0000 |
| commit | c3ff86330f6baa479a4d1ef79f1fd906b2a1a4a2 (patch) | |
| tree | 182099f48322e9b740954daa19cc653cbc8019f6 | |
| parent | 6dcea2c4ca59e0f1ac8450cc31550bdb35bc21b1 (diff) | |
| download | zcatch-c3ff86330f6baa479a4d1ef79f1fd906b2a1a4a2.tar.gz zcatch-c3ff86330f6baa479a4d1ef79f1fd906b2a1a4a2.zip | |
merge from 0.4.3: lots of small stuff
| -rw-r--r-- | src/game/client/components/menus_browser.cpp | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 59 | ||||
| -rw-r--r-- | src/game/editor/ed_layer_tiles.cpp | 35 | ||||
| -rw-r--r-- | src/game/server/hooks.cpp | 3 |
4 files changed, 69 insertions, 30 deletions
diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 6354ee22..5656bc7e 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -614,7 +614,7 @@ void MENUS::render_serverbrowser(RECT main_view) ui_vmargin(&button, 2.0f, &button); //ui_vmargin(&button, 2.0f, &button); static int join_button = 0; - if(ui_do_button(&join_button, "Connect", 0, &button, ui_draw_menu_button, 0)) + if(ui_do_button(&join_button, "Connect", 0, &button, ui_draw_menu_button, 0) || inp_key_down(KEY_ENTER)) client_connect(config.ui_server_address); ui_hsplit_b(&button_box, 5.0f, &button_box, &button); diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 9c0edcb7..304490d0 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -145,27 +145,29 @@ void EDITOR_IMAGE::analyse_tileflags() int tw = width/16; // tilesizes int th = height/16; - unsigned char *pixeldata = (unsigned char *)data; - - int tile_id = 0; - for(int ty = 0; ty < 16; ty++) - for(int tx = 0; tx < 16; tx++, tile_id++) - { - bool opaque = true; - for(int x = 0; x < tw; x++) - for(int y = 0; y < th; y++) - { - int p = (ty*tw+y)*width + tx*tw+x; - if(pixeldata[p*4+3] < 250) + if ( tw == th ) { + unsigned char *pixeldata = (unsigned char *)data; + + int tile_id = 0; + for(int ty = 0; ty < 16; ty++) + for(int tx = 0; tx < 16; tx++, tile_id++) + { + bool opaque = true; + for(int x = 0; x < tw; x++) + for(int y = 0; y < th; y++) { - opaque = false; - break; + int p = (ty*tw+y)*width + tx*tw+x; + if(pixeldata[p*4+3] < 250) + { + opaque = false; + break; + } } - } - - if(opaque) - tileflags[tile_id] |= TILEFLAG_OPAQUE; - } + + if(opaque) + tileflags[tile_id] |= TILEFLAG_OPAQUE; + } + } } @@ -409,10 +411,21 @@ QUAD *EDITOR::get_selected_quad() return 0; } +static void callback_open_map(const char *filename) { editor.load(filename); } +static void callback_append_map(const char *filename) { editor.append(filename); } +static void callback_save_map(const char *filename) { editor.save(filename); } static void do_toolbar(RECT toolbar) { RECT button; + + // ctrl+o to open + if(inp_key_down('O') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL))) + editor.invoke_file_dialog("Open Map", "Open", "data/maps/", "", callback_open_map); + + // ctrl+s to save + if(inp_key_down('S') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL))) + editor.invoke_file_dialog("Save Map", "Save", "data/maps/", "", callback_save_map); // animate button ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar); @@ -830,7 +843,7 @@ static void do_map_editor(RECT view, RECT toolbar) { //ui_clip_enable(&view); - bool show_picker = inp_key_pressed(KEY_SPACE) != 0; + bool show_picker = inp_key_pressed(KEY_SPACE) != 0 && editor.dialog == DIALOG_NONE; // render all good stuff if(!show_picker) @@ -1410,7 +1423,7 @@ static void render_layers(RECT toolbox, RECT toolbar, RECT view) editor.selected_group = g; static int layer_popup_id = 0; if(result == 2) - ui_invoke_popup_menu(&layer_popup_id, 0, ui_mouse_x(), ui_mouse_y(), 120, 130, popup_layer); + ui_invoke_popup_menu(&layer_popup_id, 0, ui_mouse_x(), ui_mouse_y(), 120, 150, popup_layer); } @@ -2135,10 +2148,6 @@ static void render_envelopeeditor(RECT view) } } -static void callback_open_map(const char *filename) { editor.load(filename); } -static void callback_append_map(const char *filename) { editor.append(filename); } -static void callback_save_map(const char *filename) { editor.save(filename); } - static int popup_menu_file(RECT view) { static int new_map_button = 0; diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index cae47acb..8f4c8660 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -107,6 +107,9 @@ void LAYER_TILES::brush_selecting(RECT rect) snap(&rect); gfx_quads_drawTL(rect.x, rect.y, rect.w, rect.h); gfx_quads_end(); + char buf[16]; + str_format(buf, sizeof(buf), "%d,%d", convert_x(rect.w), convert_y(rect.h)); + gfx_text(0, rect.x+3.0f, rect.y+3.0f, 15.0f*editor.world_zoom, buf, -1); } int LAYER_TILES::brush_grab(LAYERGROUP *brush, RECT rect) @@ -206,8 +209,28 @@ int LAYER_TILES::render_properties(RECT *toolbox) RECT button; ui_hsplit_b(toolbox, 12.0f, toolbox, &button); bool in_gamegroup = editor.map.game_group->layers.find(this) != -1; + if(editor.map.game_layer == this) + in_gamegroup = false; + static int colcl_button = 0; + if(do_editor_button(&colcl_button, "Clear Collision", in_gamegroup?0:-1, &button, draw_editor_button, 0, "Removes collision from this layer")) + { + LAYER_TILES *gl = editor.map.game_layer; + int w = min(gl->width, width); + int h = min(gl->height, height); + for(int y = 0; y < h; y++) + for(int x = 0; x < w; x++) + { + if(gl->tiles[y*gl->width+x].index <= TILE_SOLID) + if(tiles[y*width+x].index) + gl->tiles[y*gl->width+x].index = TILE_AIR; + } + + return 1; + } static int col_button = 0; - if(do_editor_button(&col_button, "Make Collision", in_gamegroup?0:-1, &button, draw_editor_button, 0, "Constructs collision from the this layer")) + ui_hsplit_b(toolbox, 5.0f, toolbox, &button); + ui_hsplit_b(toolbox, 12.0f, toolbox, &button); + if(do_editor_button(&col_button, "Make Collision", in_gamegroup?0:-1, &button, draw_editor_button, 0, "Constructs collision from this layer")) { LAYER_TILES *gl = editor.map.game_layer; int w = min(gl->width, width); @@ -249,7 +272,15 @@ int LAYER_TILES::render_properties(RECT *toolbox) else if(prop == PROP_HEIGHT && new_val > 1) resize(width, new_val); else if(prop == PROP_IMAGE) - image = new_val%editor.map.images.len(); + { + if (new_val == -1) + { + tex_id = -1; + image = -1; + } + else + image = new_val%editor.map.images.len(); + } return 0; } diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index 8688df28..640fab4c 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -153,14 +153,13 @@ void mods_message(int msgtype, int client_id) if(config.sv_spamprotection && p->last_setteam+time_freq()*3 > time_get()) return; - - p->last_setteam = time_get(); // Switch team on given client and kill/respawn him if(game.controller->can_join_team(msg->team, client_id)) { if(game.controller->can_change_team(p, msg->team)) { + p->last_setteam = time_get(); p->set_team(msg->team); (void) game.controller->check_team_balance(); } |