Skip to content
This repository was archived by the owner on Mar 22, 2026. It is now read-only.

Commit ba5d31d

Browse files
committed
[TouchController] 添加状态切换的界面
1 parent c1a8b46 commit ba5d31d

11 files changed

Lines changed: 128 additions & 6 deletions

File tree

touchcontroller/common/config/GlobalConfig.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import top.fifthlight.touchcontroller.common.config.data.ChatConfig
55
import top.fifthlight.touchcontroller.common.config.data.ControlConfig
66
import top.fifthlight.touchcontroller.common.config.data.DebugConfig
77
import top.fifthlight.touchcontroller.common.config.data.RegularConfig
8+
import top.fifthlight.touchcontroller.common.config.data.StatusConfig
89
import top.fifthlight.touchcontroller.common.config.data.TouchRingConfig
910
import top.fifthlight.touchcontroller.common.config.platform.PlatformConfig
1011
import top.fifthlight.touchcontroller.common.gal.itemlist.DefaultItemListProvider
1112

1213
@Serializable
1314
data class GlobalConfig(
15+
val status: StatusConfig = StatusConfig(),
1416
val regular: RegularConfig = RegularConfig(),
1517
val control: ControlConfig = ControlConfig(),
1618
val platform: PlatformConfig = PlatformConfig(),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package top.fifthlight.touchcontroller.common.config.data
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
data class StatusConfig(
7+
val status: Status = Status.ENABLED,
8+
) {
9+
enum class Status {
10+
DISABLED,
11+
ONLY_VIEW,
12+
ENABLED,
13+
}
14+
}

touchcontroller/common/ui/config/tab/platform/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ kt_merge_library(
55
srcs = glob(["*.kt"]),
66
merge_deps = [
77
"//touchcontroller/common/config",
8+
"//touchcontroller/common/config/data",
89
"//touchcontroller/common/config/platform",
910
"//touchcontroller/common/platform",
1011
"//touchcontroller/common/platform/blazesdl",

touchcontroller/common/ui/config/tab/platform/BlazeSDLConfigTab.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import top.fifthlight.combine.modifier.placement.padding
1111
import top.fifthlight.combine.modifier.scroll.verticalScroll
1212
import top.fifthlight.combine.widget.layout.Column
1313
import top.fifthlight.touchcontroller.assets.Texts
14+
import top.fifthlight.touchcontroller.common.config.data.StatusConfig
1415
import top.fifthlight.touchcontroller.common.config.platform.BlazeSDLPlatformConfig
1516
import top.fifthlight.touchcontroller.common.ui.config.model.LocalConfigScreenModel
1617
import top.fifthlight.touchcontroller.common.ui.config.tab.Tab
@@ -24,6 +25,7 @@ object BlazeSDLConfigTab : Tab() {
2425
titleId = Texts.SCREEN_CONFIG_PLATFORM_TITLE,
2526
group = null,
2627
index = 2,
28+
onReset = { copy(platform = platform.copy(blazesdl = BlazeSDLPlatformConfig())) },
2729
)
2830

2931
@Composable
@@ -48,14 +50,14 @@ object BlazeSDLConfigTab : Tab() {
4850
}
4951
}
5052
SliderPreferenceItem(
51-
title = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_STRENGTH),
53+
title = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_STRENGTH_TITLE),
5254
description = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_STRENGTH_DESCRIPTION),
5355
value = globalConfig.platform.blazesdl.vibrationStrength,
5456
range = 0f..1f,
5557
onValueChanged = { update { copy(vibrationStrength = it) } }
5658
)
5759
IntSliderPreferenceItem(
58-
title = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_LENGTH),
60+
title = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_LENGTH_TITLE),
5961
description = Text.translatable(Texts.SCREEN_CONFIG_PLATFORM_BLAZESDL_VIBRATION_LENGTH_DESCRIPTION),
6062
value = globalConfig.platform.blazesdl.vibrationLength,
6163
range = 0..1000,

