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.
This commit is contained in:
JosJuice 2022-07-23 14:45:26 +02:00
parent 98e2817802
commit 41a26f76fa
3 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,11 @@ public abstract class AbstractCheat implements Cheat
{ {
private Runnable mChangedCallback = null; private Runnable mChangedCallback = null;
public boolean supportsCode()
{
return true;
}
public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
@NonNull String code) @NonNull String code)
{ {

View File

@ -17,6 +17,8 @@ public interface Cheat
boolean supportsNotes(); boolean supportsNotes();
boolean supportsCode();
@NonNull @NonNull
String getName(); String getName();
@ -33,7 +35,10 @@ public interface Cheat
} }
@NonNull @NonNull
String getCode(); default String getCode()
{
return "";
}
int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
@NonNull String code); @NonNull String code);

View File

@ -31,6 +31,7 @@ public class CheatDetailsFragment extends Fragment
private EditText mEditCreator; private EditText mEditCreator;
private TextView mLabelNotes; private TextView mLabelNotes;
private EditText mEditNotes; private EditText mEditNotes;
private TextView mLabelCode;
private EditText mEditCode; private EditText mEditCode;
private Button mButtonDelete; private Button mButtonDelete;
private Button mButtonEdit; private Button mButtonEdit;
@ -59,6 +60,7 @@ public class CheatDetailsFragment extends Fragment
mEditCreator = view.findViewById(R.id.edit_creator); mEditCreator = view.findViewById(R.id.edit_creator);
mLabelNotes = view.findViewById(R.id.label_notes); mLabelNotes = view.findViewById(R.id.label_notes);
mEditNotes = view.findViewById(R.id.edit_notes); mEditNotes = view.findViewById(R.id.edit_notes);
mLabelCode = view.findViewById(R.id.label_code);
mEditCode = view.findViewById(R.id.edit_code); mEditCode = view.findViewById(R.id.edit_code);
mButtonDelete = view.findViewById(R.id.button_delete); mButtonDelete = view.findViewById(R.id.button_delete);
mButtonEdit = view.findViewById(R.id.button_edit); 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 creatorVisibility = cheat != null && cheat.supportsCreator() ? View.VISIBLE : View.GONE;
int notesVisibility = cheat != null && cheat.supportsNotes() ? 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); mLabelCreator.setVisibility(creatorVisibility);
mEditCreator.setVisibility(creatorVisibility); mEditCreator.setVisibility(creatorVisibility);
mLabelNotes.setVisibility(notesVisibility); mLabelNotes.setVisibility(notesVisibility);
mEditNotes.setVisibility(notesVisibility); mEditNotes.setVisibility(notesVisibility);
mLabelCode.setVisibility(codeVisibility);
mEditCode.setVisibility(codeVisibility);
boolean userDefined = cheat != null && cheat.getUserDefined(); boolean userDefined = cheat != null && cheat.getUserDefined();
mButtonDelete.setEnabled(userDefined); mButtonDelete.setEnabled(userDefined);