diff options
-rw-r--r-- | core/io/http_client.cpp | 6 | ||||
-rw-r--r-- | core/io/json.cpp | 4 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 16 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 7 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 17 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 3 | ||||
-rw-r--r-- | scene/2d/screen_button.cpp | 209 | ||||
-rw-r--r-- | scene/2d/screen_button.h | 15 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 39 | ||||
-rw-r--r-- | scene/gui/texture_button.cpp | 146 | ||||
-rw-r--r-- | scene/gui/texture_button.h | 17 | ||||
-rw-r--r-- | scene/gui/texture_rect.cpp | 14 | ||||
-rw-r--r-- | scene/gui/texture_rect.h | 2 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_pitch_shift.cpp | 2 | ||||
-rw-r--r-- | servers/audio/effects/eq.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 2 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 37 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 1 | ||||
-rw-r--r-- | tools/editor/editor_settings.cpp | 24 | ||||
-rw-r--r-- | tools/editor/editor_settings.h | 4 | ||||
-rw-r--r-- | tools/editor/plugins/gi_probe_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/script_create_dialog.cpp | 4 |
23 files changed, 391 insertions, 188 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 63c8abbbad..fd06d27c1f 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -566,11 +566,13 @@ PoolByteArray HTTPClient::read_response_body_chunk() { int to_read = MIN(body_left,read_chunk_size); PoolByteArray ret; ret.resize(to_read); - PoolByteArray::Write w = ret.write(); int _offset = 0; while (to_read > 0) { int rec=0; - err = _get_http_data(w.ptr()+_offset,to_read,rec); + { + PoolByteArray::Write w = ret.write(); + err = _get_http_data(w.ptr()+_offset,to_read,rec); + } if (rec>0) { body_left-=rec; to_read-=rec; diff --git a/core/io/json.cpp b/core/io/json.cpp index ac5b8f1e5f..5ade25aab4 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -374,7 +374,7 @@ Error JSON::_parse_array(Array &array,const CharType *p_str,int &index, int p_le } - return OK; + return ERR_PARSE_ERROR; } @@ -446,7 +446,7 @@ Error JSON::_parse_object(Dictionary &object,const CharType *p_str,int &index, i } } - return OK; + return ERR_PARSE_ERROR; } diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index cc69283f97..edf5f22714 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -117,7 +117,13 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) { return 0; } - +// Very simple signal handler to reap processes where ::execute was called with +// !p_blocking +void handle_sigchld(int sig) { + int saved_errno = errno; + while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {} + errno = saved_errno; +} void OS_Unix::initialize_core() { @@ -148,6 +154,14 @@ void OS_Unix::initialize_core() { ticks_start=0; ticks_start=get_ticks_usec(); + + struct sigaction sa; + sa.sa_handler = &handle_sigchld; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART | SA_NOCLDSTOP; + if (sigaction(SIGCHLD, &sa, 0) == -1) { + perror("ERROR sigaction() failed:"); + } } void OS_Unix::finalize_core() { diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 34c39c8024..c1c1f5d5a9 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2577,7 +2577,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { Vector<Node*> args; Vector<double> constants; - bool constant=true; + bool constant=false; for(int i=1;i<op->arguments.size();i++) { args.push_back(op->arguments[i]); @@ -2585,13 +2585,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { ConstantNode *c = static_cast<ConstantNode*>(op->arguments[i]); if (c->value.get_type()==Variant::REAL || c->value.get_type()==Variant::INT) { constants.push_back(c->value); - } else { - constant=false; + constant=true; } } } - if (args.size()>0 || args.size()<4) { + if (args.size()>0 && args.size()<4) { if (constant) { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index b230dda9cb..b39d6f664f 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1092,11 +1092,6 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ RasterizerGLES3::register_config(); RasterizerGLES3::make_current(); -#else - // FIXME: Does DX support still work now that rasterizer is no longer used? -#ifdef DX9_ENABLED - rasterizer = memnew( RasterizerDX9(hWnd) ); -#endif #endif visual_server = memnew( VisualServerRaster ); @@ -1268,8 +1263,6 @@ void OS_Windows::finalize() { if (gl_context) memdelete(gl_context); #endif - if (rasterizer) - memdelete(rasterizer); if (user_proc) { SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); @@ -1289,6 +1282,11 @@ void OS_Windows::finalize() { monitor_info.clear(); + for (int i = 0; i < get_audio_driver_count(); i++) + { + AudioDriverManager::get_driver(i)->finish(); + } + } void OS_Windows::finalize_core() { @@ -2395,6 +2393,11 @@ bool OS_Windows::is_vsync_enabled() const{ return true; } +bool OS_Windows::check_feature_support(const String& p_feature) { + + return VisualServer::get_singleton()->has_os_feature(p_feature); + +} OS_Windows::OS_Windows(HINSTANCE _hInstance) { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 2c8fa64f8e..73a2d5f451 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -92,7 +92,6 @@ class OS_Windows : public OS { ContextGL_Win *gl_context; #endif VisualServer *visual_server; - Rasterizer *rasterizer; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; int pressrc; @@ -286,6 +285,8 @@ public: virtual void set_use_vsync(bool p_enable); virtual bool is_vsync_enabled() const; + virtual bool check_feature_support(const String& p_feature); + OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index 20db63b66f..94678e5e94 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -63,6 +63,38 @@ Ref<BitMap> TouchScreenButton::get_bitmask() const{ return bitmask; } +void TouchScreenButton::set_shape(const Ref<Shape2D>& p_shape){ + + shape=p_shape; + + if (!is_inside_tree()) + return; + if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) + return; + update(); +} + +Ref<Shape2D> TouchScreenButton::get_shape() const{ + + return shape; +} + +void TouchScreenButton::set_shape_centered(bool p_shape_centered) { + + shape_centered=p_shape_centered; + + if (!is_inside_tree()) + return; + if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) + return; + update(); +} + +bool TouchScreenButton::is_shape_centered() const { + + return shape_centered; +} + void TouchScreenButton::_notification(int p_what) { switch(p_what) { @@ -86,6 +118,15 @@ void TouchScreenButton::_notification(int p_what) { draw_texture(texture,Point2()); } + if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) + return; + if (shape.is_valid()) { + Color draw_col=get_tree()->get_debug_collisions_color(); + Vector2 pos=shape_centered ? get_item_rect().size*0.5f : Vector2(); + draw_set_transform_matrix(get_canvas_transform().translated(pos)); + shape->draw(get_canvas_item(),draw_col); + } + } break; case NOTIFICATION_ENTER_TREE: { @@ -104,8 +145,12 @@ void TouchScreenButton::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { if (is_pressed()) - Input::get_singleton()->action_release(action); + _release(true); } break; + case NOTIFICATION_PAUSED: { + // So the button can be pressed again even though the release gets unhandled because of coming during pause + allow_repress=true; + } } } @@ -143,22 +188,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (p_event.type==InputEvent::SCREEN_TOUCH && !p_event.screen_touch.pressed && finger_pressed==p_event.screen_touch.index) { - emit_signal("released"); - - if (action_id!=-1) { - - Input::get_singleton()->action_release(action); - InputEvent ie; - ie.type=InputEvent::ACTION; - ie.ID=0; - ie.action.action=action_id; - ie.action.pressed=false; - get_tree()->input_event(ie); - } - finger_pressed=-1; - - update(); - + _release(); } if ((p_event.type==InputEvent::SCREEN_TOUCH && p_event.screen_touch.pressed)|| p_event.type==InputEvent::SCREEN_DRAG) { @@ -184,44 +214,12 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (touched) { - if (finger_pressed==-1) { - finger_pressed=p_event.screen_touch.index; - //emit change stuff - emit_signal("pressed"); - if (action_id!=-1) { - - Input::get_singleton()->action_press(action); - InputEvent ie; - ie.type=InputEvent::ACTION; - ie.ID=0; - ie.action.action=action_id; - ie.action.pressed=true; - get_tree()->input_event(ie); - } - - update(); + _press(p_event.screen_touch.index); } - } else { - if (finger_pressed!=-1) { - - emit_signal("released"); - - if (action_id!=-1) { - - Input::get_singleton()->action_release(action); - InputEvent ie; - ie.type=InputEvent::ACTION; - ie.ID=0; - ie.action.action=action_id; - ie.action.pressed=false; - get_tree()->input_event(ie); - } - finger_pressed=-1; - - update(); + _release(); } } @@ -239,67 +237,88 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (!is_visible_in_tree()) return; - if (finger_pressed!=-1) + const bool can_press=finger_pressed==-1 || allow_repress; + if (!can_press) return; //already fingering Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); + Rect2 item_rect = get_item_rect(); bool touched=false; + bool check_rect=true; + if (shape.is_valid()) { + + check_rect=false; + Transform2D xform=shape_centered ? Transform2D().translated(get_item_rect().size*0.5f) : Transform2D(); + touched=shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5,0.5))); + } + if (bitmask.is_valid()) { - if (Rect2(Point2(),bitmask->get_size()).has_point(coord)) { + check_rect=false; + if (!touched && Rect2(Point2(),bitmask->get_size()).has_point(coord)) { if (bitmask->get_bit(coord)) touched=true; } - } else { - if (!texture.is_null()) - touched=Rect2(Point2(),texture->get_size()).has_point(coord); } + if (!touched && check_rect) { + if (!texture.is_null()) + touched=item_rect.has_point(coord); + } if (touched) { - - finger_pressed=p_event.screen_touch.index; - //emit change stuff - emit_signal("pressed"); - if (action_id!=-1) { - - Input::get_singleton()->action_press(action); - InputEvent ie; - ie.type=InputEvent::ACTION; - ie.ID=0; - ie.action.action=action_id; - ie.action.pressed=true; - get_tree()->input_event(ie); - } - update(); - + _press(p_event.screen_touch.index); } } else { + if (p_event.screen_touch.index==finger_pressed) { + _release(); + } + } + } + } +} +void TouchScreenButton::_press(int p_finger_pressed) { - if (p_event.screen_touch.index==finger_pressed) { - //untouch + finger_pressed=p_finger_pressed; + allow_repress=false; - emit_signal("released"); + if (action_id!=-1) { - if (action_id!=-1) { + Input::get_singleton()->action_press(action); + InputEvent ie; + ie.type=InputEvent::ACTION; + ie.ID=0; + ie.action.action=action_id; + ie.action.pressed=true; + get_tree()->input_event(ie); + } - Input::get_singleton()->action_release(action); - InputEvent ie; - ie.type=InputEvent::ACTION; - ie.ID=0; - ie.action.action=action_id; - ie.action.pressed=false; - get_tree()->input_event(ie); - } - finger_pressed=-1; - update(); - } - } - } + emit_signal("pressed"); + update(); +} + +void TouchScreenButton::_release(bool p_exiting_tree) { + + finger_pressed=-1; + + if (action_id!=-1) { + + Input::get_singleton()->action_release(action); + InputEvent ie; + ie.type=InputEvent::ACTION; + ie.ID=0; + ie.action.action=action_id; + ie.action.pressed=false; + get_tree()->input_event(ie); + } + + if (!p_exiting_tree) { + emit_signal("released"); + update(); } } @@ -349,6 +368,12 @@ void TouchScreenButton::_bind_methods() { ClassDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask); ClassDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask); + ClassDB::bind_method(_MD("set_shape","shape"),&TouchScreenButton::set_shape); + ClassDB::bind_method(_MD("get_shape"),&TouchScreenButton::get_shape); + + ClassDB::bind_method(_MD("set_shape_centered","bool"),&TouchScreenButton::set_shape_centered); + ClassDB::bind_method(_MD("is_shape_centered"),&TouchScreenButton::is_shape_centered); + ClassDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action); ClassDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action); @@ -365,6 +390,8 @@ void TouchScreenButton::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture_pressed"),_SCS("get_texture_pressed")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"bitmask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"),_SCS("set_bitmask"),_SCS("get_bitmask")); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shape_centered"),_SCS("set_shape_centered"),_SCS("is_shape_centered")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"passby_press"),_SCS("set_passby_press"),_SCS("is_passby_press_enabled")); ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),_SCS("set_action"),_SCS("get_action")); ADD_PROPERTY( PropertyInfo(Variant::INT,"visibility_mode",PROPERTY_HINT_ENUM,"Always,TouchScreen Only"),_SCS("set_visibility_mode"),_SCS("get_visibility_mode")); @@ -379,7 +406,11 @@ void TouchScreenButton::_bind_methods() { TouchScreenButton::TouchScreenButton() { finger_pressed=-1; + allow_repress=false; action_id=-1; passby_press=false; visibility=VISIBILITY_ALWAYS; + shape_centered=true; + unit_rect=Ref<RectangleShape2D>(memnew(RectangleShape2D)); + unit_rect->set_extents(Vector2(0.5,0.5)); } diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index 34e02d644b..8ce378c660 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -32,6 +32,7 @@ #include "scene/2d/node_2d.h" #include "scene/resources/texture.h" #include "scene/resources/bit_mask.h" +#include "scene/resources/rectangle_shape_2d.h" class TouchScreenButton : public Node2D { @@ -47,16 +48,24 @@ private: Ref<Texture> texture; Ref<Texture> texture_pressed; Ref<BitMap> bitmask; + Ref<Shape2D> shape; + bool shape_centered; + + Ref<RectangleShape2D> unit_rect; StringName action; bool passby_press; int finger_pressed; + bool allow_repress; int action_id; VisibilityMode visibility; void _input(const InputEvent& p_Event); + void _press(int p_finger_pressed); + void _release(bool p_exiting_tree=false); + protected: void _notification(int p_what); @@ -73,6 +82,12 @@ public: void set_bitmask(const Ref<BitMap>& p_bitmask); Ref<BitMap> get_bitmask() const; + void set_shape(const Ref<Shape2D>& p_shape); + Ref<Shape2D> get_shape() const; + + void set_shape_centered(bool p_shape_centered); + bool is_shape_centered() const; + void set_action(const String& p_action); String get_action() const; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 0916119db3..bd126beef4 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -405,9 +405,9 @@ Variant Tween::_run_equation(InterpolateData& p_data) { case Variant::TRANSFORM2D: { - Basis i = initial_val; - Basis d = delta_val; - Basis r; + Transform2D i = initial_val; + Transform2D d = delta_val; + Transform2D r; APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(elements[0][1]); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6036b3f9df..4ca95294ca 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2431,6 +2431,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); } break; #else @@ -2440,25 +2442,30 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) { if (k.mod.shift) _pre_shift_selection(); - // compute whitespace symbols seq length - int current_line_whitespace_len = 0; - while(current_line_whitespace_len < text[cursor.line].length()) { - CharType c = text[cursor.line][current_line_whitespace_len]; - if(c != '\t' && c != ' ') - break; - current_line_whitespace_len++; - } - - if(cursor_get_column() == current_line_whitespace_len) + if (k.mod.command) { + cursor_set_line(0); cursor_set_column(0); - else - cursor_set_column(current_line_whitespace_len); + } + else { + // compute whitespace symbols seq length + int current_line_whitespace_len = 0; + while( current_line_whitespace_len < text[cursor.line].length() ) { + CharType c = text[cursor.line][current_line_whitespace_len]; + if( c != '\t' && c != ' ' ) + break; + current_line_whitespace_len++; + } - if (k.mod.command) - cursor_set_line(0); + if( cursor_get_column() == current_line_whitespace_len ) + cursor_set_column(0); + else + cursor_set_column(current_line_whitespace_len); + } if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); _cancel_completion(); completion_hint=""; @@ -2481,6 +2488,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); } break; #else @@ -2495,6 +2504,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) { if (k.mod.shift) _post_shift_selection(); + else if(k.mod.command || k.mod.control) + deselect(); _cancel_completion(); completion_hint=""; diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 03e37e9d9f..fb6262eff8 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -28,40 +28,35 @@ /*************************************************************************/ #include "texture_button.h" - Size2 TextureButton::get_minimum_size() const { - Size2 rscale; - if (normal.is_null()) { - if (pressed.is_null()) { - if (hover.is_null()) - if (click_mask.is_null()) - rscale= Size2(); + Size2 rscale = Control::get_minimum_size(); + + if (!expand) { + if (normal.is_null()) { + if (pressed.is_null()) { + if (hover.is_null()) + if (click_mask.is_null()) + rscale= Size2(); + else + rscale= click_mask->get_size(); else - rscale= click_mask->get_size(); - else - rscale= hover->get_size(); - } else - rscale=pressed->get_size(); + rscale= hover->get_size(); + } else + rscale=pressed->get_size(); - } else - rscale= normal->get_size(); + } else + rscale= normal->get_size(); + } - return rscale*scale.abs(); + return rscale.abs(); } - bool TextureButton::has_point(const Point2& p_point) const { - if (scale[0] == 0 || scale[1] == 0) { - return false; - } - - Point2 ppos = p_point/scale.abs(); - if (click_mask.is_valid()) { - Point2i p =ppos; + Point2i p =p_point; if (p.x<0 || p.x>=click_mask->get_size().width || p.y<0 || p.y>=click_mask->get_size().height) return false; @@ -119,17 +114,67 @@ void TextureButton::_notification(int p_what) { } if (texdraw.is_valid()) { - Rect2 drect(Point2(),texdraw->get_size()*scale); - draw_texture_rect(texdraw,drect,false); - + Point2 ofs; + Size2 size = texdraw->get_size(); + Rect2 tex_regin = Rect2(Point2(), texdraw->get_size()); + bool tile = false; + if (expand) { + switch (stretch_mode) { + case StretchMode::STRETCH_KEEP: + size = texdraw->get_size(); + break; + case StretchMode::STRETCH_SCALE_ON_EXPAND: + case StretchMode::STRETCH_SCALE: + size = get_size(); + break; + case StretchMode::STRETCH_TILE: + size = get_size(); + tile = true; + break; + case StretchMode::STRETCH_KEEP_CENTERED: + ofs = (get_size() - texdraw->get_size())/2; + size = texdraw->get_size(); + break; + case StretchMode::STRETCH_KEEP_ASPECT_CENTERED: + case StretchMode::STRETCH_KEEP_ASPECT: { + Size2 _size=get_size(); + float tex_width = texdraw->get_width() * _size.height / texdraw->get_height(); + float tex_height = _size.height; + + if (tex_width > _size.width) { + tex_width = _size.width; + tex_height = texdraw->get_height() * tex_width / texdraw->get_width(); + } + + if (stretch_mode==StretchMode::STRETCH_KEEP_ASPECT_CENTERED) { + ofs.x = (_size.width - tex_width)/2; + ofs.y = (_size.height - tex_height)/2; + } + size.width = tex_width; + size.height = tex_height; + } break; + case StretchMode::STRETCH_KEEP_ASPECT_COVERED:{ + size = get_size(); + Size2 tex_size = texdraw->get_size(); + Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height); + float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height; + Size2 scaledTexSize = tex_size * scale; + Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f; + tex_regin = Rect2(ofs, size/scale); + } break; + } + } + if (tile) + draw_texture_rect(texdraw,Rect2(ofs,size),tile); + else + draw_texture_rect_region(texdraw, Rect2(ofs, size), tex_regin); } if (has_focus() && focused.is_valid()) { - Rect2 drect(Point2(),focused->get_size()*scale); + Rect2 drect(Point2(), get_size()); draw_texture_rect(focused,drect,false); }; - } break; } } @@ -142,7 +187,8 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture); ClassDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture); ClassDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask); - ClassDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale); + ClassDB::bind_method(_MD("set_expand","p_expand"),&TextureButton::set_expand); + ClassDB::bind_method(_MD("set_stretch_mode","p_mode"),&TextureButton::set_stretch_mode); ClassDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture); ClassDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture); @@ -150,7 +196,8 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture); ClassDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture); ClassDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask); - ClassDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale); + ClassDB::bind_method(_MD("get_expand"),&TextureButton::get_expand); + ClassDB::bind_method(_MD("get_stretch_mode"),&TextureButton::get_stretch_mode); ADD_GROUP("Textures","texture_"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); @@ -159,7 +206,25 @@ void TextureButton::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; - ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"texture_scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale")); + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"expand",PROPERTY_HINT_RESOURCE_TYPE,"bool"), _SCS("set_expand"), _SCS("get_expand")) ; + ADD_PROPERTYNO(PropertyInfo(Variant::INT,"stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"), _SCS("get_stretch_mode")); + + const int STRETCH_SCALE_ON_EXPAND = StretchMode::STRETCH_SCALE_ON_EXPAND; + const int STRETCH_SCALE = StretchMode::STRETCH_SCALE; + const int STRETCH_TILE = StretchMode::STRETCH_TILE; + const int STRETCH_KEEP = StretchMode::STRETCH_KEEP; + const int STRETCH_KEEP_CENTERED = StretchMode::STRETCH_KEEP_CENTERED; + const int STRETCH_KEEP_ASPECT = StretchMode::STRETCH_KEEP_ASPECT; + const int STRETCH_KEEP_ASPECT_CENTERED = StretchMode::STRETCH_KEEP_ASPECT_CENTERED; + const int STRETCH_KEEP_ASPECT_COVERED = StretchMode::STRETCH_KEEP_ASPECT_COVERED; + BIND_CONSTANT(STRETCH_SCALE_ON_EXPAND); + BIND_CONSTANT(STRETCH_SCALE); + BIND_CONSTANT(STRETCH_TILE); + BIND_CONSTANT(STRETCH_KEEP); + BIND_CONSTANT(STRETCH_KEEP_CENTERED); + BIND_CONSTANT(STRETCH_KEEP_ASPECT); + BIND_CONSTANT(STRETCH_KEEP_ASPECT_CENTERED); + BIND_CONSTANT(STRETCH_KEEP_ASPECT_COVERED); } @@ -227,19 +292,26 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) { focused = p_focused; }; -void TextureButton::set_texture_scale(Size2 p_scale) { +bool TextureButton::get_expand() const { + return expand; +} - scale=p_scale; +void TextureButton::set_expand(bool p_expand) { + expand = p_expand; minimum_size_changed(); update(); } -Size2 TextureButton::get_texture_scale() const{ +void TextureButton::set_stretch_mode(TextureButton::StretchMode p_mode) { + stretch_mode = p_mode; + update(); +} - return scale; +TextureButton::StretchMode TextureButton::get_stretch_mode() const { + return stretch_mode; } TextureButton::TextureButton() { - scale=Size2(1.0, 1.0); - + expand = false; + stretch_mode = StretchMode::STRETCH_SCALE_ON_EXPAND; } diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index ef4d4d5b5b..e1d1079ceb 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -31,22 +31,28 @@ #include "scene/gui/base_button.h" #include "scene/resources/bit_mask.h" +#include "scene/gui/texture_rect.h" class TextureButton : public BaseButton { GDCLASS( TextureButton, BaseButton ); +public: + typedef TextureRect::StretchMode StretchMode; + +private: Ref<Texture> normal; Ref<Texture> pressed; Ref<Texture> hover; Ref<Texture> disabled; Ref<Texture> focused; Ref<BitMap> click_mask; - Size2 scale; + bool expand; + StretchMode stretch_mode; protected: - virtual bool has_point(const Point2& p_point) const; virtual Size2 get_minimum_size() const; + virtual bool has_point(const Point2& p_point) const; void _notification(int p_what); static void _bind_methods(); @@ -66,8 +72,11 @@ public: Ref<Texture> get_focused_texture() const; Ref<BitMap> get_click_mask() const; - void set_texture_scale(Size2 p_scale); - Size2 get_texture_scale() const; + bool get_expand() const; + void set_expand(bool p_expand); + + void set_stretch_mode(StretchMode stretch_mode); + StretchMode get_stretch_mode() const; TextureButton(); }; diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 6a4b59c5ec..74240fe98e 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -79,7 +79,15 @@ void TextureRect::_notification(int p_what) { draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height)); } break; - + case STRETCH_KEEP_ASPECT_COVERED: { + Size2 size = get_size(); + Size2 tex_size = texture->get_size(); + Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height); + float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height; + Size2 scaledTexSize = tex_size * scale; + Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f; + draw_texture_rect_region(texture, Rect2(Point2(), size), Rect2(ofs, size/scale)); + } break; } } @@ -104,7 +112,7 @@ void TextureRect::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); - ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") ); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") ); BIND_CONSTANT( STRETCH_SCALE_ON_EXPAND ); BIND_CONSTANT( STRETCH_SCALE ); @@ -113,7 +121,7 @@ void TextureRect::_bind_methods() { BIND_CONSTANT( STRETCH_KEEP_CENTERED ); BIND_CONSTANT( STRETCH_KEEP_ASPECT ); BIND_CONSTANT( STRETCH_KEEP_ASPECT_CENTERED ); - + BIND_CONSTANT( STRETCH_KEEP_ASPECT_COVERED ); } diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index e95d742759..0d72458909 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -45,7 +45,7 @@ public: STRETCH_KEEP_CENTERED, STRETCH_KEEP_ASPECT, STRETCH_KEEP_ASPECT_CENTERED, - + STRETCH_KEEP_ASPECT_COVERED, }; private: bool expand; diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index 49a14cda04..8331264208 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -220,7 +220,7 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) *p1 = *p2; *p2 = temp; } } - for (k = 0, le = 2; k < (long)(log(fftFrameSize)/log(2.)+.5); k++) { + for (k = 0, le = 2; k < (long)(log((double)fftFrameSize)/log(2.)+.5); k++) { le <<= 1; le2 = le>>1; ur = 1.0; diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp index a6499a66b4..5aab60a558 100644 --- a/servers/audio/effects/eq.cpp +++ b/servers/audio/effects/eq.cpp @@ -47,7 +47,7 @@ EQ::BandProcess::BandProcess() { void EQ::recalculate_band_coefficients() { -#define BAND_LOG( m_f ) ( log((m_f)) / log(2) ) +#define BAND_LOG( m_f ) ( log((m_f)) / log(2.) ) for (int i=0;i<band.size();i++) { diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 297413effd..c54f3dbca5 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2967,7 +2967,7 @@ void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const G } - divisor=Math::lerp(8.0,divisor,p_propagate); + divisor=Math::lerp((float)8.0,divisor,p_propagate); sum[0]/=divisor; sum[1]/=divisor; sum[2]/=divisor; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 352b0818b4..952681c5eb 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -338,6 +338,7 @@ void EditorNode::_notification(int p_what) { VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true); _editor_select(EDITOR_3D); + _update_debug_options(); /* if (defer_optimize!="") { @@ -2603,6 +2604,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { play_custom_scene_button->set_pressed(false); play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons")); //pause_button->set_pressed(false); + if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) { + for(int i=0;i<bottom_panel_items.size();i++) { + if (bottom_panel_items[i].control==log) { + _bottom_panel_switch(false,i); + break; + } + } + } emit_signal("stop_pressed"); } break; @@ -2674,7 +2683,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),!ischecked); - + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked); } break; case RUN_LIVE_DEBUG: { @@ -2682,6 +2691,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG),!ischecked); ScriptEditor::get_singleton()->get_debugger()->set_live_debugging(!ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked); + } break; /*case RUN_DEPLOY_DUMB_CLIENTS: { @@ -2696,6 +2707,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG)); debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG),!ischecked); run_native->set_deploy_debug_remote(!ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked); } break; case RUN_DEBUG_COLLISONS: { @@ -2704,6 +2716,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS),!ischecked); run_native->set_debug_collisions(!ischecked); editor_run.set_debug_collisions(!ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked); + } break; case RUN_DEBUG_NAVIGATION: { @@ -2711,6 +2725,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION),!ischecked); run_native->set_debug_navigation(!ischecked); editor_run.set_debug_navigation(!ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked); + } break; case RUN_RELOAD_SCRIPTS: { @@ -2719,6 +2735,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS),!ischecked); ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked); + } break; case SETTINGS_UPDATE_ALWAYS: { @@ -2864,6 +2882,23 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } } +void EditorNode::_update_debug_options() { + + bool check_deploy_remote = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false); + bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false); + bool check_debug_collisons = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false); + bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false); + bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", false); + bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", false); + + if (check_deploy_remote) _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true); + if (check_file_server) _menu_option_confirm(RUN_FILE_SERVER, true); + if (check_debug_collisons) _menu_option_confirm(RUN_DEBUG_COLLISONS, true); + if (check_debug_navigation) _menu_option_confirm(RUN_DEBUG_NAVIGATION, true); + if (check_live_debug) _menu_option_confirm(RUN_LIVE_DEBUG, true); + if (check_reload_scripts) _menu_option_confirm(RUN_RELOAD_SCRIPTS, true); + +} Control* EditorNode::get_viewport() { diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 4aca433f9c..7ac2760a5c 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -432,6 +432,7 @@ private: void _menu_option(int p_option); void _menu_confirm_current(); void _menu_option_confirm(int p_option,bool p_confirmed); + void _update_debug_options(); void _property_editor_forward(); void _property_editor_back(); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 1cdc426541..6d9f1bd979 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -242,13 +242,20 @@ void EditorSettings::create() { String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); DirAccess* d = DirAccess::create_for_path(exe_path); + bool self_contained = false; if (d->file_exists(exe_path + "/._sc_")) { + self_contained = true; + extra_config->load(exe_path + "/._sc_"); + } else if (d->file_exists(exe_path + "/_sc_")) { + self_contained = true; + extra_config->load(exe_path + "/_sc_"); + } + if (self_contained) { // editor is self contained config_path = exe_path; config_dir = "editor_data"; - extra_config->load(exe_path + "/._sc_"); } else { if (OS::get_singleton()->has_environment("APPDATA")) { @@ -655,6 +662,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("run/auto_save/save_before_running",true); set("run/output/always_clear_output_on_play",true); set("run/output/always_open_output_on_play",true); + set("run/output/always_close_output_on_stop",false); set("filesystem/resources/save_compressed_resources",true); set("filesystem/resources/auto_reload_modified_images",true); @@ -1029,26 +1037,22 @@ void EditorSettings::set_optimize_save(bool p_optimize) { optimize_save=p_optimize; } -String EditorSettings::get_last_selected_language() -{ +Variant EditorSettings::get_project_metadata(const String& p_section, const String& p_key, Variant p_default) { Ref<ConfigFile> cf = memnew( ConfigFile ); String path = get_project_settings_path().plus_file("project_metadata.cfg"); Error err = cf->load(path); if (err != OK) { - return ""; + return p_default; } - Variant last_selected_language = cf->get_value("script_setup", "last_selected_language"); - if (last_selected_language.get_type() != Variant::STRING) - return ""; - return static_cast<String>(last_selected_language); + return cf->get_value(p_section, p_key, p_default); } -void EditorSettings::set_last_selected_language(String p_language) +void EditorSettings::set_project_metadata(const String& p_section, const String& p_key, Variant p_data) { Ref<ConfigFile> cf = memnew( ConfigFile ); String path = get_project_settings_path().plus_file("project_metadata.cfg"); cf->load(path); - cf->set_value("script_setup", "last_selected_language", p_language); + cf->set_value(p_section, p_key, p_data); cf->save(path); } diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index c11feef667..809389eb40 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -160,8 +160,8 @@ public: void set_optimize_save(bool p_optimize); - String get_last_selected_language(); - void set_last_selected_language(String p_language); + Variant get_project_metadata(const String& p_section, const String& p_key, Variant p_default); + void set_project_metadata(const String& p_section, const String& p_key, Variant p_data); EditorSettings(); ~EditorSettings(); diff --git a/tools/editor/plugins/gi_probe_editor_plugin.cpp b/tools/editor/plugins/gi_probe_editor_plugin.cpp index 39f32d0dc7..925ac8ef11 100644 --- a/tools/editor/plugins/gi_probe_editor_plugin.cpp +++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp @@ -80,6 +80,4 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { GIProbeEditorPlugin::~GIProbeEditorPlugin() { - - memdelete(bake); } diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index da01cdefe5..496d8670eb 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -128,7 +128,7 @@ void ScriptCreateDialog::_create_new() { Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text()); String selected_language = language_menu->get_item_text(language_menu->get_selected()); - editor_settings->set_last_selected_language(selected_language); + editor_settings->set_project_metadata("script_setup", "last_selected_language", selected_language); if (cname!="") scr->set_name(cname); @@ -380,7 +380,7 @@ ScriptCreateDialog::ScriptCreateDialog() { } editor_settings = EditorSettings::get_singleton(); - String last_selected_language = editor_settings->get_last_selected_language(); + String last_selected_language = editor_settings->get_project_metadata("script_setup", "last_selected_language", ""); if (last_selected_language != "") for (int i = 0; i < language_menu->get_item_count(); i++) if (language_menu->get_item_text(i) == last_selected_language) |