summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/color.cpp2
-rw-r--r--doc/classes/BaseButton.xml4
-rw-r--r--doc/classes/LineEdit.xml4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp110
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp8
-rw-r--r--scene/gui/base_button.cpp4
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/resources/bit_mask.cpp4
9 files changed, 88 insertions, 53 deletions
diff --git a/core/color.cpp b/core/color.cpp
index 7278b5c4ee..36afe5e004 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -396,7 +396,7 @@ String Color::to_html(bool p_alpha) const {
txt += _to_hex(g);
txt += _to_hex(b);
if (p_alpha)
- txt = _to_hex(a) + txt;
+ txt += _to_hex(a);
return txt;
}
diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml
index 7f1aaa6822..9dd3cf0eff 100644
--- a/doc/classes/BaseButton.xml
+++ b/doc/classes/BaseButton.xml
@@ -21,7 +21,7 @@
<method name="_toggled" qualifiers="virtual">
<return type="void">
</return>
- <argument index="0" name="pressed" type="bool">
+ <argument index="0" name="button_pressed" type="bool">
</argument>
<description>
Called when button is toggled (only if toggle_mode is active).
@@ -82,7 +82,7 @@
</description>
</signal>
<signal name="toggled">
- <argument index="0" name="pressed" type="bool">
+ <argument index="0" name="button_pressed" type="bool">
</argument>
<description>
This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the [i]pressed[/i] argument.
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index 4434a7b7e2..c28b722eb3 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -131,14 +131,14 @@
</members>
<signals>
<signal name="text_changed">
- <argument index="0" name="text" type="String">
+ <argument index="0" name="new_text" type="String">
</argument>
<description>
Emitted when the text changes.
</description>
</signal>
<signal name="text_entered">
- <argument index="0" name="text" type="String">
+ <argument index="0" name="new_text" type="String">
</argument>
<description>
Emitted when the user presses KEY_ENTER on the [code]LineEdit[/code].
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 2a46aba207..bd5e5c7355 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4435,6 +4435,7 @@ void CanvasItemEditorViewport::_on_change_type_closed() {
void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
label->set_position(get_global_position() + Point2(14, 14) * EDSCALE);
label_desc->set_position(label->get_position() + Point2(0, label->get_size().height));
+ bool add_preview = false;
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
@@ -4456,9 +4457,12 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
}
}
}
- editor->get_scene_root()->add_child(preview_node);
+ add_preview = true;
}
}
+
+ if (add_preview)
+ editor->get_scene_root()->add_child(preview_node);
}
void CanvasItemEditorViewport::_remove_preview() {
@@ -4603,6 +4607,14 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
void CanvasItemEditorViewport::_perform_drop_data() {
_remove_preview();
+ // Without root dropping multiple files is not allowed
+ if (!target_node && selected_files.size() > 1) {
+ accept->get_ok()->set_text(TTR("Ok"));
+ accept->set_text(TTR("Cannot instantiate multiple nodes without root."));
+ accept->popup_centered_minsize();
+ return;
+ }
+
Vector<String> error_files;
editor_data->get_undo_redo().create_action(TTR("Create Node"));
@@ -4613,30 +4625,40 @@ void CanvasItemEditorViewport::_perform_drop_data() {
if (res.is_null()) {
continue;
}
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
- if (texture != NULL) {
- Node *child;
- if (default_type == "Light2D")
- child = memnew(Light2D);
- else if (default_type == "Particles2D")
- child = memnew(Particles2D);
- else if (default_type == "Polygon2D")
- child = memnew(Polygon2D);
- else if (default_type == "TouchScreenButton")
- child = memnew(TouchScreenButton);
- else if (default_type == "TextureRect")
- child = memnew(TextureRect);
- else if (default_type == "NinePatchRect")
- child = memnew(NinePatchRect);
- else
- child = memnew(Sprite); // default
-
- _create_nodes(target_node, child, path, drop_pos);
- } else if (scene != NULL) {
- bool success = _create_instance(target_node, path, drop_pos);
- if (!success) {
- error_files.push_back(path);
+ if (scene != NULL && scene.is_valid()) {
+ if (!target_node) {
+ // Without root node act the same as "Load Inherited Scene"
+ Error err = EditorNode::get_singleton()->load_scene(path, false, true);
+ if (err != OK) {
+ error_files.push_back(path);
+ }
+ } else {
+ bool success = _create_instance(target_node, path, drop_pos);
+ if (!success) {
+ error_files.push_back(path);
+ }
+ }
+ } else {
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ if (texture != NULL && texture.is_valid()) {
+ Node *child;
+ if (default_type == "Light2D")
+ child = memnew(Light2D);
+ else if (default_type == "Particles2D")
+ child = memnew(Particles2D);
+ else if (default_type == "Polygon2D")
+ child = memnew(Polygon2D);
+ else if (default_type == "TouchScreenButton")
+ child = memnew(TouchScreenButton);
+ else if (default_type == "TextureRect")
+ child = memnew(TextureRect);
+ else if (default_type == "NinePatchRect")
+ child = memnew(NinePatchRect);
+ else
+ child = memnew(Sprite); // default
+
+ _create_nodes(target_node, child, path, drop_pos);
}
}
}
@@ -4661,14 +4683,14 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
bool can_instance = false;
- for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least one
+ for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once
RES res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
String type = res->get_class();
if (type == "PackedScene") {
- Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
+ Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
continue;
@@ -4682,7 +4704,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
type == "StreamTexture" ||
type == "AtlasTexture" ||
type == "LargeTexture") {
- Ref<Texture> texture = ResourceLoader::load(files[i]);
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
if (texture.is_valid() == false) {
continue;
}
@@ -4708,6 +4730,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
}
void CanvasItemEditorViewport::_show_resource_type_selector() {
+ _remove_preview();
List<BaseButton *> btn_list;
button_group->get_buttons(&btn_list);
@@ -4719,6 +4742,17 @@ void CanvasItemEditorViewport::_show_resource_type_selector() {
selector->popup_centered_minsize();
}
+bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
+
+ for (int i = 0; i < selected_files.size(); ++i) {
+ if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") {
+ return false;
+ }
+ }
+
+ return true;
+}
+
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
@@ -4728,6 +4762,8 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
if (d.has("type") && String(d["type"]) == "files") {
selected_files = d["files"];
}
+ if (selected_files.size() == 0)
+ return;
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
if (list.size() == 0) {
@@ -4737,25 +4773,19 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
} else {
drop_pos = p_point;
target_node = NULL;
- _show_resource_type_selector();
- return;
}
}
- if (list.size() != 1) {
- accept->get_ok()->set_text(TTR("I see.."));
- accept->set_text(TTR("This operation requires a single selected node."));
- accept->popup_centered_minsize();
- _remove_preview();
- return;
- }
- target_node = list[0];
- if (is_shift && target_node != editor->get_edited_scene()) {
- target_node = target_node->get_parent();
+ if (list.size() > 0) {
+ target_node = list[0];
+ if (is_shift && target_node != editor->get_edited_scene()) {
+ target_node = target_node->get_parent();
+ }
}
+
drop_pos = p_point;
- if (is_alt) {
+ if (is_alt && !_only_packed_scenes_selected()) {
_show_resource_type_selector();
} else {
_perform_drop_data();
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 5be71bfc28..ace87f9fe2 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -576,6 +576,7 @@ class CanvasItemEditorViewport : public Control {
void _remove_preview();
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
+ bool _only_packed_scenes_selected() const;
void _create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point);
bool _create_instance(Node *parent, String &path, const Point2 &p_point);
void _perform_drop_data();
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 2405afc677..8101ebc6f3 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -45,7 +45,11 @@ void PluginScriptLanguage::init() {
}
String PluginScriptLanguage::get_type() const {
- return String(_desc.type);
+ // We should use _desc.type here, however the returned type is used to
+ // query ClassDB which would complain given the type is not registered
+ // from his point of view...
+ // To solve this we just use a more generic (but present in ClassDB) type.
+ return String("PluginScript");
}
String PluginScriptLanguage::get_extension() const {
@@ -168,7 +172,7 @@ Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_
for (int i = 0; i < options.size(); i++) {
r_options->push_back(String(options[i]));
}
- Error err = *(Error *)tmp;
+ Error err = *(Error *)&tmp;
return err;
}
return ERR_UNAVAILABLE;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d765248cca..8b9469021c 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -504,12 +504,12 @@ void BaseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_button_group"), &BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
- BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "pressed")));
+ BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "button_pressed")));
ADD_SIGNAL(MethodInfo("pressed"));
ADD_SIGNAL(MethodInfo("button_up"));
ADD_SIGNAL(MethodInfo("button_down"));
- ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "pressed")));
+ ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "button_pressed")));
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 53f609723f..97f740a4ba 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1413,8 +1413,8 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled);
ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled);
- ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text")));
- ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text")));
+ ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text")));
+ ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "new_text")));
BIND_ENUM_CONSTANT(ALIGN_LEFT);
BIND_ENUM_CONSTANT(ALIGN_CENTER);
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index e99db8d9cb..e9e15a2532 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -81,7 +81,7 @@ void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) {
if (p_value)
b |= (1 << bbit);
else
- b &= !(1 << bbit);
+ b &= ~(1 << bbit);
data[bbyte] = b;
}
@@ -127,7 +127,7 @@ void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
if (p_value)
b |= (1 << bbit);
else
- b &= !(1 << bbit);
+ b &= ~(1 << bbit);
bitmask[bbyte] = b;
}