Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

弹幕"显示区域"改为无级调节 #1576

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
* Copyright (C) 2024-2025 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
Expand Down Expand Up @@ -306,48 +306,27 @@ fun EpisodeVideoSettings(
)


var displayArea by remember(danmakuConfig) {
mutableFloatStateOf(
when (danmakuConfig.displayArea) {
0.125f -> 1f
0.25f -> 2f
0.50f -> 3f
0.75f -> 4f
1f -> 5f
else -> 2f
},
)
}
SliderItem(
value = displayArea,
value = danmakuConfig.displayArea,
onValueChange = {
displayArea = it
},
// 这个会导致 repopulate, 所以改完了才更新
onValueChangeFinished = {
setDanmakuConfig(
danmakuConfig.copy(
displayArea = when (displayArea) {
1f -> 0.125f
2f -> 0.25f
3f -> 0.50f
4f -> 0.75f
5f -> 1f
else -> 0.25f
},
displayArea = it.coerceIn(0f, 1f),
),
)
},
valueRange = 1f..5f,
steps = 3,
valueRange = 0f..1f,
title = { Text("显示区域") },
valueLabel = {
when (displayArea) {
1f -> Text("1/8 屏")
2f -> Text("1/4 屏")
3f -> Text("半屏")
4f -> Text("3/4 屏")
5f -> Text("全屏")
val v = danmakuConfig.displayArea
when {
v == 0f -> Text("关闭")
v <= 1 / 8f -> Text("1/8 屏")
v <= 1 / 6f -> Text("1/6 屏")
v <= 1 / 4f -> Text("1/4 屏")
v <= 1 / 2f -> Text("半屏")
v <= 3 / 4f -> Text("3/4 屏")
v == 1f -> Text("全屏")
}
},
useThinSlider = useThinSlider,
Expand Down
31 changes: 17 additions & 14 deletions danmaku/ui/src/androidMain/kotlin/DanmakuHost.android.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,11 @@ private fun DanmakuConfig(
mutableFloatStateOf(
when (danmakuConfig.displayArea) {
0.125f -> 1f
0.25f -> 2f
0.50f -> 3f
0.75f -> 4f
1f -> 5f
1f / 6 -> 2f
0.25f -> 3f
0.50f -> 4f
0.75f -> 5f
1f -> 6f
else -> 2f
},
)
Expand All @@ -490,25 +491,27 @@ private fun DanmakuConfig(
danmakuConfig.copy(
displayArea = when (displayArea) {
1f -> 0.125f
2f -> 0.25f
3f -> 0.50f
4f -> 0.75f
5f -> 1f
2f -> 1f / 6
3f -> 0.25f
4f -> 0.50f
5f -> 0.75f
6f -> 1f
else -> 0.25f
},
),
)
},
valueRange = 1f..5f,
steps = 3,
valueRange = 1f..6f,
steps = 4,
title = { Text("显示区域") },
valueLabel = {
when (displayArea) {
1f -> Text("1/8 屏")
2f -> Text("1/4 屏")
3f -> Text("半屏")
4f -> Text("3/4 屏")
5f -> Text("全屏")
2f -> Text("1/6 屏")
3f -> Text("1/4 屏")
4f -> Text("半屏")
5f -> Text("3/4 屏")
6f -> Text("全屏")
}
},
)
Expand Down
Loading