diff options
Diffstat (limited to 'tools/editor/plugins')
17 files changed, 1240 insertions, 604 deletions
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 6ab5af539a..6542fc8b4a 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -1401,6 +1401,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { add_child(file); name_dialog = memnew( ConfirmationDialog ); + name_dialog->set_title("Create New Animation"); name_dialog->set_hide_on_ok(false); add_child(name_dialog); name = memnew( LineEdit ); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 4599dbfb54..261d862b37 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -115,6 +115,8 @@ void BakedLightBaker::_add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_m if (!mat_map.has(mat)) { MeshMaterial mm; + mm.is_double_sided = mat->get_flag(Material::FLAG_DOUBLE_SIDED); + mm.use_alpha = false; Ref<FixedMaterial> fm = mat; if (fm.is_valid()) { @@ -128,6 +130,8 @@ void BakedLightBaker::_add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_m mm.specular.color=mm.specular.color.to_linear(); mm.specular.tex=_get_mat_tex(fm->get_texture(FixedMaterial::PARAM_SPECULAR)); + + mm.use_alpha = fm->get_fixed_flag(FixedMaterial::FLAG_USE_ALPHA); } else { mm.diffuse.color=Color(1,1,1,1); @@ -311,7 +315,12 @@ void BakedLightBaker::_parse_geometry(Node* p_node) { lights.push_back(dirl); } - } else if (p_node->cast_to<Spatial>()){ + } + else if (p_node->cast_to<BakedLightSampler>()){ + // Ignore meshes and lights contained in baked light samplers + return; + } + else if (p_node->cast_to<Spatial>()){ Spatial *sp = p_node->cast_to<Spatial>(); @@ -472,6 +481,7 @@ BakedLightBaker::BVH* BakedLightBaker::_parse_bvh(BVH** p_children, int p_size, BVH* right = _parse_bvh(&p_children[p_size/2],p_size-p_size/2,p_depth+1,max_depth); BVH *_new = memnew(BVH); + _new->id=-1; _new->aabb=aabb; _new->center=aabb.pos+aabb.size*0.5; _new->children[0]=left; @@ -488,6 +498,7 @@ void BakedLightBaker::_make_bvh() { int max_depth=0; for(int i=0;i<triangles.size();i++) { bases[i]=memnew( BVH ); + bases[i]->id=i; bases[i]->leaf=&triangles[i]; bases[i]->aabb.pos=triangles[i].vertices[0]; bases[i]->aabb.expand_to(triangles[i].vertices[1]); @@ -949,7 +960,7 @@ void BakedLightBaker::_plot_light(ThreadStack& thread_stack,const Vector3& p_plo } -float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce,bool p_only_dist) { +float BakedLightBaker::_throw_ray(ThreadStack& thread_stack, bool p_bake_direct, const Vector3& p_begin, const Vector3& p_end, float p_rest, const Color& p_light, float *p_att_curve, float p_att_pos, int p_att_curve_len, int p_bounces, bool p_first_bounce, bool p_only_dist, Vector<int> &p_ignore_list) { uint32_t* stack = thread_stack.ray_stack; @@ -978,6 +989,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c Vector3 r_point; Vector3 end=p_end; + int triangle_id = -1; Triangle *triangle=NULL; //for(int i=0;i<max_depth;i++) @@ -986,7 +998,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c int level=0; //AABB ray_aabb; //ray_aabb.pos=p_begin; - //ray_aabb.expand_to(p_end); + //ray_aabb.expand_to(end); const BVH *bvhptr = bvh; @@ -1004,47 +1016,53 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c switch(mode) { case TEST_AABB_BIT: { - if (b.leaf) { + if (p_ignore_list.find(b.id)==-1) { + if (b.leaf) { - Face3 f3(b.leaf->vertices[0],b.leaf->vertices[1],b.leaf->vertices[2]); + Face3 f3(b.leaf->vertices[0],b.leaf->vertices[1],b.leaf->vertices[2]); - Vector3 res; + Vector3 res; - if (f3.intersects_segment(p_begin,end,&res)) { + if (f3.intersects_segment(p_begin,end,&res)) { - float nd = n.dot(res); - if (nd<d) { + float nd = n.dot(res); + if (nd<d) { - d=nd; - r_point=res; - end=res; - len=(p_begin-end).length(); - r_normal=f3.get_plane().get_normal(); - triangle=b.leaf; - inters=true; - } + d=nd; + r_point=res; + end=res; + len=(p_begin-end).length(); + r_normal=f3.get_plane().get_normal(); + triangle=b.leaf; + triangle_id=b.id; + inters=true; + } - } + } - stack[level]=VISIT_DONE_BIT; - } else { + stack[level]=VISIT_DONE_BIT; + } else { - bool valid = b.aabb.smits_intersect_ray(p_begin,n,0,len); - //bool valid = b.aabb.intersects_segment(p_begin,p_end); - // bool valid = b.aabb.intersects(ray_aabb); + bool valid = b.aabb.smits_intersect_ray(p_begin,n,0,len); + //bool valid = b.aabb.intersects_segment(p_begin,end); + // bool valid = b.aabb.intersects(ray_aabb); - if (!valid) { + if (!valid) { - stack[level]=VISIT_DONE_BIT; + stack[level]=VISIT_DONE_BIT; - } else { + } else { - stack[level]=VISIT_LEFT_BIT; - } + stack[level]=VISIT_LEFT_BIT; + } + } + } + else { + stack[level] = VISIT_DONE_BIT; } } continue; @@ -1099,17 +1117,36 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c } - if (n.dot(r_normal)>0) - return -1; - - if (n.dot(r_normal)>0) - r_normal=-r_normal; + bool passthrough = false; //ok... Color diffuse_at_point(0.8,0.8,0.8); Color specular_at_point(0.0,0.0,0.0); + if (triangle->material) { + + if ((triangle->material->is_double_sided == true || triangle->material->use_alpha == true) && use_translucency == true) { + if (n.dot(r_normal)>0) + r_normal = -r_normal; + + if (triangle->material->use_alpha == true) + passthrough = true; + } + else { + if (n.dot(r_normal)>0) + return -1; + } + + //triangle->get_uv(r_point); + + diffuse_at_point = triangle->material->diffuse.get_color(uv); + specular_at_point = triangle->material->specular.get_color(uv); + } + else { + if (n.dot(r_normal)>0) + return -1; + } float dist = p_begin.distance_to(r_point); @@ -1139,23 +1176,18 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c //the multiplication can happen with more detail in the shader - - if (triangle->material) { - - //triangle->get_uv(r_point); - - diffuse_at_point=triangle->material->diffuse.get_color(uv); - specular_at_point=triangle->material->specular.get_color(uv); - } - - diffuse_at_point.r=res_light.r*diffuse_at_point.r; diffuse_at_point.g=res_light.g*diffuse_at_point.g; diffuse_at_point.b=res_light.b*diffuse_at_point.b; float ret=1e6; - if (p_bounces>0) { + if (passthrough == true && triangle_id !=-1) + { + p_ignore_list.push_back(triangle_id); + ret=_throw_ray(thread_stack, p_bake_direct, r_point, p_end, p_rest, p_light, p_att_curve, p_att_pos, p_att_curve_len, p_bounces, p_first_bounce, p_only_dist, p_ignore_list); + } + else if (p_bounces>0 ) { p_rest-=dist; @@ -1226,33 +1258,37 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c bool skip=false; - if (!p_first_bounce || p_bake_direct) { - + if (passthrough == false) { + if (!p_first_bounce || p_bake_direct) { - float r = plot_size * cell_size*2; - 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; - } else { - - - Vector3 c1=r_normal.cross(n).normalized(); - Vector3 c2=r_normal.cross(c1).normalized(); - double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; - double r3 = double(rand())/RAND_MAX; - Vector3 rn = ((c1*(r1-0.5)) + (c2*(r2-0.5)) + (r_normal*r3*0.25)).normalized(); - float d =_throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1,false,true); - r = plot_size*cell_size*ao_radius; - if (d>0 && d<r) { + float r = plot_size * cell_size * 2; + 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 { - //plot_light=Color(0,0,0,0); + } + else { + + + Vector3 c1 = r_normal.cross(n).normalized(); + Vector3 c2 = r_normal.cross(c1).normalized(); + double r1 = double(rand()) / RAND_MAX; + double r2 = double(rand()) / RAND_MAX; + double r3 = double(rand()) / RAND_MAX; + Vector3 rn = ((c1*(r1 - 0.5)) + (c2*(r2 - 0.5)) + (r_normal*r3*0.25)).normalized(); + float d = _throw_ray(thread_stack, p_bake_direct, r_point, r_point + rn*p_rest, p_rest, diffuse_at_point, p_att_curve, p_att_pos, p_att_curve_len, p_bounces - 1, false, true); + r = plot_size*cell_size*ao_radius; + if (d > 0 && d < 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; + + } + else { + //plot_light=Color(0,0,0,0); + } } } } diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h index 8fbeeddc6a..58197283a2 100644 --- a/tools/editor/plugins/baked_light_baker.h +++ b/tools/editor/plugins/baked_light_baker.h @@ -92,6 +92,9 @@ public: Param diffuse; Param specular; Param emission; + + bool is_double_sided; + bool use_alpha; }; struct Triangle { @@ -154,6 +157,7 @@ public: struct BVH { + int id; AABB aabb; Vector3 center; Triangle *leaf; @@ -307,7 +311,7 @@ public: void _plot_light(ThreadStack& thread_stack,const Vector3& p_plot_pos,const AABB& p_plot_aabb,const Color& p_light,const Color& p_tint_light,bool p_only_full,const Plane& p_plane); //void _plot_light_point(const Vector3& p_plot_pos, Octant *p_octant, const AABB& p_aabb,const Color& p_light); - float _throw_ray(ThreadStack& thread_stack,bool p_bake_direct,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce=false,bool p_only_dist=false); + float _throw_ray(ThreadStack& thread_stack,bool p_bake_direct,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce=false,bool p_only_dist=false, Vector<int>&p_ignore_list=Vector<int>()); float total_light_area; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index d318f6f6fa..b03eed77b1 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -41,9 +41,9 @@ class SnapDialog : public ConfirmationDialog { OBJ_TYPE(SnapDialog,ConfirmationDialog); - -protected: - friend class CanvasItemEditor; + +friend class CanvasItemEditor; + SpinBox *grid_offset_x; SpinBox *grid_offset_y; SpinBox *grid_step_x; @@ -58,63 +58,75 @@ public: Label *label; VBoxContainer *container; GridContainer *child_container; - + set_title("Configure Snap"); get_ok()->set_text("Close"); - container = memnew(VBoxContainer); + + container = memnew( VBoxContainer ); add_child(container); - - child_container = memnew(GridContainer); + set_child_rect(container); + + child_container = memnew( GridContainer ); child_container->set_columns(3); container->add_child(child_container); - - label = memnew(Label); + + label = memnew( Label ); label->set_text("Grid Offset:"); child_container->add_child(label); - grid_offset_x=memnew(SpinBox); + label->set_h_size_flags(SIZE_EXPAND_FILL); + + grid_offset_x = memnew( SpinBox ); grid_offset_x->set_min(-SPIN_BOX_GRID_RANGE); grid_offset_x->set_max(SPIN_BOX_GRID_RANGE); grid_offset_x->set_suffix("px"); child_container->add_child(grid_offset_x); - grid_offset_y=memnew(SpinBox); + + grid_offset_y = memnew( SpinBox ); grid_offset_y->set_min(-SPIN_BOX_GRID_RANGE); grid_offset_y->set_max(SPIN_BOX_GRID_RANGE); grid_offset_y->set_suffix("px"); child_container->add_child(grid_offset_y); - label = memnew(Label); + label = memnew( Label ); label->set_text("Grid Step:"); child_container->add_child(label); - grid_step_x=memnew(SpinBox); + label->set_h_size_flags(SIZE_EXPAND_FILL); + + grid_step_x = memnew( SpinBox ); grid_step_x->set_min(-SPIN_BOX_GRID_RANGE); grid_step_x->set_max(SPIN_BOX_GRID_RANGE); grid_step_x->set_suffix("px"); child_container->add_child(grid_step_x); - grid_step_y=memnew(SpinBox); + + grid_step_y = memnew( SpinBox ); grid_step_y->set_min(-SPIN_BOX_GRID_RANGE); grid_step_y->set_max(SPIN_BOX_GRID_RANGE); grid_step_y->set_suffix("px"); child_container->add_child(grid_step_y); - - container->add_child(memnew(HSeparator)); - child_container = memnew(GridContainer); + container->add_child( memnew( HSeparator ) ); + + child_container = memnew( GridContainer ); child_container->set_columns(2); container->add_child(child_container); - label = memnew(Label); + label = memnew( Label ); label->set_text("Rotation Offset:"); child_container->add_child(label); - rotation_offset=memnew(SpinBox); + label->set_h_size_flags(SIZE_EXPAND_FILL); + + rotation_offset = memnew( SpinBox ); rotation_offset->set_min(-SPIN_BOX_ROTATION_RANGE); rotation_offset->set_max(SPIN_BOX_ROTATION_RANGE); rotation_offset->set_suffix("deg"); child_container->add_child(rotation_offset); - - label = memnew(Label); + + label = memnew( Label ); label->set_text("Rotation Step:"); child_container->add_child(label); - rotation_step=memnew(SpinBox); + label->set_h_size_flags(SIZE_EXPAND_FILL); + + rotation_step = memnew( SpinBox ); rotation_step->set_min(-SPIN_BOX_ROTATION_RANGE); rotation_step->set_max(SPIN_BOX_ROTATION_RANGE); rotation_step->set_suffix("deg"); @@ -2278,7 +2290,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SNAP_CONFIGURE: { ((SnapDialog *)snap_dialog)->set_fields(snap_offset, snap_step, snap_rotation_offset, snap_rotation_step); - snap_dialog->popup_centered(Size2(200,160)); + snap_dialog->popup_centered(Size2(220,160)); } break; case ZOOM_IN: { zoom=zoom*(1.0/0.5); @@ -3173,7 +3185,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_item("Paste Pose",ANIM_PASTE_POSE); p->add_item("Clear Pose",ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K); - snap_dialog = memnew(SnapDialog); + snap_dialog = memnew( SnapDialog ); snap_dialog->connect("confirmed",this,"_snap_changed"); add_child(snap_dialog); diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 62cf1b4acb..f56b9a2fd9 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -115,6 +115,18 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) { } break; case LINE_SHAPE: { + if (idx<2) { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0){ + line->set_d(p_point.length()); + }else{ + line->set_normal(p_point/30.0); + } + + canvas_item_editor->get_viewport_control()->update(); + } + } break; @@ -200,6 +212,19 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) { } break; case LINE_SHAPE: { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0) { + undo_redo->add_do_method(line.ptr(),"set_d",line->get_d()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_d",p_org); + undo_redo->add_undo_method(c,"update"); + } else { + undo_redo->add_do_method(line.ptr(),"set_normal",line->get_normal()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_normal",p_org); + undo_redo->add_undo_method(c,"update"); + } } break; @@ -418,6 +443,14 @@ void CollisionShape2DEditor::_canvas_draw() { } break; case LINE_SHAPE: { + Ref<LineShape2D> shape = node->get_shape(); + + handles.resize(2); + handles[0] = shape->get_normal() * shape->get_d(); + handles[1] = shape->get_normal() * (shape->get_d() + 30.0); + + c->draw_texture(h,gt.xform(handles[0])-size); + c->draw_texture(h,gt.xform(handles[1])-size); } break; diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index c2b3ecfcda..5f52d4c3e7 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -491,8 +491,14 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; + int ofs = ima_adpcm.last_nibble>>1; + + if (stereo) + ofs*=2; + + nibble = (ima_adpcm.last_nibble&1)? - (src_ptr[ima_adpcm.last_nibble>>1]>>4):(src_ptr[ima_adpcm.last_nibble>>1]&0xF); + (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF); step=_ima_adpcm_step_table[ima_adpcm.step_index]; ima_adpcm.step_index += _ima_adpcm_index_table[nibble]; diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp index 13d4c8db5a..cea774f94b 100644 --- a/tools/editor/plugins/mesh_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_editor_plugin.cpp @@ -160,7 +160,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_OUTLINE_MESH: { - outline_dialog->popup_centered_minsize(); + outline_dialog->popup_centered(Vector2(200, 90)); } break; } @@ -212,7 +212,6 @@ MeshInstanceEditor::MeshInstanceEditor() { options = memnew( MenuButton ); - //add_child(options); SpatialEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text("Mesh"); @@ -231,14 +230,20 @@ MeshInstanceEditor::MeshInstanceEditor() { options->get_popup()->connect("item_pressed", this,"_menu_option"); outline_dialog = memnew( ConfirmationDialog ); - outline_dialog->set_title("Outline Size: "); + outline_dialog->set_title("Create Outline Mesh"); + outline_dialog->get_ok()->set_text("Create"); + + VBoxContainer *outline_dialog_vbc = memnew( VBoxContainer ); + outline_dialog->add_child(outline_dialog_vbc); + outline_dialog->set_child_rect(outline_dialog_vbc); + outline_size = memnew( SpinBox ); outline_size->set_min(0.001); outline_size->set_max(1024); outline_size->set_step(0.001); outline_size->set_val(0.05); - outline_dialog->add_child(outline_size); - outline_dialog->set_child_rect(outline_size); + outline_dialog_vbc->add_margin_child("Outline Size:",outline_size); + add_child(outline_dialog); outline_dialog->connect("confirmed",this,"_create_outline_mesh"); diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index 3c88b1d3a8..a5c823f8bd 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -289,7 +289,7 @@ void MultiMeshEditor::_menu_option(int p_option) { _last_pp_node=node; } - populate_dialog->popup_centered(Size2(250,395)); + populate_dialog->popup_centered(Size2(250,380)); } break; } @@ -325,10 +325,8 @@ MultiMeshEditor::MultiMeshEditor() { options = memnew( MenuButton ); - //add_child(options); SpatialEditor::get_singleton()->add_control_to_menu_panel(options); - options->set_area_as_parent_rect(); - + options->set_text("MultiMesh"); options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance","EditorIcons")); @@ -373,12 +371,12 @@ MultiMeshEditor::MultiMeshEditor() { populate_axis->select(2); vbc->add_margin_child("Mesh Up Axis:",populate_axis); - populate_rotate_random = memnew( HScrollBar ); + populate_rotate_random = memnew( HSlider ); populate_rotate_random->set_max(1); populate_rotate_random->set_step(0.01); vbc->add_margin_child("Random Rotation:",populate_rotate_random); - populate_tilt_random = memnew( HScrollBar ); + populate_tilt_random = memnew( HSlider ); populate_tilt_random->set_max(1); populate_tilt_random->set_step(0.01); vbc->add_margin_child("Random Tilt:",populate_tilt_random); @@ -416,8 +414,7 @@ MultiMeshEditor::MultiMeshEditor() { std->connect("selected",this,"_browsed"); _last_pp_node=NULL; - //options->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); - //options->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); + err_dialog = memnew( AcceptDialog ); add_child(err_dialog); } @@ -451,13 +448,6 @@ MultiMeshEditorPlugin::MultiMeshEditorPlugin(EditorNode *p_node) { multimesh_editor = memnew( MultiMeshEditor ); editor->get_viewport()->add_child(multimesh_editor); -// multimesh_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); -// multimesh_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); - multimesh_editor->set_margin(MARGIN_LEFT,253); - multimesh_editor->set_margin(MARGIN_RIGHT,310); - multimesh_editor->set_margin(MARGIN_TOP,0); - multimesh_editor->set_margin(MARGIN_BOTTOM,10); - multimesh_editor->options->hide(); } diff --git a/tools/editor/plugins/multimesh_editor_plugin.h b/tools/editor/plugins/multimesh_editor_plugin.h index 4f0c0d008b..edc3dfd55f 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.h +++ b/tools/editor/plugins/multimesh_editor_plugin.h @@ -42,10 +42,10 @@ class MultiMeshEditor : public Control { OBJ_TYPE(MultiMeshEditor, Control ); - friend class MultiMeshEditorPlugin; +friend class MultiMeshEditorPlugin; AcceptDialog *err_dialog; - MenuButton * options; + MenuButton * options; MultiMeshInstance *_last_pp_node; bool browsing_source; @@ -59,8 +59,8 @@ class MultiMeshEditor : public Control { ConfirmationDialog *populate_dialog; OptionButton *populate_axis; - HScrollBar *populate_rotate_random; - HScrollBar *populate_tilt_random; + HSlider *populate_rotate_random; + HSlider *populate_tilt_random; SpinBox *populate_scale_random; SpinBox *populate_scale; SpinBox *populate_amount; diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index 31fa7246ae..d88f2adc73 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -156,8 +156,14 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; + int ofs = ima_adpcm.last_nibble>>1; + + if (stereo) + ofs*=2; + nibble = (ima_adpcm.last_nibble&1)? - (src_ptr[ima_adpcm.last_nibble>>1]>>4):(src_ptr[ima_adpcm.last_nibble>>1]&0xF); + (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF); + step=_ima_adpcm_step_table[ima_adpcm.step_index]; ima_adpcm.step_index += _ima_adpcm_index_table[nibble]; diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index cf9a6c41a4..b497458a2a 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -49,9 +49,13 @@ void SampleLibraryEditor::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { play->set_icon( get_icon("Play","EditorIcons") ); + play->set_tooltip("Play Sample"); stop->set_icon( get_icon("Stop","EditorIcons") ); + stop->set_tooltip("Stop Sample"); load->set_icon( get_icon("Folder","EditorIcons") ); + load->set_tooltip("Open Sample File(s)"); _delete->set_icon( get_icon("Del","EditorIcons") ); + _delete->set_tooltip("Remove Sample"); } if (p_what==NOTIFICATION_READY) { diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index bd0f580a34..65ed420a51 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -572,28 +572,119 @@ void ScriptEditor::_goto_script_line(REF p_script,int p_line) { } + +void ScriptEditor::_update_history_arrows() { + + script_back->set_disabled( history_pos<=0 ); + script_forward->set_disabled( history_pos>=history.size()-1 ); +} + + +void ScriptEditor::_go_to_tab(int p_idx) { + + Node *cn = tab_container->get_child(p_idx); + if (!cn) + return; + Control *c = cn->cast_to<Control>(); + if (!c) + return; + + if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptTextEditor>()) { + + history[history_pos].scroll_pos=n->cast_to<ScriptTextEditor>()->get_text_edit()->get_v_scroll(); + history[history_pos].cursor_column=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_column(); + history[history_pos].cursor_row=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_line(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].scroll_pos=n->cast_to<EditorHelp>()->get_scroll(); + } + } + + history.resize(history_pos+1); + ScriptHistory sh; + sh.control=c; + sh.scroll_pos=0; + + history.push_back(sh); + history_pos++; + + + tab_container->set_current_tab(p_idx); + + c = tab_container->get_current_tab_control(); + + if (c->cast_to<ScriptTextEditor>()) { + + script_name_label->set_text(c->cast_to<ScriptTextEditor>()->get_name()); + script_icon->set_texture(c->cast_to<ScriptTextEditor>()->get_icon()); + if (is_visible()) + c->cast_to<ScriptTextEditor>()->get_text_edit()->grab_focus(); + } + if (c->cast_to<EditorHelp>()) { + + script_name_label->set_text(c->cast_to<EditorHelp>()->get_class_name()); + script_icon->set_texture(get_icon("Help","EditorIcons")); + if (is_visible()) + c->cast_to<EditorHelp>()->set_focused(); + } + + + + c->set_meta("__editor_pass",++edit_pass); + _update_history_arrows(); + _update_script_colors(); +} + void ScriptEditor::_close_current_tab() { int selected = tab_container->get_current_tab(); if (selected<0 || selected>=tab_container->get_child_count()) return; + Node *tselected = tab_container->get_child(selected); ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); - if (!current) - return; + if (current) { + apply_scripts(); + } - apply_scripts(); + //remove from history + history.resize(history_pos+1); + + for(int i=0;i<history.size();i++) { + if (history[i].control==tselected) { + history.remove(i); + i--; + history_pos--; + } + } + + if (history_pos>=history.size()) { + history_pos=history.size()-1; + } int idx = tab_container->get_current_tab(); - memdelete(current); + memdelete(tselected); if (idx>=tab_container->get_child_count()) idx=tab_container->get_child_count()-1; if (idx>=0) { + + if (history_pos>=0) { + idx = history[history_pos].control->get_index(); + } tab_container->set_current_tab(idx); + //script_list->select(idx); } + _update_history_arrows(); + + _update_script_names(); EditorNode::get_singleton()->save_layout(); @@ -755,33 +846,15 @@ void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2) void ScriptEditor::_menu_option(int p_option) { - if (p_option==FILE_OPEN) { - editor->open_resource("Script"); - return; - } - int selected = tab_container->get_current_tab(); - if (selected<0 || selected>=tab_container->get_child_count()) - return; - - ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); - if (!current) - return; - switch(p_option) { case FILE_NEW: { script_create_dialog->config("Node", ".gd"); script_create_dialog->popup_centered(Size2(300, 300)); } break; - case FILE_SAVE: { - if (!_test_script_times_on_disk()) - return; - editor->save_resource( current->get_edited_script() ); - - } break; - case FILE_SAVE_AS: { - - editor->save_resource_as( current->get_edited_script() ); + case FILE_OPEN: { + editor->open_resource("Script"); + return; } break; case FILE_SAVE_ALL: { @@ -806,387 +879,470 @@ void ScriptEditor::_menu_option(int p_option) { } break; - case EDIT_UNDO: { - current->get_text_edit()->undo(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_REDO: { - current->get_text_edit()->redo(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_CUT: { - - current->get_text_edit()->cut(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_COPY: { - current->get_text_edit()->copy(); - current->get_text_edit()->call_deferred("grab_focus"); - - } break; - case EDIT_PASTE: { - current->get_text_edit()->paste(); - current->get_text_edit()->call_deferred("grab_focus"); + case SEARCH_HELP: { + help_search_dialog->popup("current"); } break; - case EDIT_SELECT_ALL: { - - current->get_text_edit()->select_all(); - current->get_text_edit()->call_deferred("grab_focus"); + case SEARCH_CLASSES: { - } break; - case EDIT_MOVE_LINE_UP: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int from_line = tx->get_selection_from_line(); - int from_col = tx->get_selection_from_column(); - int to_line = tx->get_selection_to_line(); - int to_column = tx->get_selection_to_column(); - - for (int i = from_line; i <= to_line; i++) - { - int line_id = i; - int next_id = i - 1; - - if (line_id == 0 || next_id < 0) - return; - - swap_lines(tx, line_id, next_id); - } - int from_line_up = from_line > 0 ? from_line-1 : from_line; - int to_line_up = to_line > 0 ? to_line-1 : to_line; - tx->select(from_line_up, from_col, to_line_up, to_column); - } - else - { - int line_id = tx->cursor_get_line(); - int next_id = line_id - 1; - - if (line_id == 0 || next_id < 0) - return; - - swap_lines(tx, line_id, next_id); - } - tx->update(); - - } break; - case EDIT_MOVE_LINE_DOWN: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int from_line = tx->get_selection_from_line(); - int from_col = tx->get_selection_from_column(); - int to_line = tx->get_selection_to_line(); - int to_column = tx->get_selection_to_column(); - - for (int i = to_line; i >= from_line; i--) - { - int line_id = i; - int next_id = i + 1; - - if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) - return; - - swap_lines(tx, line_id, next_id); - } - int from_line_down = from_line < tx->get_line_count() ? from_line+1 : from_line; - int to_line_down = to_line < tx->get_line_count() ? to_line+1 : to_line; - tx->select(from_line_down, from_col, to_line_down, to_column); - } - else - { - int line_id = tx->cursor_get_line(); - int next_id = line_id + 1; - - if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) - return; - - swap_lines(tx, line_id, next_id); - } - tx->update(); - - } break; - case EDIT_INDENT_LEFT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - // begins with tab - if (line_text.begins_with("\t")) - { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(i, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) - { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(i, line_text); - } - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - // begins with tab - if (line_text.begins_with("\t")) - { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(begin, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) - { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(begin, line_text); - } - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_INDENT_RIGHT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - line_text = '\t' + line_text; - tx->set_line(i, line_text); - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - line_text = '\t' + line_text; - tx->set_line(begin, line_text); - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_CLONE_DOWN: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - int line = tx->cursor_get_line(); - int next_line = line + 1; - - if (line == tx->get_line_count() || next_line > tx->get_line_count()) - return; - - String line_clone = tx->get_line(line); - tx->insert_at(line_clone, next_line); - tx->update(); - - } break; - case EDIT_TOGGLE_COMMENT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - - if (line_text.begins_with("#")) - line_text = line_text.substr(1, line_text.length()); - else - line_text = "#" + line_text; - tx->set_line(i, line_text); - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - - if (line_text.begins_with("#")) - line_text = line_text.substr(1, line_text.length()); - else - line_text = "#" + line_text; - tx->set_line(begin, line_text); - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_COMPLETE: { - - current->get_text_edit()->query_code_comple(); + if (tab_container->get_tab_count()==0) + break; - } break; - case EDIT_AUTO_INDENT: { + String current; - TextEdit *te = current->get_text_edit(); - String text = te->get_text(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - int begin,end; - if (te->is_selection_active()) { - begin=te->get_selection_from_line(); - end=te->get_selection_to_line(); - } else { - begin=0; - end=te->get_line_count()-1; + EditorHelp *eh = tab_container->get_child( tab_container->get_current_tab() )->cast_to<EditorHelp>(); + if (eh) { + current=eh->get_class_name(); } - scr->get_language()->auto_indent_code(text,begin,end); - te->set_text(text); + help_index->popup_centered_ratio(0.6); + if (current!="") { + help_index->call_deferred("select_class",current); + } } break; - case SEARCH_FIND: { + case SEARCH_WEBSITE: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->popup_search(); + OS::get_singleton()->shell_open("http://www.godotengine.org/projects/godot-engine/wiki/Documentation#Tutorials"); } break; - case SEARCH_FIND_NEXT: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->search_next(); - } break; - case SEARCH_REPLACE: { + case WINDOW_NEXT: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->popup_replace(); + _history_forward(); } break; - case SEARCH_LOCATE_FUNCTION: { - - if (!current) - return; - quick_open->popup(current->get_functions()); + case WINDOW_PREV: { + _history_back(); } break; - case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(current->get_text_edit()); - } break; - case DEBUG_TOGGLE_BREAKPOINT: { - int line=current->get_text_edit()->cursor_get_line(); - bool dobreak = !current->get_text_edit()->is_line_set_as_breakpoint(line); - current->get_text_edit()->set_line_as_breakpoint(line,dobreak); - get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); - } break; - case DEBUG_NEXT: { + } - if (debugger) - debugger->debug_next(); - } break; - case DEBUG_STEP: { - if (debugger) - debugger->debug_step(); + int selected = tab_container->get_current_tab(); + if (selected<0 || selected>=tab_container->get_child_count()) + return; - } break; - case DEBUG_BREAK: { + ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); + if (current) { + + switch(p_option) { + case FILE_NEW: { + script_create_dialog->config("Node", ".gd"); + script_create_dialog->popup_centered(Size2(300, 300)); + } break; + case FILE_SAVE: { + if (!_test_script_times_on_disk()) + return; + editor->save_resource( current->get_edited_script() ); + + } break; + case FILE_SAVE_AS: { + + editor->save_resource_as( current->get_edited_script() ); + + } break; + case EDIT_UNDO: { + current->get_text_edit()->undo(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_REDO: { + current->get_text_edit()->redo(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_CUT: { + + current->get_text_edit()->cut(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_COPY: { + current->get_text_edit()->copy(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_PASTE: { + current->get_text_edit()->paste(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_SELECT_ALL: { + + current->get_text_edit()->select_all(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_MOVE_LINE_UP: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = from_line; i <= to_line; i++) + { + int line_id = i; + int next_id = i - 1; + + if (line_id == 0 || next_id < 0) + return; + + swap_lines(tx, line_id, next_id); + } + int from_line_up = from_line > 0 ? from_line-1 : from_line; + int to_line_up = to_line > 0 ? to_line-1 : to_line; + tx->select(from_line_up, from_col, to_line_up, to_column); + } + else + { + int line_id = tx->cursor_get_line(); + int next_id = line_id - 1; - if (debugger) - debugger->debug_break(); + if (line_id == 0 || next_id < 0) + return; - } break; - case DEBUG_CONTINUE: { + swap_lines(tx, line_id, next_id); + } + tx->update(); + + } break; + case EDIT_MOVE_LINE_DOWN: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = to_line; i >= from_line; i--) + { + int line_id = i; + int next_id = i + 1; + + if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) + return; + + swap_lines(tx, line_id, next_id); + } + int from_line_down = from_line < tx->get_line_count() ? from_line+1 : from_line; + int to_line_down = to_line < tx->get_line_count() ? to_line+1 : to_line; + tx->select(from_line_down, from_col, to_line_down, to_column); + } + else + { + int line_id = tx->cursor_get_line(); + int next_id = line_id + 1; - if (debugger) - debugger->debug_continue(); + if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) + return; - } break; - case DEBUG_SHOW: { - if (debugger) { - bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) ); - debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible); - if (visible) - debugger->hide(); + swap_lines(tx, line_id, next_id); + } + tx->update(); + + } break; + case EDIT_INDENT_LEFT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + // begins with tab + if (line_text.begins_with("\t")) + { + line_text = line_text.substr(1, line_text.length()); + tx->set_line(i, line_text); + } + // begins with 4 spaces + else if (line_text.begins_with(" ")) + { + line_text = line_text.substr(4, line_text.length()); + tx->set_line(i, line_text); + } + } + } else - debugger->show(); - } - } break; - case HELP_CONTEXTUAL: { - String text = current->get_text_edit()->get_selection_text(); - if (text == "") - text = current->get_text_edit()->get_word_under_cursor(); - if (text != "") - editor->emit_signal("request_help", text); - } break; - case FILE_CLOSE: { - if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) { - erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); - erase_tab_confirm->popup_centered_minsize(); - } else { - _close_current_tab(); - } - } break; - case WINDOW_MOVE_LEFT: { + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + // begins with tab + if (line_text.begins_with("\t")) + { + line_text = line_text.substr(1, line_text.length()); + tx->set_line(begin, line_text); + } + // begins with 4 spaces + else if (line_text.begins_with(" ")) + { + line_text = line_text.substr(4, line_text.length()); + tx->set_line(begin, line_text); + } + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_INDENT_RIGHT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + line_text = '\t' + line_text; + tx->set_line(i, line_text); + } + } + else + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + line_text = '\t' + line_text; + tx->set_line(begin, line_text); + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_CLONE_DOWN: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + int line = tx->cursor_get_line(); + int next_line = line + 1; + + if (line == tx->get_line_count() || next_line > tx->get_line_count()) + return; + + String line_clone = tx->get_line(line); + tx->insert_at(line_clone, next_line); + tx->update(); + + } break; + case EDIT_TOGGLE_COMMENT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + + if (line_text.begins_with("#")) + line_text = line_text.substr(1, line_text.length()); + else + line_text = "#" + line_text; + tx->set_line(i, line_text); + } + } + else + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + + if (line_text.begins_with("#")) + line_text = line_text.substr(1, line_text.length()); + else + line_text = "#" + line_text; + tx->set_line(begin, line_text); + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_COMPLETE: { + + current->get_text_edit()->query_code_comple(); + + } break; + case EDIT_AUTO_INDENT: { + + TextEdit *te = current->get_text_edit(); + String text = te->get_text(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + int begin,end; + if (te->is_selection_active()) { + begin=te->get_selection_from_line(); + end=te->get_selection_to_line(); + } else { + begin=0; + end=te->get_line_count()-1; + } + scr->get_language()->auto_indent_code(text,begin,end); + te->set_text(text); + + + } break; + case SEARCH_FIND: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->popup_search(); + } break; + case SEARCH_FIND_NEXT: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->search_next(); + } break; + case SEARCH_REPLACE: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->popup_replace(); + } break; + case SEARCH_LOCATE_FUNCTION: { + + if (!current) + return; + quick_open->popup(current->get_functions()); + } break; + case SEARCH_GOTO_LINE: { + + goto_line_dialog->popup_find_line(current->get_text_edit()); + } break; + case DEBUG_TOGGLE_BREAKPOINT: { + int line=current->get_text_edit()->cursor_get_line(); + bool dobreak = !current->get_text_edit()->is_line_set_as_breakpoint(line); + current->get_text_edit()->set_line_as_breakpoint(line,dobreak); + get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); + } break; + case DEBUG_NEXT: { + + if (debugger) + debugger->debug_next(); + } break; + case DEBUG_STEP: { + + if (debugger) + debugger->debug_step(); + + } break; + case DEBUG_BREAK: { + + if (debugger) + debugger->debug_break(); + + } break; + case DEBUG_CONTINUE: { + + if (debugger) + debugger->debug_continue(); + + } break; + case DEBUG_SHOW: { + if (debugger) { + bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) ); + debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible); + if (visible) + debugger->hide(); + else + debugger->show(); + } + } break; + case HELP_CONTEXTUAL: { + String text = current->get_text_edit()->get_selection_text(); + if (text == "") + text = current->get_text_edit()->get_word_under_cursor(); + if (text != "") + help_search_dialog->popup(text); + } break; + case FILE_CLOSE: { + if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) { + erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); + erase_tab_confirm->popup_centered_minsize(); + } else { + _close_current_tab(); + } + } break; + case WINDOW_MOVE_LEFT: { + + if (tab_container->get_current_tab()>0) { + tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1); + script_list->call_deferred("select",tab_container->get_current_tab()-1); + tab_container->move_child(current,tab_container->get_current_tab()-1); + _update_script_names(); + } + } break; + case WINDOW_MOVE_RIGHT: { + + if (tab_container->get_current_tab()<tab_container->get_child_count()-1) { + tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1); + script_list->call_deferred("select",tab_container->get_current_tab()+1); + tab_container->move_child(current,tab_container->get_current_tab()+1); + _update_script_names(); + } - if (tab_container->get_current_tab()>0) { - tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1); - script_list->call_deferred("select",tab_container->get_current_tab()-1); - tab_container->move_child(current,tab_container->get_current_tab()-1); - _update_script_names(); - } - } break; - case WINDOW_MOVE_RIGHT: { - if (tab_container->get_current_tab()<tab_container->get_child_count()-1) { - tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1); - script_list->call_deferred("select",tab_container->get_current_tab()+1); - tab_container->move_child(current,tab_container->get_current_tab()+1); - _update_script_names(); + } break; + + default: { + + if (p_option>=WINDOW_SELECT_BASE) { + + tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE); + script_list->select(p_option-WINDOW_SELECT_BASE); + + } } + } + } + EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); + if (help) { - } break; - default: { + switch(p_option) { - if (p_option>=WINDOW_SELECT_BASE) { + case SEARCH_FIND: { + help->popup_search(); + } break; + case SEARCH_FIND_NEXT: { + help->search_again(); + } break; + case FILE_CLOSE: { + _close_current_tab(); + } break; - tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE); - script_list->select(p_option-WINDOW_SELECT_BASE); - } } } + } void ScriptEditor::_tab_changed(int p_which) { @@ -1217,6 +1373,14 @@ void ScriptEditor::_notification(int p_what) { } EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); + help_search->set_icon(get_icon("Help","EditorIcons")); + site_search->set_icon(get_icon("Godot","EditorIcons")); + class_search->set_icon(get_icon("ClassList","EditorIcons")); + + script_forward->set_icon(get_icon("Forward","EditorIcons")); + script_back->set_icon(get_icon("Back","EditorIcons")); + + } @@ -1346,7 +1510,7 @@ void ScriptEditor::set_state(const Dictionary& p_state) { } void ScriptEditor::clear() { - +#if 0 List<ScriptTextEditor*> stes; for(int i=0;i<tab_container->get_child_count();i++) { @@ -1371,7 +1535,7 @@ void ScriptEditor::clear() { script_list->select( script_list->find_metadata(idx) ); } - +#endif } @@ -1402,31 +1566,6 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { -void ScriptEditor::_bind_methods() { - - ObjectTypeDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed); - ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); - ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); - ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); - ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); - ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); - ObjectTypeDB::bind_method("_add_callback",&ScriptEditor::_add_callback); - ObjectTypeDB::bind_method("_reload_scripts",&ScriptEditor::_reload_scripts); - ObjectTypeDB::bind_method("_resave_scripts",&ScriptEditor::_resave_scripts); - ObjectTypeDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback); - ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); - ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); - ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); - ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); - ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); - ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); - ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); - ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names); - ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed); - ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected); - ObjectTypeDB::bind_method("_script_created",&ScriptEditor::_script_created); - ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged); -} void ScriptEditor::ensure_focus_current() { @@ -1448,7 +1587,8 @@ void ScriptEditor::ensure_focus_current() { void ScriptEditor::_script_selected(int p_idx) { grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing - tab_container->set_current_tab(script_list->get_item_metadata(p_idx)); + + _go_to_tab(script_list->get_item_metadata(p_idx)); grab_focus_block=false; } @@ -1457,16 +1597,38 @@ void ScriptEditor::ensure_select_current() { if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { - ScriptTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ScriptTextEditor>(); - if (!ste) - return; - Ref<Script> script = ste->get_edited_script(); + Node *current = tab_container->get_child(tab_container->get_current_tab()); + + + ScriptTextEditor *ste = current->cast_to<ScriptTextEditor>(); + if (ste) { + + Ref<Script> script = ste->get_edited_script(); + + if (!grab_focus_block && is_inside_tree()) + ste->get_text_edit()->grab_focus(); + + edit_menu->show(); + search_menu->show(); + script_search_menu->hide(); + + + } + + EditorHelp *eh = current->cast_to<EditorHelp>(); - if (!grab_focus_block && is_inside_tree()) - ste->get_text_edit()->grab_focus(); + if (eh) { + edit_menu->hide(); + search_menu->hide(); + script_search_menu->show(); + + } } + + + } void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> > &used) { @@ -1485,6 +1647,57 @@ void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> } +struct _ScriptEditorItemData { + + String name; + Ref<Texture> icon; + int index; + String tooltip; + bool used; + int category; + + + bool operator<(const _ScriptEditorItemData& id) const { + + return category==id.category?name.nocasecmp_to(id.name)<0:category<id.category; + } + +}; + + +void ScriptEditor::_update_script_colors() { + + bool enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled"); + if (!enabled) + return; + + int hist_size = EditorSettings::get_singleton()->get("text_editor/script_temperature_history_size"); + Color hot_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_hot_color"); + Color cold_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_cold_color"); + + for(int i=0;i<script_list->get_item_count();i++) { + + int c = script_list->get_item_metadata(i); + Node *n = tab_container->get_child(c); + if (!n) + continue; + + script_list->set_item_custom_bg_color(i,Color(0,0,0,0)); + if (!n->has_meta("__editor_pass")) { + continue; + } + + int pass=n->get_meta("__editor_pass"); + int h = edit_pass - pass; + if (h>hist_size) { + continue; + } + float v = Math::ease((edit_pass-pass)/float_t(hist_size),0.4); + + + script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v)); + } +} void ScriptEditor::_update_script_names() { @@ -1496,31 +1709,75 @@ void ScriptEditor::_update_script_names() { } script_list->clear(); + bool split_script_help = EditorSettings::get_singleton()->get("text_editor/group_help_pages"); + + Vector<_ScriptEditorItemData> sedata; + for(int i=0;i<tab_container->get_child_count();i++) { + ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!ste) - continue; + if (ste) { - String script = ste->get_name(); - Ref<Texture> icon = ste->get_icon(); - String path = ste->get_edited_script()->get_path(); - script_list->add_item(script,icon); + String name = ste->get_name(); + Ref<Texture> icon = ste->get_icon(); + String tooltip = ste->get_edited_script()->get_path(); - int index = script_list->get_item_count()-1; + _ScriptEditorItemData sd; + sd.icon=icon; + sd.name=name; + sd.tooltip=tooltip; + sd.index=i; + sd.used=used.has(ste->get_edited_script()); + sd.category=0; + + sedata.push_back(sd); + } - script_list->set_item_tooltip(index,path); - script_list->set_item_metadata(index,i); - if (used.has(ste->get_edited_script())) { + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + if (eh) { + + String name = eh->get_class_name(); + Ref<Texture> icon = get_icon("Help","EditorIcons"); + String tooltip = name+" Class Reference"; + + _ScriptEditorItemData sd; + sd.icon=icon; + sd.name=name; + sd.tooltip=tooltip; + sd.index=i; + sd.used=false; + sd.category=split_script_help?1:0; + sedata.push_back(sd); + + } + + } + + sedata.sort(); + + for(int i=0;i<sedata.size();i++) { + + script_list->add_item(sedata[i].name,sedata[i].icon); + int index = script_list->get_item_count()-1; + script_list->set_item_tooltip(index,sedata[i].tooltip); + script_list->set_item_metadata(index,sedata[i].index); + if (sedata[i].used) { script_list->set_item_custom_bg_color(index,Color(88/255.0,88/255.0,60/255.0)); } - if (tab_container->get_current_tab()==index) { + if (tab_container->get_current_tab()==sedata[i].index) { script_list->select(index); + script_name_label->set_text(sedata[i].name); + script_icon->set_texture(sedata[i].icon); + } } - script_list->sort_items_by_text(); + _update_script_colors(); + + + } @@ -1531,6 +1788,8 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { // see if already has it + bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); + if (p_script->get_path().is_resource_file() && bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) { String path = EditorSettings::get_singleton()->get("external_editor/exec_path"); @@ -1559,12 +1818,13 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { if (ste->get_edited_script()==p_script) { - if (!EditorNode::get_singleton()->is_changing_scene()) { + if (open_dominant || !EditorNode::get_singleton()->is_changing_scene()) { if (tab_container->get_current_tab()!=i) { - tab_container->set_current_tab(i); + _go_to_tab(i); script_list->select( script_list->find_metadata(i) ); } - ste->get_text_edit()->grab_focus(); + if (is_visible()) + ste->get_text_edit()->grab_focus(); } return; } @@ -1576,7 +1836,8 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { ste->set_edited_script(p_script); ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste); tab_container->add_child(ste); - tab_container->set_current_tab(tab_container->get_tab_count()-1); + _go_to_tab(tab_container->get_tab_count()-1); + @@ -1675,7 +1936,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const ste->get_text_edit()->insert_text_at_cursor("\n\n"+func); } - tab_container->set_current_tab(i); + _go_to_tab(i); ste->get_text_edit()->cursor_set_line(pos); ste->get_text_edit()->cursor_set_column(1); @@ -1726,10 +1987,13 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { return; } - if (!p_layout->has_section_key("ScriptEditor","open_scripts")) + if (!p_layout->has_section_key("ScriptEditor","open_scripts") && !p_layout->has_section_key("ScriptEditor","open_help")) return; Array scripts = p_layout->get_value("ScriptEditor","open_scripts"); + Array helps; + if (p_layout->has_section_key("ScriptEditor","open_help")) + helps=p_layout->get_value("ScriptEditor","open_help"); restoring_layout=true; @@ -1742,6 +2006,18 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } } + + for(int i=0;i<helps.size();i++) { + + String path = helps[i]; + _help_class_open(path); + } + + for(int i=0;i<tab_container->get_child_count();i++) { + tab_container->get_child(i)->set_meta("__editor_pass",Variant()); + } + + if (p_layout->has_section_key("ScriptEditor","split_offset")) { script_split->set_split_offset(p_layout->get_value("ScriptEditor","split_offset")); } @@ -1754,27 +2030,184 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { Array scripts; + Array helps; for(int i=0;i<tab_container->get_child_count();i++) { ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!ste) - continue; + if (ste) { - String path = ste->get_edited_script()->get_path(); - if (!path.is_resource_file()) - continue; + String path = ste->get_edited_script()->get_path(); + if (!path.is_resource_file()) + continue; + + scripts.push_back(path); + } + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh) { + + helps.push_back(eh->get_class_name()); + } - scripts.push_back(path); } p_layout->set_value("ScriptEditor","open_scripts",scripts); + p_layout->set_value("ScriptEditor","open_help",helps); p_layout->set_value("ScriptEditor","split_offset",script_split->get_split_offset()); } +void ScriptEditor::_help_class_open(const String& p_class) { + + + for(int i=0;i<tab_container->get_child_count();i++) { + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh && eh->get_class_name()==p_class) { + + _go_to_tab(i); + _update_script_names(); + return; + } + } + + EditorHelp * eh = memnew( EditorHelp ); + + + eh->set_name(p_class); + tab_container->add_child(eh); + _go_to_tab(tab_container->get_tab_count()-1); + eh->go_to_class(p_class,0); + eh->connect("go_to_help",this,"_help_class_goto"); + _update_script_names(); + +} + +void ScriptEditor::_help_class_goto(const String& p_desc) { + + + String cname=p_desc.get_slice(":",1); + + for(int i=0;i<tab_container->get_child_count();i++) { + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh && eh->get_class_name()==cname) { + + _go_to_tab(i); + eh->go_to_help(p_desc); + _update_script_names(); + return; + } + } + + EditorHelp * eh = memnew( EditorHelp ); + + eh->set_name(cname); + tab_container->add_child(eh); + _go_to_tab(tab_container->get_tab_count()-1); + eh->go_to_help(p_desc); + eh->connect("go_to_help",this,"_help_class_goto"); + _update_script_names(); + +} + +void ScriptEditor::_update_history_pos(int p_new_pos) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptTextEditor>()) { + + history[history_pos].scroll_pos=n->cast_to<ScriptTextEditor>()->get_text_edit()->get_v_scroll(); + history[history_pos].cursor_column=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_column(); + history[history_pos].cursor_row=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_line(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].scroll_pos=n->cast_to<EditorHelp>()->get_scroll(); + } + + history_pos=p_new_pos; + tab_container->set_current_tab(history[history_pos].control->get_index()); + + n = history[history_pos].control; + + if (n->cast_to<ScriptTextEditor>()) { + + n->cast_to<ScriptTextEditor>()->get_text_edit()->set_v_scroll(history[history_pos].scroll_pos); + n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_set_column( history[history_pos].cursor_column ); + n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_set_line( history[history_pos].cursor_row ); + n->cast_to<ScriptTextEditor>()->get_text_edit()->grab_focus(); + } + + if (n->cast_to<EditorHelp>()) { + + n->cast_to<EditorHelp>()->set_scroll(history[history_pos].scroll_pos); + n->cast_to<EditorHelp>()->set_focused(); + } + + n->set_meta("__editor_pass",++edit_pass); + _update_script_names(); + _update_history_arrows(); + +} + +void ScriptEditor::_history_forward() { + + if (history_pos<history.size()-1) { + _update_history_pos(history_pos+1); + } +} + +void ScriptEditor::_history_back(){ + + if (history_pos>0) { + _update_history_pos(history_pos-1); + } + +} +void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) { + + bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); + if (open_dominant && p_script.is_valid()) { + edit(p_script); + } +} + +void ScriptEditor::_bind_methods() { + + ObjectTypeDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed); + ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); + ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); + ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); + ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); + ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); + ObjectTypeDB::bind_method("_add_callback",&ScriptEditor::_add_callback); + ObjectTypeDB::bind_method("_reload_scripts",&ScriptEditor::_reload_scripts); + ObjectTypeDB::bind_method("_resave_scripts",&ScriptEditor::_resave_scripts); + ObjectTypeDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback); + ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); + ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); + ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); + ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); + ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); + ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); + ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); + ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names); + ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed); + ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected); + ObjectTypeDB::bind_method("_script_created",&ScriptEditor::_script_created); + ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged); + ObjectTypeDB::bind_method("_help_class_open",&ScriptEditor::_help_class_open); + ObjectTypeDB::bind_method("_help_class_goto",&ScriptEditor::_help_class_goto); + ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward); + ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back); +} ScriptEditor::ScriptEditor(EditorNode *p_editor) { @@ -1816,6 +2249,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_item("Save As..",FILE_SAVE_AS); file_menu->get_popup()->add_item("Save All",FILE_SAVE_ALL,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S); file_menu->get_popup()->add_separator(); + file_menu->get_popup()->add_item("History Prev",WINDOW_PREV,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT); + file_menu->get_popup()->add_item("History Next",WINDOW_NEXT,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT); + file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_item("Close",FILE_CLOSE,KEY_MASK_CMD|KEY_W); file_menu->get_popup()->connect("item_pressed", this,"_menu_option"); @@ -1851,13 +2287,22 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(search_menu); search_menu->set_text("Search"); search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); - search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_MASK_CMD|KEY_G); + search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); search_menu->get_popup()->add_item("Replace..",SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); search_menu->get_popup()->add_separator(); search_menu->get_popup()->add_item("Goto Function..",SEARCH_LOCATE_FUNCTION,KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F); search_menu->get_popup()->add_item("Goto Line..",SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_L); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + script_search_menu = memnew( MenuButton ); + menu_hb->add_child(script_search_menu); + script_search_menu->set_text("Search"); + script_search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); + script_search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); + script_search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + script_search_menu->hide(); + + debug_menu = memnew( MenuButton ); menu_hb->add_child(debug_menu); debug_menu->set_text("Debug"); @@ -1897,6 +2342,53 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { help_menu->get_popup()->add_item("Contextual", HELP_CONTEXTUAL, KEY_MASK_SHIFT|KEY_F1); help_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + menu_hb->add_spacer(); + + + script_icon = memnew( TextureFrame ); + menu_hb->add_child(script_icon); + script_name_label = memnew( Label ); + menu_hb->add_child(script_name_label); + + script_icon->hide(); + script_name_label->hide(); + + menu_hb->add_spacer(); + + site_search = memnew( ToolButton ); + site_search->set_text("Tutorials"); + site_search->connect("pressed",this,"_menu_option",varray(SEARCH_WEBSITE)); + menu_hb->add_child(site_search); + site_search->set_tooltip("Open http://www.godotengine.org at tutorials section."); + + class_search = memnew( ToolButton ); + class_search->set_text("Classes"); + class_search->connect("pressed",this,"_menu_option",varray(SEARCH_CLASSES)); + menu_hb->add_child(class_search); + class_search->set_tooltip("Search the class hierarchy."); + + help_search = memnew( ToolButton ); + help_search->set_text("Search Help"); + help_search->connect("pressed",this,"_menu_option",varray(SEARCH_HELP)); + menu_hb->add_child(help_search); + help_search->set_tooltip("Search the reference documentation."); + + menu_hb->add_child( memnew( VSeparator) ); + + script_back = memnew( ToolButton ); + script_back->connect("pressed",this,"_history_back"); + menu_hb->add_child(script_back); + script_back->set_disabled(true); + help_search->set_tooltip("Go to previous edited document."); + + script_forward = memnew( ToolButton ); + script_forward->connect("pressed",this,"_history_forward"); + menu_hb->add_child(script_forward); + script_forward->set_disabled(true); + help_search->set_tooltip("Go to next edited document."); + + + tab_container->connect("tab_changed", this,"_tab_changed"); find_replace_dialog = memnew(FindReplaceDialog); @@ -1959,8 +2451,20 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { grab_focus_block=false; + help_search_dialog = memnew( EditorHelpSearch ); + add_child(help_search_dialog); + help_search_dialog->connect("go_to_help",this,"_help_class_goto"); + + + help_index = memnew( EditorHelpIndex ); + add_child(help_index); + help_index->connect("open_class",this,"_help_class_open"); + + history_pos=-1; // debugger_gui->hide(); + edit_pass=0; + } @@ -2062,8 +2566,14 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { script_editor->hide(); EDITOR_DEF("text_editor/auto_reload_changed_scripts",false); + EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true); EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); + EDITOR_DEF("text_editor/script_temperature_enabled",true); + EDITOR_DEF("text_editor/script_temperature_history_size",15); + EDITOR_DEF("text_editor/script_temperature_hot_color",Color(1,0,0,0.3)); + EDITOR_DEF("text_editor/script_temperature_cold_color",Color(0,0,1,0.3)); + EDITOR_DEF("text_editor/group_help_pages",false); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("external_editor/exec_flags",""); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index e635a1974b..e755f570ef 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -41,6 +41,7 @@ #include "tools/editor/code_editor.h" #include "scene/gui/split_container.h" #include "scene/gui/item_list.h" +#include "tools/editor/editor_help.h" class ScriptEditorQuickOpen : public ConfirmationDialog { @@ -141,6 +142,9 @@ class ScriptEditor : public VBoxContainer { SEARCH_REPLACE, SEARCH_LOCATE_FUNCTION, SEARCH_GOTO_LINE, + SEARCH_HELP, + SEARCH_CLASSES, + SEARCH_WEBSITE, DEBUG_TOGGLE_BREAKPOINT, DEBUG_NEXT, DEBUG_STEP, @@ -150,6 +154,8 @@ class ScriptEditor : public VBoxContainer { HELP_CONTEXTUAL, WINDOW_MOVE_LEFT, WINDOW_MOVE_RIGHT, + WINDOW_NEXT, + WINDOW_PREV, WINDOW_SELECT_BASE=100 }; @@ -157,11 +163,17 @@ class ScriptEditor : public VBoxContainer { MenuButton *file_menu; MenuButton *edit_menu; MenuButton *search_menu; + MenuButton *script_search_menu; MenuButton *debug_menu; MenuButton *help_menu; Timer *autosave_timer; uint64_t idle; + Button *help_search; + Button *site_search; + Button *class_search; + EditorHelpSearch *help_search_dialog; + ItemList *script_list; HSplitContainer *script_split; TabContainer *tab_container; @@ -172,6 +184,27 @@ class ScriptEditor : public VBoxContainer { ScriptEditorDebugger* debugger; ToolButton *scripts_visible; + TextureFrame *script_icon; + Label *script_name_label; + + ToolButton *script_back; + ToolButton *script_forward; + + + struct ScriptHistory { + + Control *control; + int scroll_pos; + int cursor_column; + int cursor_row; + }; + + Vector<ScriptHistory> history; + int history_pos; + + + EditorHelpIndex *help_index; + void _tab_changed(int p_which); void _menu_option(int p_optin); @@ -201,6 +234,8 @@ class ScriptEditor : public VBoxContainer { void _editor_pause(); void _editor_stop(); + int edit_pass; + void _add_callback(Object *p_obj, const String& p_function, const StringArray& p_args); void _res_saved_callback(const Ref<Resource>& p_res); @@ -224,8 +259,20 @@ class ScriptEditor : public VBoxContainer { void _script_split_dragged(float); + + void _history_forward(); + void _history_back(); + bool waiting_update_names; + void _help_class_open(const String& p_class); + void _help_class_goto(const String& p_desc); + void _update_history_arrows(); + void _go_to_tab(int p_idx); + void _update_history_pos(int p_new_pos); + void _update_script_colors(); + + static ScriptEditor *script_editor; protected: void _notification(int p_what); @@ -253,6 +300,8 @@ public: void set_window_layout(Ref<ConfigFile> p_layout); void get_window_layout(Ref<ConfigFile> p_layout); + void set_scene_root_script( Ref<Script> p_script ); + ScriptEditorDebugger *get_debugger() { return debugger; } ScriptEditor(EditorNode *p_editor); diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index 684e7e32ef..3a7dc26466 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -2542,7 +2542,7 @@ void ShaderGraphView::_notification(int p_what) { void ShaderGraphView::add_node(int p_type, const Vector2 &location) { - if ((p_type==ShaderGraph::NODE_INPUT||p_type==ShaderGraph::NODE_INPUT) && graph->node_count(type, p_type)>0) + if (p_type==ShaderGraph::NODE_INPUT && graph->node_count(type, p_type)>0) return; List<int> existing; diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 3ab9339265..f3458a768a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2725,7 +2725,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_TRANSFORM_CONFIGURE_SNAP: { - snap_dialog->popup_centered(Size2(200,160)); + snap_dialog->popup_centered(Size2(200,180)); } break; case MENU_TRANSFORM_LOCAL_COORDS: { @@ -3793,46 +3793,24 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { snap_dialog = memnew( ConfirmationDialog ); snap_dialog->set_title("Snap Settings"); add_child(snap_dialog); - Label *l = memnew(Label); - l->set_text("Translate Snap:"); - l->set_pos(Point2(5,5)); - snap_dialog->add_child(l); + + VBoxContainer *snap_dialog_vbc = memnew( VBoxContainer ); + snap_dialog->add_child(snap_dialog_vbc); + snap_dialog->set_child_rect(snap_dialog_vbc); snap_translate = memnew( LineEdit ); - snap_translate->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - snap_translate->set_begin( Point2(15,22) ); - snap_translate->set_end( Point2(15,35) ); snap_translate->set_text("1"); - snap_dialog->add_child(snap_translate); - - l = memnew(Label); - l->set_text("Rotate Snap (deg.):"); - l->set_pos(Point2(5,45)); - snap_dialog->add_child(l); + snap_dialog_vbc->add_margin_child("Translate Snap:",snap_translate); snap_rotate = memnew( LineEdit ); - snap_rotate->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - snap_rotate->set_begin( Point2(15,62) ); - snap_rotate->set_end( Point2(15,75) ); snap_rotate->set_text("5"); - snap_dialog->add_child(snap_rotate); - - - l = memnew(Label); - l->set_text("Scale Snap (%):"); - l->set_pos(Point2(5,85)); - snap_dialog->add_child(l); + snap_dialog_vbc->add_margin_child("Rotate Snap (deg.):",snap_rotate); snap_scale = memnew( LineEdit ); - snap_scale->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - snap_scale->set_begin( Point2(15,102) ); - snap_scale->set_end( Point2(15,115) ); snap_scale->set_text("5"); - snap_dialog->add_child(snap_scale); + snap_dialog_vbc->add_margin_child("Scale Snap (%):",snap_scale); - //snap_dialog->get_cancel()->hide(); - - /* SNAP DIALOG */ + /* SETTINGS DIALOG */ settings_dialog = memnew( ConfirmationDialog ); settings_dialog->set_title("Viewport Settings"); @@ -3906,7 +3884,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { xform_dialog = memnew( ConfirmationDialog ); xform_dialog->set_title("Transform Change"); add_child(xform_dialog); - l = memnew(Label); + Label *l = memnew(Label); l->set_text("Translate:"); l->set_pos(Point2(5,5)); xform_dialog->add_child(l); diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 55e8f164d6..63ba57bfc0 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -568,26 +568,24 @@ ThemeEditor::ThemeEditor() { CheckButton *cb = memnew( CheckButton ); cb->set_text("CheckButton"); first_vb->add_child(cb ); - CheckBox *cbx = memnew( CheckBox ); - cbx->set_text("CheckBox"); - first_vb->add_child(cbx ); - - /* TODO: This is not working properly, controls are overlapping*/ - /* - ButtonGroup *bg = memnew( ButtonGroup ); - bg->set_v_size_flags(SIZE_EXPAND_FILL); - VBoxContainer *gbvb = memnew( VBoxContainer ); - gbvb->set_v_size_flags(SIZE_EXPAND_FILL); - CheckBox *rbx1 = memnew( CheckBox ); - rbx1->set_text("CheckBox Radio1"); - rbx1->set_pressed(true); - gbvb->add_child(rbx1); - CheckBox *rbx2 = memnew( CheckBox ); - rbx2->set_text("CheckBox Radio2"); - gbvb->add_child(rbx2); - bg->add_child(gbvb); - first_vb->add_child(bg); - */ + CheckBox *cbx = memnew( CheckBox ); + cbx->set_text("CheckBox"); + first_vb->add_child(cbx ); + + + ButtonGroup *bg = memnew( ButtonGroup ); + bg->set_v_size_flags(SIZE_EXPAND_FILL); + VBoxContainer *gbvb = memnew( VBoxContainer ); + gbvb->set_v_size_flags(SIZE_EXPAND_FILL); + CheckBox *rbx1 = memnew( CheckBox ); + rbx1->set_text("CheckBox Radio1"); + rbx1->set_pressed(true); + gbvb->add_child(rbx1); + CheckBox *rbx2 = memnew( CheckBox ); + rbx2->set_text("CheckBox Radio2"); + gbvb->add_child(rbx2); + bg->add_child(gbvb); + first_vb->add_child(bg); MenuButton* test_menu_button = memnew( MenuButton ); test_menu_button->set_text("MenuButton"); diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index 39b0ef3c75..09115472a8 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -110,11 +110,15 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me if (!child2->cast_to<StaticBody2D>()) continue; StaticBody2D *sb = child2->cast_to<StaticBody2D>(); - if (sb->get_shape_count()==0) + int shape_count = sb->get_shape_count(); + if (shape_count==0) continue; - Ref<Shape2D> collision=sb->get_shape(0); - if (collision.is_valid()) { - collisions.push_back(collision); + for (int shape_index=0; shape_index<shape_count; ++shape_index) + { + Ref<Shape2D> collision=sb->get_shape(shape_index); + if (collision.is_valid()) { + collisions.push_back(collision); + } } } |