Merge pull request #71838 from m4gr3d/fix_godot_editor_cropping_3x
[3.x] Update the logic to calculate the screen scale on Android
This commit is contained in:
commit
5a7997c794
2 changed files with 16 additions and 4 deletions
|
@ -150,7 +150,6 @@ public class GodotIO {
|
|||
} else {
|
||||
selectedScaledDensity = 0.75f;
|
||||
}
|
||||
Log.d(TAG, "Selected scaled density: " + selectedScaledDensity);
|
||||
return selectedScaledDensity;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#include "tts_android.h"
|
||||
|
||||
const char *OS_Android::ANDROID_EXEC_PATH = "apk";
|
||||
static const int DEFAULT_WINDOW_WIDTH = 800;
|
||||
static const int DEFAULT_WINDOW_HEIGHT = 600;
|
||||
|
||||
String _remove_symlink(const String &dir) {
|
||||
// Workaround for Android 6.0+ using a symlink.
|
||||
|
@ -530,7 +532,18 @@ int OS_Android::get_screen_dpi(int p_screen) const {
|
|||
}
|
||||
|
||||
float OS_Android::get_screen_scale(int p_screen) const {
|
||||
return godot_io_java->get_scaled_density();
|
||||
float screen_scale = godot_io_java->get_scaled_density();
|
||||
|
||||
// Update the scale to avoid cropping.
|
||||
Vector2 screen_size = get_window_size();
|
||||
if (screen_size != Vector2()) {
|
||||
float width_scale = screen_size.width / (float)DEFAULT_WINDOW_WIDTH;
|
||||
float height_scale = screen_size.height / (float)DEFAULT_WINDOW_HEIGHT;
|
||||
screen_scale = MIN(screen_scale, MIN(width_scale, height_scale));
|
||||
}
|
||||
|
||||
print_line("Selected screen scale: " + rtos(screen_scale));
|
||||
return screen_scale;
|
||||
}
|
||||
|
||||
float OS_Android::get_screen_max_scale() const {
|
||||
|
@ -679,8 +692,8 @@ bool OS_Android::_check_internal_feature_support(const String &p_feature) {
|
|||
|
||||
OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion) {
|
||||
use_apk_expansion = p_use_apk_expansion;
|
||||
default_videomode.width = 800;
|
||||
default_videomode.height = 600;
|
||||
default_videomode.width = DEFAULT_WINDOW_WIDTH;
|
||||
default_videomode.height = DEFAULT_WINDOW_HEIGHT;
|
||||
default_videomode.fullscreen = true;
|
||||
default_videomode.resizable = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue