mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-19 22:24:23 +01:00
Ported: Update the editor display scale based on the device's scaled density - m4gr3d
3ba0508f79
This commit is contained in:
parent
220b7e99be
commit
15b447d880
@ -30,37 +30,37 @@
|
||||
|
||||
#include "editor_settings.h"
|
||||
|
||||
#include "core/io/certs_compressed.gen.h"
|
||||
#include "core/io/config_file.h"
|
||||
#include "core/io/ip.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "editor/editor_translation.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "core/array.h"
|
||||
#include "core/class_db.h"
|
||||
#include "core/color.h"
|
||||
#include "core/dictionary.h"
|
||||
#include "core/error_list.h"
|
||||
#include "core/error_macros.h"
|
||||
#include "core/io/certs_compressed.gen.h"
|
||||
#include "core/io/config_file.h"
|
||||
#include "core/io/ip.h"
|
||||
#include "core/io/ip_address.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/os/input_event.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/main_loop.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/print_string.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/set.h"
|
||||
#include "core/translation.h"
|
||||
#include "core/typedefs.h"
|
||||
#include "core/version_generated.gen.h"
|
||||
#include "editor/editor_translation.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
// PRIVATE METHODS
|
||||
|
||||
@ -1470,7 +1470,7 @@ String EditorSettings::get_editor_layouts_config() 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();
|
||||
#else
|
||||
const int screen = OS::get_singleton()->get_current_screen();
|
||||
|
@ -107,4 +107,19 @@ public class PandemoniumEditor extends FullScreenPandemoniumApp {
|
||||
Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args);
|
||||
startActivity(newInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequestedOrientation(int requestedOrientation) {
|
||||
if (!overrideOrientationRequest()) {
|
||||
super.setRequestedOrientation(requestedOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Android Editor sets its own orientation via its AndroidManifest
|
||||
*/
|
||||
protected boolean overrideOrientationRequest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,4 +34,7 @@ package net.relintai.pandemonium.editor;
|
||||
* Drives the 'run project' window of the Pandemonium Editor.
|
||||
*/
|
||||
public class PandemoniumGame extends PandemoniumEditor {
|
||||
}
|
||||
protected boolean overrideOrientationRequest() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -222,10 +222,14 @@ public class PandemoniumIO {
|
||||
}
|
||||
|
||||
public int getScreenDPI() {
|
||||
DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics();
|
||||
DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
|
||||
return (int)(metrics.density * 160f);
|
||||
}
|
||||
|
||||
public float getScaledDensity() {
|
||||
return activity.getResources().getDisplayMetrics().scaledDensity;
|
||||
}
|
||||
|
||||
public double getScreenRefreshRate(double fallback) {
|
||||
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
if (display != null) {
|
||||
|
@ -137,6 +137,16 @@ int PandemoniumIOJavaWrapper::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 PandemoniumIOJavaWrapper::get_screen_refresh_rate(float p_fallback) {
|
||||
if (_get_screen_refresh_rate) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
|
@ -50,6 +50,7 @@ private:
|
||||
jmethodID _get_locale = 0;
|
||||
jmethodID _get_model = 0;
|
||||
jmethodID _get_screen_DPI = 0;
|
||||
jmethodID _get_scaled_density = 0;
|
||||
jmethodID _get_screen_refresh_rate = 0;
|
||||
jmethodID _get_window_safe_area = 0;
|
||||
jmethodID _get_unique_id = 0;
|
||||
@ -71,6 +72,7 @@ public:
|
||||
String get_locale();
|
||||
String get_model();
|
||||
int get_screen_dpi();
|
||||
float get_scaled_density();
|
||||
void get_window_safe_area(int (&p_rect_xywh)[4]);
|
||||
float get_screen_refresh_rate(float p_fallback);
|
||||
String get_unique_id();
|
||||
|
@ -457,6 +457,14 @@ int OS_Android::get_screen_dpi(int p_screen) const {
|
||||
return pandemonium_io_java->get_screen_dpi();
|
||||
}
|
||||
|
||||
float OS_Android::get_screen_scale(int p_screen) const {
|
||||
return pandemonium_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 {
|
||||
return pandemonium_io_java->get_screen_refresh_rate(OS::get_singleton()->SCREEN_REFRESH_RATE_FALLBACK);
|
||||
}
|
||||
|
@ -157,6 +157,8 @@ public:
|
||||
virtual bool has_clipboard() const;
|
||||
virtual String get_model_name() 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 bool get_window_per_pixel_transparency_enabled() const { return transparency_enabled; }
|
||||
|
Loading…
Reference in New Issue
Block a user