mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
Android: Add creator and notes fields for Gecko codes
This commit is contained in:
parent
883a9f8a99
commit
e299be1d85
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_creator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/cheats_creator"
|
||||
android:layout_margin="@dimen/spacing_large"
|
||||
android:labelFor="@id/edit_creator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_name"
|
||||
app:layout_constraintBottom_toTopOf="@id/edit_creator" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_creator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginHorizontal="@dimen/spacing_large"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/label_creator"
|
||||
app:layout_constraintBottom_toTopOf="@id/label_notes" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/cheats_notes"
|
||||
android:layout_margin="@dimen/spacing_large"
|
||||
android:labelFor="@id/edit_notes"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_creator"
|
||||
app:layout_constraintBottom_toTopOf="@id/edit_notes" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginHorizontal="@dimen/spacing_large"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textMultiLine"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/label_notes"
|
||||
app:layout_constraintBottom_toTopOf="@id/label_code" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_code"
|
||||
android:layout_width="match_parent"
|
||||
@ -59,7 +113,7 @@
|
||||
android:labelFor="@id/edit_code"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_name"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_notes"
|
||||
app:layout_constraintBottom_toTopOf="@id/edit_code" />
|
||||
|
||||
<EditText
|
||||
|
@ -390,6 +390,8 @@
|
||||
<string name="cheats">Cheats</string>
|
||||
<string name="cheats_with_game_id">Cheats: %1$s</string>
|
||||
<string name="cheats_name">Name</string>
|
||||
<string name="cheats_creator">Creator</string>
|
||||
<string name="cheats_notes">Notes</string>
|
||||
<string name="cheats_code">Code</string>
|
||||
<string name="cheats_edit">Edit</string>
|
||||
<string name="cheats_error_no_name">Name can\'t be empty</string>
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user