summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2022-07-26 15:44:01 +0200
committerGitHub <noreply@github.com>2022-07-26 15:44:01 +0200
commit97100290ee7b5e9a2e0b7f83cb49146786cf185c (patch)
tree131f9edfe460ed6642a47f7913c073f4f45895d7 /Source/Android
parenta9edf129e35e109fe50d8b4cca444de0c60bcb52 (diff)
parent3bd2bca38508965348bff45e4a77baa945abf33d (diff)
Merge pull request #10885 from JosJuice/android-graphics-mods
Android: Add graphics mods support to GUI
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java27
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/Cheat.java7
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/CheatsViewModel.java24
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod.java61
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup.java27
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ReadOnlyCheat.java36
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatDetailsFragment.java5
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsAdapter.java16
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsDisabledWarningFragment.java16
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/GraphicsModsDisabledWarningFragment.java16
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.java (renamed from Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatWarningFragment.java)25
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java1
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java4
-rw-r--r--Source/Android/app/src/main/res/layout/fragment_cheat_list.xml16
-rw-r--r--Source/Android/app/src/main/res/layout/fragment_cheat_warning.xml3
-rw-r--r--Source/Android/app/src/main/res/values/strings.xml6
-rw-r--r--Source/Android/jni/AndroidCommon/IDCache.cpp57
-rw-r--r--Source/Android/jni/AndroidCommon/IDCache.h8
-rw-r--r--Source/Android/jni/CMakeLists.txt2
-rw-r--r--Source/Android/jni/Cheats/GraphicsMod.cpp53
-rw-r--r--Source/Android/jni/Cheats/GraphicsModGroup.cpp92
21 files changed, 467 insertions, 35 deletions
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..d672013b4e 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
@@ -3,11 +3,13 @@
package org.dolphinemu.dolphinemu.features.cheats.model;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-public abstract class AbstractCheat implements Cheat
+public abstract class AbstractCheat extends ReadOnlyCheat
{
- private Runnable mChangedCallback = null;
+ public boolean supportsCode()
+ {
+ return true;
+ }
public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
@NonNull String code)
@@ -38,25 +40,6 @@ public abstract class AbstractCheat implements Cheat
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);
}
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/model/CheatsViewModel.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/CheatsViewModel.java
index 0238628319..4d9900c168 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/CheatsViewModel.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/CheatsViewModel.java
@@ -24,10 +24,13 @@ public class CheatsViewModel extends ViewModel
private final MutableLiveData<Integer> mGeckoCheatsDownloadedEvent = new MutableLiveData<>(null);
private final MutableLiveData<Boolean> mOpenDetailsViewEvent = new MutableLiveData<>(false);
+ private GraphicsModGroup mGraphicsModGroup;
+ private ArrayList<GraphicsMod> mGraphicsMods;
private ArrayList<PatchCheat> mPatchCheats;
private ArrayList<ARCheat> mARCheats;
private ArrayList<GeckoCheat> mGeckoCheats;
+ private boolean mGraphicsModsNeedSaving = false;
private boolean mPatchCheatsNeedSaving = false;
private boolean mARCheatsNeedSaving = false;
private boolean mGeckoCheatsNeedSaving = false;
@@ -37,13 +40,23 @@ public class CheatsViewModel extends ViewModel
if (mLoaded)
return;
+ mGraphicsModGroup = GraphicsModGroup.load(gameID);
+ mGraphicsMods = new ArrayList<>();
+ Collections.addAll(mGraphicsMods, mGraphicsModGroup.getMods());
+
mPatchCheats = new ArrayList<>();
Collections.addAll(mPatchCheats, PatchCheat.loadCodes(gameID, revision));
+
mARCheats = new ArrayList<>();
Collections.addAll(mARCheats, ARCheat.loadCodes(gameID, revision));
+
mGeckoCheats = new ArrayList<>();
Collections.addAll(mGeckoCheats, GeckoCheat.loadCodes(gameID, revision));
+ for (GraphicsMod mod : mGraphicsMods)
+ {
+ mod.setChangedCallback(() -> mGraphicsModsNeedSaving = true);
+ }
for (PatchCheat cheat : mPatchCheats)
{
cheat.setChangedCallback(() -> mPatchCheatsNeedSaving = true);
@@ -62,6 +75,12 @@ public class CheatsViewModel extends ViewModel
public void saveIfNeeded(String gameID, int revision)
{
+ if (mGraphicsModsNeedSaving)
+ {
+ mGraphicsModGroup.save();
+ mGraphicsModsNeedSaving = false;
+ }
+
if (mPatchCheatsNeedSaving)
{
PatchCheat.saveCodes(gameID, revision, mPatchCheats.toArray(new PatchCheat[0]));
@@ -280,6 +299,11 @@ public class CheatsViewModel extends ViewModel
mOpenDetailsViewEvent.setValue(false);
}
+ public ArrayList<GraphicsMod> getGraphicsMods()
+ {
+ return mGraphicsMods;
+ }
+
public ArrayList<PatchCheat> getPatchCheats()
{
return mPatchCheats;
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod.java
new file mode 100644
index 0000000000..241d15093f
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod.java
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.cheats.model;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class GraphicsMod extends ReadOnlyCheat
+{
+ @Keep
+ private final long mPointer;
+
+ // When a C++ GraphicsModGroup object is destroyed, it also destroys the GraphicsMods it owns.
+ // To avoid getting dangling pointers, we keep a reference to the GraphicsModGroup here.
+ @Keep
+ private final GraphicsModGroup mParent;
+
+ @Keep
+ private GraphicsMod(long pointer, GraphicsModGroup parent)
+ {
+ mPointer = pointer;
+ mParent = parent;
+ }
+
+ public boolean supportsCreator()
+ {
+ return true;
+ }
+
+ public boolean supportsNotes()
+ {
+ return true;
+ }
+
+ public boolean supportsCode()
+ {
+ return false;
+ }
+
+ @NonNull
+ public native String getName();
+
+ @NonNull
+ public native String getCreator();
+
+ @NonNull
+ public native String getNotes();
+
+ public boolean getUserDefined()
+ {
+ // Technically graphics mods can be user defined, but we don't support editing graphics mods
+ // in the GUI, and editability is what this really controls
+ return false;
+ }
+
+ public native boolean getEnabled();
+
+ @Override
+ protected native void setEnabledImpl(boolean enabled);
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup.java
new file mode 100644
index 0000000000..0cb0a3c456
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup.java
@@ -0,0 +1,27 @@
+package org.dolphinemu.dolphinemu.features.cheats.model;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+
+public class GraphicsModGroup
+{
+ @Keep
+ private final long mPointer;
+
+ @Keep
+ private GraphicsModGroup(long pointer)
+ {
+ mPointer = pointer;
+ }
+
+ @Override
+ public native void finalize();
+
+ @NonNull
+ public native GraphicsMod[] getMods();
+
+ public native void save();
+
+ @NonNull
+ public static native GraphicsModGroup load(String gameId);
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ReadOnlyCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ReadOnlyCheat.java
new file mode 100644
index 0000000000..9751c414f8
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/ReadOnlyCheat.java
@@ -0,0 +1,36 @@
+// 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 ReadOnlyCheat implements Cheat
+{
+ private Runnable mChangedCallback = null;
+
+ public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
+ @NonNull String code)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ 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 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 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);
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsAdapter.java
index ec256cf6e2..e5be47a3f1 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsAdapter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsAdapter.java
@@ -13,6 +13,7 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.cheats.model.ARCheat;
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
import org.dolphinemu.dolphinemu.features.cheats.model.GeckoCheat;
+import org.dolphinemu.dolphinemu.features.cheats.model.GraphicsMod;
import org.dolphinemu.dolphinemu.features.cheats.model.PatchCheat;
import java.util.ArrayList;
@@ -90,8 +91,8 @@ public class CheatsAdapter extends RecyclerView.Adapter<CheatItemViewHolder>
@Override
public int getItemCount()
{
- return mViewModel.getARCheats().size() + mViewModel.getGeckoCheats().size() +
- mViewModel.getPatchCheats().size() + 7;
+ return mViewModel.getGraphicsMods().size() + mViewModel.getPatchCheats().size() +
+ mViewModel.getARCheats().size() + mViewModel.getGeckoCheats().size() + 8;
}
@Override
@@ -108,6 +109,17 @@ public class CheatsAdapter extends RecyclerView.Adapter<CheatItemViewHolder>
private CheatItem getItemAt(int position)
{
+ // Graphics mods
+
+ if (position == 0)
+ return new CheatItem(CheatItem.TYPE_HEADER, R.string.cheats_header_graphics_mod);
+ position -= 1;
+
+ ArrayList<GraphicsMod> graphicsMods = mViewModel.getGraphicsMods();
+ if (position < graphicsMods.size())
+ return new CheatItem(graphicsMods.get(position));
+ position -= graphicsMods.size();
+
// Patches
if (position == 0)
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsDisabledWarningFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsDisabledWarningFragment.java
new file mode 100644
index 0000000000..f2dfd7b341
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsDisabledWarningFragment.java
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.cheats.ui;
+
+import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
+import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
+
+public class CheatsDisabledWarningFragment extends SettingDisabledWarningFragment
+{
+ public CheatsDisabledWarningFragment()
+ {
+ super(BooleanSetting.MAIN_ENABLE_CHEATS, MenuTag.CONFIG_GENERAL,
+ R.string.cheats_disabled_warning);
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/GraphicsModsDisabledWarningFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/GraphicsModsDisabledWarningFragment.java
new file mode 100644
index 0000000000..eaf26f094b
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/GraphicsModsDisabledWarningFragment.java
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.cheats.ui;
+
+import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
+import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
+
+public class GraphicsModsDisabledWarningFragment extends SettingDisabledWarningFragment
+{
+ public GraphicsModsDisabledWarningFragment()
+ {
+ super(BooleanSetting.GFX_MODS_ENABLE, MenuTag.ADVANCED_GRAPHICS,
+ R.string.gfx_mods_disabled_warning);
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatWarningFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.java
index df6d9d94b0..c239c5c9af 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatWarningFragment.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.java
@@ -7,21 +7,35 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import org.dolphinemu.dolphinemu.R;
-import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
+import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
-public class CheatWarningFragment extends Fragment implements View.OnClickListener
+public abstract class SettingDisabledWarningFragment extends Fragment
+ implements View.OnClickListener
{
private View mView;
+ private final AbstractBooleanSetting mSetting;
+ private final MenuTag mSettingShortcut;
+ private final int mText;
+
+ public SettingDisabledWarningFragment(AbstractBooleanSetting setting, MenuTag settingShortcut,
+ int text)
+ {
+ mSetting = setting;
+ mSettingShortcut = settingShortcut;
+ mText = text;
+ }
+
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@@ -35,6 +49,9 @@ public class CheatWarningFragment extends Fragment implements View.OnClickListen
{
mView = view;
+ TextView textView = view.findViewById(R.id.text_warning);
+ textView.setText(mText);
+
Button settingsButton = view.findViewById(R.id.button_settings);
settingsButton.setOnClickListener(this);
@@ -51,13 +68,13 @@ public class CheatWarningFragment extends Fragment implements View.OnClickListen
CheatsActivity activity = (CheatsActivity) requireActivity();
try (Settings settings = activity.loadGameSpecificSettings())
{
- boolean cheatsEnabled = BooleanSetting.MAIN_ENABLE_CHEATS.getBoolean(settings);
+ boolean cheatsEnabled = mSetting.getBoolean(settings);
mView.setVisibility(cheatsEnabled ? View.GONE : View.VISIBLE);
}
}
public void onClick(View view)
{
- SettingsActivity.launch(requireContext(), MenuTag.CONFIG_GENERAL);
+ SettingsActivity.launch(requireContext(), mSettingShortcut);
}
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
index 44ee61ed71..d09aaa75b1 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java
@@ -200,6 +200,7 @@ public enum BooleanSetting implements AbstractBooleanSetting
"WaitForShadersBeforeStarting", false),
GFX_SAVE_TEXTURE_CACHE_TO_STATE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS,
"SaveTextureCacheToState", true),
+ GFX_MODS_ENABLE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "EnableMods", false),
GFX_ENHANCE_FORCE_FILTERING(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS,
"ForceFiltering", false),
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
index 8dda6b64c6..137d2e3dc5 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
@@ -756,7 +756,9 @@ public final class SettingsFragmentPresenter
private void addAdvancedGraphicsSettings(ArrayList<SettingsItem> sl)
{
- sl.add(new HeaderSetting(mContext, R.string.custom_textures, 0));
+ sl.add(new HeaderSetting(mContext, R.string.gfx_mods_and_custom_textures, 0));
+ sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_MODS_ENABLE,
+ R.string.gfx_mods, R.string.gfx_mods_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_HIRES_TEXTURES,
R.string.load_custom_texture, R.string.load_custom_texture_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_CACHE_HIRES_TEXTURES,
diff --git a/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml b/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml
index 9c976ac408..ad8ec880af 100644
--- a/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml
+++ b/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml
@@ -6,13 +6,23 @@
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
- android:id="@+id/cheat_warning"
- android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatWarningFragment"
+ android:id="@+id/cheats_warning"
+ android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatsDisabledWarningFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/gfx_mods_warning" />
+
+ <androidx.fragment.app.FragmentContainerView
+ android:id="@+id/gfx_mods_warning"
+ android:name="org.dolphinemu.dolphinemu.features.cheats.ui.GraphicsModsDisabledWarningFragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/cheats_warning"
app:layout_constraintBottom_toTopOf="@id/cheat_list" />
<androidx.recyclerview.widget.RecyclerView
@@ -21,7 +31,7 @@
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintTop_toBottomOf="@id/cheat_warning"
+ app:layout_constraintTop_toBottomOf="@id/gfx_mods_warning"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/Source/Android/app/src/main/res/layout/fragment_cheat_warning.xml b/Source/Android/app/src/main/res/layout/fragment_cheat_warning.xml
index d56a1160b6..6ed47961e2 100644
--- a/Source/Android/app/src/main/res/layout/fragment_cheat_warning.xml
+++ b/Source/Android/app/src/main/res/layout/fragment_cheat_warning.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -10,7 +11,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="@dimen/spacing_large"
- android:text="@string/cheats_disabled_warning"
+ tools:text="@string/cheats_disabled_warning"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/button_settings"
app:layout_constraintStart_toStartOf="parent"
diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml
index 78278fb96b..1b8b3583cf 100644
--- a/Source/Android/app/src/main/res/values/strings.xml
+++ b/Source/Android/app/src/main/res/values/strings.xml
@@ -319,7 +319,9 @@
<string name="wait_for_shaders_description">This causes a delay when launching games, but will reduce stuttering early on.</string>
<string name="advanced_graphics_submenu">Advanced</string>
- <string name="custom_textures">Custom Textures</string>
+ <string name="gfx_mods_and_custom_textures">Graphics Mods and Custom Textures</string>
+ <string name="gfx_mods">Graphics Mods</string>
+ <string name="gfx_mods_description">Loads graphics mods from User/Load/GraphicsMods/.</string>
<string name="load_custom_texture">Load Custom Textures</string>
<string name="load_custom_texture_description">Loads custom textures from User/Load/Textures/&lt;game_id&gt;/ and User/Load/DynamicInputTextures/&lt;game_id&gt;/.</string>
<string name="cache_custom_texture">Prefetch Custom Textures</string>
@@ -488,6 +490,7 @@
<string name="cheats_header_ar">AR Codes</string>
<string name="cheats_header_gecko">Gecko Codes</string>
<string name="cheats_header_patch">Patches</string>
+ <string name="cheats_header_graphics_mod">Graphics Mods</string>
<string name="cheats_add_ar">Add New AR Code</string>
<string name="cheats_add_gecko">Add New Gecko Code</string>
<string name="cheats_add_patch">Add New Patch</string>
@@ -508,6 +511,7 @@
<string name="cheats_download_empty">File contained no codes.</string>
<string name="cheats_download_succeeded">Downloaded %1$d codes. (added %2$d)</string>
<string name="cheats_disabled_warning">Dolphin\'s cheat system is currently disabled.</string>
+ <string name="gfx_mods_disabled_warning">Graphics mods are currently disabled.</string>
<string name="cheats_open_settings">Settings</string>
<!-- Convert Screen -->
diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp
index b125babb81..31511b485c 100644
--- a/Source/Android/jni/AndroidCommon/IDCache.cpp
+++ b/Source/Android/jni/AndroidCommon/IDCache.cpp
@@ -70,6 +70,14 @@ static jclass s_patch_cheat_class;
static jfieldID s_patch_cheat_pointer;
static jmethodID s_patch_cheat_constructor;
+static jclass s_graphics_mod_group_class;
+static jfieldID s_graphics_mod_group_pointer;
+static jmethodID s_graphics_mod_group_constructor;
+
+static jclass s_graphics_mod_class;
+static jfieldID s_graphics_mod_pointer;
+static jmethodID s_graphics_mod_constructor;
+
static jclass s_riivolution_patches_class;
static jfieldID s_riivolution_patches_pointer;
@@ -331,6 +339,36 @@ jmethodID GetPatchCheatConstructor()
return s_patch_cheat_constructor;
}
+jclass GetGraphicsModClass()
+{
+ return s_graphics_mod_class;
+}
+
+jfieldID GetGraphicsModPointer()
+{
+ return s_graphics_mod_pointer;
+}
+
+jmethodID GetGraphicsModConstructor()
+{
+ return s_graphics_mod_constructor;
+}
+
+jclass GetGraphicsModGroupClass()
+{
+ return s_graphics_mod_group_class;
+}
+
+jfieldID GetGraphicsModGroupPointer()
+{
+ return s_graphics_mod_group_pointer;
+}
+
+jmethodID GetGraphicsModGroupConstructor()
+{
+ return s_graphics_mod_group_constructor;
+}
+
jclass GetRiivolutionPatchesClass()
{
return s_riivolution_patches_class;
@@ -480,6 +518,23 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_patch_cheat_constructor = env->GetMethodID(patch_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(patch_cheat_class);
+ const jclass graphics_mod_group_class =
+ env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup");
+ s_graphics_mod_group_class =
+ reinterpret_cast<jclass>(env->NewGlobalRef(graphics_mod_group_class));
+ s_graphics_mod_group_pointer = env->GetFieldID(graphics_mod_group_class, "mPointer", "J");
+ s_graphics_mod_group_constructor = env->GetMethodID(graphics_mod_group_class, "<init>", "(J)V");
+ env->DeleteLocalRef(graphics_mod_group_class);
+
+ const jclass graphics_mod_class =
+ env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/GraphicsMod");
+ s_graphics_mod_class = reinterpret_cast<jclass>(env->NewGlobalRef(graphics_mod_class));
+ s_graphics_mod_pointer = env->GetFieldID(graphics_mod_class, "mPointer", "J");
+ s_graphics_mod_constructor =
+ env->GetMethodID(graphics_mod_class, "<init>",
+ "(JLorg/dolphinemu/dolphinemu/features/cheats/model/GraphicsModGroup;)V");
+ env->DeleteLocalRef(graphics_mod_class);
+
const jclass riivolution_patches_class =
env->FindClass("org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches");
s_riivolution_patches_class =
@@ -516,6 +571,8 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
env->DeleteGlobalRef(s_ar_cheat_class);
env->DeleteGlobalRef(s_gecko_cheat_class);
env->DeleteGlobalRef(s_patch_cheat_class);
+ env->DeleteGlobalRef(s_graphics_mod_group_class);
+ env->DeleteGlobalRef(s_graphics_mod_class);
env->DeleteGlobalRef(s_riivolution_patches_class);
env->DeleteGlobalRef(s_wii_update_cb_class);
}
diff --git a/Source/Android/jni/AndroidCommon/IDCache.h b/Source/Android/jni/AndroidCommon/IDCache.h
index 83eaa85894..58a0aa17bd 100644
--- a/Source/Android/jni/AndroidCommon/IDCache.h
+++ b/Source/Android/jni/AndroidCommon/IDCache.h
@@ -69,6 +69,14 @@ jclass GetPatchCheatClass();
jfieldID GetPatchCheatPointer();
jmethodID GetPatchCheatConstructor();
+jclass GetGraphicsModGroupClass();
+jfieldID GetGraphicsModGroupPointer();
+jmethodID GetGraphicsModGroupConstructor();
+
+jclass GetGraphicsModClass();
+jfieldID GetGraphicsModPointer();
+jmethodID GetGraphicsModConstructor();
+
jclass GetRiivolutionPatchesClass();
jfieldID GetRiivolutionPatchesPointer();
diff --git a/Source/Android/jni/CMakeLists.txt b/Source/Android/jni/CMakeLists.txt
index 74d9d90e03..146019501e 100644
--- a/Source/Android/jni/CMakeLists.txt
+++ b/Source/Android/jni/CMakeLists.txt
@@ -2,6 +2,8 @@ add_library(main SHARED
Cheats/ARCheat.cpp
Cheats/Cheats.h
Cheats/GeckoCheat.cpp
+ Cheats/GraphicsMod.cpp
+ Cheats/GraphicsModGroup.cpp
Cheats/PatchCheat.cpp
Config/NativeConfig.cpp
Config/PostProcessing.cpp
diff --git a/Source/Android/jni/Cheats/GraphicsMod.cpp b/Source/Android/jni/Cheats/GraphicsMod.cpp
new file mode 100644
index 0000000000..627351f546
--- /dev/null
+++ b/Source/Android/jni/Cheats/GraphicsMod.cpp
@@ -0,0 +1,53 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <string>
+
+#include <jni.h>
+
+#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
+#include "jni/AndroidCommon/AndroidCommon.h"
+#include "jni/AndroidCommon/IDCache.h"
+
+static GraphicsModConfig* GetPointer(JNIEnv* env, jobject obj)
+{
+ return reinterpret_cast<GraphicsModConfig*>(
+ env->GetLongField(obj, IDCache::GetGraphicsModPointer()));
+}
+
+extern "C" {
+
+JNIEXPORT jstring JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsMod_getName(JNIEnv* env, jobject obj)
+{
+ return ToJString(env, GetPointer(env, obj)->m_title);
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsMod_getCreator(JNIEnv* env,
+ jobject obj)
+{
+ return ToJString(env, GetPointer(env, obj)->m_author);
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsMod_getNotes(JNIEnv* env, jobject obj)
+{
+ return ToJString(env, GetPointer(env, obj)->m_description);
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsMod_getEnabled(JNIEnv* env,
+ jobject obj)
+{
+ return static_cast<jboolean>(GetPointer(env, obj)->m_enabled);
+}
+
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsMod_setEnabledImpl(JNIEnv* env,
+ jobject obj,
+ jboolean enabled)
+{
+ GetPointer(env, obj)->m_enabled = static_cast<bool>(enabled);
+}
+}
diff --git a/Source/Android/jni/Cheats/GraphicsModGroup.cpp b/Source/Android/jni/Cheats/GraphicsModGroup.cpp
new file mode 100644
index 0000000000..e7a9329b53
--- /dev/null
+++ b/Source/Android/jni/Cheats/GraphicsModGroup.cpp
@@ -0,0 +1,92 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <jni.h>
+
+#include <set>
+#include <vector>
+
+#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
+#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
+#include "jni/AndroidCommon/AndroidCommon.h"
+#include "jni/AndroidCommon/IDCache.h"
+
+static GraphicsModGroupConfig* GetPointer(JNIEnv* env, jobject obj)
+{
+ return reinterpret_cast<GraphicsModGroupConfig*>(
+ env->GetLongField(obj, IDCache::GetGraphicsModGroupPointer()));
+}
+
+jobject GraphicsModToJava(JNIEnv* env, GraphicsModConfig* mod, jobject jGraphicsModGroup)
+{
+ return env->NewObject(IDCache::GetGraphicsModClass(), IDCache::GetGraphicsModConstructor(),
+ reinterpret_cast<jlong>(mod), jGraphicsModGroup);
+}
+
+extern "C" {
+
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsModGroup_finalize(JNIEnv* env,
+ jobject obj)
+{
+ delete GetPointer(env, obj);
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsModGroup_getMods(JNIEnv* env,
+ jobject obj)
+{
+ GraphicsModGroupConfig* mod_group = GetPointer(env, obj);
+
+ std::set<std::string> groups;
+
+ for (const GraphicsModConfig& mod : mod_group->GetMods())
+ {
+ for (const GraphicsTargetGroupConfig& group : mod.m_groups)
+ groups.insert(group.m_name);
+ }
+
+ std::vector<GraphicsModConfig*> mods;
+
+ for (GraphicsModConfig& mod : mod_group->GetMods())
+ {
+ // If no group matches the mod's features, or if the mod has no features, skip it
+ if (std::none_of(mod.m_features.begin(), mod.m_features.end(),
+ [&groups](const GraphicsModFeatureConfig& feature) {
+ return groups.count(feature.m_group) == 1;
+ }))
+ {
+ continue;
+ }
+
+ mods.push_back(&mod);
+ }
+
+ const jobjectArray array =
+ env->NewObjectArray(static_cast<jsize>(mods.size()), IDCache::GetGraphicsModClass(), nullptr);
+
+ jsize i = 0;
+ for (GraphicsModConfig* mod : mods)
+ env->SetObjectArrayElement(array, i++, GraphicsModToJava(env, mod, obj));
+
+ return array;
+}
+
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsModGroup_save(JNIEnv* env, jobject obj)
+{
+ GetPointer(env, obj)->Save();
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsModGroup_load(JNIEnv* env, jclass,
+ jstring jGameId)
+{
+ auto* mod_group = new GraphicsModGroupConfig(GetJString(env, jGameId));
+
+ mod_group->Load();
+
+ return env->NewObject(IDCache::GetGraphicsModGroupClass(),
+ IDCache::GetGraphicsModGroupConstructor(), mod_group);
+}
+}