summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-03-08 21:38:03 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:38 +0200
commitbbe5dee9f8473b1aaf2059efd9ab83b7be444bf6 (patch)
tree0a6f63be11c4bfa595e76f74fbf7421f067e34ff /src
parentandroid: Convert EmulationFragment to Kotlin (diff)
downloadyuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar.gz
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar.bz2
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar.lz
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar.xz
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.tar.zst
yuzu-bbe5dee9f8473b1aaf2059efd9ab83b7be444bf6.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.java76
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.kt56
2 files changed, 56 insertions, 76 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.java
deleted file mode 100644
index 681117268..000000000
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.yuzu.yuzu_emu.model;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-
-import java.nio.file.Paths;
-
-public final class Game {
- private String mTitle;
- private String mDescription;
- private String mPath;
- private String mGameId;
- private String mCompany;
- private String mRegions;
-
- public Game(String title, String description, String regions, String path,
- String gameId, String company) {
- mTitle = title;
- mDescription = description;
- mRegions = regions;
- mPath = path;
- mGameId = gameId;
- mCompany = company;
- }
-
- public static ContentValues asContentValues(String title, String description, String regions, String path, String gameId, String company) {
- ContentValues values = new ContentValues();
-
- if (gameId.isEmpty()) {
- // Homebrew, etc. may not have a game ID, use filename as a unique identifier
- gameId = Paths.get(path).getFileName().toString();
- }
-
- values.put(GameDatabase.KEY_GAME_TITLE, title);
- values.put(GameDatabase.KEY_GAME_DESCRIPTION, description);
- values.put(GameDatabase.KEY_GAME_REGIONS, regions);
- values.put(GameDatabase.KEY_GAME_PATH, path);
- values.put(GameDatabase.KEY_GAME_ID, gameId);
- values.put(GameDatabase.KEY_GAME_COMPANY, company);
-
- return values;
- }
-
- public static Game fromCursor(Cursor cursor) {
- return new Game(cursor.getString(GameDatabase.GAME_COLUMN_TITLE),
- cursor.getString(GameDatabase.GAME_COLUMN_DESCRIPTION),
- cursor.getString(GameDatabase.GAME_COLUMN_REGIONS),
- cursor.getString(GameDatabase.GAME_COLUMN_PATH),
- cursor.getString(GameDatabase.GAME_COLUMN_GAME_ID),
- cursor.getString(GameDatabase.GAME_COLUMN_CAPTION));
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public String getDescription() {
- return mDescription;
- }
-
- public String getCompany() {
- return mCompany;
- }
-
- public String getRegions() {
- return mRegions;
- }
-
- public String getPath() {
- return mPath;
- }
-
- public String getGameId() {
- return mGameId;
- }
-}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.kt
new file mode 100644
index 000000000..5653d9313
--- /dev/null
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Game.kt
@@ -0,0 +1,56 @@
+package org.yuzu.yuzu_emu.model
+
+import android.content.ContentValues
+import android.database.Cursor
+import java.nio.file.Paths
+import java.util.HashSet
+
+class Game(
+ val title: String,
+ val description: String,
+ val regions: String,
+ val path: String,
+ val gameId: String,
+ val company: String
+) {
+ companion object {
+ val extensions: Set<String> = HashSet(
+ listOf(".xci", ".nsp", ".nca", ".nro")
+ )
+
+ @JvmStatic
+ fun asContentValues(
+ title: String?,
+ description: String?,
+ regions: String?,
+ path: String?,
+ gameId: String,
+ company: String?
+ ): ContentValues {
+ var realGameId = gameId
+ val values = ContentValues()
+ if (realGameId.isEmpty()) {
+ // Homebrew, etc. may not have a game ID, use filename as a unique identifier
+ realGameId = Paths.get(path).fileName.toString()
+ }
+ values.put(GameDatabase.KEY_GAME_TITLE, title)
+ values.put(GameDatabase.KEY_GAME_DESCRIPTION, description)
+ values.put(GameDatabase.KEY_GAME_REGIONS, regions)
+ values.put(GameDatabase.KEY_GAME_PATH, path)
+ values.put(GameDatabase.KEY_GAME_ID, realGameId)
+ values.put(GameDatabase.KEY_GAME_COMPANY, company)
+ return values
+ }
+
+ fun fromCursor(cursor: Cursor): Game {
+ return Game(
+ cursor.getString(GameDatabase.GAME_COLUMN_TITLE),
+ cursor.getString(GameDatabase.GAME_COLUMN_DESCRIPTION),
+ cursor.getString(GameDatabase.GAME_COLUMN_REGIONS),
+ cursor.getString(GameDatabase.GAME_COLUMN_PATH),
+ cursor.getString(GameDatabase.GAME_COLUMN_GAME_ID),
+ cursor.getString(GameDatabase.GAME_COLUMN_CAPTION)
+ )
+ }
+ }
+}