summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/connections_dialog.cpp11
-rw-r--r--tools/editor/editor_dir_dialog.cpp22
-rw-r--r--tools/editor/editor_node.cpp5
-rw-r--r--tools/editor/editor_settings.cpp1
-rw-r--r--tools/editor/icons/icon_back_buffer_copy.pngbin0 -> 204 bytes
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp347
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp2
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp101
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h11
-rw-r--r--tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/light_occluder_2d_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/navigation_polygon_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp69
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h2
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp40
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp170
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.h2
-rw-r--r--tools/editor/property_editor.cpp32
19 files changed, 656 insertions, 176 deletions
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index d7158eb7e9..cf4b21510a 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -607,6 +607,14 @@ void ConnectionsDialog::_remove_confirm() {
}
*/
+
+struct _ConnectionsDialogMethodInfoSort {
+
+ _FORCE_INLINE_ bool operator()(const MethodInfo& a, const MethodInfo& b) const {
+ return a.name < b.name;
+ }
+};
+
void ConnectionsDialog::update_tree() {
if (!is_visible())
@@ -623,7 +631,8 @@ void ConnectionsDialog::update_tree() {
node->get_signal_list(&node_signals);
-
+ //node_signals.sort_custom<_ConnectionsDialogMethodInfoSort>();
+
for(List<MethodInfo>::Element *E=node_signals.front();E;E=E->next()) {
diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp
index eee4125e93..eec452ab7f 100644
--- a/tools/editor/editor_dir_dialog.cpp
+++ b/tools/editor/editor_dir_dialog.cpp
@@ -28,6 +28,9 @@
/*************************************************************************/
#include "editor_dir_dialog.h"
#include "os/os.h"
+#include "os/keyboard.h"
+#include "tools/editor/editor_settings.h"
+
void EditorDirDialog::_update_dir(TreeItem* p_item) {
@@ -39,12 +42,21 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) {
da->change_dir(cdir);
da->list_dir_begin();
String p=da->get_next();
+
+ bool ishidden;
+ bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
+
while(p!="") {
- if (da->current_is_dir() && !p.begins_with(".")) {
- TreeItem *ti = tree->create_item(p_item);
- ti->set_text(0,p);
- ti->set_icon(0,get_icon("Folder","EditorIcons"));
- ti->set_collapsed(true);
+
+ ishidden = da->current_is_hidden();
+
+ if (show_hidden || !ishidden) {
+ if (da->current_is_dir() && !p.begins_with(".")) {
+ TreeItem *ti = tree->create_item(p_item);
+ ti->set_text(0,p);
+ ti->set_icon(0,get_icon("Folder","EditorIcons"));
+ ti->set_collapsed(true);
+ }
}
p=da->get_next();
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 3d42867d9a..5e571373ea 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -218,6 +218,7 @@ void EditorNode::_notification(int p_what) {
}
if (p_what==NOTIFICATION_ENTER_TREE) {
+
//MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata");
get_tree()->set_editor_hint(true);
get_tree()->get_root()->set_as_audio_listener(false);
@@ -231,6 +232,8 @@ void EditorNode::_notification(int p_what) {
VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport(),true);
VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport(),true);
+ VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true);
+
_editor_select(1);
if (defer_load_scene!="") {
@@ -3412,6 +3415,8 @@ EditorNode::EditorNode() {
scene_root = memnew( Viewport );
+
+
//scene_root_base->add_child(scene_root);
scene_root->set_meta("_editor_disable_input",true);
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport(),true);
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 24699ac87f..deb5d86a2e 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -446,6 +446,7 @@ void EditorSettings::_load_defaults() {
set("text_editor/create_signal_callbacks",true);
+ set("file_dialog/show_hidden_files", false);
set("animation/autorename_animation_tracks",true);
set("animation/confirm_insert_track",true);
diff --git a/tools/editor/icons/icon_back_buffer_copy.png b/tools/editor/icons/icon_back_buffer_copy.png
new file mode 100644
index 0000000000..b27eb39108
--- /dev/null
+++ b/tools/editor/icons/icon_back_buffer_copy.png
Binary files differ
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index 1fd7d26f8b..0562153199 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -47,6 +47,12 @@ class _EditorFontImportOptions : public Object {
OBJ_TYPE(_EditorFontImportOptions,Object);
public:
+ enum FontMode {
+
+ FONT_BITMAP,
+ FONT_DISTANCE_FIELD
+ };
+
enum ColorType {
COLOR_WHITE,
COLOR_CUSTOM,
@@ -69,6 +75,9 @@ public:
CHARSET_CUSTOM_LATIN
};
+
+ FontMode font_mode;
+
CharacterSet character_set;
String custom_file;
@@ -91,7 +100,6 @@ public:
bool color_use_monochrome;
String gradient_image;
-
bool disable_filter;
bool round_advance;
@@ -100,7 +108,10 @@ public:
bool _set(const StringName& p_name, const Variant& p_value) {
String n = p_name;
- if (n=="extra_space/char")
+ if (n=="mode/mode") {
+ font_mode=FontMode(int(p_value));
+ _change_notify();
+ } else if (n=="extra_space/char")
char_extra_spacing=p_value;
else if (n=="extra_space/space")
space_extra_spacing=p_value;
@@ -169,7 +180,9 @@ public:
bool _get(const StringName& p_name,Variant &r_ret) const{
String n = p_name;
- if (n=="extra_space/char")
+ if (n=="mode/mode")
+ r_ret=font_mode;
+ else if (n=="extra_space/char")
r_ret=char_extra_spacing;
else if (n=="extra_space/space")
r_ret=space_extra_spacing;
@@ -231,6 +244,9 @@ public:
void _get_property_list( List<PropertyInfo> *p_list) const{
+
+ p_list->push_back(PropertyInfo(Variant::INT,"mode/mode",PROPERTY_HINT_ENUM,"Bitmap,Distance Field"));
+
p_list->push_back(PropertyInfo(Variant::INT,"extra_space/char",PROPERTY_HINT_RANGE,"-64,64,1"));
p_list->push_back(PropertyInfo(Variant::INT,"extra_space/space",PROPERTY_HINT_RANGE,"-64,64,1"));
p_list->push_back(PropertyInfo(Variant::INT,"extra_space/top",PROPERTY_HINT_RANGE,"-64,64,1"));
@@ -240,35 +256,45 @@ public:
if (character_set>=CHARSET_CUSTOM)
p_list->push_back(PropertyInfo(Variant::STRING,"character_set/custom",PROPERTY_HINT_FILE));
- p_list->push_back(PropertyInfo(Variant::BOOL,"shadow/enabled"));
- if (shadow) {
- p_list->push_back(PropertyInfo(Variant::INT,"shadow/radius",PROPERTY_HINT_RANGE,"-64,64,1"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow/offset"));
- p_list->push_back(PropertyInfo(Variant::COLOR,"shadow/color"));
- p_list->push_back(PropertyInfo(Variant::REAL,"shadow/transition",PROPERTY_HINT_EXP_EASING));
- }
+ int usage = PROPERTY_USAGE_DEFAULT;
- p_list->push_back(PropertyInfo(Variant::BOOL,"shadow2/enabled"));
- if (shadow2) {
- p_list->push_back(PropertyInfo(Variant::INT,"shadow2/radius",PROPERTY_HINT_RANGE,"-64,64,1"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow2/offset"));
- p_list->push_back(PropertyInfo(Variant::COLOR,"shadow2/color"));
- p_list->push_back(PropertyInfo(Variant::REAL,"shadow2/transition",PROPERTY_HINT_EXP_EASING));
+ if (font_mode==FONT_DISTANCE_FIELD) {
+ usage = PROPERTY_USAGE_NOEDITOR;
}
- p_list->push_back(PropertyInfo(Variant::INT,"color/mode",PROPERTY_HINT_ENUM,"White,Color,Gradient,Gradient Image"));
- if (color_type==COLOR_CUSTOM) {
- p_list->push_back(PropertyInfo(Variant::COLOR,"color/color"));
+ {
+ p_list->push_back(PropertyInfo(Variant::BOOL,"shadow/enabled",PROPERTY_HINT_NONE,"",usage));
+ if (shadow) {
+ p_list->push_back(PropertyInfo(Variant::INT,"shadow/radius",PROPERTY_HINT_RANGE,"-64,64,1",usage));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow/offset",PROPERTY_HINT_NONE,"",usage));
+ p_list->push_back(PropertyInfo(Variant::COLOR,"shadow/color",PROPERTY_HINT_NONE,"",usage));
+ p_list->push_back(PropertyInfo(Variant::REAL,"shadow/transition",PROPERTY_HINT_EXP_EASING,"",usage));
+ }
+
+ p_list->push_back(PropertyInfo(Variant::BOOL,"shadow2/enabled",PROPERTY_HINT_NONE,"",usage));
+ if (shadow2) {
+ p_list->push_back(PropertyInfo(Variant::INT,"shadow2/radius",PROPERTY_HINT_RANGE,"-64,64,1",usage));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow2/offset",PROPERTY_HINT_NONE,"",usage));
+ p_list->push_back(PropertyInfo(Variant::COLOR,"shadow2/color",PROPERTY_HINT_NONE,"",usage));
+ p_list->push_back(PropertyInfo(Variant::REAL,"shadow2/transition",PROPERTY_HINT_EXP_EASING,"",usage));
+ }
+
+ p_list->push_back(PropertyInfo(Variant::INT,"color/mode",PROPERTY_HINT_ENUM,"White,Color,Gradient,Gradient Image",usage));
+ if (color_type==COLOR_CUSTOM) {
+ p_list->push_back(PropertyInfo(Variant::COLOR,"color/color",PROPERTY_HINT_NONE,"",usage));
+
+ }
+ if (color_type==COLOR_GRADIENT_RANGE) {
+ p_list->push_back(PropertyInfo(Variant::COLOR,"color/begin",PROPERTY_HINT_NONE,"",usage));
+ p_list->push_back(PropertyInfo(Variant::COLOR,"color/end",PROPERTY_HINT_NONE,"",usage));
+ }
+ if (color_type==COLOR_GRADIENT_IMAGE) {
+ p_list->push_back(PropertyInfo(Variant::STRING,"color/image",PROPERTY_HINT_FILE,"",usage));
+ }
+ p_list->push_back(PropertyInfo(Variant::BOOL,"color/monochrome",PROPERTY_HINT_NONE,"",usage));
}
- if (color_type==COLOR_GRADIENT_RANGE) {
- p_list->push_back(PropertyInfo(Variant::COLOR,"color/begin"));
- p_list->push_back(PropertyInfo(Variant::COLOR,"color/end"));
- }
- if (color_type==COLOR_GRADIENT_IMAGE) {
- p_list->push_back(PropertyInfo(Variant::STRING,"color/image",PROPERTY_HINT_FILE));
- }
- p_list->push_back(PropertyInfo(Variant::BOOL,"color/monochrome"));
+
p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/round_advance"));
p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/disable_filter"));
@@ -307,6 +333,7 @@ public:
gradient_end=Color(0.5,0.5,0.5,1);
color_use_monochrome=false;
+ font_mode=FONT_BITMAP;
round_advance=true;
disable_filter=false;
@@ -314,6 +341,8 @@ public:
_EditorFontImportOptions() {
+ font_mode=FONT_BITMAP;
+
char_extra_spacing=0;
top_extra_spacing=0;
bottom_extra_spacing=0;
@@ -706,6 +735,137 @@ struct _EditorKerningKey {
};
+
+static unsigned char get_SDF_radial(
+ unsigned char *fontmap,
+ int w, int h,
+ int x, int y,
+ int max_radius )
+{
+ // hideous brute force method
+ float d2 = max_radius*max_radius+1.0;
+ unsigned char v = fontmap[x+y*w];
+ for( int radius = 1; (radius <= max_radius) && (radius*radius < d2); ++radius )
+ {
+ int line, lo, hi;
+ // north
+ line = y - radius;
+ if( (line >= 0) && (line < h) )
+ {
+ lo = x - radius;
+ hi = x + radius;
+ if( lo < 0 ) { lo = 0; }
+ if( hi >= w ) { hi = w-1; }
+ int idx = line * w + lo;
+ for( int i = lo; i <= hi; ++i )
+ {
+ // check this pixel
+ if( fontmap[idx] != v )
+ {
+ float nx = i - x;
+ float ny = line - y;
+ float nd2 = nx*nx+ny*ny;
+ if( nd2 < d2 )
+ {
+ d2 = nd2;
+ }
+ }
+ // move on
+ ++idx;
+ }
+ }
+ // south
+ line = y + radius;
+ if( (line >= 0) && (line < h) )
+ {
+ lo = x - radius;
+ hi = x + radius;
+ if( lo < 0 ) { lo = 0; }
+ if( hi >= w ) { hi = w-1; }
+ int idx = line * w + lo;
+ for( int i = lo; i <= hi; ++i )
+ {
+ // check this pixel
+ if( fontmap[idx] != v )
+ {
+ float nx = i - x;
+ float ny = line - y;
+ float nd2 = nx*nx+ny*ny;
+ if( nd2 < d2 )
+ {
+ d2 = nd2;
+ }
+ }
+ // move on
+ ++idx;
+ }
+ }
+ // west
+ line = x - radius;
+ if( (line >= 0) && (line < w) )
+ {
+ lo = y - radius + 1;
+ hi = y + radius - 1;
+ if( lo < 0 ) { lo = 0; }
+ if( hi >= h ) { hi = h-1; }
+ int idx = lo * w + line;
+ for( int i = lo; i <= hi; ++i )
+ {
+ // check this pixel
+ if( fontmap[idx] != v )
+ {
+ float nx = line - x;
+ float ny = i - y;
+ float nd2 = nx*nx+ny*ny;
+ if( nd2 < d2 )
+ {
+ d2 = nd2;
+ }
+ }
+ // move on
+ idx += w;
+ }
+ }
+ // east
+ line = x + radius;
+ if( (line >= 0) && (line < w) )
+ {
+ lo = y - radius + 1;
+ hi = y + radius - 1;
+ if( lo < 0 ) { lo = 0; }
+ if( hi >= h ) { hi = h-1; }
+ int idx = lo * w + line;
+ for( int i = lo; i <= hi; ++i )
+ {
+ // check this pixel
+ if( fontmap[idx] != v )
+ {
+ float nx = line - x;
+ float ny = i - y;
+ float nd2 = nx*nx+ny*ny;
+ if( nd2 < d2 )
+ {
+ d2 = nd2;
+ }
+ }
+ // move on
+ idx += w;
+ }
+ }
+ }
+ d2 = sqrtf( d2 );
+ if( v==0 )
+ {
+ d2 = -d2;
+ }
+ d2 *= 127.5 / max_radius;
+ d2 += 127.5;
+ if( d2 < 0.0 ) d2 = 0.0;
+ if( d2 > 255.0 ) d2 = 255.0;
+ return (unsigned char)(d2 + 0.5);
+}
+
+
Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata>& p_from, const String &p_existing) {
Ref<ResourceImportMetadata> from = p_from;
@@ -754,7 +914,11 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
}
- error = FT_Set_Pixel_Sizes(face,0,size);
+ int font_mode = from->get_option("mode/mode");
+
+ int scaler=(font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD)?16:1;
+
+ error = FT_Set_Pixel_Sizes(face,0,size*scaler);
FT_GlyphSlot slot = face->glyph;
@@ -820,9 +984,9 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
{
bool skip=false;
- error = FT_Load_Char( face, charcode, FT_LOAD_RENDER );
+ error = FT_Load_Char( face, charcode, font_mode==_EditorFontImportOptions::FONT_BITMAP?FT_LOAD_RENDER:FT_LOAD_MONOCHROME );
if (error) skip=true;
- else error = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
+ else error = FT_Render_Glyph( face->glyph, font_mode==_EditorFontImportOptions::FONT_BITMAP?ft_render_mode_normal:ft_render_mode_mono );
if (error) {
skip=true;
} else if (!skip) {
@@ -847,28 +1011,36 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
}
_EditorFontData * fdata = memnew( _EditorFontData );
- fdata->bitmap.resize( slot->bitmap.width*slot->bitmap.rows );
- fdata->width=slot->bitmap.width;
- fdata->height=slot->bitmap.rows;
- fdata->character=charcode;
- fdata->glyph=FT_Get_Char_Index(face,charcode);
- if (charcode=='x')
- xsize=slot->bitmap.width;
- if (charcode<127) {
- if (slot->bitmap_top>max_up) {
+ int w = slot->bitmap.width;
+ int h = slot->bitmap.rows;
+ int p = slot->bitmap.pitch;
- max_up=slot->bitmap_top;
- }
+ print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch));
+ if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
- if ( (slot->bitmap_top - fdata->height)<max_down ) {
+ // oversize the holding buffer so I can smooth it!
+ int sw = w + scaler * 4;
+ int sh = h + scaler * 4;
+ // do the SDF
+ int sdfw = sw / scaler;
+ int sdfh = sh / scaler;
- max_down=slot->bitmap_top - fdata->height;
- }
+ fdata->width=sdfw;
+ fdata->height=sdfh;
+ } else {
+ fdata->width=w;
+ fdata->height=h;
}
+ fdata->character=charcode;
+ fdata->glyph=FT_Get_Char_Index(face,charcode);
+ if (charcode=='x')
+ xsize=w/scaler;
+
+
fdata->valign=slot->bitmap_top;
fdata->halign=slot->bitmap_left;
@@ -878,12 +1050,85 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
else
fdata->advance=slot->advance.x/float(1<<6);
+ if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
+
+ fdata->halign = fdata->halign / scaler - 1.5;
+ fdata->valign = fdata->valign / scaler + 1.5;
+ fdata->advance/=scaler;
+
+ }
+
fdata->advance+=font_spacing;
- for (int i=0;i<slot->bitmap.width;i++) {
- for (int j=0;j<slot->bitmap.rows;j++) {
- fdata->bitmap[j*slot->bitmap.width+i]=slot->bitmap.buffer[j*slot->bitmap.width+i];
+ if (charcode<127) {
+ int top = fdata->valign;
+ int hmax = h/scaler;
+
+ if (top>max_up) {
+
+ max_up=top;
+ }
+
+
+ if ( (top - hmax)<max_down ) {
+
+ max_down=top - hmax;
+ }
+ }
+
+ if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
+
+
+ // oversize the holding buffer so I can smooth it!
+ int sw = w + scaler * 4;
+ int sh = h + scaler * 4;
+
+ unsigned char *smooth_buf = new unsigned char[sw*sh];
+
+ for( int i = 0; i < sw*sh; ++i ) {
+ smooth_buf[i] = 0;
+ }
+
+ // copy the glyph into the buffer to be smoothed
+ unsigned char *buf = slot->bitmap.buffer;
+ for( int j = 0; j < h; ++j ) {
+ for( int i = 0; i < w; ++i ) {
+ smooth_buf[scaler*2+i+(j+scaler*2)*sw] = 255 * ((buf[j*p+(i>>3)] >> (7 - (i & 7))) & 1);
+ }
+ }
+
+ // do the SDF
+ int sdfw = fdata->width;
+ int sdfh = fdata->height;
+
+ fdata->bitmap.resize( sdfw*sdfh );
+
+ for( int j = 0; j < sdfh; ++j ) {
+ for( int i = 0; i < sdfw; ++i ) {
+ int pd_idx = j*sdfw+i;
+
+ //fdata->bitmap[j*slot->bitmap.width+i]=slot->bitmap.buffer[j*slot->bitmap.width+i];
+
+ fdata->bitmap[pd_idx] =
+ //get_SDF
+ get_SDF_radial
+ ( smooth_buf, sw, sh,
+ i*scaler + (scaler >>1), j*scaler + (scaler >>1),
+ 2*scaler );
+
+ }
+ }
+
+ delete [] smooth_buf;
+
+ } else {
+ fdata->bitmap.resize( slot->bitmap.width*slot->bitmap.rows );
+ for (int i=0;i<slot->bitmap.width;i++) {
+ for (int j=0;j<slot->bitmap.rows;j++) {
+
+ fdata->bitmap[j*slot->bitmap.width+i]=slot->bitmap.buffer[j*slot->bitmap.width+i];
+ }
}
}
@@ -904,9 +1149,10 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
spd->ofs_x=0;
spd->ofs_y=0;
- if (!FT_Load_Char( face, ' ', FT_LOAD_RENDER ) && !FT_Render_Glyph( face->glyph, ft_render_mode_normal )) {
+ if (!FT_Load_Char( face, ' ', FT_LOAD_RENDER ) && !FT_Render_Glyph( face->glyph, font_mode==_EditorFontImportOptions::FONT_BITMAP?ft_render_mode_normal:ft_render_mode_mono )) {
spd->advance = slot->advance.x>>6; //round to nearest or store as float
+ spd->advance/=scaler;
spd->advance+=font_spacing;
} else {
@@ -955,7 +1201,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
if (kern==0)
continue;
- kerning_map[kpk]=kern;
+ kerning_map[kpk]=kern/scaler;
}
}
}
@@ -1079,7 +1325,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
pixels.resize(s.x*s.y*4);
DVector<uint8_t>::Write w = pixels.write();
- print_line("val: "+itos(font_data_list[i]->valign));
+ //print_line("val: "+itos(font_data_list[i]->valign));
for(int y=0;y<s.height;y++) {
int yc=CLAMP(y-o.y+font_data_list[i]->valign,0,height-1);
@@ -1284,6 +1530,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
font->clear();
font->set_height(height+bottom_space+top_space);
font->set_ascent(ascent+top_space);
+ font->set_distance_field_hint(font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD);
//register texures
{
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index 42a185b7c2..184f80a1b7 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -1233,7 +1233,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
if (dist<r) {
//avoid accumulaiton of light on corners
//plot_light=plot_light.linear_interpolate(Color(0,0,0,0),1.0-sd/plot_size*plot_size);
- skip-true;
+ skip=true;
} else {
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 514f4b6525..fdec72332e 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -87,7 +87,7 @@ Dictionary CanvasItemEditor::get_state() const {
state["ofs"]=Point2(h_scroll->get_val(),v_scroll->get_val());
// state["ofs"]=-transform.get_origin();
state["use_snap"]=is_snap_active();
- state["snap"]=snap;
+ state["snap_vec"]=Vector2(get_snap());
state["pixel_snap"]=pixel_snap;
return state;
}
@@ -111,7 +111,15 @@ void CanvasItemEditor::set_state(const Dictionary& p_state){
}
if (state.has("snap")) {
- snap=state["snap"];
+ snap_x->set_val(state["snap"]);
+ snap_y->set_val(state["snap"]);
+ }
+
+ if (state.has("snap_vec")) {
+ Vector2 sv = state["snap_vec"];
+ snap_x->set_val(sv.x);
+ snap_y->set_val(sv.y);
+ viewport->update();
}
if (state.has("pixel_snap")) {
@@ -300,7 +308,7 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE
Vector2 drag = p_dir;
if (p_snap)
- drag*=snap;
+ drag*=get_snap();
undo_redo->add_undo_method(canvas_item,"edit_set_state",canvas_item->edit_get_state());
@@ -554,6 +562,13 @@ void CanvasItemEditor::_append_canvas_item(CanvasItem *c) {
}
+void CanvasItemEditor::_snap_changed(double) {
+
+ viewport->update();
+}
+
+
+
void CanvasItemEditor::_dialog_value_changed(double) {
if (updating_value_dialog)
@@ -563,7 +578,7 @@ void CanvasItemEditor::_dialog_value_changed(double) {
case SNAP_CONFIGURE: {
- snap=dialog_val->get_val();
+ // snap=dialog_val->get_val();
viewport->update();
} break;
case ZOOM_SET: {
@@ -1165,7 +1180,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
continue;
}
- if (pixel_snap || (is_snap_active() && snap>0)) {
+ if (pixel_snap || (is_snap_active() && get_snap().x>0 && get_snap().y>0)) {
if (drag!=DRAG_ALL) {
dfrom=drag_point_from;
@@ -1174,14 +1189,14 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
Vector2 newpos = drag_point_from + (dto-dfrom);
Vector2 disp;
- if (!is_snap_active() || snap<1) {
+ if (!is_snap_active() || get_snap().x<1 || get_snap().y<1) {
disp.x = Math::fposmod(newpos.x,1);
disp.y = Math::fposmod(newpos.y,1);
} else {
- disp.x = Math::fposmod(newpos.x,snap);
- disp.y = Math::fposmod(newpos.y,snap);
+ disp.x = Math::fposmod(newpos.x,get_snap().x);
+ disp.y = Math::fposmod(newpos.y,get_snap().y);
}
dto-=disp;
}
@@ -1477,7 +1492,7 @@ void CanvasItemEditor::_viewport_draw() {
_update_scrollbars();
RID ci=viewport->get_canvas_item();
- if (snap>0 && is_snap_active() && true ) {
+ if (get_snap().x>0 && get_snap().y>0 && is_snap_active() && true ) {
Size2 s = viewport->get_size();
@@ -1485,7 +1500,7 @@ void CanvasItemEditor::_viewport_draw() {
Matrix32 xform = transform.affine_inverse();
for(int i=0;i<s.width;i++) {
- int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(i,0)).x/snap));
+ int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(i,0)).x/get_snap().x));
if (i==0)
last_cell=cell;
if (last_cell!=cell)
@@ -1495,7 +1510,7 @@ void CanvasItemEditor::_viewport_draw() {
for(int i=0;i<s.height;i++) {
- int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(0,i)).y/snap));
+ int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(0,i)).y/get_snap().y));
if (i==0)
last_cell=cell;
if (last_cell!=cell)
@@ -1809,6 +1824,8 @@ void CanvasItemEditor::_notification(int p_what) {
group_button->set_icon(get_icon("Group","EditorIcons"));
ungroup_button->set_icon(get_icon("Ungroup","EditorIcons"));
key_insert_button->set_icon(get_icon("Key","EditorIcons"));
+ snap_x->connect("value_changed",this,"_snap_changed");
+ snap_y->connect("value_changed",this,"_snap_changed");
}
@@ -2002,7 +2019,7 @@ Point2 CanvasItemEditor::snapify(const Point2& p_pos) const {
Vector2 pos = p_pos;
- if (!active || snap<1) {
+ if (!active || get_snap().x<1 || get_snap().y<1) {
if (pixel_snap) {
@@ -2014,8 +2031,8 @@ Point2 CanvasItemEditor::snapify(const Point2& p_pos) const {
}
- pos.x=Math::stepify(pos.x,snap);
- pos.y=Math::stepify(pos.y,snap);
+ pos.x=Math::stepify(pos.x,get_snap().x);
+ pos.y=Math::stepify(pos.y,get_snap().y);
return pos;
@@ -2038,15 +2055,46 @@ void CanvasItemEditor::_popup_callback(int p_op) {
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_PIXEL);
edit_menu->get_popup()->set_item_checked(idx,pixel_snap);
} break;
+ case SNAP_OBJECT_CENTERS: {
+
+ List<Node*> &selection = editor_selection->get_selected_node_list();
+
+ undo_redo->create_action("Snap Object Centers");
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+
+ CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ if (!canvas_item)
+ continue;
+ if (!canvas_item->is_visible())
+ continue;
+ Node2D* node = canvas_item->cast_to<Node2D>();
+ if (!node)
+ continue;
+
+ Matrix32 gtrans = node->get_global_transform();
+ gtrans.elements[2]=snapify(gtrans.elements[2]);
+
+ undo_redo->add_do_method(node,"set_global_transform",gtrans);
+ undo_redo->add_undo_method(node,"set_global_transform",node->get_global_transform());
+ }
+
+ undo_redo->add_do_method(viewport,"update");
+ undo_redo->add_undo_method(viewport,"update");
+ undo_redo->commit_action();
+
+ } break;
case SNAP_CONFIGURE: {
updating_value_dialog=true;
+ snap_dialog->popup_centered_minsize();
+/*
dialog_label->set_text("Snap (Pixels):");
dialog_val->set_min(1);
dialog_val->set_step(1);
dialog_val->set_max(4096);
dialog_val->set_val(snap);
value_dialog->popup_centered(Size2(200,85));
+ */
updating_value_dialog=false;
} break;
@@ -2604,6 +2652,7 @@ void CanvasItemEditor::_bind_methods() {
ObjectTypeDB::bind_method("_unhandled_key_input",&CanvasItemEditor::_unhandled_key_input);
ObjectTypeDB::bind_method("_viewport_draw",&CanvasItemEditor::_viewport_draw);
ObjectTypeDB::bind_method("_viewport_input_event",&CanvasItemEditor::_viewport_input_event);
+ ObjectTypeDB::bind_method("_snap_changed",&CanvasItemEditor::_snap_changed);
ADD_SIGNAL( MethodInfo("item_lock_status_changed") );
ADD_SIGNAL( MethodInfo("item_group_status_changed") );
@@ -2812,6 +2861,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_item("Configure Snap..",SNAP_CONFIGURE);
p->add_separator();
p->add_check_item("Use Pixel Snap",SNAP_USE_PIXEL);
+ p->add_item("Snap Selected Object Centers",SNAP_OBJECT_CENTERS);
p->add_separator();
p->add_item("Expand to Parent",EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P);
p->add_separator();
@@ -2918,12 +2968,33 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
dialog_val->connect("value_changed",this,"_dialog_value_changed");
select_sb = Ref<StyleBoxTexture>( memnew( StyleBoxTexture) );
+ snap_dialog = memnew( AcceptDialog );
+ VBoxContainer *snap_vb = memnew( VBoxContainer );
+ snap_dialog->add_child(snap_vb);
+ snap_dialog->set_child_rect(snap_vb);
+ snap_dialog->set_title("Snap Configuration");
+ snap_x = memnew( SpinBox );
+ snap_x->set_custom_minimum_size(Size2(250,0));
+ snap_y = memnew( SpinBox );
+ snap_x->set_min(1);
+ snap_x->set_max(4096);
+ snap_x->set_step(1);
+ snap_x->set_val(10);
+ snap_y->set_min(1);
+ snap_y->set_max(4096);
+ snap_y->set_step(1);
+ snap_y->set_val(10);
+ snap_vb->add_margin_child("Snap X",snap_x);
+ snap_vb->add_margin_child("Snap Y",snap_y);
+ add_child(snap_dialog);
+
+
key_pos=true;
key_rot=true;
key_scale=false;
zoom=1;
- snap=10;
+ //snap=10;
updating_value_dialog=false;
box_selecting=false;
//zoom=0.5;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h
index 6648d486e8..9160742826 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.h
+++ b/tools/editor/plugins/canvas_item_editor_plugin.h
@@ -77,6 +77,7 @@ class CanvasItemEditor : public VBoxContainer {
SNAP_USE,
SNAP_CONFIGURE,
SNAP_USE_PIXEL,
+ SNAP_OBJECT_CENTERS,
ZOOM_IN,
ZOOM_OUT,
ZOOM_RESET,
@@ -143,7 +144,6 @@ class CanvasItemEditor : public VBoxContainer {
Matrix32 transform;
float zoom;
- int snap;
bool pixel_snap;
bool box_selecting;
Point2 box_selecting_to;
@@ -250,7 +250,11 @@ class CanvasItemEditor : public VBoxContainer {
AcceptDialog *value_dialog;
Label *dialog_label;
SpinBox *dialog_val;
-
+
+ AcceptDialog *snap_dialog;
+ SpinBox *snap_x;
+ SpinBox *snap_y;
+
CanvasItem *ref_item;
void _add_canvas_item(CanvasItem *p_canvas_item);
@@ -289,6 +293,7 @@ class CanvasItemEditor : public VBoxContainer {
void _viewport_input_event(const InputEvent& p_event);
void _viewport_draw();
+ void _snap_changed(double);
HSplitContainer *palette_split;
VSplitContainer *bottom_split;
@@ -335,7 +340,7 @@ protected:
public:
bool is_snap_active() const;
- int get_snap() const { return snap; }
+ Size2i get_snap() const { return Size2i(snap_x->get_val(),snap_y->get_val()); }
Matrix32 get_canvas_transform() const { return transform; }
diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index dab6df9a39..9a0d5b4066 100644
--- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -369,6 +369,7 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) {
wip.clear();
wip_active=false;
edited_point=-1;
+ canvas_item_editor->get_viewport_control()->update();
} else {
node=NULL;
diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
index c1fb81b66a..5fa3d8ac8f 100644
--- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -96,7 +96,7 @@ bool LightOccluder2DEditor::forward_input_event(const InputEvent& p_event) {
create_poly->set_text("No OccluderPolygon2D resource on this node.\nCreate and assign one?");
create_poly->popup_centered_minsize();
}
- return false;
+ return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);
}
switch(p_event.type) {
@@ -389,7 +389,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
wip.clear();
wip_active=false;
edited_point=-1;
-
+ canvas_item_editor->get_viewport_control()->update();
} else {
node=NULL;
@@ -402,6 +402,8 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
void LightOccluder2DEditor::_create_poly() {
+ if (!node)
+ return;
undo_redo->create_action("Create Occluder Polygon");
undo_redo->add_do_method(node,"set_occluder_polygon",Ref<OccluderPolygon2D>(memnew( OccluderPolygon2D)));
undo_redo->add_undo_method(node,"set_occluder_polygon",Variant(REF()));
diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
index 599d18c8bb..163accfdd3 100644
--- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -36,6 +36,9 @@ void NavigationPolygonEditor::_node_removed(Node *p_node) {
void NavigationPolygonEditor::_create_nav() {
+ if (!node)
+ return;
+
undo_redo->create_action("Create Navigation Polygon");
undo_redo->add_do_method(node,"set_navigation_polygon",Ref<NavigationPolygon>(memnew( NavigationPolygon)));
undo_redo->add_undo_method(node,"set_navigation_polygon",Variant(REF()));
@@ -107,7 +110,7 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) {
create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?");
create_nav->popup_centered_minsize();
}
- return false;
+ return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);;
}
@@ -445,6 +448,7 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) {
wip.clear();
wip_active=false;
edited_point=-1;
+ canvas_item_editor->get_viewport_control()->update();
} else {
node=NULL;
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 1349d5ccab..bb9b36bb66 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -920,7 +920,7 @@ void ScriptEditor::_menu_option(int p_option) {
String line_text = tx->get_line(i);
if (line_text.begins_with("#"))
- line_text = line_text.strip_edges().substr(1, line_text.length());
+ line_text = line_text.substr(1, line_text.length());
else
line_text = "#" + line_text;
tx->set_line(i, line_text);
@@ -932,7 +932,7 @@ void ScriptEditor::_menu_option(int p_option) {
String line_text = tx->get_line(begin);
if (line_text.begins_with("#"))
- line_text = line_text.strip_edges().substr(1, line_text.length());
+ line_text = line_text.substr(1, line_text.length());
else
line_text = "#" + line_text;
tx->set_line(begin, line_text);
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 87bd8105af..8f14c567c3 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -477,6 +477,16 @@ void SpatialEditorViewport::_select_region() {
}
+void SpatialEditorViewport::_update_name() {
+
+ String ortho = orthogonal?"Orthogonal":"Perspective";
+
+ if (name!="")
+ view_menu->set_text("[ "+name+" "+ortho+" ]");
+ else
+ view_menu->set_text("[ "+ortho+" ]");
+}
+
void SpatialEditorViewport::_compute_edit(const Point2& p_point) {
@@ -832,6 +842,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
_edit.plane=TRANSFORM_X_AXIS;
set_message("View Plane Transform.",2);
+ name="";
+ _update_name();
} break;
case TRANSFORM_X_AXIS: {
@@ -1460,6 +1472,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
cursor.x_rot=Math_PI/2.0;
if (cursor.x_rot<-Math_PI/2.0)
cursor.x_rot=-Math_PI/2.0;
+ name="";
+ _update_name();
} break;
default: {}
@@ -1484,9 +1498,14 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (k.mod.shift) {
cursor.x_rot=-Math_PI/2.0;
set_message("Bottom View.",2);
+ name="Bottom";
+ _update_name();
+
} else {
cursor.x_rot=Math_PI/2.0;
set_message("Top View.",2);
+ name="Top";
+ _update_name();
}
} break;
case KEY_KP_1: {
@@ -1495,10 +1514,14 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (k.mod.shift) {
cursor.y_rot=Math_PI;
set_message("Rear View.",2);
+ name="Rear";
+ _update_name();
} else {
cursor.y_rot=0;
set_message("Front View.",2);
+ name="Front";
+ _update_name();
}
} break;
@@ -1508,9 +1531,13 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (k.mod.shift) {
cursor.y_rot=Math_PI/2.0;
set_message("Left View.",2);
+ name="Left";
+ _update_name();
} else {
cursor.y_rot=-Math_PI/2.0;
set_message("Right View.",2);
+ name="Right";
+ _update_name();
}
} break;
@@ -1518,6 +1545,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
orthogonal = !orthogonal;
_menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
+ _update_name();
} break;
@@ -1831,35 +1859,47 @@ void SpatialEditorViewport::_menu_option(int p_option) {
cursor.x_rot=Math_PI/2.0;
cursor.y_rot=0;
+ name="Top";
+ _update_name();
} break;
case VIEW_BOTTOM: {
cursor.x_rot=-Math_PI/2.0;
cursor.y_rot=0;
+ name="Bottom";
+ _update_name();
} break;
case VIEW_LEFT: {
cursor.y_rot=Math_PI/2.0;
cursor.x_rot=0;
+ name="Left";
+ _update_name();
} break;
case VIEW_RIGHT: {
cursor.y_rot=-Math_PI/2.0;
cursor.x_rot=0;
+ name="Right";
+ _update_name();
} break;
case VIEW_FRONT: {
cursor.y_rot=0;
cursor.x_rot=0;
+ name="Front";
+ _update_name();
} break;
case VIEW_REAR: {
cursor.y_rot=Math_PI;
cursor.x_rot=0;
+ name="Rear";
+ _update_name();
} break;
case VIEW_CENTER_TO_SELECTION: {
@@ -1941,6 +1981,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false );
orthogonal=false;
call_deferred("update_transform_gizmo_view");
+ _update_name();
} break;
case VIEW_ORTHOGONAL: {
@@ -1949,6 +1990,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true );
orthogonal=true;
call_deferred("update_transform_gizmo_view");
+ _update_name();
} break;
case VIEW_AUDIO_LISTENER: {
@@ -2147,15 +2189,13 @@ void SpatialEditorViewport::reset() {
message_time=0;
message="";
last_message="";
+ name="Top";
cursor.x_rot=0;
cursor.y_rot=0;
cursor.distance=4;
cursor.region_select=false;
-
-
-
-
+ _update_name();
}
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
@@ -2189,18 +2229,17 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu = memnew( MenuButton );
surface->add_child(view_menu);
view_menu->set_pos( Point2(4,4));
- view_menu->set_text("[view]");
view_menu->set_self_opacity(0.5);
- view_menu->get_popup()->add_item("Top",VIEW_TOP);
- view_menu->get_popup()->add_item("Bottom",VIEW_BOTTOM);
- view_menu->get_popup()->add_item("Left",VIEW_LEFT);
- view_menu->get_popup()->add_item("Right",VIEW_RIGHT);
- view_menu->get_popup()->add_item("Front",VIEW_FRONT);
- view_menu->get_popup()->add_item("Rear",VIEW_REAR);
+ view_menu->get_popup()->add_item("Top (Num7)",VIEW_TOP);
+ view_menu->get_popup()->add_item("Bottom (Shift+Num7)",VIEW_BOTTOM);
+ view_menu->get_popup()->add_item("Left (Num3)",VIEW_LEFT);
+ view_menu->get_popup()->add_item("Right (Shift+Num3)",VIEW_RIGHT);
+ view_menu->get_popup()->add_item("Front (Num1)",VIEW_FRONT);
+ view_menu->get_popup()->add_item("Rear (Shift+Num1)",VIEW_REAR);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item("Perspective",VIEW_PERSPECTIVE);
- view_menu->get_popup()->add_check_item("Orthogonal",VIEW_ORTHOGONAL);
+ view_menu->get_popup()->add_check_item("Perspective (Num5)",VIEW_PERSPECTIVE);
+ view_menu->get_popup()->add_check_item("Orthogonal (Num5)",VIEW_ORTHOGONAL);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_item("Environment",VIEW_ENVIRONMENT);
@@ -2233,6 +2272,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
viewport->set_as_audio_listener(true);
}
+
+ name="Top";
+ _update_name();
+
EditorSettings::get_singleton()->connect("settings_changed",this,"update_transform_gizmo_view");
}
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index 646a4d2d86..4d594d1921 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -92,6 +92,7 @@ public:
};
private:
int index;
+ String name;
void _menu_option(int p_option);
Size2 prev_size;
@@ -110,6 +111,7 @@ private:
bool orthogonal;
float gizmo_scale;
+ void _update_name();
void _compute_edit(const Point2& p_point);
void _clear_selected();
void _select_clicked(bool p_append,bool p_single);
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 47727a00c2..79e43f9012 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -640,19 +640,53 @@ void TileMapEditor::_canvas_draw() {
Ref<Texture> t = ts->tile_get_texture(st);
if (t.is_valid()) {
- Vector2 from = xform.xform(ts->tile_get_texture_offset(st)+node->map_to_world(over_tile)+node->get_cell_draw_offset());
+ Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
Rect2 r = ts->tile_get_region(st);
Size2 sc = xform.get_scale();
if (mirror_x->is_pressed())
sc.x*=-1.0;
if (mirror_y->is_pressed())
sc.y*=-1.0;
+
+ Rect2 rect;
+ if (r==Rect2()) {
+ rect=Rect2(from,t->get_size());
+ } else {
+
+ rect=Rect2(from,r.get_size());
+ }
+
+
+ if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
+ rect.pos+=ts->tile_get_texture_offset(st);
+
+ } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
+ rect.pos+=node->get_cell_size()/2;
+ Vector2 s = r.size;
+
+ Vector2 center = (s/2) - ts->tile_get_texture_offset(st);
+
+
+ if (mirror_x->is_pressed())
+ rect.pos.x-=s.x-center.x;
+ else
+ rect.pos.x-=center.x;
+
+ if (mirror_y->is_pressed())
+ rect.pos.y-=s.y-center.y;
+ else
+ rect.pos.y-=center.y;
+ }
+
+ rect.pos=xform.xform(rect.pos);
+ rect.size*=sc;
+
if (r==Rect2()) {
- canvas_item_editor->draw_texture_rect(t,Rect2(from,t->get_size()*sc),false,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transpose->is_pressed());
} else {
- canvas_item_editor->draw_texture_rect_region(t,Rect2(from,r.get_size()*sc),r,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transpose->is_pressed());
}
}
}
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index a51caf7d54..8ff7720934 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -37,83 +37,103 @@ void TileSetEditor::edit(const Ref<TileSet>& p_tileset) {
void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_merge) {
if (!p_merge)
- p_library->clear();
+ p_library->clear();
for(int i=0;i<scene->get_child_count();i++) {
- Node *child = scene->get_child(i);
+ Node *child = scene->get_child(i);
- if (!child->cast_to<Sprite>()) {
- if (child->get_child_count()>0) {
- child=child->get_child(0);
- if (!child->cast_to<Sprite>()) {
- continue;
- }
+ if (!child->cast_to<Sprite>()) {
+ if (child->get_child_count()>0) {
+ child=child->get_child(0);
+ if (!child->cast_to<Sprite>()) {
+ continue;
+ }
- } else
- continue;
+ } else
+ continue;
- }
+ }
- Sprite *mi = child->cast_to<Sprite>();
- Ref<Texture> texture=mi->get_texture();
- if (texture.is_null())
+ Sprite *mi = child->cast_to<Sprite>();
+ Ref<Texture> texture=mi->get_texture();
+ Ref<CanvasItemMaterial> material=mi->get_material();
+
+ if (texture.is_null())
continue;
- int id = p_library->find_tile_by_name(mi->get_name());
- if (id<0) {
-
- id=p_library->get_last_unused_tile_id();
- p_library->create_tile(id);
- p_library->tile_set_name(id,mi->get_name());
- }
-
-
- p_library->tile_set_texture(id,texture);
- Vector2 phys_offset;
-
- if (mi->is_centered()) {
- Size2 s;
- if (mi->is_region()) {
- s=mi->get_region_rect().size;
- } else {
- s=texture->get_size();
- }
- phys_offset+=-s/2;
- }
- if (mi->is_region()) {
- p_library->tile_set_region(id,mi->get_region_rect());
- }
-
- Vector<Ref<Shape2D> >collisions;
-
- for(int j=0;j<mi->get_child_count();j++) {
-
- Node *child2 = mi->get_child(j);
- if (!child2->cast_to<StaticBody2D>())
- continue;
- StaticBody2D *sb = child2->cast_to<StaticBody2D>();
- if (sb->get_shape_count()==0)
- continue;
- Ref<Shape2D> collision=sb->get_shape(0);
- if (collision.is_valid()) {
- collisions.push_back(collision);
+ int id = p_library->find_tile_by_name(mi->get_name());
+ if (id<0) {
+
+ id=p_library->get_last_unused_tile_id();
+ p_library->create_tile(id);
+ p_library->tile_set_name(id,mi->get_name());
+ }
+
+
+
+ p_library->tile_set_texture(id,texture);
+ p_library->tile_set_material(id,material);
+
+ Vector2 phys_offset;
+
+ if (mi->is_centered()) {
+ Size2 s;
+ if (mi->is_region()) {
+ s=mi->get_region_rect().size;
+ } else {
+ s=texture->get_size();
+ }
+ phys_offset+=-s/2;
+ }
+ if (mi->is_region()) {
+ p_library->tile_set_region(id,mi->get_region_rect());
+ }
+
+ Vector<Ref<Shape2D> >collisions;
+ Ref<NavigationPolygon> nav_poly;
+ Ref<OccluderPolygon2D> occluder;
+
+ for(int j=0;j<mi->get_child_count();j++) {
+
+ Node *child2 = mi->get_child(j);
+
+ if (child2->cast_to<NavigationPolygonInstance>())
+ nav_poly=child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon();
+
+ if (child2->cast_to<LightOccluder2D>())
+ occluder=child2->cast_to<LightOccluder2D>()->get_occluder_polygon();
+
+ if (!child2->cast_to<StaticBody2D>())
+ continue;
+ StaticBody2D *sb = child2->cast_to<StaticBody2D>();
+ if (sb->get_shape_count()==0)
+ continue;
+ Ref<Shape2D> collision=sb->get_shape(0);
+ if (collision.is_valid()) {
+ collisions.push_back(collision);
}
- }
+ }
- if (collisions.size()) {
+ if (collisions.size()) {
- p_library->tile_set_shapes(id,collisions);
- p_library->tile_set_shape_offset(id,-phys_offset);
- } else {
- p_library->tile_set_shape_offset(id,Vector2());
+ p_library->tile_set_shapes(id,collisions);
+ p_library->tile_set_shape_offset(id,-phys_offset);
+ } else {
+ p_library->tile_set_shape_offset(id,Vector2());
+
+ }
+
+ p_library->tile_set_texture_offset(id,mi->get_offset());
+ p_library->tile_set_navigation_polygon(id,nav_poly);
+ p_library->tile_set_light_occluder(id,occluder);
+ p_library->tile_set_occluder_offset(id,-phys_offset);
+ p_library->tile_set_navigation_polygon_offset(id,-phys_offset);
- }
- p_library->tile_set_texture_offset(id,mi->get_offset());
}
}
@@ -121,23 +141,23 @@ void TileSetEditor::_menu_confirm() {
switch(option) {
- case MENU_OPTION_REMOVE_ITEM: {
+ case MENU_OPTION_REMOVE_ITEM: {
- tileset->remove_tile(to_erase);
- } break;
- case MENU_OPTION_MERGE_FROM_SCENE:
- case MENU_OPTION_CREATE_FROM_SCENE: {
+ tileset->remove_tile(to_erase);
+ } break;
+ case MENU_OPTION_MERGE_FROM_SCENE:
+ case MENU_OPTION_CREATE_FROM_SCENE: {
- EditorNode *en = editor;
- Node * scene = en->get_edited_scene();
- if (!scene)
- break;
+ EditorNode *en = editor;
+ Node * scene = en->get_edited_scene();
+ if (!scene)
+ break;
- _import_scene(scene,tileset,option==MENU_OPTION_MERGE_FROM_SCENE);
+ _import_scene(scene,tileset,option==MENU_OPTION_MERGE_FROM_SCENE);
- } break;
+ } break;
}
}
@@ -165,11 +185,11 @@ void TileSetEditor::_menu_cbk(int p_option) {
cd->set_text("Create from scene?");
cd->popup_centered(Size2(300,60));
} break;
- case MENU_OPTION_MERGE_FROM_SCENE: {
+ case MENU_OPTION_MERGE_FROM_SCENE: {
- cd->set_text("Merge from scene?");
- cd->popup_centered(Size2(300,60));
- } break;
+ cd->set_text("Merge from scene?");
+ cd->popup_centered(Size2(300,60));
+ } break;
}
}
diff --git a/tools/editor/plugins/tile_set_editor_plugin.h b/tools/editor/plugins/tile_set_editor_plugin.h
index 2531ec55bf..1248b4e007 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.h
+++ b/tools/editor/plugins/tile_set_editor_plugin.h
@@ -56,7 +56,7 @@ class TileSetEditor : public Control {
int option;
void _menu_cbk(int p_option);
- void _menu_confirm();
+ void _menu_confirm();
static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge);
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 25c39b3173..078a177ca1 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -651,6 +651,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
if (!RES(v).is_null()) {
+
+
menu->add_icon_item(get_icon("EditResource","EditorIcons"),"Edit",OBJ_MENU_EDIT);
menu->add_icon_item(get_icon("Del","EditorIcons"),"Clear",OBJ_MENU_CLEAR);
menu->add_icon_item(get_icon("Duplicate","EditorIcons"),"Make Unique",OBJ_MENU_MAKE_UNIQUE);
@@ -659,6 +661,13 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->add_separator();
menu->add_icon_item(get_icon("Reload","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
}
+ /*if (r.is_valid() && r->get_path().is_resource_file()) {
+ menu->set_item_tooltip(1,r->get_path());
+ } else if (r.is_valid()) {
+ menu->set_item_tooltip(1,r->get_name()+" ("+r->get_type()+")");
+ }*/
+ } else {
+
}
@@ -1858,9 +1867,17 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
p_item->set_text(1,"<"+res->get_type()+">");
};
+
+ if (res.is_valid() && res->get_path().is_resource_file()) {
+ p_item->set_tooltip(1,res->get_path());
+ } else if (res.is_valid()) {
+ p_item->set_tooltip(1,res->get_name()+" ("+res->get_type()+")");
+ }
+
+
if (has_icon(res->get_type(),"EditorIcons")) {
- p_item->set_icon(1,get_icon(res->get_type(),"EditorIcons"));
+ p_item->set_icon(0,get_icon(res->get_type(),"EditorIcons"));
} else {
Dictionary d = p_item->get_metadata(0);
@@ -1870,10 +1887,10 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
if (has_icon(hint_text,"EditorIcons")) {
- p_item->set_icon(1,get_icon(hint_text,"EditorIcons"));
+ p_item->set_icon(0,get_icon(hint_text,"EditorIcons"));
} else {
- p_item->set_icon(1,get_icon("Object","EditorIcons"));
+ p_item->set_icon(0,get_icon("Object","EditorIcons"));
}
}
@@ -2362,7 +2379,7 @@ void PropertyEditor::update_tree() {
} else {
if (p.type == Variant::REAL) {
- item->set_range_config(1, -65536, 65535, 0.01);
+ item->set_range_config(1, -65536, 65535, 0.001);
} else {
item->set_range_config(1, -65536, 65535, 1);
@@ -2584,6 +2601,13 @@ void PropertyEditor::update_tree() {
if (has_icon(res->get_type(),"EditorIcons")) {
type=res->get_type();
}
+
+ if (res.is_valid() && res->get_path().is_resource_file()) {
+ item->set_tooltip(1,res->get_path());
+ } else if (res.is_valid()) {
+ item->set_tooltip(1,res->get_name()+" ("+res->get_type()+")");
+ }
+
}