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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "jni/GameList/GameFile.h"
#include <chrono>
#include <memory>
#include <utility>
#include <vector>
#include <jni.h>
#include "Core/TimePlayed.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "UICommon/GameFile.h"
#include "jni/AndroidCommon/AndroidCommon.h"
#include "jni/AndroidCommon/IDCache.h"
static std::shared_ptr<const UICommon::GameFile>* GetPointer(JNIEnv* env, jobject obj)
{
return reinterpret_cast<std::shared_ptr<const UICommon::GameFile>*>(
env->GetLongField(obj, IDCache::GetGameFilePointer()));
}
static std::shared_ptr<const UICommon::GameFile>& GetRef(JNIEnv* env, jobject obj)
{
return *GetPointer(env, obj);
}
jobject GameFileToJava(JNIEnv* env, std::shared_ptr<const UICommon::GameFile> game_file)
{
if (!game_file)
return nullptr;
return env->NewObject(
IDCache::GetGameFileClass(), IDCache::GetGameFileConstructor(),
reinterpret_cast<jlong>(new std::shared_ptr<const UICommon::GameFile>(std::move(game_file))));
}
extern "C" {
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_finalize(JNIEnv* env,
jobject obj)
{
delete GetPointer(env, obj);
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getPlatform(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetPlatform());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getTitle(JNIEnv* env,
jobject obj)
{
return ToJString(env,
GetRef(env, obj)->GetName(UICommon::GameFile::Variant::LongAndPossiblyCustom));
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getDescription(JNIEnv* env,
jobject obj)
{
return ToJString(
env, GetRef(env, obj)->GetDescription(UICommon::GameFile::Variant::LongAndPossiblyCustom));
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getCompany(JNIEnv* env,
jobject obj)
{
return ToJString(env, DiscIO::GetCompanyFromID(GetRef(env, obj)->GetMakerID()));
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getCountry(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetCountry());
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getRegion(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetRegion());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getPath(JNIEnv* env,
jobject obj)
{
return ToJString(env, GetRef(env, obj)->GetFilePath());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getGameId(JNIEnv* env,
jobject obj)
{
return ToJString(env, GetRef(env, obj)->GetGameID());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getGameTdbId(JNIEnv* env,
jobject obj)
{
return ToJString(env, GetRef(env, obj)->GetGameTDBID());
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getDiscNumber(JNIEnv* env,
jobject obj)
{
return GetRef(env, obj)->GetDiscNumber();
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getRevision(JNIEnv* env,
jobject obj)
{
return GetRef(env, obj)->GetRevision();
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBlobType(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetBlobType());
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_model_GameFile_getFileFormatName(JNIEnv* env, jobject obj)
{
return ToJString(env, GetRef(env, obj)->GetFileFormatName());
}
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBlockSize(JNIEnv* env,
jobject obj)
{
return GetRef(env, obj)->GetBlockSize();
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_model_GameFile_getCompressionMethod(JNIEnv* env, jobject obj)
{
return ToJString(env, GetRef(env, obj)->GetCompressionMethod());
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_model_GameFile_shouldShowFileFormatDetails(JNIEnv* env, jobject obj)
{
return static_cast<jboolean>(GetRef(env, obj)->ShouldShowFileFormatDetails());
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_model_GameFile_shouldAllowConversion(JNIEnv* env, jobject obj)
{
return static_cast<jboolean>(GetRef(env, obj)->ShouldAllowConversion());
}
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env,
jobject obj)
{
return GetRef(env, obj)->GetFileSize();
}
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_isDatelDisc(JNIEnv* env,
jobject obj)
{
return static_cast<jboolean>(GetRef(env, obj)->IsDatelDisc());
}
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_isNKit(JNIEnv* env,
jobject obj)
{
return static_cast<jboolean>(GetRef(env, obj)->IsNKit());
}
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBanner(JNIEnv* env,
jobject obj)
{
const std::vector<u32>& buffer = GetRef(env, obj)->GetBannerImage().buffer;
const auto size = static_cast<jsize>(buffer.size());
const jintArray out_array = env->NewIntArray(size);
if (!out_array)
return nullptr;
env->SetIntArrayRegion(out_array, 0, size, reinterpret_cast<const jint*>(buffer.data()));
return out_array;
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBannerWidth(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetBannerImage().width);
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBannerHeight(JNIEnv* env,
jobject obj)
{
return static_cast<jint>(GetRef(env, obj)->GetBannerImage().height);
}
JNIEXPORT jlong JNICALL
Java_org_dolphinemu_dolphinemu_model_GameFile_getTimePlayedMsInternal(JNIEnv* env, jobject obj)
{
const std::chrono::milliseconds time = TimePlayed().GetTimePlayed(GetRef(env, obj)->GetGameID());
return time.count();
}
JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_parse(JNIEnv* env, jclass,
jstring path)
{
auto game_file = std::make_shared<UICommon::GameFile>(GetJString(env, path));
if (!game_file->IsValid())
game_file.reset();
return GameFileToJava(env, game_file);
}
}
|