海报从 Empurple 的 Best50ImageRenderer/ImageBuilder 移植:按原始像素坐标 (1762x1850 画布、300x100 卡片、5 列、行距 120) 叠加在 base.png 上,底图里 已画好的面板/药丸标签/页脚不重复绘制;页面外壳走 Ichino 的 Material 3。 RatingCalculator 的达成率分档改成单张有序表,避免偏移与评级错位; RA 与评级由 test/rating_calculator_test.dart 的边界用例锁定。 GetUserRatingApi 只需要 userId(Cookie 可选),所以 Preview API 模式、未登录 游戏服务器时也能出图,只是没有 FC/AP/FS 标记。导出用 RepaintBoundary 抓 全尺寸 PNG:原生走 share_plus(不支持文件分享的平台回退为落盘并提示路径), web 走下载。 BEST35 与 BEST15 改为各自独立排版。原先沿用 Empurple 的跨列表全局序号, BEST35 没打满时 BEST15 会整体上移混进上半区。 path_provider 会经 path_provider_android 2.3.x 拖入 jni 插件,而 jni 把 windows/linux 也声明成 ffiPlugin,桌面构建因此去链接 jvm.lib 并失败, 故用 dependency_overrides 钉住 path_provider_android <2.3.0。
103 lines
2.7 KiB
Dart
103 lines
2.7 KiB
Dart
/// GetUserRatingApi 的 `userRating` 结构,移植自 Empurple 的 `UserRatingData`。
|
|
///
|
|
/// 服务端已按 RA 排好 BEST 35 / BEST 15,客户端不再重排。
|
|
enum MusicLevel {
|
|
basic,
|
|
advanced,
|
|
expert,
|
|
master,
|
|
reMaster;
|
|
|
|
static MusicLevel fromInt(int level) =>
|
|
level >= 0 && level < MusicLevel.values.length
|
|
? MusicLevel.values[level]
|
|
: MusicLevel.basic;
|
|
}
|
|
|
|
class UserRatingItemBean {
|
|
final int musicId;
|
|
final int level;
|
|
final int achievement;
|
|
final int comboStatus;
|
|
final int syncStatus;
|
|
final int romVersion;
|
|
|
|
const UserRatingItemBean({
|
|
required this.musicId,
|
|
required this.level,
|
|
required this.achievement,
|
|
required this.comboStatus,
|
|
required this.syncStatus,
|
|
required this.romVersion,
|
|
});
|
|
|
|
/// 达成率百分比数值,接口原值 1001234 => 100.1234。
|
|
double get achievementPercent => achievement / 10000.0;
|
|
|
|
/// 对应 Empurple 的 `formatRatingSimple`。
|
|
String get achievementText => '${achievementPercent.toStringAsFixed(4)}%';
|
|
|
|
/// DX 谱的 musicId 会加 10000 偏移。
|
|
bool get isDx => musicId > 10000;
|
|
|
|
MusicLevel get musicLevel => MusicLevel.fromInt(level);
|
|
|
|
factory UserRatingItemBean.fromJson(Map<String, dynamic> json) {
|
|
int toInt(dynamic v) {
|
|
if (v == null) return 0;
|
|
if (v is int) return v;
|
|
if (v is num) return v.toInt();
|
|
if (v is String) return int.tryParse(v) ?? 0;
|
|
return 0;
|
|
}
|
|
|
|
return UserRatingItemBean(
|
|
musicId: toInt(json['musicId']),
|
|
level: toInt(json['level']),
|
|
achievement: toInt(json['achievement']),
|
|
comboStatus: toInt(json['comboStatus']),
|
|
syncStatus: toInt(json['syncStatus']),
|
|
romVersion: toInt(json['romVersion']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class UserRatingBean {
|
|
final int userId;
|
|
final List<UserRatingItemBean> ratingList;
|
|
final List<UserRatingItemBean> newRatingList;
|
|
|
|
const UserRatingBean({
|
|
required this.userId,
|
|
required this.ratingList,
|
|
required this.newRatingList,
|
|
});
|
|
|
|
static List<UserRatingItemBean> _parseList(dynamic raw) {
|
|
if (raw is! List) return const [];
|
|
return raw
|
|
.whereType<Map<String, dynamic>>()
|
|
.map(UserRatingItemBean.fromJson)
|
|
.toList();
|
|
}
|
|
|
|
factory UserRatingBean.fromJson(Map<String, dynamic> json) {
|
|
int toInt(dynamic v) {
|
|
if (v == null) return 0;
|
|
if (v is int) return v;
|
|
if (v is num) return v.toInt();
|
|
if (v is String) return int.tryParse(v) ?? 0;
|
|
return 0;
|
|
}
|
|
|
|
final userRating =
|
|
(json['userRating'] as Map<String, dynamic>?) ?? const {};
|
|
|
|
return UserRatingBean(
|
|
userId: toInt(json['userId']),
|
|
ratingList: _parseList(userRating['ratingList']),
|
|
newRatingList: _parseList(userRating['newRatingList']),
|
|
);
|
|
}
|
|
}
|