summaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
authorGeorge L. Albany <Megacake1234@gmail.com>2024-11-27 21:15:49 +0000
committerGitHub <noreply@github.com>2024-11-27 21:15:49 +0000
commit85d87116e184e7923b8d6804cab2681b61c62d83 (patch)
tree55ec5bfa061a5c27272b831e697b78ed1b756a70 /platform
parentb06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (diff)
parent721f53fde47c2727d99e3ecccdb789a67df36de0 (diff)
downloadredot-engine-master.tar.gz
Merge pull request #886 from Spartan322/merge/f128f38HEADmaster
Merge commit godotengine/godot@f128f38
Diffstat (limited to 'platform')
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt2
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java2
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotHost.java2
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/io/FilePicker.kt46
-rw-r--r--platform/android/os_android.cpp3
-rw-r--r--platform/web/emscripten_helpers.py1
-rw-r--r--platform/windows/display_server_windows.cpp4
-rw-r--r--platform/windows/display_server_windows.h4
-rw-r--r--platform/windows/os_windows.cpp3
9 files changed, 60 insertions, 7 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index 0a424a7c6a..89d029eaed 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -1125,7 +1125,7 @@ class Godot(private val context: Context) {
@Keep
private fun createNewGodotInstance(args: Array<String>): Int {
- return primaryHost?.onNewGodotInstanceRequested(args) ?: 0
+ return primaryHost?.onNewGodotInstanceRequested(args) ?: -1
}
@Keep
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java b/platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java
index 80812f6e41..f82061b9ee 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java
@@ -476,7 +476,7 @@ public class GodotFragment extends Fragment implements IDownloaderClient, GodotH
if (parentHost != null) {
return parentHost.onNewGodotInstanceRequested(args);
}
- return 0;
+ return -1;
}
@Override
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java b/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java
index 97fbe203ba..7c75e9ffbf 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java
@@ -94,7 +94,7 @@ public interface GodotHost {
* @return the id of the new instance. See {@code onGodotForceQuit}
*/
default int onNewGodotInstanceRequested(String[] args) {
- return 0;
+ return -1;
}
/**
diff --git a/platform/android/java/lib/src/org/godotengine/godot/io/FilePicker.kt b/platform/android/java/lib/src/org/godotengine/godot/io/FilePicker.kt
index 2befe0583b..19fb452892 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/io/FilePicker.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/io/FilePicker.kt
@@ -37,6 +37,7 @@ import android.net.Uri
import android.os.Build
import android.provider.DocumentsContract
import android.util.Log
+import android.webkit.MimeTypeMap
import androidx.annotation.RequiresApi
import org.godotengine.godot.GodotLib
import org.godotengine.godot.io.file.MediaStoreData
@@ -145,10 +146,11 @@ internal class FilePicker {
if (fileMode != FILE_MODE_OPEN_DIR) {
intent.type = "*/*"
if (filters.isNotEmpty()) {
- if (filters.size == 1) {
- intent.type = filters[0]
+ val resolvedFilters = filters.map { resolveMimeType(it) }.distinct()
+ if (resolvedFilters.size == 1) {
+ intent.type = resolvedFilters[0]
} else {
- intent.putExtra(Intent.EXTRA_MIME_TYPES, filters)
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, resolvedFilters.toTypedArray())
}
}
intent.addCategory(Intent.CATEGORY_OPENABLE)
@@ -156,5 +158,43 @@ internal class FilePicker {
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true)
activity?.startActivityForResult(intent, FILE_PICKER_REQUEST)
}
+
+ /**
+ * Retrieves the MIME type for a given file extension.
+ *
+ * @param ext the extension whose MIME type is to be determined.
+ * @return the MIME type as a string, or "application/octet-stream" if the type is unknown.
+ */
+ private fun resolveMimeType(ext: String): String {
+ val mimeTypeMap = MimeTypeMap.getSingleton()
+ var input = ext
+
+ // Fix for extensions like "*.txt" or ".txt".
+ if (ext.contains(".")) {
+ input = ext.substring(ext.indexOf(".") + 1);
+ }
+
+ // Check if the input is already a valid MIME type.
+ if (mimeTypeMap.hasMimeType(input)) {
+ return input
+ }
+
+ val resolvedMimeType = mimeTypeMap.getMimeTypeFromExtension(input)
+ if (resolvedMimeType != null) {
+ return resolvedMimeType
+ }
+ // Check for wildcard MIME types like "image/*".
+ if (input.contains("/*")) {
+ val category = input.substringBefore("/*")
+ return when (category) {
+ "image" -> "image/*"
+ "video" -> "video/*"
+ "audio" -> "audio/*"
+ else -> "application/octet-stream"
+ }
+ }
+ // Fallback to a generic MIME type if the input is neither a valid extension nor MIME type.
+ return "application/octet-stream"
+ }
}
}
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index aa22f970ff..da66442736 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -865,6 +865,9 @@ Error OS_Android::create_process(const String &p_path, const List<String> &p_arg
Error OS_Android::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) {
int instance_id = godot_java->create_new_godot_instance(p_arguments);
+ if (instance_id == -1) {
+ return FAILED;
+ }
if (r_child_id) {
*r_child_id = instance_id;
}
diff --git a/platform/web/emscripten_helpers.py b/platform/web/emscripten_helpers.py
index aca5d4ecba..6a3855da84 100644
--- a/platform/web/emscripten_helpers.py
+++ b/platform/web/emscripten_helpers.py
@@ -71,6 +71,7 @@ def create_template_zip(env, js, wasm, side):
"___GODOT_OPT_CACHE___": json.dumps(opt_cache),
"___GODOT_OFFLINE_PAGE___": "offline.html",
"___GODOT_THREADS_ENABLED___": "true" if env["threads"] else "false",
+ "___GODOT_ENSURE_CROSSORIGIN_ISOLATION_HEADERS___": "true",
}
html = env.Substfile(target="#bin/godot${PROGSUFFIX}.html", source=html, SUBST_DICT=subst_dict)
in_files.append(html)
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 8f27889382..8a0402a7eb 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2169,6 +2169,10 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_initiali
r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
r_style_ex |= WS_EX_ACCEPTFILES;
+
+ if (OS::get_singleton()->get_current_rendering_driver_name() == "d3d12") {
+ r_style_ex |= WS_EX_NOREDIRECTIONBITMAP;
+ }
}
void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint) {
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 020b0a7636..df8ed3412a 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -358,6 +358,10 @@ typedef enum _SHC_PROCESS_DPI_AWARENESS {
SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2,
} SHC_PROCESS_DPI_AWARENESS;
+#ifndef WS_EX_NOREDIRECTIONBITMAP
+#define WS_EX_NOREDIRECTIONBITMAP 0x00200000L
+#endif
+
class DropTargetWindows;
class DisplayServerWindows : public DisplayServer {
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index dbd68e56ec..43625b5726 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1530,7 +1530,8 @@ DWRITE_FONT_STRETCH OS_Windows::_stretch_to_dw(int p_stretch) const {
}
Vector<String> OS_Windows::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
- if (!dwrite2_init) {
+ // This may be called before TextServerManager has been created, which would cause a crash downstream if we do not check here
+ if (!dwrite2_init || !TextServerManager::get_singleton()) {
return Vector<String>();
}