Skip to content

增加摇杆左半屏移动功能#546

Open
LanRhyme wants to merge 6 commits intoZalithLauncher:mainfrom
LanRhyme:main
Open

增加摇杆左半屏移动功能#546
LanRhyme wants to merge 6 commits intoZalithLauncher:mainfrom
LanRhyme:main

Conversation

@LanRhyme
Copy link
Contributor

No description provided.

Copy link
Collaborator

@Lo-quee Lo-quee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其次,你应当考虑到,虽然大部分情况,启动器是LTR布局,但是仍有部分语种是RTL布局,比如阿拉伯语,我没有对你的代码进行测试,不过你应该考虑到这样的情况。
可以尝试增加两半屏的选项,同时启用绝对坐标的形式进行实现,同时修改语言文本减少歧义。

@LanRhyme
Copy link
Contributor Author

修好了

Copy link
Collaborator

@Lo-quee Lo-quee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以及,现在已经使用CompositionLocalProvider限制了布局方向,理论上不用担心RTL布局导致的问题,但是现在有一个新的习惯问题需要解决,我们貌似没有考虑到左撇子(
目前只有左半屏摇杆功能,可以将现有实现通用化(更改函数、数据类的名称,加入新的状态决定作用到左右半屏),用户可以自己进行调整

Comment on lines 48 to 60
* 左半屏动态摇杆组件
* 使用 PointerEventPass.Final 实现不阻塞底层按钮的探测
*/
class LeftHalfScreenJoystickState {
var isVisible by mutableStateOf(false)
var center by mutableStateOf(Offset.Zero)
var joystickOffset by mutableStateOf(Offset.Zero) // 摇杆相对于中心的偏移
var isLocked by mutableStateOf(false)
var internalCanLock by mutableStateOf(false)
}

@Composable
fun rememberLeftHalfScreenJoystickState() = remember { LeftHalfScreenJoystickState() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请将状态请修改为data class形式:

data class LeftHalfScreenJoystickState(
    val isVisible: Boolean = false,
    val center: Offset = Offset.Zero,
    val joystickOffset: Offset = Offset.Zero,
    val isLocked: Boolean = false,
    val internalCanLock: Boolean = false
)

@Composable
fun rememberLeftHalfScreenJoystickState() = remember { LeftHalfScreenJoystickState() }

后续要进行更新状态,则可以这么做:

var state = rememberLeftHalfScreenJoystickState()
//...
state = state.copy(isVisible = true, internalCanLock = true)

方便配置的同时,也有利于状态同步

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我认为是没有必要的,反而会更复杂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants