committed by
bunnei
17 changed files with 343 additions and 373 deletions
-
127src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
-
5src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
-
121src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
-
129src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MenuFragment.java
-
8src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt
-
37src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/SerializableHelper.kt
-
9src/android/app/src/main/res/drawable/ic_controller.xml
-
10src/android/app/src/main/res/drawable/ic_exit.xml
-
9src/android/app/src/main/res/drawable/ic_pause.xml
-
9src/android/app/src/main/res/drawable/ic_play.xml
-
33src/android/app/src/main/res/layout/activity_emulation.xml
-
92src/android/app/src/main/res/layout/fragment_emulation.xml
-
56src/android/app/src/main/res/layout/fragment_ingame_menu.xml
-
23src/android/app/src/main/res/layout/header_in_game.xml
-
32src/android/app/src/main/res/menu/menu_in_game.xml
-
12src/android/app/src/main/res/menu/menu_overlay_options.xml
-
4src/android/app/src/main/res/values/strings.xml
@ -1,129 +0,0 @@ |
|||
package org.yuzu.yuzu_emu.fragments; |
|||
|
|||
import android.content.pm.PackageManager; |
|||
import android.graphics.Rect; |
|||
import android.os.Bundle; |
|||
import android.util.SparseIntArray; |
|||
import android.view.LayoutInflater; |
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
import android.widget.Button; |
|||
import android.widget.LinearLayout; |
|||
|
|||
import androidx.annotation.ColorInt; |
|||
import androidx.annotation.NonNull; |
|||
import androidx.annotation.Nullable; |
|||
import androidx.core.graphics.Insets; |
|||
import androidx.core.view.ViewCompat; |
|||
import androidx.core.view.WindowInsetsCompat; |
|||
import androidx.fragment.app.Fragment; |
|||
|
|||
import com.google.android.material.color.MaterialColors; |
|||
import com.google.android.material.elevation.ElevationOverlayProvider; |
|||
|
|||
import org.yuzu.yuzu_emu.R; |
|||
import org.yuzu.yuzu_emu.activities.EmulationActivity; |
|||
|
|||
|
|||
public final class MenuFragment extends Fragment implements View.OnClickListener |
|||
{ |
|||
private static final String KEY_TITLE = "title"; |
|||
private static final String KEY_WII = "wii"; |
|||
private static SparseIntArray buttonsActionsMap = new SparseIntArray(); |
|||
|
|||
private int mCutInset = 0; |
|||
|
|||
static |
|||
{ |
|||
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); |
|||
} |
|||
|
|||
public static MenuFragment newInstance() |
|||
{ |
|||
MenuFragment fragment = new MenuFragment(); |
|||
|
|||
Bundle arguments = new Bundle(); |
|||
fragment.setArguments(arguments); |
|||
|
|||
return fragment; |
|||
} |
|||
|
|||
// This is primarily intended to account for any navigation bar at the bottom of the screen |
|||
private int getBottomPaddingRequired() |
|||
{ |
|||
Rect visibleFrame = new Rect(); |
|||
requireActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(visibleFrame); |
|||
return visibleFrame.bottom - visibleFrame.top - getResources().getDisplayMetrics().heightPixels; |
|||
} |
|||
|
|||
@NonNull |
|||
@Override |
|||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, |
|||
Bundle savedInstanceState) |
|||
{ |
|||
View rootView = inflater.inflate(R.layout.fragment_ingame_menu, container, false); |
|||
|
|||
LinearLayout options = rootView.findViewById(R.id.layout_options); |
|||
|
|||
// mPauseEmulation = options.findViewById(R.id.menu_pause_emulation); |
|||
// mUnpauseEmulation = options.findViewById(R.id.menu_unpause_emulation); |
|||
// |
|||
// updatePauseUnpauseVisibility(); |
|||
// |
|||
// if (!requireActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) |
|||
// { |
|||
// options.findViewById(R.id.menu_overlay_controls).setVisibility(View.GONE); |
|||
// } |
|||
// |
|||
// if (!getArguments().getBoolean(KEY_WII, true)) |
|||
// { |
|||
// options.findViewById(R.id.menu_refresh_wiimotes).setVisibility(View.GONE); |
|||
// } |
|||
|
|||
int bottomPaddingRequired = getBottomPaddingRequired(); |
|||
|
|||
// Provide a safe zone between the navigation bar and Exit Emulation to avoid accidental touches |
|||
float density = getResources().getDisplayMetrics().density; |
|||
if (bottomPaddingRequired >= 32 * density) |
|||
{ |
|||
bottomPaddingRequired += 32 * density; |
|||
} |
|||
|
|||
if (bottomPaddingRequired > rootView.getPaddingBottom()) |
|||
{ |
|||
rootView.setPadding(rootView.getPaddingLeft(), rootView.getPaddingTop(), |
|||
rootView.getPaddingRight(), bottomPaddingRequired); |
|||
} |
|||
|
|||
for (int childIndex = 0; childIndex < options.getChildCount(); childIndex++) |
|||
{ |
|||
Button button = (Button) options.getChildAt(childIndex); |
|||
|
|||
button.setOnClickListener(this); |
|||
} |
|||
|
|||
rootView.findViewById(R.id.menu_exit).setOnClickListener(this); |
|||
|
|||
// mTitleText = rootView.findViewById(R.id.text_game_title); |
|||
// String title = getArguments().getString(KEY_TITLE, null); |
|||
// if (title != null) |
|||
// { |
|||
// mTitleText.setText(title); |
|||
// } |
|||
|
|||
if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) |
|||
{ |
|||
// rootView.post(() -> NativeLibrary.SetObscuredPixelsLeft(rootView.getWidth())); |
|||
} |
|||
|
|||
return rootView; |
|||
} |
|||
|
|||
@Override |
|||
public void onClick(View button) |
|||
{ |
|||
int action = buttonsActionsMap.get(button.getId()); |
|||
EmulationActivity activity = (EmulationActivity) requireActivity(); |
|||
activity.handleMenuAction(action); |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
package org.yuzu.yuzu_emu.utils |
|||
|
|||
import android.content.Intent |
|||
import android.os.Build |
|||
import android.os.Bundle |
|||
import android.os.Parcelable |
|||
import java.io.Serializable |
|||
|
|||
object SerializableHelper { |
|||
inline fun <reified T : Serializable> Bundle.serializable(key: String): T? { |
|||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) |
|||
getSerializable(key, T::class.java) |
|||
else |
|||
getSerializable(key) as? T |
|||
} |
|||
|
|||
inline fun <reified T : Serializable> Intent.serializable(key: String): T? { |
|||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) |
|||
getSerializableExtra(key, T::class.java) |
|||
else |
|||
getSerializableExtra(key) as? T |
|||
} |
|||
|
|||
inline fun <reified T : Parcelable> Bundle.parcelable(key: String): T? { |
|||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) |
|||
getParcelable(key, T::class.java) |
|||
else |
|||
getParcelable(key) as? T |
|||
} |
|||
|
|||
inline fun <reified T : Parcelable> Intent.parcelable(key: String): T? { |
|||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) |
|||
getParcelableExtra(key, T::class.java) |
|||
else |
|||
getParcelableExtra(key) as? T |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportHeight="24" |
|||
android:viewportWidth="24"> |
|||
<path |
|||
android:fillColor="?attr/colorControlNormal" |
|||
android:pathData="M21,6L3,6c-1.1,0 -2,0.9 -2,2v8c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.1 -0.9,-2 -2,-2zM11,13L8,13v3L6,16v-3L3,13v-2h3L6,8h2v3h3v2zM15.5,15c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM19.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S18.67,9 19.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z" /> |
|||
</vector> |
|||
@ -0,0 +1,10 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:autoMirrored="true" |
|||
android:viewportHeight="24" |
|||
android:viewportWidth="24"> |
|||
<path |
|||
android:fillColor="?attr/colorControlNormal" |
|||
android:pathData="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" /> |
|||
</vector> |
|||
@ -0,0 +1,9 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportHeight="24" |
|||
android:viewportWidth="24"> |
|||
<path |
|||
android:fillColor="?attr/colorControlNormal" |
|||
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z" /> |
|||
</vector> |
|||
@ -0,0 +1,9 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportHeight="24" |
|||
android:viewportWidth="24"> |
|||
<path |
|||
android:fillColor="?attr/colorControlNormal" |
|||
android:pathData="M8,5v14l11,-7z" /> |
|||
</vector> |
|||
@ -1,32 +1,13 @@ |
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:keepScreenOn="true" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:id="@+id/frame_content"> |
|||
<FrameLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:id="@+id/frame_content" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:keepScreenOn="true"> |
|||
|
|||
<FrameLayout |
|||
android:id="@+id/frame_emulation_fragment" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"/> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:orientation="horizontal" |
|||
android:baselineAligned="false"> |
|||
|
|||
<FrameLayout |
|||
android:id="@+id/frame_menu" |
|||
android:layout_width="@dimen/menu_width" |
|||
android:layout_height="match_parent" |
|||
tools:layout="@layout/fragment_ingame_menu"/> |
|||
|
|||
<FrameLayout |
|||
android:id="@+id/frame_submenu" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"/> |
|||
|
|||
</LinearLayout> |
|||
android:layout_height="match_parent" /> |
|||
|
|||
</FrameLayout> |
|||
@ -1,47 +1,63 @@ |
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:id="@+id/drawer_layout" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:keepScreenOn="true" |
|||
tools:context="org.yuzu.yuzu_emu.fragments.EmulationFragment"> |
|||
tools:context="org.yuzu.yuzu_emu.fragments.EmulationFragment" |
|||
tools:openDrawer="start"> |
|||
|
|||
<!-- This is what everything is rendered to during emulation --> |
|||
<Button |
|||
android:id="@+id/done_control_config" |
|||
style="@style/Widget.Material3.Button.Icon" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center" |
|||
android:padding="@dimen/spacing_small" |
|||
android:text="@string/emulation_done" |
|||
android:visibility="gone" /> |
|||
|
|||
<!-- This is the onscreen input overlay --> |
|||
<SurfaceView |
|||
android:id="@+id/surface_emulation" |
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:focusable="false" |
|||
android:focusableInTouchMode="false" /> |
|||
android:layout_height="match_parent"> |
|||
|
|||
<org.yuzu.yuzu_emu.overlay.InputOverlay |
|||
android:id="@+id/surface_input_overlay" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:focusable="true" |
|||
android:focusableInTouchMode="true" /> |
|||
<!-- This is the onscreen input overlay --> |
|||
<SurfaceView |
|||
android:id="@+id/surface_emulation" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:focusable="false" |
|||
android:focusableInTouchMode="false" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/show_fps_text" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="18dp" |
|||
android:layout_marginTop="2dp" |
|||
android:clickable="false" |
|||
android:linksClickable="false" |
|||
android:longClickable="false" |
|||
android:shadowColor="@android:color/black" |
|||
android:textColor="@android:color/white" |
|||
android:textSize="12sp" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/show_fps_text" |
|||
<org.yuzu.yuzu_emu.overlay.InputOverlay |
|||
android:id="@+id/surface_input_overlay" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:focusable="true" |
|||
android:focusableInTouchMode="true" /> |
|||
|
|||
<!-- This is what everything is rendered to during emulation --> |
|||
<Button |
|||
style="@style/Widget.Material3.Button.ElevatedButton" |
|||
android:id="@+id/done_control_config" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center" |
|||
android:text="@string/emulation_done" |
|||
android:visibility="gone" /> |
|||
|
|||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
|||
|
|||
<com.google.android.material.navigation.NavigationView |
|||
android:id="@+id/in_game_menu" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="18dp" |
|||
android:layout_marginTop="2dp" |
|||
android:clickable="false" |
|||
android:linksClickable="false" |
|||
android:longClickable="false" |
|||
android:shadowColor="@android:color/black" |
|||
android:textColor="@android:color/white" |
|||
android:textSize="12sp" /> |
|||
|
|||
</FrameLayout> |
|||
android:layout_height="match_parent" |
|||
android:layout_gravity="start" |
|||
app:headerLayout="@layout/header_in_game" |
|||
app:menu="@menu/menu_in_game" /> |
|||
|
|||
</androidx.drawerlayout.widget.DrawerLayout> |
|||
@ -1,56 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:orientation="vertical" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:background="?attr/colorSurface" |
|||
android:elevation="3dp" |
|||
tools:layout_width="250dp"> |
|||
|
|||
<TextView |
|||
android:id="@+id/text_game_title" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginHorizontal="32dp" |
|||
android:layout_marginVertical="24dp" |
|||
android:ellipsize="end" |
|||
android:letterSpacing="0" |
|||
android:maxLines="@integer/game_title_lines" |
|||
android:textSize="20sp" |
|||
android:textColor="?attr/colorOnSurface" |
|||
tools:text="The Legend of Zelda: Breath of the Wild" /> |
|||
|
|||
<com.google.android.material.divider.MaterialDivider |
|||
android:id="@+id/divider" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" /> |
|||
|
|||
<ScrollView |
|||
android:layout_width="match_parent" |
|||
android:layout_height="0dp" |
|||
android:layout_weight="1" |
|||
android:scrollbarSize="4dp" |
|||
android:fadeScrollbars="false"> |
|||
|
|||
<LinearLayout |
|||
android:id="@+id/layout_options" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="vertical" /> |
|||
|
|||
</ScrollView> |
|||
|
|||
<com.google.android.material.divider.MaterialDivider |
|||
android:id="@+id/divider_2" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" /> |
|||
|
|||
<Button |
|||
android:id="@+id/menu_exit" |
|||
style="@style/InGameMenuOption" |
|||
android:layout_marginTop="@dimen/spacing_large" |
|||
android:text="@string/emulation_exit" /> |
|||
|
|||
</LinearLayout> |
|||
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<androidx.constraintlayout.widget.ConstraintLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:fitsSystemWindows="true"> |
|||
|
|||
<com.google.android.material.textview.MaterialTextView |
|||
android:id="@+id/text_game_title" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_margin="24dp" |
|||
android:textAppearance="?attr/textAppearanceHeadlineMedium" |
|||
android:textColor="?attr/colorOnSurface" |
|||
android:textAlignment="viewStart" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" |
|||
tools:text="Super Mario Odyssey" /> |
|||
|
|||
</androidx.constraintlayout.widget.ConstraintLayout> |
|||
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<item android:title=""> |
|||
|
|||
<menu> |
|||
|
|||
<item |
|||
android:id="@+id/menu_pause_emulation" |
|||
android:icon="@drawable/ic_pause" |
|||
android:title="@string/emulation_pause" /> |
|||
|
|||
<item |
|||
android:id="@+id/menu_settings" |
|||
android:icon="@drawable/ic_settings" |
|||
android:title="@string/preferences_settings" /> |
|||
|
|||
<item |
|||
android:id="@+id/menu_overlay_controls" |
|||
android:icon="@drawable/ic_controller" |
|||
android:title="@string/emulation_input_overlay" /> |
|||
|
|||
</menu> |
|||
|
|||
</item> |
|||
|
|||
<item |
|||
android:id="@+id/menu_exit" |
|||
android:icon="@drawable/ic_exit" |
|||
android:title="@string/emulation_exit" /> |
|||
|
|||
</menu> |
|||
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<item |
|||
android:id="@+id/menu_edit_overlay" |
|||
android:title="@string/emulation_touch_overlay_edit" /> |
|||
|
|||
<item |
|||
android:id="@+id/menu_reset_overlay" |
|||
android:title="@string/emulation_touch_overlay_reset" /> |
|||
|
|||
</menu> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue