From ea38f4bd1209d41a090f45e20e93028aaf11bb4c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 15 Sep 2023 07:26:52 +0200 Subject: [PATCH] early-access version 3872 --- README.md | 2 +- .../org/yuzu/yuzu_emu/adapters/GameAdapter.kt | 23 ++++++++++++++++--- .../org/yuzu/yuzu_emu/utils/GameIconUtils.kt | 11 +++++++++ src/android/app/src/main/jni/native.cpp | 8 +++---- .../app/src/main/res/drawable/shortcut.xml | 11 +++++++++ .../res/navigation/emulation_navigation.xml | 2 +- .../app/src/main/res/values/dimens.xml | 1 + 7 files changed, 48 insertions(+), 10 deletions(-) create mode 100755 src/android/app/src/main/res/drawable/shortcut.xml diff --git a/README.md b/README.md index fd9a1e53c..cd616d18b 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3870. +This is the source code for early-access 3872. ## Legal Notice diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt index 0013e8512..f9f88a1d2 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt @@ -4,7 +4,8 @@ package org.yuzu.yuzu_emu.adapters import android.content.Intent -import android.graphics.drawable.BitmapDrawable +import android.graphics.Bitmap +import android.graphics.drawable.LayerDrawable import android.net.Uri import android.text.TextUtils import android.view.LayoutInflater @@ -15,7 +16,10 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutManagerCompat +import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.IconCompat +import androidx.core.graphics.drawable.toBitmap +import androidx.core.graphics.drawable.toDrawable import androidx.documentfile.provider.DocumentFile import androidx.lifecycle.ViewModelProvider import androidx.navigation.findNavController @@ -87,11 +91,24 @@ class GameAdapter(private val activity: AppCompatActivity) : action = Intent.ACTION_VIEW data = Uri.parse(holder.game.path) } + + val layerDrawable = ResourcesCompat.getDrawable( + YuzuApplication.appContext.resources, + R.drawable.shortcut, + null + ) as LayerDrawable + layerDrawable.setDrawableByLayerId( + R.id.shortcut_foreground, + GameIconUtils.getGameIcon(holder.game).toDrawable(YuzuApplication.appContext.resources) + ) + val inset = YuzuApplication.appContext.resources + .getDimensionPixelSize(R.dimen.icon_inset) + layerDrawable.setLayerInset(1, inset, inset, inset, inset) val shortcut = ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path) .setShortLabel(holder.game.title) .setIcon( - IconCompat.createWithBitmap( - (holder.binding.imageGameScreen.drawable as BitmapDrawable).bitmap + IconCompat.createWithAdaptiveBitmap( + layerDrawable.toBitmap(config = Bitmap.Config.ARGB_8888) ) ) .setIntent(openIntent) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconUtils.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconUtils.kt index c0fe596d7..9fe99fab1 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconUtils.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconUtils.kt @@ -6,9 +6,11 @@ package org.yuzu.yuzu_emu.utils import android.graphics.Bitmap import android.graphics.BitmapFactory import android.widget.ImageView +import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toDrawable import coil.ImageLoader import coil.decode.DataSource +import coil.executeBlocking import coil.fetch.DrawableResult import coil.fetch.FetchResult import coil.fetch.Fetcher @@ -74,4 +76,13 @@ object GameIconUtils { .build() imageLoader.enqueue(request) } + + fun getGameIcon(game: Game): Bitmap { + val request = ImageRequest.Builder(YuzuApplication.appContext) + .data(game) + .error(R.drawable.default_icon) + .build() + return imageLoader.executeBlocking(request) + .drawable!!.toBitmap(config = Bitmap.Config.ARGB_8888) + } } diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index b9ecefa74..8a2021ff0 100755 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -262,9 +262,6 @@ public: Core::SystemResultStatus InitializeEmulation(const std::string& filepath) { std::scoped_lock lock(m_mutex); - // Loads the configuration. - Config{}; - // Create the render window. m_window = std::make_unique(&m_input_subsystem, m_native_window, m_vulkan_library); @@ -330,12 +327,13 @@ public: m_system.ShutdownMainProcess(); m_detached_tasks.WaitForAllTasks(); m_load_result = Core::SystemResultStatus::ErrorNotInitialized; + m_window.reset(); + OnEmulationStopped(Core::SystemResultStatus::Success); + return; } // Tear down the render window. m_window.reset(); - - OnEmulationStopped(m_load_result); } void PauseEmulation() { diff --git a/src/android/app/src/main/res/drawable/shortcut.xml b/src/android/app/src/main/res/drawable/shortcut.xml new file mode 100755 index 000000000..c749e5d72 --- /dev/null +++ b/src/android/app/src/main/res/drawable/shortcut.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/android/app/src/main/res/navigation/emulation_navigation.xml b/src/android/app/src/main/res/navigation/emulation_navigation.xml index c7be37f9b..cfc494b3f 100755 --- a/src/android/app/src/main/res/navigation/emulation_navigation.xml +++ b/src/android/app/src/main/res/navigation/emulation_navigation.xml @@ -27,7 +27,7 @@ app:nullable="true" /> + app:argType="org.yuzu.yuzu_emu.features.settings.model.Settings$MenuTag" /> 72dp 256dp 165dp + 24dp 20dp 3dp