Skip to content

Commit 92767a3

Browse files
committed
refactor(dialog): 移除对话框点击关闭配置选项
- 移除了 DialogActionPayload 中的 closesDialog 属性 - 移除了 DialogActionSpec 中的 closesDialog 属性 - 移除了 DialogWidgetSpec 中的 closeOnClick 属性 - 更新了 DialogCompiler 中的相关参数传递逻辑 - 修改了 DialogMenuRenderer 中的关闭判断逻辑,改为检查 dialogState - 更新了默认关闭动作的创建方式,不再设置自动关闭 - 将等待响应状态的对话框动作类型从 WAIT_FOR_RESPONSE 改为 NONE - 移除了 MenuSerializer 中对 Close-On-Click 和 close-on-click 配置的解析 - 更新了示例菜单配置文件,将原来的关闭行为改为执行 'close' 动作
1 parent 1a105f2 commit 92767a3

11 files changed

Lines changed: 11 additions & 20 deletions

File tree

api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/dialog/DialogActionPayload.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ data class DialogActionPayload(
44
val id: String,
55
val label: String,
66
val width: Int? = null,
7-
val closesDialog: Boolean = true,
8-
val nextPage: Int? = null,
97
val exitAction: Boolean = false
108
)

api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/dialog/DialogNMSImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class DialogNMSImpl : DialogNMS() {
107107
private fun buildDialog(payload: DialogPayload): Any {
108108
val common = buildCommonDialogData(payload)
109109
val actions = if (payload.actions.isEmpty() && payload.exitAction == null) {
110-
listOf(DialogActionPayload("__default_close__", "Close", 120, true, null, false))
110+
listOf(DialogActionPayload("__default_close__", "Close", 120, false))
111111
} else {
112112
payload.actions
113113
}
@@ -177,7 +177,7 @@ class DialogNMSImpl : DialogNMS() {
177177
optionalComponent(payload.externalTitle),
178178
effectiveAllowEscClose,
179179
false,
180-
dialogAction("WAIT_FOR_RESPONSE"),
180+
dialogAction("NONE"),
181181
body,
182182
inputs
183183
)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=me.arasple.mc.trmenu
2-
version=3.10.1
2+
version=3.10.2

plugin/src/main/kotlin/trplugins/menu/module/conf/MenuSerializer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ object MenuSerializer : ISerializer {
599599
id = section.getString("Id") ?: "action_$index",
600600
label = section.getString("Label") ?: "Action-$index",
601601
width = section.getInt("Width").takeIf { it > 0 },
602-
closesDialog = section.getBoolean("Close-On-Click", true),
603602
nextPage = section.getString("Next-Page")?.toIntOrNull() ?: section.getInt("Next-Page").takeIf { section.contains("Next-Page") },
604603
exitAction = section.getBoolean("Exit", false),
605604
actions = Reactions.ofReaction(TrMenu.actionHandle, section["Execute"] ?: section["Actions"]),
@@ -641,7 +640,6 @@ object MenuSerializer : ISerializer {
641640
max = widget.getString("max")?.toDoubleOrNull(),
642641
step = widget.getString("step")?.toDoubleOrNull() ?: 1.0,
643642
maxLength = widget.getInt("max-length").takeIf { it > 0 },
644-
closeOnClick = widget.getBoolean("close-on-click", true),
645643
nextPage = widget.getString("next-page")?.toIntOrNull(),
646644
exitAction = widget.getBoolean("exit", false) || widget.getBoolean("exit-action", false),
647645
actions = Property.asList(widget["execute"] ?: widget["actions"]),

plugin/src/main/kotlin/trplugins/menu/module/display/dialog/compiler/DialogCompiler.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ object DialogCompiler {
171171
node.id,
172172
node.widget.label ?: node.id,
173173
width,
174-
node.widget.closeOnClick,
175174
node.widget.nextPage,
176175
node.widget.exitAction,
177176
Reactions.ofReaction(TrMenu.actionHandle, node.widget.actions)
@@ -220,8 +219,6 @@ object DialogCompiler {
220219
id = spec.id,
221220
label = session.parse(spec.label),
222221
width = spec.width,
223-
closesDialog = spec.closesDialog,
224-
nextPage = spec.nextPage,
225222
exitAction = spec.exitAction
226223
)
227224
}

plugin/src/main/kotlin/trplugins/menu/module/display/dialog/model/DialogActionSpec.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ data class DialogActionSpec(
66
val id: String,
77
val label: String,
88
val width: Int? = null,
9-
val closesDialog: Boolean = true,
109
val nextPage: Int? = null,
1110
val exitAction: Boolean = false,
1211
val actions: Reactions,

plugin/src/main/kotlin/trplugins/menu/module/display/dialog/model/DialogWidgetSpec.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ data class DialogWidgetSpec(
2121
val max: Double? = null,
2222
val step: Double = 1.0,
2323
val maxLength: Int? = null,
24-
val closeOnClick: Boolean = true,
2524
val nextPage: Int? = null,
2625
val exitAction: Boolean = false,
2726
val actions: List<Any> = emptyList(),

plugin/src/main/kotlin/trplugins/menu/module/display/dialog/runtime/DialogMenuRenderer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ object DialogMenuRenderer {
8585
page(session, action.nextPage)
8686
return
8787
}
88-
if (action.closesDialog) {
89-
close(session)
88+
// If the action execution already closed the dialog (via 'close' action), don't refresh
89+
if (session.dialogState == null) {
9090
return
9191
}
92+
// Otherwise refresh to replace the "waiting for response" screen
9293
refresh(session)
9394
}
9495

plugin/src/main/resources/menus/Dialog-Confirmation-Example.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Dialog:
4545
- Id: 'confirm_delete'
4646
Label: '&c确认删除'
4747
Width: 160
48-
Close-On-Click: true
4948
Execute:
5049
- 'set-meta: confirm_reason %trmenu_dialog_input_delete_reason%'
5150
- 'set-meta: confirm_targets %trmenu_dialog_option_cleanup_targets%'
5251
- 'tell: &c已确认删除, 范围: %trmenu_dialog_option_cleanup_targets%'
52+
- 'close'
5353
- Id: 'cancel_delete'
5454
Label: '&a取消操作'
5555
Width: 160
56-
Close-On-Click: true
5756
Execute:
5857
- 'tell: &a已取消删除请求'
58+
- 'close'

plugin/src/main/resources/menus/Dialog-Example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Dialog:
6060
- Id: 'submit_notice'
6161
Label: '&a提交选择'
6262
Width: 180
63-
Close-On-Click: true
6463
Execute:
6564
- 'set-meta: notice_note %trmenu_dialog_input_signup_note%'
6665
- 'set-meta: notice_packs %trmenu_dialog_option_reward_packs%'
6766
- 'tell: &aNOTICE 示例已提交, 奖励包: %trmenu_dialog_option_reward_packs%'
67+
- 'close'

0 commit comments

Comments
 (0)