Merge pull request #59868 from m4gr3d/update_default_display_scale
This commit is contained in:
commit
5f9ae5e936
8 changed files with 46 additions and 2 deletions
|
@ -1463,7 +1463,7 @@ String EditorSettings::get_editor_layouts_config() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
float EditorSettings::get_auto_display_scale() const {
|
float EditorSettings::get_auto_display_scale() const {
|
||||||
#ifdef OSX_ENABLED
|
#if defined(OSX_ENABLED) || defined(ANDROID_ENABLED)
|
||||||
return OS::get_singleton()->get_screen_max_scale();
|
return OS::get_singleton()->get_screen_max_scale();
|
||||||
#else
|
#else
|
||||||
const int screen = OS::get_singleton()->get_current_screen();
|
const int screen = OS::get_singleton()->get_current_screen();
|
||||||
|
|
|
@ -107,4 +107,18 @@ public class GodotEditor extends FullScreenGodotApp {
|
||||||
Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args);
|
Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args);
|
||||||
startActivity(newInstance);
|
startActivity(newInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRequestedOrientation(int requestedOrientation) {
|
||||||
|
if (!overrideOrientationRequest()) {
|
||||||
|
super.setRequestedOrientation(requestedOrientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Godot Android Editor sets its own orientation via its AndroidManifest
|
||||||
|
*/
|
||||||
|
protected boolean overrideOrientationRequest() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,7 @@ package org.godotengine.editor;
|
||||||
* Drives the 'run project' window of the Godot Editor.
|
* Drives the 'run project' window of the Godot Editor.
|
||||||
*/
|
*/
|
||||||
public class GodotGame extends GodotEditor {
|
public class GodotGame extends GodotEditor {
|
||||||
|
protected boolean overrideOrientationRequest() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,10 +222,14 @@ public class GodotIO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScreenDPI() {
|
public int getScreenDPI() {
|
||||||
DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics();
|
DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
|
||||||
return (int)(metrics.density * 160f);
|
return (int)(metrics.density * 160f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getScaledDensity() {
|
||||||
|
return activity.getResources().getDisplayMetrics().scaledDensity;
|
||||||
|
}
|
||||||
|
|
||||||
public double getScreenRefreshRate(double fallback) {
|
public double getScreenRefreshRate(double fallback) {
|
||||||
Display display = activity.getWindowManager().getDefaultDisplay();
|
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc
|
||||||
_get_locale = p_env->GetMethodID(cls, "getLocale", "()Ljava/lang/String;");
|
_get_locale = p_env->GetMethodID(cls, "getLocale", "()Ljava/lang/String;");
|
||||||
_get_model = p_env->GetMethodID(cls, "getModel", "()Ljava/lang/String;");
|
_get_model = p_env->GetMethodID(cls, "getModel", "()Ljava/lang/String;");
|
||||||
_get_screen_DPI = p_env->GetMethodID(cls, "getScreenDPI", "()I");
|
_get_screen_DPI = p_env->GetMethodID(cls, "getScreenDPI", "()I");
|
||||||
|
_get_scaled_density = p_env->GetMethodID(cls, "getScaledDensity", "()F");
|
||||||
_get_screen_refresh_rate = p_env->GetMethodID(cls, "getScreenRefreshRate", "(D)D");
|
_get_screen_refresh_rate = p_env->GetMethodID(cls, "getScreenRefreshRate", "(D)D");
|
||||||
_get_window_safe_area = p_env->GetMethodID(cls, "getWindowSafeArea", "()[I"),
|
_get_window_safe_area = p_env->GetMethodID(cls, "getWindowSafeArea", "()[I"),
|
||||||
_get_unique_id = p_env->GetMethodID(cls, "getUniqueID", "()Ljava/lang/String;");
|
_get_unique_id = p_env->GetMethodID(cls, "getUniqueID", "()Ljava/lang/String;");
|
||||||
|
@ -137,6 +138,16 @@ int GodotIOJavaWrapper::get_screen_dpi() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GodotIOJavaWrapper::get_scaled_density() {
|
||||||
|
if (_get_scaled_density) {
|
||||||
|
JNIEnv *env = get_jni_env();
|
||||||
|
ERR_FAIL_COND_V(env == nullptr, 1.0f);
|
||||||
|
return env->CallFloatMethod(godot_io_instance, _get_scaled_density);
|
||||||
|
} else {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float GodotIOJavaWrapper::get_screen_refresh_rate(float p_fallback) {
|
float GodotIOJavaWrapper::get_screen_refresh_rate(float p_fallback) {
|
||||||
if (_get_screen_refresh_rate) {
|
if (_get_screen_refresh_rate) {
|
||||||
JNIEnv *env = get_jni_env();
|
JNIEnv *env = get_jni_env();
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
jmethodID _get_locale = 0;
|
jmethodID _get_locale = 0;
|
||||||
jmethodID _get_model = 0;
|
jmethodID _get_model = 0;
|
||||||
jmethodID _get_screen_DPI = 0;
|
jmethodID _get_screen_DPI = 0;
|
||||||
|
jmethodID _get_scaled_density = 0;
|
||||||
jmethodID _get_screen_refresh_rate = 0;
|
jmethodID _get_screen_refresh_rate = 0;
|
||||||
jmethodID _get_window_safe_area = 0;
|
jmethodID _get_window_safe_area = 0;
|
||||||
jmethodID _get_unique_id = 0;
|
jmethodID _get_unique_id = 0;
|
||||||
|
@ -72,6 +73,7 @@ public:
|
||||||
String get_locale();
|
String get_locale();
|
||||||
String get_model();
|
String get_model();
|
||||||
int get_screen_dpi();
|
int get_screen_dpi();
|
||||||
|
float get_scaled_density();
|
||||||
void get_window_safe_area(int (&p_rect_xywh)[4]);
|
void get_window_safe_area(int (&p_rect_xywh)[4]);
|
||||||
float get_screen_refresh_rate(float p_fallback);
|
float get_screen_refresh_rate(float p_fallback);
|
||||||
String get_unique_id();
|
String get_unique_id();
|
||||||
|
|
|
@ -472,6 +472,14 @@ int OS_Android::get_screen_dpi(int p_screen) const {
|
||||||
return godot_io_java->get_screen_dpi();
|
return godot_io_java->get_screen_dpi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float OS_Android::get_screen_scale(int p_screen) const {
|
||||||
|
return godot_io_java->get_scaled_density();
|
||||||
|
}
|
||||||
|
|
||||||
|
float OS_Android::get_screen_max_scale() const {
|
||||||
|
return get_screen_scale();
|
||||||
|
}
|
||||||
|
|
||||||
float OS_Android::get_screen_refresh_rate(int p_screen) const {
|
float OS_Android::get_screen_refresh_rate(int p_screen) const {
|
||||||
return godot_io_java->get_screen_refresh_rate(OS::get_singleton()->SCREEN_REFRESH_RATE_FALLBACK);
|
return godot_io_java->get_screen_refresh_rate(OS::get_singleton()->SCREEN_REFRESH_RATE_FALLBACK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ public:
|
||||||
virtual bool has_clipboard() const;
|
virtual bool has_clipboard() const;
|
||||||
virtual String get_model_name() const;
|
virtual String get_model_name() const;
|
||||||
virtual int get_screen_dpi(int p_screen = 0) const;
|
virtual int get_screen_dpi(int p_screen = 0) const;
|
||||||
|
virtual float get_screen_scale(int p_screen = -1) const;
|
||||||
|
virtual float get_screen_max_scale() const;
|
||||||
virtual float get_screen_refresh_rate(int p_screen = 0) const;
|
virtual float get_screen_refresh_rate(int p_screen = 0) const;
|
||||||
|
|
||||||
virtual bool get_window_per_pixel_transparency_enabled() const { return transparency_enabled; }
|
virtual bool get_window_per_pixel_transparency_enabled() const { return transparency_enabled; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue