mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
* feat: 支持woolang绑定,嘻嘻嘻
This commit is contained in:
8
src/Woolang/.gitignore
vendored
Normal file
8
src/Woolang/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
/pkg
|
||||
/.vs
|
||||
/build
|
||||
/woolang
|
||||
/debug_*
|
||||
/release_*
|
||||
|
||||
101
src/Woolang/demo.wo
Normal file
101
src/Woolang/demo.wo
Normal file
@@ -0,0 +1,101 @@
|
||||
import maa;
|
||||
import pkg::filesystem;
|
||||
|
||||
let ASST_DEBUG = true;
|
||||
|
||||
func main()
|
||||
{
|
||||
let cur_path = filesys::normalize(std::exepath());
|
||||
|
||||
if (AsstLoadResource(cur_path->tostring) == AsstTrue)
|
||||
{
|
||||
if (ASST_DEBUG)
|
||||
{
|
||||
let overseas_dir = cur_path / "resource" / "global";
|
||||
for (let _, client: ["YoStarJP", "YoStarEN", "YoStarKR", "txwy"])
|
||||
{
|
||||
let overseas_path = overseas_dir / client;
|
||||
let loaded = AsstLoadResource(cur_path->tostring);
|
||||
|
||||
if (AsstLoadResource(overseas_path->tostring) != AsstTrue || loaded != AsstTrue)
|
||||
return result::err("Load resource failed.");
|
||||
}
|
||||
}
|
||||
|
||||
let ptr = AsstCreate();
|
||||
if (ptr == nullptr: AsstHandle)
|
||||
return result::err("AsstCreate() failed.");
|
||||
|
||||
if (ASST_DEBUG)
|
||||
do AsstAsyncConnect(ptr, "adb", "127.0.0.1:5555", "DEBUG", AsstTrue);
|
||||
else
|
||||
do AsstAsyncConnect(ptr, "adb", "127.0.0.1:5555", "", AsstTrue);
|
||||
|
||||
if (AsstConnected(ptr) == AsstFalse)
|
||||
{
|
||||
AsstDestroy(ptr);
|
||||
return result::err("Connect failed.");
|
||||
}
|
||||
|
||||
if (ASST_DEBUG)
|
||||
{
|
||||
do AsstAppendTask(ptr, "Debug", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
do AsstAppendTask(ptr, "StartUp", "");
|
||||
do AsstAppendTask(ptr, "Fight", @"
|
||||
{
|
||||
"stage": "1-7"
|
||||
}
|
||||
"@);
|
||||
do AsstAppendTask(ptr, "Recruit", @"
|
||||
{
|
||||
"select":[4],
|
||||
"confirm":[3,4],
|
||||
"times":4
|
||||
}
|
||||
"@);
|
||||
do AsstAppendTask(ptr, "Infrast", @"
|
||||
{
|
||||
"facility": ["Mfg", "Trade", "Power", "Control", "Reception", "Office", "Dorm"],
|
||||
"drones": "Money"
|
||||
}
|
||||
"@);
|
||||
do AsstAppendTask(ptr, "Mall", @"
|
||||
{
|
||||
"shopping": true,
|
||||
"buy_first": [
|
||||
"许可"
|
||||
],
|
||||
"black_list": [
|
||||
"家具",
|
||||
"碳"
|
||||
]
|
||||
}
|
||||
"@);
|
||||
do AsstAppendTask(ptr, "Award", "");
|
||||
do AsstAppendTask(ptr, "Roguelike", @"
|
||||
{
|
||||
"squad": "突击战术分队",
|
||||
"roles": "先手必胜",
|
||||
"core_char": "棘刺"
|
||||
}
|
||||
"@);
|
||||
}
|
||||
|
||||
do AsstStart(ptr);
|
||||
while (AsstRunning(ptr) == AsstTrue)
|
||||
{
|
||||
std::sleep(0.1);
|
||||
}
|
||||
do AsstStop(ptr);
|
||||
do AsstDestroy(ptr);
|
||||
|
||||
return result::ok(do nil);
|
||||
}
|
||||
else
|
||||
return result::err("Load resource failed.");
|
||||
}
|
||||
|
||||
main()->unwarp();
|
||||
73
src/Woolang/maa.wo
Normal file
73
src/Woolang/maa.wo
Normal file
@@ -0,0 +1,73 @@
|
||||
// maa.wo
|
||||
|
||||
import woo::std;
|
||||
import pkg::woffi;
|
||||
|
||||
WOFFI_TYPEDEF!
|
||||
{
|
||||
public using AsstHandle = pointer;
|
||||
public using AsstBool = uint8;
|
||||
public using AsstSize = uint64;
|
||||
|
||||
public using AsstId = int32;
|
||||
public using AsstMsgId = int32;
|
||||
public using AsstTaskId = int32;
|
||||
public using AsstAsyncCallId = int32;
|
||||
|
||||
public using AsstOptionKey = int32;
|
||||
public using AsstStaticOptionKey = int32;
|
||||
public using AsstInstanceOptionKey = int32;
|
||||
|
||||
public using AsstApiCallback = pointer;
|
||||
}
|
||||
|
||||
public let AsstTrue = 1: AsstBool;
|
||||
public let AsstFalse = 0: AsstBool;
|
||||
|
||||
WOFFI_FUNCTIONS!
|
||||
{
|
||||
import "MaaCore.dll";
|
||||
|
||||
public stdcall func AsstSetUserDir(path: cstring)=> AsstBool;
|
||||
public stdcall func AsstLoadResource(path: cstring)=> AsstBool;
|
||||
public stdcall func AsstSetStaticOption(key: AsstStaticOptionKey, value: cstring)=> AsstBool;
|
||||
|
||||
public stdcall func AsstCreate()=> AsstHandle;
|
||||
public stdcall func AsstCreateEx(callback: AsstApiCallback, custom_arg: pointer)=> AsstHandle;
|
||||
public stdcall func AsstDestroy(handle: AsstHandle)=> void;
|
||||
|
||||
public stdcall func AsstSetInstanceOption(
|
||||
handle: AsstHandle, key: AsstInstanceOptionKey, value: cstring)=> AsstBool;
|
||||
|
||||
// deprecated in 5.0
|
||||
public stdcall func AsstConnect(
|
||||
handle: AsstHandle, adb_path: cstring, address: cstring, config: cstring)=> AsstBool;
|
||||
|
||||
public stdcall func AsstAppendTask(
|
||||
handle: AsstHandle, type: cstring, params: cstring)=> AsstTaskId;
|
||||
public stdcall func AsstSetTaskParams(
|
||||
handle: AsstHandle, id: AsstTaskId, params: cstring)=> AsstTaskId;
|
||||
|
||||
public stdcall func AsstStart(handle: AsstHandle)=> AsstBool;
|
||||
public stdcall func AsstStop(handle: AsstHandle)=> AsstBool;
|
||||
public stdcall func AsstRunning(handle: AsstHandle)=> AsstBool;
|
||||
public stdcall func AsstConnected(handle: AsstHandle)=> AsstBool;
|
||||
|
||||
public stdcall func AsstAsyncConnect(
|
||||
handle: AsstHandle,
|
||||
adb_path: cstring,
|
||||
address: cstring,
|
||||
config: cstring,
|
||||
block: AsstBool)=> AsstAsyncCallId;
|
||||
public stdcall func AsstAsyncClick(handle: AsstHandle, x: int32, y: int32, block: AsstBool)=> AsstAsyncCallId;
|
||||
public stdcall func AsstAsyncScreencap(handle: AsstHandle, block: AsstBool)=>AsstAsyncCallId;
|
||||
|
||||
public stdcall func AsstGetImage(handle: AsstHandle, buff: pointer, buff_size: AsstSize)=> AsstSize;
|
||||
public stdcall func AsstGetUUID(handle: AsstHandle, buff: pointer, buff_size: AsstSize)=> AsstSize;
|
||||
public stdcall func AsstGetTasksList(handle: AsstHandle, buff: pointer, buff_size: AsstSize)=> AsstSize;
|
||||
public stdcall func AsstGetNullSize()=> AsstSize;
|
||||
|
||||
public stdcall func AsstGetVersion()=> cstring;
|
||||
public stdcall func AsstLog(level: cstring, message: cstring)=> void;
|
||||
}
|
||||
;
|
||||
23
src/Woolang/package.json
Normal file
23
src/Woolang/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"config" : [
|
||||
"release_x64"
|
||||
],
|
||||
"dependence" : {
|
||||
"filesystem" : {
|
||||
"path" : "pkg",
|
||||
"remote" : "https://git.cinogama.net/cinogamaproject/woolangpackages",
|
||||
"version" : "1.0.0"
|
||||
},
|
||||
"woffi" : {
|
||||
"path" : "pkg",
|
||||
"remote" : "https://git.cinogama.net/cinogamaproject/woolangpackages",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
},
|
||||
"name" : "maa",
|
||||
"version" : "1.0.0",
|
||||
"woolang" : {
|
||||
"remote" : "https://git.cinogama.net/cinogamaproject",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user