touchcontroller/common/ui/config/tab/status/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ kt_merge_library(
44
name = "status",
55
srcs = glob(["*.kt"]),
66
merge_deps = [
7+
"//touchcontroller/common/config",
8+
"//touchcontroller/common/config/data",
9+
"//touchcontroller/common/ui/config/model",
10+
"//touchcontroller/common/ui/config/state",
711
"//touchcontroller/common/ui/config/tab",
812
"//touchcontroller/common/ui/config/tab/status/model",
913
"//touchcontroller/common/ui/config/tab/status/state",
1014
"//touchcontroller/common/ui/theme",
15+
"//touchcontroller/common/ui/widget",
1116
"//touchcontroller/resources/lang:text_binding",
1217
],
1318
visibility = ["//touchcontroller:__subpackages__"],

touchcontroller/common/ui/config/tab/status/StatusTab.kt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.runtime.getValue
66
import androidx.compose.runtime.remember
77
import top.fifthlight.combine.data.Text
88
import top.fifthlight.combine.data.TextColor
9+
import top.fifthlight.combine.layout.Alignment
910
import top.fifthlight.combine.layout.Arrangement
1011
import top.fifthlight.combine.modifier.Modifier
1112
import top.fifthlight.combine.modifier.drawing.border
@@ -16,20 +17,50 @@ import top.fifthlight.combine.modifier.scroll.verticalScroll
1617
import top.fifthlight.combine.widget.layout.Column
1718
import top.fifthlight.combine.widget.ui.Text
1819
import top.fifthlight.touchcontroller.assets.Texts
20+
import top.fifthlight.touchcontroller.common.config.data.ControlConfig
21+
import top.fifthlight.touchcontroller.common.config.data.StatusConfig
22+
import top.fifthlight.touchcontroller.common.ui.config.model.LocalConfigScreenModel
1923
import top.fifthlight.touchcontroller.common.ui.config.tab.Tab
2024
import top.fifthlight.touchcontroller.common.ui.config.tab.TabOptions
2125
import top.fifthlight.touchcontroller.common.ui.config.tab.status.model.StatusTabModel
2226
import top.fifthlight.touchcontroller.common.ui.theme.LocalTouchControllerTheme
27+
import top.fifthlight.touchcontroller.common.ui.widget.ListButton
2328

2429
object StatusTab : Tab() {
2530
override val options = TabOptions(
2631
titleId = Texts.SCREEN_CONFIG_STATUS_TITLE,
2732
group = null,
2833
index = 1,
34+
onReset = { copy(status = StatusConfig()) },
2935
)
3036

37+
@Composable
38+
private fun StatusItem(
39+
modifier: Modifier = Modifier,
40+
title: Text,
41+
description: Text,
42+
selected: Boolean,
43+
onClick: () -> Unit,
44+
) {
45+
ListButton(
46+
modifier = Modifier.then(modifier),
47+
checked = selected,
48+
onClick = onClick,
49+
) {
50+
Column(
51+
modifier = Modifier.alignment(Alignment.CenterLeft),
52+
verticalArrangement = Arrangement.spacedBy(4),
53+
) {
54+
Text(title)
55+
Text(description)
56+
}
57+
}
58+
}
59+
3160
@Composable
3261
override fun Content() {
62+
val screenModel = LocalConfigScreenModel.current
63+
val screenState by screenModel.uiState.collectAsState()
3364
val tabModel = remember { StatusTabModel() }
3465
val uiState by tabModel.uiState.collectAsState()
3566
Column(
@@ -67,6 +98,38 @@ object StatusTab : Tab() {
6798
Text(Text.format(Texts.SCREEN_CONFIG_STATUS_DEBUG_INFO_SYSTEM, systemInfo.system))
6899
Text(Text.format(Texts.SCREEN_CONFIG_STATUS_DEBUG_INFO_ARCHITECTURE, systemInfo.arch))
69100
}
101+
102+
Text(Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_TITLE))
103+
104+
Column(Modifier.fillMaxWidth()) {
105+
StatusItem(
106+
modifier = Modifier.fillMaxWidth(),
107+
title = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_ENABLE_TITLE),
108+
description = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_ENABLE_DESCRIPTION),
109+
selected = screenState.config.status.status == StatusConfig.Status.ENABLED,
110+
onClick = {
111+
screenModel.updateConfig { copy(status = status.copy(status = StatusConfig.Status.ENABLED)) }
112+
}
113+
)
114+
StatusItem(
115+
modifier = Modifier.fillMaxWidth(),
116+
title = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_ONLY_VIEW_TITLE),
117+
description = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_ONLY_VIEW_DESCRIPTION),
118+
selected = screenState.config.status.status == StatusConfig.Status.ONLY_VIEW,
119+
onClick = {
120+
screenModel.updateConfig { copy(status = status.copy(status = StatusConfig.Status.ONLY_VIEW)) }
121+
}
122+
)
123+
StatusItem(
124+
modifier = Modifier.fillMaxWidth(),
125+
title = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_DISABLE_TITLE),
126+
description = Text.translatable(Texts.SCREEN_CONFIG_STATUS_STATUS_DISABLE_DESCRIPTION),
127+
selected = screenState.config.status.status == StatusConfig.Status.DISABLED,
128+
onClick = {
129+
screenModel.updateConfig { copy(status = status.copy(status = StatusConfig.Status.DISABLED)) }
130+
}
131+
)
132+
}
70133
}
71134
}
72135
}

