mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
editor update
This commit is contained in:
parent
e26b898b74
commit
c04df11f1e
Binary file not shown.
|
@ -631,7 +631,7 @@ static void menu2_render_serverbrowser(RECT main_view)
|
|||
ui_vsplit_r(&view, 200.0f, &view, &server_details);
|
||||
|
||||
// server list
|
||||
ui_hsplit_t(&view, 20.0f, &headers, &view);
|
||||
ui_hsplit_t(&view, 16.0f, &headers, &view);
|
||||
//ui_hsplit_b(&view, 110.0f, &view, &filters);
|
||||
ui_hsplit_b(&view, 5.0f, &view, 0);
|
||||
ui_hsplit_b(&view, 20.0f, &view, &status);
|
||||
|
@ -684,7 +684,7 @@ static void menu2_render_serverbrowser(RECT main_view)
|
|||
//{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_PING, BROWSESORT_PING, "Ping", 1, 40.0f, FIXED, {0}, {0}},
|
||||
{COL_PING, BROWSESORT_PING, "Ping", 1, 25.0f, FIXED, {0}, {0}},
|
||||
};
|
||||
|
||||
int num_cols = sizeof(cols)/sizeof(column);
|
||||
|
@ -785,6 +785,8 @@ static void menu2_render_serverbrowser(RECT main_view)
|
|||
|
||||
int selected = strcmp(item->address, config.ui_server_address) == 0; //selected_index==item_index;
|
||||
|
||||
|
||||
/*
|
||||
if(selected)
|
||||
{
|
||||
selected_index = i;
|
||||
|
@ -832,9 +834,19 @@ static void menu2_render_serverbrowser(RECT main_view)
|
|||
}
|
||||
else
|
||||
{
|
||||
ui_hsplit_t(&view, 20.0f, &row, &view);
|
||||
*/
|
||||
ui_hsplit_t(&view, 17.0f, &row, &view);
|
||||
select_hit_box = row;
|
||||
}
|
||||
//}
|
||||
|
||||
if(selected)
|
||||
{
|
||||
selected_index = i;
|
||||
RECT r = row;
|
||||
ui_margin(&r, 1.5f, &r);
|
||||
ui_draw_rect(&r, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f);
|
||||
}
|
||||
|
||||
|
||||
// make sure that only those in view can be selected
|
||||
if(row.y+row.h > original_view.y)
|
||||
|
@ -875,18 +887,18 @@ static void menu2_render_serverbrowser(RECT main_view)
|
|||
ui_draw_browse_icon(0x100, &button);
|
||||
}
|
||||
else if(id == COL_NAME)
|
||||
ui_do_label(&button, item->name, 15.0f, -1);
|
||||
ui_do_label(&button, item->name, 12.0f, -1);
|
||||
else if(id == COL_MAP)
|
||||
ui_do_label(&button, item->map, 15.0f, -1);
|
||||
ui_do_label(&button, item->map, 12.0f, -1);
|
||||
else if(id == COL_PLAYERS)
|
||||
{
|
||||
sprintf(temp, "%i/%i", item->num_players, item->max_players);
|
||||
ui_do_label(&button, temp, 15.0f, 1);
|
||||
ui_do_label(&button, temp, 12.0f, 1);
|
||||
}
|
||||
else if(id == COL_PING)
|
||||
{
|
||||
sprintf(temp, "%i", item->latency);
|
||||
ui_do_label(&button, temp, 15.0f, 1);
|
||||
ui_do_label(&button, temp, 12.0f, 1);
|
||||
}
|
||||
else if(id == COL_PROGRESS)
|
||||
{
|
||||
|
@ -899,7 +911,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";
|
||||
ui_do_label(&button, version, 15.0f, 1);
|
||||
ui_do_label(&button, version, 12.0f, 1);
|
||||
}
|
||||
else if(id == COL_GAMETYPE)
|
||||
{
|
||||
|
@ -907,7 +919,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";
|
||||
ui_do_label(&button, type, 15.0f, 0);
|
||||
ui_do_label(&button, type, 12.0f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ void ui_set_hot_item(const void *id) { becomming_hot_item = id; }
|
|||
void ui_set_active_item(const void *id) { active_item = id; if (id) last_active_item = id; }
|
||||
void ui_clear_last_active_item() { last_active_item = 0; }
|
||||
const void *ui_hot_item() { return hot_item; }
|
||||
const void *ui_next_hot_item() { return becomming_hot_item; }
|
||||
const void *ui_active_item() { return active_item; }
|
||||
const void *ui_last_active_item() { return last_active_item; }
|
||||
|
||||
|
@ -234,25 +235,36 @@ void ui_hmargin(const RECT *original, float cut, RECT *other_rect)
|
|||
other_rect->h = r.h - 2*cut;
|
||||
}
|
||||
|
||||
|
||||
int ui_do_button(const void *id, const char *text, int checked, const RECT *r, ui_draw_button_func draw_func, const void *extra)
|
||||
{
|
||||
/* logic */
|
||||
int ret = 0;
|
||||
int inside = ui_mouse_inside(r);
|
||||
static int button_used = 0;
|
||||
|
||||
if(ui_active_item() == id)
|
||||
{
|
||||
if(!ui_mouse_button(0))
|
||||
if(!ui_mouse_button(button_used))
|
||||
{
|
||||
if(inside && checked >= 0)
|
||||
ret = 1;
|
||||
ret = 1+button_used;
|
||||
ui_set_active_item(0);
|
||||
}
|
||||
}
|
||||
else if(ui_hot_item() == id)
|
||||
{
|
||||
if(ui_mouse_button(0))
|
||||
{
|
||||
ui_set_active_item(id);
|
||||
button_used = 0;
|
||||
}
|
||||
|
||||
if(ui_mouse_button(1))
|
||||
{
|
||||
ui_set_active_item(id);
|
||||
button_used = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(inside)
|
||||
|
|
|
@ -35,6 +35,7 @@ void ui_set_hot_item(const void *id);
|
|||
void ui_set_active_item(const void *id);
|
||||
void ui_clear_last_active_item();
|
||||
const void *ui_hot_item();
|
||||
const void *ui_next_hot_item();
|
||||
const void *ui_active_item();
|
||||
const void *ui_last_active_item();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,8 +25,7 @@ void swap(T &a, T &b)
|
|||
|
||||
enum
|
||||
{
|
||||
MODE_MAP=0,
|
||||
MODE_LAYERS,
|
||||
MODE_LAYERS=0,
|
||||
MODE_IMAGES,
|
||||
|
||||
DIALOG_NONE=0,
|
||||
|
@ -198,7 +197,7 @@ public:
|
|||
virtual void brush_flip_y() {}
|
||||
|
||||
virtual void render() {}
|
||||
virtual void render_properties(RECT *toolbox) {}
|
||||
virtual int render_properties(RECT *toolbox) { return 0; }
|
||||
|
||||
virtual void get_size(float *w, float *h) { *w = 0; *h = 0;}
|
||||
|
||||
|
@ -351,13 +350,14 @@ public:
|
|||
show_envelope_editor = 0;
|
||||
}
|
||||
|
||||
void do_file_dialog(const char *title, const char *button_text,
|
||||
void invoke_file_dialog(const char *title, const char *button_text,
|
||||
const char *basepath, const char *default_name,
|
||||
void (*func)(const char *filename));
|
||||
|
||||
void make_game_group(LAYERGROUP *group);
|
||||
void make_game_layer(LAYER *layer);
|
||||
|
||||
void reset(bool create_default=true);
|
||||
int save(const char *filename);
|
||||
int load(const char *filename);
|
||||
|
||||
|
@ -431,7 +431,7 @@ public:
|
|||
virtual void brush_flip_x();
|
||||
virtual void brush_flip_y();
|
||||
|
||||
virtual void render_properties(RECT *toolbox);
|
||||
virtual int render_properties(RECT *toolbox);
|
||||
|
||||
void get_size(float *w, float *h) { *w = width*32.0f; *h = height*32.0f; }
|
||||
|
||||
|
@ -458,7 +458,7 @@ public:
|
|||
virtual void brush_flip_x();
|
||||
virtual void brush_flip_y();
|
||||
|
||||
virtual void render_properties(RECT *toolbox);
|
||||
virtual int render_properties(RECT *toolbox);
|
||||
|
||||
void get_size(float *w, float *h);
|
||||
|
||||
|
@ -473,5 +473,8 @@ public:
|
|||
LAYER_GAME(int w, int h);
|
||||
~LAYER_GAME();
|
||||
|
||||
virtual void render_properties(RECT *toolbox);
|
||||
virtual int render_properties(RECT *toolbox);
|
||||
};
|
||||
|
||||
int do_editor_button(const void *id, const char *text, int checked, const RECT *r, ui_draw_button_func draw_func, int flags, const char *tooltip);
|
||||
void draw_editor_button(const void *id, const char *text, int checked, const RECT *r, const void *extra);
|
||||
|
|
|
@ -12,8 +12,9 @@ LAYER_GAME::~LAYER_GAME()
|
|||
{
|
||||
}
|
||||
|
||||
void LAYER_GAME::render_properties(RECT *toolbox)
|
||||
int LAYER_GAME::render_properties(RECT *toolbox)
|
||||
{
|
||||
LAYER_TILES::render_properties(toolbox);
|
||||
int r = LAYER_TILES::render_properties(toolbox);
|
||||
image = -1;
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ void LAYER_QUADS::get_size(float *w, float *h)
|
|||
|
||||
extern int selected_points;
|
||||
|
||||
void LAYER_QUADS::render_properties(RECT *toolbox)
|
||||
int LAYER_QUADS::render_properties(RECT *toolbox)
|
||||
{
|
||||
// layer props
|
||||
if(editor.props == PROPS_LAYER)
|
||||
|
@ -276,6 +276,8 @@ void LAYER_QUADS::render_properties(RECT *toolbox)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -184,10 +184,26 @@ void LAYER_TILES::resize(int new_w, int new_h)
|
|||
}
|
||||
|
||||
|
||||
void LAYER_TILES::render_properties(RECT *toolbox)
|
||||
int LAYER_TILES::render_properties(RECT *toolbox)
|
||||
{
|
||||
if(editor.props != PROPS_LAYER)
|
||||
return;
|
||||
RECT button;
|
||||
ui_hsplit_b(toolbox, 12.0f, toolbox, &button);
|
||||
bool in_gamegroup = editor.game_group->layers.find(this) != -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"))
|
||||
{
|
||||
LAYER_TILES *gl = editor.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)
|
||||
gl->tiles[y*gl->width+x].index = tiles[y*width+x].index?TILE_SOLID:TILE_AIR;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -214,4 +230,6 @@ void LAYER_TILES::render_properties(RECT *toolbox)
|
|||
resize(new_val, height);
|
||||
else if(prop == PROP_HEIGHT && new_val > 1)
|
||||
resize(width, new_val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue