aboutsummaryrefslogtreecommitdiff
path: root/extension/src/Utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/Utilities.cpp')
-rw-r--r--extension/src/Utilities.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/extension/src/Utilities.cpp b/extension/src/Utilities.cpp
new file mode 100644
index 0000000..a912490
--- /dev/null
+++ b/extension/src/Utilities.cpp
@@ -0,0 +1,16 @@
+#include "Utilities.hpp"
+
+#include <godot_cpp/classes/resource_loader.hpp>
+#include <godot_cpp/variant/utility_functions.hpp>
+
+using namespace godot;
+using namespace OpenVic;
+
+Ref<Image> OpenVic::load_godot_image(String const& path) {
+ if (path.begins_with("res://")) {
+ ResourceLoader* loader = ResourceLoader::get_singleton();
+ return loader ? loader->load(path) : nullptr;
+ } else {
+ return Image::load_from_file(path);
+ }
+}