summaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp11
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp58
-rw-r--r--tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp12
-rw-r--r--tools/editor/plugins/light_occluder_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/navigation_polygon_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/particles_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/sample_editor_plugin.cpp15
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp112
-rw-r--r--tools/editor/plugins/script_editor_plugin.h6
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp11
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp7
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp349
-rw-r--r--tools/editor/plugins/sprite_frames_editor_plugin.cpp63
-rw-r--r--tools/editor/plugins/texture_region_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp20
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp22
21 files changed, 378 insertions, 329 deletions
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 10c7bf79a3..98ba25b482 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -407,7 +407,6 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource>& p_resource) {
void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool());
List<String> extensions;
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
@@ -1404,6 +1403,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
hb->add_child(animation);
animation->set_h_size_flags(SIZE_EXPAND_FILL);
animation->set_tooltip(TTR("Display list of animations in player."));
+ animation->set_clip_text(true);
autoplay = memnew( ToolButton );
hb->add_child(autoplay);
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index a381ec4678..24914e4bc5 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -90,7 +90,6 @@ Size2 AnimationTreeEditor::get_node_size(const StringName& p_node) const {
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
Ref<Font> font = get_font("font","PopupMenu");
- Color font_color = get_color("font_color","PopupMenu");
Size2 size = style->get_minimum_size();
@@ -633,7 +632,6 @@ AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2&
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
Ref<Font> font = get_font("font","PopupMenu");
- Color font_color = get_color("font_color","PopupMenu");
float h = (font->get_height()+get_constant("vseparation","PopupMenu"));
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index 1962f81e87..6a88ba4cbe 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -645,7 +645,6 @@ void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_de
leaf_list=child_idx;
cell_count++;
- int lz = lights.size();
for(int ci=0;ci<8;ci++) {
child->light_accum[ci][0]=0;
child->light_accum[ci][1]=0;
@@ -1016,8 +1015,6 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
//ray_aabb.expand_to(p_end);
- const BVH *bvhptr = bvh;
-
bstack[0]=bvh;
stack[0]=TEST_AABB_BIT;
@@ -1693,7 +1690,7 @@ void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) {
Vector3 from = dl.pos;
double r1 = double(rand())/RAND_MAX;
- double r2 = double(rand())/RAND_MAX;
+ //double r2 = double(rand())/RAND_MAX;
double r3 = double(rand())/RAND_MAX;
float d=Math::tan(Math::deg2rad(dl.spot_angle));
@@ -1994,7 +1991,6 @@ void BakedLightBaker::update_octree_images(DVector<uint8_t> &p_octree,DVector<ui
const double *normptr=norm_arr.ptr();
*/
double norm = 1.0/double(total_rays);
- int lz=lights.size();
mult/=multiplier;
double saturation = baked_light->get_saturation();
@@ -2261,8 +2257,6 @@ void BakedLightBaker::_plot_pixel_to_lightmap(int x, int y, int width, int heigh
continue;
n/=len;
- const BVH *bvhptr = bvh;
-
bstack[0]=bvh;
stack[0]=TEST_RAY_BIT;
@@ -2404,8 +2398,6 @@ Error BakedLightBaker::transfer_to_lightmaps() {
float gamma = baked_light->get_gamma_adjust();
float mult = baked_light->get_energy_multiplier();
-
- const double *normptr=norm_arr.ptr();
for(int i=0;i<triangles.size();i++) {
if (i%200==0) {
@@ -2538,7 +2530,6 @@ Error BakedLightBaker::transfer_to_lightmaps() {
Vector<uint8_t> copy_data=bt.data;
uint8_t *data=bt.data.ptr();
- uint8_t *src_data=copy_data.ptr();
const int max_radius=8;
const int shadow_radius=2;
const int max_dist=0x7FFFFFFF;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 81601a81a7..f9499904db 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1940,8 +1940,6 @@ void CanvasItemEditor::_viewport_draw() {
Map<Node*,Object*> &selection = editor_selection->get_selection();
- CanvasItem *single_item=NULL;
-
bool pivot_found=false;
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
@@ -1961,15 +1959,6 @@ void CanvasItemEditor::_viewport_draw() {
Matrix32 xform=transform * canvas_item->get_global_transform_with_canvas();
VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform);
- Point2 ofs=Point2();//get_global_pos();
- Rect2 draw_rect=rect;
- Color light_edit_color=Color(1.0,0.8,0.8);
- Color dark_edit_color=Color(0.4,0.1,0.1);
- Size2 handle_size=Size2(handle_len,handle_len);
-
- //select_sb->draw(ci,draw_rect.grow(2));
- //DRAW_EMPTY_RECT( draw_rect.grow(2), light_edit_color );
- //DRAW_EMPTY_RECT( draw_rect.grow(1), dark_edit_color );
Vector2 endpoints[4]={
@@ -3374,25 +3363,25 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p;
p = edit_menu->get_popup();
- p->add_check_item(TTR("Use Snap"),SNAP_USE);
- p->add_check_item(TTR("Show Grid"),SNAP_SHOW_GRID);
- p->add_check_item(TTR("Use Rotation Snap"),SNAP_USE_ROTATION);
- p->add_check_item(TTR("Snap Relative"),SNAP_RELATIVE);
- p->add_item(TTR("Configure Snap.."),SNAP_CONFIGURE);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap")), SNAP_USE);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid")), SNAP_SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_relative", TTR("Snap Relative")), SNAP_RELATIVE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/configure_snap", TTR("Configure Snap..")), SNAP_CONFIGURE);
p->add_separator();
- p->add_check_item(TTR("Use Pixel Snap"),SNAP_USE_PIXEL);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL);
p->add_separator();
- p->add_item(TTR("Expand to Parent"),EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT);
p->add_separator();
p->add_submenu_item(TTR("Skeleton.."),"skeleton");
PopupMenu *p2 = memnew(PopupMenu);
p->add_child(p2);
p2->set_name("skeleton");
- p2->add_item(TTR("Make Bones"),SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B);
- p2->add_item(TTR("Clear Bones"),SKELETON_CLEAR_BONES);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES);
p2->add_separator();
- p2->add_item(TTR("Make IK Chain"),SKELETON_SET_IK_CHAIN);
- p2->add_item(TTR("Clear IK Chain"),SKELETON_CLEAR_IK_CHAIN);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN);
p2->connect("item_pressed", this,"_popup_callback");
@@ -3409,13 +3398,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
- p->add_item(TTR("Zoom In"),ZOOM_IN);
- p->add_item(TTR("Zoom Out"),ZOOM_OUT);
- p->add_item(TTR("Zoom Reset"),ZOOM_RESET);
- p->add_item(TTR("Zoom Set.."),ZOOM_SET);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_in", TTR("Zoom In")), ZOOM_IN);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_out", TTR("Zoom Out")), ZOOM_OUT);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset")), ZOOM_RESET);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_set", TTR("Zoom Set..")), ZOOM_SET);
p->add_separator();
- p->add_item(TTR("Center Selection"), VIEW_CENTER_TO_SELECTION, KEY_F);
- p->add_item(TTR("Frame Selection"), VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION);
anchor_menu = memnew( MenuButton );
anchor_menu->set_text(TTR("Anchor"));
@@ -3458,7 +3447,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_insert_button = memnew( Button );
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_KEY));
- key_insert_button->set_tooltip(TTR("Insert Keys (Ins)"));
+ key_insert_button->set_tooltip(TTR("Insert Keys"));
+ key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
animation_hb->add_child(key_insert_button);
@@ -3469,12 +3459,12 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = animation_menu->get_popup();
- p->add_item(TTR("Insert Key"),ANIM_INSERT_KEY,KEY_INSERT);
- p->add_item(TTR("Insert Key (Existing Tracks)"),ANIM_INSERT_KEY_EXISTING,KEY_MASK_CMD+KEY_INSERT);
+ p->add_shortcut(ED_GET_SHORTCUT("canvas_item_editor/anim_insert_key"), ANIM_INSERT_KEY);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key_existing_tracks", TTR("Insert Key (Existing Tracks)"), KEY_MASK_CMD+KEY_INSERT), ANIM_INSERT_KEY_EXISTING);
p->add_separator();
- p->add_item(TTR("Copy Pose"),ANIM_COPY_POSE);
- p->add_item(TTR("Paste Pose"),ANIM_PASTE_POSE);
- p->add_item(TTR("Clear Pose"),ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_copy_pose", TTR("Copy Pose")), ANIM_COPY_POSE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_paste_pose", TTR("Paste Pose")), ANIM_PASTE_POSE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_clear_pose", TTR("Clear Pose"), KEY_MASK_SHIFT | KEY_K), ANIM_CLEAR_POSE);
snap_dialog = memnew( SnapDialog );
snap_dialog->connect("confirmed",this,"_snap_changed");
diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 5ed9f8ab5f..95364e8921 100644
--- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -349,8 +349,6 @@ void CollisionPolygon2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
index b18afe7838..0b06b3ba21 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -381,8 +381,6 @@ void CollisionPolygonEditor::_polygon_draw() {
poly=node->get_polygon();
-
- int len = poly.size();
float depth = node->get_depth()*0.5;
imgeom->clear();
@@ -586,7 +584,7 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1));
handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false);
- Ref<Texture> handle= SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons");
+ Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons");
handle_material->set_point_size(handle->get_width());
handle_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle);
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index a057e6c2a1..b1bce60484 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -36,6 +36,7 @@
#include "scene/resources/mesh.h"
#include "scene/resources/bit_mask.h"
#include "tools/editor/editor_scale.h"
+
bool EditorTexturePreviewPlugin::handles(const String& p_type) const {
return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture"));
@@ -442,7 +443,6 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES& p_from) {
Color keyword_color = EditorSettings::get_singleton()->get("text_editor/keyword_color");
Color text_color = EditorSettings::get_singleton()->get("text_editor/text_color");
Color symbol_color = EditorSettings::get_singleton()->get("text_editor/symbol_color");
- Color comment_color = EditorSettings::get_singleton()->get("text_editor/comment_color");
for(int i=0;i<thumbnail_size;i++) {
@@ -607,7 +607,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
-1, -1, -1, -1, 2, 4, 6, 8
};
- int16_t nibble,signed_nibble,diff,step;
+ int16_t nibble,diff,step;
ima_adpcm.last_nibble++;
const uint8_t *src_ptr=sdata;
@@ -628,10 +628,6 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
if (ima_adpcm.step_index>88)
ima_adpcm.step_index=88;
- /*
- signed_nibble = (nibble&7) * ((nibble&8)?-1:1);
- diff = (2 * signed_nibble + 1) * step / 4; */
-
diff = step >> 3 ;
if (nibble & 1)
diff += step >> 2 ;
@@ -748,15 +744,13 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
for(int j=0;j<h;j++) {
- int half,ofs;
+ int half;
float v;
if (j<(h/2)) {
half=0;
- ofs=0;
v = (j/(float)(h/2)) * 2.0 - 1.0;
} else {
half=1;
- ofs=h/2;
if( (float)(h/2) != 0 ) {
v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
} else {
diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 14e7b14fc3..56e58bc983 100644
--- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -364,8 +364,6 @@ void LightOccluder2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
index 5a8cd8791e..22546c72f3 100644
--- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -427,8 +427,6 @@ void NavigationPolygonEditor::_canvas_draw() {
poly = Variant(node->get_navigation_polygon()->get_outline(j));
}
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp
index 93e2fb2f38..7e20cc3f54 100644
--- a/tools/editor/plugins/particles_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_editor_plugin.cpp
@@ -283,7 +283,6 @@ void ParticlesEditor::_generate_emission_points() {
ofs=(Vector3(1,1,1)-dir)*Vector3(Math::randf(),Math::randf(),Math::randf())*aabb.size;
ofs+=aabb.pos;
- Vector3 dirv = -dir;
Vector3 ofsv = ofs + aabb.size * dir;
//space it a little
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
index d78508c429..19d1ccc06f 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -466,8 +466,6 @@ void Polygon2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp
index b094184a29..7965fa54ae 100644
--- a/tools/editor/plugins/sample_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_editor_plugin.cpp
@@ -151,7 +151,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
-1, -1, -1, -1, 2, 4, 6, 8
};
- int16_t nibble,signed_nibble,diff,step;
+ int16_t nibble,diff,step;
ima_adpcm.last_nibble++;
const uint8_t *src_ptr=sdata;
@@ -172,10 +172,6 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
if (ima_adpcm.step_index>88)
ima_adpcm.step_index=88;
- /*
- signed_nibble = (nibble&7) * ((nibble&8)?-1:1);
- diff = (2 * signed_nibble + 1) * step / 4; */
-
diff = step >> 3 ;
if (nibble & 1)
diff += step >> 2 ;
@@ -285,15 +281,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
for(int j=0;j<h;j++) {
- int half,ofs;
+ int half;
float v;
if (j<(h/2)) {
half=0;
- ofs=0;
v = (j/(float)(h/2)) * 2.0 - 1.0;
} else {
half=1;
- ofs=h/2;
v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
}
@@ -324,12 +318,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
void SampleEditor::_update_sample() {
player->stop_all();
- if (sample->get_format()==Sample::FORMAT_IMA_ADPCM)
- return; //bye or unsupported
generate_preview_texture(sample,peakdisplay);
info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s");
+ if (library->has_sample("default"))
+ library->remove_sample("default");
+
library->add_sample("default",sample);
}
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 10e4fc8475..fc5f552723 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -43,6 +43,28 @@
/*** SCRIPT EDITOR ****/
+static bool _can_open_in_editor(Script* p_script) {
+
+ String path = p_script->get_path();
+
+ if (path.find("::")!=-1) {
+ //refuse handling this if it can't be edited
+
+ bool valid=false;
+ for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_edited_scene_count();i++) {
+ if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) {
+ valid=true;
+ break;
+ }
+ }
+
+ return valid;
+ }
+
+ return true;
+}
+
+
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
@@ -290,6 +312,8 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
+ get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff")));
+ get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa")));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
@@ -585,7 +609,6 @@ void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>*
Error err = script->get_language()->complete_code(p_code,script->get_path().get_base_dir(),base,r_options,hint);
if (hint!="") {
get_text_edit()->set_code_hint(hint);
- print_line("hint: "+hint.replace(String::chr(0xFFFF),"|"));
}
}
@@ -748,9 +771,9 @@ void ScriptEditor::_go_to_tab(int p_idx) {
_update_script_colors();
}
-void ScriptEditor::_close_current_tab() {
+void ScriptEditor::_close_tab(int p_idx) {
- int selected = tab_container->get_current_tab();
+ int selected = p_idx;
if (selected<0 || selected>=tab_container->get_child_count())
return;
@@ -796,6 +819,11 @@ void ScriptEditor::_close_current_tab() {
_update_script_names();
EditorNode::get_singleton()->save_layout();
+}
+
+void ScriptEditor::_close_current_tab() {
+
+ _close_tab(tab_container->get_current_tab());
}
@@ -848,6 +876,15 @@ void ScriptEditor::_reload_scripts(){
}
+ uint64_t last_date = script->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(script->get_path());
+
+ //printf("last date: %lli vs date: %lli\n",last_date,date);
+ if (last_date==date) {
+ continue;
+ }
+
+
Ref<Script> rel_script = ResourceLoader::load(script->get_path(),script->get_type(),true);
ERR_CONTINUE(!rel_script.is_valid());
script->set_source_code( rel_script->get_source_code() );
@@ -1682,6 +1719,33 @@ void ScriptEditor::_notification(int p_what) {
}
+
+void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) {
+
+
+
+ for(int i=0;i<tab_container->get_child_count();i++) {
+
+ ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+
+ if (ste) {
+
+ Ref<Script> script = ste->get_edited_script();
+ if (!script.is_valid())
+ continue;
+
+ if (script->get_path().find("::")!=-1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ _close_tab(i);
+ i--;
+
+ }
+ }
+
+ }
+
+
+}
+
void ScriptEditor::edited_scene_changed() {
_update_modified_scripts_for_external_editor();
@@ -2060,11 +2124,18 @@ void ScriptEditor::_update_script_names() {
}
+
+
void ScriptEditor::edit(const Ref<Script>& p_script) {
if (p_script.is_null())
return;
+ // refuse to open built-in if scene is not loaded
+
+
+
+
// see if already has it
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change");
@@ -2316,6 +2387,22 @@ void ScriptEditor::_script_split_dragged(float) {
EditorNode::get_singleton()->save_layout();
}
+void ScriptEditor::_unhandled_input(const InputEvent& p_event) {
+ if (p_event.key.pressed || !is_visible()) return;
+ if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
+ int next_tab = script_list->get_current() + 1;
+ next_tab %= script_list->get_item_count();
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
+ if (ED_IS_SHORTCUT("script_editor/prev_script", p_event)) {
+ int next_tab = script_list->get_current() - 1;
+ next_tab = next_tab >= 0 ? next_tab : script_list->get_item_count() - 1;
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
+}
+
void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
if (!bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
@@ -2335,6 +2422,8 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
for(int i=0;i<scripts.size();i++) {
String path = scripts[i];
+ if (!FileAccess::exists(path))
+ continue;
Ref<Script> scr = ResourceLoader::load(path);
if (scr.is_valid()) {
edit(scr);
@@ -2512,7 +2601,7 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) {
if (bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor")))
return;
- if (open_dominant && p_script.is_valid()) {
+ if (open_dominant && p_script.is_valid() && _can_open_in_editor(p_script.ptr())) {
edit(p_script);
}
}
@@ -2598,6 +2687,7 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward);
ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back);
ObjectTypeDB::bind_method("_live_auto_reload_running_scripts",&ScriptEditor::_live_auto_reload_running_scripts);
+ ObjectTypeDB::bind_method("_unhandled_input",&ScriptEditor::_unhandled_input);
}
@@ -2631,6 +2721,10 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
+ ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_GREATER);
+ ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_LESS);
+ set_process_unhandled_input(true);
+
file_menu = memnew( MenuButton );
menu_hb->add_child(file_menu);
file_menu->set_text(TTR("File"));
@@ -2895,6 +2989,16 @@ void ScriptEditorPlugin::edit(Object *p_object) {
bool ScriptEditorPlugin::handles(Object *p_object) const {
+ if (p_object->cast_to<Script>()) {
+
+ bool valid = _can_open_in_editor(p_object->cast_to<Script>());
+
+ if (!valid) { //user tried to open it by clicking
+ EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded"));
+ }
+ return valid;
+ }
+
return p_object->is_type("Script");
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 0636190a41..2e6e2c035c 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -234,6 +234,8 @@ class ScriptEditor : public VBoxContainer {
bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>());
+ void _close_tab(int p_idx);
+
void _close_current_tab();
bool grab_focus_block;
@@ -279,6 +281,8 @@ class ScriptEditor : public VBoxContainer {
void _script_split_dragged(float);
+ void _unhandled_input(const InputEvent& p_event);
+
void _history_forward();
void _history_back();
@@ -329,6 +333,8 @@ public:
virtual void edited_scene_changed();
+ void close_builtin_scripts_from_scene(const String& p_scene);
+
ScriptEditorDebugger *get_debugger() { return debugger; }
void set_live_auto_reload_running_scripts(bool p_enabled);
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 76042c3028..9ef84af260 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -81,6 +81,8 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
+ get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff")));
+ get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa")));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
@@ -118,9 +120,10 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_region("/*","*/",comment_color,false);
get_text_edit()->add_color_region("//","",comment_color,false);
- //colorize strings
+
+ /*//colorize strings
Color string_color = EDITOR_DEF("text_editor/string_color",Color::hex(0x6b6f00ff));
- /*
+
List<String> strings;
shader->get_shader_mode()->get_string_delimiters(&strings);
@@ -499,7 +502,7 @@ ShaderEditor::ShaderEditor() {
edit_menu->set_pos(Point2(5,-1));
edit_menu->set_text(TTR("Edit"));
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO);
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_Z), EDIT_REDO);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y), EDIT_REDO);
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X), EDIT_CUT);
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C), EDIT_COPY);
@@ -519,7 +522,7 @@ ShaderEditor::ShaderEditor() {
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
// search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K);
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_G), SEARCH_GOTO_LINE);
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE);
search_menu->get_popup()->connect("item_pressed", this,"_menu_option");
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index d567c8e9b3..375220051c 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -176,7 +176,9 @@ void GraphColorRampEdit::_input_event(const InputEvent& p_event) {
void GraphColorRampEdit::_notification(int p_what){
if (p_what==NOTIFICATION_ENTER_TREE) {
- picker->connect("color_changed",this,"_color_changed");
+ if (!picker->is_connected("color_changed",this,"_color_changed")) {
+ picker->connect("color_changed",this,"_color_changed");
+ }
}
if (p_what==NOTIFICATION_DRAW) {
@@ -184,9 +186,8 @@ void GraphColorRampEdit::_notification(int p_what){
Point prev;
prev.offset=0;
prev.color=Color(0,0,0);
- int w = get_size().x;
- int h = get_size().y;
+ int h = get_size().y;
int total_w = get_size().width-get_size().height-3;
for(int i=-1;i<points.size();i++) {
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 8d72178f23..a70df78697 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -53,8 +53,6 @@
void SpatialEditorViewport::_update_camera() {
if (orthogonal) {
- Size2 size = get_size();
- Size2 vpsize = Point2(cursor.distance*size.get_aspect(), cursor.distance / size.get_aspect());
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
}
@@ -79,21 +77,30 @@ void SpatialEditorViewport::_update_camera() {
String SpatialEditorGizmo::get_handle_name(int p_idx) const {
+ if (get_script_instance() && get_script_instance()->has_method("get_handle_name"))
+ return get_script_instance()->call("get_handle_name", p_idx);
+
return "";
}
Variant SpatialEditorGizmo::get_handle_value(int p_idx) const{
+ if (get_script_instance() && get_script_instance()->has_method("get_handle_value"))
+ return get_script_instance()->call("get_handle_value", p_idx);
+
return Variant();
}
void SpatialEditorGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) {
+ if (get_script_instance() && get_script_instance()->has_method("set_handle"))
+ get_script_instance()->call("set_handle", p_idx, p_camera, p_point);
}
void SpatialEditorGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
-
+ if (get_script_instance() && get_script_instance()->has_method("commit_handle"))
+ get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel);
}
bool SpatialEditorGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
@@ -276,10 +283,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
r_includes_current=false;
List<_RayResult> results;
- Vector3 cn=_get_camera_normal();
- Plane cplane(pos,cn.normalized());
-
- float min_d=1e20;
for (int i=0;i<instances.size();i++) {
@@ -649,21 +652,8 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hili
Vector3 ray_pos=_get_ray_pos( Vector2( p_screenpos.x, p_screenpos.y ) );
Vector3 ray=_get_ray( Vector2( p_screenpos.x, p_screenpos.y ) );
- Vector3 cn=_get_camera_normal();
- Plane cplane(ray_pos,cn.normalized());
-
Transform gt = spatial_editor->get_gizmo_transform();
float gs=gizmo_scale;
- /*
- if (orthogonal) {
- gs= cursor.distance/surface->get_size().get_aspect();
-
- } else {
- gs = cplane.distance_to(gt.origin);
- }
-
- gs*=GIZMO_SCALE_DEFAULT;
-*/
if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) {
@@ -1268,16 +1258,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (_edit.gizmo.is_valid()) {
- Plane plane=Plane(_edit.gizmo_initial_pos,_get_camera_normal());
-
-
- Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) );
- Vector3 ray=_get_ray( Vector2( m.x, m.y ) );
-
- //Vector3 intersection;
- //if (!plane.intersects_ray(ray_pos,ray,&intersection))
- // break;
-
_edit.gizmo->set_handle(_edit.gizmo_handle,camera,Vector2(m.x,m.y));
Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
@@ -1658,136 +1638,89 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
default: {}
}
} break;
-
case InputEvent::KEY: {
-
const InputEventKey &k = p_event.key;
if (!k.pressed)
break;
- switch(k.scancode) {
-
- case KEY_S: {
-
- if (_edit.mode!=TRANSFORM_NONE) {
-
- _edit.snap=true;
- }
- } break;
- case KEY_7:
- case KEY_KP_7: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_7)
- return;
- cursor.y_rot=0;
- if (k.mod.shift) {
- cursor.x_rot=-Math_PI/2.0;
- set_message(TTR("Bottom View."),2);
- name=TTR("Bottom");
- _update_name();
-
- } else {
- cursor.x_rot=Math_PI/2.0;
- set_message(TTR("Top View."),2);
- name=TTR("Top");
- _update_name();
- }
- } break;
- case KEY_1:
- case KEY_KP_1: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_1)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI;
- set_message(TTR("Rear View."),2);
- name=TTR("Rear");
- _update_name();
-
- } else {
- cursor.y_rot=0;
- set_message(TTR("Front View."),2);
- name=TTR("Front");
- _update_name();
- }
-
- } break;
- case KEY_3:
- case KEY_KP_3: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_3)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI/2.0;
- set_message(TTR("Left View."),2);
- name=TTR("Left");
- _update_name();
- } else {
- cursor.y_rot=-Math_PI/2.0;
- set_message(TTR("Right View."),2);
- name=TTR("Right");
- _update_name();
- }
-
- } break;
- case KEY_5:
- case KEY_KP_5: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_5)
- return;
-
- //orthogonal = !orthogonal;
- _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
- _update_name();
-
-
- } break;
- case KEY_K: {
-
- if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
- break;
-
- if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
- set_message(TTR("Keying is disabled (no key inserted)."));
- break;
- }
-
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
-
- Spatial *sp = E->get()->cast_to<Spatial>();
- if (!sp)
- continue;
-
- emit_signal("transform_key_request",sp,"",sp->get_transform());
- }
-
-
- set_message(TTR("Animation Key Inserted."));
+ if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
+ if (_edit.mode != TRANSFORM_NONE) {
+ _edit.snap=true;
+ }
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = -Math_PI/2.0;
+ set_message(TTR("Bottom View."),2);
+ name = TTR("Bottom");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = Math_PI/2.0;
+ set_message(TTR("Top View."),2);
+ name = TTR("Top");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot = Math_PI;
+ set_message(TTR("Rear View."),2);
+ name = TTR("Rear");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot=0;
+ set_message(TTR("Front View."),2);
+ name=TTR("Front");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = Math_PI/2.0;
+ set_message(TTR("Left View."),2);
+ name = TTR("Left");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = -Math_PI/2.0;
+ set_message(TTR("Right View."),2);
+ name = TTR("Right");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) {
+ _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
+ if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
+ break;
+ if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
+ set_message(TTR("Keying is disabled (no key inserted)."));
+ break;
+ }
- } break;
+ List<Node*> &selection = editor_selection->get_selected_node_list();
- case KEY_F: {
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
- if (k.pressed && k.mod.shift && k.mod.control) {
- _menu_option(VIEW_ALIGN_SELECTION_WITH_VIEW);
- } else if (k.pressed) {
- _menu_option(VIEW_CENTER_TO_SELECTION);
- }
+ Spatial *sp = E->get()->cast_to<Spatial>();
+ if (!sp)
+ continue;
- } break;
+ emit_signal("transform_key_request",sp,"",sp->get_transform());
+ }
- case KEY_SPACE: {
- if (!k.pressed)
- emit_signal("toggle_maximize_view", this);
- } break;
+ set_message(TTR("Animation Key Inserted."));
}
+ if (k.scancode == KEY_SPACE) {
+ if (!k.pressed) emit_signal("toggle_maximize_view", this);
+ }
} break;
@@ -1855,16 +1788,6 @@ void SpatialEditorViewport::_notification(int p_what) {
continue;
- /*
- ??
- if (!se->poly_instance.is_valid())
- continue;
- if (!ObjectDB::get_instance( E->key() )) {
- VisualServer::get_singleton()->free( se->poly_instance );
- se->poly_instance=RID();
- continue;
- }
- */
VisualInstance *vi=sp->cast_to<VisualInstance>();
@@ -1902,35 +1825,6 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->update();
}
- //grid
- Vector3 grid_cam_axis=_get_camera_normal();
- /*
- for(int i=0;i<3;i++) {
-
-
- Vector3 axis;
- axis[i]=1;
-
- bool should_be_visible= grid_enabled && (grid_enable[i] || (Math::abs(grid_cam_axis.dot(axis))>0.99 && orthogonal));
-
- if (should_be_visible!=grid_visible[i]) {
-
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,should_be_visible);
- grid_visible[i]=should_be_visible;
- }
- }
-
- if (last_grid_snap!=spatial_editor->get_translate_snap()) {
-
-
- last_grid_snap=spatial_editor->get_translate_snap()
- Transform gridt;
- gridt.basis.scale(Vector3(last_grid_snap,last_grid_snap,last_grid_snap));
- for(int i=0;i<3;i++)
- VisualServer::get_singleton()->instance_set_transform(grid_instance[i],gridt);
-
- }*/
-
}
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -2470,29 +2364,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
surface->add_child(view_menu);
view_menu->set_pos( Point2(4,4));
view_menu->set_self_opacity(0.5);
-
- view_menu->get_popup()->add_item(TTR("Top (Num7)"),VIEW_TOP);
- view_menu->get_popup()->add_item(TTR("Bottom (Shift+Num7)"),VIEW_BOTTOM);
- view_menu->get_popup()->add_item(TTR("Left (Num3)"),VIEW_LEFT);
- view_menu->get_popup()->add_item(TTR("Right (Shift+Num3)"),VIEW_RIGHT);
- view_menu->get_popup()->add_item(TTR("Front (Num1)"),VIEW_FRONT);
- view_menu->get_popup()->add_item(TTR("Rear (Shift+Num1)"),VIEW_REAR);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/right_view"), VIEW_RIGHT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/front_view"), VIEW_FRONT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/rear_view"), VIEW_REAR);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Perspective (Num5)"),VIEW_PERSPECTIVE);
- view_menu->get_popup()->add_check_item(TTR("Orthogonal (Num5)"),VIEW_ORTHOGONAL);
+ view_menu->get_popup()->add_check_item(TTR("Perspective") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_PERSPECTIVE);
+ view_menu->get_popup()->add_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", 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(TTR("Environment"),VIEW_ENVIRONMENT);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Audio Listener"),VIEW_AUDIO_LISTENER);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Gizmos"),VIEW_GIZMOS);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")),VIEW_GIZMOS);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_item(TTR("Selection (F)"),VIEW_CENTER_TO_SELECTION);
- view_menu->get_popup()->add_item(TTR("Align with view (Ctrl+Shift+F)"),VIEW_ALIGN_SELECTION_WITH_VIEW);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
view_menu->get_popup()->connect("item_pressed",this,"_menu_option");
preview_camera = memnew( Button );
@@ -2613,16 +2506,9 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) {
si->sbox_instance=VisualServer::get_singleton()->instance_create2(selection_box->get_rid(),sp->get_world()->get_scenario());
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF);
- RID inst = sp->call("_get_visual_instance_rid");
-
-// if (inst.is_valid())
-// si->aabb = VisualServer::get_singleton()->instance_get_base_aabb(inst);
-
-
if (get_tree()->is_editor_hint())
editor->call("edit_node",sp);
-
return si;
}
@@ -3951,6 +3837,19 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child(vs);
+ ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT+KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT+KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/front_view", TTR("Front View"), KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT+KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/right_view", TTR("Right View"), KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5);
+ ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S);
+ ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K);
+ ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F);
+ ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F);
+
+
PopupMenu *p;
transform_menu = memnew( MenuButton );
@@ -3958,13 +3857,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child( transform_menu );
p = transform_menu->get_popup();
- p->add_check_item(TTR("Use Snap"),MENU_TRANSFORM_USE_SNAP);
- p->add_item(TTR("Configure Snap.."),MENU_TRANSFORM_CONFIGURE_SNAP);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_snap", TTR("Use Snap")), MENU_TRANSFORM_USE_SNAP);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap..")), MENU_TRANSFORM_CONFIGURE_SNAP);
p->add_separator();
- p->add_check_item(TTR("Local Coords"),MENU_TRANSFORM_LOCAL_COORDS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Local Coords")), MENU_TRANSFORM_LOCAL_COORDS);
//p->set_item_checked(p->get_item_count()-1,true);
p->add_separator();
- p->add_item(TTR("Transform Dialog.."),MENU_TRANSFORM_DIALOG);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog..")), MENU_TRANSFORM_DIALOG);
p->connect("item_pressed", this,"_menu_item_pressed");
@@ -3975,27 +3874,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
- p->add_check_item(TTR("Use Default Light"),MENU_VIEW_USE_DEFAULT_LIGHT);
- p->add_check_item(TTR("Use Default sRGB"),MENU_VIEW_USE_DEFAULT_SRGB);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_light", TTR("Use Default Light")), MENU_VIEW_USE_DEFAULT_LIGHT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_srgb", TTR("Use Default sRGB")), MENU_VIEW_USE_DEFAULT_SRGB);
p->add_separator();
- p->add_check_item(TTR("1 Viewport"),MENU_VIEW_USE_1_VIEWPORT,KEY_MASK_CMD+KEY_1);
- p->add_check_item(TTR("2 Viewports"),MENU_VIEW_USE_2_VIEWPORTS,KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("2 Viewports (Alt)"),MENU_VIEW_USE_2_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("3 Viewports"),MENU_VIEW_USE_3_VIEWPORTS,KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("3 Viewports (Alt)"),MENU_VIEW_USE_3_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("4 Viewports"),MENU_VIEW_USE_4_VIEWPORTS,KEY_MASK_CMD+KEY_4);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD+KEY_1), MENU_VIEW_USE_1_VIEWPORT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"),KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD+KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
p->add_separator();
- p->add_check_item(TTR("Display Normal"),MENU_VIEW_DISPLAY_NORMAL);
- p->add_check_item(TTR("Display Wireframe"),MENU_VIEW_DISPLAY_WIREFRAME);
- p->add_check_item(TTR("Display Overdraw"),MENU_VIEW_DISPLAY_OVERDRAW);
- p->add_check_item(TTR("Display Shadeless"),MENU_VIEW_DISPLAY_SHADELESS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_normal", TTR("Display Normal")), MENU_VIEW_DISPLAY_NORMAL);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_wireframe", TTR("Display Wireframe")), MENU_VIEW_DISPLAY_WIREFRAME);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_overdraw", TTR("Display Overdraw")), MENU_VIEW_DISPLAY_OVERDRAW);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_shadeless", TTR("Display Shadeless")), MENU_VIEW_DISPLAY_SHADELESS);
p->add_separator();
- p->add_check_item(TTR("View Origin"),MENU_VIEW_ORIGIN);
- p->add_check_item(TTR("View Grid"),MENU_VIEW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_origin", TTR("View Origin")), MENU_VIEW_ORIGIN);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid")), MENU_VIEW_GRID);
p->add_separator();
- p->add_item(TTR("Settings"),MENU_VIEW_CAMERA_SETTINGS);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings")), MENU_VIEW_CAMERA_SETTINGS);
p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true );
diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
index 4f59287994..e29a0c8d52 100644
--- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -31,7 +31,7 @@
#include "io/resource_loader.h"
#include "globals.h"
#include "tools/editor/editor_settings.h"
-
+#include "scene/3d/sprite_3d.h"
@@ -355,6 +355,35 @@ void SpriteFramesEditor::_animation_select() {
}
+
+static void _find_anim_sprites(Node* p_node,List<Node*> *r_nodes,Ref<SpriteFrames> p_sfames) {
+
+ Node *edited = EditorNode::get_singleton()->get_edited_scene();
+ if (!edited)
+ return;
+ if (p_node!=edited && p_node->get_owner()!=edited)
+ return;
+
+ {
+ AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
+ if (as && as->get_sprite_frames()==p_sfames) {
+ r_nodes->push_back(p_node);
+ }
+ }
+
+ {
+ AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>();
+ if (as && as->get_sprite_frames()==p_sfames) {
+ r_nodes->push_back(p_node);
+ }
+ }
+
+ for(int i=0;i<p_node->get_child_count();i++) {
+ _find_anim_sprites(p_node->get_child(i),r_nodes,p_sfames);
+ }
+
+}
+
void SpriteFramesEditor::_animation_name_edited(){
if (updating)
@@ -381,9 +410,24 @@ void SpriteFramesEditor::_animation_name_edited(){
name=new_name+" "+itos(counter);
}
+ List<Node*> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
+
undo_redo->create_action(TTR("Rename Animation"));
undo_redo->add_do_method(frames,"rename_animation",edited_anim,name);
undo_redo->add_undo_method(frames,"rename_animation",name,edited_anim);
+
+ for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+
+ String current = E->get()->call("get_animation");
+ if (current!=edited_anim)
+ continue;
+
+ undo_redo->add_do_method(E->get(),"set_animation",name);
+ undo_redo->add_undo_method(E->get(),"set_animation",edited_anim);
+
+ }
+
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
@@ -406,12 +450,28 @@ void SpriteFramesEditor::_animation_add(){
name=new_name+" "+itos(counter);
}
+ List<Node*> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
+
+
undo_redo->create_action(TTR("Add Animation"));
undo_redo->add_do_method(frames,"add_animation",name);
undo_redo->add_undo_method(frames,"remove_animation",name);
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
+
+ for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+
+ String current = E->get()->call("get_animation");
+ if (frames->has_animation(current))
+ continue;
+
+ undo_redo->add_do_method(E->get(),"set_animation",name);
+ undo_redo->add_undo_method(E->get(),"set_animation",current);
+
+ }
+
edited_anim=new_name;
undo_redo->commit_action();
@@ -426,6 +486,7 @@ void SpriteFramesEditor::_animation_remove(){
if (!frames->has_animation(edited_anim))
return;
+
undo_redo->create_action(TTR("Remove Animation"));
undo_redo->add_do_method(frames,"remove_animation",edited_anim);
undo_redo->add_undo_method(frames,"add_animation",edited_anim);
diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp
index 8515008982..63d8e2e1cf 100644
--- a/tools/editor/plugins/texture_region_editor_plugin.cpp
+++ b/tools/editor/plugins/texture_region_editor_plugin.cpp
@@ -302,7 +302,6 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
}
}
} else if (edited_margin < 0) {
- print_line("EDIT RECTANGLE!!!");
drag_from=mtx.affine_inverse().xform(Vector2(mb.x,mb.y));
if (snap_mode == SNAP_PIXEL)
drag_from = drag_from.snapped(Vector2(1,1));
@@ -332,7 +331,6 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
}
} else if (drag) {
- print_line("DRAGING!!!");
if (edited_margin >= 0) {
undo_redo->create_action("Set Margin");
static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT};
@@ -776,6 +774,8 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
snap_step=Vector2(10,10);
snap_separation = Vector2(0,0);
+ edited_margin = -1;
+ drag_index = -1;
drag=false;
VBoxContainer *main_vb = memnew( VBoxContainer );
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index d5f85d3333..d686c37d1a 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -223,7 +223,7 @@ void TileMapEditor::_update_palette() {
String name;
if (tileset->tile_get_name(E->get())!="") {
- name = tileset->tile_get_name(E->get());
+ name = itos(E->get())+" - "+tileset->tile_get_name(E->get());
} else {
name = "#"+itos(E->get());
}
@@ -412,6 +412,24 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h
if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
rect.pos+=tile_ofs;
+ } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_BOTTOM_LEFT) {
+ Size2 cell_size = node->get_cell_size();
+
+ rect.pos+=tile_ofs;
+
+ if(p_transpose)
+ {
+ if(p_flip_h)
+ rect.pos.x-=cell_size.x;
+ else
+ rect.pos.x+=cell_size.x;
+ } else {
+ if(p_flip_v)
+ rect.pos.y-=cell_size.y;
+ else
+ rect.pos.y+=cell_size.y;
+ }
+
} else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
rect.pos+=node->get_cell_size()/2;
Vector2 s = r.size;
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index a2c7147bf3..39a15189e7 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -73,24 +73,24 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
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;
+ Size2 s;
- 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()) {
+ s=mi->get_region_rect().size;
p_library->tile_set_region(id,mi->get_region_rect());
+ } else {
+ const int frame = mi->get_frame();
+ const int hframes = mi->get_hframes();
+ s=texture->get_size()/Size2(hframes,mi->get_vframes());
+ p_library->tile_set_region(id,Rect2(Vector2(frame%hframes,frame/hframes)*s,s));
+ }
+
+ if (mi->is_centered()) {
+ phys_offset+=-s/2;
}
Vector<Ref<Shape2D> >collisions;