summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/citra/citra_emu/model/Game.java
blob: a4ffc59c71ae478381c67a9b4ce5e5044da36cfc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package org.citra.citra_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_COMPANY));
    }

    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;
    }
}