feat: special danmaku by @My-Responsitories

Closes #91
Closes #219
Closes #394
Closes #602
Closes #613

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-05 16:32:23 +08:00
parent 08dc04f874
commit b02e6c04b9
8 changed files with 48 additions and 27 deletions

View File

@@ -38,7 +38,7 @@ class PlDanmakuController {
if (result['status']) {
if (result['data'].elems.isNotEmpty) {
for (DanmakuElem element in result['data'].elems) {
if (element.mode == 7) {
if (element.mode == 7 && !plPlayerController.showSpecialDanmaku) {
continue;
}
int pos = element.progress ~/ 100; //每0.1秒存储一次

View File

@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'package:PiliPlus/grpc/dm/v1/dm.pb.dart';
import 'package:PiliPlus/utils/extension.dart';
@@ -103,22 +104,32 @@ class _PlDanmakuState extends State<PlDanmaku> {
_plDanmakuController.getCurrentDanmaku(currentPosition);
if (currentDanmakuList != null) {
for (DanmakuElem e in currentDanmakuList) {
_controller!.addDanmaku(
DanmakuContentItem(
e.content,
color: playerController.blockTypes.contains(6)
? Colors.white
: DmUtils.decimalToColor(e.color),
type: DmUtils.getPosition(e.mode),
isColorful: playerController.showVipDanmaku &&
e.colorful == DmColorfulType.VipGradualColor
? true
: null,
count: widget.playerController.mergeDanmaku && e.hasAttr()
? e.attr
: null,
),
);
if (e.mode == 7) {
_controller!.addDanmaku(
SpecialDanmakuContentItem.fromList(
DmUtils.decimalToColor(e.color),
e.fontsize.toDouble(),
jsonDecode(e.content),
),
);
} else {
_controller!.addDanmaku(
DanmakuContentItem(
e.content,
color: playerController.blockTypes.contains(6)
? Colors.white
: DmUtils.decimalToColor(e.color),
type: DmUtils.getPosition(e.mode),
isColorful: playerController.showVipDanmaku &&
e.colorful == DmColorfulType.VipGradualColor
? true
: null,
count: widget.playerController.mergeDanmaku && e.hasAttr()
? e.attr
: null,
),
);
}
}
}
}

View File

@@ -1837,6 +1837,13 @@ List<SettingsModel> get extraSettings => [
setKey: SettingBoxKey.showVipDanmaku,
defaultVal: true,
),
SettingsModel(
settingsType: SettingsType.sw1tch,
title: '显示高级弹幕',
leading: Icon(MdiIcons.paletteAdvanced),
setKey: SettingBoxKey.showSpecialDanmaku,
defaultVal: true,
),
SettingsModel(
settingsType: SettingsType.sw1tch,
title: '合并弹幕',

View File

@@ -287,6 +287,7 @@ class PlPlayerController {
late int subtitlePaddingB = GStorage.subtitlePaddingB;
late double subtitleBgOpaticy = GStorage.subtitleBgOpaticy;
late bool showVipDanmaku = GStorage.showVipDanmaku;
late bool showSpecialDanmaku = GStorage.showSpecialDanmaku;
late double subtitleStrokeWidth = GStorage.subtitleStrokeWidth;
late int subtitleFontWeight = GStorage.subtitleFontWeight;

View File

@@ -12,14 +12,11 @@ class DmUtils {
}
static DanmakuItemType getPosition(int mode) {
DanmakuItemType type = DanmakuItemType.scroll;
if (mode >= 1 && mode <= 3) {
type = DanmakuItemType.scroll;
} else if (mode == 4) {
type = DanmakuItemType.bottom;
} else if (mode == 5) {
type = DanmakuItemType.top;
}
return type;
return switch (mode) {
4 => DanmakuItemType.bottom,
5 => DanmakuItemType.top,
7 => DanmakuItemType.special,
_ => DanmakuItemType.scroll,
};
}
}

View File

@@ -342,6 +342,9 @@ class GStorage {
static bool get showVipDanmaku =>
GStorage.setting.get(SettingBoxKey.showVipDanmaku, defaultValue: true);
static bool get showSpecialDanmaku => GStorage.setting
.get(SettingBoxKey.showSpecialDanmaku, defaultValue: true);
static bool get mergeDanmaku =>
GStorage.setting.get(SettingBoxKey.mergeDanmaku, defaultValue: false);
@@ -695,6 +698,7 @@ class SettingBoxKey {
refreshDragPercentage = 'refreshDragPercentage',
refreshDisplacement = 'refreshDisplacement',
showVipDanmaku = 'showVipDanmaku',
showSpecialDanmaku = 'showSpecialDanmaku',
mergeDanmaku = 'mergeDanmaku',
showHotRcmd = 'showHotRcmd',
audioNormalization = 'audioNormalization',