From 41a26f76fae1e580f99c471dc70ea420f3d598e6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 23 Jul 2022 14:45:26 +0200 Subject: [PATCH] Android: Add Cheat.supportsCode method Patches, AR codes and Gecko codes have an associated code that the GUI can show, but graphics mods don't. --- .../dolphinemu/features/cheats/model/AbstractCheat.java | 5 +++++ .../dolphinemu/dolphinemu/features/cheats/model/Cheat.java | 7 ++++++- .../features/cheats/ui/CheatDetailsFragment.java | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java index 9a86d58533..2c33ccc616 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java @@ -9,6 +9,11 @@ public abstract class AbstractCheat implements Cheat { private Runnable mChangedCallback = null; + public boolean supportsCode() + { + return true; + } + public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, @NonNull String code) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/Cheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/Cheat.java index 75a3befc6f..142931b9cb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/Cheat.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/Cheat.java @@ -17,6 +17,8 @@ public interface Cheat boolean supportsNotes(); + boolean supportsCode(); + @NonNull String getName(); @@ -33,7 +35,10 @@ public interface Cheat } @NonNull - String getCode(); + default String getCode() + { + return ""; + } int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, @NonNull String code); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatDetailsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatDetailsFragment.java index e5a027f64b..9c207996bb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatDetailsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatDetailsFragment.java @@ -31,6 +31,7 @@ public class CheatDetailsFragment extends Fragment private EditText mEditCreator; private TextView mLabelNotes; private EditText mEditNotes; + private TextView mLabelCode; private EditText mEditCode; private Button mButtonDelete; private Button mButtonEdit; @@ -59,6 +60,7 @@ public class CheatDetailsFragment extends Fragment mEditCreator = view.findViewById(R.id.edit_creator); mLabelNotes = view.findViewById(R.id.label_notes); mEditNotes = view.findViewById(R.id.edit_notes); + mLabelCode = view.findViewById(R.id.label_code); mEditCode = view.findViewById(R.id.edit_code); mButtonDelete = view.findViewById(R.id.button_delete); mButtonEdit = view.findViewById(R.id.button_edit); @@ -158,10 +160,13 @@ public class CheatDetailsFragment extends Fragment int creatorVisibility = cheat != null && cheat.supportsCreator() ? View.VISIBLE : View.GONE; int notesVisibility = cheat != null && cheat.supportsNotes() ? View.VISIBLE : View.GONE; + int codeVisibility = cheat != null && cheat.supportsCode() ? View.VISIBLE : View.GONE; mLabelCreator.setVisibility(creatorVisibility); mEditCreator.setVisibility(creatorVisibility); mLabelNotes.setVisibility(notesVisibility); mEditNotes.setVisibility(notesVisibility); + mLabelCode.setVisibility(codeVisibility); + mEditCode.setVisibility(codeVisibility); boolean userDefined = cheat != null && cheat.getUserDefined(); mButtonDelete.setEnabled(userDefined);