diff options
-rw-r--r-- | core/image.cpp | 19 | ||||
-rw-r--r-- | core/io/http_client.cpp | 1 | ||||
-rw-r--r-- | core/variant_parser.cpp | 15 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 14 | ||||
-rw-r--r-- | scene/2d/canvas_item.cpp | 7 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 3 | ||||
-rw-r--r-- | scene/main/node.cpp | 4 | ||||
-rw-r--r-- | scene/main/node.h | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 12 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 3 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 11 | ||||
-rw-r--r-- | tools/editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_font_import_plugin.cpp | 26 | ||||
-rw-r--r-- | tools/editor/plugins/editor_preview_plugins.cpp | 10 | ||||
-rw-r--r-- | tools/editor/plugins/mesh_instance_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | tools/editor/plugins/sample_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 12 |
18 files changed, 135 insertions, 28 deletions
diff --git a/core/image.cpp b/core/image.cpp index 57496683ef..d6ac3f28ea 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1735,8 +1735,17 @@ Error Image::_decompress_bc() { print_line("decompressing bc"); + int wd=width,ht=height; + if (wd%4!=0) { + wd+=4-(wd%4); + } + if (ht%4!=0) { + ht+=4-(ht%4); + } + + int mm; - int size = _get_dst_image_size(width,height,FORMAT_RGBA,mm,mipmaps); + int size = _get_dst_image_size(wd,ht,FORMAT_RGBA,mm,mipmaps); DVector<uint8_t> newdata; newdata.resize(size); @@ -1746,7 +1755,8 @@ Error Image::_decompress_bc() { int rofs=0; int wofs=0; - int wd=width,ht=height; + + //print_line("width: "+itos(wd)+" height: "+itos(ht)); for(int i=0;i<=mm;i++) { @@ -2051,6 +2061,11 @@ Error Image::_decompress_bc() { data=newdata; format=FORMAT_RGBA; + if (wd!=width || ht!=height) { + //todo, crop + width=wd; + height=ht; + } return OK; } diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 3520680118..0dfae6584b 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -76,6 +76,7 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){ close(); connection=p_connection; + status=STATUS_CONNECTED; } diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 886bea2910..dce873a306 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1775,7 +1775,20 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r } if (c>32) { - if (c!='=') { + if (c=='"') { //quoted + p_stream->saved='"'; + Token tk; + Error err = get_token(p_stream,tk,line,r_err_str); + if (err) + return err; + if (tk.type!=TK_STRING) { + r_err_str="Error reading quoted string"; + return err; + } + + what=tk.value; + + } else if (c!='=') { what+=String::chr(c); } else { r_assign=what; diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 73d54b6afa..cdf17e3161 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -115,7 +115,17 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private int mState; private boolean keep_screen_on=true; - private void setState(int newState) { + static private Intent mCurrentIntent; + + @Override public void onNewIntent(Intent intent) { + mCurrentIntent = intent; + } + + static public Intent getCurrentIntent() { + return mCurrentIntent; + } + + private void setState(int newState) { if (mState != newState) { mState = newState; mStatusText.setText(Helpers.getDownloaderStringResourceIDFromState(newState)); @@ -545,6 +555,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } } + mCurrentIntent = getIntent(); + initializeGodot(); diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index fa9b040d92..eb37634b24 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1003,11 +1003,14 @@ 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()); + ERR_FAIL_COND_V(!get_viewport(),Vector2()); + return get_canvas_transform().affine_inverse().xform( get_viewport()->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()); + ERR_FAIL_COND_V(!get_viewport(),Vector2()); + + return get_global_transform().affine_inverse().xform( get_global_mouse_pos() ); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7fbd412de8..5e18da32aa 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1209,6 +1209,9 @@ void TextEdit::_notification(int p_what) { } break; case NOTIFICATION_FOCUS_ENTER: { + if (!caret_blink_enabled) { + draw_caret = true; + } if (OS::get_singleton()->has_virtual_keyboard()) OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect()); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 50b0fe224e..11b400d4a9 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2081,6 +2081,10 @@ void Node::update_configuration_warning() { } +bool Node::is_owned_by_parent() const { + return data.parent_owned; +} + void Node::_bind_methods() { ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false)); diff --git a/scene/main/node.h b/scene/main/node.h index a3b8d8de81..88334f32f0 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -313,6 +313,8 @@ public: NodePath get_import_path() const; #endif + bool is_owned_by_parent() const; + void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const; void clear_internal_tree_resource_paths(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 3bb3a70468..a1df7062ea 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1574,6 +1574,14 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) { // _block(); + + //mouse wheel events can't be stopped + bool cant_stop_me_now = (p_input.type==InputEvent::MOUSE_BUTTON && + (p_input.mouse_button.button_index==BUTTON_WHEEL_DOWN || + p_input.mouse_button.button_index==BUTTON_WHEEL_UP || + p_input.mouse_button.button_index==BUTTON_WHEEL_LEFT || + p_input.mouse_button.button_index==BUTTON_WHEEL_RIGHT ) ); + CanvasItem *ci=p_control; while(ci) { @@ -1589,7 +1597,7 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) { break; if (gui.key_event_accepted) break; - if (control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION)) + if (!cant_stop_me_now && control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION)) break; } @@ -2361,8 +2369,8 @@ void Viewport::input(const InputEvent& p_event) { ERR_FAIL_COND(!is_inside_tree()); - get_tree()->_call_input_pause(input_group,"_input",p_event); _gui_input_event(p_event); + get_tree()->_call_input_pause(input_group,"_input",p_event); //get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5ac7946391..ac528e6659 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1413,8 +1413,7 @@ NodePath SceneState::get_node_path(int p_idx,bool p_for_parent) const { } } - for(int i=0;i<base_path.get_name_count();i++) { - StringName sn = base_path.get_name(i); + for(int i=base_path.get_name_count()-1;i>=0;i--) { sub_path.insert(0,base_path.get_name(i)); } diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index a734f63ac2..c7e2fc4e73 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -1140,7 +1140,12 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b } +static String _valprop(const String& p_name) { + if (p_name.find("\"")!=-1 || p_name.find("=")!=-1 || p_name.find(" ")!=-1) + return "\""+p_name.c_escape()+"\""; + return p_name; +} Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_resource,uint32_t p_flags) { @@ -1296,7 +1301,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re String vars; VariantWriter::write_to_string(value,vars,_write_resources,this); - f->store_string(name+" = "+vars+"\n"); + f->store_string(_valprop(name)+" = "+vars+"\n"); } @@ -1320,8 +1325,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re Vector<StringName> groups = state->get_node_groups(i); - if (instance.is_valid()) - print_line("for path "+String(path)+" instance "+instance->get_path()); String header="[node"; header+=" name=\""+String(name)+"\""; @@ -1372,7 +1375,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re String vars; VariantWriter::write_to_string(state->get_node_property_value(i,j),vars,_write_resources,this); - f->store_string(String(state->get_node_property_name(i,j))+" = "+vars+"\n"); + f->store_string(_valprop(String(state->get_node_property_name(i,j)))+" = "+vars+"\n"); } if (state->get_node_property_count(i)) { diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 0fffaca782..49a1158ec6 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -583,7 +583,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("3d_editor/zoom_modifier",4); hints["3d_editor/zoom_modifier"]=PropertyInfo(Variant::INT,"3d_editor/zoom_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl"); set("3d_editor/emulate_numpad",false); - set("3d_editor/trackpad_hint", false); + set("3d_editor/emulate_3_button_mouse", false); set("2d_editor/bone_width",5); set("2d_editor/bone_color1",Color(1.0,1.0,1.0,0.9)); diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 97ccb766c0..70bc44ba7d 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -102,6 +102,7 @@ public: bool disable_filter; bool round_advance; + bool premultiply_alpha; @@ -167,6 +168,8 @@ public: round_advance=p_value; else if (n=="advanced/disable_filter") disable_filter=p_value; + else if (n=="advanced/premultiply_alpha") + premultiply_alpha=p_value; else return false; @@ -235,6 +238,8 @@ public: r_ret=round_advance; else if (n=="advanced/disable_filter") r_ret=disable_filter; + else if (n=="advanced/premultiply_alpha") + r_ret=premultiply_alpha; else return false; @@ -297,6 +302,7 @@ public: p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/round_advance")); p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/disable_filter")); + p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/premultiply_alpha")); } @@ -336,6 +342,7 @@ public: font_mode=FONT_BITMAP; round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -368,6 +375,7 @@ public: round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -1542,12 +1550,30 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe } + if (from->has_option("advanced/premultiply_alpha") && bool(from->get_option("advanced/premultiply_alpha"))) { + + DVector<uint8_t> data = atlas.get_data(); + int dl = data.size(); + { + DVector<uint8_t>::Write w = data.write(); + + for(int i=0;i<dl;i+=4) { + + w[i+0]= uint8_t(int(w[i+0])*int(w[i+3])/255); + w[i+1]= uint8_t(int(w[i+1])*int(w[i+3])/255); + w[i+2]= uint8_t(int(w[i+2])*int(w[i+3])/255); + } + } + + atlas=Image(res_size.x,res_size.y,0,Image::FORMAT_RGBA,data); + } if (from->has_option("color/monochrome") && bool(from->get_option("color/monochrome"))) { atlas.convert(Image::FORMAT_GRAYSCALE_ALPHA); } + if (0) { //debug the texture Ref<ImageTexture> atlast = memnew( ImageTexture ); diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index f5470451ba..a057e6c2a1 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -669,7 +669,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -687,8 +687,8 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { float max[2]={-1e10,-1e10}; float min[2]={1e10,1e10}; int c=stereo?2:1; - int from = i*len/w; - int to = (i+1)*len/w; + int from = uint64_t(i)*len/w; + int to = (uint64_t(i)+1)*len/w; if (to>=len) to=len-1; @@ -699,7 +699,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/32768.0; + float v = src[uint64_t(k)*c+j]/32768.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -715,7 +715,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/128.0; + float v = src[uint64_t(k)*c+j]/128.0; if (v>max[j]) max[j]=v; if (v<min[j]) diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.cpp b/tools/editor/plugins/mesh_instance_editor_plugin.cpp index f604e4c57c..c952feb1da 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_instance_editor_plugin.cpp @@ -183,6 +183,12 @@ void MeshInstanceEditor::_create_outline_mesh() { return; } + if (mesh->get_surface_count() == 0) { + err_dialog->set_text(TTR("Mesh has not surface to create outlines from!")); + err_dialog->popup_centered_minsize(); + return; + } + Ref<Mesh> mesho = mesh->create_outline(outline_size->get_val()); if (mesho.is_null()) { diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index a3891a648b..b094184a29 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -211,7 +211,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -229,8 +229,8 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag float max[2]={-1e10,-1e10}; float min[2]={1e10,1e10}; int c=stereo?2:1; - int from = i*len/w; - int to = (i+1)*len/w; + int from = uint64_t(i)*len/w; + int to = (uint64_t(i)+1)*len/w; if (to>=len) to=len-1; @@ -241,7 +241,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int k=from;k<=to;k++) { - float v = src[k*c+j]/32768.0; + float v = src[uint64_t(k)*c+j]/32768.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -257,7 +257,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int k=from;k<=to;k++) { - float v = src[k*c+j]/128.0; + float v = src[uint64_t(k)*c+j]/128.0; if (v>max[j]) max[j]=v; if (v<min[j]) @@ -270,7 +270,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag if (!stereo) { for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -297,7 +297,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; } - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[half] && v<max[half]) { imgofs[0]=255; imgofs[1]=150; diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index fdb654571a..8d72178f23 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1580,7 +1580,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { nav_mode = NAVIGATION_PAN; } - } else if (EditorSettings::get_singleton()->get("3d_editor/trackpad_hint")) { + } else if (EditorSettings::get_singleton()->get("3d_editor/emulate_3_button_mouse")) { // Handle trackpad (no external mouse) use case int mod = 0; if (m.mod.shift) diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 69d6d97980..30ffdf6664 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1388,6 +1388,13 @@ void SceneTreeDock::_create() { } String newname=n->get_name(); + + List<Node*> to_erase; + for(int i=0;i<n->get_child_count();i++) { + if (n->get_child(i)->get_owner()==NULL && n->is_owned_by_parent()) { + to_erase.push_back(n->get_child(i)); + } + } n->replace_by(newnode,true); if (n==edited_scene) { @@ -1408,6 +1415,11 @@ void SceneTreeDock::_create() { memdelete(n); + while(to_erase.front()) { + memdelete(to_erase.front()->get()); + to_erase.pop_front(); + } + } |