summaryrefslogtreecommitdiff
path: root/scene/main/timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/timer.cpp')
-rw-r--r--scene/main/timer.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 4bc159f6aa..9e462eb1c8 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -30,14 +30,12 @@
#include "timer.h"
-#include "core/config/engine.h"
-
void Timer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
if (autostart) {
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) {
break;
}
#endif
@@ -58,7 +56,7 @@ void Timer::_notification(int p_what) {
stop();
}
- emit_signal("timeout");
+ emit_signal(SNAME("timeout"));
}
} break;
@@ -74,19 +72,19 @@ void Timer::_notification(int p_what) {
} else {
stop();
}
- emit_signal("timeout");
+ emit_signal(SNAME("timeout"));
}
} break;
}
}
-void Timer::set_wait_time(float p_time) {
+void Timer::set_wait_time(double p_time) {
ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero.");
wait_time = p_time;
}
-float Timer::get_wait_time() const {
+double Timer::get_wait_time() const {
return wait_time;
}
@@ -106,7 +104,7 @@ bool Timer::has_autostart() const {
return autostart;
}
-void Timer::start(float p_time) {
+void Timer::start(double p_time) {
ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree. Either add it or set autostart to true.");
if (p_time > 0) {
@@ -139,7 +137,7 @@ bool Timer::is_stopped() const {
return get_time_left() <= 0;
}
-float Timer::get_time_left() const {
+double Timer::get_time_left() const {
return time_left > 0 ? time_left : 0;
}
@@ -207,11 +205,11 @@ void Timer::_bind_methods() {
ADD_SIGNAL(MethodInfo("timeout"));
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_timer_process_callback", "get_timer_process_callback");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_RANGE, "0.001,4096,0.001,or_greater,exp"), "set_wait_time", "get_wait_time");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "is_one_shot");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), "set_autostart", "has_autostart");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", 0), "set_paused", "is_paused");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", 0), "", "get_time_left");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_paused", "is_paused");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_time_left");
BIND_ENUM_CONSTANT(TIMER_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(TIMER_PROCESS_IDLE);