summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/godot_result_callbacks.cpp5
-rw-r--r--modules/bullet/rigid_body_bullet.cpp39
-rw-r--r--modules/bullet/rigid_body_bullet.h1
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp4
-rw-r--r--modules/enet/networked_multiplayer_enet.h8
-rw-r--r--modules/gdnative/SCsub4
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp4
-rw-r--r--modules/gdnative/gdnative_api.json6
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp423
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h113
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.cpp (renamed from modules/gdnative/gd_native_library_editor.cpp)19
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.h (renamed from modules/gdnative/gd_native_library_editor.h)6
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h4
-rw-r--r--modules/gdnative/register_types.cpp7
-rw-r--r--modules/gdscript/gdscript_function.cpp2
-rw-r--r--modules/gdscript/gdscript_parser.cpp42
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml30
-rw-r--r--modules/gridmap/grid_map.cpp255
-rw-r--r--modules/gridmap/grid_map.h16
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/mono/editor/bindings_generator.cpp818
-rw-r--r--modules/mono/editor/bindings_generator.h162
-rw-r--r--modules/mono/editor/csharp_project.cpp6
-rw-r--r--modules/mono/editor/godotsharp_builds.cpp2
-rw-r--r--modules/mono/editor/godotsharp_editor.cpp18
-rw-r--r--modules/mono/editor/mono_bottom_panel.cpp6
-rw-r--r--modules/mono/glue/cs_files/Error.cs47
-rw-r--r--modules/mono/glue/cs_files/ExportAttribute.cs8
-rw-r--r--modules/mono/glue/cs_files/GD.cs4
-rw-r--r--modules/mono/glue/cs_files/Rect2.cs12
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp5
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h9
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h2
-rw-r--r--modules/opus/register_types.cpp15
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp16
-rw-r--r--modules/thekla_unwrap/register_types.cpp2
-rw-r--r--modules/visual_script/visual_script_editor.cpp110
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp915
-rw-r--r--modules/visual_script/visual_script_flow_control.h34
42 files changed, 1767 insertions, 1424 deletions
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index cbf30c8a2e..37e45cfff8 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -142,6 +142,9 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) {
+ if (m_count >= m_resultMax)
+ return cp.getDistance();
+
if (cp.getDistance() <= 0) {
PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count];
@@ -165,7 +168,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
++m_count;
}
- return m_count < m_resultMax;
+ return cp.getDistance();
}
bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 669b2c3f0c..5e736c1856 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -264,6 +264,7 @@ RigidBodyBullet::RigidBodyBullet() :
can_sleep(true),
force_integration_callback(NULL),
isTransformChanged(false),
+ previousActiveState(true),
maxCollisionsDetection(0),
collisionsCount(0),
maxAreasWhereIam(10),
@@ -287,6 +288,7 @@ RigidBodyBullet::RigidBodyBullet() :
for (int i = areasWhereIam.size() - 1; 0 <= i; --i) {
areasWhereIam[i] = NULL;
}
+ btBody->setSleepingThresholds(0.2, 0.2);
}
RigidBodyBullet::~RigidBodyBullet() {
@@ -337,7 +339,7 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) {
void RigidBodyBullet::dispatch_callbacks() {
/// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent
- if (btBody->isActive() && force_integration_callback && isTransformChanged) {
+ if ((btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) {
BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this);
@@ -364,6 +366,8 @@ void RigidBodyBullet::dispatch_callbacks() {
/// Lock axis
btBody->setLinearVelocity(btBody->getLinearVelocity() * btBody->getLinearFactor());
btBody->setAngularVelocity(btBody->getAngularVelocity() * btBody->getAngularFactor());
+
+ previousActiveState = btBody->isActive();
}
void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
@@ -580,7 +584,8 @@ Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const {
void RigidBodyBullet::apply_central_impulse(const Vector3 &p_impulse) {
btVector3 btImpu;
G_TO_B(p_impulse, btImpu);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyCentralImpulse(btImpu);
}
@@ -589,14 +594,16 @@ void RigidBodyBullet::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impul
btVector3 btPos;
G_TO_B(p_impulse, btImpu);
G_TO_B(p_pos, btPos);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyImpulse(btImpu, btPos);
}
void RigidBodyBullet::apply_torque_impulse(const Vector3 &p_impulse) {
btVector3 btImp;
G_TO_B(p_impulse, btImp);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyTorqueImpulse(btImp);
}
@@ -605,28 +612,32 @@ void RigidBodyBullet::apply_force(const Vector3 &p_force, const Vector3 &p_pos)
btVector3 btPos;
G_TO_B(p_force, btForce);
G_TO_B(p_pos, btPos);
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->applyForce(btForce, btPos);
}
void RigidBodyBullet::apply_central_force(const Vector3 &p_force) {
btVector3 btForce;
G_TO_B(p_force, btForce);
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->applyCentralForce(btForce);
}
void RigidBodyBullet::apply_torque(const Vector3 &p_torque) {
btVector3 btTorq;
G_TO_B(p_torque, btTorq);
- btBody->activate();
+ if (Vector3() != p_torque)
+ btBody->activate();
btBody->applyTorque(btTorq);
}
void RigidBodyBullet::set_applied_force(const Vector3 &p_force) {
btVector3 btVec = btBody->getTotalTorque();
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->clearForces();
btBody->applyTorque(btVec);
@@ -644,7 +655,8 @@ Vector3 RigidBodyBullet::get_applied_force() const {
void RigidBodyBullet::set_applied_torque(const Vector3 &p_torque) {
btVector3 btVec = btBody->getTotalForce();
- btBody->activate();
+ if (Vector3() != p_torque)
+ btBody->activate();
btBody->clearForces();
btBody->applyCentralForce(btVec);
@@ -711,7 +723,8 @@ bool RigidBodyBullet::is_continuous_collision_detection_enabled() const {
void RigidBodyBullet::set_linear_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- btBody->activate();
+ if (Vector3() != p_velocity)
+ btBody->activate();
btBody->setLinearVelocity(btVec);
}
@@ -724,7 +737,8 @@ Vector3 RigidBodyBullet::get_linear_velocity() const {
void RigidBodyBullet::set_angular_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- btBody->activate();
+ if (Vector3() != p_velocity)
+ btBody->activate();
btBody->setAngularVelocity(btVec);
}
@@ -833,6 +847,9 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
+ if (!is_active())
+ return;
+
Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude());
real_t newLinearDamp(linearDamp);
real_t newAngularDamp(angularDamp);
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index c0eb148e24..c3b72172d9 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -207,6 +207,7 @@ private:
bool isScratchedSpaceOverrideModificator;
bool isTransformChanged;
+ bool previousActiveState; // Last check state
ForceIntegrationCallback *force_integration_callback;
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index ce485956b4..396bebf0ea 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -386,7 +386,7 @@ int NetworkedMultiplayerENet::get_available_packet_count() const {
return incoming_packets.size();
}
-Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) const {
+Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
ERR_FAIL_COND_V(incoming_packets.size() == 0, ERR_UNAVAILABLE);
@@ -480,7 +480,7 @@ int NetworkedMultiplayerENet::get_max_packet_size() const {
return 1 << 24; //anything is good
}
-void NetworkedMultiplayerENet::_pop_current_packet() const {
+void NetworkedMultiplayerENet::_pop_current_packet() {
if (current_packet.packet) {
enet_packet_destroy(current_packet.packet);
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index 81d517147d..d7bc5c7849 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -86,12 +86,12 @@ private:
CompressionMode compression_mode;
- mutable List<Packet> incoming_packets;
+ List<Packet> incoming_packets;
- mutable Packet current_packet;
+ Packet current_packet;
uint32_t _gen_unique_id() const;
- void _pop_current_packet() const;
+ void _pop_current_packet();
Vector<uint8_t> src_compressor_mem;
Vector<uint8_t> dst_compressor_mem;
@@ -123,7 +123,7 @@ public:
virtual bool is_server() const;
virtual int get_available_packet_count() const;
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) const; ///< buffer is GONE after next get_packet
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); ///< buffer is GONE after next get_packet
virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
virtual int get_max_packet_size() const;
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index fd11c8d094..4e73ebfb9d 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -3,12 +3,12 @@
Import('env')
gdn_env = env.Clone()
-
-gdn_env.add_source_files(env.modules_sources, "gd_native_library_editor.cpp")
gdn_env.add_source_files(env.modules_sources, "gdnative.cpp")
gdn_env.add_source_files(env.modules_sources, "register_types.cpp")
gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp")
gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp")
+gdn_env.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
+gdn_env.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
gdn_env.Append(CPPPATH=['#modules/gdnative/include/'])
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 92a88e354b..8ff67b10b1 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -52,10 +52,6 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name) {
return (godot_object *)Engine::get_singleton()->get_singleton_object(String(p_name));
} // result shouldn't be freed
-void GDAPI *godot_get_stack_bottom() {
- return OS::get_singleton()->get_stack_bottom();
-}
-
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index b7b2553435..06c6e9f410 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5533,12 +5533,6 @@
]
},
{
- "name": "godot_get_stack_bottom",
- "return_type": "void *",
- "arguments": [
- ]
- },
- {
"name": "godot_method_bind_get_method",
"return_type": "godot_method_bind *",
"arguments": [
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
new file mode 100644
index 0000000000..1e638ab702
--- /dev/null
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -0,0 +1,423 @@
+/*************************************************************************/
+/* gdnative_library_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifdef TOOLS_ENABLED
+#include "gdnative_library_editor_plugin.h"
+#include "gdnative.h"
+
+void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) {
+ library = p_library;
+ Ref<ConfigFile> config = p_library->get_config_file();
+
+ for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
+ for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
+
+ String target = E->key() + "." + it->get();
+ TargetConfig ecfg;
+ ecfg.library = config->get_value("entry", target, "");
+ ecfg.dependencies = config->get_value("dependencies", target, Array());
+ entry_configs[target] = ecfg;
+ }
+ }
+
+ _update_tree();
+}
+
+void GDNativeLibraryEditor::_bind_methods() {
+
+ ClassDB::bind_method("_on_item_button", &GDNativeLibraryEditor::_on_item_button);
+ ClassDB::bind_method("_on_library_selected", &GDNativeLibraryEditor::_on_library_selected);
+ ClassDB::bind_method("_on_dependencies_selected", &GDNativeLibraryEditor::_on_dependencies_selected);
+ ClassDB::bind_method("_on_filter_selected", &GDNativeLibraryEditor::_on_filter_selected);
+ ClassDB::bind_method("_on_item_collapsed", &GDNativeLibraryEditor::_on_item_collapsed);
+ ClassDB::bind_method("_on_item_activated", &GDNativeLibraryEditor::_on_item_activated);
+ ClassDB::bind_method("_on_create_new_entry", &GDNativeLibraryEditor::_on_create_new_entry);
+}
+
+void GDNativeLibraryEditor::_update_tree() {
+
+ tree->clear();
+ TreeItem *root = tree->create_item();
+
+ for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
+
+ if (showing_platform != E->key() && showing_platform != "All")
+ continue;
+
+ TreeItem *platform = tree->create_item(root);
+ platform->set_text(0, E->get().name);
+ platform->set_metadata(0, E->get().library_extension);
+
+ platform->set_custom_bg_color(0, get_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(1, get_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(2, get_color("prop_category", "Editor"));
+ platform->set_selectable(0, false);
+ platform->set_expand_right(0, true);
+
+ for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
+
+ String target = E->key() + "." + it->get();
+ TreeItem *bit = tree->create_item(platform);
+
+ bit->set_text(0, it->get());
+ bit->set_metadata(0, target);
+ bit->set_selectable(0, false);
+ bit->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+
+ bit->add_button(1, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
+ String file = entry_configs[target].library;
+ if (!file.empty()) {
+ bit->add_button(1, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
+ }
+ bit->set_text(1, file);
+
+ bit->add_button(2, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
+ Array files = entry_configs[target].dependencies;
+ if (files.size()) {
+ bit->add_button(2, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
+ }
+ bit->set_text(2, Variant(files));
+
+ bit->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up"));
+ bit->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
+ bit->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
+ }
+
+ TreeItem *new_arch = tree->create_item(platform);
+ new_arch->set_text(0, TTR("Double click to create a new entry"));
+ new_arch->set_text_align(0, TreeItem::ALIGN_CENTER);
+ new_arch->set_custom_color(0, get_color("accent_color", "Editor"));
+ new_arch->set_expand_right(0, true);
+ new_arch->set_metadata(1, E->key());
+
+ platform->set_collapsed(collapsed_items.find(E->get().name) != NULL);
+ }
+}
+
+void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
+
+ String target = Object::cast_to<TreeItem>(item)->get_metadata(0);
+ String platform = target.substr(0, target.find("."));
+ String entry = target.substr(platform.length() + 1, target.length());
+ String section = (id == BUTTON_SELECT_DEPENDENCES || id == BUTTON_CLEAR_DEPENDENCES) ? "dependencies" : "entry";
+
+ if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) {
+
+ EditorFileDialog::Mode mode = EditorFileDialog::MODE_OPEN_FILE;
+ if (id == BUTTON_SELECT_DEPENDENCES)
+ mode = EditorFileDialog::MODE_OPEN_FILES;
+
+ file_dialog->set_meta("target", target);
+ file_dialog->set_meta("section", section);
+ file_dialog->clear_filters();
+ file_dialog->add_filter(Object::cast_to<TreeItem>(item)->get_parent()->get_metadata(0));
+ file_dialog->set_mode(mode);
+ file_dialog->popup_centered_ratio();
+
+ } else if (id == BUTTON_CLEAR_LIBRARY) {
+ _set_target_value(section, target, "");
+ } else if (id == BUTTON_CLEAR_DEPENDENCES) {
+ _set_target_value(section, target, Array());
+ } else if (id == BUTTON_ERASE_ENTRY) {
+ _erase_entry(platform, entry);
+ } else if (id == BUTTON_MOVE_UP || id == BUTTON_MOVE_DOWN) {
+ _move_entry(platform, entry, id);
+ }
+}
+
+void GDNativeLibraryEditor::_on_library_selected(const String &file) {
+
+ _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file);
+}
+
+void GDNativeLibraryEditor::_on_dependencies_selected(const PoolStringArray &files) {
+
+ _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files);
+}
+
+void GDNativeLibraryEditor::_on_filter_selected(int id) {
+
+ showing_platform = filter->get_item_metadata(id);
+ _update_tree();
+}
+
+void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) {
+
+ TreeItem *item = Object::cast_to<TreeItem>(p_item);
+ String name = item->get_text(0);
+
+ if (item->is_collapsed()) {
+ collapsed_items.insert(name);
+ } else if (Set<String>::Element *e = collapsed_items.find(name)) {
+ collapsed_items.erase(e);
+ }
+}
+
+void GDNativeLibraryEditor::_on_item_activated() {
+
+ TreeItem *item = tree->get_selected();
+ if (item && tree->get_selected_column() == 0 && item->get_metadata(0).get_type() == Variant::NIL) {
+ new_architecture_dialog->set_meta("platform", item->get_metadata(1));
+ new_architecture_dialog->popup_centered();
+ }
+}
+
+void GDNativeLibraryEditor::_on_create_new_entry() {
+
+ String platform = new_architecture_dialog->get_meta("platform");
+ String entry = new_architecture_input->get_text().strip_edges();
+ if (!entry.empty()) {
+ platforms[platform].entries.push_back(entry);
+ _update_tree();
+ }
+}
+
+void GDNativeLibraryEditor::_set_target_value(const String &section, const String &target, Variant file) {
+ if (section == "entry")
+ entry_configs[target].library = file;
+ else if (section == "dependencies")
+ entry_configs[target].dependencies = file;
+ _translate_to_config_file();
+ _update_tree();
+}
+
+void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) {
+
+ if (platforms.has(platform)) {
+ if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
+
+ String target = platform + "." + entry;
+ Ref<ConfigFile> config = library->get_config_file();
+
+ platforms[platform].entries.erase(E);
+ _set_target_value("entry", target, "");
+ _set_target_value("dependencies", target, Array());
+ _translate_to_config_file();
+ _update_tree();
+ }
+ }
+}
+
+void GDNativeLibraryEditor::_move_entry(const String &platform, const String &entry, int dir) {
+ if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
+ if (E->prev() && dir == BUTTON_MOVE_UP) {
+ platforms[platform].entries.insert_before(E->prev(), E->get());
+ platforms[platform].entries.erase(E);
+ } else if (E->next() && dir == BUTTON_MOVE_DOWN) {
+ platforms[platform].entries.insert_after(E->next(), E->get());
+ platforms[platform].entries.erase(E);
+ }
+ _translate_to_config_file();
+ _update_tree();
+ }
+}
+
+void GDNativeLibraryEditor::_translate_to_config_file() {
+
+ if (!library.is_null()) {
+
+ Ref<ConfigFile> config = library->get_config_file();
+ config->erase_section("entry");
+ config->erase_section("dependencies");
+
+ for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
+ for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
+
+ String target = E->key() + "." + it->get();
+ if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty())
+ continue;
+
+ config->set_value("entry", target, entry_configs[target].library);
+ config->set_value("dependencies", target, entry_configs[target].dependencies);
+ }
+ }
+
+ library->_change_notify();
+ }
+}
+
+GDNativeLibraryEditor::GDNativeLibraryEditor() {
+
+ showing_platform = "All";
+
+ { // Define platforms
+ NativePlatformConfig platform_windows;
+ platform_windows.name = "Windows";
+ platform_windows.entries.push_back("64");
+ platform_windows.entries.push_back("32");
+ platform_windows.library_extension = "*.dll";
+ platforms["Windows"] = platform_windows;
+
+ NativePlatformConfig platform_linux;
+ platform_linux.name = "Linux/X11";
+ platform_linux.entries.push_back("64");
+ platform_linux.entries.push_back("32");
+ platform_linux.library_extension = "*.so";
+ platforms["X11"] = platform_linux;
+
+ NativePlatformConfig platform_osx;
+ platform_osx.name = "Mac OSX";
+ platform_osx.entries.push_back("64");
+ platform_osx.entries.push_back("32");
+ platform_osx.library_extension = "*.dylib";
+ platforms["OSX"] = platform_osx;
+
+ NativePlatformConfig platform_haiku;
+ platform_haiku.name = "Haiku";
+ platform_haiku.entries.push_back("64");
+ platform_haiku.entries.push_back("32");
+ platform_haiku.library_extension = "*.so";
+ platforms["Haiku"] = platform_haiku;
+
+ NativePlatformConfig platform_uwp;
+ platform_uwp.name = "Windows Universal";
+ platform_uwp.entries.push_back("arm");
+ platform_uwp.entries.push_back("x86");
+ platform_uwp.entries.push_back("x64");
+ platform_uwp.library_extension = "*.dll";
+ platforms["UWP"] = platform_uwp;
+
+ NativePlatformConfig platform_android;
+ platform_android.name = "Android";
+ platform_android.entries.push_back("armeabi-v7a");
+ platform_android.entries.push_back("arm64-v8a");
+ platform_android.entries.push_back("x86");
+ platform_android.entries.push_back("x86_64");
+ platform_android.library_extension = "*.so";
+ platforms["Android"] = platform_android;
+
+ // TODO: Javascript platform is not supported yet
+ // NativePlatformConfig platform_html5;
+ // platform_html5.name = "HTML5";
+ // platform_html5.library_extension = "*.wasm";
+ // platforms["Javascript"] = platform_html5;
+
+ NativePlatformConfig platform_ios;
+ platform_ios.name = "iOS";
+ platform_ios.entries.push_back("armv7");
+ platform_ios.entries.push_back("arm64");
+ platform_ios.library_extension = "*.dylib";
+ platforms["iOS"] = platform_ios;
+ }
+
+ VBoxContainer *container = memnew(VBoxContainer);
+ add_child(container);
+ container->set_anchors_and_margins_preset(PRESET_WIDE);
+
+ HBoxContainer *hbox = memnew(HBoxContainer);
+ container->add_child(hbox);
+ Label *label = memnew(Label);
+ label->set_text(TTR("Platform:"));
+ hbox->add_child(label);
+ filter = memnew(OptionButton);
+ hbox->add_child(filter);
+ filter->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ int idx = 0;
+ filter->add_item(TTR("All"), idx);
+ filter->set_item_metadata(idx, "All");
+ idx += 1;
+ for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
+ filter->add_item(E->get().name, idx);
+ filter->set_item_metadata(idx, E->key());
+ idx += 1;
+ }
+ filter->connect("item_selected", this, "_on_filter_selected");
+
+ tree = memnew(Tree);
+ container->add_child(tree);
+ tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_hide_root(true);
+ tree->set_column_titles_visible(true);
+ tree->set_columns(4);
+ tree->set_column_expand(0, false);
+ tree->set_column_min_width(0, int(200 * EDSCALE));
+ tree->set_column_title(0, TTR("Platform"));
+ tree->set_column_title(1, TTR("Dynamic Library"));
+ tree->set_column_title(2, TTR("Dependencies"));
+ tree->set_column_expand(3, false);
+ tree->set_column_min_width(3, int(110 * EDSCALE));
+ tree->connect("button_pressed", this, "_on_item_button");
+ tree->connect("item_collapsed", this, "_on_item_collapsed");
+ tree->connect("item_activated", this, "_on_item_activated");
+
+ file_dialog = memnew(EditorFileDialog);
+ file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
+ file_dialog->set_resizable(true);
+ add_child(file_dialog);
+ file_dialog->connect("file_selected", this, "_on_library_selected");
+ file_dialog->connect("files_selected", this, "_on_dependencies_selected");
+
+ new_architecture_dialog = memnew(ConfirmationDialog);
+ add_child(new_architecture_dialog);
+ new_architecture_dialog->set_title(TTR("Add an architecture entry"));
+ new_architecture_input = memnew(LineEdit);
+ new_architecture_dialog->add_child(new_architecture_input);
+ new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
+ new_architecture_input->set_anchors_and_margins_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE);
+ new_architecture_dialog->get_ok()->connect("pressed", this, "_on_create_new_entry");
+}
+
+void GDNativeLibraryEditorPlugin::edit(Object *p_node) {
+
+ if (Object::cast_to<GDNativeLibrary>(p_node)) {
+ library_editor->edit(Object::cast_to<GDNativeLibrary>(p_node));
+ library_editor->show();
+ } else
+ library_editor->hide();
+}
+
+bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const {
+
+ return p_node->is_class("GDNativeLibrary");
+}
+
+void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) {
+
+ if (p_visible) {
+ button->show();
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor);
+
+ } else {
+ if (library_editor->is_visible_in_tree())
+ EditorNode::get_singleton()->hide_bottom_panel();
+ button->hide();
+ }
+}
+
+GDNativeLibraryEditorPlugin::GDNativeLibraryEditorPlugin(EditorNode *p_node) {
+
+ library_editor = memnew(GDNativeLibraryEditor);
+ library_editor->set_custom_minimum_size(Size2(0, 250 * EDSCALE));
+ button = p_node->add_bottom_panel_item(TTR("GDNativeLibrary"), library_editor);
+ button->hide();
+}
+
+#endif
diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h
new file mode 100644
index 0000000000..1fa6a0c945
--- /dev/null
+++ b/modules/gdnative/gdnative_library_editor_plugin.h
@@ -0,0 +1,113 @@
+/*************************************************************************/
+/* gdnative_library_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
+#define GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+#include "gdnative.h"
+
+class GDNativeLibraryEditor : public Control {
+
+ GDCLASS(GDNativeLibraryEditor, Control);
+
+ struct NativePlatformConfig {
+ String name;
+ String library_extension;
+ List<String> entries;
+ };
+
+ struct TargetConfig {
+ String library;
+ Array dependencies;
+ };
+
+ enum ItemButton {
+ BUTTON_SELECT_LIBRARY,
+ BUTTON_CLEAR_LIBRARY,
+ BUTTON_SELECT_DEPENDENCES,
+ BUTTON_CLEAR_DEPENDENCES,
+ BUTTON_ERASE_ENTRY,
+ BUTTON_MOVE_UP,
+ BUTTON_MOVE_DOWN,
+ };
+
+ Tree *tree;
+ OptionButton *filter;
+ EditorFileDialog *file_dialog;
+ ConfirmationDialog *new_architecture_dialog;
+ LineEdit *new_architecture_input;
+ Set<String> collapsed_items;
+
+ String showing_platform;
+ Ref<GDNativeLibrary> library;
+ Map<String, NativePlatformConfig> platforms;
+ Map<String, TargetConfig> entry_configs;
+
+protected:
+ static void _bind_methods();
+ void _update_tree();
+ void _on_item_button(Object *item, int column, int id);
+ void _on_library_selected(const String &file);
+ void _on_dependencies_selected(const PoolStringArray &files);
+ void _on_filter_selected(int id);
+ void _on_item_collapsed(Object *item);
+ void _on_item_activated();
+ void _on_create_new_entry();
+ void _set_target_value(const String &section, const String &target, Variant file);
+ void _erase_entry(const String &platform, const String &entry);
+ void _move_entry(const String &platform, const String &entry, int dir);
+ void _translate_to_config_file();
+
+public:
+ void edit(Ref<GDNativeLibrary> p_library);
+
+ GDNativeLibraryEditor();
+};
+
+class GDNativeLibraryEditorPlugin : public EditorPlugin {
+
+ GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin);
+
+ GDNativeLibraryEditor *library_editor;
+ EditorNode *editor;
+ Button *button;
+
+public:
+ virtual String get_name() const { return "GDNativeLibrary"; }
+ bool has_main_screen() const { return false; }
+ virtual void edit(Object *p_node);
+ virtual bool handles(Object *p_node) const;
+ virtual void make_visible(bool p_visible);
+
+ GDNativeLibraryEditorPlugin(EditorNode *p_node);
+};
+#endif
+#endif // GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
diff --git a/modules/gdnative/gd_native_library_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp
index fda5dcdcad..2ad497fcad 100644
--- a/modules/gdnative/gd_native_library_editor.cpp
+++ b/modules/gdnative/gdnative_library_singleton_editor.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_native_library_editor.cpp */
+/* gdnative_library_singleton_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef TOOLS_ENABLED
-#include "gd_native_library_editor.h"
-
+#include "gdnative_library_singleton_editor.h"
#include "gdnative.h"
-void GDNativeLibraryEditor::_find_gdnative_singletons(EditorFileSystemDirectory *p_dir, const Set<String> &enabled_list) {
+void GDNativeLibrarySingletonEditor::_find_gdnative_singletons(EditorFileSystemDirectory *p_dir, const Set<String> &enabled_list) {
// check children
@@ -65,7 +64,7 @@ void GDNativeLibraryEditor::_find_gdnative_singletons(EditorFileSystemDirectory
}
}
-void GDNativeLibraryEditor::_update_libraries() {
+void GDNativeLibrarySingletonEditor::_update_libraries() {
updating = true;
libraries->clear();
@@ -88,7 +87,7 @@ void GDNativeLibraryEditor::_update_libraries() {
updating = false;
}
-void GDNativeLibraryEditor::_item_edited() {
+void GDNativeLibrarySingletonEditor::_item_edited() {
if (updating)
return;
@@ -119,7 +118,7 @@ void GDNativeLibraryEditor::_item_edited() {
}
}
-void GDNativeLibraryEditor::_notification(int p_what) {
+void GDNativeLibrarySingletonEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible_in_tree()) {
@@ -128,12 +127,12 @@ void GDNativeLibraryEditor::_notification(int p_what) {
}
}
-void GDNativeLibraryEditor::_bind_methods() {
+void GDNativeLibrarySingletonEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_item_edited"), &GDNativeLibraryEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_item_edited"), &GDNativeLibrarySingletonEditor::_item_edited);
}
-GDNativeLibraryEditor::GDNativeLibraryEditor() {
+GDNativeLibrarySingletonEditor::GDNativeLibrarySingletonEditor() {
libraries = memnew(Tree);
libraries->set_columns(2);
libraries->set_column_titles_visible(true);
diff --git a/modules/gdnative/gd_native_library_editor.h b/modules/gdnative/gdnative_library_singleton_editor.h
index a11c4620dd..ee1a32c5a5 100644
--- a/modules/gdnative/gd_native_library_editor.h
+++ b/modules/gdnative/gdnative_library_singleton_editor.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_native_library_editor.h */
+/* gdnative_library_singleton_editor.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,7 +34,7 @@
#include "editor/editor_file_system.h"
#include "editor/project_settings_editor.h"
-class GDNativeLibraryEditor : public VBoxContainer {
+class GDNativeLibrarySingletonEditor : public VBoxContainer {
Tree *libraries;
bool updating;
@@ -48,7 +48,7 @@ protected:
static void _bind_methods();
public:
- GDNativeLibraryEditor();
+ GDNativeLibrarySingletonEditor();
};
#endif
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index f7f5606428..9d7829a51f 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -212,10 +212,6 @@ void GDAPI godot_object_destroy(godot_object *p_o);
godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
-////// OS API
-
-void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread
-
////// MethodBind API
typedef struct {
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 1cb35ec006..bd9bae5294 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -45,7 +45,8 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
-#include "gd_native_library_editor.h"
+#include "gdnative_library_editor_plugin.h"
+#include "gdnative_library_singleton_editor.h"
// Class used to discover singleton gdnative files
static void actual_discoverer_handler();
@@ -267,7 +268,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
static void editor_init_callback() {
- GDNativeLibraryEditor *library_editor = memnew(GDNativeLibraryEditor);
+ GDNativeLibrarySingletonEditor *library_editor = memnew(GDNativeLibrarySingletonEditor);
library_editor->set_name(TTR("GDNative"));
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor);
@@ -278,6 +279,8 @@ static void editor_init_callback() {
export_plugin.instance();
EditorExport::get_singleton()->add_export_plugin(export_plugin);
+
+ EditorNode::get_singleton()->add_editor_plugin(memnew(GDNativeLibraryEditorPlugin(EditorNode::get_singleton())));
}
#endif
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index ee23f0ea0f..d6352f1e6e 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1257,6 +1257,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
exit_ok = true;
OPCODE_BREAK;
}
+
+// Enable for debugging
#if 0
default: {
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 36ae61e388..8c110143b8 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -597,12 +597,36 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_CALL;
+ //Do a quick Array and Dictionary Check. Replace if either require no arguments.
+ bool replaced = false;
+
if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
+ Variant::Type ct = tokenizer->get_token_type();
+ if (p_parsing_constant == false) {
+ if (ct == Variant::ARRAY) {
+ if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ ArrayNode *arr = alloc_node<ArrayNode>();
+ expr = arr;
+ replaced = true;
+ tokenizer->advance(3);
+ }
+ }
+ if (ct == Variant::DICTIONARY) {
+ if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ DictionaryNode *dict = alloc_node<DictionaryNode>();
+ expr = dict;
+ replaced = true;
+ tokenizer->advance(3);
+ }
+ }
+ }
- TypeNode *tn = alloc_node<TypeNode>();
- tn->vtype = tokenizer->get_token_type();
- op->arguments.push_back(tn);
- tokenizer->advance(2);
+ if (!replaced) {
+ TypeNode *tn = alloc_node<TypeNode>();
+ tn->vtype = tokenizer->get_token_type();
+ op->arguments.push_back(tn);
+ tokenizer->advance(2);
+ }
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
BuiltInFunctionNode *bn = alloc_node<BuiltInFunctionNode>();
@@ -628,11 +652,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
_make_completable_call(0);
completion_node = op;
}
- if (!_parse_arguments(op, op->arguments, p_static, true))
- return NULL;
-
- expr = op;
-
+ if (!replaced) {
+ if (!_parse_arguments(op, op->arguments, p_static, true))
+ return NULL;
+ expr = op;
+ }
} else if (tokenizer->is_token_literal(0, true)) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//identifier (reference)
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index 8c862b52e8..e9bb90631d 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -21,6 +21,26 @@
Clear all cells.
</description>
</method>
+ <method name="clear_baked_meshes">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_bake_mesh_instance">
+ <return type="RID">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_bake_meshes">
+ <return type="Array">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_cell_item" qualifiers="const">
<return type="int">
</return>
@@ -103,6 +123,16 @@
Array of [Vector3] with the non empty cell coordinates in the grid map.
</description>
</method>
+ <method name="make_baked_meshes">
+ <return type="void">
+ </return>
+ <argument index="0" name="gen_lightmap_uv" type="bool" default="false">
+ </argument>
+ <argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="map_to_world" qualifiers="const">
<return type="Vector3">
</return>
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index b3a1947647..0b73cbfc6d 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -101,6 +101,27 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
}
_recreate_octant_data();
+ } else if (name == "baked_meshes") {
+
+ clear_baked_meshes();
+
+ Array meshes = p_value;
+
+ for (int i = 0; i < meshes.size(); i++) {
+ BakedMesh bm;
+ bm.mesh = meshes[i];
+ ERR_CONTINUE(!bm.mesh.is_valid());
+ bm.instance = VS::get_singleton()->instance_create();
+ VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ if (is_inside_tree()) {
+ VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ }
+ baked_meshes.push_back(bm);
+ }
+
+ _recreate_octant_data();
} else
return false;
@@ -145,6 +166,15 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
d["cells"] = cells;
r_ret = d;
+ } else if (name == "baked_meshes") {
+
+ Array ret;
+ ret.resize(baked_meshes.size());
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ ret.push_back(baked_meshes[i].mesh);
+ }
+ r_ret = ret;
+
} else
return false;
@@ -161,6 +191,9 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_y"));
p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_z"));
p_list->push_back(PropertyInfo(Variant::REAL, "cell_scale"));
+ if (baked_meshes.size()) {
+ p_list->push_back(PropertyInfo(Variant::ARRAY, "baked_meshes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
+ }
p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
}
@@ -235,6 +268,12 @@ bool GridMap::get_center_z() const {
void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
+ if (baked_meshes.size() && !recreating_octants) {
+ //if you set a cell item, baked meshes go good bye
+ clear_baked_meshes();
+ _recreate_octant_data();
+ }
+
ERR_FAIL_INDEX(ABS(p_x), 1 << 20);
ERR_FAIL_INDEX(ABS(p_y), 1 << 20);
ERR_FAIL_INDEX(ABS(p_z), 1 << 20);
@@ -436,16 +475,17 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
xform.basis.set_orthogonal_index(c.rot);
xform.set_origin(cellpos * cell_size + ofs);
xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
+ if (baked_meshes.size() == 0) {
+ if (theme->get_item_mesh(c.item).is_valid()) {
+ if (!multimesh_items.has(c.item)) {
+ multimesh_items[c.item] = List<Pair<Transform, IndexKey> >();
+ }
- if (theme->get_item_mesh(c.item).is_valid()) {
- if (!multimesh_items.has(c.item)) {
- multimesh_items[c.item] = List<Pair<Transform, IndexKey> >();
+ Pair<Transform, IndexKey> p;
+ p.first = xform;
+ p.second = E->get();
+ multimesh_items[c.item].push_back(p);
}
-
- Pair<Transform, IndexKey> p;
- p.first = xform;
- p.second = E->get();
- multimesh_items[c.item].push_back(p);
}
Vector<MeshLibrary::ShapeData> shapes = theme->get_item_shapes(c.item);
@@ -469,7 +509,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
nm.xform = xform;
if (navigation) {
- nm.id = navigation->navmesh_create(navmesh, xform, this);
+ nm.id = navigation->navmesh_add(navmesh, xform, this);
} else {
nm.id = -1;
}
@@ -477,41 +517,44 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
}
- //update multimeshes
- for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) {
- Octant::MultimeshInstance mmi;
+ //update multimeshes, only if not baked
+ if (baked_meshes.size() == 0) {
+
+ for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) {
+ Octant::MultimeshInstance mmi;
- RID mm = VS::get_singleton()->multimesh_create();
- VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
- VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid());
+ RID mm = VS::get_singleton()->multimesh_create();
+ VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
+ VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid());
- int idx = 0;
- for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) {
- VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
+ int idx = 0;
+ for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) {
+ VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
#ifdef TOOLS_ENABLED
- Octant::MultimeshInstance::Item it;
- it.index = idx;
- it.transform = F->get().first;
- it.key = F->get().second;
- mmi.items.push_back(it);
+ Octant::MultimeshInstance::Item it;
+ it.index = idx;
+ it.transform = F->get().first;
+ it.key = F->get().second;
+ mmi.items.push_back(it);
#endif
- idx++;
- }
+ idx++;
+ }
- RID instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(instance, mm);
+ RID instance = VS::get_singleton()->instance_create();
+ VS::get_singleton()->instance_set_base(instance, mm);
- if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(instance, get_global_transform());
- }
+ if (is_inside_tree()) {
+ VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(instance, get_global_transform());
+ }
- mmi.multimesh = mm;
- mmi.instance = instance;
+ mmi.multimesh = mm;
+ mmi.instance = instance;
- g.multimesh_instances.push_back(mmi);
+ g.multimesh_instances.push_back(mmi);
+ }
}
if (col_debug.size()) {
@@ -556,7 +599,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (cell_map.has(F->key()) && F->get().id < 0) {
Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item);
if (nm.is_valid()) {
- F->get().id = navigation->navmesh_create(nm, F->get().xform, this);
+ F->get().id = navigation->navmesh_add(nm, F->get().xform, this);
}
}
}
@@ -642,6 +685,11 @@ void GridMap::_notification(int p_what) {
_octant_enter_world(E->key());
}
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ }
+
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -655,6 +703,10 @@ void GridMap::_notification(int p_what) {
last_transform = new_xform;
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ }
+
} break;
case NOTIFICATION_EXIT_WORLD: {
@@ -667,6 +719,9 @@ void GridMap::_notification(int p_what) {
//_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
//_update_octants_callback();
//_update_area_instances();
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -701,12 +756,14 @@ void GridMap::_queue_octants_dirty() {
void GridMap::_recreate_octant_data() {
+ recreating_octants = true;
Map<IndexKey, Cell> cell_copy = cell_map;
_clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
}
+ recreating_octants = false;
}
void GridMap::_clear_internal() {
@@ -726,6 +783,7 @@ void GridMap::_clear_internal() {
void GridMap::clear() {
_clear_internal();
+ clear_baked_meshes();
}
void GridMap::resource_changed(const RES &p_res) {
@@ -791,6 +849,11 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells);
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
+ ClassDB::bind_method(D_METHOD("get_bake_meshes"), &GridMap::get_bake_meshes);
+ ClassDB::bind_method(D_METHOD("get_bake_mesh_instance", "idx"), &GridMap::get_bake_mesh_instance);
+
+ ClassDB::bind_method(D_METHOD("clear_baked_meshes"), &GridMap::clear_baked_meshes);
+ ClassDB::bind_method(D_METHOD("make_baked_meshes", "gen_lightmap_uv", "lightmap_uv_texel_size"), &GridMap::make_baked_meshes, DEFVAL(false), DEFVAL(0.1));
BIND_CONSTANT(INVALID_CELL_ITEM);
}
@@ -883,10 +946,129 @@ Vector3 GridMap::_get_offset() const {
cell_size.z * 0.5 * int(center_z));
}
+void GridMap::clear_baked_meshes() {
+
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ VS::get_singleton()->free(baked_meshes[i].instance);
+ }
+ baked_meshes.clear();
+
+ _recreate_octant_data();
+}
+
+void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texel_size) {
+
+ if (!theme.is_valid())
+ return;
+
+ //generate
+ Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool> > > surface_map;
+
+ for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
+
+ IndexKey key = E->key();
+
+ int item = E->get().item;
+ if (!theme->has_item(item))
+ continue;
+
+ Ref<Mesh> mesh = theme->get_item_mesh(item);
+ if (!mesh.is_valid())
+ continue;
+
+ Vector3 cellpos = Vector3(key.x, key.y, key.z);
+ Vector3 ofs = _get_offset();
+
+ Transform xform;
+
+ xform.basis.set_orthogonal_index(E->get().rot);
+ xform.set_origin(cellpos * cell_size + ofs);
+ xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
+
+ OctantKey ok;
+ ok.x = key.x / octant_size;
+ ok.y = key.y / octant_size;
+ ok.z = key.z / octant_size;
+
+ if (!surface_map.has(ok)) {
+ surface_map[ok] = Map<Ref<Material>, Ref<SurfaceTool> >();
+ }
+
+ Map<Ref<Material>, Ref<SurfaceTool> > &mat_map = surface_map[ok];
+
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+
+ if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ continue;
+
+ Ref<Material> surf_mat = mesh->surface_get_material(i);
+ if (!mat_map.has(surf_mat)) {
+ Ref<SurfaceTool> st;
+ st.instance();
+ st->begin(Mesh::PRIMITIVE_TRIANGLES);
+ st->set_material(surf_mat);
+ mat_map[surf_mat] = st;
+ }
+
+ mat_map[surf_mat]->append_from(mesh, i, xform);
+ }
+ }
+
+ int ofs = 0;
+
+ for (Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool> > >::Element *E = surface_map.front(); E; E = E->next()) {
+
+ print_line("generating mesh " + itos(ofs++) + "/" + itos(surface_map.size()));
+ Ref<ArrayMesh> mesh;
+ mesh.instance();
+ for (Map<Ref<Material>, Ref<SurfaceTool> >::Element *F = E->get().front(); F; F = F->next()) {
+ F->get()->commit(mesh);
+ }
+
+ BakedMesh bm;
+ bm.mesh = mesh;
+ bm.instance = VS::get_singleton()->instance_create();
+ VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ if (is_inside_tree()) {
+ VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ }
+
+ if (p_gen_lightmap_uv) {
+ mesh->lightmap_unwrap(get_global_transform(), p_lightmap_uv_texel_size);
+ }
+ baked_meshes.push_back(bm);
+ }
+
+ _recreate_octant_data();
+}
+
+Array GridMap::get_bake_meshes() {
+
+ if (!baked_meshes.size()) {
+ make_baked_meshes(true);
+ }
+
+ Array arr;
+ for (int i = 0; i < baked_meshes.size(); i++) {
+ arr.push_back(baked_meshes[i].mesh);
+ arr.push_back(Transform());
+ }
+
+ return arr;
+}
+
+RID GridMap::get_bake_mesh_instance(int p_idx) {
+
+ ERR_FAIL_INDEX_V(p_idx, baked_meshes.size(), RID());
+ return baked_meshes[p_idx].instance;
+}
+
GridMap::GridMap() {
cell_size = Vector3(2, 2, 2);
- octant_size = 4;
+ octant_size = 8;
awaiting_update = false;
_in_tree = false;
center_x = true;
@@ -901,6 +1083,7 @@ GridMap::GridMap() {
navigation = NULL;
set_notify_transform(true);
+ recreating_octants = false;
}
GridMap::~GridMap() {
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 5bfdf1dac3..241ac7a434 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -148,6 +148,9 @@ class GridMap : public Spatial {
bool clip;
bool clip_above;
int clip_floor;
+
+ bool recreating_octants;
+
Vector3::Axis clip_axis;
Ref<MeshLibrary> theme;
@@ -186,6 +189,13 @@ class GridMap : public Spatial {
Vector3 _get_offset() const;
+ struct BakedMesh {
+ Ref<Mesh> mesh;
+ RID instance;
+ };
+
+ Vector<BakedMesh> baked_meshes;
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -232,8 +242,14 @@ public:
Array get_meshes();
+ void clear_baked_meshes();
+ void make_baked_meshes(bool p_gen_lightmap_uv = false, float p_lightmap_uv_texel_size = 0.1);
+
void clear();
+ Array get_bake_meshes();
+ RID get_bake_mesh_instance(int p_idx);
+
GridMap();
~GridMap();
};
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index af5a0334c3..44dd776e9a 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -1376,7 +1376,7 @@ bool CSharpScript::_update_exports() {
hint_string = NATIVE_GDMONOCLASS_NAME(field_type.type_class);
} else {
hint = PropertyHint(CACHED_FIELD(ExportAttribute, hint)->get_int_value(attr));
- hint_string = CACHED_FIELD(ExportAttribute, hint_string)->get_string_value(attr);
+ hint_string = CACHED_FIELD(ExportAttribute, hintString)->get_string_value(attr);
}
PropertyInfo prop_info = PropertyInfo(type, name, hint, hint_string, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE);
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index fbb9b2ed14..d7885ade61 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -108,7 +108,7 @@ const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN = "\t%0 %1_in
bool BindingsGenerator::verbose_output = false;
-static String snake_to_pascal_case(const String &p_identifier) {
+static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_upper = false) {
String ret;
Vector<String> parts = p_identifier.split("_", true);
@@ -118,6 +118,10 @@ static String snake_to_pascal_case(const String &p_identifier) {
if (part.length()) {
part[0] = _find_upper(part[0]);
+ if (p_input_is_upper) {
+ for (int j = 1; j < part.length(); j++)
+ part[j] = _find_lower(part[j]);
+ }
ret += part;
} else {
if (i == 0 || i == (parts.size() - 1)) {
@@ -137,7 +141,7 @@ static String snake_to_pascal_case(const String &p_identifier) {
return ret;
}
-static String snake_to_camel_case(const String &p_identifier) {
+static String snake_to_camel_case(const String &p_identifier, bool p_input_is_upper = false) {
String ret;
Vector<String> parts = p_identifier.split("_", true);
@@ -146,8 +150,13 @@ static String snake_to_camel_case(const String &p_identifier) {
String part = parts[i];
if (part.length()) {
- if (i != 0)
+ if (i != 0) {
part[0] = _find_upper(part[0]);
+ }
+ if (p_input_is_upper) {
+ for (int j = i != 0 ? 1 : 0; j < part.length(); j++)
+ part[j] = _find_lower(part[j]);
+ }
ret += part;
} else {
if (i == 0 || i == (parts.size() - 1)) {
@@ -167,6 +176,25 @@ static String snake_to_camel_case(const String &p_identifier) {
return ret;
}
+String BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
+
+ CRASH_COND(p_ienum.constants.empty());
+
+ const List<ConstantInterface>::Element *front = p_ienum.constants.front();
+ int candidate_len = front->get().name.length();
+
+ for (const List<ConstantInterface>::Element *E = front->next(); E; E = E->next()) {
+ int j = 0;
+ for (j = 0; j < candidate_len && j < E->get().name.length(); j++) {
+ if (front->get().name[j] != E->get().name[j])
+ break;
+ }
+ candidate_len = j;
+ }
+
+ return front->get().name.substr(0, candidate_len);
+}
+
void BindingsGenerator::_generate_header_icalls() {
core_custom_icalls.clear();
@@ -220,7 +248,7 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
const TypeInterface *return_type = _get_type_by_name_or_placeholder(imethod.return_type);
String im_sig = "IntPtr " CS_PARAM_METHODBIND ", IntPtr " CS_PARAM_INSTANCE;
- String im_unique_sig = imethod.return_type + ",IntPtr,IntPtr";
+ String im_unique_sig = imethod.return_type.operator String() + ",IntPtr,IntPtr";
// Get arguments information
int i = 0;
@@ -256,6 +284,129 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
}
}
+void BindingsGenerator::_generate_global_constants(List<String> &p_output) {
+
+ // Constants (in partial GD class)
+
+ p_output.push_back("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK);
+ p_output.push_back(INDENT1 "public static partial class " BINDINGS_GLOBAL_SCOPE_CLASS "\n" INDENT1 "{");
+
+ for (const List<ConstantInterface>::Element *E = global_constants.front(); E; E = E->next()) {
+ const ConstantInterface &iconstant = E->get();
+
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
+ p_output.push_back(MEMBER_BEGIN "/// <summary>\n");
+
+ Vector<String> description_lines = iconstant.const_doc->description.split("\n");
+
+ for (int i = 0; i < description_lines.size(); i++) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
+ p_output.push_back(INDENT2 "/// ");
+ p_output.push_back(description_line.xml_escape());
+ p_output.push_back("\n");
+ }
+ }
+
+ p_output.push_back(INDENT2 "/// </summary>");
+ }
+
+ p_output.push_back(MEMBER_BEGIN "public const int ");
+ p_output.push_back(iconstant.name);
+ p_output.push_back(" = ");
+ p_output.push_back(itos(iconstant.value));
+ p_output.push_back(";");
+ }
+
+ if (!global_constants.empty())
+ p_output.push_back("\n");
+
+ p_output.push_back(INDENT1 CLOSE_BLOCK); // end of GD class
+
+ // Enums
+
+ for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) {
+ const EnumInterface &ienum = E->get();
+
+ CRASH_COND(ienum.constants.empty());
+
+ String enum_proxy_name = ienum.cname.operator String();
+
+ bool enum_in_static_class = false;
+
+ if (enum_proxy_name.find(".") > 0) {
+ enum_in_static_class = true;
+ String enum_class_name = enum_proxy_name.get_slicec('.', 0);
+ enum_proxy_name = enum_proxy_name.get_slicec('.', 1);
+
+ CRASH_COND(enum_class_name != "Variant"); // Hard-coded...
+
+ if (verbose_output) {
+ WARN_PRINTS("Declaring global enum `" + enum_proxy_name + "` inside static class `" + enum_class_name + "`");
+ }
+
+ p_output.push_back("\n" INDENT1 "public static partial class ");
+ p_output.push_back(enum_class_name);
+ p_output.push_back("\n" INDENT1 OPEN_BLOCK);
+ }
+
+ p_output.push_back("\n" INDENT1 "public enum ");
+ p_output.push_back(enum_proxy_name);
+ p_output.push_back("\n" INDENT1 OPEN_BLOCK);
+
+ for (const List<ConstantInterface>::Element *E = ienum.constants.front(); E; E = E->next()) {
+ const ConstantInterface &iconstant = E->get();
+
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
+ p_output.push_back(INDENT2 "/// <summary>\n");
+
+ Vector<String> description_lines = iconstant.const_doc->description.split("\n");
+
+ for (int i = 0; i < description_lines.size(); i++) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
+ p_output.push_back(INDENT2 "/// ");
+ p_output.push_back(description_line.xml_escape());
+ p_output.push_back("\n");
+ }
+ }
+
+ p_output.push_back(INDENT2 "/// </summary>\n");
+ }
+
+ String constant_name = iconstant.name;
+
+ if (!ienum.prefix.empty() && constant_name.begins_with(ienum.prefix)) {
+ constant_name = constant_name.substr(ienum.prefix.length(), constant_name.length());
+ }
+
+ if (constant_name[0] >= '0' && constant_name[0] <= '9') {
+ // The name of enum constants may begin with a numeric digit when strip from the enum prefix,
+ // so we make the prefix one word shorter in those cases.
+ int i = 0;
+ for (i = ienum.prefix.length() - 1; i >= 0; i--) {
+ if (ienum.prefix[i] >= 'A' && ienum.prefix[i] <= 'Z')
+ break;
+ }
+ constant_name = ienum.prefix.substr(i, ienum.prefix.length()) + constant_name;
+ }
+
+ p_output.push_back(INDENT2);
+ p_output.push_back(constant_name);
+ p_output.push_back(" = ");
+ p_output.push_back(itos(iconstant.value));
+ p_output.push_back(E != ienum.constants.back() ? ",\n" : "\n");
+ }
+
+ p_output.push_back(INDENT1 CLOSE_BLOCK);
+
+ if (enum_in_static_class)
+ p_output.push_back(INDENT1 CLOSE_BLOCK);
+ }
+
+ p_output.push_back(CLOSE_BLOCK); // end of namespace
+}
+
Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bool p_verbose_output) {
verbose_output = p_verbose_output;
@@ -282,7 +433,19 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
if (!solution.set_path(p_output_dir))
return ERR_FILE_NOT_FOUND;
- for (Map<String, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
+ // Generate source file for global scope constants and enums
+ {
+ List<String> constants_source;
+ _generate_global_constants(constants_source);
+ String output_file = path_join(core_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
+ Error save_err = _save_file(output_file, constants_source);
+ if (save_err != OK)
+ return save_err;
+
+ compile_items.push_back(output_file);
+ }
+
+ for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
const TypeInterface &itype = E->get();
if (itype.api_type == ClassDB::API_EDITOR)
@@ -314,49 +477,6 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
#undef GENERATE_BUILTIN_TYPE
- // Generate source for GlobalConstants
-
- String constants_source;
- int global_constants_count = GlobalConstants::get_global_constant_count();
-
- if (global_constants_count > 0) {
- Map<String, DocData::ClassDoc>::Element *match = EditorHelp::get_doc_data()->class_list.find("@GlobalScope");
-
- ERR_EXPLAIN("Could not find `@GlobalScope` in DocData");
- ERR_FAIL_COND_V(!match, ERR_BUG);
-
- const DocData::ClassDoc &global_scope_doc = match->value();
-
- for (int i = 0; i < global_constants_count; i++) {
- const DocData::ConstantDoc &const_doc = global_scope_doc.constants[i];
-
- if (i > 0)
- constants_source += MEMBER_BEGIN;
-
- if (const_doc.description.size()) {
- constants_source += "/// <summary>\n";
-
- Vector<String> description_lines = const_doc.description.split("\n");
-
- for (int i = 0; i < description_lines.size(); i++) {
- if (description_lines[i].size()) {
- constants_source += INDENT2 "/// ";
- constants_source += description_lines[i].strip_edges().xml_escape();
- constants_source += "\n";
- }
- }
-
- constants_source += INDENT2 "/// </summary>" MEMBER_BEGIN;
- }
-
- constants_source += "public const int ";
- constants_source += GlobalConstants::get_global_constant_name(i);
- constants_source += " = ";
- constants_source += itos(GlobalConstants::get_global_constant_value(i));
- constants_source += ";";
- }
- }
-
// Generate sources from compressed files
Map<String, CompressedFile> compressed_files;
@@ -372,19 +492,6 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
data.resize(file_data.uncompressed_size);
Compression::decompress(data.ptrw(), file_data.uncompressed_size, file_data.data, file_data.compressed_size, Compression::MODE_DEFLATE);
- if (file_name.get_basename() == BINDINGS_GLOBAL_SCOPE_CLASS) {
- // GD.cs must be formatted to include the generated global constants
- String data_str = String::utf8(reinterpret_cast<const char *>(data.ptr()), data.size());
-
- Dictionary format_keys;
- format_keys["GodotGlobalConstants"] = constants_source;
- data_str = data_str.format(format_keys, "/*{_}*/");
-
- CharString data_utf8 = data_str.utf8();
- data.resize(data_utf8.length());
- copymem(data.ptrw(), reinterpret_cast<const uint8_t *>(data_utf8.get_data()), data_utf8.length());
- }
-
FileAccessRef file = FileAccess::open(output_file, FileAccess::WRITE);
ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
file->store_buffer(data.ptr(), data.size());
@@ -470,7 +577,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir,
if (!solution.set_path(p_output_dir))
return ERR_FILE_NOT_FOUND;
- for (Map<String, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
+ for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
const TypeInterface &itype = E->get();
if (itype.api_type != ClassDB::API_EDITOR)
@@ -543,7 +650,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir,
// e.g.: warning CS0108: 'SpriteBase3D.FLAG_MAX' hides inherited member 'GeometryInstance.FLAG_MAX'. Use the new keyword if hiding was intended.
Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const String &p_output_file) {
- bool is_derived_type = itype.base_name.length();
+ bool is_derived_type = itype.base_name != StringName();
List<InternalCall> &custom_icalls = itype.api_type == ClassDB::API_EDITOR ? editor_custom_icalls : core_custom_icalls;
@@ -569,9 +676,10 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
Vector<String> description_lines = class_doc->description.split("\n");
for (int i = 0; i < description_lines.size(); i++) {
- if (description_lines[i].size()) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
output.push_back(INDENT1 "/// ");
- output.push_back(description_lines[i].strip_edges().xml_escape());
+ output.push_back(description_line.xml_escape());
output.push_back("\n");
}
}
@@ -592,7 +700,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.push_back(obj_types[itype.base_name].proxy_name);
output.push_back("\n");
} else {
- ERR_PRINTS("Base type '" + itype.base_name + "' does not exist, for class " + itype.name);
+ ERR_PRINTS("Base type '" + itype.base_name.operator String() + "' does not exist, for class " + itype.name);
return ERR_INVALID_DATA;
}
@@ -602,18 +710,19 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
// Add constants
- for (int i = 0; i < class_doc->constants.size(); i++) {
- const DocData::ConstantDoc &const_doc = class_doc->constants[i];
+ for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) {
+ const ConstantInterface &iconstant = E->get();
- if (const_doc.description.size()) {
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
output.push_back(MEMBER_BEGIN "/// <summary>\n");
- Vector<String> description_lines = const_doc.description.split("\n");
+ Vector<String> description_lines = iconstant.const_doc->description.split("\n");
for (int i = 0; i < description_lines.size(); i++) {
- if (description_lines[i].size()) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
output.push_back(INDENT2 "/// ");
- output.push_back(description_lines[i].strip_edges().xml_escape());
+ output.push_back(description_line.xml_escape());
output.push_back("\n");
}
}
@@ -622,24 +731,84 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
output.push_back(MEMBER_BEGIN "public const int ");
- output.push_back(const_doc.name);
+ output.push_back(iconstant.name);
output.push_back(" = ");
- output.push_back(const_doc.value);
+ output.push_back(itos(iconstant.value));
output.push_back(";");
}
- if (class_doc->constants.size())
+ if (itype.constants.size())
output.push_back("\n");
- // Add properties
+ // Add enums
+
+ for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) {
+ const EnumInterface &ienum = E->get();
+
+ ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG);
+
+ output.push_back(MEMBER_BEGIN "public enum ");
+ output.push_back(ienum.cname.operator String());
+ output.push_back(MEMBER_BEGIN OPEN_BLOCK);
+
+ for (const List<ConstantInterface>::Element *E = ienum.constants.front(); E; E = E->next()) {
+ const ConstantInterface &iconstant = E->get();
+
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
+ output.push_back(INDENT3 "/// <summary>\n");
+
+ Vector<String> description_lines = iconstant.const_doc->description.split("\n");
+
+ for (int i = 0; i < description_lines.size(); i++) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
+ output.push_back(INDENT3 "/// ");
+ output.push_back(description_line.xml_escape());
+ output.push_back("\n");
+ }
+ }
+
+ output.push_back(INDENT3 "/// </summary>\n");
+ }
+
+ String constant_name = iconstant.name;
+
+ if (!ienum.prefix.empty() && constant_name.begins_with(ienum.prefix)) {
+ constant_name = constant_name.substr(ienum.prefix.length(), constant_name.length());
+ }
+
+ if (constant_name[0] >= '0' && constant_name[0] <= '9') {
+ // The name of enum constants may begin with a numeric digit when strip from the enum prefix,
+ // so we make the prefix one word shorter in those cases.
+ int i = 0;
+ for (i = ienum.prefix.length() - 1; i >= 0; i--) {
+ if (ienum.prefix[i] >= 'A' && ienum.prefix[i] <= 'Z')
+ break;
+ }
+ constant_name = ienum.prefix.substr(i, ienum.prefix.length()) + constant_name;
+ }
+
+ output.push_back(INDENT3);
+ output.push_back(constant_name);
+ output.push_back(" = ");
+ output.push_back(itos(iconstant.value));
+ output.push_back(E != ienum.constants.back() ? ",\n" : "\n");
+ }
+
+ output.push_back(INDENT2 CLOSE_BLOCK);
+ }
+
+ if (itype.enums.size())
+ output.push_back("\n");
- const Vector<DocData::PropertyDoc> &properties = class_doc->properties;
+ // Add properties
- for (int i = 0; i < properties.size(); i++) {
- const DocData::PropertyDoc &prop_doc = properties[i];
- Error prop_err = _generate_cs_property(itype, prop_doc, output);
+ for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) {
+ const PropertyInterface &iprop = E->get();
+ Error prop_err = _generate_cs_property(itype, iprop, output);
if (prop_err != OK) {
- ERR_EXPLAIN("Failed to generate property '" + prop_doc.name + "' for class '" + itype.name + "'");
+ ERR_EXPLAIN("Failed to generate property '" + iprop.cname.operator String() +
+ "' for class '" + itype.name + "'");
ERR_FAIL_V(prop_err);
}
}
@@ -766,14 +935,14 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
" = IntPtr.Zero;\n" CLOSE_BLOCK_L4 CLOSE_BLOCK_L3 INDENT3
"GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2);
- Map<String, TypeInterface>::Element *array_itype = builtin_types.find("Array");
+ Map<StringName, TypeInterface>::Element *array_itype = builtin_types.find(name_cache.type_Array);
if (!array_itype) {
ERR_PRINT("BUG: Array type interface not found!");
return ERR_BUG;
}
- Map<String, TypeInterface>::Element *object_itype = obj_types.find("Object");
+ Map<StringName, TypeInterface>::Element *object_itype = obj_types.find("Object");
if (!object_itype) {
ERR_PRINT("BUG: Object type interface not found!");
@@ -787,7 +956,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
}
- Map<String, String>::Element *extra_member = extra_members.find(itype.name);
+ Map<StringName, String>::Element *extra_member = extra_members.find(itype.cname);
if (extra_member)
output.push_back(extra_member->get());
@@ -820,43 +989,39 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
return _save_file(p_output_file, output);
}
-Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInterface &p_itype, const DocData::PropertyDoc &p_prop_doc, List<String> &p_output) {
+Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInterface &p_itype, const PropertyInterface &p_iprop, List<String> &p_output) {
- const MethodInterface *setter = p_itype.find_method_by_name(p_prop_doc.setter);
+ const MethodInterface *setter = p_itype.find_method_by_name(p_iprop.setter);
// Search it in base types too
const TypeInterface *current_type = &p_itype;
- while (!setter && current_type->base_name.length()) {
- Map<String, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
+ while (!setter && current_type->base_name != StringName()) {
+ Map<StringName, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
ERR_FAIL_NULL_V(base_match, ERR_BUG);
current_type = &base_match->get();
- setter = current_type->find_method_by_name(p_prop_doc.setter);
+ setter = current_type->find_method_by_name(p_iprop.setter);
}
- const MethodInterface *getter = p_itype.find_method_by_name(p_prop_doc.getter);
+ const MethodInterface *getter = p_itype.find_method_by_name(p_iprop.getter);
// Search it in base types too
current_type = &p_itype;
- while (!getter && current_type->base_name.length()) {
- Map<String, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
+ while (!getter && current_type->base_name != StringName()) {
+ Map<StringName, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
ERR_FAIL_NULL_V(base_match, ERR_BUG);
current_type = &base_match->get();
- getter = current_type->find_method_by_name(p_prop_doc.getter);
+ getter = current_type->find_method_by_name(p_iprop.getter);
}
ERR_FAIL_COND_V(!setter && !getter, ERR_BUG);
- bool is_valid = false;
- int prop_index = ClassDB::get_property_index(p_itype.name, p_prop_doc.name, &is_valid);
- ERR_FAIL_COND_V(!is_valid, ERR_BUG);
-
if (setter) {
- int setter_argc = prop_index != -1 ? 2 : 1;
+ int setter_argc = p_iprop.index != -1 ? 2 : 1;
ERR_FAIL_COND_V(setter->arguments.size() != setter_argc, ERR_BUG);
}
if (getter) {
- int getter_argc = prop_index != -1 ? 1 : 0;
+ int getter_argc = p_iprop.index != -1 ? 1 : 0;
ERR_FAIL_COND_V(getter->arguments.size() != getter_argc, ERR_BUG);
}
@@ -864,18 +1029,12 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
ERR_FAIL_COND_V(getter->return_type != setter->arguments.back()->get().type, ERR_BUG);
}
- // Let's not trust PropertyDoc::type
- String proptype_name = getter ? getter->return_type : setter->arguments.back()->get().type;
+ StringName proptype_name = getter ? getter->return_type : setter->arguments.back()->get().type;
const TypeInterface *prop_itype = _get_type_by_name_or_null(proptype_name);
- if (!prop_itype) {
- // Try with underscore prefix
- prop_itype = _get_type_by_name_or_null("_" + proptype_name);
- }
+ ERR_FAIL_NULL_V(prop_itype, ERR_BUG); // Property type not found
- ERR_FAIL_NULL_V(prop_itype, ERR_BUG);
-
- String prop_proxy_name = escape_csharp_keyword(snake_to_pascal_case(p_prop_doc.name));
+ String prop_proxy_name = escape_csharp_keyword(snake_to_pascal_case(p_iprop.cname));
// Prevent property and enclosing type from sharing the same name
if (prop_proxy_name == p_itype.proxy_name) {
@@ -887,15 +1046,16 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
prop_proxy_name += "_";
}
- if (p_prop_doc.description.size()) {
+ if (p_iprop.prop_doc && p_iprop.prop_doc->description.size()) {
p_output.push_back(MEMBER_BEGIN "/// <summary>\n");
- Vector<String> description_lines = p_prop_doc.description.split("\n");
+ Vector<String> description_lines = p_iprop.prop_doc->description.split("\n");
for (int i = 0; i < description_lines.size(); i++) {
- if (description_lines[i].size()) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
p_output.push_back(INDENT2 "/// ");
- p_output.push_back(description_lines[i].strip_edges().xml_escape());
+ p_output.push_back(description_line.xml_escape());
p_output.push_back("\n");
}
}
@@ -917,16 +1077,34 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.push_back(INDENT3 "get\n" OPEN_BLOCK_L3);
p_output.push_back("return ");
p_output.push_back(getter->proxy_name + "(");
- if (prop_index != -1)
- p_output.push_back(itos(prop_index));
+ if (p_iprop.index != -1) {
+ const ArgumentInterface &idx_arg = getter->arguments.front()->get();
+ if (idx_arg.type != name_cache.type_int) {
+ // Assume the index parameter is an enum
+ const TypeInterface *idx_arg_type = _get_type_by_name_or_null(idx_arg.type);
+ CRASH_COND(idx_arg_type == NULL);
+ p_output.push_back("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index));
+ } else {
+ p_output.push_back(itos(p_iprop.index));
+ }
+ }
p_output.push_back(");\n" CLOSE_BLOCK_L3);
}
if (setter) {
p_output.push_back(INDENT3 "set\n" OPEN_BLOCK_L3);
p_output.push_back(setter->proxy_name + "(");
- if (prop_index != -1)
- p_output.push_back(itos(prop_index) + ", ");
+ if (p_iprop.index != -1) {
+ const ArgumentInterface &idx_arg = setter->arguments.front()->get();
+ if (idx_arg.type != name_cache.type_int) {
+ // Assume the index parameter is an enum
+ const TypeInterface *idx_arg_type = _get_type_by_name_or_null(idx_arg.type);
+ CRASH_COND(idx_arg_type == NULL);
+ p_output.push_back("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index) + ", ");
+ } else {
+ p_output.push_back(itos(p_iprop.index) + ", ");
+ }
+ }
p_output.push_back("value);\n" CLOSE_BLOCK_L3);
}
@@ -1033,9 +1211,10 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
Vector<String> description_lines = p_imethod.method_doc->description.split("\n");
for (int i = 0; i < description_lines.size(); i++) {
- if (description_lines[i].size()) {
+ String description_line = description_lines[i].strip_edges();
+ if (description_line.size()) {
p_output.push_back(INDENT2 "/// ");
- p_output.push_back(description_lines[i].strip_edges().xml_escape());
+ p_output.push_back(description_line.xml_escape());
p_output.push_back("\n");
}
}
@@ -1069,7 +1248,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
if (p_imethod.is_virtual) {
// Godot virtual method must be overridden, therefore we return a default value by default.
- if (return_type->name == "void") {
+ if (return_type->cname == name_cache.type_void) {
p_output.push_back("return;\n" CLOSE_BLOCK_L2);
} else {
p_output.push_back("return default(");
@@ -1108,7 +1287,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
if (p_imethod.arguments.size())
p_output.push_back(cs_in_statements);
- if (return_type->name == "void") {
+ if (return_type->cname == name_cache.type_void) {
p_output.push_back(im_call);
} else if (return_type->cs_out.empty()) {
p_output.push_back("return " + im_call);
@@ -1142,7 +1321,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
generated_icall_funcs.clear();
- for (Map<String, TypeInterface>::Element *type_elem = obj_types.front(); type_elem; type_elem = type_elem->next()) {
+ for (Map<StringName, TypeInterface>::Element *type_elem = obj_types.front(); type_elem; type_elem = type_elem->next()) {
const TypeInterface &itype = type_elem->get();
List<InternalCall> &custom_icalls = itype.api_type == ClassDB::API_EDITOR ? editor_custom_icalls : core_custom_icalls;
@@ -1295,7 +1474,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
if (p_imethod.is_virtual)
return OK; // Ignore
- bool ret_void = p_imethod.return_type == "void";
+ bool ret_void = p_imethod.return_type == name_cache.type_void;
const TypeInterface *return_type = _get_type_by_name_or_placeholder(p_imethod.return_type);
@@ -1447,14 +1626,19 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
return OK;
}
-const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_null(const String &p_name) {
+const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_null(const StringName &p_cname) {
+
+ const Map<StringName, TypeInterface>::Element *match = builtin_types.find(p_cname);
- const Map<String, TypeInterface>::Element *match = builtin_types.find(p_name);
+ if (match)
+ return &match->get();
+
+ match = obj_types.find(p_cname);
if (match)
return &match->get();
- match = obj_types.find(p_name);
+ match = enum_types.find(p_cname);
if (match)
return &match->get();
@@ -1462,24 +1646,27 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_
return NULL;
}
-const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_placeholder(const String &p_name) {
+const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_placeholder(const StringName &p_cname) {
- const TypeInterface *found = _get_type_by_name_or_null(p_name);
+ const TypeInterface *found = _get_type_by_name_or_null(p_cname);
if (found)
return found;
- ERR_PRINTS(String() + "Type not found. Creating placeholder: " + p_name);
+ ERR_PRINTS(String() + "Type not found. Creating placeholder: " + p_cname.operator String());
- const Map<String, TypeInterface>::Element *match = placeholder_types.find(p_name);
+ const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_cname);
if (match)
return &match->get();
TypeInterface placeholder;
- TypeInterface::create_placeholder_type(placeholder, p_name);
+ TypeInterface::create_placeholder_type(placeholder, p_cname);
- return &placeholder_types.insert(placeholder.name, placeholder)->get();
+ return &placeholder_types.insert(placeholder.cname, placeholder)->get();
+}
+
+static void _create_constant_interface_from(const StringName &p_constant, const DocData::ClassDoc &p_classdoc) {
}
void BindingsGenerator::_populate_object_type_interfaces() {
@@ -1490,8 +1677,6 @@ void BindingsGenerator::_populate_object_type_interfaces() {
ClassDB::get_class_list(&class_list);
class_list.sort_custom<StringName::AlphCompare>();
- StringName refclass_name = String("Reference");
-
while (class_list.size()) {
StringName type_cname = class_list.front()->get();
@@ -1502,21 +1687,23 @@ void BindingsGenerator::_populate_object_type_interfaces() {
continue;
}
+ if (!ClassDB::is_class_exposed(type_cname)) {
+ if (verbose_output)
+ WARN_PRINTS("Ignoring type " + type_cname.operator String() + " because it's not exposed");
+ class_list.pop_front();
+ continue;
+ }
+
+ ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(type_cname);
+
TypeInterface itype = TypeInterface::create_object_type(type_cname, api_type);
itype.base_name = ClassDB::get_parent_class(type_cname);
itype.is_singleton = Engine::get_singleton()->has_singleton(itype.proxy_name);
itype.is_instantiable = ClassDB::can_instance(type_cname) && !itype.is_singleton;
- itype.is_reference = ClassDB::is_parent_class(type_cname, refclass_name);
+ itype.is_reference = ClassDB::is_parent_class(type_cname, name_cache.type_Reference);
itype.memory_own = itype.is_reference;
- if (!ClassDB::is_class_exposed(type_cname)) {
- if (verbose_output)
- WARN_PRINTS("Ignoring type " + String(type_cname) + " because it's not exposed");
- class_list.pop_front();
- continue;
- }
-
itype.c_out = "\treturn ";
itype.c_out += C_METHOD_UNMANAGED_GET_MANAGED;
itype.c_out += itype.is_reference ? "(%1.ptr());\n" : "(%1);\n";
@@ -1530,6 +1717,8 @@ void BindingsGenerator::_populate_object_type_interfaces() {
itype.im_type_in = "IntPtr";
itype.im_type_out = itype.proxy_name;
+ // Populate methods
+
List<MethodInfo> virtual_method_list;
ClassDB::get_virtual_methods(type_cname, &virtual_method_list, true);
@@ -1547,6 +1736,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
MethodInterface imethod;
imethod.name = method_info.name;
+ imethod.cname = imethod.name;
if (method_info.flags & METHOD_FLAG_VIRTUAL)
imethod.is_virtual = true;
@@ -1570,12 +1760,12 @@ void BindingsGenerator::_populate_object_type_interfaces() {
// The method Object.free is registered as a virtual method, but without the virtual flag.
// This is because this method is not supposed to be overridden, but called.
// We assume the return type is void.
- imethod.return_type = "void";
+ imethod.return_type = name_cache.type_void;
// Actually, more methods like this may be added in the future,
// which could actually will return something differnet.
// Let's put this to notify us if that ever happens.
- if (itype.name != "Object" || imethod.name != "free") {
+ if (itype.cname != name_cache.type_Object || imethod.name != "free") {
if (verbose_output) {
WARN_PRINTS("Notification: New unexpected virtual non-overridable method found.\n"
"We only expected Object.free, but found " +
@@ -1585,22 +1775,21 @@ void BindingsGenerator::_populate_object_type_interfaces() {
} else {
ERR_PRINTS("Missing MethodBind for non-virtual method: " + itype.name + "." + imethod.name);
}
- } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
- //imethod.return_type = return_info.class_name;
- imethod.return_type = "int";
+ } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { // TODO redundant?
+ imethod.return_type = return_info.class_name;
} else if (return_info.class_name != StringName()) {
imethod.return_type = return_info.class_name;
} else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
imethod.return_type = return_info.hint_string;
} else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
- imethod.return_type = "Variant";
+ imethod.return_type = name_cache.type_Variant;
} else if (return_info.type == Variant::NIL) {
- imethod.return_type = "void";
+ imethod.return_type = name_cache.type_void;
} else {
imethod.return_type = Variant::get_type_name(return_info.type);
}
- if (!itype.requires_collections && imethod.return_type == "Dictionary")
+ if (!itype.requires_collections && imethod.return_type == name_cache.type_Dictionary)
itype.requires_collections = true;
for (int i = 0; i < argc; i++) {
@@ -1609,22 +1798,21 @@ void BindingsGenerator::_populate_object_type_interfaces() {
ArgumentInterface iarg;
iarg.name = arginfo.name;
- if (arginfo.type == Variant::INT && arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
- //iarg.type = arginfo.class_name;
- iarg.type = "int";
+ if (arginfo.type == Variant::INT && arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { // TODO redundant?
+ iarg.type = arginfo.class_name;
} else if (arginfo.class_name != StringName()) {
iarg.type = arginfo.class_name;
} else if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
iarg.type = arginfo.hint_string;
} else if (arginfo.type == Variant::NIL) {
- iarg.type = "Variant";
+ iarg.type = name_cache.type_Variant;
} else {
iarg.type = Variant::get_type_name(arginfo.type);
}
iarg.name = escape_csharp_keyword(snake_to_camel_case(iarg.name));
- if (!itype.requires_collections && iarg.type == "Dictionary")
+ if (!itype.requires_collections && iarg.type == name_cache.type_Dictionary)
itype.requires_collections = true;
if (m && m->has_default_argument(i)) {
@@ -1636,7 +1824,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
if (imethod.is_vararg) {
ArgumentInterface ivararg;
- ivararg.type = "VarArg";
+ ivararg.type = name_cache.type_VarArg;
ivararg.name = "@args";
imethod.add_argument(ivararg);
}
@@ -1679,7 +1867,128 @@ void BindingsGenerator::_populate_object_type_interfaces() {
}
}
- obj_types.insert(itype.name, itype);
+ // Populate properties
+
+ List<PropertyInfo> property_list;
+ ClassDB::get_property_list(type_cname, &property_list, true);
+ for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
+ const PropertyInfo &property = E->get();
+
+ if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_CATEGORY)
+ continue;
+
+ PropertyInterface iprop;
+ iprop.cname = property.name;
+ iprop.proxy_name = escape_csharp_keyword(snake_to_pascal_case(iprop.cname));
+ iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname);
+ iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname);
+
+ bool valid = false;
+ iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid);
+ ERR_FAIL_COND(!valid);
+
+ // Prevent property and enclosing type from sharing the same name
+ if (iprop.proxy_name == itype.proxy_name) {
+ if (verbose_output) {
+ WARN_PRINTS("Name of property `" + iprop.proxy_name + "` is ambiguous with the name of its class `" +
+ itype.proxy_name + "`. Renaming property to `" + iprop.proxy_name + "_`");
+ }
+
+ iprop.proxy_name += "_";
+ }
+
+ iprop.prop_doc = NULL;
+
+ for (int i = 0; i < itype.class_doc->properties.size(); i++) {
+ const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i];
+
+ if (prop_doc.name == iprop.cname) {
+ iprop.prop_doc = &prop_doc;
+ break;
+ }
+ }
+
+ itype.properties.push_back(iprop);
+ }
+
+ // Populate enums and constants
+
+ List<String> constant_list;
+ ClassDB::get_integer_constant_list(type_cname, &constant_list, true);
+
+ const HashMap<StringName, List<StringName> > &enum_map = class_info->enum_map;
+ const StringName *k = NULL;
+
+ while ((k = enum_map.next(k))) {
+ StringName enum_proxy_cname = *k;
+ String enum_proxy_name = enum_proxy_cname.operator String();
+ if (itype.find_property_by_proxy_name(enum_proxy_cname)) {
+ // We have several conflicts between enums and PascalCase properties,
+ // so we append 'Enum' to the enum name in those cases.
+ enum_proxy_name += "Enum";
+ enum_proxy_cname = StringName(enum_proxy_name);
+ }
+ EnumInterface ienum(enum_proxy_cname);
+ const List<StringName> &constants = enum_map.get(*k);
+ for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ int *value = class_info->constant_map.getptr(E->get());
+ ERR_FAIL_NULL(value);
+ constant_list.erase(E->get().operator String());
+
+ ConstantInterface iconstant(snake_to_pascal_case(E->get(), true), *value);
+
+ iconstant.const_doc = NULL;
+ for (int i = 0; i < itype.class_doc->constants.size(); i++) {
+ const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i];
+
+ if (const_doc.name == iconstant.name) {
+ iconstant.const_doc = &const_doc;
+ break;
+ }
+ }
+
+ ienum.constants.push_back(iconstant);
+ }
+
+ ienum.prefix = _determine_enum_prefix(ienum);
+
+ itype.enums.push_back(ienum);
+
+ TypeInterface enum_itype;
+ enum_itype.name = itype.name + "." + String(*k);
+ enum_itype.cname = StringName(enum_itype.name);
+ enum_itype.proxy_name = itype.proxy_name + "." + enum_proxy_name;
+ enum_itype.c_arg_in = "&%s";
+ enum_itype.c_type = "int";
+ enum_itype.c_type_in = "int";
+ enum_itype.c_type_out = "int";
+ enum_itype.cs_type = enum_itype.proxy_name;
+ enum_itype.im_type_in = enum_itype.proxy_name;
+ enum_itype.im_type_out = enum_itype.proxy_name;
+ enum_itype.class_doc = &EditorHelp::get_doc_data()->class_list[enum_itype.proxy_name];
+ enum_types.insert(enum_itype.cname, enum_itype);
+ }
+
+ for (const List<String>::Element *E = constant_list.front(); E; E = E->next()) {
+ int *value = class_info->constant_map.getptr(E->get());
+ ERR_FAIL_NULL(value);
+
+ ConstantInterface iconstant(snake_to_pascal_case(E->get(), true), *value);
+
+ iconstant.const_doc = NULL;
+ for (int i = 0; i < itype.class_doc->constants.size(); i++) {
+ const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i];
+
+ if (const_doc.name == iconstant.name) {
+ iconstant.const_doc = &const_doc;
+ break;
+ }
+ }
+
+ itype.constants.push_back(iconstant);
+ }
+
+ obj_types.insert(itype.cname, itype);
class_list.pop_front();
}
@@ -1704,7 +2013,10 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
r_iarg.default_argument = bool(p_val) ? "true" : "false";
break;
case Variant::INT:
- break; // Keep it
+ if (r_iarg.type != name_cache.type_int) {
+ r_iarg.default_argument = "(%s)" + r_iarg.default_argument;
+ }
+ break;
case Variant::REAL:
#ifndef REAL_T_IS_DOUBLE
r_iarg.default_argument += "f";
@@ -1762,7 +2074,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
default: {}
}
- if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type == "Variant" && r_iarg.default_argument != "null")
+ if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type == name_cache.type_Variant && r_iarg.default_argument != "null")
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
}
@@ -1774,7 +2086,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
#define INSERT_STRUCT_TYPE(m_type, m_type_in) \
{ \
- itype = TypeInterface::create_value_type(#m_type); \
+ itype = TypeInterface::create_value_type(String(#m_type)); \
itype.c_in = "\tMARSHALLED_IN(" #m_type ", %1, %1_in);\n"; \
itype.c_out = "\tMARSHALLED_OUT(" #m_type ", %1, ret_out)\n" \
"\treturn mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(%2), ret_out);\n"; \
@@ -1783,7 +2095,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_in = "ref %s"; \
itype.cs_out = "return (" #m_type ")%0;"; \
itype.im_type_out = "object"; \
- builtin_types.insert(#m_type, itype); \
+ builtin_types.insert(itype.cname, itype); \
}
INSERT_STRUCT_TYPE(Vector2, "real_t*")
@@ -1799,22 +2111,22 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
#undef INSERT_STRUCT_TYPE
-#define INSERT_PRIMITIVE_TYPE(m_type) \
- { \
- itype = TypeInterface::create_value_type(#m_type); \
- itype.c_arg_in = "&%s"; \
- itype.c_type_in = #m_type; \
- itype.c_type_out = #m_type; \
- itype.im_type_in = #m_type; \
- itype.im_type_out = #m_type; \
- builtin_types.insert(#m_type, itype); \
+#define INSERT_PRIMITIVE_TYPE(m_type) \
+ { \
+ itype = TypeInterface::create_value_type(String(#m_type)); \
+ itype.c_arg_in = "&%s"; \
+ itype.c_type_in = #m_type; \
+ itype.c_type_out = #m_type; \
+ itype.im_type_in = #m_type; \
+ itype.im_type_out = #m_type; \
+ builtin_types.insert(itype.cname, itype); \
}
INSERT_PRIMITIVE_TYPE(bool)
//INSERT_PRIMITIVE_TYPE(int)
// int
- itype = TypeInterface::create_value_type("int");
+ itype = TypeInterface::create_value_type(String("int"));
itype.c_arg_in = "&%s_in";
//* ptrcall only supports int64_t and uint64_t
itype.c_in = "\t%0 %1_in = (%0)%1;\n";
@@ -1825,7 +2137,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.c_type_out = itype.name;
itype.im_type_in = itype.name;
itype.im_type_out = itype.name;
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
#undef INSERT_PRIMITIVE_TYPE
@@ -1836,6 +2148,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
#else
itype.name = "float";
#endif
+ itype.cname = itype.name;
itype.proxy_name = itype.name;
itype.c_arg_in = "&%s_in";
//* ptrcall only supports double
@@ -1848,11 +2161,12 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_type = itype.proxy_name;
itype.im_type_in = itype.proxy_name;
itype.im_type_out = itype.proxy_name;
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
// String
itype = TypeInterface();
itype.name = "String";
+ itype.cname = itype.name;
itype.proxy_name = "string";
itype.c_in = "\t%0 %1_in = " C_METHOD_MONOSTR_TO_GODOT "(%1);\n";
itype.c_out = "\treturn " C_METHOD_MONOSTR_FROM_GODOT "(%1);\n";
@@ -1863,11 +2177,12 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_type = itype.proxy_name;
itype.im_type_in = itype.proxy_name;
itype.im_type_out = itype.proxy_name;
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
// NodePath
itype = TypeInterface();
itype.name = "NodePath";
+ itype.cname = itype.name;
itype.proxy_name = "NodePath";
itype.c_out = "\treturn memnew(NodePath(%1));\n";
itype.c_type = itype.name;
@@ -1879,16 +2194,17 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
_populate_builtin_type(itype, Variant::NODE_PATH);
- extra_members.insert(itype.name, MEMBER_BEGIN "public NodePath() : this(string.Empty) {}\n" MEMBER_BEGIN "public NodePath(string path)\n" OPEN_BLOCK_L2
- "this." BINDINGS_PTR_FIELD " = NativeCalls.godot_icall_NodePath_Ctor(path);\n" CLOSE_BLOCK_L2
- MEMBER_BEGIN "public static implicit operator NodePath(string from)\n" OPEN_BLOCK_L2 "return new NodePath(from);\n" CLOSE_BLOCK_L2
- MEMBER_BEGIN "public static implicit operator string(NodePath from)\n" OPEN_BLOCK_L2
- "return NativeCalls." ICALL_PREFIX "NodePath_operator_String(NodePath." CS_SMETHOD_GETINSTANCE "(from));\n" CLOSE_BLOCK_L2);
- builtin_types.insert(itype.name, itype);
+ extra_members.insert(itype.cname, MEMBER_BEGIN "public NodePath() : this(string.Empty) {}\n" MEMBER_BEGIN "public NodePath(string path)\n" OPEN_BLOCK_L2
+ "this." BINDINGS_PTR_FIELD " = NativeCalls.godot_icall_NodePath_Ctor(path);\n" CLOSE_BLOCK_L2
+ MEMBER_BEGIN "public static implicit operator NodePath(string from)\n" OPEN_BLOCK_L2 "return new NodePath(from);\n" CLOSE_BLOCK_L2
+ MEMBER_BEGIN "public static implicit operator string(NodePath from)\n" OPEN_BLOCK_L2
+ "return NativeCalls." ICALL_PREFIX "NodePath_operator_String(NodePath." CS_SMETHOD_GETINSTANCE "(from));\n" CLOSE_BLOCK_L2);
+ builtin_types.insert(itype.cname, itype);
// RID
itype = TypeInterface();
itype.name = "RID";
+ itype.cname = itype.name;
itype.proxy_name = "RID";
itype.c_out = "\treturn memnew(RID(%1));\n";
itype.c_type = itype.name;
@@ -1900,13 +2216,14 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
_populate_builtin_type(itype, Variant::_RID);
- extra_members.insert(itype.name, MEMBER_BEGIN "internal RID()\n" OPEN_BLOCK_L2
- "this." BINDINGS_PTR_FIELD " = IntPtr.Zero;\n" CLOSE_BLOCK_L2);
- builtin_types.insert(itype.name, itype);
+ extra_members.insert(itype.cname, MEMBER_BEGIN "internal RID()\n" OPEN_BLOCK_L2
+ "this." BINDINGS_PTR_FIELD " = IntPtr.Zero;\n" CLOSE_BLOCK_L2);
+ builtin_types.insert(itype.cname, itype);
// Variant
itype = TypeInterface();
itype.name = "Variant";
+ itype.cname = itype.name;
itype.proxy_name = "object";
itype.c_in = "\t%0 %1_in = " C_METHOD_MANAGED_TO_VARIANT "(%1);\n";
itype.c_out = "\treturn " C_METHOD_MANAGED_FROM_VARIANT "(%1);\n";
@@ -1917,11 +2234,12 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_type = itype.proxy_name;
itype.im_type_in = "object";
itype.im_type_out = itype.proxy_name;
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
// VarArg (fictitious type to represent variable arguments)
itype = TypeInterface();
itype.name = "VarArg";
+ itype.cname = itype.name;
itype.proxy_name = "object[]";
itype.c_in = "\t%0 %1_in = " C_METHOD_MONOARRAY_TO(Array) "(%1);\n";
itype.c_arg_in = "&%s_in";
@@ -1929,12 +2247,13 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.c_type_in = "MonoArray*";
itype.cs_type = "params object[]";
itype.im_type_in = "object[]";
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
#define INSERT_ARRAY_FULL(m_name, m_type, m_proxy_t) \
{ \
itype = TypeInterface(); \
itype.name = #m_name; \
+ itype.cname = itype.name; \
itype.proxy_name = #m_proxy_t "[]"; \
itype.c_in = "\t%0 %1_in = " C_METHOD_MONOARRAY_TO(m_type) "(%1);\n"; \
itype.c_out = "\treturn " C_METHOD_MONOARRAY_FROM(m_type) "(%1);\n"; \
@@ -1971,6 +2290,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
// Dictionary
itype = TypeInterface();
itype.name = "Dictionary";
+ itype.cname = itype.name;
itype.proxy_name = "Dictionary<object, object>";
itype.c_in = "\t%0 %1_in = " C_METHOD_MANAGED_TO_DICT "(%1);\n";
itype.c_out = "\treturn " C_METHOD_MANAGED_FROM_DICT "(%1);\n";
@@ -1981,11 +2301,12 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_type = itype.proxy_name;
itype.im_type_in = itype.proxy_name;
itype.im_type_out = itype.proxy_name;
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
// void (fictitious type to represent the return type of methods that do not return anything)
itype = TypeInterface();
itype.name = "void";
+ itype.cname = itype.name;
itype.proxy_name = itype.name;
itype.c_type = itype.name;
itype.c_type_in = itype.c_type;
@@ -1993,21 +2314,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cs_type = itype.proxy_name;
itype.im_type_in = itype.proxy_name;
itype.im_type_out = itype.proxy_name;
- builtin_types.insert(itype.name, itype);
-
- // Error
- itype = TypeInterface();
- itype.name = "Error";
- itype.proxy_name = "Error";
- itype.c_type = itype.name;
- itype.c_type_in = itype.c_type;
- itype.c_type_out = itype.c_type;
- itype.cs_type = itype.proxy_name;
- itype.cs_in = "(int)%0";
- itype.cs_out = "return (Error)%s;";
- itype.im_type_in = "int";
- itype.im_type_out = "int";
- builtin_types.insert(itype.name, itype);
+ builtin_types.insert(itype.cname, itype);
}
void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::Type vtype) {
@@ -2024,6 +2331,7 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
MethodInterface imethod;
imethod.name = mi.name;
+ imethod.cname = imethod.name;
imethod.proxy_name = mi.name;
for (int i = 0; i < mi.arguments.size(); i++) {
@@ -2033,11 +2341,11 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
iarg.name = pi.name;
if (pi.type == Variant::NIL)
- iarg.type = "Variant";
+ iarg.type = name_cache.type_Variant;
else
iarg.type = Variant::get_type_name(pi.type);
- if (!r_itype.requires_collections && iarg.type == "Dictionary")
+ if (!r_itype.requires_collections && iarg.type == name_cache.type_Dictionary)
r_itype.requires_collections = true;
if ((mi.default_arguments.size() - mi.arguments.size() + i) >= 0)
@@ -2048,12 +2356,12 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
if (mi.return_val.type == Variant::NIL) {
if (mi.return_val.name != "")
- imethod.return_type = "Variant";
+ imethod.return_type = name_cache.type_Variant;
} else {
imethod.return_type = Variant::get_type_name(mi.return_val.type);
}
- if (!r_itype.requires_collections && imethod.return_type == "Dictionary")
+ if (!r_itype.requires_collections && imethod.return_type == name_cache.type_Dictionary)
r_itype.requires_collections = true;
if (r_itype.class_doc) {
@@ -2069,15 +2377,113 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
}
}
-BindingsGenerator::BindingsGenerator() {
+void BindingsGenerator::_populate_global_constants() {
+
+ int global_constants_count = GlobalConstants::get_global_constant_count();
+
+ if (global_constants_count > 0) {
+ Map<String, DocData::ClassDoc>::Element *match = EditorHelp::get_doc_data()->class_list.find("@GlobalScope");
+
+ ERR_EXPLAIN("Could not find `@GlobalScope` in DocData");
+ CRASH_COND(!match);
+
+ const DocData::ClassDoc &global_scope_doc = match->value();
+
+ for (int i = 0; i < global_constants_count; i++) {
+
+ String constant_name = GlobalConstants::get_global_constant_name(i);
+
+ const DocData::ConstantDoc *const_doc = NULL;
+ for (int i = 0; i < global_scope_doc.constants.size(); i++) {
+ const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[i];
+
+ if (curr_const_doc.name == constant_name) {
+ const_doc = &curr_const_doc;
+ break;
+ }
+ }
+
+ int constant_value = GlobalConstants::get_global_constant_value(i);
+ StringName enum_name = GlobalConstants::get_global_constant_enum(i);
+
+ ConstantInterface iconstant(snake_to_pascal_case(constant_name, true), constant_value);
+ iconstant.const_doc = const_doc;
+
+ if (enum_name != StringName()) {
+ EnumInterface ienum(enum_name);
+ List<EnumInterface>::Element *match = global_enums.find(ienum);
+ if (match) {
+ match->get().constants.push_back(iconstant);
+ } else {
+ ienum.constants.push_back(iconstant);
+ global_enums.push_back(ienum);
+ }
+ } else {
+ global_constants.push_back(iconstant);
+ }
+ }
+
+ for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) {
+ EnumInterface &ienum = E->get();
+
+ TypeInterface enum_itype;
+ enum_itype = TypeInterface::create_value_type(ienum.cname);
+ enum_itype.c_arg_in = "&%s";
+ enum_itype.c_type = "int";
+ enum_itype.c_type_in = "int";
+ enum_itype.c_type_out = "int";
+ enum_itype.im_type_in = enum_itype.name;
+ enum_itype.im_type_out = enum_itype.name;
+ enum_types.insert(enum_itype.cname, enum_itype);
+
+ ienum.prefix = _determine_enum_prefix(ienum);
+
+ // HARDCODED
+ if (ienum.cname == name_cache.enum_Error) {
+ if (!ienum.prefix.empty()) { // Just in case it ever changes
+ ERR_PRINTS("Prefix for enum 'Error' is not empty");
+ }
+
+ ienum.prefix = "Err";
+ }
+ }
+ }
+
+ // HARDCODED
+ List<StringName> hardcoded_enums;
+ hardcoded_enums.push_back("Vector3.Axis");
+ for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) {
+ // These enums are not generated and must be written manually (e.g.: Vector3.Axis)
+ // Here, we are assuming core types do not begin with underscore
+ TypeInterface enum_itype;
+ enum_itype = TypeInterface::create_value_type(E->get());
+ enum_itype.c_arg_in = "&%s";
+ enum_itype.c_type = "int";
+ enum_itype.c_type_in = "int";
+ enum_itype.c_type_out = "int";
+ enum_itype.im_type_in = enum_itype.name;
+ enum_itype.im_type_out = enum_itype.name;
+ enum_types.insert(enum_itype.cname, enum_itype);
+ }
+}
+
+BindingsGenerator::BindingsGenerator() :
+ name_cache(NameCache::get_singleton()) {
EditorHelp::generate_doc();
+ enum_types.clear();
+
_populate_object_type_interfaces();
_populate_builtin_type_interfaces();
+
+ _populate_global_constants();
+
+ // Populate internal calls (after populating type interfaces and global constants)
+
_generate_header_icalls();
- for (Map<String, TypeInterface>::Element *E = obj_types.front(); E; E = E->next())
+ for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next())
_generate_method_icalls(E->get());
_generate_method_icalls(builtin_types["NodePath"]);
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index dfa3aa9911..eac00690ff 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -39,6 +39,47 @@
#include "ustring.h"
class BindingsGenerator {
+
+ struct ConstantInterface {
+ String name;
+ int value;
+ const DocData::ConstantDoc *const_doc;
+
+ ConstantInterface() {}
+
+ ConstantInterface(const String &p_name, int p_value) {
+ name = p_name;
+ value = p_value;
+ }
+ };
+
+ struct EnumInterface {
+ StringName cname;
+ String prefix;
+ List<ConstantInterface> constants;
+
+ _FORCE_INLINE_ bool operator==(const EnumInterface &p_ienum) const {
+ return p_ienum.cname == cname;
+ }
+
+ EnumInterface() {}
+
+ EnumInterface(const StringName &p_cname) {
+ cname = p_cname;
+ }
+ };
+
+ struct PropertyInterface {
+ StringName cname;
+ String proxy_name;
+ int index;
+
+ StringName setter;
+ StringName getter;
+
+ const DocData::PropertyDoc *prop_doc;
+ };
+
struct ArgumentInterface {
enum DefaultParamMode {
CONSTANT,
@@ -46,7 +87,7 @@ class BindingsGenerator {
NULLABLE_REF
};
- String type;
+ StringName type;
String name;
String default_argument;
DefaultParamMode def_param_mode;
@@ -58,6 +99,7 @@ class BindingsGenerator {
struct MethodInterface {
String name;
+ StringName cname;
/**
* Name of the C# method
@@ -67,7 +109,7 @@ class BindingsGenerator {
/**
* [TypeInterface::name] of the return type
*/
- String return_type;
+ StringName return_type;
/**
* Determines if the method has a variable number of arguments (VarArg)
@@ -103,7 +145,7 @@ class BindingsGenerator {
}
MethodInterface() {
- return_type = "void";
+ return_type = NameCache::get_singleton().type_void;
is_vararg = false;
is_virtual = false;
requires_object_call = false;
@@ -118,11 +160,12 @@ class BindingsGenerator {
* Also used to format [c_out].
*/
String name;
+ StringName cname;
/**
* Identifier name of the base class.
*/
- String base_name;
+ StringName base_name;
/**
* Name of the C# class
@@ -256,23 +299,32 @@ class BindingsGenerator {
const DocData::ClassDoc *class_doc;
+ List<ConstantInterface> constants;
+ List<EnumInterface> enums;
+ List<PropertyInterface> properties;
List<MethodInterface> methods;
- const MethodInterface *find_method_by_name(const String &p_name) const {
-
+ const MethodInterface *find_method_by_name(const StringName &p_cname) const {
for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().name == p_name)
+ if (E->get().cname == p_cname)
return &E->get();
}
return NULL;
}
- static TypeInterface create_value_type(const String &p_name) {
- TypeInterface itype;
+ const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const {
+ for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) {
+ if (E->get().proxy_name == p_proxy_name)
+ return &E->get();
+ }
- itype.name = p_name;
- itype.proxy_name = p_name;
+ return NULL;
+ }
+
+ private:
+ static void _init_value_type(TypeInterface &itype) {
+ itype.proxy_name = itype.name;
itype.c_type = itype.name;
itype.c_type_in = "void*";
@@ -281,15 +333,31 @@ class BindingsGenerator {
itype.im_type_in = "ref " + itype.proxy_name;
itype.im_type_out = itype.proxy_name;
itype.class_doc = &EditorHelp::get_doc_data()->class_list[itype.proxy_name];
+ }
+ public:
+ static TypeInterface create_value_type(const String &p_name) {
+ TypeInterface itype;
+ itype.name = p_name;
+ itype.cname = StringName(p_name);
+ _init_value_type(itype);
+ return itype;
+ }
+
+ static TypeInterface create_value_type(const StringName &p_name) {
+ TypeInterface itype;
+ itype.name = p_name.operator String();
+ itype.cname = p_name;
+ _init_value_type(itype);
return itype;
}
- static TypeInterface create_object_type(const String &p_name, ClassDB::APIType p_api_type) {
+ static TypeInterface create_object_type(const StringName &p_cname, ClassDB::APIType p_api_type) {
TypeInterface itype;
- itype.name = p_name;
- itype.proxy_name = p_name.begins_with("_") ? p_name.substr(1, p_name.length()) : p_name;
+ itype.name = p_cname;
+ itype.cname = p_cname;
+ itype.proxy_name = itype.name.begins_with("_") ? itype.name.substr(1, itype.name.length()) : itype.name;
itype.api_type = p_api_type;
itype.is_object_type = true;
itype.class_doc = &EditorHelp::get_doc_data()->class_list[itype.proxy_name];
@@ -297,9 +365,10 @@ class BindingsGenerator {
return itype;
}
- static void create_placeholder_type(TypeInterface &r_itype, const String &p_name) {
- r_itype.name = p_name;
- r_itype.proxy_name = p_name;
+ static void create_placeholder_type(TypeInterface &r_itype, const StringName &p_cname) {
+ r_itype.name = p_cname;
+ r_itype.cname = p_cname;
+ r_itype.proxy_name = r_itype.name;
r_itype.c_type = r_itype.name;
r_itype.c_type_in = "MonoObject*";
@@ -359,11 +428,15 @@ class BindingsGenerator {
static bool verbose_output;
- Map<String, TypeInterface> placeholder_types;
- Map<String, TypeInterface> builtin_types;
- Map<String, TypeInterface> obj_types;
+ Map<StringName, TypeInterface> placeholder_types;
+ Map<StringName, TypeInterface> builtin_types;
+ Map<StringName, TypeInterface> enum_types;
+ Map<StringName, TypeInterface> obj_types;
- Map<String, String> extra_members;
+ List<EnumInterface> global_enums;
+ List<ConstantInterface> global_constants;
+
+ Map<StringName, String> extra_members;
List<InternalCall> method_icalls;
Map<const MethodInterface *, const InternalCall *> method_icalls_map;
@@ -373,8 +446,41 @@ class BindingsGenerator {
List<InternalCall> core_custom_icalls;
List<InternalCall> editor_custom_icalls;
- const List<InternalCall>::Element *find_icall_by_name(const String &p_name, const List<InternalCall> &p_list) {
+ struct NameCache {
+ StringName type_void;
+ StringName type_int;
+ StringName type_Array;
+ StringName type_Dictionary;
+ StringName type_Variant;
+ StringName type_VarArg;
+ StringName type_Object;
+ StringName type_Reference;
+ StringName enum_Error;
+
+ NameCache() {
+ type_void = StaticCString::create("void");
+ type_int = StaticCString::create("int");
+ type_Array = StaticCString::create("Array");
+ type_Dictionary = StaticCString::create("Dictionary");
+ type_Variant = StaticCString::create("Variant");
+ type_VarArg = StaticCString::create("VarArg");
+ type_Object = StaticCString::create("Object");
+ type_Reference = StaticCString::create("Reference");
+ enum_Error = StaticCString::create("Error");
+ }
+
+ static NameCache &get_singleton() {
+ static NameCache singleton;
+ return singleton;
+ }
+
+ NameCache(const NameCache &);
+ NameCache &operator=(const NameCache &);
+ };
+
+ const NameCache &name_cache;
+ const List<InternalCall>::Element *find_icall_by_name(const String &p_name, const List<InternalCall> &p_list) {
const List<InternalCall>::Element *it = p_list.front();
while (it) {
if (it->get().name == p_name) return it;
@@ -392,11 +498,13 @@ class BindingsGenerator {
return p_type.name;
}
+ String _determine_enum_prefix(const EnumInterface &p_ienum);
+
void _generate_header_icalls();
void _generate_method_icalls(const TypeInterface &p_itype);
- const TypeInterface *_get_type_by_name_or_null(const String &p_name);
- const TypeInterface *_get_type_by_name_or_placeholder(const String &p_name);
+ const TypeInterface *_get_type_by_name_or_null(const StringName &p_cname);
+ const TypeInterface *_get_type_by_name_or_placeholder(const StringName &p_cname);
void _default_argument_from_variant(const Variant &p_var, ArgumentInterface &r_iarg);
void _populate_builtin_type(TypeInterface &r_type, Variant::Type vtype);
@@ -404,11 +512,15 @@ class BindingsGenerator {
void _populate_object_type_interfaces();
void _populate_builtin_type_interfaces();
+ void _populate_global_constants();
+
Error _generate_cs_type(const TypeInterface &itype, const String &p_output_file);
- Error _generate_cs_property(const TypeInterface &p_itype, const DocData::PropertyDoc &p_prop_doc, List<String> &p_output);
+ Error _generate_cs_property(const TypeInterface &p_itype, const PropertyInterface &p_prop_doc, List<String> &p_output);
Error _generate_cs_method(const TypeInterface &p_itype, const MethodInterface &p_imethod, int &p_method_bind_count, List<String> &p_output);
+ void _generate_global_constants(List<String> &p_output);
+
Error _generate_glue_method(const TypeInterface &p_itype, const MethodInterface &p_imethod, List<String> &p_output);
Error _save_file(const String &path, const List<String> &content);
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 9a1efb4423..d5819a4ca3 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -54,7 +54,7 @@ String generate_core_api_project(const String &p_dir, const Vector<String> &p_fi
ERR_FAIL_V(String());
}
- return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
+ return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
}
String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector<String> &p_files) {
@@ -75,7 +75,7 @@ String generate_editor_api_project(const String &p_dir, const String &p_core_dll
ERR_FAIL_V(String());
}
- return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
+ return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
}
String generate_game_project(const String &p_dir, const String &p_name, const Vector<String> &p_files) {
@@ -96,7 +96,7 @@ String generate_game_project(const String &p_dir, const String &p_name, const Ve
ERR_FAIL_V(String());
}
- return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
+ return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
}
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) {
diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp
index b88d34fc33..3750a2b02a 100644
--- a/modules/mono/editor/godotsharp_builds.cpp
+++ b/modules/mono/editor/godotsharp_builds.cpp
@@ -313,7 +313,7 @@ GodotSharpBuilds *GodotSharpBuilds::singleton = NULL;
void GodotSharpBuilds::build_exit_callback(const MonoBuildInfo &p_build_info, int p_exit_code) {
BuildProcess *match = builds.getptr(p_build_info);
- ERR_FAIL_COND(!match);
+ ERR_FAIL_NULL(match);
BuildProcess &bp = *match;
bp.on_exit(p_exit_code);
diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp
index 1bc1e8a515..1e61646769 100644
--- a/modules/mono/editor/godotsharp_editor.cpp
+++ b/modules/mono/editor/godotsharp_editor.cpp
@@ -50,9 +50,9 @@ GodotSharpEditor *GodotSharpEditor::singleton = NULL;
bool GodotSharpEditor::_create_project_solution() {
- EditorProgress pr("create_csharp_solution", "Generating solution...", 2);
+ EditorProgress pr("create_csharp_solution", TTR("Generating solution..."), 2);
- pr.step("Generating C# project...");
+ pr.step(TTR("Generating C# project..."));
String path = OS::get_singleton()->get_resource_dir();
String name = ProjectSettings::get_singleton()->get("application/config/name");
@@ -67,7 +67,7 @@ bool GodotSharpEditor::_create_project_solution() {
NETSolution solution(name);
if (!solution.set_path(path)) {
- show_error_dialog("Failed to create solution.");
+ show_error_dialog(TTR("Failed to create solution."));
return false;
}
@@ -79,7 +79,7 @@ bool GodotSharpEditor::_create_project_solution() {
Error sln_error = solution.save();
if (sln_error != OK) {
- show_error_dialog("Failed to save solution.");
+ show_error_dialog(TTR("Failed to save solution."));
return false;
}
@@ -89,13 +89,13 @@ bool GodotSharpEditor::_create_project_solution() {
if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_EDITOR))
return false;
- pr.step("Done");
+ pr.step(TTR("Done"));
// Here, after all calls to progress_task_step
call_deferred("_remove_create_sln_menu_option");
} else {
- show_error_dialog("Failed to create C# project.");
+ show_error_dialog(TTR("Failed to create C# project."));
}
return true;
@@ -194,14 +194,14 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
error_dialog = memnew(AcceptDialog);
editor->get_gui_base()->add_child(error_dialog);
- bottom_panel_btn = editor->add_bottom_panel_item("Mono", memnew(MonoBottomPanel(editor)));
+ bottom_panel_btn = editor->add_bottom_panel_item(TTR("Mono"), memnew(MonoBottomPanel(editor)));
godotsharp_builds = memnew(GodotSharpBuilds);
editor->add_child(memnew(MonoReloadNode));
menu_button = memnew(MenuButton);
- menu_button->set_text("Mono");
+ menu_button->set_text(TTR("Mono"));
menu_popup = menu_button->get_popup();
String sln_path = GodotSharpDirs::get_project_sln_path();
@@ -209,7 +209,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) {
bottom_panel_btn->hide();
- menu_popup->add_item("Create C# solution", MENU_CREATE_SLN);
+ menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN);
}
menu_popup->connect("id_pressed", this, "_menu_option_pressed");
diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp
index 31dc09856a..be714026ad 100644
--- a/modules/mono/editor/mono_bottom_panel.cpp
+++ b/modules/mono/editor/mono_bottom_panel.cpp
@@ -197,7 +197,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) {
panel_builds_tab->add_child(toolbar_hbc);
ToolButton *build_project_btn = memnew(ToolButton);
- build_project_btn->set_text("Build Project");
+ build_project_btn->set_text(TTR("Build Project"));
build_project_btn->set_focus_mode(FOCUS_NONE);
build_project_btn->connect("pressed", this, "_build_project_pressed");
toolbar_hbc->add_child(build_project_btn);
@@ -205,7 +205,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) {
toolbar_hbc->add_spacer();
warnings_btn = memnew(ToolButton);
- warnings_btn->set_text("Warnings");
+ warnings_btn->set_text(TTR("Warnings"));
warnings_btn->set_toggle_mode(true);
warnings_btn->set_pressed(true);
warnings_btn->set_visible(false);
@@ -214,7 +214,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) {
toolbar_hbc->add_child(warnings_btn);
errors_btn = memnew(ToolButton);
- errors_btn->set_text("Errors");
+ errors_btn->set_text(TTR("Errors"));
errors_btn->set_toggle_mode(true);
errors_btn->set_pressed(true);
errors_btn->set_visible(false);
diff --git a/modules/mono/glue/cs_files/Error.cs b/modules/mono/glue/cs_files/Error.cs
deleted file mode 100644
index dee4b88f74..0000000000
--- a/modules/mono/glue/cs_files/Error.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-namespace Godot
-{
- public enum Error : int
- {
- OK = 0,
- FAILED = 1,
- ERR_UNAVAILABLE = 2,
- ERR_UNCONFIGURED = 3,
- ERR_UNAUTHORIZED = 4,
- ERR_PARAMETER_RANGE_ERROR = 5,
- ERR_OUT_OF_MEMORY = 6,
- ERR_FILE_NOT_FOUND = 7,
- ERR_FILE_BAD_DRIVE = 8,
- ERR_FILE_BAD_PATH = 9,
- ERR_FILE_NO_PERMISSION = 10,
- ERR_FILE_ALREADY_IN_USE = 11,
- ERR_FILE_CANT_OPEN = 12,
- ERR_FILE_CANT_WRITE = 13,
- ERR_FILE_CANT_READ = 14,
- ERR_FILE_UNRECOGNIZED = 15,
- ERR_FILE_CORRUPT = 16,
- ERR_FILE_MISSING_DEPENDENCIES = 17,
- ERR_FILE_EOF = 18,
- ERR_CANT_OPEN = 19,
- ERR_CANT_CREATE = 20,
- ERR_PARSE_ERROR = 43,
- ERROR_QUERY_FAILED = 21,
- ERR_ALREADY_IN_USE = 22,
- ERR_LOCKED = 23,
- ERR_TIMEOUT = 24,
- ERR_CANT_AQUIRE_RESOURCE = 28,
- ERR_INVALID_DATA = 30,
- ERR_INVALID_PARAMETER = 31,
- ERR_ALREADY_EXISTS = 32,
- ERR_DOES_NOT_EXIST = 33,
- ERR_DATABASE_CANT_READ = 34,
- ERR_DATABASE_CANT_WRITE = 35,
- ERR_COMPILATION_FAILED = 36,
- ERR_METHOD_NOT_FOUND = 37,
- ERR_LINK_FAILED = 38,
- ERR_SCRIPT_FAILED = 39,
- ERR_CYCLIC_LINK = 40,
- ERR_BUSY = 44,
- ERR_HELP = 46,
- ERR_BUG = 47
- }
-}
diff --git a/modules/mono/glue/cs_files/ExportAttribute.cs b/modules/mono/glue/cs_files/ExportAttribute.cs
index dce9cc59a0..e6f569e1bb 100644
--- a/modules/mono/glue/cs_files/ExportAttribute.cs
+++ b/modules/mono/glue/cs_files/ExportAttribute.cs
@@ -5,13 +5,13 @@ namespace Godot
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class ExportAttribute : Attribute
{
- private int hint;
- private string hint_string;
+ private PropertyHint hint;
+ private string hintString;
- public ExportAttribute(int hint = GD.PROPERTY_HINT_NONE, string hint_string = "")
+ public ExportAttribute(PropertyHint hint = PropertyHint.None, string hintString = "")
{
this.hint = hint;
- this.hint_string = hint_string;
+ this.hintString = hintString;
}
}
}
diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs
index 99fc289161..b335ef55e4 100644
--- a/modules/mono/glue/cs_files/GD.cs
+++ b/modules/mono/glue/cs_files/GD.cs
@@ -2,10 +2,8 @@ using System;
namespace Godot
{
- public static class GD
+ public static partial class GD
{
- /*{GodotGlobalConstants}*/
-
public static object Bytes2Var(byte[] bytes)
{
return NativeCalls.godot_icall_Godot_bytes2var(bytes);
diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs
index f2718d7b7a..e1fbb65da5 100644
--- a/modules/mono/glue/cs_files/Rect2.cs
+++ b/modules/mono/glue/cs_files/Rect2.cs
@@ -109,14 +109,14 @@ namespace Godot
return g;
}
- public Rect2 GrowMargin(int margin, float by)
+ public Rect2 GrowMargin(Margin margin, float by)
{
Rect2 g = this;
- g.GrowIndividual((GD.MARGIN_LEFT == margin) ? by : 0,
- (GD.MARGIN_TOP == margin) ? by : 0,
- (GD.MARGIN_RIGHT == margin) ? by : 0,
- (GD.MARGIN_BOTTOM == margin) ? by : 0);
+ g.GrowIndividual((Margin.Left == margin) ? by : 0,
+ (Margin.Top == margin) ? by : 0,
+ (Margin.Right == margin) ? by : 0,
+ (Margin.Bottom == margin) ? by : 0);
return g;
}
@@ -230,4 +230,4 @@ namespace Godot
});
}
}
-} \ No newline at end of file
+}
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index eb34f9dd3f..63b24f3ee6 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -290,7 +290,7 @@ int GDMonoField::get_int_value(MonoObject *p_object) {
String GDMonoField::get_string_value(MonoObject *p_object) {
MonoObject *val = get_value(p_object);
- return val ? GDMonoMarshal::mono_string_to_godot((MonoString *)val) : String();
+ return GDMonoMarshal::mono_string_to_godot((MonoString *)val);
}
bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) {
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index e473348897..e8aea8624d 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -70,7 +70,9 @@ void gdmono_MonoLogCallback(const char *log_domain, const char *log_level, const
}
if (fatal) {
- ERR_PRINTS("Mono: FALTAL ERROR, ABORTING! Logfile: " + GDMonoLog::get_singleton()->get_log_file_path() + "\n");
+ ERR_PRINTS("Mono: FATAL ERROR, ABORTING! Logfile: " + GDMonoLog::get_singleton()->get_log_file_path() + "\n");
+ // If we were to abort without flushing, the log wouldn't get written.
+ f->flush();
abort();
}
}
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 8bc2bb5096..d744d24f24 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -490,8 +490,9 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
return unbox<double>(p_obj);
case MONO_TYPE_STRING: {
- String str = mono_string_to_godot((MonoString *)p_obj);
- return str;
+ if (p_obj == NULL)
+ return Variant(); // NIL
+ return mono_string_to_godot_not_null((MonoString *)p_obj);
} break;
case MONO_TYPE_VALUETYPE: {
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index 443e947fb5..1be4be1a1c 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -62,13 +62,20 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type);
String mono_to_utf8_string(MonoString *p_mono_string);
String mono_to_utf16_string(MonoString *p_mono_string);
-_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) {
+_FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) {
if (sizeof(CharType) == 2)
return mono_to_utf16_string(p_mono_string);
return mono_to_utf8_string(p_mono_string);
}
+_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) {
+ if (p_mono_string == NULL)
+ return String();
+
+ return mono_string_to_godot_not_null(p_mono_string);
+}
+
_FORCE_INLINE_ MonoString *mono_from_utf8_string(const String &p_string) {
return mono_string_new(mono_domain_get(), p_string.utf8().get_data());
}
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 1cccd0ad9d..638636e985 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -95,7 +95,7 @@ void MonoCache::clear_members() {
class_ExportAttribute = NULL;
field_ExportAttribute_hint = NULL;
- field_ExportAttribute_hint_string = NULL;
+ field_ExportAttribute_hintString = NULL;
class_ToolAttribute = NULL;
class_RemoteAttribute = NULL;
class_SyncAttribute = NULL;
@@ -163,7 +163,7 @@ void update_godot_api_cache() {
// Attributes
CACHE_CLASS_AND_CHECK(ExportAttribute, GODOT_API_CLASS(ExportAttribute));
CACHE_FIELD_AND_CHECK(ExportAttribute, hint, CACHED_CLASS(ExportAttribute)->get_field("hint"));
- CACHE_FIELD_AND_CHECK(ExportAttribute, hint_string, CACHED_CLASS(ExportAttribute)->get_field("hint_string"));
+ CACHE_FIELD_AND_CHECK(ExportAttribute, hintString, CACHED_CLASS(ExportAttribute)->get_field("hintString"));
CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute));
CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute));
CACHE_CLASS_AND_CHECK(SyncAttribute, GODOT_API_CLASS(SyncAttribute));
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index c38f8c5af5..4308b357ba 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -97,7 +97,7 @@ struct MonoCache {
GDMonoClass *class_ExportAttribute;
GDMonoField *field_ExportAttribute_hint;
- GDMonoField *field_ExportAttribute_hint_string;
+ GDMonoField *field_ExportAttribute_hintString;
GDMonoClass *class_ToolAttribute;
GDMonoClass *class_RemoteAttribute;
GDMonoClass *class_SyncAttribute;
diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp
index a69c8bf9f3..6d7a3575ed 100644
--- a/modules/opus/register_types.cpp
+++ b/modules/opus/register_types.cpp
@@ -34,13 +34,18 @@
static ResourceFormatLoaderAudioStreamOpus *opus_stream_loader = NULL;
void register_opus_types() {
-
- opus_stream_loader = memnew(ResourceFormatLoaderAudioStreamOpus);
- ResourceLoader::add_resource_format_loader(opus_stream_loader);
- ClassDB::register_class<AudioStreamOpus>();
+ // Sorry guys, do not enable this unless you can figure out a way
+ // to get Opus to not do any memory allocation or system calls
+ // in the audio thread.
+ // Currently the implementation even reads files from the audio thread,
+ // and this is not how audio programming works.
+
+ //opus_stream_loader = memnew(ResourceFormatLoaderAudioStreamOpus);
+ //ResourceLoader::add_resource_format_loader(opus_stream_loader);
+ //ClassDB::register_class<AudioStreamOpus>();
}
void unregister_opus_types() {
- memdelete(opus_stream_loader);
+ //memdelete(opus_stream_loader);
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 5c252bda86..6f5bbba8d1 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -42,12 +42,17 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
int todo = p_frames;
- while (todo && active) {
+ int start_buffer = 0;
- int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2);
+ while (todo && active) {
+ float *buffer = (float *)p_buffer;
+ if (start_buffer > 0) {
+ buffer = (buffer + start_buffer * 2);
+ }
+ int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, buffer, todo * 2);
if (vorbis_stream->channels == 1 && mixed > 0) {
//mix mono to stereo
- for (int i = 0; i < mixed; i++) {
+ for (int i = start_buffer; i < mixed; i++) {
p_buffer[i].r = p_buffer[i].l;
}
}
@@ -60,11 +65,14 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
//loop
seek(vorbis_stream->loop_offset);
loops++;
+ // we still have buffer to fill, start from this element in the next iteration.
+ start_buffer = p_frames - todo;
} else {
- for (int i = mixed; i < p_frames; i++) {
+ for (int i = p_frames - todo; i < p_frames; i++) {
p_buffer[i] = AudioFrame(0, 0);
}
active = false;
+ todo = 0;
}
}
}
diff --git a/modules/thekla_unwrap/register_types.cpp b/modules/thekla_unwrap/register_types.cpp
index ab3203068f..da6c1bab2a 100644
--- a/modules/thekla_unwrap/register_types.cpp
+++ b/modules/thekla_unwrap/register_types.cpp
@@ -65,7 +65,7 @@ bool thekla_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
Thekla::atlas_set_default_options(&options);
options.packer_options.witness.packing_quality = 1;
options.packer_options.witness.texel_area = 1.0 / p_texel_size;
- options.packer_options.witness.conservative = true;
+ options.packer_options.witness.conservative = false;
//generate
Thekla::Atlas_Error err;
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 6c58de8a5a..faf3aecbd4 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -228,7 +228,7 @@ protected:
if (String(p_name) == "type") {
- Dictionary dc = d.copy();
+ Dictionary dc = d.duplicate();
dc["type"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
@@ -241,7 +241,7 @@ protected:
if (String(p_name) == "hint") {
- Dictionary dc = d.copy();
+ Dictionary dc = d.duplicate();
dc["hint"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
@@ -254,7 +254,7 @@ protected:
if (String(p_name) == "hint_string") {
- Dictionary dc = d.copy();
+ Dictionary dc = d.duplicate();
dc["hint_string"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
@@ -480,33 +480,33 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
select_func_text->hide();
Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("MiniVariant", "EditorIcons"),
- Control::get_icon("MiniBoolean", "EditorIcons"),
- Control::get_icon("MiniInteger", "EditorIcons"),
- Control::get_icon("MiniFloat", "EditorIcons"),
- Control::get_icon("MiniString", "EditorIcons"),
- Control::get_icon("MiniVector2", "EditorIcons"),
- Control::get_icon("MiniRect2", "EditorIcons"),
- Control::get_icon("MiniVector3", "EditorIcons"),
- Control::get_icon("MiniTransform2D", "EditorIcons"),
- Control::get_icon("MiniPlane", "EditorIcons"),
- Control::get_icon("MiniQuat", "EditorIcons"),
- Control::get_icon("MiniAabb", "EditorIcons"),
- Control::get_icon("MiniBasis", "EditorIcons"),
- Control::get_icon("MiniTransform", "EditorIcons"),
- Control::get_icon("MiniColor", "EditorIcons"),
- Control::get_icon("MiniPath", "EditorIcons"),
- Control::get_icon("MiniRid", "EditorIcons"),
+ Control::get_icon("Variant", "EditorIcons"),
+ Control::get_icon("bool", "EditorIcons"),
+ Control::get_icon("int", "EditorIcons"),
+ Control::get_icon("float", "EditorIcons"),
+ Control::get_icon("String", "EditorIcons"),
+ Control::get_icon("Vector2", "EditorIcons"),
+ Control::get_icon("Rect2", "EditorIcons"),
+ Control::get_icon("Vector3", "EditorIcons"),
+ Control::get_icon("Transform2D", "EditorIcons"),
+ Control::get_icon("Plane", "EditorIcons"),
+ Control::get_icon("Quat", "EditorIcons"),
+ Control::get_icon("AABB", "EditorIcons"),
+ Control::get_icon("Basis", "EditorIcons"),
+ Control::get_icon("Transform", "EditorIcons"),
+ Control::get_icon("Color", "EditorIcons"),
+ Control::get_icon("NodePath", "EditorIcons"),
+ Control::get_icon("RID", "EditorIcons"),
Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("MiniDictionary", "EditorIcons"),
- Control::get_icon("MiniArray", "EditorIcons"),
- Control::get_icon("MiniRawArray", "EditorIcons"),
- Control::get_icon("MiniIntArray", "EditorIcons"),
- Control::get_icon("MiniFloatArray", "EditorIcons"),
- Control::get_icon("MiniStringArray", "EditorIcons"),
- Control::get_icon("MiniVector2Array", "EditorIcons"),
- Control::get_icon("MiniVector3Array", "EditorIcons"),
- Control::get_icon("MiniColorArray", "EditorIcons")
+ Control::get_icon("Dictionary", "EditorIcons"),
+ Control::get_icon("Array", "EditorIcons"),
+ Control::get_icon("PoolByteArray", "EditorIcons"),
+ Control::get_icon("PoolIntArray", "EditorIcons"),
+ Control::get_icon("PoolRealArray", "EditorIcons"),
+ Control::get_icon("PoolStringArray", "EditorIcons"),
+ Control::get_icon("PoolVector2Array", "EditorIcons"),
+ Control::get_icon("PoolVector3Array", "EditorIcons"),
+ Control::get_icon("PoolColorArray", "EditorIcons")
};
Ref<Texture> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons");
@@ -774,33 +774,33 @@ void VisualScriptEditor::_update_members() {
variables->set_custom_color(0, Control::get_color("mono_color", "Editor"));
Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("MiniVariant", "EditorIcons"),
- Control::get_icon("MiniBoolean", "EditorIcons"),
- Control::get_icon("MiniInteger", "EditorIcons"),
- Control::get_icon("MiniFloat", "EditorIcons"),
- Control::get_icon("MiniString", "EditorIcons"),
- Control::get_icon("MiniVector2", "EditorIcons"),
- Control::get_icon("MiniRect2", "EditorIcons"),
- Control::get_icon("MiniVector3", "EditorIcons"),
- Control::get_icon("MiniMatrix32", "EditorIcons"),
- Control::get_icon("MiniPlane", "EditorIcons"),
- Control::get_icon("MiniQuat", "EditorIcons"),
- Control::get_icon("MiniAabb", "EditorIcons"),
- Control::get_icon("MiniMatrix3", "EditorIcons"),
- Control::get_icon("MiniTransform", "EditorIcons"),
- Control::get_icon("MiniColor", "EditorIcons"),
- Control::get_icon("MiniPath", "EditorIcons"),
- Control::get_icon("MiniRid", "EditorIcons"),
+ Control::get_icon("Variant", "EditorIcons"),
+ Control::get_icon("bool", "EditorIcons"),
+ Control::get_icon("int", "EditorIcons"),
+ Control::get_icon("float", "EditorIcons"),
+ Control::get_icon("String", "EditorIcons"),
+ Control::get_icon("Vector2", "EditorIcons"),
+ Control::get_icon("Rect2", "EditorIcons"),
+ Control::get_icon("Vector3", "EditorIcons"),
+ Control::get_icon("Transform2D", "EditorIcons"),
+ Control::get_icon("Plane", "EditorIcons"),
+ Control::get_icon("Quat", "EditorIcons"),
+ Control::get_icon("AABB", "EditorIcons"),
+ Control::get_icon("Basis", "EditorIcons"),
+ Control::get_icon("Transform", "EditorIcons"),
+ Control::get_icon("Color", "EditorIcons"),
+ Control::get_icon("NodePath", "EditorIcons"),
+ Control::get_icon("RID", "EditorIcons"),
Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("MiniDictionary", "EditorIcons"),
- Control::get_icon("MiniArray", "EditorIcons"),
- Control::get_icon("MiniRawArray", "EditorIcons"),
- Control::get_icon("MiniIntArray", "EditorIcons"),
- Control::get_icon("MiniFloatArray", "EditorIcons"),
- Control::get_icon("MiniStringArray", "EditorIcons"),
- Control::get_icon("MiniVector2Array", "EditorIcons"),
- Control::get_icon("MiniVector3Array", "EditorIcons"),
- Control::get_icon("MiniColorArray", "EditorIcons")
+ Control::get_icon("Dictionary", "EditorIcons"),
+ Control::get_icon("Array", "EditorIcons"),
+ Control::get_icon("PoolByteArray", "EditorIcons"),
+ Control::get_icon("PoolIntArray", "EditorIcons"),
+ Control::get_icon("PoolRealArray", "EditorIcons"),
+ Control::get_icon("PoolStringArray", "EditorIcons"),
+ Control::get_icon("PoolVector2Array", "EditorIcons"),
+ Control::get_icon("PoolVector3Array", "EditorIcons"),
+ Control::get_icon("PoolColorArray", "EditorIcons")
};
List<StringName> var_names;
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index a38266acc0..147761783a 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -731,921 +731,6 @@ void VisualScriptSwitch::_bind_methods() {
VisualScriptSwitch::VisualScriptSwitch() {
}
- //////////////////////////////////////////
- ////////////////EVENT ACTION FILTER///////////
- //////////////////////////////////////////
-
-#if 0
-int VisualScriptInputFilter::get_output_sequence_port_count() const {
-
- return filters.size();
-}
-
-bool VisualScriptInputFilter::has_input_sequence_port() const {
-
- return true;
-}
-
-int VisualScriptInputFilter::get_input_value_port_count() const {
-
- return 1;
-}
-int VisualScriptInputFilter::get_output_value_port_count() const {
-
- return 1;
-}
-
-String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const {
-
- String text;
-
- switch (filters[p_port].type) {
- case Ref<InputEvent>::NONE: {
- text = "None";
- } break;
- case Ref<InputEvent>::KEY: {
-
- InputEventKey k = filters[p_port].key;
-
- if (k->get_scancode() == 0 && k.unicode == 0) {
- text = "No Key";
- } else {
- if (k->get_scancode() != 0) {
- text = "KeyCode: " + keycode_get_string(k->get_scancode());
- } else if (k.unicode != 0) {
- text = "Uniode: " + String::chr(k.unicode);
- }
-
- if (k->is_pressed())
- text += ", Pressed";
- else
- text += ", Released";
-
- if (k.echo)
- text += ", Echo";
- if (k->get_alt())
- text = "Alt+" + text;
- if (k->get_shift())
- text = "Shift+" + text;
- if (k->get_control())
- text = "Ctrl+" + text;
- if (k->get_metakey())
- text = "Meta+" + text;
- }
-
- } break;
- case Ref<InputEvent>::MOUSE_MOTION: {
- InputEventMouseMotion mm = filters[p_port].mouse_motion;
- text = "Mouse Motion";
-
- String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
-
- for (int i = 0; i < 7; i++) {
- if (mm->get_button_mask() & (1 << i)) {
- text = b.get_slice(",", i) + "+" + text;
- }
- }
- if (mm->get_alt())
- text = "Alt+" + text;
- if (mm->get_shift())
- text = "Shift+" + text;
- if (mm->get_control())
- text = "Ctrl+" + text;
- if (mm->get_metakey())
- text = "Meta+" + text;
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- InputEventMouseButton mb = filters[p_port].mouse_button;
-
- String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
-
- text = b.get_slice(",", mb->get_button_index()) + " Mouse Button";
-
- if (mb->is_pressed())
- text += ", Pressed";
- else
- text += ", Released";
-
- if (mb.doubleclick)
- text += ", DblClick";
- if (mb->get_alt())
- text = "Alt+" + text;
- if (mb->get_shift())
- text = "Shift+" + text;
- if (mb->get_control())
- text = "Ctrl+" + text;
- if (mb->get_metakey())
- text = "Meta+" + text;
-
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- InputEventJoypadMotion jm = filters[p_port].joy_motion;
-
- text = "JoyMotion Axis " + itos(jm.axis >> 1);
- if (jm.axis & 1)
- text += " > " + rtos(jm.axis_value);
- else
- text += " < " + rtos(-jm.axis_value);
-
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
- InputEventJoypadButton jb = filters[p_port].joy_button;
-
- text = "JoyButton " + itos(jb->get_button_index());
- if (jb->is_pressed())
- text += ", Pressed";
- else
- text += ", Released";
- } break;
- case Ref<InputEvent>::SCREEN_TOUCH: {
- InputEventScreenTouch sd = filters[p_port].screen_touch;
-
- text = "Touch Finger " + itos(sd.index);
- if (sd->is_pressed())
- text += ", Pressed";
- else
- text += ", Released";
- } break;
- case Ref<InputEvent>::SCREEN_DRAG: {
- InputEventScreenDrag sd = filters[p_port].screen_drag;
- text = "Drag Finger " + itos(sd.index);
- } break;
- case Ref<InputEvent>::ACTION: {
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
- int index = 1;
-
- text = "No Action";
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- if (filters[p_port].action.action == index) {
- text = "Action " + pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- break;
- }
- index++;
- }
-
- if (filters[p_port].action->is_pressed())
- text += ", Pressed";
- else
- text += ", Released";
-
- } break;
- }
-
- return text + " - " + itos(p_port);
-}
-
-PropertyInfo VisualScriptInputFilter::get_input_value_port_info(int p_idx) const {
-
- return PropertyInfo(Variant::INPUT_EVENT, "event");
-}
-
-PropertyInfo VisualScriptInputFilter::get_output_value_port_info(int p_idx) const {
-
- return PropertyInfo(Variant::INPUT_EVENT, "");
-}
-
-String VisualScriptInputFilter::get_caption() const {
-
- return "InputFilter";
-}
-
-String VisualScriptInputFilter::get_text() const {
-
- return "";
-}
-
-bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_value) {
-
- if (p_name == "filter_count") {
- filters.resize(p_value);
- _change_notify();
- ports_changed_notify();
- return true;
- }
-
- if (String(p_name).begins_with("filter_")) {
-
- int idx = String(p_name).replace_first("filters_", "").get_slice("/", 0).to_int();
-
- ERR_FAIL_INDEX_V(idx, filters.size(), false);
-
- String what = String(p_name).get_slice("/", 1);
-
- if (what == "type") {
- filters[idx] = Ref<InputEvent>();
- filters[idx].type = Ref<InputEvent>::Type(int(p_value));
- if (filters[idx].type == Ref<InputEvent>::JOYPAD_MOTION) {
- filters[idx].joy_motion.axis_value = 0.5; //for threshold
- } else if (filters[idx].type == Ref<InputEvent>::KEY) {
- filters[idx]->is_pressed() = true; //put these as true to make it more user friendly
- } else if (filters[idx].type == Ref<InputEvent>::MOUSE_BUTTON) {
- filters[idx]->is_pressed() = true;
- } else if (filters[idx].type == Ref<InputEvent>::JOYPAD_BUTTON) {
- filters[idx].joy_button->is_pressed() = true;
- } else if (filters[idx].type == Ref<InputEvent>::SCREEN_TOUCH) {
- filters[idx].screen_touch->is_pressed() = true;
- } else if (filters[idx].type == Ref<InputEvent>::ACTION) {
- filters[idx].action->is_pressed() = true;
- }
- _change_notify();
- ports_changed_notify();
-
- return true;
- }
- if (what == "device") {
- filters[idx].device = p_value;
- ports_changed_notify();
- return true;
- }
-
- switch (filters[idx].type) {
-
- case Ref<InputEvent>::KEY: {
-
- if (what == "scancode") {
- String sc = p_value;
- if (sc == String()) {
- filters[idx]->get_scancode() = 0;
- } else {
- filters[idx]->get_scancode() = find_keycode(p_value);
- }
-
- } else if (what == "unicode") {
-
- String uc = p_value;
-
- if (uc == String()) {
- filters[idx].key.unicode = 0;
- } else {
- filters[idx].key.unicode = uc[0];
- }
-
- } else if (what == "pressed") {
-
- filters[idx]->is_pressed() = p_value;
- } else if (what == "echo") {
-
- filters[idx]->is_echo() = p_value;
-
- } else if (what == "mod_alt") {
- filters[idx]->get_alt() = p_value;
-
- } else if (what == "mod_shift") {
- filters[idx]->get_shift() = p_value;
-
- } else if (what == "mod_ctrl") {
- filters[idx]->get_control() = p_value;
-
- } else if (what == "mod_meta") {
- filters[idx]->get_metakey() = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
-
- return true;
- } break;
- case Ref<InputEvent>::MOUSE_MOTION: {
-
- if (what == "button_mask") {
- filters[idx]->get_button_mask() = p_value;
-
- } else if (what == "mod_alt") {
- filters[idx].mouse_motion->get_alt() = p_value;
-
- } else if (what == "mod_shift") {
- filters[idx].mouse_motion->get_shift() = p_value;
-
- } else if (what == "mod_ctrl") {
- filters[idx].mouse_motion->get_control() = p_value;
-
- } else if (what == "mod_meta") {
- filters[idx].mouse_motion->get_metakey() = p_value;
- } else {
- return false;
- }
-
- ports_changed_notify();
- return true;
-
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- if (what == "button_index") {
- filters[idx]->get_button_index() = p_value;
- } else if (what == "pressed") {
- filters[idx]->is_pressed() = p_value;
- } else if (what == "doubleclicked") {
- filters[idx].mouse_button.doubleclick = p_value;
-
- } else if (what == "mod_alt") {
- filters[idx].mouse_button->get_alt() = p_value;
-
- } else if (what == "mod_shift") {
- filters[idx].mouse_button->get_shift() = p_value;
-
- } else if (what == "mod_ctrl") {
- filters[idx].mouse_button->get_control() = p_value;
-
- } else if (what == "mod_meta") {
- filters[idx].mouse_button->get_metakey() = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
- return true;
-
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- if (what == "axis") {
- filters[idx].joy_motion.axis = int(p_value) << 1 | filters[idx].joy_motion.axis;
- } else if (what == "mode") {
- filters[idx].joy_motion.axis |= int(p_value);
- } else if (what == "threshold") {
- filters[idx].joy_motion.axis_value = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
- return true;
-
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
-
- if (what == "button_index") {
- filters[idx].joy_button->get_button_index() = p_value;
- } else if (what == "pressed") {
- filters[idx].joy_button->is_pressed() = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
- return true;
-
- } break;
- case Ref<InputEvent>::SCREEN_TOUCH: {
-
- if (what == "finger_index") {
- filters[idx].screen_touch.index = p_value;
- } else if (what == "pressed") {
- filters[idx].screen_touch->is_pressed() = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
- return true;
- } break;
- case Ref<InputEvent>::SCREEN_DRAG: {
- if (what == "finger_index") {
- filters[idx].screen_drag.index = p_value;
- } else {
- return false;
- }
- ports_changed_notify();
- return true;
- } break;
- case Ref<InputEvent>::ACTION: {
-
- if (what == "action_name") {
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
- int index = 1;
-
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- if (name == String(p_value)) {
-
- filters[idx].action.action = index;
- ports_changed_notify();
- return true;
- }
-
- index++;
- }
-
- filters[idx].action.action = 0;
- ports_changed_notify();
-
- return false;
-
- } else if (what == "pressed") {
-
- filters[idx].action->is_pressed() = p_value;
- ports_changed_notify();
- return true;
- }
-
- } break;
- }
- }
- return false;
-}
-
-bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (p_name == "filter_count") {
- r_ret = filters.size();
- return true;
- }
-
- if (String(p_name).begins_with("filter_")) {
-
- int idx = String(p_name).replace_first("filters_", "").get_slice("/", 0).to_int();
-
- ERR_FAIL_INDEX_V(idx, filters.size(), false);
-
- String what = String(p_name).get_slice("/", 1);
-
- if (what == "type") {
- r_ret = filters[idx].type;
- return true;
- }
- if (what == "device") {
- r_ret = filters[idx].device;
- return true;
- }
-
- switch (filters[idx].type) {
-
- case Ref<InputEvent>::KEY: {
-
- if (what == "scancode") {
- if (filters[idx]->get_scancode() == 0)
- r_ret = String();
- else {
-
- r_ret = keycode_get_string(filters[idx]->get_scancode());
- }
-
- } else if (what == "unicode") {
-
- if (filters[idx].key.unicode == 0) {
- r_ret = String();
- } else {
- CharType str[2] = { (CharType)filters[idx].key.unicode, 0 };
- r_ret = String(str);
- }
-
- } else if (what == "pressed") {
-
- r_ret = filters[idx]->is_pressed();
- } else if (what == "echo") {
-
- r_ret = filters[idx]->is_echo();
-
- } else if (what == "mod_alt") {
- r_ret = filters[idx]->get_alt();
-
- } else if (what == "mod_shift") {
- r_ret = filters[idx]->get_shift();
-
- } else if (what == "mod_ctrl") {
- r_ret = filters[idx]->get_control();
-
- } else if (what == "mod_meta") {
- r_ret = filters[idx]->get_metakey();
- } else {
- return false;
- }
-
- return true;
- } break;
- case Ref<InputEvent>::MOUSE_MOTION: {
-
- if (what == "button_mask") {
- r_ret = filters[idx]->get_button_mask();
-
- } else if (what == "mod_alt") {
- r_ret = filters[idx].mouse_motion->get_alt();
-
- } else if (what == "mod_shift") {
- r_ret = filters[idx].mouse_motion->get_shift();
-
- } else if (what == "mod_ctrl") {
- r_ret = filters[idx].mouse_motion->get_control();
-
- } else if (what == "mod_meta") {
- r_ret = filters[idx].mouse_motion->get_metakey();
- } else {
- return false;
- }
-
- return true;
-
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- if (what == "button_index") {
- r_ret = filters[idx]->get_button_index();
- } else if (what == "pressed") {
- r_ret = filters[idx]->is_pressed();
- } else if (what == "doubleclicked") {
- r_ret = filters[idx].mouse_button.doubleclick;
-
- } else if (what == "mod_alt") {
- r_ret = filters[idx].mouse_button->get_alt();
-
- } else if (what == "mod_shift") {
- r_ret = filters[idx].mouse_button->get_shift();
-
- } else if (what == "mod_ctrl") {
- r_ret = filters[idx].mouse_button->get_control();
-
- } else if (what == "mod_meta") {
- r_ret = filters[idx].mouse_button->get_metakey();
- } else {
- return false;
- }
- return true;
-
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- if (what == "axis_index") {
- r_ret = filters[idx].joy_motion.axis >> 1;
- } else if (what == "mode") {
- r_ret = filters[idx].joy_motion.axis & 1;
- } else if (what == "threshold") {
- r_ret = filters[idx].joy_motion.axis_value;
- } else {
- return false;
- }
- return true;
-
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
-
- if (what == "button_index") {
- r_ret = filters[idx].joy_button->get_button_index();
- } else if (what == "pressed") {
- r_ret = filters[idx].joy_button->is_pressed();
- } else {
- return false;
- }
- return true;
-
- } break;
- case Ref<InputEvent>::SCREEN_TOUCH: {
-
- if (what == "finger_index") {
- r_ret = filters[idx].screen_touch.index;
- } else if (what == "pressed") {
- r_ret = filters[idx].screen_touch->is_pressed();
- } else {
- return false;
- }
- return true;
- } break;
- case Ref<InputEvent>::SCREEN_DRAG: {
- if (what == "finger_index") {
- r_ret = filters[idx].screen_drag.index;
- } else {
- return false;
- }
- return true;
- } break;
- case Ref<InputEvent>::ACTION: {
-
- if (what == "action_name") {
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
- int index = 1;
-
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- if (filters[idx].action.action == index) {
- r_ret = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- return true;
- }
- index++;
- }
-
- r_ret = "None"; //no index
- return false;
-
- } else if (what == "pressed") {
-
- r_ret = filters[idx].action->is_pressed();
- return true;
- }
-
- } break;
- }
- }
- return false;
-}
-
-static const char *event_type_names[Ref<InputEvent>::TYPE_MAX] = {
- "None",
- "Key",
- "MouseMotion",
- "MouseButton",
- "JoypadMotion",
- "JoypadButton",
- "ScreenTouch",
- "ScreenDrag",
- "Action"
-};
-
-void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) const {
-
- p_list->push_back(PropertyInfo(Variant::INT, "filter_count", PROPERTY_HINT_RANGE, "0,64"));
-
- String et;
- for (int i = 0; i < Ref<InputEvent>::TYPE_MAX; i++) {
- if (i > 0)
- et += ",";
-
- et += event_type_names[i];
- }
-
- String kc;
- String actions;
-
- for (int i = 0; i < filters.size(); i++) {
-
- String base = "filter_" + itos(i) + "/";
- p_list->push_back(PropertyInfo(Variant::INT, base + "type", PROPERTY_HINT_ENUM, et));
- p_list->push_back(PropertyInfo(Variant::INT, base + "device"));
- switch (filters[i].type) {
-
- case Ref<InputEvent>::NONE: {
-
- } break;
- case Ref<InputEvent>::KEY: {
- if (kc == String()) {
- int kcc = keycode_get_count();
- kc = "None";
- for (int i = 0; i < kcc; i++) {
- kc += ",";
- kc += String(keycode_get_name_by_index(i));
- }
- }
- p_list->push_back(PropertyInfo(Variant::STRING, base + "scancode", PROPERTY_HINT_ENUM, kc));
- p_list->push_back(PropertyInfo(Variant::STRING, base + "unicode"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "echo"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
-
- } break;
- case Ref<InputEvent>::MOUSE_MOTION: {
- p_list->push_back(PropertyInfo(Variant::INT, base + "button_mask", PROPERTY_HINT_FLAGS, "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
-
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
- p_list->push_back(PropertyInfo(Variant::INT, base + "button_index", PROPERTY_HINT_ENUM, "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "doubleclicked"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
-
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- p_list->push_back(PropertyInfo(Variant::INT, base + "axis_index"));
- p_list->push_back(PropertyInfo(Variant::INT, base + "mode", PROPERTY_HINT_ENUM, "Min,Max"));
- p_list->push_back(PropertyInfo(Variant::REAL, base + "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"));
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
- p_list->push_back(PropertyInfo(Variant::INT, base + "button_index"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
-
- } break;
- case Ref<InputEvent>::SCREEN_TOUCH: {
- p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
-
- } break;
- case Ref<InputEvent>::SCREEN_DRAG: {
- p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
- } break;
- case Ref<InputEvent>::ACTION: {
-
- if (actions == String()) {
-
- actions = "None";
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
- Vector<String> al;
-
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
-
- al.push_back(name);
- }
-
- for (int i = 0; i < al.size(); i++) {
- actions += ",";
- actions += al[i];
- }
- }
-
- p_list->push_back(PropertyInfo(Variant::STRING, base + "action_name", PROPERTY_HINT_ENUM, actions));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
-
- } break;
- }
- }
-}
-
-class VisualScriptNodeInstanceInputFilter : public VisualScriptNodeInstance {
-public:
- VisualScriptInstance *instance;
- Vector<Ref<InputEvent>> filters;
-
- //virtual int get_working_memory_size() const { return 0; }
- //virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
- //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
-
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
-
- if (p_inputs[0]->get_type() != Variant::INPUT_EVENT) {
- r_error_str = "Input value not of type event";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return 0;
- }
-
- Ref<InputEvent> event = *p_inputs[0];
-
- for (int i = 0; i < filters.size(); i++) {
-
- const Ref<InputEvent> &ie = filters[i];
- if (ie.type != event.type)
- continue;
-
- bool match = false;
-
- switch (ie.type) {
-
- case Ref<InputEvent>::NONE: {
-
- match = true;
- } break;
- case Ref<InputEvent>::KEY: {
-
- InputEventKey k = ie.key;
- InputEventKey k2 = event.key;
-
- if (k->get_scancode() == 0 && k.unicode == 0 && k2->get_scancode() == 0 && k2.unicode == 0) {
- match = true;
-
- } else {
-
- if ((k->get_scancode() != 0 && k->get_scancode() == k2->get_scancode()) || (k.unicode != 0 && k.unicode == k2.unicode)) {
- //key valid
-
- if (
- k->is_pressed() == k2->is_pressed() &&
- k.echo == k2.echo &&
- k.mod == k2.mod) {
- match = true;
- }
- }
- }
-
- } break;
- case Ref<InputEvent>::MOUSE_MOTION: {
- InputEventMouseMotion mm = ie.mouse_motion;
- InputEventMouseMotion mm2 = event.mouse_motion;
-
- if (mm->get_button_mask() == mm2->get_button_mask() &&
- mm.mod == mm2.mod) {
- match = true;
- }
-
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- InputEventMouseButton mb = ie.mouse_button;
- InputEventMouseButton mb2 = event.mouse_button;
-
- if (mb->get_button_index() == mb2->get_button_index() &&
- mb->is_pressed() == mb2->is_pressed() &&
- mb.doubleclick == mb2.doubleclick &&
- mb.mod == mb2.mod) {
- match = true;
- }
-
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- InputEventJoypadMotion jm = ie.joy_motion;
- InputEventJoypadMotion jm2 = event.joy_motion;
-
- int axis = jm.axis >> 1;
-
- if (axis == jm2.axis) {
-
- if (jm.axis & 1) {
- //greater
- if (jm2.axis_value > jm.axis_value) {
- match = true;
- }
- } else {
- //less
- if (jm2.axis_value < -jm.axis_value) {
- match = true;
- }
- }
- }
-
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
- InputEventJoypadButton jb = ie.joy_button;
- InputEventJoypadButton jb2 = event.joy_button;
-
- if (jb->get_button_index() == jb2->get_button_index() &&
- jb->is_pressed() == jb2->is_pressed()) {
- match = true;
- }
- } break;
- case Ref<InputEvent>::SCREEN_TOUCH: {
- InputEventScreenTouch st = ie.screen_touch;
- InputEventScreenTouch st2 = event.screen_touch;
-
- if (st.index == st2.index &&
- st->is_pressed() == st2->is_pressed()) {
- match = true;
- }
-
- } break;
- case Ref<InputEvent>::SCREEN_DRAG: {
- InputEventScreenDrag sd = ie.screen_drag;
- InputEventScreenDrag sd2 = event.screen_drag;
-
- if (sd.index == sd2.index) {
- match = true;
- }
- } break;
- case Ref<InputEvent>::ACTION: {
-
- InputEventAction ia = ie.action;
- InputEventAction ia2 = event.action;
-
- if (ia.action == ia2.action &&
- ia->is_pressed() == ia2->is_pressed()) {
- match = true;
- }
- } break;
- }
-
- *p_outputs[0] = event;
-
- if (match)
- return i; //go through match output
- }
-
- return STEP_NO_ADVANCE_BIT; //none found, don't advance
- }
-};
-
-VisualScriptNodeInstance *VisualScriptInputFilter::instance(VisualScriptInstance *p_instance) {
-
- VisualScriptNodeInstanceInputFilter *instance = memnew(VisualScriptNodeInstanceInputFilter);
- instance->instance = p_instance;
- instance->filters = filters;
- return instance;
-}
-
-VisualScriptInputFilter::VisualScriptInputFilter() {
-}
-#endif
//////////////////////////////////////////
////////////////TYPE CAST///////////
//////////////////////////////////////////
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index 380eb76c45..4766bbef6b 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -228,40 +228,6 @@ public:
VisualScriptSwitch();
};
-#if 0
-class VisualScriptInputFilter : public VisualScriptNode {
-
- GDCLASS(VisualScriptInputFilter, VisualScriptNode)
-
- Vector<Ref<InputEvent>> filters;
-
-protected:
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
-
-public:
- virtual int get_output_sequence_port_count() const;
- virtual bool has_input_sequence_port() const;
-
- virtual String get_output_sequence_port_text(int p_port) const;
-
- virtual int get_input_value_port_count() const;
- virtual int get_output_value_port_count() const;
-
- virtual PropertyInfo get_input_value_port_info(int p_idx) const;
- virtual PropertyInfo get_output_value_port_info(int p_idx) const;
-
- virtual String get_caption() const;
- virtual String get_text() const;
- virtual String get_category() const { return "flow_control"; }
-
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
-
- VisualScriptInputFilter();
-};
-#endif
-
class VisualScriptTypeCast : public VisualScriptNode {
GDCLASS(VisualScriptTypeCast, VisualScriptNode)