summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/script_language.cpp52
-rw-r--r--core/script_language.h6
-rw-r--r--modules/gdscript/gdscript_editor.cpp15
-rw-r--r--scene/animation/tween.cpp4
-rw-r--r--scene/gui/control.cpp4
-rwxr-xr-xscene/main/timer.cpp3
6 files changed, 77 insertions, 7 deletions
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 97758ced66..ee8589d76a 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -50,6 +50,52 @@ void Script::_notification(int p_what) {
}
}
+Variant Script::_get_property_default_value(const StringName &p_property) {
+ Variant ret;
+ get_property_default_value(p_property, ret);
+ return ret;
+}
+
+Array Script::_get_script_property_list() {
+ Array ret;
+ List<PropertyInfo> list;
+ get_script_property_list(&list);
+ for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) {
+ ret.append(E->get().operator Dictionary());
+ }
+ return ret;
+}
+
+Array Script::_get_script_method_list() {
+ Array ret;
+ List<MethodInfo> list;
+ get_script_method_list(&list);
+ for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) {
+ ret.append(E->get().operator Dictionary());
+ }
+ return ret;
+}
+
+Array Script::_get_script_signal_list() {
+ Array ret;
+ List<MethodInfo> list;
+ get_script_signal_list(&list);
+ for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) {
+ ret.append(E->get().operator Dictionary());
+ }
+ return ret;
+}
+
+Dictionary Script::_get_script_constant_map() {
+ Dictionary ret;
+ Map<StringName, Variant> map;
+ get_constants(&map);
+ for (Map<StringName, Variant>::Element *E = map.front(); E; E = E->next()) {
+ ret[E->key()] = E->value();
+ }
+ return ret;
+}
+
void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("can_instance"), &Script::can_instance);
@@ -64,6 +110,12 @@ void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal);
+ ClassDB::bind_method(D_METHOD("get_script_property_list"), &Script::_get_script_property_list);
+ ClassDB::bind_method(D_METHOD("get_script_method_list"), &Script::_get_script_method_list);
+ ClassDB::bind_method(D_METHOD("get_script_signal_list"), &Script::_get_script_signal_list);
+ ClassDB::bind_method(D_METHOD("get_script_constant_map"), &Script::_get_script_constant_map);
+ ClassDB::bind_method(D_METHOD("get_property_default_value"), &Script::_get_property_default_value);
+
ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", 0), "set_source_code", "get_source_code");
diff --git a/core/script_language.h b/core/script_language.h
index dfb2e0ad31..1b4f1eb4cd 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -109,6 +109,12 @@ protected:
friend class PlaceHolderScriptInstance;
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {}
+ Variant _get_property_default_value(const StringName &p_property);
+ Array _get_script_property_list();
+ Array _get_script_method_list();
+ Array _get_script_signal_list();
+ Dictionary _get_script_constant_map();
+
public:
virtual bool can_instance() const = 0;
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 925dbda620..b4c38e4d40 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -1936,9 +1936,18 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
Ref<GDScript> script = base_type.script_type;
if (script.is_valid()) {
if (!_static && !p_only_functions) {
- for (const Set<StringName>::Element *E = script->get_members().front(); E; E = E->next()) {
- ScriptCodeCompletionOption option(E->get().operator String(), ScriptCodeCompletionOption::KIND_MEMBER);
- r_result.insert(option.display, option);
+ if (p_context.base && p_context.base->get_script_instance()) {
+ List<PropertyInfo> members;
+ p_context.base->get_script_instance()->get_property_list(&members);
+ for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) {
+ ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER);
+ r_result.insert(option.display, option);
+ }
+ } else {
+ for (const Set<StringName>::Element *E = script->get_members().front(); E; E = E->next()) {
+ ScriptCodeCompletionOption option(E->get().operator String(), ScriptCodeCompletionOption::KIND_MEMBER);
+ r_result.insert(option.display, option);
+ }
}
}
if (!p_only_functions) {
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 2609924f33..0f7d4466c8 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -783,10 +783,12 @@ float Tween::get_speed_scale() const {
}
bool Tween::start() {
+
+ ERR_FAIL_COND_V_MSG(!is_inside_tree(), false, "Tween was not added to the SceneTree!");
+
// Are there any pending updates?
if (pending_update != 0) {
// Start the tweens after deferring
- call_deferred("start");
return true;
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 034e9266f6..174c2fce7d 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2149,9 +2149,7 @@ bool Control::has_focus() const {
void Control::grab_focus() {
- if (!is_inside_tree()) {
- ERR_FAIL_COND(!is_inside_tree());
- }
+ ERR_FAIL_COND(!is_inside_tree());
if (data.focus_mode == FOCUS_NONE) {
WARN_PRINT("This control can't grab focus. Use set_focus_mode() to allow a control to get focus.");
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 03d46fd28d..14cc705edb 100755
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -107,6 +107,9 @@ bool Timer::has_autostart() const {
}
void Timer::start(float p_time) {
+
+ ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree!");
+
if (p_time > 0) {
set_wait_time(p_time);
}