Use an enum to represent screen orientation in the Project Settings
- Tweak the setting property hint to be more informative. - Make the setting a "basic" setting so it appears when Advanced Settings is disabled. - Remove redundant orientation setting in the iOS export preset. The project setting is now used (like on Android). Projects upgrading from a previous version will have to set the screen orientation again in the Project Settings if it wasn't set to the default value ("landscape").
This commit is contained in:
parent
2362a59a11
commit
660952a857
7 changed files with 44 additions and 60 deletions
|
@ -1114,7 +1114,8 @@ ProjectSettings::ProjectSettings() {
|
|||
|
||||
_add_builtin_input_map();
|
||||
|
||||
custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
|
||||
// Keep the enum values in sync with the `DisplayServer::ScreenOrientation` enum.
|
||||
custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::INT, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor");
|
||||
custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
|
||||
GLOBAL_DEF("physics/2d/run_on_thread", false);
|
||||
GLOBAL_DEF("physics/3d/run_on_thread", false);
|
||||
|
|
|
@ -494,8 +494,9 @@
|
|||
<member name="display/window/energy_saving/keep_screen_on" type="bool" setter="" getter="" default="true">
|
||||
If [code]true[/code], keeps the screen on (even in case of inactivity), so the screensaver does not take over. Works on desktop and mobile platforms.
|
||||
</member>
|
||||
<member name="display/window/handheld/orientation" type="String" setter="" getter="" default=""landscape"">
|
||||
Default orientation on mobile devices.
|
||||
<member name="display/window/handheld/orientation" type="int" setter="" getter="" default="0">
|
||||
The default screen orientation to use on mobile devices. See [enum DisplayServer.ScreenOrientation] for possible values.
|
||||
[b]Note:[/b] When set to a portrait orientation, this project setting does not flip the project resolution's width and height automatically. Instead, you have to set [member display/window/size/width] and [member display/window/size/height] accordingly.
|
||||
</member>
|
||||
<member name="display/window/ios/hide_home_indicator" type="bool" setter="" getter="" default="true">
|
||||
If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button.
|
||||
|
|
|
@ -1327,23 +1327,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
}
|
||||
|
||||
{
|
||||
String orientation = GLOBAL_DEF("display/window/handheld/orientation", "landscape");
|
||||
|
||||
if (orientation == "portrait") {
|
||||
window_orientation = DisplayServer::SCREEN_PORTRAIT;
|
||||
} else if (orientation == "reverse_landscape") {
|
||||
window_orientation = DisplayServer::SCREEN_REVERSE_LANDSCAPE;
|
||||
} else if (orientation == "reverse_portrait") {
|
||||
window_orientation = DisplayServer::SCREEN_REVERSE_PORTRAIT;
|
||||
} else if (orientation == "sensor_landscape") {
|
||||
window_orientation = DisplayServer::SCREEN_SENSOR_LANDSCAPE;
|
||||
} else if (orientation == "sensor_portrait") {
|
||||
window_orientation = DisplayServer::SCREEN_SENSOR_PORTRAIT;
|
||||
} else if (orientation == "sensor") {
|
||||
window_orientation = DisplayServer::SCREEN_SENSOR;
|
||||
} else {
|
||||
window_orientation = DisplayServer::SCREEN_LANDSCAPE;
|
||||
}
|
||||
window_orientation = DisplayServer::ScreenOrientation(int(GLOBAL_DEF_BASIC("display/window/handheld/orientation", DisplayServer::ScreenOrientation::SCREEN_LANDSCAPE)));
|
||||
}
|
||||
|
||||
Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60));
|
||||
|
|
|
@ -847,7 +847,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
|
|||
int version_code = p_preset->get("version/code");
|
||||
String package_name = p_preset->get("package/unique_name");
|
||||
|
||||
const int screen_orientation = _get_android_orientation_value(_get_screen_orientation());
|
||||
const int screen_orientation =
|
||||
_get_android_orientation_value(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))));
|
||||
|
||||
bool screen_support_small = p_preset->get("screen/support_small");
|
||||
bool screen_support_normal = p_preset->get("screen/support_normal");
|
||||
|
|
|
@ -44,28 +44,6 @@ const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="ut
|
|||
</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:
|
||||
|
@ -266,7 +244,7 @@ String _get_instrumentation_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;
|
||||
String orientation = _get_android_orientation_label(_get_screen_orientation());
|
||||
String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))));
|
||||
String manifest_activity_text = vformat(
|
||||
" <activity android:name=\"com.godot.game.GodotApp\" "
|
||||
"tools:replace=\"android:screenOrientation\" "
|
||||
|
|
|
@ -378,11 +378,6 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
|
|||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), ""));
|
||||
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_left"), true));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_right"), true));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait_upside_down"), true));
|
||||
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "icons/generate_missing"), false));
|
||||
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone/iPod Touch with retina display
|
||||
|
@ -501,18 +496,39 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
|
|||
strnew += lines[i].replace("$required_device_capabilities", capabilities);
|
||||
} else if (lines[i].find("$interface_orientations") != -1) {
|
||||
String orientations;
|
||||
const DisplayServer::ScreenOrientation screen_orientation =
|
||||
DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")));
|
||||
|
||||
if ((bool)p_preset->get("orientation/portrait")) {
|
||||
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
|
||||
}
|
||||
if ((bool)p_preset->get("orientation/landscape_left")) {
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
|
||||
}
|
||||
if ((bool)p_preset->get("orientation/landscape_right")) {
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
|
||||
}
|
||||
if ((bool)p_preset->get("orientation/portrait_upside_down")) {
|
||||
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
|
||||
switch (screen_orientation) {
|
||||
case DisplayServer::SCREEN_LANDSCAPE:
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_PORTRAIT:
|
||||
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_REVERSE_PORTRAIT:
|
||||
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
|
||||
// Allow both landscape orientations depending on sensor direction.
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_SENSOR_PORTRAIT:
|
||||
// Allow both portrait orientations depending on sensor direction.
|
||||
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
|
||||
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
|
||||
break;
|
||||
case DisplayServer::SCREEN_SENSOR:
|
||||
// Allow all screen orientations depending on sensor direction.
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
|
||||
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
|
||||
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
|
||||
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
strnew += lines[i].replace("$interface_orientations", orientations);
|
||||
|
|
|
@ -175,6 +175,9 @@ public:
|
|||
return scale;
|
||||
}
|
||||
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||
|
||||
// Keep the ScreenOrientation enum values in sync with the `display/window/handheld/orientation`
|
||||
// project setting hint.
|
||||
enum ScreenOrientation {
|
||||
SCREEN_LANDSCAPE,
|
||||
SCREEN_PORTRAIT,
|
||||
|
|
Loading…
Reference in a new issue