mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
merge from 0.4.3: lots of small stuff
This commit is contained in:
parent
6dcea2c4ca
commit
c3ff86330f
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue