aboutsummaryrefslogtreecommitdiff
path: root/extension/src/Utilities.cpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-05-26 00:23:57 +0200
committer GitHub <noreply@github.com>2023-05-26 00:23:57 +0200
commitba3e974f30b8a2e7611b753ddc274dec8ff28283 (patch)
tree31d37e00cf6c010180fb3212b45ac5f70728cc8f /extension/src/Utilities.cpp
parent0a1a50cde54fee469bc0069978cd27a2bd1a2fb0 (diff)
parent9843807154aa70324c84692ce9d3b54414e2b5e0 (diff)
Merge pull request #125 from OpenVicProject/import-fix
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);
+ }
+}