summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp11
-rw-r--r--core/os/dir_access.h1
-rw-r--r--core/os/main_loop.cpp27
3 files changed, 33 insertions, 6 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index a1031cf5f0..d0baae5872 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -56,6 +56,17 @@ String DirAccess::_get_root_string() const {
return "";
}
+int DirAccess::get_current_drive() {
+
+ String path = get_current_dir().to_lower();
+ for(int i=0;i<get_drive_count();i++) {
+ String d = get_drive(i).to_lower();
+ if (path.begins_with(d))
+ return i;
+ }
+
+ return 0;
+}
static Error _erase_recursive(DirAccess *da) {
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 3df9bca45a..8bacc96c60 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -84,6 +84,7 @@ public:
virtual int get_drive_count()=0;
virtual String get_drive(int p_drive)=0;
+ virtual int get_current_drive();
virtual Error change_dir(String p_dir)=0; ///< can be relative or absolute, return false on success
virtual String get_current_dir()=0; ///< return current dir location
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 83d3155b03..b4c02ddbce 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -31,7 +31,20 @@
void MainLoop::_bind_methods() {
- ObjectTypeDB::bind_method("input_event",&MainLoop::input_event);
+ ObjectTypeDB::bind_method(_MD("input_event","ev"),&MainLoop::input_event);
+ ObjectTypeDB::bind_method(_MD("input_text","text"),&MainLoop::input_text);
+ ObjectTypeDB::bind_method(_MD("init"),&MainLoop::init);
+ ObjectTypeDB::bind_method(_MD("iteration","delta"),&MainLoop::iteration);
+ ObjectTypeDB::bind_method(_MD("idle","delta"),&MainLoop::idle);
+ ObjectTypeDB::bind_method(_MD("finish"),&MainLoop::finish);
+
+ BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
+ BIND_VMETHOD( MethodInfo("_input_text",PropertyInfo(Variant::STRING,"text")) );
+ BIND_VMETHOD( MethodInfo("_initialize") );
+ BIND_VMETHOD( MethodInfo("_iteration",PropertyInfo(Variant::REAL,"delta")) );
+ BIND_VMETHOD( MethodInfo("_idle",PropertyInfo(Variant::REAL,"delta")) );
+ BIND_VMETHOD( MethodInfo("_finalize") );
+
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN);
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
@@ -58,13 +71,15 @@ MainLoop::~MainLoop()
void MainLoop::input_text( const String& p_text ) {
+ if (get_script_instance())
+ get_script_instance()->call("_input_text",p_text);
}
void MainLoop::input_event( const InputEvent& p_event ) {
if (get_script_instance())
- get_script_instance()->call("input_event",p_event);
+ get_script_instance()->call("_input_event",p_event);
}
@@ -74,13 +89,13 @@ void MainLoop::init() {
set_script(init_script.get_ref_ptr());
if (get_script_instance())
- get_script_instance()->call("init");
+ get_script_instance()->call("_initialize");
}
bool MainLoop::iteration(float p_time) {
if (get_script_instance())
- return get_script_instance()->call("iteration",p_time);
+ return get_script_instance()->call("_iteration",p_time);
return false;
@@ -88,14 +103,14 @@ bool MainLoop::iteration(float p_time) {
bool MainLoop::idle(float p_time) {
if (get_script_instance())
- return get_script_instance()->call("idle",p_time);
+ return get_script_instance()->call("_idle",p_time);
return false;
}
void MainLoop::finish() {
if (get_script_instance()) {
- get_script_instance()->call("finish");
+ get_script_instance()->call("_finalize");
set_script(RefPtr()); //clear script
}