mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom danmaku line height
Closes #56 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -140,7 +140,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
opacity: playerController.isOpenDanmu.value ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 100),
|
||||
child: DanmakuScreen(
|
||||
createdController: (DanmakuController e) async {
|
||||
createdController: (DanmakuController e) {
|
||||
playerController.danmakuController = _controller = e;
|
||||
},
|
||||
option: DanmakuOption(
|
||||
@@ -154,6 +154,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
duration: playerController.danmakuDurationVal ~/
|
||||
playerController.playbackSpeed,
|
||||
strokeWidth: playerController.strokeWidth,
|
||||
lineHeight: playerController.danmakuLineHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -143,7 +143,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
opacity: plPlayerController.isOpenDanmu.value ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 100),
|
||||
child: DanmakuScreen(
|
||||
createdController: (DanmakuController e) async {
|
||||
createdController: (DanmakuController e) {
|
||||
plPlayerController.danmakuController =
|
||||
_liveRoomController.controller = e;
|
||||
},
|
||||
@@ -159,6 +159,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
duration: plPlayerController.danmakuDurationVal ~/
|
||||
plPlayerController.playbackSpeed,
|
||||
strokeWidth: plPlayerController.strokeWidth,
|
||||
lineHeight: plPlayerController.danmakuLineHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -33,6 +33,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
late dynamic enableSystemProxy;
|
||||
late String defaultSystemProxyHost;
|
||||
late String defaultSystemProxyPort;
|
||||
late double danmakuLineHeight = GStorage.danmakuLineHeight;
|
||||
bool userLogin = false;
|
||||
|
||||
Box get setting => GStorage.setting;
|
||||
@@ -336,6 +337,64 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('弹幕行高', style: titleStyle),
|
||||
subtitle: Text('默认1.6', style: subTitleStyle),
|
||||
leading: const Icon(Icons.subtitles_outlined),
|
||||
trailing: Text(
|
||||
danmakuLineHeight.toString(),
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
onTap: () {
|
||||
String danmakuLineHeight = this.danmakuLineHeight.toString();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('弹幕行高', style: TextStyle(fontSize: 18)),
|
||||
content: TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: danmakuLineHeight,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
onChanged: (value) {
|
||||
danmakuLineHeight = value;
|
||||
},
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[\d\.]+')),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
this.danmakuLineHeight = max(
|
||||
1.0,
|
||||
double.tryParse(danmakuLineHeight) ?? 1.6,
|
||||
);
|
||||
await setting.put(
|
||||
SettingBoxKey.danmakuLineHeight,
|
||||
this.danmakuLineHeight,
|
||||
);
|
||||
setState(() {});
|
||||
},
|
||||
child: Text('确定'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Obx(
|
||||
() => ListTile(
|
||||
enableFeedback: true,
|
||||
|
||||
@@ -1056,6 +1056,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
double fontSizeFSVal = widget.controller!.fontSizeFSVal;
|
||||
double subtitleFontScale = widget.controller!.subtitleFontScale.value;
|
||||
double subtitleFontScaleFS = widget.controller!.subtitleFontScaleFS.value;
|
||||
double danmakuLineHeight = widget.controller!.danmakuLineHeight;
|
||||
// 弹幕速度
|
||||
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
|
||||
// 弹幕描边
|
||||
@@ -1467,6 +1468,46 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Text('弹幕行高 $danmakuLineHeight'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: SliderThemeData(
|
||||
trackShape: MSliderTrackShape(),
|
||||
thumbColor: Theme.of(context).colorScheme.primary,
|
||||
activeTrackColor: Theme.of(context).colorScheme.primary,
|
||||
trackHeight: 10,
|
||||
thumbShape: const RoundSliderThumbShape(
|
||||
enabledThumbRadius: 6.0),
|
||||
),
|
||||
child: Slider(
|
||||
min: 1.0,
|
||||
max: 3.0,
|
||||
value: danmakuLineHeight,
|
||||
label: '$danmakuLineHeight',
|
||||
onChanged: (double val) {
|
||||
danmakuLineHeight =
|
||||
double.parse(val.toStringAsFixed(1));
|
||||
widget.controller!.danmakuLineHeight =
|
||||
danmakuLineHeight;
|
||||
widget.controller?.putDanmakuSettings();
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
lineHeight: danmakuLineHeight,
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'字幕字体大小 ${(subtitleFontScale * 100).toStringAsFixed(1)}%'),
|
||||
Padding(
|
||||
|
||||
@@ -255,6 +255,7 @@ class PlPlayerController {
|
||||
late bool enableLongShowControl;
|
||||
RxDouble subtitleFontScale = (1.0).obs;
|
||||
RxDouble subtitleFontScaleFS = (1.5).obs;
|
||||
late double danmakuLineHeight = GStorage.danmakuLineHeight;
|
||||
|
||||
// 播放顺序相关
|
||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||
@@ -1281,6 +1282,7 @@ class PlPlayerController {
|
||||
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
||||
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
||||
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
||||
setting.put(SettingBoxKey.danmakuLineHeight, danmakuLineHeight);
|
||||
}
|
||||
|
||||
Future<void> dispose({String type = 'single'}) async {
|
||||
|
||||
@@ -142,6 +142,9 @@ class GStorage {
|
||||
static int get defaultPicQa =>
|
||||
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||
|
||||
static double get danmakuLineHeight =>
|
||||
setting.get(SettingBoxKey.danmakuLineHeight, defaultValue: 1.6);
|
||||
|
||||
static List<double> get dynamicDetailRatio =>
|
||||
setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]);
|
||||
|
||||
@@ -363,6 +366,7 @@ class SettingBoxKey {
|
||||
danmakuFontScaleFS = 'danmakuFontScaleFS',
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
danmakuMassiveMode = 'danmakuMassiveMode',
|
||||
danmakuLineHeight = 'danmakuLineHeight',
|
||||
strokeWidth = 'strokeWidth',
|
||||
fontWeight = 'fontWeight',
|
||||
memberTab = 'memberTab',
|
||||
|
||||
@@ -252,7 +252,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: cfa1b7cc7fbd7276d58307ea515533af3807ac7d
|
||||
resolved-ref: "97d835d54086adddc2666d916f8f63d9e6f64a4d"
|
||||
url: "https://github.com/bggRGjQaUbCoE/canvas_danmaku.git"
|
||||
source: git
|
||||
version: "0.2.5"
|
||||
|
||||
Reference in New Issue
Block a user