@@ -0,0 +1,69 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.model

import androidx.annotation.Keep

@Keep
class GameFile private constructor(private val pointer: Long) {
external fun finalize()

external fun getPlatform(): Int

external fun getTitle(): String

external fun getDescription(): String

external fun getCompany(): String

external fun getCountry(): Int

external fun getRegion(): Int

external fun getPath(): String

external fun getGameId(): String

external fun getGameTdbId(): String

external fun getDiscNumber(): Int

external fun getRevision(): Int

external fun getBlobType(): Int

external fun getFileFormatName(): String

external fun getBlockSize(): Long

external fun getCompressionMethod(): String

external fun shouldShowFileFormatDetails(): Boolean

external fun shouldAllowConversion(): Boolean

external fun getFileSize(): Long

external fun isDatelDisc(): Boolean

external fun isNKit(): Boolean

external fun getBanner(): IntArray

external fun getBannerWidth(): Int

external fun getBannerHeight(): Int

val customCoverPath: String
get() = "${getPath().substring(0, getPath().lastIndexOf("."))}.cover.png"

companion object {
var REGION_NTSC_J = 0
var REGION_NTSC_U = 1
var REGION_PAL = 2
var REGION_NTSC_K = 4

@JvmStatic
external fun parse(path: String): GameFile?
}
}

This file was deleted.

@@ -0,0 +1,152 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.model

import androidx.annotation.Keep
import org.dolphinemu.dolphinemu.NativeLibrary
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting
import org.dolphinemu.dolphinemu.features.settings.model.Settings
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile
import org.dolphinemu.dolphinemu.utils.ContentHandler
import org.dolphinemu.dolphinemu.utils.IniFile
import java.io.File

class GameFileCache {
@Keep
private val pointer: Long = newGameFileCache()

external fun finalize()

@Synchronized
external fun getSize(): Int

@Synchronized
external fun getAllGames(): Array<GameFile>

@Synchronized
external fun addOrGet(gamePath: String): GameFile?

/**
* Sets the list of games to cache.
*
* Games which are in the passed-in list but not in the cache are scanned and added to the cache,
* and games which are in the cache but not in the passed-in list are removed from the cache.
*
* @return true if the cache was modified
*/
@Synchronized
external fun update(gamePaths: Array<String>): Boolean

/**
* For each game that already is in the cache, scans the folder that contains the game
* for additional metadata files (PNG/XML).
*
* @return true if the cache was modified
*/
@Synchronized
external fun updateAdditionalMetadata(): Boolean

@Synchronized
external fun load(): Boolean

@Synchronized
external fun save(): Boolean

companion object {
@JvmStatic
private external fun newGameFileCache(): Long

fun addGameFolder(path: String) {
val dolphinFile = SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN)
val dolphinIni = IniFile(dolphinFile)
val pathSet = getPathSet(false)
val totalISOPaths =
dolphinIni.getInt(Settings.SECTION_INI_GENERAL, SettingsFile.KEY_ISO_PATHS, 0)

if (!pathSet.contains(path)) {
dolphinIni.setInt(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATHS,
totalISOPaths + 1
)
dolphinIni.setString(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATH_BASE + totalISOPaths,
path
)
dolphinIni.save(dolphinFile)
NativeLibrary.ReloadConfig()
}
}

private fun getPathSet(removeNonExistentFolders: Boolean): LinkedHashSet<String> {
val dolphinFile = SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN)
val dolphinIni = IniFile(dolphinFile)
val pathSet = LinkedHashSet<String>()
val totalISOPaths =
dolphinIni.getInt(Settings.SECTION_INI_GENERAL, SettingsFile.KEY_ISO_PATHS, 0)

for (i in 0 until totalISOPaths) {
val path = dolphinIni.getString(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATH_BASE + i,
""
)

val pathExists = if (ContentHandler.isContentUri(path))
ContentHandler.exists(path)
else
File(path).exists()
if (pathExists) {
pathSet.add(path)
}
}

if (removeNonExistentFolders && totalISOPaths > pathSet.size) {
var setIndex = 0

dolphinIni.setInt(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATHS,
pathSet.size
)

// One or more folders have been removed.
for (entry in pathSet) {
dolphinIni.setString(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATH_BASE + setIndex,
entry
)
setIndex++
}

// Delete known unnecessary keys. Ignore i values beyond totalISOPaths.
for (i in setIndex until totalISOPaths) {
dolphinIni.deleteKey(
Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_ISO_PATH_BASE + i
)
}

dolphinIni.save(dolphinFile)
NativeLibrary.ReloadConfig()
}
return pathSet
}

@JvmStatic
fun getAllGamePaths(): Array<String> {
val recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.boolean
val folderPathsSet = getPathSet(true)
val folderPaths = folderPathsSet.toTypedArray()
return getAllGamePaths(folderPaths, recursiveScan)
}

@JvmStatic
external fun getAllGamePaths(
folderPaths: Array<String>,
recursiveScan: Boolean
): Array<String>
}
}

This file was deleted.

@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.model

import android.net.Uri

/**
* Represents a home screen channel for Android TV api 26+
*/
class HomeScreenChannel(var name: String, var description: String, var appLinkIntentUri: Uri) {
var channelId: Long = 0
}

This file was deleted.

@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.model

class TvSettingsItem(val itemId: Int, val iconId: Int, val labelId: Int)
Expand Up @@ -123,7 +123,7 @@ class MainPresenter(private val mainView: MainView, private val activity: Fragme

fun onResume() {
if (dirToAdd != null) {
GameFileCache.addGameFolder(dirToAdd)
GameFileCache.addGameFolder(dirToAdd!!)
dirToAdd = null
}

Expand Down
Expand Up @@ -8,16 +8,16 @@ object CoverHelper {
@JvmStatic
fun buildGameTDBUrl(game: GameFile, region: String?): String {
val baseUrl = "https://art.gametdb.com/wii/cover/%s/%s.png"
return String.format(baseUrl, region, game.gameTdbId)
return String.format(baseUrl, region, game.getGameTdbId())
}

@JvmStatic
fun getRegion(game: GameFile): String {
val region: String = when (game.region) {
val region: String = when (game.getRegion()) {
GameFile.REGION_NTSC_J -> "JA"
GameFile.REGION_NTSC_U -> "US"
GameFile.REGION_NTSC_K -> "KO"
GameFile.REGION_PAL -> when (game.country) {
GameFile.REGION_PAL -> when (game.getCountry()) {
3 -> "AU" // Australia
4 -> "FR" // France
5 -> "DE" // Germany
Expand Down
4 changes: 2 additions & 2 deletions Source/Android/jni/AndroidCommon/IDCache.cpp
Expand Up @@ -563,14 +563,14 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)

const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
s_game_file_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_class));
s_game_file_pointer = env->GetFieldID(game_file_class, "mPointer", "J");
s_game_file_pointer = env->GetFieldID(game_file_class, "pointer", "J");
s_game_file_constructor = env->GetMethodID(game_file_class, "<init>", "(J)V");
env->DeleteLocalRef(game_file_class);

const jclass game_file_cache_class =
env->FindClass("org/dolphinemu/dolphinemu/model/GameFileCache");
s_game_file_cache_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_cache_class));
s_game_file_cache_pointer = env->GetFieldID(game_file_cache_class, "mPointer", "J");
s_game_file_cache_pointer = env->GetFieldID(game_file_cache_class, "pointer", "J");
env->DeleteLocalRef(game_file_cache_class);

const jclass analytics_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Analytics");
Expand Down