touchcontroller/resources/lang/en_us.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@
5555
"touchcontroller.screen.config.status.debug_info.title": "Debug info",
5656
"touchcontroller.screen.config.status.debug_info.system": "System: %s",
5757
"touchcontroller.screen.config.status.debug_info.architecture": "CPU architecture: %s",
58+
"touchcontroller.screen.config.status.status.title": "Status",
59+
"touchcontroller.screen.config.status.status.enable.title": "Enable",
60+
"touchcontroller.screen.config.status.status.enable.description": "Enable all of TouchController's functionalities.",
61+
"touchcontroller.screen.config.status.status.only_view.title": "Only view movement",
62+
"touchcontroller.screen.config.status.status.only_view.description": "Disable TouchController's layers and widgets. You can only turning view with touch.",
63+
"touchcontroller.screen.config.status.status.disable.title": "Disabled",
64+
"touchcontroller.screen.config.status.status.disable.description": "Disable all of TouchController's functionalities.",
5865

5966
"touchcontroller.screen.config.platform.title": "Platform",
60-
"touchcontroller.screen.config.platform.blazesdl.vibration_strength": "Vibration strength",
67+
"touchcontroller.screen.config.platform.blazesdl.vibration_strength.title": "Vibration strength",
6168
"touchcontroller.screen.config.platform.blazesdl.vibration_strength.description": "Set vibration strength when breaking blocks ",
62-
"touchcontroller.screen.config.platform.blazesdl.vibration_length": "Vibration length",
69+
"touchcontroller.screen.config.platform.blazesdl.vibration_length.title": "Vibration length",
6370
"touchcontroller.screen.config.platform.blazesdl.vibration_length.description": "Set vibration length when breaking blocks ",
6471

6572
"touchcontroller.screen.config.about.title": "About",

touchcontroller/resources/lang/ru_ru.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161

6262

6363

64+
65+
66+
67+
68+
69+
70+
6471

6572
"touchcontroller.screen.config.about.title": "Про мод",
6673
"touchcontroller.screen.config.about.authors.title": "Авторы: ",

touchcontroller/resources/lang/uk_ua.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161

6262

6363

64+
65+
66+
67+
68+
69+
70+
6471

6572
"touchcontroller.screen.config.about.title": "Інформація",
6673
"touchcontroller.screen.config.about.authors.title": "Автори: ",

touchcontroller/resources/lang/zh_cn.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@
5555
"touchcontroller.screen.config.status.debug_info.title": "调试信息",
5656
"touchcontroller.screen.config.status.debug_info.system": "系统:%s",
5757
"touchcontroller.screen.config.status.debug_info.architecture": "CPU 架构:%s",
58+
"touchcontroller.screen.config.status.status.title": "状态",
59+
"touchcontroller.screen.config.status.status.enable.title": "启用",
60+
"touchcontroller.screen.config.status.status.enable.description": "启用 TouchController 的全部功能。",
61+
"touchcontroller.screen.config.status.status.only_view.title": "仅视角移动",
62+
"touchcontroller.screen.config.status.status.only_view.description": "禁用 TouchController 的图层、控件功能。你只能使用触控移动视角。",
63+
"touchcontroller.screen.config.status.status.disable.title": "禁用",
64+
"touchcontroller.screen.config.status.status.disable.description": "禁用 TouchController 的全部功能。",
5865

5966
"touchcontroller.screen.config.platform.title": "平台",
60-
"touchcontroller.screen.config.platform.blazesdl.vibration_strength": "振动强度",
67+
"touchcontroller.screen.config.platform.blazesdl.vibration_strength.title": "振动强度",
6168
"touchcontroller.screen.config.platform.blazesdl.vibration_strength.description": "设置破坏方块时的振动强度",
62-
"touchcontroller.screen.config.platform.blazesdl.vibration_length": "振动长度",
69+
"touchcontroller.screen.config.platform.blazesdl.vibration_length.title": "振动长度",
6370
"touchcontroller.screen.config.platform.blazesdl.vibration_length.description": "设置破坏方块时的振动长度",
6471

6572
"touchcontroller.screen.config.about.title": "关于",

0 commit comments

Comments
 (0)