summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/base/classes.xml48
-rw-r--r--editor/editor_about.cpp2
-rw-r--r--editor/editor_node.cpp32
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp87
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h3
-rw-r--r--editor/plugins/script_editor_plugin.cpp8
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp317
-rw-r--r--editor/plugins/spatial_editor_plugin.h35
-rw-r--r--modules/gdnative/SCsub12
-rw-r--r--modules/gdnative/gdnative.cpp6
-rw-r--r--modules/gdnative/gdnative.h7
-rw-r--r--modules/gdnative/gdnative/array.cpp (renamed from modules/gdnative/godot/array.cpp)2
-rw-r--r--modules/gdnative/gdnative/basis.cpp (renamed from modules/gdnative/godot/basis.cpp)2
-rw-r--r--modules/gdnative/gdnative/color.cpp (renamed from modules/gdnative/godot/color.cpp)2
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp (renamed from modules/gdnative/godot/dictionary.cpp)2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp (renamed from modules/gdnative/godot/gdnative.cpp)3
-rw-r--r--modules/gdnative/gdnative/node_path.cpp (renamed from modules/gdnative/godot/node_path.cpp)2
-rw-r--r--modules/gdnative/gdnative/plane.cpp (renamed from modules/gdnative/godot/plane.cpp)2
-rw-r--r--modules/gdnative/gdnative/pool_arrays.cpp (renamed from modules/gdnative/godot/pool_arrays.cpp)2
-rw-r--r--modules/gdnative/gdnative/quat.cpp (renamed from modules/gdnative/godot/quat.cpp)2
-rw-r--r--modules/gdnative/gdnative/rect2.cpp (renamed from modules/gdnative/godot/rect2.cpp)2
-rw-r--r--modules/gdnative/gdnative/rect3.cpp (renamed from modules/gdnative/godot/rect3.cpp)2
-rw-r--r--modules/gdnative/gdnative/rid.cpp (renamed from modules/gdnative/godot/rid.cpp)2
-rw-r--r--modules/gdnative/gdnative/string.cpp (renamed from modules/gdnative/godot/string.cpp)2
-rw-r--r--modules/gdnative/gdnative/transform.cpp (renamed from modules/gdnative/godot/transform.cpp)2
-rw-r--r--modules/gdnative/gdnative/transform2d.cpp (renamed from modules/gdnative/godot/transform2d.cpp)2
-rw-r--r--modules/gdnative/gdnative/variant.cpp (renamed from modules/gdnative/godot/variant.cpp)2
-rw-r--r--modules/gdnative/gdnative/vector2.cpp (renamed from modules/gdnative/godot/vector2.cpp)2
-rw-r--r--modules/gdnative/gdnative/vector3.cpp (renamed from modules/gdnative/godot/vector3.cpp)2
-rw-r--r--modules/gdnative/godot/icon.png.import23
-rw-r--r--modules/gdnative/include/gdnative/array.h (renamed from modules/gdnative/godot/array.h)6
-rw-r--r--modules/gdnative/include/gdnative/basis.h (renamed from modules/gdnative/godot/basis.h)6
-rw-r--r--modules/gdnative/include/gdnative/color.h (renamed from modules/gdnative/godot/color.h)4
-rw-r--r--modules/gdnative/include/gdnative/dictionary.h (renamed from modules/gdnative/godot/dictionary.h)6
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h (renamed from modules/gdnative/godot/gdnative.h)60
-rw-r--r--modules/gdnative/include/gdnative/node_path.h (renamed from modules/gdnative/godot/node_path.h)4
-rw-r--r--modules/gdnative/include/gdnative/plane.h (renamed from modules/gdnative/godot/plane.h)4
-rw-r--r--modules/gdnative/include/gdnative/pool_arrays.h (renamed from modules/gdnative/godot/pool_arrays.h)10
-rw-r--r--modules/gdnative/include/gdnative/quat.h (renamed from modules/gdnative/godot/quat.h)4
-rw-r--r--modules/gdnative/include/gdnative/rect2.h (renamed from modules/gdnative/godot/rect2.h)4
-rw-r--r--modules/gdnative/include/gdnative/rect3.h (renamed from modules/gdnative/godot/rect3.h)6
-rw-r--r--modules/gdnative/include/gdnative/rid.h (renamed from modules/gdnative/godot/rid.h)2
-rw-r--r--modules/gdnative/include/gdnative/string.h (renamed from modules/gdnative/godot/string.h)4
-rw-r--r--modules/gdnative/include/gdnative/transform.h (renamed from modules/gdnative/godot/transform.h)8
-rw-r--r--modules/gdnative/include/gdnative/transform2d.h (renamed from modules/gdnative/godot/transform2d.h)6
-rw-r--r--modules/gdnative/include/gdnative/variant.h (renamed from modules/gdnative/godot/variant.h)38
-rw-r--r--modules/gdnative/include/gdnative/vector2.h (renamed from modules/gdnative/godot/vector2.h)2
-rw-r--r--modules/gdnative/include/gdnative/vector3.h (renamed from modules/gdnative/godot/vector3.h)4
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h (renamed from modules/nativescript/godot_nativescript.h)2
-rw-r--r--modules/gdnative/nativescript/SCsub (renamed from modules/nativescript/SCsub)0
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp (renamed from modules/nativescript/api_generator.cpp)0
-rw-r--r--modules/gdnative/nativescript/api_generator.h (renamed from modules/nativescript/api_generator.h)0
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp (renamed from modules/nativescript/godot_nativescript.cpp)8
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp (renamed from modules/nativescript/nativescript.cpp)2
-rw-r--r--modules/gdnative/nativescript/nativescript.h (renamed from modules/nativescript/nativescript.h)2
-rw-r--r--modules/gdnative/nativescript/register_types.cpp (renamed from modules/nativescript/register_types.cpp)0
-rw-r--r--modules/gdnative/nativescript/register_types.h (renamed from modules/nativescript/register_types.h)0
-rw-r--r--modules/gdnative/register_types.cpp176
-rw-r--r--modules/nativescript/config.py8
-rw-r--r--scene/gui/item_list.cpp16
-rw-r--r--scene/gui/item_list.h4
-rw-r--r--scene/gui/tree.cpp6
62 files changed, 811 insertions, 208 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index a067bf2c6f..ad597c8fdc 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -49210,10 +49210,27 @@
</class>
<class name="StyleBoxFlat" inherits="StyleBox" category="Core">
<brief_description>
- Stylebox of a single color.
- </brief_description>
- <description>
- Stylebox of a single color. Displays the stylebox of a single color, alternatively a border with light/dark colors can be assigned.
+ Customizable Stylebox with a given set of parameters. (no texture required)
+ </brief_description>
+ <description>
+ This stylebox can be used to achieve all kinds of looks without the need of a texture. Those properties are customizable:
+ - Color
+ - Border width (individual width for each border)
+ - Rounded corners (individual radius for each corner)
+ - Shadow
+ About corner radius:
+ Setting corner radius to high values is allowed. As soon as corners would overlap the stylebox will switch to a relative system. Example:
+ [codeblock]
+ height = 30
+ corner_radius_top_left = 50
+ corner_raidus_bottom_left = 100
+ [/codeblock]
+ The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will [b]never[/b] be more than the height. Result:
+ [codeblock]
+ corner_radius_top_left: 10
+ corner_raidus_bottom_left: 20
+ [/codeblock]
+
</description>
<methods>
<method name="get_aa_size" qualifiers="const">
@@ -49457,46 +49474,69 @@
</methods>
<members>
<member name="anti_aliasing" type="bool" setter="set_anti_aliased" getter="is_anti_aliased" brief="">
+ Anti Aliasing draws a small ring around edges. This ring fades to transparent. As a result edges look much smoother. This is only noticable when using rounded corners.
</member>
<member name="anti_aliasing_size" type="int" setter="set_aa_size" getter="get_aa_size" brief="">
+ This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect.
</member>
<member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" brief="">
+ The background color of the stylebox.
</member>
<member name="border_blend" type="bool" setter="set_border_blend" getter="get_border_blend" brief="">
+ When set to true, the border will fade into the background color.
</member>
<member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" brief="">
+ Sets the color of the border.
</member>
<member name="border_width_bottom" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the bottom border.
</member>
<member name="border_width_left" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the left border.
</member>
<member name="border_width_right" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the right border.
</member>
<member name="border_width_top" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the top border.
</member>
<member name="corner_detail" type="int" setter="set_corner_detail" getter="get_corner_detail" brief="">
+ This sets the amount of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value you should take the corner radius ([method set_corner_radius]) into account.
+ For corner radius smaller than 10: 4-5 should be enough
+ For corner radius smaller than 30: 8-12 should be enough ...
</member>
<member name="corner_radius_bottom_left" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the bottom left corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_bottom_right" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the bottom right corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_top_left" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the top left corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_top_right" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the top right corner. When set to 0 the corner is not rounded.
</member>
<member name="draw_center" type="bool" setter="set_draw_center" getter="is_draw_center_enabled" brief="">
+ Toggels drawing of the inner part of the stylebox.
</member>
<member name="expand_margin_bottom" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the bottom edge. Useful in combination with border_width_bottom. To draw a border outside the control rect.
</member>
<member name="expand_margin_left" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the left edge. Useful in combination with border_width_left. To draw a border outside the control rect.
</member>
<member name="expand_margin_right" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the right edge. Useful in combination with border_width_right. To draw a border outside the control rect.
</member>
<member name="expand_margin_top" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the top edge. Useful in combination with border_width_top. To draw a border outside the control rect.
</member>
<member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" brief="">
+ The color of the shadow. (This has no effect when shadow_size < 1)
</member>
<member name="shadow_size" type="int" setter="set_shadow_size" getter="get_shadow_size" brief="">
+ The shadow size in pixels.
</member>
</members>
<constants>
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index 6d2bf10a7d..a48e6c9057 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -77,7 +77,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
il->set_same_column_width(true);
il->set_auto_height(true);
while (*names_ptr) {
- il->add_item(String::utf8(*names_ptr++));
+ il->add_item(String::utf8(*names_ptr++), NULL, false);
}
vbc->add_child(il);
if (il->get_item_count() == 2) {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index d4e0aacb0f..0db50ba0f3 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2732,6 +2732,14 @@ Dictionary EditorNode::_get_main_scene_state() {
state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
state["saved_version"] = saved_version;
state["node_filter"] = scene_tree_dock->get_filter();
+ int current = -1;
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_plugin_screen == editor_table[i]) {
+ current = i;
+ break;
+ }
+ }
+ state["editor_index"] = current;
return state;
}
@@ -2742,8 +2750,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
changing_scene = false;
- if (get_edited_scene()) {
+ if (p_state.has("editor_index")) {
+ int index = p_state["editor_index"];
int current = -1;
for (int i = 0; i < editor_table.size(); i++) {
if (editor_plugin_screen == editor_table[i]) {
@@ -2752,15 +2761,18 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
}
- if (current < 2) {
- //use heuristic instead
-
- int n2d = 0, n3d = 0;
- _find_node_types(get_edited_scene(), n2d, n3d);
- if (n2d > n3d) {
- _editor_select(EDITOR_2D);
- } else if (n3d > n2d) {
- _editor_select(EDITOR_3D);
+ if (current < 2) { //if currently in spatial/2d, only switch to spatial/2d. if curently in script, stay there
+ if (index < 2 || !get_edited_scene()) {
+ _editor_select(index);
+ } else {
+ //use heuristic instead
+ int n2d = 0, n3d = 0;
+ _find_node_types(get_edited_scene(), n2d, n3d);
+ if (n2d > n3d) {
+ _editor_select(EDITOR_2D);
+ } else if (n3d > n2d) {
+ _editor_select(EDITOR_3D);
+ }
}
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 3b74601e78..df4598793c 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1019,6 +1019,51 @@ void CanvasItemEditor::_list_select(const Ref<InputEventMouseButton> &b) {
}
}
+void CanvasItemEditor::_update_cursor() {
+
+ CursorShape c = CURSOR_ARROW;
+ switch (drag) {
+ case DRAG_NONE:
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ c = CURSOR_DRAG;
+ } else {
+ switch (tool) {
+ case TOOL_MOVE:
+ c = CURSOR_MOVE;
+ break;
+ case TOOL_EDIT_PIVOT:
+ c = CURSOR_CROSS;
+ break;
+ case TOOL_PAN:
+ c = CURSOR_DRAG;
+ break;
+ }
+ }
+ break;
+ case DRAG_LEFT:
+ case DRAG_RIGHT:
+ c = CURSOR_HSIZE;
+ break;
+ case DRAG_TOP:
+ case DRAG_BOTTOM:
+ c = CURSOR_VSIZE;
+ break;
+ case DRAG_TOP_LEFT:
+ case DRAG_BOTTOM_RIGHT:
+ c = CURSOR_FDIAGSIZE;
+ break;
+ case DRAG_TOP_RIGHT:
+ case DRAG_BOTTOM_LEFT:
+ c = CURSOR_BDIAGSIZE;
+ break;
+ case DRAG_ALL:
+ case DRAG_NODE_2D:
+ c = CURSOR_MOVE;
+ break;
+ }
+ viewport->set_default_cursor_shape(c);
+}
+
void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
{
@@ -1457,6 +1502,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
// Mouse motion event
+ _update_cursor();
if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
viewport->call_deferred("grab_focus");
@@ -3562,29 +3608,31 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Sprite *sprite = memnew(Sprite);
sprite->set_texture(texture);
sprite->set_modulate(Color(1, 1, 1, 0.7f));
- preview->add_child(sprite);
+ preview_node->add_child(sprite);
label->show();
label_desc->show();
} else {
if (scene.is_valid()) {
Node *instance = scene->instance();
if (instance) {
- preview->add_child(instance);
+ preview_node->add_child(instance);
}
}
}
- editor->get_scene_root()->add_child(preview);
+ editor->get_scene_root()->add_child(preview_node);
}
}
}
void CanvasItemEditorViewport::_remove_preview() {
- if (preview->get_parent()) {
- editor->get_scene_root()->remove_child(preview);
- for (int i = preview->get_child_count() - 1; i >= 0; i--) {
- Node *node = preview->get_child(i);
- memdelete(node);
+ if (preview_node->get_parent()) {
+ for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
+ Node *node = preview_node->get_child(i);
+ node->queue_delete();
+ preview_node->remove_child(node);
}
+ editor->get_scene_root()->remove_child(preview_node);
+
label->hide();
label_desc->hide();
}
@@ -3794,11 +3842,11 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
break;
}
if (can_instance) {
- if (!preview->get_parent()) { // create preview only once
+ if (!preview_node->get_parent()) { // create preview only once
_create_preview(files);
}
Transform2D trans = canvas->get_canvas_transform();
- preview->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
+ preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
label->set_text(vformat(TTR("Adding %s..."), default_type));
}
return can_instance;
@@ -3820,11 +3868,16 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
if (list.size() == 0) {
- accept->get_ok()->set_text(TTR("OK :("));
- accept->set_text(TTR("No parent to instance a child at."));
- accept->popup_centered_minsize();
- _remove_preview();
- return;
+ Node *root_node = editor->get_edited_scene();
+ if (root_node) {
+ list.push_back(root_node);
+ } else {
+ accept->get_ok()->set_text(TTR("OK :("));
+ accept->set_text(TTR("No parent to instance a child at."));
+ accept->popup_centered_minsize();
+ _remove_preview();
+ return;
+ }
}
if (list.size() != 1) {
accept->get_ok()->set_text(TTR("I see.."));
@@ -3891,7 +3944,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
editor = p_node;
editor_data = editor->get_scene_tree_dock()->get_editor_data();
canvas = p_canvas;
- preview = memnew(Node2D);
+ preview_node = memnew(Node2D);
accept = memnew(AcceptDialog);
editor->get_gui_base()->add_child(accept);
@@ -3945,5 +3998,5 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
}
CanvasItemEditorViewport::~CanvasItemEditorViewport() {
- memdelete(preview);
+ memdelete(preview_node);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index da217007ea..52b4a37a88 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -324,6 +324,7 @@ class CanvasItemEditor : public VBoxContainer {
bool updating_scroll;
void _update_scroll(float);
void _update_scrollbars();
+ void _update_cursor();
void incbeg(float &beg, float &end, float inc, float minsize, bool p_symmetric);
void incend(float &beg, float &end, float inc, float minsize, bool p_symmetric);
@@ -459,7 +460,7 @@ class CanvasItemEditorViewport : public Control {
EditorNode *editor;
EditorData *editor_data;
CanvasItemEditor *canvas;
- Node2D *preview;
+ Node2D *preview_node;
AcceptDialog *accept;
WindowDialog *selector;
Label *selector_label;
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index b8a4ff9bf3..04be1ba4ab 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1423,7 +1423,7 @@ void ScriptEditor::_update_script_colors() {
int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size;
float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4);
- script_list->set_item_custom_bg_color(i, hot_color.linear_interpolate(cold_color, v));
+ script_list->set_item_custom_fg_color(i, hot_color.linear_interpolate(cold_color, v));
}
}
}
@@ -2517,9 +2517,9 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true);
EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true);
EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15);
- EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color(1, 0, 0, 0.3));
- EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(0, 0, 1, 0.3));
- EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(0.81, 0.81, 0.14, 0.63));
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color::html("ed5e5e"));
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(1, 1, 1, 0.3));
+ EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(1, 1, 1, 0.5));
EDITOR_DEF("text_editor/open_scripts/group_help_pages", true);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path"));
EDITOR_DEF("text_editor/open_scripts/sort_scripts_by", 0);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index d9fc2f32f7..a5f55835f0 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -35,12 +35,15 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
+#include "editor/script_editor_debugger.h"
#include "editor/spatial_editor_gizmos.h"
#include "os/keyboard.h"
#include "print_string.h"
#include "project_settings.h"
#include "scene/3d/camera.h"
#include "scene/3d/visual_instance.h"
+#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
#include "sort.h"
@@ -228,7 +231,7 @@ Vector3 SpatialEditorViewport::_get_camera_normal() const {
return -_get_camera_transform().basis.get_axis(2);
}
-Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) {
+Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const {
return camera->project_ray_normal(p_pos);
}
@@ -700,6 +703,11 @@ void SpatialEditorViewport::_smouseenter() {
surface->grab_focus();
}
+void SpatialEditorViewport::_smouseexit() {
+
+ _remove_preview();
+}
+
void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
_find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->get_shift());
@@ -1895,6 +1903,7 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->connect("draw", this, "_draw");
surface->connect("gui_input", this, "_sinput");
surface->connect("mouse_entered", this, "_smouseenter");
+ surface->connect("mouse_exited", this, "_smouseexit");
info->add_style_override("panel", get_stylebox("panel", "Panel"));
preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
_init_gizmo_instance(index);
@@ -2425,6 +2434,7 @@ void SpatialEditorViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("_draw"), &SpatialEditorViewport::_draw);
ClassDB::bind_method(D_METHOD("_smouseenter"), &SpatialEditorViewport::_smouseenter);
+ ClassDB::bind_method(D_METHOD("_smouseexit"), &SpatialEditorViewport::_smouseexit);
ClassDB::bind_method(D_METHOD("_sinput"), &SpatialEditorViewport::_sinput);
ClassDB::bind_method(D_METHOD("_menu_option"), &SpatialEditorViewport::_menu_option);
ClassDB::bind_method(D_METHOD("_toggle_camera_preview"), &SpatialEditorViewport::_toggle_camera_preview);
@@ -2432,6 +2442,8 @@ void SpatialEditorViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view);
ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &SpatialEditorViewport::_selection_result_pressed);
ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &SpatialEditorViewport::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpatialEditorViewport::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpatialEditorViewport::drop_data_fw);
ADD_SIGNAL(MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")));
}
@@ -2481,6 +2493,293 @@ void SpatialEditorViewport::focus_selection() {
cursor.pos = center;
}
+void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) {
+ preview_node = p_preview_node;
+ preview_bounds = p_preview_bounds;
+ accept = p_accept;
+}
+
+Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const {
+ const float MAX_DISTANCE = 10;
+
+ Vector3 world_ray = _get_ray(p_pos);
+ Vector3 world_pos = _get_ray_pos(p_pos);
+
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario());
+ Set<Ref<SpatialEditorGizmo> > found_gizmos;
+
+ float closest_dist = MAX_DISTANCE;
+
+ Vector3 point = world_pos + world_ray * MAX_DISTANCE;
+ Vector3 normal = Vector3(0.0, 0.0, 0.0);
+
+ for (int i = 0; i < instances.size(); i++) {
+
+ MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(ObjectDB::get_instance(instances[i]));
+
+ if (!mesh_instance)
+ continue;
+
+ Ref<SpatialEditorGizmo> seg = mesh_instance->get_gizmo();
+
+ if ((!seg.is_valid()) || found_gizmos.has(seg)) {
+ continue;
+ }
+
+ found_gizmos.insert(seg);
+
+ int handle = -1;
+ Vector3 hit_point;
+ Vector3 hit_normal;
+ bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, NULL, false);
+
+ if (!inters)
+ continue;
+
+ float dist = world_pos.distance_to(hit_point);
+
+ if (dist < 0)
+ continue;
+
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ point = hit_point;
+ normal = hit_normal;
+ }
+ }
+ Vector3 center = preview_bounds->get_size() * 0.5;
+ return point + (center * normal);
+}
+
+Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) {
+ Rect3 bounds = p_bounds;
+ for (int i = 0; i < p_parent->get_child_count(); i++) {
+ Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i));
+ if (child) {
+ MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child);
+ if (mesh_instance) {
+ Rect3 mesh_instance_bounds = mesh_instance->get_aabb();
+ mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin;
+ bounds.merge_with(mesh_instance_bounds);
+ }
+ bounds = _calculate_spatial_bounds(child, bounds);
+ }
+ }
+ return bounds;
+}
+
+void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
+ for (int i = 0; i < files.size(); i++) {
+ String path = files[i];
+ RES res = ResourceLoader::load(path);
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
+ if (scene != NULL) {
+ if (scene.is_valid()) {
+ Node *instance = scene->instance();
+ if (instance) {
+ preview_node->add_child(instance);
+ }
+ }
+ editor->get_scene_root()->add_child(preview_node);
+ }
+ }
+ *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3());
+}
+
+void SpatialEditorViewport::_remove_preview() {
+ if (preview_node->get_parent()) {
+ for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
+ Node *node = preview_node->get_child(i);
+ node->queue_delete();
+ preview_node->remove_child(node);
+ }
+ editor->get_scene_root()->remove_child(preview_node);
+ }
+}
+
+bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
+ if (p_desired_node->get_filename() == p_target_scene_path) {
+ return true;
+ }
+
+ int childCount = p_desired_node->get_child_count();
+ for (int i = 0; i < childCount; i++) {
+ Node *child = p_desired_node->get_child(i);
+ if (_cyclical_dependency_exists(p_target_scene_path, child)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
+ Ref<PackedScene> sdata = ResourceLoader::load(path);
+ if (!sdata.is_valid()) { // invalid scene
+ return false;
+ }
+
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instanced_scene) { // error on instancing
+ return false;
+ }
+
+ if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
+ memdelete(instanced_scene);
+ return false;
+ }
+ }
+
+ instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_reference(instanced_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
+
+ String new_name = parent->validate_child_name(instanced_scene);
+ ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
+
+ Transform global_transform;
+ Spatial *parent_spatial = Object::cast_to<Spatial>(parent);
+ if (parent_spatial)
+ global_transform = parent_spatial->get_global_transform();
+
+ global_transform.origin = _get_instance_position(p_point);
+
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+
+ return true;
+}
+
+void SpatialEditorViewport::_perform_drop_data() {
+ _remove_preview();
+
+ Vector<String> error_files;
+
+ editor_data->get_undo_redo().create_action(TTR("Create Node"));
+
+ for (int i = 0; i < selected_files.size(); i++) {
+ String path = selected_files[i];
+ RES res = ResourceLoader::load(path);
+ if (res.is_null()) {
+ continue;
+ }
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
+ if (scene != NULL) {
+ bool success = _create_instance(target_node, path, drop_pos);
+ if (!success) {
+ error_files.push_back(path);
+ }
+ }
+ }
+
+ editor_data->get_undo_redo().commit_action();
+
+ if (error_files.size() > 0) {
+ String files_str;
+ for (int i = 0; i < error_files.size(); i++) {
+ files_str += error_files[i].get_file().get_basename() + ",";
+ }
+ files_str = files_str.substr(0, files_str.length() - 1);
+ accept->get_ok()->set_text(TTR("Ugh"));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
+ accept->popup_centered_minsize();
+ }
+}
+
+bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+
+ bool can_instance = false;
+
+ if (!preview_node->is_inside_tree()) {
+ Dictionary d = p_data;
+ if (d.has("type") && (String(d["type"]) == "files")) {
+ Vector<String> files = d["files"];
+
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+
+ for (int i = 0; i < files.size(); i++) {
+ if (scene_extensions.find(files[i].get_extension())) {
+ 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]);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instanced_scene) {
+ continue;
+ }
+ memdelete(instanced_scene);
+ }
+ can_instance = true;
+ break;
+ }
+ }
+ if (can_instance) {
+ _create_preview(files);
+ }
+ }
+ } else {
+ can_instance = true;
+ }
+
+ if (can_instance) {
+ Transform global_transform = Transform(Basis(), _get_instance_position(p_point));
+ preview_node->set_global_transform(global_transform);
+ }
+
+ return can_instance;
+}
+
+void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ if (!can_drop_data_fw(p_point, p_data, p_from))
+ return;
+
+ bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+
+ selected_files.clear();
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"]) == "files") {
+ selected_files = d["files"];
+ }
+
+ List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
+ if (list.size() == 0) {
+ Node *root_node = editor->get_edited_scene();
+ if (root_node) {
+ list.push_back(root_node);
+ } else {
+ accept->get_ok()->set_text(TTR("OK :("));
+ accept->set_text(TTR("No parent to instance a child at."));
+ accept->popup_centered_minsize();
+ _remove_preview();
+ 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();
+ }
+ drop_pos = p_point;
+
+ _perform_drop_data();
+}
+
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
_edit.mode = TRANSFORM_NONE;
@@ -2491,6 +2790,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
index = p_index;
editor = p_editor;
+ editor_data = editor->get_scene_tree_dock()->get_editor_data();
editor_selection = editor->get_editor_selection();
undo_redo = editor->get_undo_redo();
clicked = 0;
@@ -2509,6 +2809,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
c->add_child(viewport);
surface = memnew(Control);
+ surface->set_drag_forwarding(this);
add_child(surface);
surface->set_area_as_parent_rect();
surface->set_clip_contents(true);
@@ -2573,9 +2874,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
preview_camera->hide();
preview_camera->connect("toggled", this, "_toggle_camera_preview");
previewing = NULL;
- preview = NULL;
gizmo_scale = 1.0;
+ preview_node = NULL;
+
info = memnew(PanelContainer);
info->set_self_modulate(Color(1, 1, 1, 0.4));
surface->add_child(info);
@@ -2583,6 +2885,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
info->add_child(info_label);
info->hide();
+ accept = NULL;
+
freelook_active = false;
selection_menu = memnew(PopupMenu);
@@ -4000,6 +4304,10 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
vs = memnew(VSeparator);
hbc_menu->add_child(vs);
+ // Drag and drop support;
+ preview_node = memnew(Spatial);
+ preview_bounds = Rect3();
+
ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7);
ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT + KEY_KP_1);
@@ -4044,6 +4352,9 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
+ accept = memnew(AcceptDialog);
+ editor->get_gui_base()->add_child(accept);
+
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD + KEY_1), MENU_VIEW_USE_1_VIEWPORT);
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
@@ -4078,6 +4389,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");
+ viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept);
viewport_base->add_child(viewports[i]);
}
//vbc->add_child(viewport_base);
@@ -4212,6 +4524,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
}
SpatialEditor::~SpatialEditor() {
+ memdelete(preview_node);
}
void SpatialEditorPlugin::make_visible(bool p_visible) {
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 374861b5e7..db5abe2b53 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -106,7 +106,16 @@ private:
void _menu_option(int p_option);
Size2 prev_size;
+ Spatial *preview_node;
+ Rect3 *preview_bounds;
+ Vector<String> selected_files;
+ AcceptDialog *accept;
+
+ Node *target_node;
+ Point2 drop_pos;
+
EditorNode *editor;
+ EditorData *editor_data;
EditorSelection *editor_selection;
UndoRedo *undo_redo;
@@ -143,7 +152,7 @@ private:
ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
Vector3 _get_ray_pos(const Vector2 &p_pos) const;
- Vector3 _get_ray(const Vector2 &p_pos);
+ Vector3 _get_ray(const Vector2 &p_pos) const;
Point2 _point_to_screen(const Vector3 &p_point);
Transform _get_camera_transform() const;
int get_selected_count() const;
@@ -250,6 +259,7 @@ private:
void _draw();
void _smouseenter();
+ void _smouseexit();
void _sinput(const Ref<InputEvent> &p_event);
void _update_freelook(real_t delta);
SpatialEditor *spatial_editor;
@@ -266,6 +276,17 @@ private:
void _list_select(Ref<InputEventMouseButton> b);
Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const;
+ Vector3 _get_instance_position(const Point2 &p_pos) const;
+ static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds);
+ void _create_preview(const Vector<String> &files) const;
+ void _remove_preview();
+ bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
+ bool _create_instance(Node *parent, String &path, const Point2 &p_point);
+ void _perform_drop_data();
+
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -281,6 +302,11 @@ public:
void focus_selection();
+ void assign_pending_data_pointers(
+ Spatial *p_preview_node,
+ Rect3 *p_preview_bounds,
+ AcceptDialog *p_accept);
+
Viewport *get_viewport_node() { return viewport; }
SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
@@ -396,6 +422,10 @@ private:
Ref<SpatialMaterial> indicator_mat;
Ref<SpatialMaterial> cursor_material;
+ // Scene drag and drop support
+ Spatial *preview_node;
+ Rect3 preview_bounds;
+
/*
struct Selected {
AABB aabb;
@@ -442,6 +472,8 @@ private:
MenuButton *transform_menu;
MenuButton *view_menu;
+ AcceptDialog *accept;
+
ConfirmationDialog *snap_dialog;
ConfirmationDialog *xform_dialog;
ConfirmationDialog *settings_dialog;
@@ -559,6 +591,7 @@ public:
Camera *get_camera() { return NULL; }
void edit(Spatial *p_spatial);
void clear();
+
SpatialEditor(EditorNode *p_editor);
~SpatialEditor();
};
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 65970d48c1..f386f2b542 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -2,12 +2,16 @@
Import('env')
-env.add_source_files(env.modules_sources, "*.cpp")
-env.add_source_files(env.modules_sources, "godot/*.cpp")
+gdn_env = env.Clone()
-env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
-env.Append(CPPPATH=['#modules/gdnative/'])
+gdn_env.add_source_files(env.modules_sources, "*.cpp")
+gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp")
+gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp")
+
+gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
+gdn_env.Append(CPPPATH=['#modules/gdnative/include/'])
if "platform" in env and env["platform"] == "x11": # there has to be a better solution?
env.Append(LINKFLAGS=["-rdynamic"])
+
env.use_ptrcall = True
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index ded987557c..6da538844a 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -100,6 +100,11 @@ GDNativeLibrary::~GDNativeLibrary() {
void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path);
ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path);
+
+ ClassDB::bind_method(D_METHOD("is_singleton_gdnative"), &GDNativeLibrary::is_singleton_gdnative);
+ ClassDB::bind_method(D_METHOD("set_singleton_gdnative", "singleton"), &GDNativeLibrary::set_singleton_gdnative);
+
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton_gdnative"), "set_singleton_gdnative", "is_singleton_gdnative");
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
@@ -175,7 +180,6 @@ GDNative::GDNative() {
}
GDNative::~GDNative() {
- // TODO(karroffel): implement ALL the things!
}
extern "C" void _api_anchor();
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index dc1c3507ec..4753c7efe5 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -35,7 +35,7 @@
#include "os/thread_safe.h"
#include "resource.h"
-#include <godot/gdnative.h>
+#include "gdnative/gdnative.h"
class GDNativeLibrary : public Resource {
GDCLASS(GDNativeLibrary, Resource)
@@ -77,6 +77,8 @@ class GDNativeLibrary : public Resource {
String library_paths[NUM_PLATFORMS];
+ bool singleton_gdnative = false;
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -92,6 +94,9 @@ public:
String get_library_path(StringName p_platform) const;
String get_active_library_path() const;
+
+ _FORCE_INLINE_ bool is_singleton_gdnative() const { return singleton_gdnative; }
+ _FORCE_INLINE_ void set_singleton_gdnative(bool p_singleton) { singleton_gdnative = p_singleton; }
};
typedef godot_variant (*native_call_cb)(void *, godot_string *, godot_array *);
diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/gdnative/array.cpp
index c3fde0e954..51c023981f 100644
--- a/modules/gdnative/godot/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/array.h>
+#include "gdnative/array.h"
#include "core/array.h"
#include "core/os/memory.h"
diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 1d7aa18a70..b1327cdaef 100644
--- a/modules/gdnative/godot/basis.cpp
+++ b/modules/gdnative/gdnative/basis.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/basis.h>
+#include "gdnative/basis.h"
#include "core/math/matrix3.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/gdnative/color.cpp
index 3677fdc265..3f8912d896 100644
--- a/modules/gdnative/godot/color.cpp
+++ b/modules/gdnative/gdnative/color.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/color.h>
+#include "gdnative/color.h"
#include "core/color.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index 2996cc78a3..ed98cdbb00 100644
--- a/modules/gdnative/godot/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/dictionary.h>
+#include "gdnative/dictionary.h"
#include "core/variant.h"
// core/variant.h before to avoid compile errors with MSVC
diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 7cd52da34d..cf1f6a4f16 100644
--- a/modules/gdnative/godot/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -27,11 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/gdnative.h>
+#include "gdnative/gdnative.h"
#include "class_db.h"
#include "error_macros.h"
-#include "gdnative.h"
#include "global_constants.h"
#include "os/os.h"
#include "project_settings.h"
diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp
index 2309588a81..50fade5b94 100644
--- a/modules/gdnative/godot/node_path.cpp
+++ b/modules/gdnative/gdnative/node_path.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/node_path.h>
+#include "gdnative/node_path.h"
#include "core/node_path.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/gdnative/plane.cpp
index f3d4b6971e..a5e05ffa6b 100644
--- a/modules/gdnative/godot/plane.cpp
+++ b/modules/gdnative/gdnative/plane.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/plane.h>
+#include "gdnative/plane.h"
#include "core/math/plane.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp
index 49bf851051..1393374da2 100644
--- a/modules/gdnative/godot/pool_arrays.cpp
+++ b/modules/gdnative/gdnative/pool_arrays.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/pool_arrays.h>
+#include "gdnative/pool_arrays.h"
#include "array.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index e6bea78b60..7db7847da1 100644
--- a/modules/gdnative/godot/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/quat.h>
+#include "gdnative/quat.h"
#include "core/math/quat.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp
index 98e7855dc9..ecd8cce9ca 100644
--- a/modules/gdnative/godot/rect2.cpp
+++ b/modules/gdnative/gdnative/rect2.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/rect2.h>
+#include "gdnative/rect2.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp
index 88952ab49c..d34d964db9 100644
--- a/modules/gdnative/godot/rect3.cpp
+++ b/modules/gdnative/gdnative/rect3.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/rect3.h>
+#include "gdnative/rect3.h"
#include "core/math/rect3.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/gdnative/rid.cpp
index 51c8aaa1b3..f05c39906c 100644
--- a/modules/gdnative/godot/rid.cpp
+++ b/modules/gdnative/gdnative/rid.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/rid.h>
+#include "gdnative/rid.h"
#include "core/resource.h"
#include "core/rid.h"
diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/gdnative/string.cpp
index 1282cf95e5..9b715ce36a 100644
--- a/modules/gdnative/godot/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/string.h>
+#include "gdnative/string.h"
#include "core/variant.h"
#include "string_db.h"
diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index a965067b77..d7a3e78d3f 100644
--- a/modules/gdnative/godot/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/transform.h>
+#include "gdnative/transform.h"
#include "core/math/transform.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp
index 9fc44ecdfa..dcb54f7a53 100644
--- a/modules/gdnative/godot/transform2d.cpp
+++ b/modules/gdnative/gdnative/transform2d.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/transform2d.h>
+#include "gdnative/transform2d.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 582544b3a0..b61f80b1f9 100644
--- a/modules/gdnative/godot/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/variant.h>
+#include "gdnative/variant.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index 78ed5f06a9..67f858997f 100644
--- a/modules/gdnative/godot/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/vector2.h>
+#include "gdnative/vector2.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index 5faeac2864..c85a3f1c08 100644
--- a/modules/gdnative/godot/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <godot/vector3.h>
+#include "gdnative/vector3.h"
#include "core/variant.h"
#include "core/vector.h"
diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import
deleted file mode 100644
index 27920124f9..0000000000
--- a/modules/gdnative/godot/icon.png.import
+++ /dev/null
@@ -1,23 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture"
-path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex"
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=false
-flags/anisotropic=false
-flags/srgb=2
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/HDR_as_SRGB=false
-stream=false
-size_limit=0
-detect_3d=true
diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/include/gdnative/array.h
index 08f73c8785..edab028cba 100644
--- a/modules/gdnative/godot/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -46,10 +46,10 @@ typedef struct {
} godot_array;
#endif
-#include <godot/pool_arrays.h>
-#include <godot/variant.h>
+#include <gdnative/pool_arrays.h>
+#include <gdnative/variant.h>
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
void GDAPI godot_array_new(godot_array *r_dest);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/include/gdnative/basis.h
index f36d2199de..8ff6a6f541 100644
--- a/modules/gdnative/godot/basis.h
+++ b/modules/gdnative/include/gdnative/basis.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_basis;
#endif
-#include <godot/gdnative.h>
-#include <godot/quat.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/quat.h>
+#include <gdnative/vector3.h>
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis);
void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi);
diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/include/gdnative/color.h
index 5d550e40b3..90dccf75aa 100644
--- a/modules/gdnative/godot/color.h
+++ b/modules/gdnative/include/gdnative/color.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_color;
#endif
-#include <godot/gdnative.h>
-#include <godot/string.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/string.h>
void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a);
void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b);
diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h
index 10d580af08..c85c3f3830 100644
--- a/modules/gdnative/godot/dictionary.h
+++ b/modules/gdnative/include/gdnative/dictionary.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_dictionary;
#endif
-#include <godot/array.h>
-#include <godot/gdnative.h>
-#include <godot/variant.h>
+#include <gdnative/array.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
void GDAPI godot_dictionary_new(godot_dictionary *r_dest);
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src);
diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index c71a7ae1ef..c574c56d5a 100644
--- a/modules/gdnative/godot/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -146,100 +146,74 @@ typedef float godot_real;
/////// Object (forward declared)
typedef void godot_object;
-/////// Brute force forward declarations for the rest
-/*
-typedef struct godot_variant godot_variant;
-typedef struct godot_string godot_string;
-typedef struct godot_vector2 godot_vector2;
-typedef struct godot_rect2 godot_rect2;
-typedef struct godot_vector3 godot_vector3;
-typedef struct godot_transform2d godot_transform2d;
-typedef struct godot_plane godot_plane;
-typedef struct godot_quat godot_quat;
-typedef struct godot_rect3 godot_rect3;
-typedef struct godot_basis godot_basis;
-typedef struct godot_transform godot_transform;
-typedef struct godot_color godot_color;
-typedef struct godot_node_path godot_node_path;
-typedef struct godot_rid godot_rid;
-typedef struct godot_dictionary godot_dictionary;
-typedef struct godot_array godot_array;
-typedef struct godot_pool_byte_array godot_pool_byte_array;
-typedef struct godot_pool_int_array godot_pool_int_array;
-typedef struct godot_pool_real_array godot_pool_real_array;
-typedef struct godot_pool_string_array godot_pool_string_array;
-typedef struct godot_pool_vector2_array godot_pool_vector2_array;
-typedef struct godot_pool_vector3_array godot_pool_vector3_array;
-typedef struct godot_pool_color_array godot_pool_color_array;
-*/
/////// String
-#include <godot/string.h>
+#include <gdnative/string.h>
////// Vector2
-#include <godot/vector2.h>
+#include <gdnative/vector2.h>
////// Rect2
-#include <godot/rect2.h>
+#include <gdnative/rect2.h>
////// Vector3
-#include <godot/vector3.h>
+#include <gdnative/vector3.h>
////// Transform2D
-#include <godot/transform2d.h>
+#include <gdnative/transform2d.h>
/////// Plane
-#include <godot/plane.h>
+#include <gdnative/plane.h>
/////// Quat
-#include <godot/quat.h>
+#include <gdnative/quat.h>
/////// Rect3
-#include <godot/rect3.h>
+#include <gdnative/rect3.h>
/////// Basis
-#include <godot/basis.h>
+#include <gdnative/basis.h>
/////// Transform
-#include <godot/transform.h>
+#include <gdnative/transform.h>
/////// Color
-#include <godot/color.h>
+#include <gdnative/color.h>
/////// NodePath
-#include <godot/node_path.h>
+#include <gdnative/node_path.h>
/////// RID
-#include <godot/rid.h>
+#include <gdnative/rid.h>
/////// Dictionary
-#include <godot/dictionary.h>
+#include <gdnative/dictionary.h>
/////// Array
-#include <godot/array.h>
+#include <gdnative/array.h>
// single API file for Pool*Array
-#include <godot/pool_arrays.h>
+#include <gdnative/pool_arrays.h>
void GDAPI godot_object_destroy(godot_object *p_o);
////// Variant
-#include <godot/variant.h>
+#include <gdnative/variant.h>
////// Singleton API
diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/include/gdnative/node_path.h
index 2f71ddd59d..0cfdbc1127 100644
--- a/modules/gdnative/godot/node_path.h
+++ b/modules/gdnative/include/gdnative/node_path.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_node_path;
#endif
-#include <godot/gdnative.h>
-#include <godot/string.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/string.h>
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from);
void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src);
diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/include/gdnative/plane.h
index 27548c8b0c..6a8915e08b 100644
--- a/modules/gdnative/godot/plane.h
+++ b/modules/gdnative/include/gdnative/plane.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_plane;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/vector3.h>
void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d);
void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3);
diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h
index 1b51dca38c..cb1095ee8c 100644
--- a/modules/gdnative/godot/pool_arrays.h
+++ b/modules/gdnative/include/gdnative/pool_arrays.h
@@ -113,12 +113,12 @@ typedef struct {
} godot_pool_color_array;
#endif
-#include <godot/array.h>
-#include <godot/color.h>
-#include <godot/vector2.h>
-#include <godot/vector3.h>
+#include <gdnative/array.h>
+#include <gdnative/color.h>
+#include <gdnative/vector2.h>
+#include <gdnative/vector3.h>
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
// byte
diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/include/gdnative/quat.h
index 9a3238a337..4ffb96eb26 100644
--- a/modules/gdnative/godot/quat.h
+++ b/modules/gdnative/include/gdnative/quat.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_quat;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/vector3.h>
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w);
void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle);
diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/include/gdnative/rect2.h
index 8ceeddf1b4..9e6cf60342 100644
--- a/modules/gdnative/godot/rect2.h
+++ b/modules/gdnative/include/gdnative/rect2.h
@@ -43,8 +43,8 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector2.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/vector2.h>
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size);
void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height);
diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/include/gdnative/rect3.h
index ca96aadd5c..f94b6fea25 100644
--- a/modules/gdnative/godot/rect3.h
+++ b/modules/gdnative/include/gdnative/rect3.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_rect3;
#endif
-#include <godot/gdnative.h>
-#include <godot/plane.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/plane.h>
+#include <gdnative/vector3.h>
void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/include/gdnative/rid.h
index c56ff38735..d9b5336fc9 100644
--- a/modules/gdnative/godot/rid.h
+++ b/modules/gdnative/include/gdnative/rid.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_rid;
#endif
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
void GDAPI godot_rid_new(godot_rid *r_dest);
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/include/gdnative/string.h
index 128448e64e..aca23a81d8 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -46,8 +46,8 @@ typedef struct {
} godot_string;
#endif
-#include <godot/gdnative.h>
-#include <godot/variant.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/include/gdnative/transform.h
index 60788e3d57..656afae129 100644
--- a/modules/gdnative/godot/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -45,10 +45,10 @@ typedef struct {
} godot_transform;
#endif
-#include <godot/basis.h>
-#include <godot/gdnative.h>
-#include <godot/variant.h>
-#include <godot/vector3.h>
+#include <gdnative/basis.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
+#include <gdnative/vector3.h>
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin);
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h
index c0f5725eed..a945868b17 100644
--- a/modules/gdnative/godot/transform2d.h
+++ b/modules/gdnative/include/gdnative/transform2d.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_transform2d;
#endif
-#include <godot/gdnative.h>
-#include <godot/variant.h>
-#include <godot/vector2.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
+#include <gdnative/vector2.h>
void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos);
void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin);
diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/include/gdnative/variant.h
index 849ba8bda6..969506585d 100644
--- a/modules/gdnative/godot/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -99,25 +99,25 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
-#include <godot/array.h>
-#include <godot/basis.h>
-#include <godot/color.h>
-#include <godot/dictionary.h>
-#include <godot/node_path.h>
-#include <godot/plane.h>
-#include <godot/pool_arrays.h>
-#include <godot/quat.h>
-#include <godot/rect2.h>
-#include <godot/rect3.h>
-#include <godot/rid.h>
-#include <godot/string.h>
-#include <godot/transform.h>
-#include <godot/transform2d.h>
-#include <godot/variant.h>
-#include <godot/vector2.h>
-#include <godot/vector3.h>
-
-#include <godot/gdnative.h>
+#include <gdnative/array.h>
+#include <gdnative/basis.h>
+#include <gdnative/color.h>
+#include <gdnative/dictionary.h>
+#include <gdnative/node_path.h>
+#include <gdnative/plane.h>
+#include <gdnative/pool_arrays.h>
+#include <gdnative/quat.h>
+#include <gdnative/rect2.h>
+#include <gdnative/rect3.h>
+#include <gdnative/rid.h>
+#include <gdnative/string.h>
+#include <gdnative/transform.h>
+#include <gdnative/transform2d.h>
+#include <gdnative/variant.h>
+#include <gdnative/vector2.h>
+#include <gdnative/vector3.h>
+
+#include <gdnative/gdnative.h>
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index 98e9700e32..0af4abae27 100644
--- a/modules/gdnative/godot/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_vector2;
#endif
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y);
diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/include/gdnative/vector3.h
index b76ca11a9c..a27d516ec5 100644
--- a/modules/gdnative/godot/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_vector3;
#endif
-#include <godot/basis.h>
-#include <godot/gdnative.h>
+#include <gdnative/basis.h>
+#include <gdnative/gdnative.h>
typedef enum {
GODOT_VECTOR3_AXIS_X,
diff --git a/modules/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index d1cbf221ec..96f213ead7 100644
--- a/modules/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -30,7 +30,7 @@
#ifndef GODOT_NATIVESCRIPT_H
#define GODOT_NATIVESCRIPT_H
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
#ifdef __cplusplus
extern "C" {
diff --git a/modules/nativescript/SCsub b/modules/gdnative/nativescript/SCsub
index e980e40e8e..e980e40e8e 100644
--- a/modules/nativescript/SCsub
+++ b/modules/gdnative/nativescript/SCsub
diff --git a/modules/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index fdd5a2ea19..fdd5a2ea19 100644
--- a/modules/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
diff --git a/modules/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h
index 56c2d786e6..56c2d786e6 100644
--- a/modules/nativescript/api_generator.h
+++ b/modules/gdnative/nativescript/api_generator.h
diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index 926b3261b2..61ac13b796 100644
--- a/modules/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -27,17 +27,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_nativescript.h"
-
-#include "nativescript.h"
+#include "nativescript/godot_nativescript.h"
#include "class_db.h"
#include "error_macros.h"
-#include "gdnative.h"
+#include "gdnative/gdnative.h"
#include "global_constants.h"
#include "project_settings.h"
#include "variant.h"
+#include "nativescript.h"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/modules/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index e141080687..724b8390da 100644
--- a/modules/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "nativescript.h"
-#include "modules/gdnative/godot/gdnative.h"
+#include "gdnative/gdnative.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
diff --git a/modules/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 571a3c9cc7..6c55e3e327 100644
--- a/modules/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -38,8 +38,8 @@
#include "script_language.h"
#include "self_list.h"
-#include "godot_nativescript.h"
#include "modules/gdnative/gdnative.h"
+#include <nativescript/godot_nativescript.h>
#ifndef NO_THREADS
#include "os/mutex.h"
diff --git a/modules/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index b846710ab8..b846710ab8 100644
--- a/modules/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
diff --git a/modules/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h
index 7ac558f68f..7ac558f68f 100644
--- a/modules/nativescript/register_types.h
+++ b/modules/gdnative/nativescript/register_types.h
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 9ad05b7194..d809109987 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -28,12 +28,99 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
+#include "gdnative/gdnative.h"
+
#include "gdnative.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "nativescript/register_types.h"
+
+#include "core/engine.h"
#include "core/os/os.h"
+#include "core/project_settings.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+
+// Class used to discover singleton gdnative files
+
+void actual_discoverer_handler();
+
+class GDNativeSingletonDiscover : public Object {
+ // GDCLASS(GDNativeSingletonDiscover, Object)
+
+ virtual String get_class() const {
+ // okay, this is a really dirty hack.
+ // We're overriding get_class so we can connect it to a signal
+ // This works because get_class is a virtual method, so we don't
+ // need to register a new class to ClassDB just for this one
+ // little signal.
+
+ actual_discoverer_handler();
+
+ return "Object";
+ }
+};
+
+Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) {
+
+ Set<String> file_paths;
+
+ // check children
+
+ for (int i = 0; i < p_dir->get_file_count(); i++) {
+ String file_name = p_dir->get_file(i);
+ String file_type = p_dir->get_file_type(i);
+
+ if (file_type != "GDNativeLibrary") {
+ continue;
+ }
+
+ Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i));
+ if (lib.is_valid() && lib->is_singleton_gdnative()) {
+ file_paths.insert(p_dir->get_file_path(i));
+ }
+ }
+
+ // check subdirectories
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
+ Set<String> paths = get_gdnative_singletons(p_dir->get_subdir(i));
+
+ for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
+ file_paths.insert(E->get());
+ }
+ }
+
+ return file_paths;
+}
+
+void actual_discoverer_handler() {
+ EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
+
+ Set<String> file_paths = get_gdnative_singletons(dir);
+
+ Array files;
+ files.resize(file_paths.size());
+ int i = 0;
+ for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) {
+ files.set(i, E->get());
+ }
+
+ ProjectSettings::get_singleton()->set("gdnative/singletons", files);
+
+ ProjectSettings::get_singleton()->save();
+}
+
+GDNativeSingletonDiscover *discoverer = NULL;
+
+void discoverer_callback() {
+ discoverer = memnew(GDNativeSingletonDiscover);
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", discoverer, "get_class");
+}
+
+#endif
godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot_array *p_args) {
if (handle == NULL) {
@@ -62,21 +149,110 @@ godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot
return proc(NULL, p_args);
}
+void cb_singleton_call(
+ void *p_handle,
+ godot_string *p_proc_name,
+ void *p_data,
+ int p_num_args,
+ void **p_args,
+ void *r_return) {
+ if (p_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't call singleton procedure");
+ return;
+ }
+
+ void *singleton_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ p_handle,
+ *(String *)p_proc_name,
+ singleton_proc);
+
+ if (err != OK) {
+ return;
+ }
+
+ void (*singleton_procedure_ptr)() = (void (*)())singleton_proc;
+ singleton_procedure_ptr();
+}
+
GDNativeCallRegistry *GDNativeCallRegistry::singleton;
+Vector<Ref<GDNative> > singleton_gdnatives;
+
void register_gdnative_types() {
+#ifdef TOOLS_ENABLED
+
+ if (Engine::get_singleton()->is_editor_hint()) {
+ EditorNode::add_init_callback(discoverer_callback);
+ }
+#endif
+
ClassDB::register_class<GDNativeLibrary>();
ClassDB::register_class<GDNative>();
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
+
+ GDNativeCallRegistry::singleton->register_native_raw_call_type("gdnative_singleton_call", cb_singleton_call);
+
+ register_nativescript_types();
+
+ // run singletons
+
+ Array singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
+
+ singleton_gdnatives.resize(singletons.size());
+
+ for (int i = 0; i < singletons.size(); i++) {
+ String path = singletons[i];
+
+ Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
+
+ singleton_gdnatives[i].instance();
+ singleton_gdnatives[i]->set_library(lib);
+
+ if (!singleton_gdnatives[i]->initialize()) {
+ // Can't initialize. Don't make a native_call then
+ continue;
+ }
+
+ singleton_gdnatives[i]->call_native_raw(
+ "gdnative_singleton_call",
+ "godot_gdnative_singleton",
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ }
}
void unregister_gdnative_types() {
+
+ for (int i = 0; i < singleton_gdnatives.size(); i++) {
+
+ if (singleton_gdnatives[i].is_null()) {
+ continue;
+ }
+
+ if (!singleton_gdnatives[i]->is_initialized()) {
+ continue;
+ }
+
+ singleton_gdnatives[i]->terminate();
+ }
+
+ unregister_nativescript_types();
+
memdelete(GDNativeCallRegistry::singleton);
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ memdelete(discoverer);
+ }
+#endif
+
// This is for printing out the sizes of the core types
/*
diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py
deleted file mode 100644
index 9f57b9bb74..0000000000
--- a/modules/nativescript/config.py
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-def can_build(platform):
- return True
-
-
-def configure(env):
- env.use_ptrcall = True
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index f8d82a339c..9a605c98f3 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -151,6 +151,20 @@ Color ItemList::get_item_custom_bg_color(int p_idx) const {
return items[p_idx].custom_bg;
}
+void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color) {
+
+ ERR_FAIL_INDEX(p_idx, items.size());
+
+ items[p_idx].custom_fg = p_custom_fg_color;
+}
+
+Color ItemList::get_item_custom_fg_color(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
+
+ return items[p_idx].custom_fg;
+}
+
void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) {
ERR_FAIL_INDEX(p_idx, items.size());
@@ -1021,7 +1035,7 @@ void ItemList::_notification(int p_what) {
else
max_len = size.x;
- Color modulate = items[i].selected ? font_color_selected : font_color;
+ Color modulate = items[i].selected ? font_color_selected : (items[i].custom_fg != Color() ? items[i].custom_fg : font_color);
if (items[i].disabled)
modulate.a *= 0.5;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 8166975408..673b7d8956 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -61,6 +61,7 @@ private:
bool tooltip_enabled;
Variant metadata;
String tooltip;
+ Color custom_fg;
Color custom_bg;
Rect2 rect_cache;
@@ -150,6 +151,9 @@ public:
void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color);
Color get_item_custom_bg_color(int p_idx) const;
+ void set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color);
+ Color get_item_custom_fg_color(int p_idx) const;
+
void select(int p_idx, bool p_single = true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5e15bceb7d..de17416d8e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1116,7 +1116,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
cache.selected->draw(ci, r);
}
if (text_editor->is_visible_in_tree()) {
- text_editor->set_position(get_global_position() + r.position);
+ Vector2 ofs(0, (text_editor->get_size().height - r.size.height) / 2);
+ text_editor->set_position(get_global_position() + r.position - ofs);
}
}
@@ -2572,7 +2573,8 @@ bool Tree::edit_selected() {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- Point2i textedpos = get_global_position() + rect.position;
+ Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Point2i textedpos = get_global_position() + rect.position - ofs;
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();