From 507839730954a4215956f898ec826956721a97e1 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 9 Jan 2025 14:14:50 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=9B=9E=E6=BB=9A=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=B2=A1=E5=BF=85=E8=A6=81=E7=9A=84=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/MaaFramework/MaaMsg.h | 14 ++++---- sample/python/__main__.py | 18 +++++----- source/MaaFramework/Task/TaskBase.cpp | 10 +++--- .../Python/maa/notification_handler.py | 34 +++++++++---------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/MaaFramework/MaaMsg.h b/include/MaaFramework/MaaMsg.h index d3a55314b..cfff82e5c 100644 --- a/include/MaaFramework/MaaMsg.h +++ b/include/MaaFramework/MaaMsg.h @@ -50,7 +50,7 @@ /** * @{ - * @brief Message for the tasks. + * @brief Message for the task. * * payload: { * task_id: number, @@ -66,11 +66,11 @@ /** * @{ - * @brief Message for the next List. + * @brief Message for the next list of node. * * payload: { * task_id: number, - * node: string, + * name: string, * list: string[], * } */ @@ -81,12 +81,12 @@ /** * @{ - * @brief Message for the recognition list. + * @brief Message for the recognition list of node. * * payload: { * task_id: number, * reco_id: number, - * node: string, + * name: string, * } */ #define MaaMsg_Node_Recognition_Starting ("Node.Recognition.Starting") @@ -96,12 +96,12 @@ /** * @{ - * @brief Message for the node action. + * @brief Message for the action of node. * * payload: { * task_id: number, * node_id: number, - * node: string, + * name: string, * } */ #define MaaMsg_Node_Action_Starting ("Node.Action.Starting") diff --git a/sample/python/__main__.py b/sample/python/__main__.py index ce70af748..5b2958ac0 100644 --- a/sample/python/__main__.py +++ b/sample/python/__main__.py @@ -99,24 +99,24 @@ def on_tasker_task( ): print(f"on_tasker_task: {noti_type}, {detail}") - def on_task_next_list( + def on_node_next_list( self, noti_type: NotificationType, - detail: NotificationHandler.TaskNextListDetail, + detail: NotificationHandler.NodeNextListDetail, ): - print(f"on_task_next_list: {noti_type}, {detail}") + print(f"on_node_next_list: {noti_type}, {detail}") - def on_task_recognition( + def on_node_recognition( self, noti_type: NotificationType, - detail: NotificationHandler.TaskRecognitionDetail, + detail: NotificationHandler.NodeRecognitionDetail, ): - print(f"on_task_recognition: {noti_type}, {detail}") + print(f"on_node_recognition: {noti_type}, {detail}") - def on_task_action( - self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail + def on_node_action( + self, noti_type: NotificationType, detail: NotificationHandler.NodeActionDetail ): - print(f"on_task_action: {noti_type}, {detail}") + print(f"on_node_action: {noti_type}, {detail}") if __name__ == "__main__": diff --git a/source/MaaFramework/Task/TaskBase.cpp b/source/MaaFramework/Task/TaskBase.cpp index a1896ec8c..b17d04315 100644 --- a/source/MaaFramework/Task/TaskBase.cpp +++ b/source/MaaFramework/Task/TaskBase.cpp @@ -80,7 +80,7 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N const json::value reco_list_cb_detail { { "task_id", task_id() }, - { "node", cur_node_ }, + { "name", cur_node_ }, { "list", json::array(list) }, }; if (debug_mode() || focus) { @@ -106,7 +106,7 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N const json::value reco_cb_detail { { "task_id", task_id() }, { "reco_id", 0 }, - { "node", node }, + { "name", node }, }; notify(MaaMsg_Node_Recognition_Starting, reco_cb_detail); } @@ -117,7 +117,7 @@ RecoResult TaskBase::run_recognition(const cv::Mat& image, const PipelineData::N const json::value reco_cb_detail { { "task_id", task_id() }, { "reco_id", result.reco_id }, - { "node", node }, + { "name", node }, }; notify(result.box ? MaaMsg_Node_Recognition_Succeeded : MaaMsg_Node_Recognition_Failed, reco_cb_detail); } @@ -165,7 +165,7 @@ NodeDetail TaskBase::run_action(const RecoResult& reco) const json::value cb_detail { { "task_id", task_id() }, { "node_id", 0 }, - { "node", reco.name }, + { "name", reco.name }, }; notify(MaaMsg_Node_Action_Starting, cb_detail); } @@ -186,7 +186,7 @@ NodeDetail TaskBase::run_action(const RecoResult& reco) const json::value cb_detail { { "task_id", task_id() }, { "node_id", result.node_id }, - { "node", reco.name }, + { "name", reco.name }, }; notify(result.completed ? MaaMsg_Node_Action_Succeeded : MaaMsg_Node_Action_Failed, cb_detail); } diff --git a/source/binding/Python/maa/notification_handler.py b/source/binding/Python/maa/notification_handler.py index 7191c96b3..6143aafd0 100644 --- a/source/binding/Python/maa/notification_handler.py +++ b/source/binding/Python/maa/notification_handler.py @@ -59,34 +59,34 @@ def on_tasker_task(self, noti_type: NotificationType, detail: TaskerTaskDetail): pass @dataclass - class TaskNextListDetail: + class NodeNextListDetail: task_id: int - node: str + name: str next_list: list[str] - def on_task_next_list( - self, noti_type: NotificationType, detail: TaskNextListDetail + def on_node_next_list( + self, noti_type: NotificationType, detail: NodeNextListDetail ): pass @dataclass - class TaskRecognitionDetail: + class NodeRecognitionDetail: task_id: int reco_id: int - node: str + name: str - def on_task_recognition( - self, noti_type: NotificationType, detail: TaskRecognitionDetail + def on_node_recognition( + self, noti_type: NotificationType, detail: NodeRecognitionDetail ): pass @dataclass - class TaskActionDetail: + class NodeActionDetail: task_id: int node_id: int - node: str + name: str - def on_task_action(self, noti_type: NotificationType, detail: TaskActionDetail): + def on_node_action(self, noti_type: NotificationType, detail: NodeActionDetail): pass def on_unknown_notification(self, msg: str, details: dict): @@ -122,26 +122,26 @@ def on_raw_notification(self, msg: str, details: dict): self.on_tasker_task(noti_type, detail) elif msg.startswith("Node.NextList"): - detail = self.TaskNextListDetail( + detail = self.NodeNextListDetail( task_id=details["task_id"], - node=details["node"], + name=details["name"], next_list=details["list"], ) self.on_node_next_list(noti_type, detail) elif msg.startswith("Node.Recognition"): - detail = self.TaskRecognitionDetail( + detail = self.NodeRecognitionDetail( task_id=details["task_id"], reco_id=details["reco_id"], - node=details["node"], + name=details["name"], ) self.on_node_recognition(noti_type, detail) elif msg.startswith("Node.Action"): - detail = self.TaskActionDetail( + detail = self.NodeActionDetail( task_id=details["task_id"], node_id=details["node_id"], - node=details["node"], + name=details["name"], ) self.on_node_action(noti_type, detail)