From 603970064d5714da3c58eac0d9f95516b81d7892 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 14 Feb 2024 03:52:35 +0100 Subject: [PATCH] early-access version 4138 --- README.md | 2 +- .../features/settings/model/IntSetting.kt | 4 +- .../features/settings/model/Settings.kt | 11 +++++ .../settings/model/view/SettingsItem.kt | 19 ++++++++ .../settings/ui/SettingsFragmentPresenter.kt | 2 + .../yuzu/yuzu_emu/fragments/AddonsFragment.kt | 8 +++- .../yuzu_emu/fragments/EmulationFragment.kt | 45 ++++++++++++++++++- .../fragments/MessageDialogFragment.kt | 6 +-- .../app/src/main/jni/android_settings.h | 7 +++ .../app/src/main/res/values/arrays.xml | 11 +++++ .../app/src/main/res/values/strings.xml | 8 ++++ src/core/hle/service/set/settings_server.cpp | 2 +- src/core/hle/service/set/settings_server.h | 2 +- 13 files changed, 117 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8f78d6c36..4166e0658 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4137. +This is the source code for early-access 4138. ## Legal Notice diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt index 71be2d0b2..0165cb2d1 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt @@ -24,7 +24,9 @@ enum class IntSetting(override val key: String) : AbstractIntSetting { THEME_MODE("theme_mode"), OVERLAY_SCALE("control_scale"), OVERLAY_OPACITY("control_opacity"), - LOCK_DRAWER("lock_drawer"); + LOCK_DRAWER("lock_drawer"), + VERTICAL_ALIGNMENT("vertical_alignment"), + FSR_SHARPENING_SLIDER("fsr_sharpening_slider"); override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index fee80bb21..862c6c483 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt @@ -93,4 +93,15 @@ object Settings { entries.firstOrNull { it.int == int } ?: Unspecified } } + + enum class EmulationVerticalAlignment(val int: Int) { + Top(1), + Center(0), + Bottom(2); + + companion object { + fun from(int: Int): EmulationVerticalAlignment = + entries.firstOrNull { it.int == int } ?: Center + } + } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 12f7aa1ab..21ca97bc1 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt @@ -188,6 +188,16 @@ abstract class SettingsItem( R.array.rendererScalingFilterValues ) ) + put( + SliderSetting( + IntSetting.FSR_SHARPENING_SLIDER, + R.string.fsr_sharpness, + R.string.fsr_sharpness_description, + 0, + 100, + "%" + ) + ) put( SingleChoiceSetting( IntSetting.RENDERER_ANTI_ALIASING, @@ -215,6 +225,15 @@ abstract class SettingsItem( R.array.rendererAspectRatioValues ) ) + put( + SingleChoiceSetting( + IntSetting.VERTICAL_ALIGNMENT, + R.string.vertical_alignment, + 0, + R.array.verticalAlignmentEntries, + R.array.verticalAlignmentValues + ) + ) put( SwitchSetting( BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 2ad2f4966..db1a58147 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -143,10 +143,12 @@ class SettingsFragmentPresenter( add(IntSetting.RENDERER_RESOLUTION.key) add(IntSetting.RENDERER_VSYNC.key) add(IntSetting.RENDERER_SCALING_FILTER.key) + add(IntSetting.FSR_SHARPENING_SLIDER.key) add(IntSetting.RENDERER_ANTI_ALIASING.key) add(IntSetting.MAX_ANISOTROPY.key) add(IntSetting.RENDERER_SCREEN_LAYOUT.key) add(IntSetting.RENDERER_ASPECT_RATIO.key) + add(IntSetting.VERTICAL_ALIGNMENT.key) add(BooleanSetting.PICTURE_IN_PICTURE.key) add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key) add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt index f5647fa95..872553ac4 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt @@ -104,7 +104,10 @@ class AddonsFragment : Fragment() { requireActivity(), titleId = R.string.addon_notice, descriptionId = R.string.addon_notice_description, - positiveAction = { addonViewModel.showModInstallPicker(true) } + dismissible = false, + positiveAction = { addonViewModel.showModInstallPicker(true) }, + negativeAction = {}, + negativeButtonTitleId = R.string.close ).show(parentFragmentManager, MessageDialogFragment.TAG) addonViewModel.showModNoticeDialog(false) } @@ -119,7 +122,8 @@ class AddonsFragment : Fragment() { requireActivity(), titleId = R.string.confirm_uninstall, descriptionId = R.string.confirm_uninstall_description, - positiveAction = { addonViewModel.onDeleteAddon(it) } + positiveAction = { addonViewModel.onDeleteAddon(it) }, + negativeAction = {} ).show(parentFragmentManager, MessageDialogFragment.TAG) addonViewModel.setAddonToDelete(null) } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 44af896da..6b25cc525 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -15,7 +15,9 @@ import android.os.Handler import android.os.Looper import android.os.PowerManager import android.os.SystemClock +import android.util.Rational import android.view.* +import android.widget.FrameLayout import android.widget.TextView import android.widget.Toast import androidx.activity.OnBackPressedCallback @@ -24,6 +26,7 @@ import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.Insets import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat +import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout.DrawerListener @@ -52,6 +55,7 @@ import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting import org.yuzu.yuzu_emu.features.settings.model.IntSetting import org.yuzu.yuzu_emu.features.settings.model.Settings import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationOrientation +import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationVerticalAlignment import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.Game @@ -617,7 +621,46 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { } private fun updateScreenLayout() { - binding.surfaceEmulation.setAspectRatio(null) + val verticalAlignment = + EmulationVerticalAlignment.from(IntSetting.VERTICAL_ALIGNMENT.getInt()) + val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) { + 0 -> Rational(16, 9) + 1 -> Rational(4, 3) + 2 -> Rational(21, 9) + 3 -> Rational(16, 10) + else -> null // Best fit + } + when (verticalAlignment) { + EmulationVerticalAlignment.Top -> { + binding.surfaceEmulation.setAspectRatio(aspectRatio) + val params = FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL + binding.surfaceEmulation.layoutParams = params + } + + EmulationVerticalAlignment.Center -> { + binding.surfaceEmulation.setAspectRatio(null) + binding.surfaceEmulation.updateLayoutParams { + width = ViewGroup.LayoutParams.MATCH_PARENT + height = ViewGroup.LayoutParams.MATCH_PARENT + } + } + + EmulationVerticalAlignment.Bottom -> { + binding.surfaceEmulation.setAspectRatio(aspectRatio) + val params = + FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL + binding.surfaceEmulation.layoutParams = params + } + } + emulationState.updateSurface() emulationActivity?.buildPictureInPictureParams() updateOrientation() } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt index 685df0d59..c370964e1 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt @@ -42,9 +42,9 @@ class MessageDialogFragment : DialogFragment() { } else if (positiveButtonString.isNotEmpty()) { positiveButtonString } else if (messageDialogViewModel.positiveAction != null) { - getString(R.string.close) - } else { getString(android.R.string.ok) + } else { + getString(R.string.close) } val negativeButtonId = requireArguments().getInt(NEGATIVE_BUTTON_TITLE_ID) @@ -131,7 +131,7 @@ class MessageDialogFragment : DialogFragment() { * @param positiveButtonTitleId String resource ID that will be used for the positive button. * [positiveButtonTitleString] used if 0. * @param positiveButtonTitleString String that will be used for the positive button. - * android.R.string.ok used if empty. android.R.string.close will be used if [positiveAction] + * android.R.string.close used if empty. android.R.string.ok will be used if [positiveAction] * is not null. * @param positiveAction Lambda to run when the positive button is clicked. * @param showNegativeButton Normally the negative button isn't shown if there is no diff --git a/src/android/app/src/main/jni/android_settings.h b/src/android/app/src/main/jni/android_settings.h index 4a3bc8e53..00baf86a9 100755 --- a/src/android/app/src/main/jni/android_settings.h +++ b/src/android/app/src/main/jni/android_settings.h @@ -38,6 +38,13 @@ struct Values { Settings::Specialization::Default, true, true}; + Settings::Setting vertical_alignment{linkage, + 0, + "vertical_alignment", + Settings::Category::Android, + Settings::Specialization::Default, + true, + true}; Settings::SwitchableSetting driver_path{linkage, "", "driver_path", Settings::Category::GpuDriver}; diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 4701913eb..1bd6455b4 100755 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -292,4 +292,15 @@ 5 + + @string/top + @string/center + @string/bottom + + + 1 + 0 + 2 + + diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 489e00107..78a4c958a 100755 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -226,6 +226,8 @@ Orientation Aspect ratio Window adapting filter + FSR sharpness + Determines how sharpened the image will look while using FSR\'s dynamic contrast Anti-aliasing method Force maximum clocks (Adreno only) Forces the GPU to run at the maximum possible clocks (thermal constraints will still be applied). @@ -558,6 +560,12 @@ Mute Unmute + + Vertical alignment + Top + Center + Bottom + Licenses FidelityFX-FSR diff --git a/src/core/hle/service/set/settings_server.cpp b/src/core/hle/service/set/settings_server.cpp index 5cd9d6007..a9321b98d 100755 --- a/src/core/hle/service/set/settings_server.cpp +++ b/src/core/hle/service/set/settings_server.cpp @@ -155,7 +155,7 @@ Result ISettingsServer::GetRegionCode(Out out_region_code) { } Result ISettingsServer::GetAvailableLanguageCodes2( - Out out_count, OutArray language_codes) { + Out out_count, OutArray language_codes) { LOG_DEBUG(Service_SET, "called"); const std::size_t max_amount = std::min(POST_4_0_0_MAX_ENTRIES, language_codes.size()); diff --git a/src/core/hle/service/set/settings_server.h b/src/core/hle/service/set/settings_server.h index ac8aa3fc3..a39971fe9 100755 --- a/src/core/hle/service/set/settings_server.h +++ b/src/core/hle/service/set/settings_server.h @@ -34,7 +34,7 @@ private: Result GetRegionCode(Out out_region_code); Result GetAvailableLanguageCodes2( - Out out_count, OutArray language_codes); + Out out_count, OutArray language_codes); Result GetAvailableLanguageCodeCount2(Out out_count);