Skip to content

Commit

Permalink
pi refactor [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Sep 7, 2024
1 parent da1b152 commit db4a261
Show file tree
Hide file tree
Showing 25 changed files with 2,110 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/MaaDeps
Submodule MaaDeps updated 45 files
+13 −10 .github/workflows/build.yml
+2 −1 build.py
+0 −23 maadeps/runtime_android.py
+1 −1 vcpkg
+0 −12 vcpkg-overlay/ports/abseil/avoid-export-internal.patch
+0 −59 vcpkg-overlay/ports/abseil/portfile.cmake
+0 −26 vcpkg-overlay/ports/abseil/vcpkg.json
+0 −28 vcpkg-overlay/ports/boost-asio/opt-dep.diff
+4 −9 vcpkg-overlay/ports/boost-asio/portfile.cmake
+15 −20 vcpkg-overlay/ports/boost-asio/vcpkg.json
+0 −51 vcpkg-overlay/ports/directml-bin/portfile.cmake
+0 −8 vcpkg-overlay/ports/directml-bin/vcpkg.json
+0 −20 vcpkg-overlay/ports/flatbuffers/fix-uwp-build.patch
+0 −47 vcpkg-overlay/ports/flatbuffers/portfile.cmake
+0 −21 vcpkg-overlay/ports/flatbuffers/vcpkg.json
+17 −0 vcpkg-overlay/ports/maa-fastdeploy/000-fix-rpath.patch
+4 −2 vcpkg-overlay/ports/maa-fastdeploy/portfile.cmake
+1 −1 vcpkg-overlay/ports/maa-fastdeploy/vcpkg.json
+40 −223 vcpkg-overlay/ports/maa-onnxruntime/0000-system-lib-fix.patch
+0 −9,592 vcpkg-overlay/ports/maa-onnxruntime/0001-coreml-proto.patch
+21 −0 vcpkg-overlay/ports/maa-onnxruntime/0001-suppress-depracation-warnings.patch
+10 −0 vcpkg-overlay/ports/maa-onnxruntime/0002-pkgconfig-prefix.patch
+13 −0 vcpkg-overlay/ports/maa-onnxruntime/0003-cmake-typo.patch
+225 −0 vcpkg-overlay/ports/maa-onnxruntime/0004-flatbuffers-includes.patch
+13 −0 vcpkg-overlay/ports/maa-onnxruntime/0005-disable-onnxruntime_mlas_q4dq.patch
+35 −0 vcpkg-overlay/ports/maa-onnxruntime/0006-typo-install-to-bin.patch
+8 −14 vcpkg-overlay/ports/maa-onnxruntime/portfile.cmake
+2 −15 vcpkg-overlay/ports/maa-onnxruntime/vcpkg.json
+25 −0 vcpkg-overlay/ports/onnx/fix-cmakelists.patch
+2 −18 vcpkg-overlay/ports/onnx/fix-dependency-protobuf.patch
+7 −5 vcpkg-overlay/ports/onnx/portfile.cmake
+10 −3 vcpkg-overlay/ports/onnx/vcpkg.json
+0 −48 vcpkg-overlay/ports/protobuf/compile_options.patch
+0 −21 vcpkg-overlay/ports/protobuf/fix-default-proto-file-path.patch
+0 −13 vcpkg-overlay/ports/protobuf/fix-static-build.patch
+0 −158 vcpkg-overlay/ports/protobuf/portfile.cmake
+0 −8 vcpkg-overlay/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake
+0 −16 vcpkg-overlay/ports/protobuf/vcpkg-cmake-wrapper.cmake
+0 −30 vcpkg-overlay/ports/protobuf/vcpkg.json
+21 −0 vcpkg-overlay/scripts/remove_avoid-version.patch
+10 −10 vcpkg-overlay/triplets/maa-android-library-override.cmake
+13 −13 vcpkg-overlay/triplets/maa-arm-android.cmake
+13 −0 vcpkg-overlay/triplets/maa-arm-neon-android.cmake
+13 −13 vcpkg-overlay/triplets/maa-arm64-android.cmake
+12 −3 vcpkg.json
6 changes: 6 additions & 0 deletions include/MaaFramework/MaaPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@
#else
#define MAA_TOOLKIT_API MAA_DLL_IMPORT
#endif

#ifdef MAA_PI_EXPORTS
#define MAA_PI_API MAA_DLL_EXPORT
#else
#define MAA_PI_API MAA_DLL_IMPORT
#endif
35 changes: 35 additions & 0 deletions include/MaaPI/MaaPIAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include "MaaPIDef.h" // IWYU pragma: export

#ifdef __cplusplus
extern "C"
{
#endif

MAA_PI_API MaaPIData* MaaPIDataCreate();
MAA_PI_API void MaaPIDataDestroy(MaaPIData* data);
MAA_PI_API MaaBool MaaPIDataLoad(MaaPIData* data, const char* json, const char* path);

MAA_PI_API MaaPIConfig* MaaPIConfigCreate();
MAA_PI_API void MaaPIConfigDestroy(MaaPIConfig* cfg);
MAA_PI_API MaaBool MaaPIConfigLoad(MaaPIConfig* cfg, MaaPIData* data, const char* json);
MAA_PI_API MaaBool MaaPIConfigGenDef(MaaPIConfig* cfg, MaaPIData* data);
MAA_PI_API MaaBool MaaPIConfigSave(MaaPIConfig* cfg, MaaStringBuffer* json);

MAA_PI_API MaaPIRuntime* MaaPIRuntimeCreate();
MAA_PI_API void MaaPIRuntimeDestroy(MaaPIRuntime* rt);
MAA_PI_API MaaController* MaaPIRuntimeGetController(MaaPIRuntime* rt);
MAA_PI_API MaaResource* MaaPIRuntimeGetResource(MaaPIRuntime* rt);
MAA_PI_API MaaTasker* MaaPIRuntimeGetTasker(MaaPIRuntime* rt);
MAA_PI_API MaaBool MaaPIRuntimeBind(MaaPIRuntime* rt, MaaPIData* data, MaaPIConfig* cfg);
MAA_PI_API MaaBool MaaPIRuntimeSetup(MaaPIRuntime* rt, MaaNotificationCallback cb, void* cb_arg);

MAA_PI_API MaaPIClient* MaaPIClientCreate(const char* locale, MaaPIClientHandler handler, void* handler_arg);
MAA_PI_API void MaaPIClientDestroy(MaaPIClient* client);
MAA_PI_API MaaBool MaaPIClientPerform(MaaPIClient* client, MaaPIRuntime* rt, MaaPIClientAction action);

#ifdef __cplusplus
}
#endif

38 changes: 38 additions & 0 deletions include/MaaPI/MaaPIDef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "MaaFramework/MaaDef.h" // IWYU pragma: export

struct MaaPIData;
struct MaaPIConfig;
struct MaaPIRuntime;
struct MaaPIClient;

typedef int32_t MaaPIClientAction;

enum MaaPIClientAction_Enum
{
MaaPIClientAction_SelectController,
MaaPIClientAction_SelectResource,
MaaPIClientAction_AddTask,
MaaPIClientAction_MoveTask,
MaaPIClientAction_RemoveTask,
MaaPIClientAction_ConfigureTask,
MaaPIClientAction_LaunchTask,

MaaPIClientAction_Derived_SelectAdb,
MaaPIClientAction_Derived_SelectDesktop,
MaaPIClientAction_Derived_SelectTask,
MaaPIClientAction_Derived_SelectOption,

MaaPIClientAction_DirectBegin = MaaPIClientAction_SelectController,
MaaPIClientAction_DirectEnd = MaaPIClientAction_LaunchTask,
MaaPIClientAction_DerivedBegin = MaaPIClientAction_Derived_SelectAdb,
MaaPIClientAction_DerivedEnd = MaaPIClientAction_Derived_SelectOption,
};

typedef int32_t (*MaaPIClientHandler)(
MaaPIClient* client,
MaaPIClientAction action,
MaaStringListBuffer* choice,
MaaStringListBuffer* details,
void* arg);
3 changes: 3 additions & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config.json
pi_config.json
maa_option.json
7 changes: 3 additions & 4 deletions sample/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
add_executable(sample main.cpp)
target_link_libraries(sample MaaFramework MaaToolkit)

# set(MaaPP_INC_REL ${CMAKE_CURRENT_LIST_DIR}/../../source/binding/cpp/include)
# cmake_path(ABSOLUTE_PATH MaaPP_INC_REL NORMALIZE OUTPUT_VARIABLE MaaPP_INC)
# set(MaaPP_INC_REL ${CMAKE_CURRENT_LIST_DIR}/../../source/binding/cpp/include) cmake_path(ABSOLUTE_PATH MaaPP_INC_REL
# NORMALIZE OUTPUT_VARIABLE MaaPP_INC)
#
# add_executable(sample_cpp20 main_c++20.cpp)
# target_include_directories(sample_cpp20 PRIVATE ${MaaPP_INC})
# add_executable(sample_cpp20 main_c++20.cpp) target_include_directories(sample_cpp20 PRIVATE ${MaaPP_INC})
# target_link_libraries(sample_cpp20 MaaFramework MaaToolkit HeaderOnlyLibraries)
154 changes: 154 additions & 0 deletions sample/pi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"controller": [
{
"name": "安卓端",
"type": "Adb"
},
{
"name": "桌面端",
"type": "Desktop",
"desktop": {
"class_regex": ".*",
"window_regex": "Visual Studio"
}
}
],
"resource": [
{
"name": "Official",
"paths": ["{PROJECT_DIR}/resource/base"]
},
{
"name": "Bilibili",
"paths": ["{PROJECT_DIR}/resource/base", "{PROJECT_DIR}/resource/bilibili"]
}
],
"task": [
{
"name": "收取荒原",
"entry": "Wilderness"
},
{
"name": "每日心相(意志解析)",
"entry": "Psychube"
},
{
"name": "常规作战",
"entry": "Combat",
"option": ["作战关卡", "复现次数", "刷完全部体力"]
},
{
"name": "活动:绿湖噩梦 17 艰难(活动已结束)",
"entry": "ANightmareAtGreenLake",
"option": ["复现次数", "刷完全部体力"],
"pp_override": {
"EnterTheShow": {
"next": "ANightmareAtGreenLake"
},
"TargetStageName": {
"expected": "17"
},
"StageDifficulty": {
"next": "ActivityStageDifficulty"
}
}
},
{
"name": "领取奖励",
"entry": "Awards"
}
],
"option": [
{
"name": "作战关卡",
"cases": [
{
"name": "3-9 厄险(百灵百验鸟)",
"pp_override": {
"EnterTheShow": {
"next": "MainChapter_3"
},
"TargetStageName": {
"expected": "09"
},
"StageDifficulty": {
"next": "StageDifficulty_Hard"
}
}
},
{
"name": "4-20 厄险(双头形骨架)",
"pp_override": {
"EnterTheShow": {
"next": "MainChapter_4"
},
"TargetStageName": {
"expected": "20"
},
"StageDifficulty": {
"next": "StageDifficulty_Hard"
}
}
}
]
},
{
"name": "复现次数",
"cases": [
{
"name": "x1",
"pp_override": {
"SetReplaysTimes": {
"expected": "1"
}
}
},
{
"name": "x2",
"pp_override": {
"SetReplaysTimes": {
"expected": "2"
}
}
},
{
"name": "x3",
"pp_override": {
"SetReplaysTimes": {
"expected": "3"
}
}
},
{
"name": "x4",
"pp_override": {
"SetReplaysTimes": {
"expected": "4"
}
}
}
]
},
{
"name": "刷完全部体力",
"cases": [
{
"name": "Yes",
"pp_override": {
"AllIn": {
"enabled": true
}
}
},
{
"name": "No",
"pp_override": {
"AllIn": {
"enabled": false
}
}
}
]
}
]
}
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ endif()
add_subdirectory(LibraryHolder)
add_subdirectory(MaaFramework)
add_subdirectory(MaaToolkit)
add_subdirectory(MaaProjectInterface)
add_subdirectory(MaaPI)

add_subdirectory(binding)
2 changes: 2 additions & 0 deletions source/MaaFramework/Tasker/Tasker.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <ranges>

#include "RuntimeCache.h"

#include <ranges>
Expand Down
Loading

0 comments on commit db4a261

Please sign in to comment.