mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 20:13:07 +01:00
Upgrade platform_get_default_scale()
This commit is contained in:
@@ -202,7 +202,7 @@ namespace Config
|
||||
model->disable_lightning_effect = reader->GetBoolean("disable_lightning_effect", false);
|
||||
model->allow_loading_with_incorrect_checksum = reader->GetBoolean("allow_loading_with_incorrect_checksum", true);
|
||||
model->steam_overlay_pause = reader->GetBoolean("steam_overlay_pause", true);
|
||||
model->window_scale = reader->GetFloat("window_scale", platform_get_default_scale());
|
||||
model->window_scale = reader->GetFloat("window_scale", Platform::GetDefaultScale());
|
||||
model->scale_quality = reader->GetEnum<ScaleQuality>(
|
||||
"scale_quality", ScaleQuality::SmoothNearestNeighbour, Enum_ScaleQuality);
|
||||
model->show_fps = reader->GetBoolean("show_fps", false);
|
||||
|
||||
@@ -18,22 +18,6 @@
|
||||
# include <jni.h>
|
||||
# include <wchar.h>
|
||||
|
||||
float platform_get_default_scale()
|
||||
{
|
||||
JNIEnv* env = static_cast<JNIEnv*>(SDL_AndroidGetJNIEnv());
|
||||
|
||||
jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
|
||||
jclass activityClass = env->GetObjectClass(activity);
|
||||
jmethodID getDefaultScale = env->GetMethodID(activityClass, "getDefaultScale", "()F");
|
||||
|
||||
jfloat displayScale = env->CallFloatMethod(activity, getDefaultScale);
|
||||
|
||||
env->DeleteLocalRef(activity);
|
||||
env->DeleteLocalRef(activityClass);
|
||||
|
||||
return displayScale;
|
||||
}
|
||||
|
||||
AndroidClassLoader::AndroidClassLoader()
|
||||
{
|
||||
log_info("Obtaining JNI class loader");
|
||||
|
||||
@@ -83,6 +83,22 @@ namespace Platform
|
||||
return "";
|
||||
}
|
||||
# endif
|
||||
|
||||
float GetDefaultScale()
|
||||
{
|
||||
JNIEnv* env = static_cast<JNIEnv*>(SDL_AndroidGetJNIEnv());
|
||||
|
||||
jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
|
||||
jclass activityClass = env->GetObjectClass(activity);
|
||||
jmethodID getDefaultScale = env->GetMethodID(activityClass, "getDefaultScale", "()F");
|
||||
|
||||
jfloat displayScale = env->CallFloatMethod(activity, getDefaultScale);
|
||||
|
||||
env->DeleteLocalRef(activity);
|
||||
env->DeleteLocalRef(activityClass);
|
||||
|
||||
return displayScale;
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Platform
|
||||
bool FindApp(std::string_view app, std::string* output);
|
||||
int32_t Execute(std::string_view command, std::string* output = nullptr);
|
||||
bool ProcessIsElevated();
|
||||
float GetDefaultScale();
|
||||
|
||||
bool OriginalGameDataExists(std::string_view path);
|
||||
|
||||
|
||||
@@ -137,6 +137,13 @@ namespace Platform
|
||||
sanitised = String::Trim(sanitised);
|
||||
return sanitised;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
float GetDefaultScale()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
} // namespace Platform
|
||||
|
||||
GamePalette gPalette;
|
||||
@@ -208,13 +215,6 @@ void platform_sleep(uint32_t ms)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
float platform_get_default_scale()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void core_init()
|
||||
{
|
||||
static bool initialised = false;
|
||||
|
||||
@@ -103,8 +103,6 @@ std::string platform_get_rct2_steam_dir();
|
||||
|
||||
datetime64 platform_get_datetime_now_utc();
|
||||
|
||||
float platform_get_default_scale();
|
||||
|
||||
// Called very early in the program before parsing commandline arguments.
|
||||
void core_init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user