@@ -34,9 +34,13 @@ data class ControlProfile(
3434) {
3535 companion object {
3636 fun forState (state : ControlState , buttons : Boolean , joystick : Boolean , direct : Boolean = false,
37- directionMode : DirectionControlMode = DirectionControlMode .default(joystick)): ControlProfile {
37+ directionMode : DirectionControlMode = DirectionControlMode .default(joystick),
38+ preview : Boolean = false): ControlProfile {
3839 val enabled = buttons || joystick
3940 val mode = state.mode
41+ // The layout editor must show every control its layout can display, otherwise
42+ // scene-conditional buttons stay stuck at an uneditable default position.
43+ val conditional = preview && mode in setOf (ControlMode .GAMEPLAY , ControlMode .FALLBACK )
4044 val lobbyMap = mode in setOf (ControlMode .LOBBY_MAP , ControlMode .LOBBY_MAP_VIEW )
4145 val playing = mode in setOf (ControlMode .GAMEPLAY , ControlMode .PICO8 , ControlMode .FALLBACK )
4246 val navigation = mode in setOf (ControlMode .PAUSE , ControlMode .PAUSE_MENU , ControlMode .MENU , ControlMode .CHAPTER ,
@@ -47,13 +51,14 @@ data class ControlProfile(
4751 val actions = when (mode) {
4852 ControlMode .GAMEPLAY , ControlMode .FALLBACK -> if (buttons) buildList {
4953 add(ControlAction (" Jump" , " 跳" )); add(ControlAction (" Dash" , " 冲" )); add(ControlAction (" Grab" , " 抓" ))
50- if (state.canTalk) add(ControlAction (" Talk" , " 交互" ))
54+ if (state.canTalk || conditional ) add(ControlAction (" Talk" , " 交互" ))
5155 if (mode == ControlMode .GAMEPLAY ) {
52- if (! state.bindings[" MiaoChat" ].isNullOrEmpty()) add(ControlAction (" MiaoChat" , " 聊天" , ControlIcon .CHAT ))
53- if (! state.bindings[" MiaoPlayers" ].isNullOrEmpty()) add(ControlAction (" MiaoPlayers" , " 玩家" ))
54- if (! state.bindings[" CollabMap" ].isNullOrEmpty()) add(ControlAction (" CollabMap" , " 大厅地图" , ControlIcon .BOOK ))
56+ if (conditional || ! state.bindings[" MiaoChat" ].isNullOrEmpty()) add(ControlAction (" MiaoChat" , " 聊天" , ControlIcon .CHAT ))
57+ if (conditional || ! state.bindings[" MiaoPlayers" ].isNullOrEmpty()) add(ControlAction (" MiaoPlayers" , " 玩家" ))
58+ if (conditional || ! state.bindings[" CollabMap" ].isNullOrEmpty()) add(ControlAction (" CollabMap" , " 大厅地图" , ControlIcon .BOOK ))
5559 }
56- if (mode == ControlMode .FALLBACK ) { add(confirm); add(cancel) }
60+ // Unknown Mod scenes add confirm/cancel; keep them editable as well.
61+ if (mode == ControlMode .FALLBACK || conditional) { add(confirm); add(cancel) }
5762 } else emptyList()
5863 ControlMode .PICO8 -> if (buttons) listOf (ControlAction (" Jump" , " 跳" ), ControlAction (" Dash" , " 冲" )) else emptyList()
5964 ControlMode .TITLE -> listOf (confirm.copy(label = " 开始" ))
@@ -101,5 +106,20 @@ data class ControlProfile(
101106 diagonalDirections = enabled && ! direct && playing && directionMode == DirectionControlMode .EIGHT_BUTTONS
102107 )
103108 }
109+
110+ /* *
111+ * Layout editor preview. It shows every control the layout can display in any scene,
112+ * including scene-conditional ones (Talk away from an NPC, MiaoNet 聊天 / 玩家,
113+ * CollabUtils 大厅地图 and the confirm/cancel pair of unknown Mod scenes), so positions,
114+ * sizes, slide behavior and feedback stay editable before a scene shows them.
115+ */
116+ fun forEditor (game : Boolean , joystick : Boolean ,
117+ directionMode : DirectionControlMode = DirectionControlMode .default(joystick)): ControlProfile =
118+ if (game) forState(ControlState (ControlMode .GAMEPLAY ), true , joystick,
119+ directionMode = directionMode, preview = true )
120+ else forState(ControlState (ControlMode .PAUSE ), true , false ).let {
121+ it.copy(actions = it.actions + ControlAction (" Pause" , " 完成" , ControlIcon .CONFIRM ),
122+ auxiliary = ControlAction (" MenuJournal" , " 日志" , ControlIcon .BOOK ))
123+ }
104124 }
105125}
0 commit comments