|
@@ -44,6 +44,67 @@ const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="ut
|
|
</resources>
|
|
</resources>
|
|
)";
|
|
)";
|
|
|
|
|
|
|
|
+DisplayServer::ScreenOrientation _get_screen_orientation() {
|
|
|
|
+ String orientation_settings = ProjectSettings::get_singleton()->get("display/window/handheld/orientation");
|
|
|
|
+ DisplayServer::ScreenOrientation screen_orientation;
|
|
|
|
+ if (orientation_settings == "portrait")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_PORTRAIT;
|
|
|
|
+ else if (orientation_settings == "reverse_landscape")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_REVERSE_LANDSCAPE;
|
|
|
|
+ else if (orientation_settings == "reverse_portrait")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_REVERSE_PORTRAIT;
|
|
|
|
+ else if (orientation_settings == "sensor_landscape")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_SENSOR_LANDSCAPE;
|
|
|
|
+ else if (orientation_settings == "sensor_portrait")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_SENSOR_PORTRAIT;
|
|
|
|
+ else if (orientation_settings == "sensor")
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_SENSOR;
|
|
|
|
+ else
|
|
|
|
+ screen_orientation = DisplayServer::SCREEN_LANDSCAPE;
|
|
|
|
+
|
|
|
|
+ return screen_orientation;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int _get_android_orientation_value(DisplayServer::ScreenOrientation screen_orientation) {
|
|
|
|
+ switch (screen_orientation) {
|
|
|
|
+ case DisplayServer::SCREEN_PORTRAIT:
|
|
|
|
+ return 1;
|
|
|
|
+ case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
|
|
|
|
+ return 8;
|
|
|
|
+ case DisplayServer::SCREEN_REVERSE_PORTRAIT:
|
|
|
|
+ return 9;
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
|
|
|
|
+ return 11;
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR_PORTRAIT:
|
|
|
|
+ return 12;
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR:
|
|
|
|
+ return 13;
|
|
|
|
+ case DisplayServer::SCREEN_LANDSCAPE:
|
|
|
|
+ default:
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_orientation) {
|
|
|
|
+ switch (screen_orientation) {
|
|
|
|
+ case DisplayServer::SCREEN_PORTRAIT:
|
|
|
|
+ return "portrait";
|
|
|
|
+ case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
|
|
|
|
+ return "reverseLandscape";
|
|
|
|
+ case DisplayServer::SCREEN_REVERSE_PORTRAIT:
|
|
|
|
+ return "reversePortrait";
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
|
|
|
|
+ return "userLandscape";
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR_PORTRAIT:
|
|
|
|
+ return "userPortrait";
|
|
|
|
+ case DisplayServer::SCREEN_SENSOR:
|
|
|
|
+ return "fullUser";
|
|
|
|
+ case DisplayServer::SCREEN_LANDSCAPE:
|
|
|
|
+ default:
|
|
|
|
+ return "landscape";
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// Utility method used to create a directory.
|
|
// Utility method used to create a directory.
|
|
Error create_directory(const String &p_dir) {
|
|
Error create_directory(const String &p_dir) {
|
|
if (!DirAccess::exists(p_dir)) {
|
|
if (!DirAccess::exists(p_dir)) {
|
|
@@ -209,7 +270,7 @@ String _get_plugins_tag(const String &plugins_names) {
|
|
|
|
|
|
String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
|
|
String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
|
|
bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
|
|
bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
|
|
- String orientation = (int)(p_preset->get("screen/orientation")) == 1 ? "portrait" : "landscape";
|
|
|
|
|
|
+ String orientation = _get_android_orientation_label(_get_screen_orientation());
|
|
String manifest_activity_text = vformat(
|
|
String manifest_activity_text = vformat(
|
|
" <activity android:name=\"com.godot.game.GodotApp\" "
|
|
" <activity android:name=\"com.godot.game.GodotApp\" "
|
|
"tools:replace=\"android:screenOrientation\" "
|
|
"tools:replace=\"android:screenOrientation\" "
|