diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ARCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ARCheat.java index 432da43ce1..24b74b489a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ARCheat.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ARCheat.java @@ -19,6 +19,16 @@ public class ARCheat extends AbstractCheat @Override public native void finalize(); + public boolean supportsCreator() + { + return false; + } + + public boolean supportsNotes() + { + return false; + } + @NonNull public native String getName(); @@ -30,7 +40,8 @@ public class ARCheat extends AbstractCheat public native boolean getEnabled(); @Override - protected native int trySetImpl(@NonNull String name, @NonNull String code); + protected native int trySetImpl(@NonNull String name, @NonNull String creator, + @NonNull String notes, @NonNull String code); @Override protected native void setEnabledImpl(boolean enabled); 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 cca4b041d9..5dc5e80b6f 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,12 +9,13 @@ public abstract class AbstractCheat implements Cheat { private Runnable mChangedCallback = null; - public int trySet(@NonNull String name, @NonNull String code) + public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, + @NonNull String code) { if (name.isEmpty()) return TRY_SET_FAIL_NO_NAME; - int result = trySetImpl(name, code); + int result = trySetImpl(name, creator, notes, code); if (result == TRY_SET_SUCCESS) onChanged(); @@ -39,7 +40,8 @@ public abstract class AbstractCheat implements Cheat mChangedCallback.run(); } - protected abstract int trySetImpl(@NonNull String name, @NonNull String code); + protected abstract int trySetImpl(@NonNull String name, @NonNull String creator, + @NonNull String notes, @NonNull String code); protected abstract void setEnabledImpl(boolean enabled); } 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 505bd5c026..75a3befc6f 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 @@ -13,13 +13,30 @@ public interface Cheat int TRY_SET_SUCCESS = 0; // Result codes greater than 0 represent an error on the corresponding code line (one-indexed) + boolean supportsCreator(); + + boolean supportsNotes(); + @NonNull String getName(); + @NonNull + default String getCreator() + { + return ""; + } + + @NonNull + default String getNotes() + { + return ""; + } + @NonNull String getCode(); - int trySet(@NonNull String name, @NonNull String code); + int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, + @NonNull String code); boolean getUserDefined(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GeckoCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GeckoCheat.java index 6ef6a9431e..1847daa40d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GeckoCheat.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GeckoCheat.java @@ -19,9 +19,25 @@ public class GeckoCheat extends AbstractCheat @Override public native void finalize(); + public boolean supportsCreator() + { + return true; + } + + public boolean supportsNotes() + { + return true; + } + @NonNull public native String getName(); + @NonNull + public native String getCreator(); + + @NonNull + public native String getNotes(); + @NonNull public native String getCode(); @@ -30,7 +46,8 @@ public class GeckoCheat extends AbstractCheat public native boolean getEnabled(); @Override - protected native int trySetImpl(@NonNull String name, @NonNull String code); + protected native int trySetImpl(@NonNull String name, @NonNull String creator, + @NonNull String notes, @NonNull String code); @Override protected native void setEnabledImpl(boolean enabled); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat.java index 8514ae00cc..52d88413dd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat.java @@ -19,6 +19,16 @@ public class PatchCheat extends AbstractCheat @Override public native void finalize(); + public boolean supportsCreator() + { + return false; + } + + public boolean supportsNotes() + { + return false; + } + @NonNull public native String getName(); @@ -30,7 +40,8 @@ public class PatchCheat extends AbstractCheat public native boolean getEnabled(); @Override - protected native int trySetImpl(@NonNull String name, @NonNull String code); + protected native int trySetImpl(@NonNull String name, @NonNull String creator, + @NonNull String notes, @NonNull String code); @Override protected native void setEnabledImpl(boolean enabled); 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 ffe86fc702..db625928f9 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 @@ -8,6 +8,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -23,6 +24,10 @@ public class CheatDetailsFragment extends Fragment { private View mRoot; private EditText mEditName; + private TextView mLabelCreator; + private EditText mEditCreator; + private TextView mLabelNotes; + private EditText mEditNotes; private EditText mEditCode; private Button mButtonEdit; private Button mButtonCancel; @@ -44,6 +49,10 @@ public class CheatDetailsFragment extends Fragment { mRoot = view.findViewById(R.id.root); mEditName = view.findViewById(R.id.edit_name); + mLabelCreator = view.findViewById(R.id.label_creator); + mEditCreator = view.findViewById(R.id.edit_creator); + mLabelNotes = view.findViewById(R.id.label_notes); + mEditNotes = view.findViewById(R.id.edit_notes); mEditCode = view.findViewById(R.id.edit_code); mButtonEdit = view.findViewById(R.id.button_edit); mButtonCancel = view.findViewById(R.id.button_cancel); @@ -74,7 +83,8 @@ public class CheatDetailsFragment extends Fragment { clearEditErrors(); - int result = mCheat.trySet(mEditName.getText().toString(), mEditCode.getText().toString()); + int result = mCheat.trySet(mEditName.getText().toString(), mEditCreator.getText().toString(), + mEditNotes.getText().toString(), mEditCode.getText().toString()); switch (result) { @@ -103,6 +113,13 @@ public class CheatDetailsFragment extends Fragment mRoot.setVisibility(cheat == null ? View.GONE : View.VISIBLE); + int creatorVisibility = cheat != null && cheat.supportsCreator() ? View.VISIBLE : View.GONE; + int notesVisibility = cheat != null && cheat.supportsNotes() ? View.VISIBLE : View.GONE; + mLabelCreator.setVisibility(creatorVisibility); + mEditCreator.setVisibility(creatorVisibility); + mLabelNotes.setVisibility(notesVisibility); + mEditNotes.setVisibility(notesVisibility); + boolean userDefined = cheat != null && cheat.getUserDefined(); mButtonEdit.setEnabled(userDefined); @@ -113,6 +130,8 @@ public class CheatDetailsFragment extends Fragment if (!isEditing && cheat != null) { mEditName.setText(cheat.getName()); + mEditCreator.setText(cheat.getCreator()); + mEditNotes.setText(cheat.getNotes()); mEditCode.setText(cheat.getCode()); } @@ -122,6 +141,8 @@ public class CheatDetailsFragment extends Fragment private void onIsEditingUpdated(boolean isEditing) { mEditName.setEnabled(isEditing); + mEditCreator.setEnabled(isEditing); + mEditNotes.setEnabled(isEditing); mEditCode.setEnabled(isEditing); mButtonEdit.setVisibility(isEditing ? View.GONE : View.VISIBLE); diff --git a/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml b/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml index 69cb87c82e..e970d829b2 100644 --- a/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml +++ b/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml @@ -45,9 +45,63 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/label_name" - app:layout_constraintBottom_toTopOf="@id/label_code" + app:layout_constraintBottom_toTopOf="@id/label_creator" tools:text="Hyrule Field Speed Hack" /> + + + + + + + + Cheats Cheats: %1$s Name + Creator + Notes Code Edit Name can\'t be empty diff --git a/Source/Android/jni/Cheats/ARCheat.cpp b/Source/Android/jni/Cheats/ARCheat.cpp index 7c418ec579..895fe68f7d 100644 --- a/Source/Android/jni/Cheats/ARCheat.cpp +++ b/Source/Android/jni/Cheats/ARCheat.cpp @@ -74,7 +74,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_getEnabled(JNIEnv* } JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_trySetImpl( - JNIEnv* env, jobject obj, jstring name, jstring code_string) + JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string) { ActionReplay::ARCode* code = GetPointer(env, obj); diff --git a/Source/Android/jni/Cheats/GeckoCheat.cpp b/Source/Android/jni/Cheats/GeckoCheat.cpp index a5d2ce7c65..cb65e392c1 100644 --- a/Source/Android/jni/Cheats/GeckoCheat.cpp +++ b/Source/Android/jni/Cheats/GeckoCheat.cpp @@ -41,6 +41,18 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_getName(JNIEnv* return ToJString(env, GetPointer(env, obj)->name); } +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_getCreator(JNIEnv* env, jobject obj) +{ + return ToJString(env, GetPointer(env, obj)->creator); +} + +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_getNotes(JNIEnv* env, jobject obj) +{ + return ToJString(env, JoinStrings(GetPointer(env, obj)->notes, "\n")); +} + JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_getCode(JNIEnv* env, jobject obj) { @@ -73,7 +85,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_getEnabled(JNIEn } JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_trySetImpl( - JNIEnv* env, jobject obj, jstring name, jstring code_string) + JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string) { Gecko::GeckoCode* code = GetPointer(env, obj); @@ -98,6 +110,8 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_Geck return Cheats::TRY_SET_FAIL_NO_CODE_LINES; code->name = GetJString(env, name); + code->creator = GetJString(env, creator); + code->notes = SplitString(GetJString(env, notes), '\n'); code->codes = std::move(entries); return Cheats::TRY_SET_SUCCESS; diff --git a/Source/Android/jni/Cheats/PatchCheat.cpp b/Source/Android/jni/Cheats/PatchCheat.cpp index c41f0a599d..8d093c0d39 100644 --- a/Source/Android/jni/Cheats/PatchCheat.cpp +++ b/Source/Android/jni/Cheats/PatchCheat.cpp @@ -72,7 +72,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_getEnabled(JNIEn } JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_trySetImpl( - JNIEnv* env, jobject obj, jstring name, jstring code_string) + JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string) { PatchEngine::Patch* patch = GetPointer(env, obj);