forked from dolphin-emu/dolphin
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dolphin-emu#10184 from JosJuice/android-riivolution
Android: Allow starting game with Riivolution patches from the GUI
- Loading branch information
Showing
26 changed files
with
822 additions
and
37 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
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
86 changes: 86 additions & 0 deletions
86
...rc/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.java
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,86 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
package org.dolphinemu.dolphinemu.features.riivolution.model; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
public class RiivolutionPatches | ||
{ | ||
private String mGameId; | ||
private int mRevision; | ||
private int mDiscNumber; | ||
|
||
private boolean mUnsavedChanges = false; | ||
|
||
@Keep | ||
private long mPointer; | ||
|
||
public RiivolutionPatches(String gameId, int revision, int discNumber) | ||
{ | ||
mGameId = gameId; | ||
mRevision = revision; | ||
mDiscNumber = discNumber; | ||
|
||
mPointer = initialize(); | ||
} | ||
|
||
@Override | ||
public native void finalize(); | ||
|
||
private static native long initialize(); | ||
|
||
public native int getDiscCount(); | ||
|
||
public native String getDiscName(int discIndex); | ||
|
||
public native int getSectionCount(int discIndex); | ||
|
||
public native String getSectionName(int discIndex, int sectionIndex); | ||
|
||
public native int getOptionCount(int discIndex, int sectionIndex); | ||
|
||
public native String getOptionName(int discIndex, int sectionIndex, int optionIndex); | ||
|
||
public native int getChoiceCount(int discIndex, int sectionIndex, int optionIndex); | ||
|
||
public native String getChoiceName(int discIndex, int sectionIndex, int optionIndex, | ||
int choiceIndex); | ||
|
||
/** | ||
* @return 0 if no choice is selected, otherwise the index of the selected choice plus one. | ||
*/ | ||
public native int getSelectedChoice(int discIndex, int sectionIndex, int optionIndex); | ||
|
||
/** | ||
* @param choiceIndex 0 to select no choice, otherwise the choice index plus one. | ||
*/ | ||
public void setSelectedChoice(int discIndex, int sectionIndex, int optionIndex, int choiceIndex) | ||
{ | ||
mUnsavedChanges = true; | ||
setSelectedChoiceImpl(discIndex, sectionIndex, optionIndex, choiceIndex); | ||
} | ||
|
||
/** | ||
* @param choiceIndex 0 to select no choice, otherwise the choice index plus one. | ||
*/ | ||
private native void setSelectedChoiceImpl(int discIndex, int sectionIndex, int optionIndex, | ||
int choiceIndex); | ||
|
||
public void loadConfig() | ||
{ | ||
loadConfigImpl(mGameId, mRevision, mDiscNumber); | ||
} | ||
|
||
private native void loadConfigImpl(String gameId, int revision, int discNumber); | ||
|
||
public void saveConfig() | ||
{ | ||
if (mUnsavedChanges) | ||
{ | ||
mUnsavedChanges = false; | ||
saveConfigImpl(mGameId); | ||
} | ||
} | ||
|
||
private native void saveConfigImpl(String gameId); | ||
} |
84 changes: 84 additions & 0 deletions
84
...p/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionAdapter.java
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,84 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
package org.dolphinemu.dolphinemu.features.riivolution.ui; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import org.dolphinemu.dolphinemu.R; | ||
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class RiivolutionAdapter extends RecyclerView.Adapter<RiivolutionViewHolder> | ||
{ | ||
private final Context mContext; | ||
private final RiivolutionPatches mPatches; | ||
private final ArrayList<RiivolutionItem> mItems = new ArrayList<>(); | ||
|
||
public RiivolutionAdapter(Context context, RiivolutionPatches patches) | ||
{ | ||
mContext = context; | ||
mPatches = patches; | ||
|
||
int discCount = mPatches.getDiscCount(); | ||
for (int i = 0; i < discCount; i++) | ||
{ | ||
mItems.add(new RiivolutionItem(i)); | ||
|
||
int sectionCount = mPatches.getSectionCount(i); | ||
for (int j = 0; j < sectionCount; j++) | ||
{ | ||
mItems.add(new RiivolutionItem(i, j)); | ||
|
||
int optionCount = mPatches.getOptionCount(i, j); | ||
for (int k = 0; k < optionCount; k++) | ||
{ | ||
mItems.add(new RiivolutionItem(i, j, k)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@NonNull @Override | ||
public RiivolutionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) | ||
{ | ||
LayoutInflater inflater = LayoutInflater.from(parent.getContext()); | ||
|
||
switch (viewType) | ||
{ | ||
case RiivolutionViewHolder.TYPE_HEADER: | ||
View headerView = inflater.inflate(R.layout.list_item_riivolution_header, parent, false); | ||
return new RiivolutionViewHolder(headerView); | ||
case RiivolutionViewHolder.TYPE_OPTION: | ||
View optionView = inflater.inflate(R.layout.list_item_riivolution_option, parent, false); | ||
return new RiivolutionViewHolder(optionView); | ||
default: | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull RiivolutionViewHolder holder, int position) | ||
{ | ||
holder.bind(mContext, mPatches, mItems.get(position)); | ||
} | ||
|
||
@Override | ||
public int getItemCount() | ||
{ | ||
return mItems.size(); | ||
} | ||
|
||
@Override | ||
public int getItemViewType(int position) | ||
{ | ||
return mItems.get(position).mOptionIndex != -1 ? | ||
RiivolutionViewHolder.TYPE_OPTION : RiivolutionViewHolder.TYPE_HEADER; | ||
} | ||
} |
Oops, something went wrong.