Skip to content

Commit

Permalink
Add CopyLeaderboardRecordByUserId
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelOtter committed Oct 17, 2023
1 parent 2dc6a1a commit 510ecc1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/bearwaves/eos4j/EOSLeaderboards.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public LeaderboardRecord copyLeaderboardRecordByIndex(CopyLeaderboardRecordByInd
return EOSLeaderboardsNative.copyLeaderboardRecordByIndex(handle, options);
}

public LeaderboardRecord copyLeaderboardRecordByUserId(CopyLeaderboardRecordByUserIdOptions options) throws EOSException {
return EOSLeaderboardsNative.copyLeaderboardRecordByUserId(handle, options);
}

public static class QueryLeaderboardDefinitionsOptions {
public final EOS.ProductUserId localUserId;
public final Date startTime;
Expand Down Expand Up @@ -140,6 +144,14 @@ public CopyLeaderboardRecordByIndexOptions(int index) {
}
}

public static class CopyLeaderboardRecordByUserIdOptions {
EOS.ProductUserId userId;

public CopyLeaderboardRecordByUserIdOptions(EOS.ProductUserId userId) {
this.userId = userId;
}
}

public interface OnQueryLeaderboardDefinitionsCompleteCallback {
void run(OnQueryLeaderboardDefinitionsCompleteCallbackInfo data);
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/bearwaves/eos4j/EOSLeaderboardsNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,35 @@ static native EOSLeaderboards.LeaderboardRecord copyLeaderboardRecordByIndex(
return env->NewObject(result_cls, result_ctor, (long long) out_record, user_id, out_record->Rank, out_record->Score, env->NewStringUTF(out_record->UserDisplayName));
*/

static native EOSLeaderboards.LeaderboardRecord copyLeaderboardRecordByUserId(
long handle,
EOSLeaderboards.CopyLeaderboardRecordByUserIdOptions options
) throws EOSException; /*
jobject user_id_obj = EOS4J::javaObjectFromObjectField(env, options, "userId", "Lcom/bearwaves/eos4j/EOS$ProductUserId;");
auto user_id = EOS4J::javaLongFromObjectField(env, user_id_obj, "ptr");
EOS_Leaderboards_CopyLeaderboardRecordByUserIdOptions copy_options;
memset(&copy_options, 0, sizeof(copy_options));
copy_options.ApiVersion = EOS_LEADERBOARDS_COPYLEADERBOARDRECORDBYUSERID_API_LATEST;
copy_options.UserId = reinterpret_cast<EOS_ProductUserId>(user_id);
EOS_Leaderboards_LeaderboardRecord* out_record;
auto copy_result = EOS_Leaderboards_CopyLeaderboardRecordByUserId(reinterpret_cast<EOS_HLeaderboards>(handle), &copy_options, &out_record);
if (copy_result != EOS_EResult::EOS_Success) {
EOS4J::throwEOSException(env, static_cast<int>(copy_result));
return nullptr;
}
jclass result_cls = env->FindClass("com/bearwaves/eos4j/EOSLeaderboards$LeaderboardRecord");
jmethodID result_ctor = env->GetMethodID(result_cls, "<init>", "(JLcom/bearwaves/eos4j/EOS$ProductUserId;IILjava/lang/String;)V");
jclass puid_cls = env->FindClass("com/bearwaves/eos4j/EOS$ProductUserId");
jmethodID puid_ctor = env->GetMethodID(puid_cls, "<init>", "(J)V");
auto record_user_id = env->NewObject(puid_cls, puid_ctor, out_record->UserId);
return env->NewObject(result_cls, result_ctor, (long long) out_record, record_user_id, out_record->Rank, out_record->Score, env->NewStringUTF(out_record->UserDisplayName));
*/

static native void releaseLeaderboardRecord(long handle); /*
EOS_Leaderboards_LeaderboardRecord_Release(reinterpret_cast<EOS_Leaderboards_LeaderboardRecord*>(handle));
*/
Expand Down

0 comments on commit 510ecc1

Please sign in to comment.