From b56badf77b652abca012dd4dbd4932a03e4139dd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 17 Apr 2015 16:18:46 -0300 Subject: -Added android immersive mode, fixes #303 --- platform/android/export/export.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'platform/android/export/export.cpp') diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8199e7c62..1dca83274 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -186,6 +186,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { bool apk_expansion; bool remove_prev; bool use_32_fb; + bool immersive; String apk_expansion_salt; String apk_expansion_pkey; int orientation; @@ -282,6 +283,8 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& _signed=p_value; else if (n=="screen/use_32_bits_view") use_32_fb=p_value; + else if (n=="screen/immersive_mode") + immersive=p_value; else if (n=="screen/orientation") orientation=p_value; else if (n=="screen/support_small") @@ -349,6 +352,8 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) r_ret=_signed; else if (n=="screen/use_32_bits_view") r_ret=use_32_fb; + else if (n=="screen/immersive_mode") + r_ret=immersive; else if (n=="screen/orientation") r_ret=orientation; else if (n=="screen/support_small") @@ -399,6 +404,7 @@ void EditorExportPlatformAndroid::_get_property_list( List *p_list p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); p_list->push_back( PropertyInfo( Variant::BOOL, "package/signed") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/use_32_bits_view") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "screen/immersive_mode") ); p_list->push_back( PropertyInfo( Variant::INT, "screen/orientation",PROPERTY_HINT_ENUM,"Landscape,Portrait") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_small") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_normal") ); @@ -1171,6 +1177,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (use_32_fb) cl.push_back("-use_depth_32"); + if (immersive) + cl.push_back("-use_immersive"); if (cl.size()) { //add comandline @@ -1547,6 +1555,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() { orientation=0; remove_prev=true; use_32_fb=true; + immersive=true; device_thread=Thread::create(_device_poll_thread,this); devices_changed=true; -- cgit v1.2.3-70-g09d2 From 59154cccf9fcf814a21a2596993fb1b6777d3bb7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 20 Apr 2015 19:38:02 -0300 Subject: -Changed Godot exit to be clean. -Added more debug information on memory cleanliness on exit (if run with -v) -Fixed several memory leaks, fixes #1731, fixes #755 --- bin/tests/test_render.cpp | 8 ++++- core/io/file_access_network.cpp | 1 + core/io/file_access_pack.cpp | 15 ++++++++ core/io/file_access_pack.h | 4 +++ core/io/file_access_zip.cpp | 2 +- core/object.cpp | 15 +++++++- core/register_core_types.cpp | 6 ++-- core/string_db.cpp | 18 ++++++++-- drivers/gles2/rasterizer_gles2.cpp | 6 +++- main/main.cpp | 15 +++++++- modules/gridmap/grid_map_editor_plugin.cpp | 25 +++++++------ modules/gridmap/grid_map_editor_plugin.h | 7 ++++ platform/android/export/export.cpp | 3 ++ platform/bb10/export/export.cpp | 2 ++ platform/x11/detect.py | 7 ++++ platform/x11/os_x11.cpp | 3 ++ platform/x11/os_x11.h | 3 +- scene/2d/camera_2d.cpp | 3 +- scene/2d/canvas_item.cpp | 1 - scene/main/viewport.cpp | 1 + servers/visual/rasterizer.h | 1 + servers/visual/visual_server_raster.cpp | 10 ++++-- servers/visual_server.cpp | 33 +++++++++++++---- servers/visual_server.h | 2 ++ tools/editor/animation_editor.cpp | 4 +-- tools/editor/editor_import_export.cpp | 8 +++++ tools/editor/editor_import_export.h | 1 + tools/editor/editor_node.cpp | 21 ++++++----- tools/editor/fileserver/editor_file_server.cpp | 2 ++ .../io_plugins/editor_font_import_plugin.cpp | 3 +- tools/editor/plugins/baked_light_baker.cpp | 1 + tools/editor/plugins/canvas_item_editor_plugin.cpp | 39 +++++++++++++++----- tools/editor/plugins/canvas_item_editor_plugin.h | 5 ++- .../plugins/sample_library_editor_plugin.cpp | 3 +- tools/editor/plugins/spatial_editor_plugin.cpp | 41 +++++++++++++++------- tools/editor/plugins/spatial_editor_plugin.h | 3 ++ tools/editor/project_settings.cpp | 9 +++-- 37 files changed, 263 insertions(+), 68 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/bin/tests/test_render.cpp b/bin/tests/test_render.cpp index ce7606dce..97a52b16c 100644 --- a/bin/tests/test_render.cpp +++ b/bin/tests/test_render.cpp @@ -33,6 +33,8 @@ #include "print_string.h" #include "os/os.h" #include "quick_hull.h" +#include "os/keyboard.h" + #define OBJECT_COUNT 50 namespace TestRender { @@ -59,10 +61,14 @@ class TestMainLoop : public MainLoop { float ofs; bool quit; +protected: + + public: virtual void input_event(const InputEvent& p_event) { - + if (p_event.type==InputEvent::KEY && p_event.key.pressed) + quit=true; } virtual void init() { diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index a5ec05c35..850e05512 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -254,6 +254,7 @@ FileAccessNetworkClient::~FileAccessNetworkClient() { quit=true; sem->post(); Thread::wait_to_finish(thread); + memdelete(thread); } memdelete(blockrequest_mutex); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 15435a8b6..bf1211f2b 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -107,6 +107,21 @@ PackedData::PackedData() { add_pack_source(memnew(PackedSourcePCK)); } +void PackedData::_free_packed_dirs(PackedDir *p_dir) { + + for (Map::Element *E=p_dir->subdirs.front();E;E=E->next()) + _free_packed_dirs(E->get()); + memdelete(p_dir); +} + +PackedData::~PackedData() { + + for(int i=0;iis_stdout_verbose()) { + const uint32_t *K=NULL; + while((K=instances.next(K))) { + + String node_name; + if (instances[*K]->is_type("Node")) + node_name=" - Node Name: "+String(instances[*K]->call("get_name")); + if (instances[*K]->is_type("Resoucre")) + node_name=" - Resource Name: "+String(instances[*K]->call("get_name"))+" Path: "+String(instances[*K]->call("get_path")); + print_line("Leaked Instance: "+String(instances[*K]->get_type())+":"+itos(*K)+node_name); + } + } } instances.clear(); instance_checks.clear(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 70e2ec191..8754946bb 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -205,12 +205,14 @@ void unregister_core_types() { if (ip) memdelete(ip); + + ObjectDB::cleanup(); + unregister_variant_methods(); - CoreStringNames::free(); ObjectTypeDB::cleanup(); ResourceCache::clear(); - ObjectDB::cleanup(); + CoreStringNames::free(); StringName::cleanup(); if (_global_mutex) { diff --git a/core/string_db.cpp b/core/string_db.cpp index 8761551fe..57fdd6e70 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "string_db.h" #include "print_string.h" - +#include "os/os.h" StaticCString StaticCString::create(const char *p_ptr) { StaticCString scs; scs.ptr=p_ptr; return scs; } @@ -55,15 +55,29 @@ void StringName::setup() { void StringName::cleanup() { _global_lock(); + int lost_strings=0; for(int i=0;inext; + lost_strings++; + if (OS::get_singleton()->is_stdout_verbose()) { + + if (d->cname) { + print_line("Orphan StringName: "+String(d->cname)); + } else { + print_line("Orphan StringName: "+String(d->name)); + } + } + + _table[i]=_table[i]->next; memdelete(d); } } + if (OS::get_singleton()->is_stdout_verbose() && lost_strings) { + print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit."); + } _global_unlock(); } diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 0221cbe77..0598d9222 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -1613,7 +1613,8 @@ Variant RasterizerGLES2::shader_get_default_param(RID p_shader, const StringName RID RasterizerGLES2::material_create() { - return material_owner.make_rid( memnew( Material ) ); + RID material = material_owner.make_rid( memnew( Material ) ); + return material; } void RasterizerGLES2::material_set_shader(RID p_material, RID p_shader) { @@ -10815,7 +10816,10 @@ void RasterizerGLES2::init() { void RasterizerGLES2::finish() { + free(default_material); + free(shadow_material); free(canvas_shadow_blur); + free( overdraw_material ); } int RasterizerGLES2::get_render_info(VS::RenderInfo p_info) { diff --git a/main/main.cpp b/main/main.cpp index e753ac5e1..7c687bb0c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -87,6 +87,9 @@ static MessageQueue *message_queue=NULL; static Performance *performance = NULL; static PathRemap *path_remap; static PackedData *packed_data=NULL; +#ifdef MINIZIP_ENABLED +static ZipArchive *zip_packed_data=NULL; +#endif static FileAccessNetworkClient *file_access_network_client=NULL; static TranslationServer *translation_server = NULL; @@ -248,7 +251,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas packed_data = memnew(PackedData); #ifdef MINIZIP_ENABLED - packed_data->add_pack_source(ZipArchive::get_singleton()); + zip_packed_data = ZipArchive::get_singleton(); + packed_data->add_pack_source(zip_packed_data); #endif bool editor=false; @@ -740,6 +744,15 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas memdelete(packed_data); if (file_access_network_client) memdelete(file_access_network_client); + + if (packed_data) + memdelete( packed_data ); +#ifdef MINIZIP_ENABLED + if (zip_packed_data) + memdelete( zip_packed_data ); +#endif + + unregister_core_types(); OS::get_singleton()->_cmdline.clear(); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 992e5b364..39f83b806 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -868,7 +868,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { { //update grids - RID indicator_mat = VisualServer::get_singleton()->fixed_material_create(); + indicator_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false ); @@ -922,7 +922,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { d[VS::ARRAY_VERTEX]=grid_points[i]; d[VS::ARRAY_COLOR]=grid_colors[i]; VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat,true); + VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat); } @@ -1340,7 +1340,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { Array d; d.resize(VS::ARRAY_MAX); - RID inner_mat = VisualServer::get_singleton()->fixed_material_create(); + inner_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3)); VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true); @@ -1349,9 +1349,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { d[VS::ARRAY_VERTEX]=triangles; VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat,true); + VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat); - RID outer_mat = VisualServer::get_singleton()->fixed_material_create(); + outer_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8)); VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0); VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true); @@ -1361,10 +1361,10 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { d[VS::ARRAY_VERTEX]=lines; VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat,true); + VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat); - RID inner_mat_dup = VisualServer::get_singleton()->fixed_material_create(); + inner_mat_dup = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3)); VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true); @@ -1373,9 +1373,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { d[VS::ARRAY_VERTEX]=triangles; VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d); - VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup,true); + VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup); - RID outer_mat_dup = VisualServer::get_singleton()->fixed_material_create(); + outer_mat_dup = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8)); VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0); VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); @@ -1385,7 +1385,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { d[VS::ARRAY_VERTEX]=lines; VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup,true); + VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup); } @@ -1409,6 +1409,11 @@ GridMapEditor::~GridMapEditor() { VisualServer::get_singleton()->free(cursor_instance); } + VisualServer::get_singleton()->free(inner_mat); + VisualServer::get_singleton()->free(outer_mat); + VisualServer::get_singleton()->free(inner_mat_dup); + VisualServer::get_singleton()->free(outer_mat_dup); + VisualServer::get_singleton()->free(selection_mesh); if (selection_instance.is_valid()) VisualServer::get_singleton()->free(selection_instance); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index bd7e007a5..716ef66f0 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -105,6 +105,13 @@ class GridMapEditor : public VBoxContainer { RID duplicate_mesh; RID duplicate_instance; + RID indicator_mat; + + RID inner_mat; + RID outer_mat; + RID inner_mat_dup; + RID outer_mat_dup; + bool updating; diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1dca83274..4d3f8f110 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1635,8 +1635,11 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const { EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { + quit_request=true; Thread::wait_to_finish(device_thread); + memdelete(device_lock); + memdelete(device_thread); } diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 7862ecd49..a807e184c 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -764,6 +764,8 @@ EditorExportPlatformBB10::~EditorExportPlatformBB10() { quit_request=true; Thread::wait_to_finish(device_thread); + memdelete(device_lock); + memdelete(device_thread); } diff --git a/platform/x11/detect.py b/platform/x11/detect.py index b0876d7fc..4ecd23204 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -52,6 +52,7 @@ def get_opts(): return [ ('use_llvm','Use llvm compiler','no'), ('use_sanitizer','Use llvm compiler sanitize address','no'), + ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'), ('pulseaudio','Detect & Use pulseaudio','yes'), ('new_wm_api', 'Use experimental window management API','no'), ] @@ -94,6 +95,12 @@ def configure(env): env.Append(LINKFLAGS=['-fsanitize=address']) env.extra_suffix+="s" + if (env["use_leak_sanitizer"]=="yes"): + env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix+="s" + + #if (env["tools"]=="no"): # #no tools suffix # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 413d845bf..67ec33f3a 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -258,9 +258,11 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + audio_driver_index=p_audio_driver; if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { bool success=false; + audio_driver_index=-1; for(int i=0;iget_name())); print_line("Using alternate audio driver: "+String(AudioDriverManagerSW::get_driver(i)->get_name())); + audio_driver_index=i; break; } } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 59cda21ca..0036485f3 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -157,9 +157,10 @@ class OS_X11 : public OS_Unix { int joystick_count; - Joystick joysticks[JOYSTICKS_MAX]; + Joystick joysticks[JOYSTICKS_MAX]; + int audio_driver_index; unsigned int capture_idle; bool maximized; //void set_wm_border(bool p_enabled); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 64fb703b7..2ebf34d34 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -37,7 +37,8 @@ void Camera2D::_update_scroll() { return; if (get_tree()->is_editor_hint()) { - update(); //will just be drawn + // update(); //will just be drawn + //?? return; } diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 489da9e55..09c5a2a2b 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -342,7 +342,6 @@ void CanvasItem::_update_callback() { return; } - VisualServer::get_singleton()->canvas_item_clear(get_canvas_item()); //todo updating = true - only allow drawing here if (is_visible()) { //todo optimize this!! diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d3ce88e78..4d9feb3af 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1450,6 +1450,7 @@ Viewport::~Viewport() { VisualServer::get_singleton()->free( viewport ); SpatialSoundServer::get_singleton()->free(listener); + SpatialSound2DServer::get_singleton()->free(listener_2d); if (render_target_texture.is_valid()) render_target_texture->vp=NULL; //so if used, will crash } diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index f0a67e844..81862fb3a 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -661,6 +661,7 @@ public: }; Type type; + virtual ~Command(){} }; struct CommandLine : public Command { diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index eaa02df51..2417c02bf 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -4393,7 +4393,7 @@ void VisualServerRaster::free( RID p_rid ) { VS_CHANGED; - if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid)) { + if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid) || rasterizer->is_environment(p_rid)) { rasterizer->free(p_rid); } else if (rasterizer->is_skeleton(p_rid)) { @@ -4410,7 +4410,7 @@ void VisualServerRaster::free( RID p_rid ) { } rasterizer->free(p_rid); - } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) ) { + } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) || rasterizer->is_immediate(p_rid)) { //delete the resource _free_attached_instances(p_rid); @@ -7488,6 +7488,10 @@ void VisualServerRaster::finish() { free(default_cursor_texture); + if (test_cube.is_valid()) + free(test_cube); + + _free_internal_rids(); _clean_up_owner( &room_owner,"Room" ); _clean_up_owner( &portal_owner,"Portal" ); @@ -7505,7 +7509,7 @@ void VisualServerRaster::finish() { octree_allocator.clear(); if (instance_dependency_map.size()) { - print_line("base resources missing "+itos(instance_dependency_map.size())); + print_line("Base resources missing amount: "+itos(instance_dependency_map.size())); } ERR_FAIL_COND( instance_dependency_map.size() ); } diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index a49b3eca3..78320f277 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -130,6 +130,24 @@ RID VisualServer::get_test_texture() { return test_texture; }; +void VisualServer::_free_internal_rids() { + + if (test_texture.is_valid()) + free(test_texture); + if (white_texture.is_valid()) + free(white_texture); + if (test_material.is_valid()) + free(test_material); + + for(int i=0;i<16;i++) { + if (material_2d[i].is_valid()) + free(material_2d[i]); + } + + + +} + RID VisualServer::_make_test_cube() { DVector vertices; @@ -202,16 +220,17 @@ RID VisualServer::_make_test_cube() { mesh_add_surface( test_cube, PRIMITIVE_TRIANGLES,d ); - RID material = fixed_material_create(); + + test_material = fixed_material_create(); //material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true); - fixed_material_set_texture( material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() ); - fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 ); - fixed_material_set_param( material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) ); + fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() ); + fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 ); + fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) ); - fixed_material_set_param( material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) ); - fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) ); + fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) ); + fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) ); - mesh_surface_set_material(test_cube, 0, material ); + mesh_surface_set_material(test_cube, 0, test_material ); return test_cube; } diff --git a/servers/visual_server.h b/servers/visual_server.h index e962cf4ea..c1c2ef4fd 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -55,8 +55,10 @@ class VisualServer : public Object { void _canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector& p_margins, const Color& p_modulate=Color(1,1,1)); protected: RID _make_test_cube(); + void _free_internal_rids(); RID test_texture; RID white_texture; + RID test_material; RID material_2d[16]; static VisualServer* (*create_func)(); diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 6bbb81f0d..8d666f050 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -3289,10 +3289,10 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h keying->connect("pressed",this,"_keying_toggled"); */ - l = memnew( Label ); +/* l = memnew( Label ); l->set_text("Base: "); l->set_pos(Point2(0,3)); -// dr_panel->add_child(l); +// dr_panel->add_child(l);*/ // menu->get_popup()->connect("item_pressed",this,"_menu_callback"); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 11ceff632..d76009a72 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -1779,3 +1779,11 @@ EditorImportExport::EditorImportExport() { } + +EditorImportExport::~EditorImportExport() { + + + +} + + diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 0970f713e..9704d4a69 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -336,6 +336,7 @@ public: void save_config(); EditorImportExport(); + ~EditorImportExport(); }; VARIANT_ENUM_CAST(EditorImportExport::ImageAction); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b81fcc1de..69b6be621 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -144,6 +144,7 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { void EditorNode::_notification(int p_what) { if (p_what==NOTIFICATION_EXIT_TREE) { + editor_data.save_editor_external_data(); log->deinit(); // do not get messages anymore @@ -1393,7 +1394,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) { } play_button->set_pressed(false); - pause_button->set_pressed(false); + //pause_button->set_pressed(false); play_scene_button->set_pressed(false); String current_filename; @@ -2152,7 +2153,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { editor_run.stop(); play_button->set_pressed(false); play_scene_button->set_pressed(false); - pause_button->set_pressed(false); + //pause_button->set_pressed(false); emit_signal("stop_pressed"); } break; @@ -3023,7 +3024,7 @@ void EditorNode::notify_child_process_exited() { play_button->set_pressed(false); play_scene_button->set_pressed(false); - pause_button->set_pressed(false); + //pause_button->set_pressed(false); stop_button->set_pressed(false); editor_run.stop(); @@ -3306,6 +3307,7 @@ EditorNode::EditorNode() { FileDialog::unregister_func=_file_dialog_unregister; editor_import_export = memnew( EditorImportExport ); + add_child(editor_import_export); register_exporters(); @@ -3491,8 +3493,9 @@ EditorNode::EditorNode() { prev_scene->set_disabled(true); //left_menu_hb->add_child( prev_scene ); prev_scene->connect("pressed",this,"_menu_option",make_binds(FILE_OPEN_PREV)); - //gui_base->add_child(prev_scene); + gui_base->add_child(prev_scene); prev_scene->set_pos(Point2(3,24)); + prev_scene->hide(); Separator *vs=NULL; @@ -3617,14 +3620,14 @@ EditorNode::EditorNode() { - pause_button = memnew( ToolButton ); + /*pause_button = memnew( ToolButton ); //menu_panel->add_child(pause_button); - not needed for now? pause_button->set_toggle_mode(true); pause_button->set_icon(gui_base->get_icon("Pause","EditorIcons")); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE)); pause_button->set_tooltip("Pause the scene (F7)."); - +*/ stop_button = memnew( ToolButton ); play_hb->add_child(stop_button); //stop_button->set_toggle_mode(true); @@ -3641,7 +3644,7 @@ EditorNode::EditorNode() { native_play_button->hide(); native_play_button->get_popup()->connect("item_pressed",this,"_run_in_device"); - VSeparator *s1 = memnew( VSeparator ); +// VSeparator *s1 = memnew( VSeparator ); // play_hb->add_child(s1); play_scene_button = memnew( ToolButton ); @@ -3677,13 +3680,14 @@ EditorNode::EditorNode() { p->set_item_tooltip(p->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),"Deploy dumb clients when the File Server is active."); p->connect("item_pressed",this,"_menu_option"); + /* run_settings_button = memnew( ToolButton ); //menu_hb->add_child(run_settings_button); //run_settings_button->set_toggle_mode(true); run_settings_button->set_focus_mode(Control::FOCUS_NONE); run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons")); run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SCENE_SETTINGS)); - +*/ /* run_settings_button = memnew( ToolButton ); @@ -4246,6 +4250,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { + memdelete(editor_selection); memdelete(file_server); EditorSettings::destroy(); diff --git a/tools/editor/fileserver/editor_file_server.cpp b/tools/editor/fileserver/editor_file_server.cpp index f21d9b4ec..b66a1d522 100644 --- a/tools/editor/fileserver/editor_file_server.cpp +++ b/tools/editor/fileserver/editor_file_server.cpp @@ -278,6 +278,7 @@ void EditorFileServer::_thread_start(void*s) { self->to_wait.erase(w); self->wait_mutex->unlock(); Thread::wait_to_finish(w); + memdelete(w); self->wait_mutex->lock(); } self->wait_mutex->unlock(); @@ -346,5 +347,6 @@ EditorFileServer::~EditorFileServer() { quit=true; Thread::wait_to_finish(thread); + memdelete(thread); memdelete(wait_mutex); } diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 5ce983b3d..b0ff6f6e7 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -650,6 +650,7 @@ public: vbl->add_spacer(); vbl->add_margin_child("Test: ",testhb); + /* HBoxContainer *upd_hb = memnew( HBoxContainer ); // vbl->add_child(upd_hb); upd_hb->add_spacer(); @@ -657,7 +658,7 @@ public: upd_hb->add_child(update); update->set_text("Update"); update->connect("pressed",this,"_update"); - +*/ options = memnew( _EditorFontImportOptions ); prop_edit = memnew( PropertyEditor() ); vbr->add_margin_child("Options:",prop_edit,true); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 184f80a1b..4599dbfb5 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -2127,6 +2127,7 @@ void BakedLightBaker::_stop_thread() { bake_thread_exit=true; for(int i=0;i::Element *Cbone=NULL; //closest + Map::Element *Cbone=NULL; //closest { bone_ik_list.clear(); float closest_dist=1e20; int bone_width = EditorSettings::get_singleton()->get("2d_editor/bone_width"); - for(List::Element *E=bone_list.front();E;E=E->next()) { + for(Map::Element *E=bone_list.front();E;E=E->next()) { if (E->get().from == E->get().to) continue; @@ -1789,7 +1789,7 @@ void CanvasItemEditor::_viewport_draw() { Color bone_ik_color = EditorSettings::get_singleton()->get("2d_editor/bone_ik_color"); Color bone_selected_color = EditorSettings::get_singleton()->get("2d_editor/bone_selected_color"); - for(List::Element*E=bone_list.front();E;E=E->next()) { + for(Map::Element*E=bone_list.front();E;E=E->next()) { E->get().from=Vector2(); E->get().to=Vector2(); @@ -1884,10 +1884,12 @@ void CanvasItemEditor::_notification(int p_what) { } - for(List::Element *E=bone_list.front();E;E=E->next()) { + + for(Map::Element *E=bone_list.front();E;E=E->next()) { Object *b = ObjectDB::get_instance(E->get().bone); if (!b) { + viewport->update(); break; } @@ -1989,9 +1991,14 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, cons if (c->has_meta("_edit_bone_")) { - BoneList bone; - bone.bone=c->get_instance_ID(); - bone_list.push_back(bone); + ObjectID id = c->get_instance_ID(); + if (!bone_list.has(id)) { + BoneList bone; + bone.bone=id; + bone_list[id]=bone; + } + + bone_list[id].last_pass=bone_last_frame; } r_rect.expand_to( xform.xform(rect.pos) ); @@ -2026,11 +2033,26 @@ void CanvasItemEditor::_update_scrollbars() { Rect2 canvas_item_rect=Rect2(Point2(),screen_rect); lock_list.clear();; - bone_list.clear();; + bone_last_frame++; + + if (editor->get_edited_scene()) _find_canvas_items_span(editor->get_edited_scene(),canvas_item_rect,Matrix32()); + List::Element*> bone_to_erase; + + for(Map::Element*E=bone_list.front();E;E=E->next()) { + + if (E->get().last_pass!=bone_last_frame) { + bone_to_erase.push_back(E); + } + } + + while(bone_to_erase.size()) { + bone_list.erase(bone_to_erase.front()->get()); + bone_to_erase.pop_front(); + } //expand area so it's easier to do animations and stuff at 0,0 canvas_item_rect.size+=screen_rect*2; @@ -3024,6 +3046,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { set_process_unhandled_key_input(true); can_move_pivot=false; drag=DRAG_NONE; + bone_last_frame=0; } CanvasItemEditor *CanvasItemEditor::singleton=NULL; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index aa892dca4..48a34e2d0 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -181,9 +181,12 @@ class CanvasItemEditor : public VBoxContainer { Vector2 from; Vector2 to; ObjectID bone; + uint64_t last_pass; }; - List bone_list; + uint64_t bone_last_frame; + Map bone_list; + Matrix32 bone_orig_xform; struct BoneIK { diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index 372e8558f..bb9d1f9dd 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -332,7 +332,8 @@ SampleLibraryEditor::SampleLibraryEditor() { play->set_pos(Point2( 5, 5 )); play->set_size( Size2(1,1 ) ); play->set_toggle_mode(true); - //add_child(play); + add_child(play); + play->hide(); stop = memnew( Button ); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 04a558715..4dae60399 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1764,6 +1764,12 @@ void SpatialEditorViewport::_notification(int p_what) { preview_camera->set_icon(get_icon("Camera","EditorIcons")); _init_gizmo_instance(index); + } + if (p_what==NOTIFICATION_EXIT_TREE) { + + + _finish_gizmo_instances(); + } if (p_what==NOTIFICATION_MOUSE_ENTER) { @@ -2052,6 +2058,16 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { } + +void SpatialEditorViewport::_finish_gizmo_instances() { + + + for(int i=0;i<3;i++) { + VS::get_singleton()->free(move_gizmo_instance[i]); + VS::get_singleton()->free(rotate_gizmo_instance[i]); + } + +} void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -2971,14 +2987,14 @@ void SpatialEditor::_init_indicators() { VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform); - RID mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + //RID mat = VisualServer::get_singleton()->fixed_material_create(); + ///VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); + //VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); { - RID indicator_mat = VisualServer::get_singleton()->fixed_material_create(); + indicator_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false ); VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); @@ -3042,7 +3058,7 @@ void SpatialEditor::_init_indicators() { d[VisualServer::ARRAY_COLOR]=origin_colors; VisualServer::get_singleton()->mesh_add_surface(origin,VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat,true); + VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat); // origin = VisualServer::get_singleton()->poly_create(); @@ -3073,17 +3089,17 @@ void SpatialEditor::_init_indicators() { cursor_points.push_back(Vector3(0,-cs,0)); cursor_points.push_back(Vector3(0,0,+cs)); cursor_points.push_back(Vector3(0,0,-cs)); - RID cmat=VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(cmat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1)); - VisualServer::get_singleton()->material_set_flag( cmat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->fixed_material_set_flag(cmat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(cmat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + cursor_material=VisualServer::get_singleton()->fixed_material_create(); + VisualServer::get_singleton()->fixed_material_set_param(cursor_material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1)); + VisualServer::get_singleton()->material_set_flag( cursor_material, VisualServer::MATERIAL_FLAG_UNSHADED, true ); + VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); + VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); Array d; d.resize(VS::ARRAY_MAX); d[VS::ARRAY_VERTEX]=cursor_points; VisualServer::get_singleton()->mesh_add_surface(cursor_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cmat,true); + VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material); cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario()); VS::get_singleton()->instance_set_layer_mask(cursor_instance,1<free(origin_instance); VisualServer::get_singleton()->free(origin); for(int i=0;i<3;i++) { @@ -3267,6 +3282,8 @@ void SpatialEditor::_finish_indicators() { VisualServer::get_singleton()->free(cursor_instance); VisualServer::get_singleton()->free(cursor_mesh); + VisualServer::get_singleton()->free(indicator_mat); + VisualServer::get_singleton()->free(cursor_material); } void SpatialEditor::_instance_scene() { diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 76ae7bf1e..b890f285e 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -224,6 +224,7 @@ private: void _preview_exited_scene(); void _toggle_camera_preview(bool); void _init_gizmo_instance(int p_idx); + void _finish_gizmo_instances(); protected: @@ -324,6 +325,8 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; + RID indicator_mat; + RID cursor_material; /* struct Selected { diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 5acb27dd3..85adbd3a3 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -1280,8 +1280,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { del->set_text("Del"); del->connect("pressed",this,"_item_del"); + /* Button *save = memnew( Button ); - //props_base->add_child(save); + props_base->add_child(save); + save->set_anchor(MARGIN_LEFT,ANCHOR_END); save->set_anchor(MARGIN_RIGHT,ANCHOR_END); save->set_anchor(MARGIN_TOP,ANCHOR_END); @@ -1290,7 +1292,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { save->set_end( Point2(10,20) ); save->set_text("Save"); save->connect("pressed",this,"_save"); - +*/ popup_platform = memnew( MenuButton ); popup_platform->set_text("Copy To Platform.."); popup_platform->set_disabled(true); @@ -1409,6 +1411,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { device_input->add_child(device_index); + /* save = memnew( Button ); input_base->add_child(save); save->set_anchor(MARGIN_LEFT,ANCHOR_END); @@ -1419,7 +1422,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { save->set_end( Point2(10,20) ); save->set_text("Save"); save->connect("pressed",this,"_save"); - +*/ setting=false; //translations -- cgit v1.2.3-70-g09d2 From 4804462ee06c1b3e2d1b50b857ce8693d3c0936d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 10:44:08 -0300 Subject: -Fixes from source code analyzizer, closes #1768 --- bin/tests/test_physics_2d.cpp | 4 ++-- core/math/math_funcs.cpp | 4 ++-- core/variant_op.cpp | 2 +- drivers/unix/memory_pool_static_malloc.cpp | 2 +- platform/android/export/export.cpp | 8 ++++---- scene/3d/mesh_instance.cpp | 4 ++-- scene/animation/tween.cpp | 2 +- scene/gui/scroll_bar.cpp | 16 ++++++++-------- scene/gui/text_edit.cpp | 2 +- scene/resources/scene_preloader.cpp | 2 +- servers/physics/joints/generic_6dof_joint_sw.cpp | 2 +- servers/physics_2d_server.cpp | 2 +- servers/physics_server.cpp | 2 +- servers/visual/shader_language.cpp | 2 +- tools/collada/collada.cpp | 2 +- tools/editor/animation_editor.cpp | 2 +- tools/editor/io_plugins/editor_sample_import_plugin.cpp | 4 ++-- 17 files changed, 31 insertions(+), 31 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/bin/tests/test_physics_2d.cpp b/bin/tests/test_physics_2d.cpp index a441bed43..70a7d868b 100644 --- a/bin/tests/test_physics_2d.cpp +++ b/bin/tests/test_physics_2d.cpp @@ -191,7 +191,7 @@ class TestPhysics2DMainLoop : public MainLoop { Image image(convex_png); - body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image=vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].image=vs->texture_create_from_image(image); RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON); @@ -206,7 +206,7 @@ class TestPhysics2DMainLoop : public MainLoop { arr.push_back(Point2(11,7)-sb); ps->shape_set_data(convex_polygon_shape,arr); - body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape; + body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].shape = convex_polygon_shape; } diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 490e529d8..6ad5c7499 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -48,8 +48,8 @@ uint32_t Math::rand_from_seed(uint32_t *seed) { s = 0x12345987; k = s / 127773; s = 16807 * (s - k * 127773) - 2836 * k; - if (s < 0) - s += 2147483647; +// if (s < 0) +// s += 2147483647; (*seed) = s; return (s & Math::RANDOM_MAX); #else diff --git a/core/variant_op.cpp b/core/variant_op.cpp index dafe3bd02..f68652b8c 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -2433,7 +2433,7 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const { } else if (str == "pressed") { valid=true; - ie.action.pressed; + return ie.action.pressed; } } diff --git a/drivers/unix/memory_pool_static_malloc.cpp b/drivers/unix/memory_pool_static_malloc.cpp index 62abe7d26..e0bab27a6 100644 --- a/drivers/unix/memory_pool_static_malloc.cpp +++ b/drivers/unix/memory_pool_static_malloc.cpp @@ -153,7 +153,7 @@ void* MemoryPoolStaticMalloc::_realloc(void *p_memory,size_t p_bytes) { return alloc( p_bytes ); } - if (p_bytes<=0) { + if (p_bytes==0) { this->free(p_memory); ERR_FAIL_COND_V( p_bytes < 0 , NULL ); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 4d3f8f110..35ea7f15f 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -641,11 +641,11 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { int iofs=ofs+8; - uint32_t string_count=decode_uint32(&p_manifest[iofs]); - uint32_t styles_count=decode_uint32(&p_manifest[iofs+4]); + string_count=decode_uint32(&p_manifest[iofs]); + styles_count=decode_uint32(&p_manifest[iofs+4]); uint32_t string_flags=decode_uint32(&p_manifest[iofs+8]); - uint32_t string_data_offset=decode_uint32(&p_manifest[iofs+12]); - uint32_t styles_offset=decode_uint32(&p_manifest[iofs+16]); + string_data_offset=decode_uint32(&p_manifest[iofs+12]); + styles_offset=decode_uint32(&p_manifest[iofs+16]); /* printf("string count: %i\n",string_count); printf("flags: %i\n",string_flags); diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 66e29627c..62b32729c 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -168,7 +168,7 @@ Node* MeshInstance::create_trimesh_collision_node() { static_body->add_shape( shape ); return static_body; - return NULL; + } void MeshInstance::create_trimesh_collision() { @@ -202,7 +202,7 @@ Node* MeshInstance::create_convex_collision_node() { static_body->add_shape( shape ); return static_body; - return NULL; + } void MeshInstance::create_convex_collision() { diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index ffa1c09ab..a7a4129a5 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -269,7 +269,7 @@ Variant Tween::_run_equation(InterpolateData& p_data) { { case Variant::BOOL: - result = ((int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec)) >= 0.5; + result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5; break; case Variant::INT: diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 04a559124..b1fd914fc 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -51,20 +51,20 @@ void ScrollBar::_input_event(InputEvent p_event) { if (b.button_index==5 && b.pressed) { - if (orientation==VERTICAL) - set_val( get_val() + get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); + //if (orientation==VERTICAL) + // set_val( get_val() + get_page() / 4.0 ); + //else + set_val( get_val() + get_page() / 4.0 ); accept_event(); } if (b.button_index==4 && b.pressed) { - if (orientation==HORIZONTAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() - get_page() / 4.0 ); + //if (orientation==HORIZONTAL) + // set_val( get_val() - get_page() / 4.0 ); + //else + set_val( get_val() - get_page() / 4.0 ); accept_event(); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index c54333856..1e8243216 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1552,7 +1552,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { case KEY_HOME: case KEY_END: // ignore arrows if any modifiers are held (shift = selecting, others may be used for editor hotkeys) - if (k.mod.command || k.mod.shift || k.mod.alt || k.mod.command) + if (k.mod.command || k.mod.shift || k.mod.alt) break; unselect=true; break; diff --git a/scene/resources/scene_preloader.cpp b/scene/resources/scene_preloader.cpp index 08e88b32c..09001c1a9 100644 --- a/scene/resources/scene_preloader.cpp +++ b/scene/resources/scene_preloader.cpp @@ -407,7 +407,7 @@ Dictionary ScenePreloader::_get_bundled_scene() const { rconns.push_back(cd.signal); rconns.push_back(cd.method); rconns.push_back(cd.binds.size()); - for(int j=0;jop==OP_CONSTRUCT && all_const) { - bool all_const=false; + Vector cdata; for(int i=0;iis_visible() && p_input.is_action("ui_page_up")) - selected_track=selected_track--;; + selected_track--;; if (selected_track<0) selected_track=0; diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index 49b8af67f..d1fe10df0 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -719,8 +719,8 @@ void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector& p_data,D xm_sample=CLAMP(in[i]*32767.0,-32768,32767); - if (xm_sample==32767 || xm_sample==-32768) - printf("clippy!\n",xm_sample); + //if (xm_sample==32767 || xm_sample==-32768) + // printf("clippy!\n",xm_sample); } // xm_sample=xm_sample+xm_prev; -- cgit v1.2.3-70-g09d2 From 1e422941c88105852cc376569b7aa92e7784f4cd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 21:13:20 -0300 Subject: -Fixed android export options (screen sizes, orientation should work) -added functions to get mouse position in CanvasItem --- core/os/input.cpp | 2 +- platform/android/AndroidManifest.xml.template | 4 ++-- platform/android/export/export.cpp | 20 +++++++++----------- scene/2d/canvas_item.cpp | 14 +++++++++++++- scene/2d/canvas_item.h | 3 +++ 5 files changed, 28 insertions(+), 15 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/core/os/input.cpp b/core/os/input.cpp index 4a8718e2d..2b939ede4 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -56,7 +56,7 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis); ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name); ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); - //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); + //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed); ObjectTypeDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask); ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode); diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template index 71e8b866d..c95c86c06 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/AndroidManifest.xml.template @@ -7,7 +7,7 @@ > @@ -15,7 +15,7 @@ android:label="@string/godot_project_name_string" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" - android:screenOrientation="portrait" + android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"> diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 35ea7f15f..e11a2c09c 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -768,19 +768,21 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") { + encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]); + /* print_line("FOUND screen orientation"); if (attr_value==0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else { string_table[attr_value]=(orientation==0?"landscape":"portrait"); - } + }*/ } if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") { print_line("FOUND application"); if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Application name in a resource, should be plaintext.") + WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).") } else { String aname = get_project_name(); @@ -791,7 +793,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { print_line("FOUND activity name"); if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Activity name in a resource, should be plaintext") + WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)") } else { String aname; if (this->name!="") { @@ -835,23 +837,19 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { WARN_PRINT("Screen res name in a resource, should be plaintext") } else if (attrname=="smallScreens") { - print_line("SMALLSCREEN"); - string_table[attr_value]=screen_support[SCREEN_SMALL]?"true":"false"; + encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="mediumScreens") { - print_line("MEDSCREEN"); - string_table[attr_value]=screen_support[SCREEN_NORMAL]?"true":"false"; + encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="largeScreens") { - print_line("LARGECREEN"); - string_table[attr_value]=screen_support[SCREEN_LARGE]?"true":"false"; + encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="xlargeScreens") { - print_line("XLARGECREEN"); - string_table[attr_value]=screen_support[SCREEN_XLARGE]?"true":"false"; + encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } } diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 09c5a2a2b..9b2cdf4ea 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -35,7 +35,7 @@ #include "scene/resources/font.h" #include "scene/resources/texture.h" #include "scene/resources/style_box.h" - +#include "os/input.h" bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) { @@ -1010,6 +1010,16 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const { } +Vector2 CanvasItem::get_global_mouse_pos() const { + + return get_viewport_transform().affine_inverse().xform(Input::get_singleton()->get_mouse_pos()); +} +Vector2 CanvasItem::get_local_mouse_pos() const{ + + return (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Input::get_singleton()->get_mouse_pos()); +} + + void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children); @@ -1075,6 +1085,8 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform); ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect); ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform); + ObjectTypeDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos); + ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos); ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas); ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d); //ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 075563804..6d8308dbe 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -260,6 +260,9 @@ public: InputEvent make_input_local(const InputEvent& pevent) const; + Vector2 get_global_mouse_pos() const; + Vector2 get_local_mouse_pos() const; + CanvasItem(); ~CanvasItem(); }; -- cgit v1.2.3-70-g09d2 From 61e90385f6cbeebb8d3d03c33078802c2fa11eda Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 22:45:32 -0300 Subject: -option to select arm and x86 architectures on android export (will not work with current templates, you have to make new and include both x86 and arm support) --- platform/android/export/export.cpp | 53 +++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index e11a2c09c..d0e2dfbce 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -187,6 +187,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { bool remove_prev; bool use_32_fb; bool immersive; + bool export_arm; + bool export_x86; String apk_expansion_salt; String apk_expansion_pkey; int orientation; @@ -281,6 +283,10 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& icon=p_value; else if (n=="package/signed") _signed=p_value; + else if (n=="architecture/arm") + export_arm=p_value; + else if (n=="architecture/x86") + export_x86=p_value; else if (n=="screen/use_32_bits_view") use_32_fb=p_value; else if (n=="screen/immersive_mode") @@ -350,6 +356,10 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) r_ret=icon; else if (n=="package/signed") r_ret=_signed; + else if (n=="architecture/arm") + r_ret=export_arm; + else if (n=="architecture/x86") + r_ret=export_x86; else if (n=="screen/use_32_bits_view") r_ret=use_32_fb; else if (n=="screen/immersive_mode") @@ -403,6 +413,8 @@ void EditorExportPlatformAndroid::_get_property_list( List *p_list p_list->push_back( PropertyInfo( Variant::STRING, "package/name") ); p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); p_list->push_back( PropertyInfo( Variant::BOOL, "package/signed") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/arm") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/x86") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/use_32_bits_view") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/immersive_mode") ); p_list->push_back( PropertyInfo( Variant::INT, "screen/orientation",PROPERTY_HINT_ENUM,"Landscape,Portrait") ); @@ -1045,6 +1057,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d char fname[16384]; ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); + bool skip=false; + String file=fname; Vector data; @@ -1097,20 +1111,31 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d } } + if (file=="lib/x86/libgodot_android.so" && !export_x86) { + skip=true; + } + + if (file=="lib/armeabi/libgodot_android.so" && !export_arm) { + skip=true; + } + print_line("ADDING: "+file); - zipOpenNewFileInZip(apk, - file.utf8().get_data(), - NULL, - NULL, - 0, - NULL, - 0, - NULL, - Z_DEFLATED, - Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(apk,data.ptr(),data.size()); - zipCloseFileInZip(apk); + if (!skip) { + zipOpenNewFileInZip(apk, + file.utf8().get_data(), + NULL, + NULL, + 0, + NULL, + 0, + NULL, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION); + + zipWriteInFileInZip(apk,data.ptr(),data.size()); + zipCloseFileInZip(apk); + } ret = unzGoToNextFile(pkg); } @@ -1555,6 +1580,10 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() { use_32_fb=true; immersive=true; + export_arm=true; + export_x86=false; + + device_thread=Thread::create(_device_poll_thread,this); devices_changed=true; -- cgit v1.2.3-70-g09d2 From 524d9fad59cd596bb291648c8c2e1b4a46fb2d02 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 23:21:27 -0300 Subject: -fixed godot icon for android -added a genname option to generate the name of android app --- platform/android/export/export.cpp | 37 ++++++++++++++++++++++++---- platform/android/java/res/drawable/icon.png | Bin 91728 -> 17135 bytes 2 files changed, 32 insertions(+), 5 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d0e2dfbce..d169ec51d 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -225,6 +225,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static void _device_poll_thread(void *ud); + String get_package_name(); + String get_project_name() const; void _fix_manifest(Vector& p_manifest); void _fix_resources(Vector& p_manifest); @@ -756,7 +758,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { if (tname=="manifest" && attrname=="package") { print_line("FOUND PACKAGE"); - string_table[attr_value]=package; + string_table[attr_value]=get_package_name(); } //print_line("tname: "+tname); @@ -1169,7 +1171,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (apk_expansion) { - String apkfname="main."+itos(version_code)+"."+package+".obb"; + String apkfname="main."+itos(version_code)+"."+get_package_name()+".obb"; String fullpath=p_path.get_base_dir().plus_file(apkfname); FileAccess *pf = FileAccess::open(fullpath,FileAccess::WRITE); if (!pf) { @@ -1514,7 +1516,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-s"); args.push_back(devices[p_device].id); args.push_back("uninstall"); - args.push_back(package); + args.push_back(get_package_name()); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); #if 0 @@ -1552,7 +1554,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-a"); args.push_back("android.intent.action.MAIN"); args.push_back("-n"); - args.push_back(package+"/com.android.godot.Godot"); + args.push_back(get_package_name()+"/com.android.godot.Godot"); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); if (err || rv!=0) { @@ -1564,12 +1566,37 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { return OK; } +String EditorExportPlatformAndroid::get_package_name() { + + String pname = package; + String basename = Globals::get_singleton()->get("application/name"); + basename=basename.to_lower(); + + String name; + bool first=true; + for(int i=0;i='0' && c<='9' && first) { + continue; + } + if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) { + name+=String::chr(c); + first=false; + } + } + if (name=="") + name="noname"; + + pname=pname.replace("$genname",name); + return pname; + +} EditorExportPlatformAndroid::EditorExportPlatformAndroid() { version_code=1; version_name="1.0"; - package="com.android.noname"; + package="org.godotengine.$genname"; name=""; _signed=true; apk_expansion=false; diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png index 050a1cf93..78757e903 100644 Binary files a/platform/android/java/res/drawable/icon.png and b/platform/android/java/res/drawable/icon.png differ -- cgit v1.2.3-70-g09d2 From 95047562d743b1c1fdc007432c8a0c145a455c5d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 29 Jun 2015 00:29:49 -0300 Subject: Several performance improvements, mainly in loading and instancing scenes and resources. A general speedup should be apparent, with even more peformance increase when compiling optimized. WARNING: Tested and it seems to work, but if something breaks, please report. --- core/bind/core_bind.cpp | 2 + core/globals.cpp | 2 +- core/image.cpp | 8 +-- core/io/http_client.cpp | 2 +- core/io/ip_address.cpp | 2 +- core/io/resource_format_binary.cpp | 2 +- core/io/resource_format_xml.cpp | 75 ++++++++++++++------------- core/method_bind.cpp | 4 +- core/object.cpp | 7 ++- core/object.h | 29 ++++++++--- core/object_type_db.cpp | 22 +++++--- core/object_type_db.h | 14 ++--- core/script_debugger_local.cpp | 16 +++--- core/string_db.cpp | 4 +- core/string_db.h | 12 ++++- core/ustring.cpp | 41 +++++++++++++-- core/ustring.h | 1 + core/variant.cpp | 57 ++++++++++++++++++++ core/variant.h | 1 + core/vector.h | 8 +-- main/main.cpp | 10 ++-- modules/gdscript/gd_script.cpp | 4 +- modules/gridmap/grid_map.cpp | 8 +-- platform/android/export/export.cpp | 8 +-- scene/2d/animated_sprite.cpp | 8 +-- scene/2d/area_2d.cpp | 17 +++--- scene/2d/canvas_item.cpp | 8 +-- scene/2d/collision_object_2d.cpp | 58 +++++++++++++-------- scene/2d/node_2d.cpp | 10 ++-- scene/2d/particles_2d.cpp | 36 ++++++------- scene/2d/sprite.cpp | 34 ++++++------ scene/3d/area.cpp | 4 +- scene/3d/collision_object.cpp | 8 +-- scene/3d/skeleton.cpp | 8 +-- scene/3d/spatial.cpp | 2 +- scene/animation/animation_player.cpp | 21 ++++---- scene/audio/sample_player.cpp | 2 +- scene/gui/base_button.cpp | 6 +-- scene/gui/button.cpp | 8 +-- scene/gui/button_array.cpp | 8 +-- scene/gui/control.cpp | 40 +++++++------- scene/gui/label.cpp | 10 ++-- scene/gui/texture_button.cpp | 16 +++--- scene/gui/texture_frame.cpp | 6 +-- scene/gui/tree.cpp | 6 +-- scene/main/node.cpp | 2 +- scene/resources/animation.cpp | 8 +-- scene/resources/baked_light.cpp | 8 +-- scene/resources/mesh.cpp | 10 ++-- scene/resources/mesh_library.cpp | 8 +-- scene/resources/packed_scene.cpp | 9 ++-- scene/resources/sample_library.cpp | 4 +- scene/resources/theme.cpp | 12 ++--- scene/scene_string_names.cpp | 9 ++++ scene/scene_string_names.h | 12 ++++- tools/collada/collada.cpp | 4 +- tools/doc/doc_data.cpp | 6 +-- tools/docdump/doc_dump.cpp | 4 +- tools/editor/create_dialog.cpp | 4 +- tools/editor/editor_help.cpp | 6 +-- tools/editor/plugins/script_editor_plugin.cpp | 4 +- tools/editor/property_editor.cpp | 4 +- 62 files changed, 475 insertions(+), 294 deletions(-) (limited to 'platform/android/export/export.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 26b1dac6f..120cb0000 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1772,6 +1772,7 @@ void _Thread::_start_func(void *ud) { memdelete(tud); Variant::CallError ce; const Variant* arg[1]={&t->userdata}; + t->ret=t->target_instance->call(t->target_method,arg,1,ce); if (ce.error!=Variant::CallError::CALL_OK) { @@ -1796,6 +1797,7 @@ void _Thread::_start_func(void *ud) { default: {} } + ERR_EXPLAIN("Could not call function '"+t->target_method.operator String()+"'' starting thread ID: "+t->get_id()+" Reason: "+reason); ERR_FAIL(); } diff --git a/core/globals.cpp b/core/globals.cpp index 8a7d66b68..062adc21f 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1321,7 +1321,7 @@ Vector Globals::get_optimizer_presets() const { if (!E->get().name.begins_with("optimizer_presets/")) continue; - names.push_back(E->get().name.get_slice("/",1)); + names.push_back(E->get().name.get_slicec('/',1)); } names.sort(); diff --git a/core/image.cpp b/core/image.cpp index 037018519..c31fa4784 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1016,10 +1016,10 @@ void Image::create( const char ** p_xpm ) { String line_str=line_ptr; line_str.replace("\t"," "); - size_width=line_str.get_slice(" ",0).to_int(); - size_height=line_str.get_slice(" ",1).to_int(); - colormap_size=line_str.get_slice(" ",2).to_int(); - pixelchars=line_str.get_slice(" ",3).to_int(); + size_width=line_str.get_slicec(' ',0).to_int(); + size_height=line_str.get_slicec(' ',1).to_int(); + colormap_size=line_str.get_slicec(' ',2).to_int(); + pixelchars=line_str.get_slicec(' ',3).to_int(); ERR_FAIL_COND(colormap_size > 32766); ERR_FAIL_COND(pixelchars > 5); ERR_FAIL_COND(size_width > 32767); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index dbd009e31..24012660d 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -325,7 +325,7 @@ Error HTTPClient::poll(){ if (i==0 && responses[i].begins_with("HTTP")) { - String num = responses[i].get_slice(" ",1); + String num = responses[i].get_slicec(' ',1); response_num=num.to_int(); } else { diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index c5506f1a7..ed5a45c9e 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -47,7 +47,7 @@ IP_Address::IP_Address(const String& p_string) { } for(int i=0;i<4;i++) { - field[i]=p_string.get_slice(".",i).to_int(); + field[i]=p_string.get_slicec('.',i).to_int(); } } diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 0f6f8a74b..c6cf631de 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1819,7 +1819,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ Property p; p.name_idx=get_string_index(F->get().name); p.value=E->get()->get(F->get().name); - if (F->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && p.value.is_zero()) + if ((F->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && p.value.is_zero())||(F->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && p.value.is_one()) ) continue; p.pi=F->get(); diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 36746a411..b744cbf96 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1207,47 +1207,47 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) r_v=Vector3( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double(), - data.get_slice(",",2).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double(), + data.get_slicec(',',2).to_double() ); } else if (type=="vector2") { r_v=Vector2( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double() ); } else if (type=="plane") { r_v=Plane( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double(), - data.get_slice(",",2).to_double(), - data.get_slice(",",3).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double(), + data.get_slicec(',',2).to_double(), + data.get_slicec(',',3).to_double() ); } else if (type=="quaternion") { r_v=Quat( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double(), - data.get_slice(",",2).to_double(), - data.get_slice(",",3).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double(), + data.get_slicec(',',2).to_double(), + data.get_slicec(',',3).to_double() ); } else if (type=="rect2") { r_v=Rect2( Vector2( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double() ), Vector2( - data.get_slice(",",2).to_double(), - data.get_slice(",",3).to_double() + data.get_slicec(',',2).to_double(), + data.get_slicec(',',3).to_double() ) ); @@ -1256,14 +1256,14 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) r_v=AABB( Vector3( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double(), - data.get_slice(",",2).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double(), + data.get_slicec(',',2).to_double() ), Vector3( - data.get_slice(",",3).to_double(), - data.get_slice(",",4).to_double(), - data.get_slice(",",5).to_double() + data.get_slicec(',',3).to_double(), + data.get_slicec(',',4).to_double(), + data.get_slicec(',',5).to_double() ) ); @@ -1272,7 +1272,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) Matrix32 m3; for (int i=0;i<3;i++) { for (int j=0;j<2;j++) { - m3.elements[i][j]=data.get_slice(",",i*2+j).to_double(); + m3.elements[i][j]=data.get_slicec(',',i*2+j).to_double(); } } r_v=m3; @@ -1282,7 +1282,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) Matrix3 m3; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { - m3.elements[i][j]=data.get_slice(",",i*3+j).to_double(); + m3.elements[i][j]=data.get_slicec(',',i*3+j).to_double(); } } r_v=m3; @@ -1292,24 +1292,24 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) Transform tr; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { - tr.basis.elements[i][j]=data.get_slice(",",i*3+j).to_double(); + tr.basis.elements[i][j]=data.get_slicec(',',i*3+j).to_double(); } } tr.origin=Vector3( - data.get_slice(",",9).to_double(), - data.get_slice(",",10).to_double(), - data.get_slice(",",11).to_double() + data.get_slicec(',',9).to_double(), + data.get_slicec(',',10).to_double(), + data.get_slicec(',',11).to_double() ); r_v=tr; } else if (type=="color") { r_v=Color( - data.get_slice(",",0).to_double(), - data.get_slice(",",1).to_double(), - data.get_slice(",",2).to_double(), - data.get_slice(",",3).to_double() + data.get_slicec(',',0).to_double(), + data.get_slicec(',',1).to_double(), + data.get_slicec(',',2).to_double(), + data.get_slicec(',',3).to_double() ); } else if (type=="node_path") { @@ -1674,8 +1674,8 @@ void ResourceInteractiveLoaderXML::open(FileAccess *p_f) { ERR_FAIL(); } - int major = version.get_slice(".",0).to_int(); - int minor = version.get_slice(".",1).to_int(); + int major = version.get_slicec('.',0).to_int(); + int minor = version.get_slicec('.',1).to_int(); if (major>VERSION_MAJOR) { @@ -2607,9 +2607,12 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res String name = PE->get().name; Variant value = res->get(name); - if (PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero()) + + + if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) ) continue; + write_property(name,value); } diff --git a/core/method_bind.cpp b/core/method_bind.cpp index 3429e5f0a..ce5738043 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -40,8 +40,8 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const { PropertyInfo pi( get_argument_type(p_argument), name ); if ((pi.type==Variant::OBJECT) && name.find(":")!=-1) { pi.hint=PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string=name.get_slice(":",1); - pi.name=name.get_slice(":",0); + pi.hint_string=name.get_slicec(':',1); + pi.name=name.get_slicec(':',0); } return pi; diff --git a/core/object.cpp b/core/object.cpp index 6bb7973ce..07ac430d7 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -258,12 +258,15 @@ bool Object::_predelete() { _predelete_ok=1; notification(NOTIFICATION_PREDELETE,true); + if (_predelete_ok) { + _type_ptr=NULL; //must restore so destructors can access type ptr correctly + } return _predelete_ok; } void Object::_postinitialize() { - + _type_ptr=_get_type_namev(); _initialize_typev(); notification(NOTIFICATION_POSTINITIALIZE); @@ -1707,7 +1710,7 @@ bool Object::is_edited() const { Object::Object() { - + _type_ptr=NULL; _block_signals=false; _predelete_ok=0; _instance_ID=0; diff --git a/core/object.h b/core/object.h index 9680af924..eb0e78a8c 100644 --- a/core/object.h +++ b/core/object.h @@ -82,7 +82,8 @@ enum PropertyUsageFlags { PROPERTY_USAGE_BUNDLE=128, //used for optimized bundles PROPERTY_USAGE_CATEGORY=256, PROPERTY_USAGE_STORE_IF_NONZERO=512, //only store if nonzero - PROPERTY_USAGE_NO_INSTANCE_STATE=1024, + PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false + PROPERTY_USAGE_NO_INSTANCE_STATE=2048, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, @@ -97,6 +98,8 @@ enum PropertyUsageFlags { #define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), m_property, m_setter, m_getter, m_index ) #define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter ) #define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter, m_index ) +#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter ) +#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter, m_index ) struct PropertyInfo { @@ -179,10 +182,10 @@ public:\ virtual String get_type() const { \ return String(#m_type);\ }\ -virtual StringName get_type_name() const { \ +virtual const StringName* _get_type_namev() const { \ if (!_type_name)\ _type_name=get_type_static();\ - return _type_name;\ + return &_type_name;\ }\ static _FORCE_INLINE_ void* get_type_ptr_static() { \ static int ptr;\ @@ -388,6 +391,8 @@ friend void postinitialize_handler(Object*); ScriptInstance *script_instance; RefPtr script; Dictionary metadata; + mutable StringName _type_name; + mutable const StringName* _type_ptr; void _add_user_signal(const String& p_name, const Array& p_pargs=Array()); bool _has_user_signal(const StringName& p_name) const; @@ -445,7 +450,11 @@ protected: Variant _call_deferred_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); - + virtual const StringName* _get_type_namev() const { + if (!_type_name) + _type_name=get_type_static(); + return &_type_name; + } DVector _get_meta_list_bind() const; Array _get_property_list_bind() const; @@ -523,11 +532,19 @@ public: virtual String get_type() const { return "Object"; } virtual String get_save_type() const { return get_type(); } //type stored when saving - virtual StringName get_type_name() const { return StringName("Object"); } + + + virtual bool is_type(const String& p_type) const { return (p_type=="Object"); } virtual bool is_type_ptr(void *p_ptr) const { return get_type_ptr_static()==p_ptr; } - + _FORCE_INLINE_ const StringName& get_type_name() const { + if (!_type_ptr) { + return *_get_type_namev(); + } else { + return *_type_ptr; + } + } /* IAPI */ // void set(const String& p_name, const Variant& p_value); diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index a2cae5094..c29171457 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -205,7 +205,7 @@ ObjectTypeDB::TypeInfo::~TypeInfo() { } -bool ObjectTypeDB::is_type(const String &p_type,const String& p_inherits) { +bool ObjectTypeDB::is_type(const StringName &p_type,const StringName& p_inherits) { OBJTYPE_LOCK; @@ -220,7 +220,7 @@ bool ObjectTypeDB::is_type(const String &p_type,const String& p_inherits) { return false; } -void ObjectTypeDB::get_type_list( List *p_types) { +void ObjectTypeDB::get_type_list( List *p_types) { OBJTYPE_LOCK; @@ -235,7 +235,7 @@ void ObjectTypeDB::get_type_list( List *p_types) { } -void ObjectTypeDB::get_inheriters_from( const String& p_type,List *p_types) { +void ObjectTypeDB::get_inheriters_from( const StringName& p_type,List *p_types) { OBJTYPE_LOCK; @@ -249,7 +249,7 @@ void ObjectTypeDB::get_inheriters_from( const String& p_type,List *p_typ } -String ObjectTypeDB::type_inherits_from(const String& p_type) { +StringName ObjectTypeDB::type_inherits_from(const StringName& p_type) { OBJTYPE_LOCK; @@ -258,7 +258,7 @@ String ObjectTypeDB::type_inherits_from(const String& p_type) { return ti->inherits; } -bool ObjectTypeDB::type_exists(const String &p_type) { +bool ObjectTypeDB::type_exists(const StringName &p_type) { OBJTYPE_LOCK; return types.has(p_type); @@ -269,7 +269,7 @@ void ObjectTypeDB::add_compatibility_type(const StringName& p_type,const StringN compat_types[p_type]=p_fallback; } -Object *ObjectTypeDB::instance(const String &p_type) { +Object *ObjectTypeDB::instance(const StringName &p_type) { TypeInfo *ti; { @@ -287,7 +287,7 @@ Object *ObjectTypeDB::instance(const String &p_type) { return ti->creation_func(); } -bool ObjectTypeDB::can_instance(const String &p_type) { +bool ObjectTypeDB::can_instance(const StringName &p_type) { OBJTYPE_LOCK; @@ -650,7 +650,13 @@ bool ObjectTypeDB::set_property(Object* p_object,const StringName& p_property, c Variant index=psg->index; const Variant* arg[2]={&index,&p_value}; Variant::CallError ce; - p_object->call(psg->setter,arg,2,ce); +// p_object->call(psg->setter,arg,2,ce); + if (psg->_setptr) { + psg->_setptr->call(p_object,arg,2,ce); + } else { + p_object->call(psg->setter,arg,2,ce); + } + } else { const Variant* arg[1]={&p_value}; diff --git a/core/object_type_db.h b/core/object_type_db.h index 27c150696..caa5baddd 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -228,13 +228,13 @@ public: T::register_custom_data_to_otdb(); } - static void get_type_list( List *p_types); - static void get_inheriters_from( const String& p_type,List *p_types); - static String type_inherits_from(const String& p_type); - static bool type_exists(const String &p_type); - static bool is_type(const String &p_type,const String& p_inherits); - static bool can_instance(const String &p_type); - static Object *instance(const String &p_type); + static void get_type_list( List *p_types); + static void get_inheriters_from( const StringName& p_type,List *p_types); + static StringName type_inherits_from(const StringName& p_type); + static bool type_exists(const StringName &p_type); + static bool is_type(const StringName &p_type,const StringName& p_inherits); + static bool can_instance(const StringName &p_type); + static Object *instance(const StringName &p_type); #if 0 template diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index 2266b05f6..649bbe89f 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -60,7 +60,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { if (line.get_slice_count(" ")==1) { print_line("*Frame "+itos(current_frame)+" - "+p_script->debug_get_stack_level_source(current_frame)+":"+itos(p_script->debug_get_stack_level_line(current_frame))+" in function '"+p_script->debug_get_stack_level_function(current_frame)+"'"); } else { - int frame = line.get_slice(" ",1).to_int(); + int frame = line.get_slicec(' ',1).to_int(); if (frame<0 || frame >=total_frames) { print_line("Error: Invalid frame."); } else { @@ -108,7 +108,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { print_line("Usage: print "); } else { - String expr = line.get_slice(" ",2); + String expr = line.get_slicec(' ',2); String res = p_script->debug_parse_stack_level_expression(current_frame,expr); print_line(res); } @@ -130,9 +130,9 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { } else { - String bppos=line.get_slice(" ",1); - String source=bppos.get_slice(":",0).strip_edges(); - int line=bppos.get_slice(":",1).strip_edges().to_int(); + String bppos=line.get_slicec(' ',1); + String source=bppos.get_slicec(':',0).strip_edges(); + int line=bppos.get_slicec(':',1).strip_edges().to_int(); source = breakpoint_find_source(source); @@ -147,9 +147,9 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { clear_breakpoints(); } else { - String bppos=line.get_slice(" ",1); - String source=bppos.get_slice(":",0).strip_edges(); - int line=bppos.get_slice(":",1).strip_edges().to_int(); + String bppos=line.get_slicec(' ',1); + String source=bppos.get_slicec(':',0).strip_edges(); + int line=bppos.get_slicec(':',1).strip_edges().to_int(); source = breakpoint_find_source(source); diff --git a/core/string_db.cpp b/core/string_db.cpp index 57fdd6e70..b48d9f37d 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -158,7 +158,7 @@ void StringName::operator=(const StringName& p_name) { _data = p_name._data; } } - +/* was inlined StringName::operator String() const { if (_data) @@ -166,7 +166,7 @@ StringName::operator String() const { return ""; } - +*/ StringName::StringName(const StringName& p_name) { ERR_FAIL_COND(!configured); diff --git a/core/string_db.h b/core/string_db.h index 912d7513a..3b3249bf5 100644 --- a/core/string_db.h +++ b/core/string_db.h @@ -114,7 +114,17 @@ public: } bool operator!=(const StringName& p_name) const; - operator String() const; + _FORCE_INLINE_ operator String() const { + + if (_data) { + if (_data->cname ) + return String(_data->cname); + else + return _data->name; + } + + return String(); + } static StringName search(const char *p_name); static StringName search(const CharType *p_name); diff --git a/core/ustring.cpp b/core/ustring.cpp index 5df95ac4c..945c84156 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -486,7 +486,7 @@ String String::capitalize() const { String cap; for (int i=0;i0) { slice[0]=_find_upper(slice[0]); @@ -577,6 +577,41 @@ String String::get_slice(String p_splitter, int p_slice) const { } +String String::get_slicec(CharType p_splitter, int p_slice) const { + + if (empty()) + return String(); + + if (p_slice<0) + return String(); + + const CharType *c=this->ptr(); + int i=0; + int prev=0; + int count=0; + while(true) { + + + if (c[i]==0 || c[i]==p_splitter) { + + if (p_slice==count) { + + return substr(prev,i-prev); + } else { + count++; + prev=i+1; + } + + } + + i++; + + } + + return String(); //no find! + +} + Vector String::split_spaces() const { @@ -3333,8 +3368,8 @@ String String::path_to(const String& p_path) const { //nothing } else { //dos style - String src_begin=src.get_slice("/",0); - String dst_begin=dst.get_slice("/",0); + String src_begin=src.get_slicec('/',0); + String dst_begin=dst.get_slicec('/',0); if (src_begin!=dst_begin) return p_path; //impossible to do this diff --git a/core/ustring.h b/core/ustring.h index 53ed31986..1000c1cc8 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -153,6 +153,7 @@ public: int get_slice_count(String p_splitter) const; String get_slice(String p_splitter,int p_slice) const; + String get_slicec(CharType splitter,int p_slice) const; Vector split(const String &p_splitter,bool p_allow_empty=true) const; Vector split_spaces() const; diff --git a/core/variant.cpp b/core/variant.cpp index 034dc2b4f..e0bceb4dd 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -878,6 +878,63 @@ bool Variant::is_zero() const { return false; } + +bool Variant::is_one() const { + + switch( type ) { + case NIL: { + + return true; + } break; + + // atomic types + case BOOL: { + + return _data._bool==true; + } break; + case INT: { + + return _data._int==1; + + } break; + case REAL: { + + return _data._real==1; + + } break; + case VECTOR2: { + + return *reinterpret_cast(_data._mem)==Vector2(1,1); + + } break; + case RECT2: { + + return *reinterpret_cast(_data._mem)==Rect2(1,1,1,1); + + } break; + case VECTOR3: { + + return *reinterpret_cast(_data._mem)==Vector3(1,1,1); + + } break; + case PLANE: { + + return *reinterpret_cast(_data._mem)==Plane(1,1,1,1); + + } break; + case COLOR: { + + return *reinterpret_cast(_data._mem)==Color(1,1,1,1); + + } break; + + default: { return !is_zero(); } + } + + return false; +} + + void Variant::reference(const Variant& p_variant) { diff --git a/core/variant.h b/core/variant.h index 5f338ef66..8fd9662c3 100644 --- a/core/variant.h +++ b/core/variant.h @@ -185,6 +185,7 @@ public: _FORCE_INLINE_ bool is_array() const { return type>=ARRAY; }; bool is_shared() const; bool is_zero() const; + bool is_one() const; operator bool() const; operator signed int() const; diff --git a/core/vector.h b/core/vector.h index b93d9a0de..d10340062 100644 --- a/core/vector.h +++ b/core/vector.h @@ -340,12 +340,14 @@ template void Vector::remove(int p_index) { ERR_FAIL_INDEX(p_index, size()); - for (int i=p_index; i diff --git a/main/main.cpp b/main/main.cpp index 15f969f46..f68bde003 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -524,8 +524,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas ScriptDebuggerRemote *sdr = memnew( ScriptDebuggerRemote ); uint16_t debug_port = GLOBAL_DEF("debug/remote_port",6007); if (debug_host.find(":")!=-1) { - debug_port=debug_host.get_slice(":",1).to_int(); - debug_host=debug_host.get_slice(":",0); + debug_port=debug_host.get_slicec(':',1).to_int(); + debug_host=debug_host.get_slicec(':',0); } Error derr = sdr->connect_to_host(debug_host,debug_port); @@ -546,8 +546,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas file_access_network_client=memnew(FileAccessNetworkClient); int port; if (remotefs.find(":")!=-1) { - port=remotefs.get_slice(":",1).to_int(); - remotefs=remotefs.get_slice(":",0); + port=remotefs.get_slicec(':',1).to_int(); + remotefs=remotefs.get_slicec(':',0); } else { port=6010; } @@ -1219,7 +1219,7 @@ bool Main::start() { String s = E->get().name; if (!s.begins_with("autoload/")) continue; - String name = s.get_slice("/",1); + String name = s.get_slicec('/',1); String path = Globals::get_singleton()->get(s); RES res = ResourceLoader::load(path); ERR_EXPLAIN("Can't autoload: "+path); diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index b6ad7aa71..63bb44784 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -2556,9 +2556,9 @@ void GDScriptLanguage::init() { //populate native classes - List class_list; + List class_list; ObjectTypeDB::get_type_list(&class_list); - for(List::Element *E=class_list.front();E;E=E->next()) { + for(List::Element *E=class_list.front();E;E=E->next()) { StringName n = E->get(); String s = String(n); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 121b23001..4f0daf329 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -130,8 +130,8 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { } else if (name.begins_with("areas/")) { - int which = name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int which = name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (what=="bounds") { ERR_FAIL_COND_V(area_map.has(which),false); create_area(which,p_value); @@ -215,8 +215,8 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const { r_ret= d; } else if (name.begins_with("areas/")) { - int which = name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int which = name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (what=="bounds") r_ret= area_get_bounds(which); else if (what=="name") diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d169ec51d..0f9ce8081 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -317,7 +317,7 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& apk_expansion_pkey=p_value; else if (n.begins_with("permissions/")) { - String what = n.get_slice("/",1).to_upper(); + String what = n.get_slicec('/',1).to_upper(); bool state = p_value; if (state) perms.insert(what); @@ -325,7 +325,7 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& perms.erase(what); } else if (n.begins_with("user_permissions/")) { - int which = n.get_slice("/",1).to_int(); + int which = n.get_slicec('/',1).to_int(); ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false); user_perms[which]=p_value; @@ -390,11 +390,11 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) r_ret=apk_expansion_pkey; else if (n.begins_with("permissions/")) { - String what = n.get_slice("/",1).to_upper(); + String what = n.get_slicec('/',1).to_upper(); r_ret = perms.has(what); } else if (n.begins_with("user_permissions/")) { - int which = n.get_slice("/",1).to_int(); + int which = n.get_slicec('/',1).to_int(); ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false); r_ret=user_perms[which]; } else diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index e350a3401..0b00ac956 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -330,11 +330,11 @@ void AnimatedSprite::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames")); ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); + ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v")); - ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v")); + ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); } diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index f9e79e25b..c44b46adb 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -428,8 +428,9 @@ void Area2D::set_enable_monitoring(bool p_enable) { if (monitoring) { - Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),this,"_body_inout"); - Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,"_area_inout"); + Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_body_inout); + Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_area_inout); + } else { Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),NULL,StringName()); Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),NULL,StringName()); @@ -652,17 +653,17 @@ void Area2D::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Replace"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale")); + ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point")); + ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_gravity"),_SCS("get_gravity")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp")); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled")); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable")); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); } diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 6a1ea0728..789c6bdbe 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1103,14 +1103,14 @@ void CanvasItem::_bind_methods() { BIND_VMETHOD(MethodInfo("_draw")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") ); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); + ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") ); + ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") ); ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") ); - ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") ); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") ); ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material/material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") ); ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"material/use_parent"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") ); //exporting these two things doesn't really make much sense i think diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index f577b8159..8b8caf13d 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -115,19 +115,16 @@ void CollisionObject2D::_update_shapes() { bool CollisionObject2D::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; - if (name=="shape_count") { + if (name.begins_with("shapes/")) { - shapes.resize(p_value); - _update_shapes(); - _change_notify(); - - } else if (name.begins_with("shapes/")) { - - int idx=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); - if (what=="shape") - set_shape(idx,RefPtr(p_value)); - else if (what=="transform") + int idx=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); + if (what=="shape") { + if (idx>=shapes.size()) + add_shape(RefPtr(p_value)); + else + set_shape(idx,RefPtr(p_value)); + } else if (what=="transform") set_shape_transform(idx,p_value); else if (what=="trigger") set_shape_as_trigger(idx,p_value); @@ -143,12 +140,10 @@ bool CollisionObject2D::_get(const StringName& p_name,Variant &r_ret) const { String name=p_name; - if (name=="shape_count") { - r_ret= shapes.size(); - } else if (name.begins_with("shapes/")) { + if (name.begins_with("shapes/")) { - int idx=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int idx=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (what=="shape") r_ret= get_shape(idx); else if (what=="transform") @@ -163,7 +158,7 @@ bool CollisionObject2D::_get(const StringName& p_name,Variant &r_ret) const { void CollisionObject2D::_get_property_list( List *p_list) const { - p_list->push_back( PropertyInfo(Variant::INT,"shape_count",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) ); + //p_list->push_back( PropertyInfo(Variant::INT,"shape_count",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) ); for(int i=0;i& p_shape, const Matrix32& p_transform) { + ERR_FAIL_COND(p_shape.is_null()); + ShapeData sdata; sdata.shape=p_shape; sdata.xform=p_transform; sdata.trigger=false; - shapes.push_back(sdata); - _update_shapes(); + + if (area) + Physics2DServer::get_singleton()->area_add_shape(get_rid(),p_shape->get_rid(),p_transform); + else + Physics2DServer::get_singleton()->body_add_shape(get_rid(),p_shape->get_rid(),p_transform); + + shapes.push_back(sdata); } int CollisionObject2D::get_shape_count() const { @@ -270,8 +272,15 @@ int CollisionObject2D::get_shape_count() const { void CollisionObject2D::set_shape(int p_shape_idx, const Ref& p_shape) { ERR_FAIL_INDEX(p_shape_idx,shapes.size()); + ERR_FAIL_COND(p_shape.is_null()); + shapes[p_shape_idx].shape=p_shape; - _update_shapes(); + if (area) + Physics2DServer::get_singleton()->area_set_shape(get_rid(),p_shape_idx,p_shape->get_rid()); + else + Physics2DServer::get_singleton()->body_set_shape(get_rid(),p_shape_idx,p_shape->get_rid()); + +// _update_shapes(); } void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_transform) { @@ -279,7 +288,12 @@ void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_t ERR_FAIL_INDEX(p_shape_idx,shapes.size()); shapes[p_shape_idx].xform=p_transform; - _update_shapes(); + if (area) + Physics2DServer::get_singleton()->area_set_shape_transform(get_rid(),p_shape_idx,p_transform); + else + Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(),p_shape_idx,p_transform); + +// _update_shapes(); } Ref CollisionObject2D::get_shape(int p_shape_idx) const { diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 99c33c787..6141b6a09 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -398,11 +398,11 @@ void Node2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_relative_transform"),&Node2D::get_relative_transform); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos")); - ADD_PROPERTY(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_rotd"),_SCS("_get_rotd")); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale")); - ADD_PROPERTY(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z")); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative")); + ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos")); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_rotd"),_SCS("_get_rotd")); + ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale")); + ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z")); + ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative")); } diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index f0b7c2be6..8f805ceba 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -1072,19 +1072,19 @@ void Particles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),_SCS("set_amount"),_SCS("get_amount") ); ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_lifetime"),_SCS("get_lifetime") ); - ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/time_scale",PROPERTY_HINT_EXP_RANGE,"0.01,128,0.01"),_SCS("set_time_scale"),_SCS("get_time_scale") ); - ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/preprocess",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_pre_process_time"),_SCS("get_pre_process_time") ); - ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/emit_timeout",PROPERTY_HINT_RANGE,"0,3600,0.1"),_SCS("set_emit_timeout"),_SCS("get_emit_timeout") ); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/emitting"),_SCS("set_emitting"),_SCS("is_emitting") ); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"config/offset"),_SCS("set_emissor_offset"),_SCS("get_emissor_offset")); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"config/half_extents"),_SCS("set_emission_half_extents"),_SCS("get_emission_half_extents")); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/local_space"),_SCS("set_use_local_space"),_SCS("is_using_local_space")); - ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_explosiveness"),_SCS("get_explosiveness")); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/flip_h"),_SCS("set_flip_h"),_SCS("is_flipped_h")); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/flip_v"),_SCS("set_flip_v"),_SCS("is_flipped_v")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); - ADD_PROPERTY(PropertyInfo(Variant::INT,"config/h_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_h_frames"),_SCS("get_h_frames")); - ADD_PROPERTY(PropertyInfo(Variant::INT,"config/v_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_v_frames"),_SCS("get_v_frames")); + ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/time_scale",PROPERTY_HINT_EXP_RANGE,"0.01,128,0.01"),_SCS("set_time_scale"),_SCS("get_time_scale") ); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/preprocess",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_pre_process_time"),_SCS("get_pre_process_time") ); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/emit_timeout",PROPERTY_HINT_RANGE,"0,3600,0.1"),_SCS("set_emit_timeout"),_SCS("get_emit_timeout") ); + ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/emitting"),_SCS("set_emitting"),_SCS("is_emitting") ); + ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/offset"),_SCS("set_emissor_offset"),_SCS("get_emissor_offset")); + ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/half_extents"),_SCS("set_emission_half_extents"),_SCS("get_emission_half_extents")); + ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/local_space"),_SCS("set_use_local_space"),_SCS("is_using_local_space")); + ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_explosiveness"),_SCS("get_explosiveness")); + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_h"),_SCS("set_flip_h"),_SCS("is_flipped_h")); + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_v"),_SCS("set_flip_v"),_SCS("is_flipped_v")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); + ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/h_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_h_frames"),_SCS("get_h_frames")); + ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/v_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_v_frames"),_SCS("get_v_frames")); for(int i=0;i& p_texture) { if (p_texture==texture) return; +#ifdef DEBUG_ENABLED if (texture.is_valid()) { texture->disconnect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->update); } +#endif texture=p_texture; +#ifdef DEBUG_ENABLED if (texture.is_valid()) { texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites texture->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->update); } +#endif update(); item_rect_changed(); } @@ -313,17 +317,17 @@ void Sprite::_bind_methods() { ADD_SIGNAL(MethodInfo("frame_changed")); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v")); - ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes"), _SCS("set_vframes"),_SCS("get_vframes")); - ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes"), _SCS("set_hframes"),_SCS("get_hframes")); - ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame")); - ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region")); - ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect")); + ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture")); + ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); + ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v")); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes"), _SCS("set_vframes"),_SCS("get_vframes")); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes"), _SCS("set_hframes"),_SCS("get_hframes")); + ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame")); + ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region")); + ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect")); } @@ -530,10 +534,10 @@ void ViewportSprite::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate); ObjectTypeDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate); - ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); - ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); + ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path")); + ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); + ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); + ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); } diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index a00946a07..58cbbdba2 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -299,8 +299,8 @@ void Area::set_enable_monitoring(bool p_enable) { if (monitoring) { - PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(),this,"_body_inout"); - PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,"_area_inout"); + PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_body_inout); + PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_area_inout); } else { PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(),NULL,StringName()); PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(),NULL,StringName()); diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index efc5db50e..5ecadb48b 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -122,8 +122,8 @@ bool CollisionObject::_set(const StringName& p_name, const Variant& p_value) { } else if (name.begins_with("shapes/")) { - int idx=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int idx=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (what=="shape") set_shape(idx,RefPtr(p_value)); else if (what=="transform") @@ -148,8 +148,8 @@ bool CollisionObject::_get(const StringName& p_name,Variant &r_ret) const { r_ret= shapes.size(); } else if (name.begins_with("shapes/")) { - int idx=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int idx=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (what=="shape") r_ret= get_shape(idx); else if (what=="transform") diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index ee1b28a8a..9df29f70e 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -41,8 +41,8 @@ bool Skeleton::_set(const StringName& p_path, const Variant& p_value) { if (!path.begins_with("bones/")) return false; - int which=path.get_slice("/",1).to_int(); - String what=path.get_slice("/",2); + int which=path.get_slicec('/',1).to_int(); + String what=path.get_slicec('/',2); if (which==bones.size() && what=="name") { @@ -88,8 +88,8 @@ bool Skeleton::_get(const StringName& p_name,Variant &r_ret) const { if (!path.begins_with("bones/")) return false; - int which=path.get_slice("/",1).to_int(); - String what=path.get_slice("/",2); + int which=path.get_slicec('/',1).to_int(); + String what=path.get_slicec('/',2); ERR_FAIL_INDEX_V( which, bones.size(), false ); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index c672d0e94..7117c5917 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -758,7 +758,7 @@ void Spatial::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("_set_rotation_deg"), _SCS("_get_rotation_deg") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation_rad",PROPERTY_HINT_NONE,"",0), _SCS("set_rotation"), _SCS("get_rotation") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_") ); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_") ); //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), _SCS("set_transform"), _SCS("get_transform") ); ADD_SIGNAL( MethodInfo("visibility_changed" ) ); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 74ae2c0d5..f8b58b5cb 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -35,10 +35,10 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; - if (name=="playback/speed" || name=="speed") { //bw compatibility + if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility set_speed(p_value); - } else if (name=="playback/active") { + } else if (p_name==SceneStringNames::get_singleton()->playback_active) { set_active(p_value); } else if (name.begins_with("playback/play")) { @@ -52,16 +52,16 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) { } else if (name.begins_with("anims/")) { - String which=name.get_slice("/",1); + String which=name.get_slicec('/',1); add_animation(which,p_value); } else if (name.begins_with("next/")) { - String which=name.get_slice("/",1); + String which=name.get_slicec('/',1); animation_set_next(which,p_value); - } else if (name=="blend_times") { + } else if (p_name==SceneStringNames::get_singleton()->blend_times) { Array array=p_value; int len = array.size(); @@ -77,7 +77,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) { set_blend_time(from,to,time); } - } else if (name=="autoplay") { + } else if (p_name==SceneStringNames::get_singleton()->autoplay) { autoplay=p_value; } else @@ -106,12 +106,12 @@ bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const { } else if (name.begins_with("anims/")) { - String which=name.get_slice("/",1); + String which=name.get_slicec('/',1); r_ret= get_animation(which).get_ref_ptr(); } else if (name.begins_with("next/")) { - String which=name.get_slice("/",1); + String which=name.get_slicec('/',1); r_ret= animation_get_next(which); @@ -661,8 +661,11 @@ void AnimationPlayer::_animation_process(float p_delta) { Error AnimationPlayer::add_animation(const StringName& p_name, const Ref& p_animation) { +#ifdef DEBUG_ENABLED ERR_EXPLAIN("Invalid animation name: "+String(p_name)); ERR_FAIL_COND_V( String(p_name).find("/")!=-1 || String(p_name).find(":")!=-1 || String(p_name).find(",")!=-1 || String(p_name).find("[")!=-1, ERR_INVALID_PARAMETER ); +#endif + ERR_FAIL_COND_V( p_animation.is_null() , ERR_INVALID_PARAMETER ); //print_line("Add anim: "+String(p_name)+" name: "+p_animation->get_name()); @@ -1271,7 +1274,7 @@ AnimationPlayer::AnimationPlayer() { animation_process_mode=ANIMATION_PROCESS_IDLE; processing=false; default_blend_time=0; - root=NodePath(".."); + root=SceneStringNames::get_singleton()->path_pp; playing = false; active=true; } diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp index 25e83df39..b93f7e7dd 100644 --- a/scene/audio/sample_player.cpp +++ b/scene/audio/sample_player.cpp @@ -102,7 +102,7 @@ bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const { r_ret= get_sample_library(); } else if (name.begins_with("default/")) { - String what=name.get_slice("/",1); + String what=name.get_slicec('/',1); if (what=="volume_db") r_ret= get_default_volume_db(); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 8b6f433c9..965e7f399 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -390,10 +390,10 @@ void BaseButton::_bind_methods() { ADD_SIGNAL( MethodInfo("pressed" ) ); ADD_SIGNAL( MethodInfo("released" ) ); ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); BIND_CONSTANT( DRAW_NORMAL ); diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index b465db5c8..edeb18bfc 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -225,11 +225,11 @@ void Button::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align); ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat); - ADD_PROPERTY( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") ); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") ); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") ); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") ); } diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index 7f565de24..b86e32dda 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -34,7 +34,7 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { String n=String(p_name); if (n.begins_with("button/")) { - String what = n.get_slice("/",1); + String what = n.get_slicec('/',1); if (what=="count") { int new_size=p_value; if (new_size>0 && buttons.size()==0) { @@ -57,7 +57,7 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { } else { int idx=what.to_int(); ERR_FAIL_INDEX_V(idx,buttons.size(),false); - String f = n.get_slice("/",2); + String f = n.get_slicec('/',2); if (f=="text") buttons[idx].text=p_value; else if (f=="icon") @@ -80,7 +80,7 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const { String n=String(p_name); if (n.begins_with("button/")) { - String what = n.get_slice("/",1); + String what = n.get_slicec('/',1); if (what=="count") { r_ret=buttons.size(); } else if (what=="align") { @@ -92,7 +92,7 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const { } else { int idx=what.to_int(); ERR_FAIL_INDEX_V(idx,buttons.size(),false); - String f = n.get_slice("/",2); + String f = n.get_slicec('/',2); if (f=="text") r_ret=buttons[idx].text; else if (f=="icon") diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2367c03e9..a1c064465 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -136,27 +136,27 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) { if (p_value.get_type()==Variant::NIL) { if (name.begins_with("custom_icons/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.icon_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_styles/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.style_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_fonts/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.font_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_colors/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.color_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_constants/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.constant_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); @@ -165,23 +165,23 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) { } else { if (name.begins_with("custom_icons/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); notification(NOTIFICATION_THEME_CHANGED); add_icon_override(dname,p_value); } else if (name.begins_with("custom_styles/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_style_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_fonts/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_font_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_colors/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_color_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_constants/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_constant_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else @@ -217,22 +217,22 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const { return false; if (sname.begins_with("custom_icons/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.icon_override.has(name)?Variant(data.icon_override[name]):Variant(); } else if (sname.begins_with("custom_styles/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.style_override.has(name)?Variant(data.style_override[name]):Variant(); } else if (sname.begins_with("custom_fonts/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.font_override.has(name)?Variant(data.font_override[name]):Variant(); } else if (sname.begins_with("custom_colors/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.color_override.has(name)?Variant(data.color_override[name]):Variant(); } else if (sname.begins_with("custom_constants/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.constant_override.has(name)?Variant(data.constant_override[name]):Variant(); } else @@ -2832,16 +2832,16 @@ void Control::_bind_methods() { 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::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM ); + 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 ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") ); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") ); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") ); - ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") ); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") ); ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") ); BIND_CONSTANT( ANCHOR_BEGIN ); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 27d0f568a..e7af4fa34 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -613,11 +613,11 @@ void Label::_bind_methods() { BIND_CONSTANT( VALIGN_BOTTOM ); BIND_CONSTANT( VALIGN_FILL ); - ADD_PROPERTY( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") ); } diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 823fd55c6..5b2caecb5 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -157,14 +157,14 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_scale"),&TextureButton::get_scale); ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale")); - ADD_PROPERTY(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture")); + 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::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); } diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_frame.cpp index 931fb1cb1..5a6bc8663 100644 --- a/scene/gui/texture_frame.cpp +++ b/scene/gui/texture_frame.cpp @@ -77,9 +77,9 @@ void TextureFrame::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand ); ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand ); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); - ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); + ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index a09920cb2..6c15f1cae 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1106,7 +1106,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& int option = (int)p_item->cells[i].val; String s = p_item->cells[i].text; - s=s.get_slice(",",option); + s=s.get_slicec(',',option); Ref downarrow = cache.select_arrow; @@ -1527,7 +1527,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ popup_menu->clear(); for (int i=0;iadd_item(s,i); } @@ -2234,7 +2234,7 @@ bool Tree::edit_selected() { popup_menu->clear(); for (int i=0;iadd_item(s,i); } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b7fa5c830..7e31bf8dd 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1891,7 +1891,7 @@ void Node::_bind_methods() { #ifdef TOOLS_ENABLED ObjectTypeDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path); ObjectTypeDB::bind_method(_MD("_get_import_path"),&Node::get_import_path); - ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_path"),_SCS("_get_import_path")); + ADD_PROPERTYNZ( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_path"),_SCS("_get_import_path")); #endif diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 095406dad..9d668a571 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -42,8 +42,8 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { set_step(p_value); else if (name.begins_with("tracks/")) { - int track=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int track=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (tracks.size()==track && what=="type") { @@ -257,8 +257,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { r_ret= step; else if (name.begins_with("tracks/")) { - int track=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int track=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); ERR_FAIL_INDEX_V( track, tracks.size(), false ); if (what=="type") { diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp index 226edec9a..31282a027 100644 --- a/scene/resources/baked_light.cpp +++ b/scene/resources/baked_light.cpp @@ -311,11 +311,11 @@ bool BakedLight::_set(const StringName& p_name, const Variant& p_value) { String n = p_name; if (!n.begins_with("lightmap")) return false; - int idx = n.get_slice("/",1).to_int(); + int idx = n.get_slicec('/',1).to_int(); ERR_FAIL_COND_V(idx<0,false); ERR_FAIL_COND_V(idx>lightmaps.size(),false); - String what = n.get_slice("/",2); + String what = n.get_slicec('/',2); Ref tex; Size2 gens; @@ -343,11 +343,11 @@ bool BakedLight::_get(const StringName& p_name,Variant &r_ret) const{ String n = p_name; if (!n.begins_with("lightmap")) return false; - int idx = n.get_slice("/",1).to_int(); + int idx = n.get_slicec('/',1).to_int(); ERR_FAIL_COND_V(idx<0,false); ERR_FAIL_COND_V(idx>lightmaps.size(),false); - String what = n.get_slice("/",2); + String what = n.get_slicec('/',2); if (what=="texture") { if (idx==lightmaps.size()) diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 039a4788d..8cb090441 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -99,7 +99,7 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { if (sl==-1) return false; int idx=sname.substr(8,sl-8).to_int()-1; - String what = sname.get_slice("/",1); + String what = sname.get_slicec('/',1); if (what=="material") surface_set_material(idx,p_value); else if (what=="name") @@ -117,8 +117,8 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { return false; - int idx=sname.get_slice("/",1).to_int(); - String what=sname.get_slice("/",2); + int idx=sname.get_slicec('/',1).to_int(); + String what=sname.get_slicec('/',2); if (idx==surfaces.size()) { @@ -180,7 +180,7 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const { if (sl==-1) return false; int idx=sname.substr(8,sl-8).to_int()-1; - String what = sname.get_slice("/",1); + String what = sname.get_slicec('/',1); if (what=="material") r_ret=surface_get_material(idx); else if (what=="name") @@ -195,7 +195,7 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const { return false; - int idx=sname.get_slice("/",1).to_int(); + int idx=sname.get_slicec('/',1).to_int(); ERR_FAIL_INDEX_V(idx,surfaces.size(),false); Dictionary d; diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index ffa29572f..5ebab9be7 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -35,8 +35,8 @@ bool MeshLibrary::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (name.begins_with("item/")) { - int idx = name.get_slice("/",1).to_int(); - String what = name.get_slice("/",2); + int idx = name.get_slicec('/',1).to_int(); + String what = name.get_slicec('/',2); if (!item_map.has(idx)) create_item(idx); @@ -60,9 +60,9 @@ bool MeshLibrary::_set(const StringName& p_name, const Variant& p_value) { bool MeshLibrary::_get(const StringName& p_name,Variant &r_ret) const { String name=p_name; - int idx = name.get_slice("/",1).to_int(); + int idx = name.get_slicec('/',1).to_int(); ERR_FAIL_COND_V(!item_map.has(idx),false); - String what = name.get_slice("/",2); + String what = name.get_slicec('/',2); if(what=="name") r_ret= get_item_name(idx); diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index a1cb1205e..b6082c3a7 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -53,7 +53,7 @@ Node *PackedScene::instance(bool p_gen_edit_state) const { if (prop_count) props=&variants[0]; - Vector properties; + //Vector properties; const NodeData *nd = &nodes[0]; @@ -257,10 +257,13 @@ Error PackedScene::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map< String name = E->get().name; Variant value = p_node->get( E->get().name ); - if (E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero()) { + if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) { continue; } + print_line("PASSED!"); + print_line("at: "+String(p_node->get_name())+"::"+name+": - nz: "+itos(E->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO)+" no: "+itos(E->get().usage&PROPERTY_USAGE_STORE_IF_NONONE)); + print_line("value: "+String(value)+" is zero: "+itos(value.is_zero())+" is one" +itos(value.is_one())); if (nd.instance>=0) { //only save changed properties in instance @@ -278,7 +281,7 @@ Error PackedScene::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map< continue; } - if (instance_state[name]==value) { + if (instance_state.has(name) && instance_state[name]==value) { continue; } diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp index 6bb9bc0d0..ffcaa1e67 100644 --- a/scene/resources/sample_library.cpp +++ b/scene/resources/sample_library.cpp @@ -34,7 +34,7 @@ bool SampleLibrary::_set(const StringName& p_name, const Variant& p_value) { if (String(p_name).begins_with("samples/")) { - String name=String(p_name).get_slice("/",1); + String name=String(p_name).get_slicec('/',1); if (p_value.get_type()==Variant::NIL) sample_map.erase(name); else { @@ -66,7 +66,7 @@ bool SampleLibrary::_get(const StringName& p_name,Variant &r_ret) const { if (String(p_name).begins_with("samples/")) { - String name=String(p_name).get_slice("/",1); + String name=String(p_name).get_slicec('/',1); if(sample_map.has(name)) { Dictionary d; d["sample"]=sample_map[name].sample; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 21bdb6c0a..3060fe41b 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -40,9 +40,9 @@ bool Theme::_set(const StringName& p_name, const Variant& p_value) { if (sname.find("/")!=-1) { - String type=sname.get_slice("/",1); - String node_type=sname.get_slice("/",0); - String name=sname.get_slice("/",2); + String type=sname.get_slicec('/',1); + String node_type=sname.get_slicec('/',0); + String name=sname.get_slicec('/',2); if (type=="icons") { @@ -75,9 +75,9 @@ bool Theme::_get(const StringName& p_name,Variant &r_ret) const { if (sname.find("/")!=-1) { - String type=sname.get_slice("/",1); - String node_type=sname.get_slice("/",0); - String name=sname.get_slice("/",2); + String type=sname.get_slicec('/',1); + String node_type=sname.get_slicec('/',0); + String name=sname.get_slicec('/',2); if (type=="icons") { diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 2689c1471..9509878dc 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -68,6 +68,8 @@ SceneStringNames::SceneStringNames() { area_enter_shape = StaticCString::create("area_enter_shape"); area_exit_shape = StaticCString::create("area_exit_shape"); + _body_inout = StaticCString::create("_body_inout"); + _area_inout = StaticCString::create("_area_inout"); idle=StaticCString::create("idle"); iteration=StaticCString::create("iteration"); @@ -161,4 +163,11 @@ SceneStringNames::SceneStringNames() { frame_changed=StaticCString::create("frame_changed"); + playback_speed=StaticCString::create("playback/speed"); + playback_active=StaticCString::create("playback/active"); + autoplay=StaticCString::create("autoplay"); + blend_times=StaticCString::create("blend_times"); + speed=StaticCString::create("speed"); + + path_pp=NodePath(".."); } diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 83e817dbf..48f17ed38 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -30,7 +30,7 @@ #define SCENE_STRING_NAMES_H #include "string_db.h" - +#include "path_db.h" class SceneStringNames { friend void register_scene_types(); @@ -87,6 +87,8 @@ public: StringName area_enter_shape; StringName area_exit_shape; + StringName _body_inout; + StringName _area_inout; StringName _get_gizmo_geometry; @@ -170,6 +172,14 @@ public: StringName frame_changed; + StringName playback_speed; + StringName playback_active; + StringName autoplay; + StringName blend_times; + StringName speed; + + NodePath path_pp; + }; diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index b7ec5c9d0..deec5f60c 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -2054,8 +2054,8 @@ void Collada::_parse_animation(XMLParser& parser) { } if (target.find("/")!=-1) { //transform component - track.target=target.get_slice("/",0); - track.param=target.get_slice("/",1); + track.target=target.get_slicec('/',0); + track.param=target.get_slicec('/',1); if (track.param.find(".")!=-1) track.component=track.param.get_slice(".",1).to_upper(); track.param=track.param.get_slice(".",0); diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index b3eb6b08f..08697ab72 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -137,9 +137,9 @@ void DocData::merge_from(const DocData& p_data) { void DocData::generate(bool p_basic_types) { - List classes; + List classes; ObjectTypeDB::get_type_list(&classes); - classes.sort(); + classes.sort_custom(); while(classes.size()) { @@ -547,7 +547,7 @@ void DocData::generate(bool p_basic_types) { Globals::Singleton &s=E->get(); pd.name=s.name; pd.type=s.ptr->get_type(); - while (ObjectTypeDB::type_inherits_from(pd.type)!="Object") + while (String(ObjectTypeDB::type_inherits_from(pd.type))!="Object") pd.type=ObjectTypeDB::type_inherits_from(pd.type); if (pd.type.begins_with("_")) pd.type=pd.type.substr(1,pd.type.length()); diff --git a/tools/docdump/doc_dump.cpp b/tools/docdump/doc_dump.cpp index 17aff3dc7..5f108ee9c 100644 --- a/tools/docdump/doc_dump.cpp +++ b/tools/docdump/doc_dump.cpp @@ -76,10 +76,10 @@ static String _escape_string(const String& p_str) { void DocDump::dump(const String& p_file) { - List class_list; + List class_list; ObjectTypeDB::get_type_list(&class_list); - class_list.sort(); + class_list.sort_custom(); FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index c0f35a4ac..a9119349c 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -128,7 +128,7 @@ void CreateDialog::_update_search() { _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); */ - List type_list; + List type_list; ObjectTypeDB::get_type_list(&type_list); HashMap types; @@ -137,7 +137,7 @@ void CreateDialog::_update_search() { root->set_text(0,base_type); - List::Element *I=type_list.front(); + List::Element *I=type_list.front(); TreeItem *to_select=NULL; for(;I;I=I->next()) { diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 25fc526bf..213c18e1b 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -79,7 +79,7 @@ void EditorHelpSearch::_update_search() { _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); */ - List type_list; + List type_list; ObjectTypeDB::get_type_list(&type_list); DocData *doc=EditorHelp::get_doc_data(); @@ -1241,13 +1241,13 @@ void EditorHelp::_update_doc() { class_list->clear(); - List type_list; + List type_list; tree_item_map.clear(); TreeItem *root = class_list->create_item(); class_list->set_hide_root(true); - List::Element *I=type_list.front(); + List::Element *I=type_list.front(); for(Map::Element *E=doc->class_list.front();E;E=E->next()) { diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index b15abf809..3ef240e74 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -321,10 +321,10 @@ void ScriptTextEditor::_load_theme_settings() { //colorize engine types Color type_color= EDITOR_DEF("text_editor/engine_type_color",Color(0.0,0.2,0.4)); - List types; + List types; ObjectTypeDB::get_type_list(&types); - for(List::Element *E=types.front();E;E=E->next()) { + for(List::Element *E=types.front();E;E=E->next()) { get_text_edit()->add_keyword_color(E->get(),type_color); } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 2fa8b98ff..955c426d2 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -614,9 +614,9 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty Set valid_inheritors; valid_inheritors.insert(base); - List inheritors; + List inheritors; ObjectTypeDB::get_inheriters_from(base.strip_edges(),&inheritors); - List::Element *E=inheritors.front(); + List::Element *E=inheritors.front(); while(E) { valid_inheritors.insert(E->get()); E=E->next(); -- cgit v1.2.3-70-g09d2