summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp12
-rw-r--r--core/os/file_access.cpp28
-rw-r--r--core/os/file_access.h3
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/input.h2
-rw-r--r--core/os/main_loop.cpp1
-rw-r--r--core/os/main_loop.h1
-rw-r--r--core/os/os.h4
8 files changed, 42 insertions, 11 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index daa3eacd5f..8f4f2b6920 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -349,9 +349,9 @@ class DirChanger {
String original_dir;
public:
- DirChanger(DirAccess *p_da, String p_dir) {
- da = p_da;
- original_dir = p_da->get_current_dir();
+ DirChanger(DirAccess *p_da, String p_dir) :
+ da(p_da),
+ original_dir(p_da->get_current_dir()) {
p_da->change_dir(p_dir);
}
@@ -431,8 +431,12 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
ERR_FAIL_COND_V(err, err);
}
+ if (!p_to.ends_with("/")) {
+ p_to = p_to + "/";
+ }
+
DirChanger dir_changer(this, p_from);
- Error err = _copy_dir(target_da, p_to + "/", p_chmod_flags);
+ Error err = _copy_dir(target_da, p_to, p_chmod_flags);
memdelete(target_da);
return err;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index e09e5e16ad..679b1c9054 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -346,9 +346,9 @@ String FileAccess::get_line() const {
return String::utf8(line.get_data());
}
-Vector<String> FileAccess::get_csv_line(String delim) const {
+Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
- ERR_FAIL_COND_V(delim.length() != 1, Vector<String>());
+ ERR_FAIL_COND_V(p_delim.length() != 1, Vector<String>());
String l;
int qc = 0;
@@ -376,7 +376,7 @@ Vector<String> FileAccess::get_csv_line(String delim) const {
CharType c = l[i];
CharType s[2] = { 0, 0 };
- if (!in_quote && c == delim[0]) {
+ if (!in_quote && c == p_delim[0]) {
strings.push_back(current);
current = String();
} else if (c == '"') {
@@ -525,6 +525,28 @@ void FileAccess::store_line(const String &p_line) {
store_8('\n');
}
+void FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_delim) {
+
+ ERR_FAIL_COND(p_delim.length() != 1);
+
+ String line = "";
+ int size = p_values.size();
+ for (int i = 0; i < size; ++i) {
+ String value = p_values[i];
+
+ if (value.find("\"") != -1 || value.find(p_delim) != -1 || value.find("\n") != -1) {
+ value = "\"" + value.replace("\"", "\"\"") + "\"";
+ }
+ if (i < size - 1) {
+ value += p_delim;
+ }
+
+ line += value;
+ }
+
+ store_line(line);
+}
+
void FileAccess::store_buffer(const uint8_t *p_src, int p_length) {
for (int i = 0; i < p_length; i++)
diff --git a/core/os/file_access.h b/core/os/file_access.h
index b7d93e9f5d..f1f3005dd9 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -112,7 +112,7 @@ public:
virtual int get_buffer(uint8_t *p_dst, int p_length) const; ///< get an array of bytes
virtual String get_line() const;
virtual String get_token() const;
- virtual Vector<String> get_csv_line(String delim = ",") const;
+ virtual Vector<String> get_csv_line(const String &p_delim = ",") const;
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
* It's not about the current CPU type but file formats.
@@ -136,6 +136,7 @@ public:
virtual void store_string(const String &p_string);
virtual void store_line(const String &p_line);
+ virtual void store_csv_line(const Vector<String> &p_values, const String &p_delim = ",");
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 4cd1f0b24a..3b895b16b4 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -86,7 +86,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
- ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press);
+ ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
diff --git a/core/os/input.h b/core/os/input.h
index db523d6789..dc2c213db2 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -113,7 +113,7 @@ public:
virtual Vector3 get_magnetometer() const = 0;
virtual Vector3 get_gyroscope() const = 0;
- virtual void action_press(const StringName &p_action) = 0;
+ virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
virtual void action_release(const StringName &p_action) = 0;
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 0945cdd512..6e0b914367 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -60,6 +60,7 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
BIND_CONSTANT(NOTIFICATION_CRASH);
+ BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE);
};
void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 43f74302a8..e9b331ee45 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -65,6 +65,7 @@ public:
NOTIFICATION_TRANSLATION_CHANGED = 90,
NOTIFICATION_WM_ABOUT = 91,
NOTIFICATION_CRASH = 92,
+ NOTIFICATION_OS_IME_UPDATE = 93,
};
virtual void input_event(const Ref<InputEvent> &p_event);
diff --git a/core/os/os.h b/core/os/os.h
index 7786ffb26e..05ec3ac424 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -242,7 +242,8 @@ public:
virtual void set_ime_active(const bool p_active) {}
virtual void set_ime_position(const Point2 &p_pos) {}
- virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp) {}
+ virtual Point2 get_ime_selection() const { return Point2(); }
+ virtual String get_ime_text() const { return String(); }
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; }
virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; }
@@ -480,6 +481,7 @@ public:
enum EngineContext {
CONTEXT_EDITOR,
CONTEXT_PROJECTMAN,
+ CONTEXT_ENGINE,
};
virtual void set_context(int p_context);