diff --git a/source/MaaFramework/API/MaaTypes.h b/source/MaaFramework/API/MaaTypes.h index dc70b6f48..38646028e 100644 --- a/source/MaaFramework/API/MaaTypes.h +++ b/source/MaaFramework/API/MaaTypes.h @@ -146,6 +146,7 @@ struct MaaDebugContextAPI public: virtual ~MaaDebugContextAPI() = default; + virtual std::vector get_task_list() const = 0; virtual const MAA_DEBUG_NS::Task* get_task_debug_info(std::string_view task) const = 0; }; diff --git a/source/MaaFramework/Debug/DebugContext.cpp b/source/MaaFramework/Debug/DebugContext.cpp new file mode 100644 index 000000000..ff1f7060a --- /dev/null +++ b/source/MaaFramework/Debug/DebugContext.cpp @@ -0,0 +1,15 @@ +#include "DebugContext.h" + +MAA_DEBUG_NS_BEGIN + +DebugContext::DebugContext(TaskNS::PipelineTask* task) + : task_(task) +{ +} + +std::vector DebugContext::get_task_list() const +{ + return task_->data_mgr_.get_task_list(); +} + +MAA_DEBUG_NS_END diff --git a/source/MaaFramework/Debug/DebugContext.h b/source/MaaFramework/Debug/DebugContext.h new file mode 100644 index 000000000..d04cbad8a --- /dev/null +++ b/source/MaaFramework/Debug/DebugContext.h @@ -0,0 +1,22 @@ +#pragma once + +#include "API/MaaTypes.h" +#include "Conf/Conf.h" +#include "Instance/InstanceInternalAPI.hpp" +#include "Task/PipelineTask.h" + +MAA_DEBUG_NS_BEGIN + +class DebugContext : public MaaDebugContextAPI +{ +public: + DebugContext(TaskNS::PipelineTask* task); + + virtual std::vector get_task_list() const override; + virtual const MAA_DEBUG_NS::Task* get_task_debug_info(std::string_view task) const override; + +private: + TaskNS::PipelineTask* task_; +}; + +MAA_DEBUG_NS_END diff --git a/source/MaaFramework/Task/PipelineTask.h b/source/MaaFramework/Task/PipelineTask.h index 3454e88b5..9eb1da190 100644 --- a/source/MaaFramework/Task/PipelineTask.h +++ b/source/MaaFramework/Task/PipelineTask.h @@ -14,11 +14,19 @@ #include "Task/Recognizer.h" #include "Task/TaskDataMgr.h" +MAA_DEBUG_NS_BEGIN + +class DebugContext; + +MAA_DEBUG_NS_END + MAA_TASK_NS_BEGIN class PipelineTask : public MaaInstanceSink { public: + friend class DebugNS::DebugContext; + using TaskData = MAA_RES_NS::TaskData; public: diff --git a/source/MaaFramework/Task/TaskDataMgr.cpp b/source/MaaFramework/Task/TaskDataMgr.cpp index 06b3510a0..76a196c93 100644 --- a/source/MaaFramework/Task/TaskDataMgr.cpp +++ b/source/MaaFramework/Task/TaskDataMgr.cpp @@ -4,6 +4,8 @@ #include "Resource/ResourceMgr.h" #include "Utils/ImageIo.h" #include "Utils/Logger.h" +#include +#include MAA_TASK_NS_BEGIN @@ -12,6 +14,22 @@ TaskDataMgr::TaskDataMgr(InstanceInternalAPI* inst) { } +std::vector TaskDataMgr::get_task_list() +{ + if (!resource()) { + LogError << "Resource not binded"; + return {}; + } + auto& raw_data_mgr = resource()->pipeline_res(); + auto raw_tasks = raw_data_mgr.get_task_list(); + auto diff_tasks = diff_tasks_ | std::views::keys; + + std::set tasks(raw_tasks.begin(), raw_tasks.end()); + tasks.insert(diff_tasks.begin(), diff_tasks.end()); + + return std::vector(tasks.begin(), tasks.end()); +} + const MAA_RES_NS::TaskData& TaskDataMgr::get_task_data(const std::string& task_name) { if (!resource()) { diff --git a/source/MaaFramework/Task/TaskDataMgr.h b/source/MaaFramework/Task/TaskDataMgr.h index 9eb28ae0d..c9d6d2e8c 100644 --- a/source/MaaFramework/Task/TaskDataMgr.h +++ b/source/MaaFramework/Task/TaskDataMgr.h @@ -20,6 +20,7 @@ class TaskDataMgr public: explicit TaskDataMgr(InstanceInternalAPI* inst); + std::vector get_task_list(); const TaskData& get_task_data(const std::string& task_name); bool set_param(const json::value& param);