diff options
58 files changed, 823 insertions, 266 deletions
diff --git a/core/array.cpp b/core/array.cpp index ab9f19d6a0..41af460d83 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -222,6 +222,24 @@ void Array::invert(){ } +void Array::push_front(const Variant& p_value) { + + _p->array.insert(0,p_value); +} + +void Array::pop_back(){ + + if (!_p->array.empty()) + _p->array.resize( _p->array.size() -1 ); + +} +void Array::pop_front(){ + + if (!_p->array.empty()) + _p->array.remove(0); + +} + Array::Array(const Array& p_from) { diff --git a/core/array.h b/core/array.h index 904309b257..c29b4355ca 100644 --- a/core/array.h +++ b/core/array.h @@ -53,7 +53,7 @@ public: bool empty() const; void clear(); - bool is_shared() const; + bool is_shared() const; bool operator==(const Array& p_array) const; @@ -75,6 +75,10 @@ public: void erase(const Variant& p_value); + void push_front(const Variant& p_value); + void pop_back(); + void pop_front(); + Array(const Array& p_from); Array(bool p_shared=false); ~Array(); diff --git a/core/object.cpp b/core/object.cpp index 96f0c86832..f6ba76a0b5 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1405,6 +1405,10 @@ bool Object::is_connected(const StringName& p_signal, Object *p_to_object, const bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal); if (signal_is_valid) return false; + + if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) + return false; + ERR_EXPLAIN("Nonexistent signal: "+p_signal); ERR_FAIL_COND_V(!s,false); } diff --git a/core/os/os.h b/core/os/os.h index e908177df7..ab1a07276c 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -75,7 +75,7 @@ public: bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_width=1280,int p_height=720,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2d10cf4d44..2ac876c8f4 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -450,6 +450,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0(Array,clear); VCALL_LOCALMEM0R(Array,hash); VCALL_LOCALMEM1(Array,push_back); + VCALL_LOCALMEM1(Array,push_front); + VCALL_LOCALMEM0(Array,pop_back); + VCALL_LOCALMEM0(Array,pop_front); VCALL_LOCALMEM1(Array,append); VCALL_LOCALMEM1(Array,resize); VCALL_LOCALMEM2(Array,insert); @@ -1426,12 +1429,15 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(ARRAY,NIL,Array,clear,varray()); ADDFUNC0(ARRAY,INT,Array,hash,varray()); ADDFUNC1(ARRAY,NIL,Array,push_back,NIL,"value",varray()); + ADDFUNC1(ARRAY,NIL,Array,push_front,NIL,"value",varray()); ADDFUNC1(ARRAY,NIL,Array,append,NIL,"value",varray()); ADDFUNC1(ARRAY,NIL,Array,resize,INT,"pos",varray()); ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray()); ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray()); ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray()); ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray()); + ADDFUNC0(ARRAY,NIL,Array,pop_back,varray()); + ADDFUNC0(ARRAY,NIL,Array,pop_front,varray()); ADDFUNC0(ARRAY,NIL,Array,sort,varray()); ADDFUNC2(ARRAY,NIL,Array,sort_custom,OBJECT,"obj",STRING,"func",varray()); ADDFUNC0(ARRAY,NIL,Array,invert,varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 1bcfa7d2ae..e33b79e63c 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -2635,7 +2635,7 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const { if (l) { for(int i=0;i<l;i++) { - if ((*arr)[i]==p_index) + if (evaluate(OP_EQUAL,(*arr)[i],p_index)) return true; } diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index fed8c28740..239b129388 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -460,6 +460,19 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=Vector2(args[0],args[1]); return OK; + } else if (id=="Rect2"){ + + Vector<float> args; + Error err = _parse_construct<float>(p_stream,args,line,r_err_str); + if (err) + return err; + + if (args.size()!=4) { + r_err_str="Expected 4 arguments for constructor"; + } + + value=Rect2(args[0],args[1],args[2],args[3]); + return OK; } else if (id=="Vector3"){ Vector<float> args; diff --git a/drivers/SCsub b/drivers/SCsub index 8e241830f8..e52d6538e5 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -61,39 +61,42 @@ import string if env['vsproj']=="yes": env.AddToVSProject(env.drivers_sources) -for f in env.drivers_sources: - fname = "" - if type(f) == type(""): - fname = env.File(f).path - else: - fname = env.File(f)[0].path - fname = fname.replace("\\", "/") - base = string.join(fname.split("/")[:2], "/") - if base != cur_base and len(list) > max_src: - if num > 0: - lib = env.Library("drivers"+str(num), list) - lib_list.append(lib) - list = [] - num = num+1 - cur_base = base - list.append(f) +if (False): #split drivers, this used to be needed for windows until separate builders for windows were created -lib = env.Library("drivers"+str(num), list) -lib_list.append(lib) + for f in env.drivers_sources: + fname = "" + if type(f) == type(""): + fname = env.File(f).path + else: + fname = env.File(f)[0].path + fname = fname.replace("\\", "/") + base = string.join(fname.split("/")[:2], "/") + if base != cur_base and len(list) > max_src: + if num > 0: + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) + list = [] + num = num+1 + cur_base = base + list.append(f) -if len(lib_list) > 0: - import os, sys - if os.name=='posix' and sys.platform=='msys': - env.Replace(ARFLAGS=['rcsT']) + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) - lib = env.Library("drivers_collated", lib_list) - lib_list = [lib] + if len(lib_list) > 0: + import os, sys + if os.name=='posix' and sys.platform=='msys': + env.Replace(ARFLAGS=['rcsT']) -drivers_base=[] -env.add_source_files(drivers_base,"*.cpp") -lib_list.insert(0, env.Library("drivers", drivers_base)) + lib = env.Library("drivers_collated", lib_list) + lib_list = [lib] -env.Prepend(LIBS=lib_list) + drivers_base=[] + env.add_source_files(drivers_base,"*.cpp") + lib_list.insert(0, env.Library("drivers", drivers_base)) -#lib = env.Library("drivers",env.drivers_sources) -#env.Prepend(LIBS=[lib]) + env.Prepend(LIBS=lib_list) +else: + env.add_source_files(env.drivers_sources,"*.cpp") + lib = env.Library("drivers",env.drivers_sources) + env.Prepend(LIBS=[lib]) diff --git a/main/main.cpp b/main/main.cpp index a060dbd232..66391ffa7e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -95,6 +95,7 @@ static TranslationServer *translation_server = NULL; static OS::VideoMode video_mode; static bool init_maximized=false; +static bool init_windowed=false; static bool init_fullscreen=false; static bool init_use_custom_pos=false; static bool debug_collisions=false; @@ -146,6 +147,7 @@ void Main::print_help(const char* p_binary) { OS::get_singleton()->print("\t-p XxY\t : Request Window Position\n"); OS::get_singleton()->print("\t-f\t\t : Request Fullscreen\n"); OS::get_singleton()->print("\t-mx\t\t Request Maximized\n"); + OS::get_singleton()->print("\t-w\t\t Request Windowed\n"); OS::get_singleton()->print("\t-vd DRIVER\t : Video Driver ("); for (int i=0;i<OS::get_singleton()->get_video_driver_count();i++) { @@ -354,6 +356,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } else if (I->get()=="-mx") { // video driver init_maximized=true; + } else if (I->get()=="-w") { // video driver + + init_windowed=true; } else if (I->get()=="-vd") { // video driver if (I->next()) { @@ -841,11 +846,7 @@ Error Main::setup2() { if (init_use_custom_pos) { OS::get_singleton()->set_window_position(init_custom_pos); } - if (init_maximized) { - OS::get_singleton()->set_window_maximized(true); - } else if (init_fullscreen) { - OS::get_singleton()->set_window_fullscreen(true); - } + register_core_singletons(); @@ -859,8 +860,12 @@ Error Main::setup2() { if (init_screen!=-1) { OS::get_singleton()->set_current_screen(init_screen); } - if (init_maximized) { + if (init_windowed) { + //do none.. + } else if (init_maximized) { OS::get_singleton()->set_window_maximized(true); + } else if (init_fullscreen) { + OS::get_singleton()->set_window_fullscreen(true); } MAIN_PRINT("Main: Load Remaps"); diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 93f4d00e05..3db5e1d215 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -226,6 +226,8 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_ queue_event(ev); }; + mouse_list.pressed[p_idx] = p_pressed; + if (p_use_as_mouse) { InputEvent ev; @@ -245,8 +247,6 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_ ev.mouse_button.doubleclick = p_doubleclick; ev.mouse_button.pressed = p_pressed; - mouse_list.pressed[p_idx] = p_pressed; - queue_event(ev); }; }; diff --git a/platform/isim/detect.py b/platform/isim/detect.py index bd0fd2fea3..0adbd9f413 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -21,8 +21,8 @@ def get_opts(): return [ ('ISIMPLATFORM', 'name of the iphone platform', 'iPhoneSimulator'), - ('ISIMPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Platforms/${ISIMPLATFORM}.platform'), - ('ISIMSDK', 'path to the iphone SDK', '$ISIMPATH/Developer/SDKs/${ISIMPLATFORM}.sdk'), + ('ISIMPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), + ('ISIMSDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${ISIMPLATFORM}.platform/Developer/SDKs/${ISIMPLATFORM}.sdk'), ('game_center', 'Support for game center', 'yes'), ('store_kit', 'Support for in-app store', 'yes'), ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'), @@ -46,9 +46,10 @@ def configure(env): env['ENV']['PATH'] = env['ISIMPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH'] - env['CC'] = '$ISIMPATH/Developer/usr/bin/gcc' - env['CXX'] = '$ISIMPATH/Developer/usr/bin/g++' - env['AR'] = 'ar' + env['CC'] = '$ISIMPATH/usr/bin/${ios_triple}clang' + env['CXX'] = '$ISIMPATH/usr/bin/${ios_triple}clang++' + env['AR'] = '$ISIMPATH/usr/bin/${ios_triple}ar' + env['RANLIB'] = '$ISIMPATH/usr/bin/${ios_triple}ranlib' import string env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') @@ -97,4 +98,8 @@ def configure(env): env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-fexceptions']) + import methods + env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 4990d04ab6..c9f5458484 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -838,8 +838,8 @@ const char * OS_OSX::get_video_driver_name(int p_driver) const { OS::VideoMode OS_OSX::get_default_video_mode() const { VideoMode vm; - vm.width=800; - vm.height=600; + vm.width=1280; + vm.height=720 ; vm.fullscreen=false; vm.resizable=true; return vm; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 1fb8e6dbd0..49ce1d3b9a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -148,7 +148,7 @@ const char * OS_Windows::get_video_driver_name(int p_driver) const { OS::VideoMode OS_Windows::get_default_video_mode() const { - return VideoMode(800,600,false); + return VideoMode(1280,720,false); } int OS_Windows::get_audio_driver_count() const { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4f1b475d06..13dc1069a3 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -82,7 +82,7 @@ const char * OS_X11::get_video_driver_name(int p_driver) const { } OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(800,600,false); + return OS::VideoMode(1280,720,false); } int OS_X11::get_audio_driver_count() const { diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 52ae5d2954..b7b99f935a 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -118,10 +118,10 @@ Matrix32 Camera2D::get_camera_transform() { - if (smoothing>0.0) { + if (smoothing_enabled) { float c = smoothing*get_fixed_process_delta_time(); - smoothed_camera_pos = ((new_camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; + smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; ret_camera_pos=smoothed_camera_pos; // camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; } else { @@ -440,6 +440,27 @@ float Camera2D::get_h_offset() const{ } +void Camera2D::_set_old_smoothing(float p_val) { + //compatibility + if (p_val>0) { + smoothing_enabled=true; + set_follow_smoothing(p_val); + } + +} + +void Camera2D::set_enable_follow_smoothing(bool p_enabled) { + + smoothing_enabled=p_enabled; + +} + +bool Camera2D::is_follow_smoothing_enabled() const { + + return smoothing_enabled; +} + + void Camera2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset); @@ -489,14 +510,17 @@ void Camera2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing); ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing); + ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing); + ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled); + ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll); + ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset")); ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") ); ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT); @@ -507,6 +531,12 @@ void Camera2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); + + //compatibility + ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") ); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT); ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP); ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT); @@ -535,8 +565,9 @@ Camera2D::Camera2D() { drag_margin[MARGIN_BOTTOM]=0.2; camera_pos=Vector2(); first=true; + smoothing_enabled=false; - smoothing=0.0; + smoothing=5.0; zoom = Vector2(1, 1); h_drag_enabled=true; diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 79d84f48d0..dcf98d4295 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -59,6 +59,7 @@ protected: bool rotating; bool current; float smoothing; + bool smoothing_enabled; int limit[4]; float drag_margin[4]; @@ -73,6 +74,8 @@ protected: void _make_current(Object *p_which); void _set_current(bool p_current); + + void _set_old_smoothing(float p_enable); protected: virtual Matrix32 get_camera_transform(); @@ -108,6 +111,9 @@ public: void set_h_offset(float p_offset); float get_h_offset() const; + void set_enable_follow_smoothing(bool p_enabled); + bool is_follow_smoothing_enabled() const; + void set_follow_smoothing(float p_speed); float get_follow_smoothing() const; diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index abd532c156..295a57d033 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1156,6 +1156,8 @@ Matrix32 CanvasItem::get_canvas_transform() const { if (canvas_layer) return canvas_layer->get_transform(); + else if (get_parent()->cast_to<CanvasItem>()) + return get_parent()->cast_to<CanvasItem>()->get_canvas_transform(); else return get_viewport()->get_canvas_transform(); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 1479cb7881..616d3da7c9 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -113,6 +113,12 @@ void CollisionPolygon2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } + } break; case NOTIFICATION_EXIT_TREE: { can_update_body=false; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 85751fc735..56f68ae634 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -77,6 +77,11 @@ void CollisionShape2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { @@ -120,6 +125,7 @@ void CollisionShape2D::_notification(int p_what) { rect=Rect2(); + Color draw_col=get_tree()->get_debug_collisions_color(); shape->draw(get_canvas_item(),draw_col); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 167b637bdc..1d48a9c8a0 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -32,6 +32,8 @@ #include "method_bind_ext.inc" #include "os/os.h" + + int TileMap::_get_quadrant_size() const { if (y_sort_mode) @@ -299,6 +301,7 @@ void TileMap::_update_dirty_quadrants() { q.occluder_instances.clear(); Ref<CanvasItemMaterial> prev_material; RID prev_canvas_item; + RID prev_debug_canvas_item; for(int i=0;i<q.cells.size();i++) { @@ -319,6 +322,7 @@ void TileMap::_update_dirty_quadrants() { Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id); RID canvas_item; + RID debug_canvas_item; if (prev_canvas_item==RID() || prev_material!=mat) { @@ -331,11 +335,24 @@ void TileMap::_update_dirty_quadrants() { vs->canvas_item_set_transform( canvas_item, xform ); q.canvas_items.push_back(canvas_item); + if (debug_shapes) { + + debug_canvas_item=vs->canvas_item_create(); + vs->canvas_item_set_parent( debug_canvas_item, canvas_item ); + vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item,false); + vs->canvas_item_set_z(debug_canvas_item,VS::CANVAS_ITEM_Z_MAX-1); + q.canvas_items.push_back(debug_canvas_item); + prev_debug_canvas_item=debug_canvas_item; + } + prev_canvas_item=canvas_item; prev_material=mat; } else { canvas_item=prev_canvas_item; + if (debug_shapes) { + debug_canvas_item=prev_debug_canvas_item; + } } @@ -407,9 +424,8 @@ void TileMap::_update_dirty_quadrants() { _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,xform); - shape->draw(canvas_item,debug_collision_color); + if (debug_canvas_item) { + shape->draw(debug_canvas_item,debug_collision_color); } ps->body_add_shape(q.body,shape->get_rid(),xform); @@ -417,9 +433,6 @@ void TileMap::_update_dirty_quadrants() { } } - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,Matrix32()); - } if (navigation) { Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); @@ -452,6 +465,7 @@ void TileMap::_update_dirty_quadrants() { VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform); VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid()); VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas()); + VS::get_singleton()->canvas_light_occluder_set_light_mask(orid,occluder_light_mask); Quadrant::Occluder oc; oc.xform=xform; oc.id=orid; @@ -1075,6 +1089,24 @@ Array TileMap::get_used_cells() const { return a; } +void TileMap::set_occluder_light_mask(int p_mask) { + + occluder_light_mask=p_mask; + for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { + + for (Map<PosKey,Quadrant::Occluder>::Element *F=E->get().occluder_instances.front();F;F=F->next()) { + VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id,occluder_light_mask); + } + } +} + +int TileMap::get_occluder_light_mask() const{ + + return occluder_light_mask; +} + + + void TileMap::_bind_methods() { @@ -1126,6 +1158,9 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce); ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce); + ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask); + ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask); + ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); @@ -1160,6 +1195,7 @@ void TileMap::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce")); ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data")); @@ -1197,6 +1233,7 @@ TileMap::TileMap() { use_kinematic=false; navigation=NULL; y_sort_mode=false; + occluder_light_mask=1; fp_adjust=0.00001; tile_origin=TILE_ORIGIN_TOP_LEFT; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 60534cce15..4676d1ef7a 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -150,6 +150,8 @@ private: TileOrigin tile_origin; + int occluder_light_mask; + void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk); @@ -187,6 +189,7 @@ public: INVALID_CELL=-1 }; + void set_tileset(const Ref<TileSet>& p_tileset); Ref<TileSet> get_tileset() const; @@ -247,6 +250,9 @@ public: void set_y_sort_mode(bool p_enable); bool is_y_sort_mode_enabled() const; + void set_occluder_light_mask(int p_mask); + int get_occluder_light_mask() const; + void clear(); TileMap(); diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 8cdf4dd039..2ff51d22c4 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -105,6 +105,8 @@ void Container::fit_child_in_rect(Control *p_child,const Rect2& p_rect) { p_child->set_pos(r.pos); p_child->set_size(r.size); + p_child->set_rotation(0); + p_child->set_scale(Vector2(1,1)); } void Container::queue_sort() { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index bd6b8078ff..ec4886a6ac 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -580,8 +580,8 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_DRAW: { - Matrix32 xform; - xform.set_origin(get_pos()); + Matrix32 xform=Matrix32(data.rotation,get_pos()); + xform.scale_basis(data.scale); VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform); VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),true, Rect2(Point2(),get_size())); //emit_signal(SceneStringNames::get_singleton()->draw); @@ -1927,6 +1927,7 @@ void Control::set_size(const Size2& p_size) { data.margin[3] = _s2a( y+h, data.anchor[3], ph ); _size_changed(); + } @@ -2412,9 +2413,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const { Matrix32 Control::get_transform() const { - Matrix32 xf; - xf.set_origin(get_pos()); - return xf; + Matrix32 xform=Matrix32(data.rotation,get_pos()); + xform.scale_basis(data.scale); + return xform; } String Control::_get_tooltip() const { @@ -2728,6 +2729,39 @@ bool Control::is_text_field() const { return false; } + +void Control::_set_rotation_deg(float p_rot) { + set_rotation(Math::deg2rad(p_rot)); +} + +float Control::_get_rotation_deg() const { + return Math::rad2deg(get_rotation()); +} + +void Control::set_rotation(float p_rotation) { + + data.rotation=p_rotation; + update(); + _notify_transform(); +} + +float Control::get_rotation() const{ + + return data.rotation; +} + +void Control::set_scale(const Vector2& p_scale){ + + data.scale=p_scale; + update(); + _notify_transform(); +} +Vector2 Control::get_scale() const{ + + return data.scale; +} + + void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event); @@ -2756,15 +2790,21 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size); ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size); ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos); + ObjectTypeDB::bind_method(_MD("set_rotation","rotation"),&Control::set_rotation); + ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation"),&Control::_set_rotation_deg); + ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale); ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin); ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin); ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end); ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos); ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size); + ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation); + ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale); ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size); ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size); ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos); ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect); + ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg); ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect); ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false)); @@ -2846,6 +2886,8 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") ); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") ); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") ); + ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("_set_rotation_deg"),_SCS("_get_rotation_deg") ); + ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") ); ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP ); @@ -2928,6 +2970,8 @@ Control::Control() { data.v_size_flags=SIZE_FILL; data.expand=1; data.pending_min_size_update=false; + data.rotation=0; + data.scale=Vector2(1,1); for (int i=0;i<4;i++) { diff --git a/scene/gui/control.h b/scene/gui/control.h index 4311b299c8..09a4b48e6b 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -107,7 +107,10 @@ private: float margin[4]; AnchorType anchor[4]; - FocusMode focus_mode; + FocusMode focus_mode; + + float rotation; + Vector2 scale; bool pending_resize; @@ -211,6 +214,8 @@ private: void _size_changed(); String _get_tooltip() const; + void _set_rotation_deg(float p_rot); + float _get_rotation_deg() const; protected: bool window_has_modal_stack() const; @@ -299,6 +304,13 @@ public: Rect2 get_rect() const; Rect2 get_global_rect() const; Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server + + void set_rotation(float p_rotation); + float get_rotation() const; + + void set_scale(const Vector2& p_scale); + Vector2 get_scale() const; + void set_area_as_parent_rect(int p_margin=0); @@ -382,7 +394,7 @@ public: void warp_mouse(const Point2& p_to_pos); - virtual bool is_text_field() const; + virtual bool is_text_field() const; Control(); ~Control(); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index ff94a37be0..3cc5acc1a6 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -77,9 +77,14 @@ void OptionButton::_selected(int p_which) { } } - ERR_FAIL_COND(selid==-1); + if (selid==-1 && p_which>=0 && p_which<popup->get_item_count()) { + _select(p_which,true); + } else { - _select(selid,true); + ERR_FAIL_COND(selid==-1); + + _select(selid,true); + } } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 20f28ecf10..9dc03272b2 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -370,7 +370,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) { } int over=_get_mouse_over(Point2(m.x,m.y)); - int id = (over<0 || items[over].separator || items[over].disabled)?-1:items[over].ID; + int id = (over<0 || items[over].separator || items[over].disabled)?-1:(items[over].ID>=0?items[over].ID:over); if (id<0) { mouse_over=-1; @@ -524,7 +524,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i item.icon=p_icon; item.text=p_label; item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; items.push_back(item); update(); } @@ -533,7 +533,7 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) { Item item; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; items.push_back(item); update(); } @@ -542,7 +542,7 @@ void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu, Item item; item.text=XL_MESSAGE(p_label); - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.submenu=p_submenu; items.push_back(item); update(); @@ -554,7 +554,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l item.icon=p_icon; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.checkable=true; items.push_back(item); update(); @@ -564,7 +564,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel) Item item; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.checkable=true; items.push_back(item); update(); @@ -753,9 +753,11 @@ int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const { void PopupMenu::activate_item(int p_item) { + ERR_FAIL_INDEX(p_item,items.size()); ERR_FAIL_COND(items[p_item].separator); - emit_signal("item_pressed",items[p_item].ID); + int id = items[p_item].ID>=0?items[p_item].ID:p_item; + emit_signal("item_pressed",id); //hide all parent PopupMenue's Node *next = get_parent(); @@ -789,7 +791,7 @@ void PopupMenu::clear() { items.clear(); mouse_over=-1; update(); - idcount=0; + } @@ -937,7 +939,7 @@ void PopupMenu::set_invalidate_click_until_motion() { PopupMenu::PopupMenu() { - idcount=0; + mouse_over=-1; set_focus_mode(FOCUS_ALL); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index ed78fe6738..30223469a3 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -59,7 +59,6 @@ class PopupMenu : public Popup { Timer *submenu_timer; List<Rect2> autohide_areas; Vector<Item> items; - int idcount; int mouse_over; int submenu_over; Rect2 parent_rect; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index a48136f541..051a8dd018 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -68,6 +68,25 @@ void SpinBox::_line_edit_input(const InputEvent& p_event) { } +void SpinBox::_range_click_timeout() { + + if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + + int pos_y = Input::get_singleton()->get_mouse_pos().y-get_global_pos().y; + bool up = pos_y < (get_size().height/2); + set_val( get_val() + (up?get_step():-get_step())); + + if (range_click_timer->is_one_shot()) { + range_click_timer->set_wait_time(0.075); + range_click_timer->set_one_shot(false); + range_click_timer->start(); + } + + } else { + range_click_timer->stop(); + } +} + void SpinBox::_input_event(const InputEvent& p_event) { @@ -85,6 +104,10 @@ void SpinBox::_input_event(const InputEvent& p_event) { set_val( get_val() + (up?get_step():-get_step())); + range_click_timer->set_wait_time(0.6); + range_click_timer->set_one_shot(true); + range_click_timer->start(); + } break; case BUTTON_RIGHT: { @@ -112,6 +135,8 @@ void SpinBox::_input_event(const InputEvent& p_event) { if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) { //set_default_cursor_shape(CURSOR_ARROW); + range_click_timer->stop(); + if (drag.enabled) { drag.enabled=false; Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); @@ -167,6 +192,7 @@ void SpinBox::_notification(int p_what) { Size2i size = get_size(); updown->draw(ci,Point2i(size.width-updown->get_width(),(size.height-updown->get_height())/2)); + } else if (p_what==NOTIFICATION_FOCUS_EXIT) { @@ -227,6 +253,7 @@ void SpinBox::_bind_methods() { ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit); ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit); ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input); + ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable")); @@ -248,4 +275,8 @@ SpinBox::SpinBox() { line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED); line_edit->connect("input_event",this,"_line_edit_input"); drag.enabled=false; + + range_click_timer = memnew( Timer ); + range_click_timer->connect("timeout",this,"_range_click_timeout"); + add_child(range_click_timer); } diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 4c8cb8432a..1b3bc6d817 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -31,6 +31,7 @@ #include "scene/gui/line_edit.h" #include "scene/gui/range.h" +#include "scene/main/timer.h" class SpinBox : public Range { @@ -39,6 +40,9 @@ class SpinBox : public Range { LineEdit *line_edit; int last_w; + Timer *range_click_timer; + void _range_click_timeout(); + void _text_entered(const String& p_string); virtual void _value_changed(double); String prefix; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 78792dc785..29969b65e6 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -29,6 +29,7 @@ #include "text_edit.h" #include "os/keyboard.h" +#include "os/input.h" #include "os/os.h" #include "globals.h" @@ -349,6 +350,29 @@ void TextEdit::_update_scrollbars() { updating_scrolls=false; } +void TextEdit::_click_selection_held() { + + if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode!=Selection::MODE_NONE) { + + Point2 mp = Input::get_singleton()->get_mouse_pos()-get_global_pos(); + + int row,col; + _get_mouse_pos(Point2i(mp.x,mp.y), row,col); + + select(selection.selecting_line,selection.selecting_column,row,col); + + cursor_set_line( row ); + cursor_set_column( col ); + update(); + + click_select_held->start(); + + } else { + + click_select_held->stop(); + } +} + void TextEdit::_notification(int p_what) { @@ -1292,6 +1316,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { update(); } } else { + + if (mb.button_index==BUTTON_LEFT) + click_select_held->stop(); // notify to show soft keyboard notification(NOTIFICATION_FOCUS_ENTER); @@ -1304,16 +1331,18 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (mm.button_mask&BUTTON_MASK_LEFT) { - int row,col; - _get_mouse_pos(Point2i(mm.x,mm.y), row,col); - if (selection.selecting_mode!=Selection::MODE_NONE) { + + int row,col; + _get_mouse_pos(Point2i(mm.x,mm.y), row,col); select(selection.selecting_line,selection.selecting_column,row,col); cursor_set_line( row ); cursor_set_column( col ); update(); + + click_select_held->start(); } @@ -3697,6 +3726,7 @@ void TextEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit); ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit); ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op); + ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held); BIND_CONSTANT( SEARCH_MATCH_CASE ); BIND_CONSTANT( SEARCH_WHOLE_WORDS ); @@ -3811,6 +3841,11 @@ TextEdit::TextEdit() { idle_detect->set_one_shot(true); idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3)); idle_detect->connect("timeout", this,"_push_current_op"); + + click_select_held = memnew( Timer ); + add_child(click_select_held); + click_select_held->set_wait_time(0.05); + click_select_held->connect("timeout", this,"_click_selection_held"); #if 0 syntax_coloring=true; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 91369309cf..f8e8ef3b9a 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -219,6 +219,7 @@ class TextEdit : public Control { uint64_t last_dblclk; Timer *idle_detect; + Timer *click_select_held; HScrollBar *h_scroll; VScrollBar *v_scroll; bool updating_scrolls; @@ -240,6 +241,7 @@ class TextEdit : public Control { void adjust_viewport_to_cursor(); void _scroll_moved(double); void _update_scrollbars(); + void _click_selection_held(); void _pre_shift_selection(); void _post_shift_selection(); diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 5b2caecb5b..7e6bf2cbdf 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -145,7 +145,7 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture); ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture); ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask); - ObjectTypeDB::bind_method(_MD("set_scale","scale"),&TextureButton::set_scale); + ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale); ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate); ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture); @@ -154,7 +154,7 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture); ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture); ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask); - ObjectTypeDB::bind_method(_MD("get_scale"),&TextureButton::get_scale); + ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale); ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); @@ -163,7 +163,7 @@ void TextureButton::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; - ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale")); + ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale")); ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); } @@ -232,14 +232,14 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) { focused = p_focused; }; -void TextureButton::set_scale(Size2 p_scale) { +void TextureButton::set_texture_scale(Size2 p_scale) { scale=p_scale; minimum_size_changed(); update(); } -Size2 TextureButton::get_scale() const{ +Size2 TextureButton::get_texture_scale() const{ return scale; } diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index 01924c1c15..49687986c4 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -68,8 +68,8 @@ public: Ref<Texture> get_focused_texture() const; Ref<BitMap> get_click_mask() const; - void set_scale(Size2 p_scale); - Size2 get_scale() const; + void set_texture_scale(Size2 p_scale); + Size2 get_texture_scale() const; void set_modulate(const Color& p_modulate); Color get_modulate() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 16a12fe407..ee7c0724e3 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1369,7 +1369,40 @@ Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) { } +void Tree::_range_click_timeout() { + if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + + Point2 pos = (Input::get_singleton()->get_mouse_pos()-get_global_pos())-cache.bg->get_offset(); + if (show_column_titles) { + pos.y-=_get_title_button_height(); + + if (pos.y<0) { + range_click_timer->stop(); + return; + } + } + + click_handled=false; + InputModifierState mod = {}; // should be irrelevant.. + + blocked++; + propagate_mouse_event(pos+cache.offset, 0, 0, false, root, BUTTON_LEFT, mod); + blocked--; + + if (range_click_timer->is_one_shot()) { + range_click_timer->set_wait_time(0.05); + range_click_timer->set_one_shot(false); + range_click_timer->start(); + } + + if (!click_handled) + range_click_timer->stop(); + + } else { + range_click_timer->stop(); + } +} int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod) { @@ -1564,9 +1597,25 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ bool up=p_pos.y < (item_h /2); if (p_button==BUTTON_LEFT) { + + if (range_click_timer->get_time_left() == 0) { + + range_item_last=p_item; + range_up_last=up; + + range_click_timer->set_wait_time(0.6); + range_click_timer->set_one_shot(true); + range_click_timer->start(); + + } else if (up != range_up_last) { + + return -1; // break. avoid changing direction on mouse held + } + p_item->set_range( col, c.val + (up?1.0:-1.0) * c.step ); item_edited(col,p_item); + } else if (p_button==BUTTON_RIGHT) { p_item->set_range( col, (up?c.max:c.min) ); @@ -2024,6 +2073,8 @@ void Tree::_input_event(InputEvent p_event) { update_cache(); const InputEventMouseMotion& b=p_event.mouse_motion; + range_click_timer->stop(); + Ref<StyleBox> bg = cache.bg; Point2 pos = Point2(b.x,b.y) - bg->get_offset(); @@ -2031,7 +2082,6 @@ void Tree::_input_event(InputEvent p_event) { Cache::ClickType old_hover = cache.hover_type; int old_index = cache.hover_index; - cache.hover_type=Cache::CLICK_NONE; cache.hover_index=0; if (show_column_titles) { @@ -2108,6 +2158,8 @@ void Tree::_input_event(InputEvent p_event) { if (b.button_index==BUTTON_LEFT) { + range_click_timer->stop(); + if (pressing_for_editor) { if (range_drag_enabled) { @@ -2228,10 +2280,13 @@ void Tree::_input_event(InputEvent p_event) { } break; case BUTTON_WHEEL_UP: { + + range_click_timer->stop(); v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 ); } break; case BUTTON_WHEEL_DOWN: { + range_click_timer->stop(); v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 ); } break; } @@ -3135,6 +3190,7 @@ bool Tree::is_folding_hidden() const { void Tree::_bind_methods() { + ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout); ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event); ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select); ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter); @@ -3229,6 +3285,10 @@ Tree::Tree() { add_child(h_scroll); add_child(v_scroll); + range_click_timer = memnew( Timer ); + range_click_timer->connect("timeout",this,"_range_click_timeout"); + add_child(range_click_timer); + h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); text_editor->connect("text_entered", this,"_text_editor_enter"); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 8fb9b802a1..55ccc16d01 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -127,7 +127,7 @@ friend class Tree; - TreeItem(Tree *p_tree); + TreeItem(Tree *p_tree); void _changed_notify(int p_cell); @@ -301,6 +301,11 @@ friend class TreeItem; Vector<ColumnInfo> columns; + Timer *range_click_timer; + TreeItem *range_item_last; + bool range_up_last; + void _range_click_timeout(); + int compute_item_height(TreeItem *p_item) const; int get_item_height(TreeItem *p_item) const; // void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index d99da5e906..22b19f50b2 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -338,6 +338,13 @@ float VideoPlayer::get_stream_pos() const { return playback->get_pos(); }; +Ref<Texture> VideoPlayer::get_video_texture() { + + if (playback.is_valid()) + return playback->get_texture(); + + return Ref<Texture> (); +} void VideoPlayer::set_autoplay(bool p_enable) { @@ -384,6 +391,8 @@ void VideoPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec); ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec); + ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture ); + ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); // ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") ); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index c485e3d6b6..b14d3936b9 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -88,6 +88,8 @@ public: bool has_expand() const; + Ref<Texture> get_video_texture(); + void set_stream(const Ref<VideoStream> &p_stream); Ref<VideoStream> get_stream() const; @@ -110,8 +112,8 @@ public: void set_autoplay(bool p_vol); bool has_autoplay() const; - void set_audio_track(int p_track); - int get_audio_track() const; + void set_audio_track(int p_track); + int get_audio_track() const; void set_buffering_msec(int p_msec); int get_buffering_msec() const; diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp index 97d3fafd58..bf1f298e7a 100644 --- a/scene/resources/color_ramp.cpp +++ b/scene/resources/color_ramp.cpp @@ -26,6 +26,23 @@ ColorRamp::~ColorRamp() { void ColorRamp::_bind_methods() { + + + + + ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point); + ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point); + + ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset); + ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset); + + ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color); + ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color); + + ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset); + + ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count); + ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets); ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets); @@ -79,6 +96,23 @@ Vector<ColorRamp::Point>& ColorRamp::get_points() { return points; } +void ColorRamp::add_point(float p_offset, const Color& p_color) { + + Point p; + p.offset=p_offset; + p.color=p_color; + is_sorted=false; + points.push_back(p); + +} + +void ColorRamp::remove_point(int p_index) { + + ERR_FAIL_INDEX(p_index,points.size()); + ERR_FAIL_COND(points.size()<=2); + points.remove(p_index); +} + void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) { points = p_points; is_sorted = false; diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h index 8f6ba2c3e5..aab5698c2b 100644 --- a/scene/resources/color_ramp.h +++ b/scene/resources/color_ramp.h @@ -32,6 +32,9 @@ public: ColorRamp(); virtual ~ColorRamp(); + void add_point(float p_offset, const Color& p_color); + void remove_point(int p_index); + void set_points(Vector<Point>& points); Vector<Point>& get_points(); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 2d93113b40..aad5e7cfdd 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -462,31 +462,16 @@ void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,fl void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const { - Point2 pos=p_pos; - float ofs=0; - VisualServer *vs = VisualServer::get_singleton(); + Vector2 ofs; for (int i=0;i<p_text.length();i++) { - const Character * c = char_map.getptr(p_text[i]); + int width = get_char_size(p_text[i]).width; - if (!c) - continue; - -// if (p_clip_w>=0 && (ofs+c->rect.size.width)>(p_clip_w)) -// break; //width exceeded - - if (p_clip_w>=0 && (ofs+c->rect.size.width)>p_clip_w) + if (p_clip_w>=0 && (ofs.x+width)>p_clip_w) break; //clip - Point2 cpos=pos; - cpos.x+=ofs+c->h_align; - cpos.y-=ascent; - cpos.y+=c->v_align; - ERR_CONTINUE( c->texture_idx<-1 || c->texture_idx>=textures.size()); - if (c->texture_idx!=-1) - textures[c->texture_idx]->draw_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), c->rect, p_modulate ); - - ofs+=get_char_size(p_text[i],p_text[i+1]).width; + + ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate); } } @@ -494,8 +479,11 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ const Character * c = char_map.getptr(p_char); - if (!c) + if (!c) { + if (fallback.is_valid()) + return fallback->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate); return 0; + } Point2 cpos=p_pos; cpos.x+=c->h_align; @@ -508,6 +496,16 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ return get_char_size(p_char,p_next).width; } +void Font::set_fallback(const Ref<Font> &p_fallback) { + + fallback=p_fallback; +} + +Ref<Font> Font::get_fallback() const{ + + return fallback; +} + void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt); @@ -548,6 +546,8 @@ void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("_set_textures"),&Font::_set_textures); ObjectTypeDB::bind_method(_MD("_get_textures"),&Font::_get_textures); + ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&Font::set_fallback); + ObjectTypeDB::bind_method(_MD("get_fallback"),&Font::get_fallback); ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") ); ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") ); @@ -556,6 +556,7 @@ void Font::_bind_methods() { ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") ); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") ); + ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"Font" ), _SCS("set_fallback"), _SCS("get_fallback") ); } diff --git a/scene/resources/font.h b/scene/resources/font.h index 6728b59f8e..27e3045eaa 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -84,6 +84,7 @@ private: void _set_textures(const Vector<Variant> & p_textures); Vector<Variant> _get_textures() const; + Ref<Font> fallback; protected: static void _bind_methods(); @@ -113,9 +114,13 @@ public: int get_kerning_pair(CharType p_A,CharType p_B) const; Vector<KerningPairKey> get_kerning_pair_keys() const; - _FORCE_INLINE_ Size2 get_char_size(CharType p_char,CharType p_next=0) const; + inline Size2 get_char_size(CharType p_char,CharType p_next=0) const; Size2 get_string_size(const String& p_string) const; + + void set_fallback(const Ref<Font> &p_fallback); + Ref<Font> get_fallback() const; + void clear(); void set_distance_field_hint(bool p_distance_field); @@ -134,8 +139,11 @@ Size2 Font::get_char_size(CharType p_char,CharType p_next) const { const Character * c = char_map.getptr(p_char); - if (!c) + if (!c) { + if (fallback.is_valid()) + return fallback->get_char_size(p_char,p_next); return Size2(); + } Size2 ret(c->advance,c->rect.size.y); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 55bb4e9073..b4ea60cb8d 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -535,6 +535,8 @@ void ShaderMaterial::_shader_changed() { void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) { + ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL); + if (shader.is_valid()) shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed); shader=p_shader; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 863f2be699..f8283bb5ca 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -509,6 +509,19 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } } + if (exists && p_node->get_script_instance()) { + //if this is an overriden value by another script, save it anyway + //as the script change will erase it + //https://github.com/godotengine/godot/issues/2958 + + bool valid=false; + p_node->get_script_instance()->get_property_type(name,&valid); + if (valid) { + exists=false; + isdefault=false; + } + } + if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { //exists and did not change diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index a9376faf62..f0a2721016 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -448,31 +448,19 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_origi void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("shader"); + ObjectTypeDB::get_extensions_for_type("Shader", p_extensions); } + bool ResourceFormatLoaderShader::handles_type(const String& p_type) const { - return p_type=="Shader"; + return ObjectTypeDB::is_type(p_type, "Shader"); } String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const { - if (p_path.extension().to_lower()=="shader") + if (p_path.extension().to_lower()=="shd") return "Shader"; return ""; } - - - - - - - - - - - - - diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index deec5f60c7..107ffac626 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -1683,8 +1683,12 @@ Collada::Node* Collada::_parse_visual_scene_node(XMLParser& parser) { if ( parser.has_attribute("sid") ) { //bones may not have sid joint->sid=parser.get_attribute_value("sid"); // state.bone_map[joint->sid]=joint; - } else if (state.idref_joints.has(name)) + } else if (state.idref_joints.has(name)) { joint->sid=name; //kind of a cheat but.. + } else if (parser.has_attribute("name")) { + joint->sid=parser.get_attribute_value_safe("name"); + } + if (joint->sid!="") { state.sid_to_node_map[joint->sid]=id; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 104539c308..61ad7b6cbb 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -6,6 +6,8 @@ #include "editor_resource_preview.h" #include "editor_settings.h" #include "scene/gui/margin_container.h" +#include "os/file_access.h" + EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL; EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL; @@ -194,6 +196,9 @@ void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>& void EditorFileDialog::_request_single_thumbnail(const String& p_path) { + if (!FileAccess::exists(p_path)) + return; + EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",p_path); //print_line("want file "+p_path); set_process(true); @@ -435,6 +440,8 @@ void EditorFileDialog::update_file_list() { } + String cdir = dir_access->get_current_dir(); + bool skip_pp = access==ACCESS_RESOURCES && cdir=="res://"; dir_access->list_dir_begin(); @@ -455,7 +462,7 @@ void EditorFileDialog::update_file_list() { if (show_hidden || !ishidden) { if (!isdir) files.push_back(item); - else + else if (item!=".." || !skip_pp) dirs.push_back(item); } } diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index cd455406b7..64b104334f 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -41,6 +41,7 @@ #include "io/md5.h" #include "io_plugins/editor_texture_import_plugin.h" #include "tools/editor/plugins/script_editor_plugin.h" +#include "io/zip_io.h" String EditorImportPlugin::validate_source_path(const String& p_path) { @@ -1077,6 +1078,59 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path } +Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) { + + + ZipData *zd = (ZipData*)p_userdata; + + zipFile zip=(zipFile)zd->zip; + + zipOpenNewFileInZip(zip, + p_path.utf8().get_data(), + NULL, + NULL, + 0, + NULL, + 0, + NULL, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION); + + zipWriteInFileInZip(zip,p_data.ptr(),p_data.size()); + zipCloseFileInZip(zip); + + zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total); + zd->count++; + return OK; + +} + +Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) { + + EditorProgress ep("savezip","Packing",102); + + //FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE); + + FileAccess *src_f; + zlib_filefunc_def io = zipio_create_io_from_file(&src_f); + zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io); + + ZipData zd; + zd.count=0; + zd.ep=&ep; + zd.zip=zip; + + + Error err = export_project_files(save_zip_file,&zd,p_make_bundles); + + zipClose(zip,NULL); + + if (err) + return err; + + +} + Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p_alignment) { EditorProgress ep("savepack","Packing",102); diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 93086f7ad4..940a41bafd 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -33,6 +33,7 @@ #include "scene/main/node.h" #include "scene/resources/texture.h" + class EditorExportPlatform; class FileAccess; class EditorProgress; @@ -107,8 +108,17 @@ protected: }; + struct ZipData { + + void* zip; + EditorProgress *ep; + int count; + + }; + void gen_export_flags(Vector<String> &r_flags, int p_flags); static Error save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); + static Error save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); public: @@ -134,6 +144,8 @@ public: Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles); Error save_pack(FileAccess *p_where, bool p_make_bundles=false, int p_alignment = 1); + Error save_zip(const String& p_path, bool p_make_bundles=false); + virtual String get_name() const =0; virtual ImageCompression get_image_compression() const=0; virtual Ref<Texture> get_logo() const =0; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 35404b0bba..3dbca760f0 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -1816,7 +1816,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) { } play_button->set_pressed(false); - play_button->set_icon(gui_base->get_icon("Play","EditorIcons")); + play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons")); //pause_button->set_pressed(false); play_scene_button->set_pressed(false); play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons")); @@ -2688,7 +2688,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { editor_run.stop(); play_button->set_pressed(false); - play_button->set_icon(gui_base->get_icon("Play","EditorIcons")); + play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons")); play_scene_button->set_pressed(false); play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons")); //pause_button->set_pressed(false); diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp index cea774f94b..5314529a23 100644 --- a/tools/editor/plugins/mesh_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_editor_plugin.cpp @@ -1,13 +1,8 @@ #include "mesh_editor_plugin.h" -#include "tools/editor/editor_plugin.h" -#include "tools/editor/editor_node.h" -#include "scene/3d/mesh_instance.h" #include "scene/3d/physics_body.h" #include "scene/3d/body_shape.h" -#include "scene/gui/spin_box.h" #include "scene/gui/box_container.h" -#include "scene/3d/mesh_instance.h" #include "scene/3d/navigation_mesh.h" #include "spatial_editor_plugin.h" @@ -38,92 +33,106 @@ void MeshInstanceEditor::_menu_option(int p_option) { } switch(p_option) { - case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: { + case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: + case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: { - Ref<Shape> shape = mesh->create_trimesh_shape(); - if (shape.is_null()) - return; - StaticBody *body = memnew( StaticBody ); - CollisionShape *cshape = memnew( CollisionShape ); - cshape->set_shape(shape); - body->add_child(cshape); - Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner(); + bool trimesh_shape = (p_option==MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); + EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Static Trimesh"); - ur->add_do_method(node,"add_child",body); - ur->add_do_method(body,"set_owner",owner); - ur->add_do_method(cshape,"set_owner",owner); - ur->add_do_reference(body); - ur->add_undo_method(node,"remove_child",body); - ur->commit_action(); - } break; - case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: { + List<Node*> selection = editor_selection->get_selected_node_list(); - Ref<Shape> shape = mesh->create_convex_shape(); - if (shape.is_null()) - return; - StaticBody *body = memnew( StaticBody ); - CollisionShape *cshape = memnew( CollisionShape ); - cshape->set_shape(shape); - body->add_child(cshape); - Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner(); + if (selection.empty()) { + Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape(); + if (shape.is_null()) + return; - UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Static Trimesh"); - ur->add_do_method(node,"add_child",body); - ur->add_do_method(body,"set_owner",owner); - ur->add_do_method(cshape,"set_owner",owner); - ur->add_do_reference(body); - ur->add_undo_method(node,"remove_child",body); - ur->commit_action(); + CollisionShape *cshape = memnew( CollisionShape ); + cshape->set_shape(shape); + StaticBody *body = memnew( StaticBody ); + body->add_child(cshape); - } break; - case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE: { + Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner(); + if (trimesh_shape) + ur->create_action("Create Static Trimesh Body"); + else + ur->create_action("Create Static Convex Body"); - if (node==get_tree()->get_edited_scene_root()) { - err_dialog->set_text("This doesn't work on scene root!"); - err_dialog->popup_centered_minsize(); + ur->add_do_method(node,"add_child",body); + ur->add_do_method(body,"set_owner",owner); + ur->add_do_method(cshape,"set_owner",owner); + ur->add_do_reference(body); + ur->add_undo_method(node,"remove_child",body); + ur->commit_action(); return; } - Ref<Shape> shape = mesh->create_trimesh_shape(); - if (shape.is_null()) - return; - CollisionShape *cshape = memnew( CollisionShape ); - cshape->set_shape(shape); - Node *owner = node->get_owner(); + if (trimesh_shape) + ur->create_action("Create Static Trimesh Body"); + else + ur->create_action("Create Static Convex Body"); + + for (List<Node*>::Element *E=selection.front();E;E=E->next()) { + + MeshInstance *instance = E->get()->cast_to<MeshInstance>(); + if (!instance) + continue; + + Ref<Mesh> m = instance->get_mesh(); + if (m.is_null()) + continue; + + Ref<Shape> shape = trimesh_shape ? m->create_trimesh_shape() : m->create_convex_shape(); + if (shape.is_null()) + continue; + + CollisionShape *cshape = memnew( CollisionShape ); + cshape->set_shape(shape); + StaticBody *body = memnew( StaticBody ); + body->add_child(cshape); + + Node *owner = instance==get_tree()->get_edited_scene_root() ? instance : instance->get_owner(); + + ur->add_do_method(instance,"add_child",body); + ur->add_do_method(body,"set_owner",owner); + ur->add_do_method(cshape,"set_owner",owner); + ur->add_do_reference(body); + ur->add_undo_method(instance,"remove_child",body); + } - UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Static Trimesh"); - ur->add_do_method(node->get_parent(),"add_child",cshape); - ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1); - ur->add_do_method(cshape,"set_owner",owner); - ur->add_do_reference(cshape); - ur->add_undo_method(node->get_parent(),"remove_child",cshape); ur->commit_action(); } break; - case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: { + case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE: + case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: { if (node==get_tree()->get_edited_scene_root()) { err_dialog->set_text("This doesn't work on scene root!"); err_dialog->popup_centered_minsize(); return; } - Ref<Shape> shape = mesh->create_convex_shape(); + + bool trimesh_shape = (p_option==MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); + + Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape(); if (shape.is_null()) return; + CollisionShape *cshape = memnew( CollisionShape ); cshape->set_shape(shape); Node *owner = node->get_owner(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Static Trimesh"); + + if (trimesh_shape) + ur->create_action("Create Trimesh Shape"); + else + ur->create_action("Create Convex Shape"); + ur->add_do_method(node->get_parent(),"add_child",cshape); ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1); ur->add_do_method(cshape,"set_owner",owner); @@ -132,10 +141,8 @@ void MeshInstanceEditor::_menu_option(int p_option) { ur->commit_action(); } break; - case MENU_OPTION_CREATE_NAVMESH: { - - + case MENU_OPTION_CREATE_NAVMESH: { Ref<NavigationMesh> nmesh = memnew( NavigationMesh ); @@ -158,6 +165,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { ur->add_undo_method(node,"remove_child",nmi); ur->commit_action(); } break; + case MENU_OPTION_CREATE_OUTLINE_MESH: { outline_dialog->popup_centered(Vector2(200, 90)); diff --git a/tools/editor/plugins/mesh_editor_plugin.h b/tools/editor/plugins/mesh_editor_plugin.h index e502b5dc2b..6b3e23f31f 100644 --- a/tools/editor/plugins/mesh_editor_plugin.h +++ b/tools/editor/plugins/mesh_editor_plugin.h @@ -23,24 +23,19 @@ class MeshInstanceEditor : public Node { MENU_OPTION_CREATE_OUTLINE_MESH, }; + MeshInstance *node; + + MenuButton *options; + ConfirmationDialog *outline_dialog; SpinBox *outline_size; AcceptDialog *err_dialog; - - Panel *panel; - MeshInstance *node; - - LineEdit *surface_source; - LineEdit *mesh_source; - - void _menu_option(int p_option); void _create_outline_mesh(); friend class MeshInstanceEditorPlugin; - MenuButton * options; protected: void _node_removed(Node *p_node); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 37f4076a0c..df6397ed1d 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -604,7 +604,6 @@ void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) { void ScriptEditor::_show_debugger(bool p_show) { debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), p_show); - } void ScriptEditor::_script_created(Ref<Script> p_script) { @@ -981,7 +980,22 @@ void ScriptEditor::_menu_option(int p_option) { case WINDOW_PREV: { _history_back(); } 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 DEBUG_SHOW_KEEP_OPEN: { + bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN) ); + if (debugger) + debugger->set_hide_on_stop(visible); + debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible); + } break; } @@ -1335,16 +1349,6 @@ void ScriptEditor::_menu_option(int p_option) { 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 == "") @@ -2394,6 +2398,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu->get_popup()->add_item("Continue",DEBUG_CONTINUE); debug_menu->get_popup()->add_separator(); debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW); + debug_menu->get_popup()->add_check_item("Keep Debuger Open",DEBUG_SHOW_KEEP_OPEN); debug_menu->get_popup()->connect("item_pressed", this,"_menu_option"); debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 7875b4d144..32c1e7e1c8 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -151,7 +151,8 @@ class ScriptEditor : public VBoxContainer { DEBUG_BREAK, DEBUG_CONTINUE, DEBUG_SHOW, - HELP_CONTEXTUAL, + DEBUG_SHOW_KEEP_OPEN, + HELP_CONTEXTUAL, WINDOW_MOVE_LEFT, WINDOW_MOVE_RIGHT, WINDOW_NEXT, diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index b288439b74..36976a9120 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -471,20 +471,32 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) { ERR_PRINT("Invalid platform for export of PCK"); return; } - FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); - if (!f) { - error->set_text("Error exporting project PCK! Can't write"); - error->popup_centered_minsize(); - } - ERR_FAIL_COND(!f); - Error err = exporter->save_pack(f,false); - memdelete(f); + if (p_file.ends_with(".pck")) { + FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); + if (!f) { + error->set_text("Error exporting project PCK! Can't write"); + error->popup_centered_minsize(); + } + ERR_FAIL_COND(!f); - if (err!=OK) { - error->set_text("Error exporting project!"); - error->popup_centered_minsize(); - return; + Error err = exporter->save_pack(f,false); + memdelete(f); + + if (err!=OK) { + error->set_text("Error exporting project!"); + error->popup_centered_minsize(); + return; + } + } else if (p_file.ends_with(".zip")) { + + Error err = exporter->save_zip(p_file,false); + + if (err!=OK) { + error->set_text("Error exporting project!"); + error->popup_centered_minsize(); + return; + } } } @@ -1425,6 +1437,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { pck_export->set_title("Export Project PCK"); pck_export->connect("file_selected", this,"_export_action_pck"); pck_export->add_filter("*.pck ; Data Pack"); + pck_export->add_filter("*.zip ; Zip"); add_child(pck_export); button_export = add_button("Export..",!OS::get_singleton()->get_swap_ok_cancel(),"export_pck"); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 7ab09f0487..9fb623022b 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -89,13 +89,23 @@ void CustomPropertyEditor::_menu_option(int p_which) { case OBJ_MENU_LOAD: { file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - List<String> extensions; String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String(); - ResourceLoader::get_recognized_extensions_for_type(type,&extensions); - file->clear_filters(); + List<String> extensions; + for (int i=0;i<type.get_slice_count(",");i++) { + + ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",",i),&extensions); + } + + Set<String> valid_extensions; for (List<String>::Element *E=extensions.front();E;E=E->next()) { + valid_extensions.insert(E->get()); + } + + file->clear_filters(); + for (Set<String>::Element *E=valid_extensions.front();E;E=E->next()) { + file->add_filter("*."+E->get()+" ; "+E->get().to_upper() ); } @@ -2549,7 +2559,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK ); item->set_text(1,"On"); item->set_checked( 1, obj->get( p.name ) ); - item->set_icon( 0, get_icon("Bool","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("Bool","EditorIcons") ); item->set_editable(1,!read_only); } break; @@ -2561,7 +2572,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_text(1, String::num(obj->get( p.name ),2) ); item->set_editable(1,!read_only); - item->set_icon( 0, get_icon("Curve","EditorIcons")); + if (show_type_icons) + item->set_icon( 0, get_icon("Curve","EditorIcons")); break; @@ -2631,7 +2643,8 @@ void PropertyEditor::update_tree() { // int c = p.hint_string.get_slice_count(","); item->set_text(1,p.hint_string); - item->set_icon( 0,get_icon("Enum","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Enum","EditorIcons") ); item->set_range(1, obj->get( p.name ) ); item->set_editable(1,!read_only); break; @@ -2647,11 +2660,13 @@ void PropertyEditor::update_tree() { }; if (p.type==Variant::REAL) { - item->set_icon( 0, get_icon("Real","EditorIcons")); + if (show_type_icons) + item->set_icon( 0, get_icon("Real","EditorIcons")); item->set_range(1, obj->get( p.name ) ); } else { - item->set_icon( 0,get_icon("Integer","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Integer","EditorIcons") ); item->set_range(1, obj->get( p.name ) ); } @@ -2671,7 +2686,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING ); item->set_editable(1,!read_only); - item->set_icon( 0, get_icon("File","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("File","EditorIcons") ); item->set_text(1,obj->get(p.name)); item->add_button(1,get_icon("Folder","EditorIcons")); @@ -2691,7 +2707,8 @@ void PropertyEditor::update_tree() { item->set_text(1, p.hint_string); item->set_range(1,idx); item->set_editable( 1, !read_only ); - item->set_icon( 0,get_icon("Enum","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Enum","EditorIcons") ); } break; @@ -2699,7 +2716,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING ); item->set_editable(1,!read_only); - item->set_icon( 0, get_icon("String","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("String","EditorIcons") ); item->set_text(1,obj->get(p.name)); if (p.hint==PROPERTY_HINT_MULTILINE_TEXT) item->add_button(1,get_icon("MultiLine","EditorIcons") ); @@ -2719,7 +2737,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"Array["+itos(v.call("size"))+"]"); else item->set_text(1,"Array[]"); - item->set_icon( 0, get_icon("ArrayData","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("ArrayData","EditorIcons") ); } break; @@ -2734,7 +2753,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"IntArray["+itos(v.call("size"))+"]"); else item->set_text(1,"IntArray[]"); - item->set_icon( 0, get_icon("ArrayInt","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("ArrayInt","EditorIcons") ); } break; @@ -2748,7 +2768,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"FloatArray["+itos(v.call("size"))+"]"); else item->set_text(1,"FloatArray[]"); - item->set_icon( 0, get_icon("ArrayReal","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("ArrayReal","EditorIcons") ); } break; @@ -2762,7 +2783,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"String["+itos(v.call("size"))+"]"); else item->set_text(1,"String[]"); - item->set_icon( 0, get_icon("ArrayString","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("ArrayString","EditorIcons") ); } break; @@ -2776,7 +2798,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"Byte["+itos(v.call("size"))+"]"); else item->set_text(1,"Byte[]"); - item->set_icon( 0, get_icon("ArrayData","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("ArrayData","EditorIcons") ); } break; @@ -2790,7 +2813,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"Vector2["+itos(v.call("size"))+"]"); else item->set_text(1,"Vector2[]"); - item->set_icon( 0, get_icon("Vector2","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("Vector2","EditorIcons") ); } break; @@ -2804,7 +2828,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"Vector3["+itos(v.call("size"))+"]"); else item->set_text(1,"Vector3[]"); - item->set_icon( 0, get_icon("Vector","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("Vector","EditorIcons") ); } break; @@ -2818,7 +2843,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"Color["+itos(v.call("size"))+"]"); else item->set_text(1,"Color[]"); - item->set_icon( 0, get_icon("Color","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0, get_icon("Color","EditorIcons") ); } break; @@ -2827,7 +2853,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Vector2","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Vector2","EditorIcons") ); } break; case Variant::RECT2: { @@ -2835,7 +2862,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Rect2","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Rect2","EditorIcons") ); } break; case Variant::VECTOR3: { @@ -2843,7 +2871,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Vector","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Vector","EditorIcons") ); } break; case Variant::MATRIX32: @@ -2858,7 +2887,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Matrix","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Matrix","EditorIcons") ); } break; case Variant::PLANE: { @@ -2866,7 +2896,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Plane","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Plane","EditorIcons") ); } break; case Variant::_AABB: { @@ -2874,7 +2905,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,"AABB"); - item->set_icon( 0,get_icon("Rect3","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Rect3","EditorIcons") ); } break; case Variant::QUAT: { @@ -2882,7 +2914,8 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); item->set_editable( 1, true ); item->set_text(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Quat","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Quat","EditorIcons") ); } break; case Variant::COLOR: { @@ -2891,7 +2924,8 @@ void PropertyEditor::update_tree() { item->set_editable( 1, !read_only ); // item->set_text(1,obj->get(p.name)); item->set_custom_bg_color(1,obj->get(p.name)); - item->set_icon( 0,get_icon("Color","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Color","EditorIcons") ); } break; case Variant::IMAGE: { @@ -2903,7 +2937,8 @@ void PropertyEditor::update_tree() { item->set_text(1,"[Image (empty)]"); else item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"]"); - item->set_icon( 0,get_icon("Image","EditorIcons") ); + if (show_type_icons) + item->set_icon( 0,get_icon("Image","EditorIcons") ); } break; case Variant::NODE_PATH: { @@ -3583,6 +3618,7 @@ PropertyEditor::PropertyEditor() { use_doc_hints=false; use_filter=false; subsection_selectable=false; + show_type_icons=EDITOR_DEF("inspector/show_type_icons",false); } diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index f004616c08..e933d7ab3b 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -161,6 +161,7 @@ class PropertyEditor : public Control { bool keying; bool read_only; bool show_categories; + bool show_type_icons; float refresh_countdown; bool use_doc_hints; bool use_filter; diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 60f2afa2c2..d0bf4faf02 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -571,10 +571,10 @@ void ScriptEditorDebugger::_notification(int p_what) { show(); + dobreak->set_disabled(false); tabs->set_current_tab(0); - emit_signal("show_debugger",true); reason->set_text("Child Process Connected"); reason->set_tooltip("Child Process Connected"); scene_tree->clear(); @@ -737,8 +737,10 @@ void ScriptEditorDebugger::stop(){ le_set->set_disabled(true); - hide(); - emit_signal("show_debugger",false); + if (hide_on_stop) { + hide(); + emit_signal("show_debugger",false); + } } @@ -768,9 +770,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { void ScriptEditorDebugger::_hide_request() { - hide(); emit_signal("show_debugger",false); - } void ScriptEditorDebugger::_output_clear() { @@ -1160,6 +1160,10 @@ void ScriptEditorDebugger:: _error_stack_selected(int p_idx){ } +void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) { + + hide_on_stop=p_hide; +} void ScriptEditorDebugger::_bind_methods() { @@ -1462,6 +1466,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ live_debug=false; last_path_id=false; error_count=0; + hide_on_stop=true; last_error_count=0; diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h index 6b66a62dd5..43666b37d5 100644 --- a/tools/editor/script_editor_debugger.h +++ b/tools/editor/script_editor_debugger.h @@ -71,6 +71,8 @@ class ScriptEditorDebugger : public Control { int error_count; int last_error_count; + bool hide_on_stop; + TextureButton *tb; @@ -182,6 +184,7 @@ public: void update_live_edit_root(); + void set_hide_on_stop(bool p_hide); virtual Size2 get_minimum_size() const; ScriptEditorDebugger(EditorNode *p_editor=NULL); |