Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #10092 from JosJuice/android-cheats
Android: Add cheat GUI
- Loading branch information
Showing
41 changed files
with
2,678 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| package org.dolphinemu.dolphinemu.features.cheats.model; | ||
|
|
||
| import androidx.annotation.Keep; | ||
| import androidx.annotation.NonNull; | ||
|
|
||
| public class ARCheat extends AbstractCheat | ||
| { | ||
| @Keep | ||
| private final long mPointer; | ||
|
|
||
| public ARCheat() | ||
| { | ||
| mPointer = createNew(); | ||
| } | ||
|
|
||
| @Keep | ||
| private ARCheat(long pointer) | ||
| { | ||
| mPointer = pointer; | ||
| } | ||
|
|
||
| @Override | ||
| public native void finalize(); | ||
|
|
||
| private native long createNew(); | ||
|
|
||
| public boolean supportsCreator() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| public boolean supportsNotes() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| @NonNull | ||
| public native String getName(); | ||
|
|
||
| @NonNull | ||
| public native String getCode(); | ||
|
|
||
| public native boolean getUserDefined(); | ||
|
|
||
| public native boolean getEnabled(); | ||
|
|
||
| @Override | ||
| protected native int trySetImpl(@NonNull String name, @NonNull String creator, | ||
| @NonNull String notes, @NonNull String code); | ||
|
|
||
| @Override | ||
| protected native void setEnabledImpl(boolean enabled); | ||
|
|
||
| @NonNull | ||
| public static native ARCheat[] loadCodes(String gameId, int revision); | ||
|
|
||
| public static native void saveCodes(String gameId, int revision, ARCheat[] codes); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| package org.dolphinemu.dolphinemu.features.cheats.model; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| public abstract class AbstractCheat implements Cheat | ||
| { | ||
| private Runnable mChangedCallback = null; | ||
|
|
||
| public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes, | ||
| @NonNull String code) | ||
| { | ||
| if (!code.isEmpty() && code.charAt(0) == '$') | ||
| { | ||
| int firstLineEnd = code.indexOf('\n'); | ||
| if (firstLineEnd == -1) | ||
| { | ||
| name = code.substring(1); | ||
| code = ""; | ||
| } | ||
| else | ||
| { | ||
| name = code.substring(1, firstLineEnd); | ||
| code = code.substring(firstLineEnd + 1); | ||
| } | ||
| } | ||
|
|
||
| if (name.isEmpty()) | ||
| return TRY_SET_FAIL_NO_NAME; | ||
|
|
||
| int result = trySetImpl(name, creator, notes, code); | ||
|
|
||
| if (result == TRY_SET_SUCCESS) | ||
| onChanged(); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| public void setEnabled(boolean enabled) | ||
| { | ||
| setEnabledImpl(enabled); | ||
| onChanged(); | ||
| } | ||
|
|
||
| public void setChangedCallback(@Nullable Runnable callback) | ||
| { | ||
| mChangedCallback = callback; | ||
| } | ||
|
|
||
| protected void onChanged() | ||
| { | ||
| if (mChangedCallback != null) | ||
| mChangedCallback.run(); | ||
| } | ||
|
|
||
| protected abstract int trySetImpl(@NonNull String name, @NonNull String creator, | ||
| @NonNull String notes, @NonNull String code); | ||
|
|
||
| protected abstract void setEnabledImpl(boolean enabled); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| package org.dolphinemu.dolphinemu.features.cheats.model; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| public interface Cheat | ||
| { | ||
| int TRY_SET_FAIL_CODE_MIXED_ENCRYPTION = -3; | ||
| int TRY_SET_FAIL_NO_CODE_LINES = -2; | ||
| int TRY_SET_FAIL_NO_NAME = -1; | ||
| 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 creator, @NonNull String notes, | ||
| @NonNull String code); | ||
|
|
||
| boolean getUserDefined(); | ||
|
|
||
| boolean getEnabled(); | ||
|
|
||
| void setEnabled(boolean enabled); | ||
|
|
||
| void setChangedCallback(@Nullable Runnable callback); | ||
| } |
Oops, something went wrong.