Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #11615 from t895/kotlin-riivolution
Android: Convert Riivolution Boot Activity to Kotlin
- Loading branch information
Showing
11 changed files
with
380 additions
and
418 deletions.
There are no files selected for viewing
86 changes: 0 additions & 86 deletions
86
...rc/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
.../src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.kt
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,80 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| package org.dolphinemu.dolphinemu.features.riivolution.model | ||
|
|
||
| import androidx.annotation.Keep | ||
|
|
||
| class RiivolutionPatches( | ||
| private val gameId: String, | ||
| private val revision: Int, | ||
| private val discNumber: Int | ||
| ) { | ||
| private var unsavedChanges = false | ||
|
|
||
| @Keep | ||
| private val pointer: Long = initialize() | ||
|
|
||
| external fun finalize() | ||
|
|
||
| external fun getDiscCount(): Int | ||
|
|
||
| external fun getDiscName(discIndex: Int): String | ||
|
|
||
| external fun getSectionCount(discIndex: Int): Int | ||
|
|
||
| external fun getSectionName(discIndex: Int, sectionIndex: Int): String | ||
|
|
||
| external fun getOptionCount(discIndex: Int, sectionIndex: Int): Int | ||
|
|
||
| external fun getOptionName(discIndex: Int, sectionIndex: Int, optionIndex: Int): String | ||
|
|
||
| external fun getChoiceCount(discIndex: Int, sectionIndex: Int, optionIndex: Int): Int | ||
|
|
||
| external fun getChoiceName( | ||
| discIndex: Int, | ||
| sectionIndex: Int, | ||
| optionIndex: Int, | ||
| choiceIndex: Int | ||
| ): String | ||
|
|
||
| /** | ||
| * @return 0 if no choice is selected, otherwise the index of the selected choice plus one. | ||
| */ | ||
| external fun getSelectedChoice(discIndex: Int, sectionIndex: Int, optionIndex: Int): Int | ||
|
|
||
| /** | ||
| * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. | ||
| */ | ||
| fun setSelectedChoice(discIndex: Int, sectionIndex: Int, optionIndex: Int, choiceIndex: Int) { | ||
| unsavedChanges = true | ||
| setSelectedChoiceImpl(discIndex, sectionIndex, optionIndex, choiceIndex) | ||
| } | ||
|
|
||
| /** | ||
| * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. | ||
| */ | ||
| private external fun setSelectedChoiceImpl( | ||
| discIndex: Int, sectionIndex: Int, optionIndex: Int, | ||
| choiceIndex: Int | ||
| ) | ||
|
|
||
| fun loadConfig() { | ||
| loadConfigImpl(gameId, revision, discNumber) | ||
| } | ||
|
|
||
| private external fun loadConfigImpl(gameId: String, revision: Int, discNumber: Int) | ||
|
|
||
| fun saveConfig() { | ||
| if (unsavedChanges) { | ||
| unsavedChanges = false | ||
| saveConfigImpl(gameId) | ||
| } | ||
| } | ||
|
|
||
| private external fun saveConfigImpl(gameId: String) | ||
|
|
||
| companion object { | ||
| @JvmStatic | ||
| private external fun initialize(): Long | ||
| } | ||
| } |
66 changes: 0 additions & 66 deletions
66
...p/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionAdapter.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionAdapter.kt
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,46 @@ | ||
| // 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.ViewGroup | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import org.dolphinemu.dolphinemu.databinding.ListItemRiivolutionBinding | ||
| import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches | ||
|
|
||
| class RiivolutionAdapter(private val context: Context, private val patches: RiivolutionPatches) : | ||
| RecyclerView.Adapter<RiivolutionViewHolder>() { | ||
| private val items = ArrayList<RiivolutionItem>() | ||
|
|
||
| init { | ||
| val discCount = patches.getDiscCount() | ||
| for (i in 0 until discCount) { | ||
| items.add(RiivolutionItem(i)) | ||
|
|
||
| val sectionCount = patches.getSectionCount(i) | ||
| for (j in 0 until sectionCount) { | ||
| items.add(RiivolutionItem(i, j)) | ||
|
|
||
| val optionCount = patches.getOptionCount(i, j) | ||
| for (k in 0 until optionCount) { | ||
| items.add(RiivolutionItem(i, j, k)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RiivolutionViewHolder { | ||
| val inflater = LayoutInflater.from(parent.context) | ||
| val binding = ListItemRiivolutionBinding.inflate(inflater) | ||
| return RiivolutionViewHolder(binding.root, binding) | ||
| } | ||
|
|
||
| override fun onBindViewHolder(holder: RiivolutionViewHolder, position: Int) { | ||
| holder.bind(context, patches, items[position]) | ||
| } | ||
|
|
||
| override fun getItemCount(): Int { | ||
| return items.size | ||
| } | ||
| } |
Oops, something went wrong.