-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,614 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.inherit</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// swift-tools-version: 5.7 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "MeoAssistant", | ||
platforms: [.macOS(.v11)], | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library(name: "MeoAssistant", targets: ["MeoAssistant"]), | ||
.library(name: "opencv2", targets: ["opencv2"]) | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.binaryTarget(name: "MeoAssistant", path: "../../../build/MeoAssistant.xcframework"), | ||
.binaryTarget(name: "opencv2", path: "../../../build/opencv2.xcframework") | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# MeoAssistant | ||
|
||
Metapackage for OpenCV and MeoAssistant. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// ConnectionSettingsView.swift | ||
// MeoAsstMac | ||
// | ||
// Created by hguandl on 10/10/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ConnectionSettingsView: View { | ||
@EnvironmentObject private var appDelegate: AppDelegate | ||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
Text("ADB地址") | ||
TextField("", text: $appDelegate.connectionAddress) | ||
} | ||
} | ||
.padding(.horizontal) | ||
} | ||
} | ||
|
||
struct ConnectionSettingsView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ConnectionSettingsView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// FightSettingsView.swift | ||
// MeoAsstMac | ||
// | ||
// Created by hguandl on 9/10/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FightSettingsView: View { | ||
@EnvironmentObject private var appDelegate: AppDelegate | ||
|
||
var body: some View { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Toggle("吃理智药", isOn: $appDelegate.useSanityPotion).frame(width: 80, alignment: .leading) | ||
TextField("", value: $appDelegate.sanityPotion, format: .number).frame(width: 80) | ||
} | ||
HStack { | ||
Toggle("吃源石*", isOn: $appDelegate.useOriginitePrime).frame(width: 80, alignment: .leading) | ||
TextField("", value: $appDelegate.originitePrime, format: .number).frame(width: 80) | ||
} | ||
HStack { | ||
Toggle("指定次数*", isOn: $appDelegate.limitPerformBattles).frame(width: 80, alignment: .leading) | ||
TextField("", value: $appDelegate.performBattles, format: .number).frame(width: 80) | ||
} | ||
Toggle(isOn: .constant(false)) { | ||
Picker("指定材料", selection: .constant(0)) {} | ||
} | ||
.disabled(true) | ||
Picker("关卡选择", selection: $appDelegate.stageSelect) { | ||
Text("当前/上次").tag("") | ||
Text("1-7").tag("1-7") | ||
Text("CE-6").tag("CE-6") | ||
Text("AP-5").tag("AP-5") | ||
Text("CA-5").tag("CA-5") | ||
Text("LS-6").tag("LS-5") | ||
Text("剿灭模式").tag("Annihilation") | ||
} | ||
Picker("剩余理智", selection: $appDelegate.remainingSanityStage) { | ||
Text("不选择").tag("") | ||
Text("1-7") | ||
Text("龙门币 CE-6").tag("CE-6") | ||
Text("红票 AP-5").tag("AP-5") | ||
Text("技能书 CA-5").tag("CA-5") | ||
Text("经验书 LS-6").tag("LS-5") | ||
Text("剿灭模式").tag("Annihilation") | ||
} | ||
Text("标注 * 的选项重启后不保存").font(.footnote) | ||
} | ||
} | ||
} | ||
|
||
struct FightSettingsView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FightSettingsView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// InfrastSettingsView.swift | ||
// MeoAsstMac | ||
// | ||
// Created by hguandl on 9/10/2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct InfrastSettingsView: View { | ||
@EnvironmentObject private var appDelegate: AppDelegate | ||
|
||
@Environment(\.defaultMinListRowHeight) private var rowHeight | ||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
List { | ||
ForEach(appDelegate.facilities, id: \.name) { facility in | ||
Toggle(facility.description, isOn: binding(for: facility)) | ||
} | ||
.onMove { source, destination in | ||
appDelegate.facilities.move(fromOffsets: source, toOffset: destination) | ||
} | ||
} | ||
.frame(height: 12 * rowHeight) | ||
|
||
Form { | ||
Section { | ||
Text("无人机用途") | ||
Picker("", selection: $appDelegate.droneUsage) { | ||
ForEach(DroneUsage.allCases, id: \.self) { usage in | ||
Text(usage.description).tag(usage.rawValue) | ||
} | ||
} | ||
.padding(.bottom) | ||
} | ||
Divider() | ||
Section { | ||
Text("基建工作心情阈值: \(appDelegate.dormThreshold * 100, specifier: "%.0f")%") | ||
Slider(value: $appDelegate.dormThreshold, in: 0 ... 1) | ||
} | ||
Divider() | ||
Section { | ||
Toggle("宿舍空余位置蹭信赖", isOn: $appDelegate.dormTrust) | ||
Toggle("不将已进驻的干员放入宿舍", isOn: $appDelegate.dormFilterStationed) | ||
Toggle("源石碎片自动补货", isOn: $appDelegate.originiumReplenishment) | ||
} | ||
} | ||
} | ||
.padding() | ||
|
||
Toggle("启用自定义基建配置(beta)", isOn: .constant(false)).disabled(true) | ||
.padding(.vertical) | ||
} | ||
} | ||
|
||
// MARK: Custom bindings | ||
|
||
private func binding(for facility: MaaInfrastFacility) -> Binding<Bool> { | ||
return Binding { | ||
facility.enabled | ||
} set: { newValue in | ||
if let i = appDelegate.facilities.firstIndex(where: { $0.name == facility.name }) { | ||
appDelegate.facilities[i].enabled = newValue | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct InfrastSettingsView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
InfrastSettingsView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// Maa.swift | ||
// MeoAsstMac | ||
// | ||
// Created by hguandl on 9/10/2022. | ||
// | ||
|
||
import Foundation | ||
import MeoAssistant | ||
|
||
public struct Maa { | ||
static var resourceLoaded = false | ||
|
||
private let handle: AsstHandle | ||
|
||
public static func loadResource(path: String) -> Bool { | ||
if AsstLoadResource(path) { | ||
resourceLoaded = true | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
public static func setUserDirectory(path: String) -> Bool { | ||
AsstSetUserDir(path) | ||
} | ||
|
||
public init() { | ||
let callback: AsstApiCallback = { msg, details, _ in | ||
if msg >= 20000 { | ||
return | ||
} | ||
if let details = details { | ||
let details = String(cString: details, encoding: .utf8) ?? "<nil>" | ||
let message = MaaMessage(msg: msg, details: details) | ||
Self.publishLogMessage(message: message) | ||
} | ||
} | ||
|
||
self.handle = AsstCreateEx(callback, nil) | ||
} | ||
|
||
public func appendTask(taskType: String, taskConfig: String) -> Int32 { | ||
AsstAppendTask(handle, taskType, taskConfig) | ||
} | ||
|
||
public func connect(adbPath: String, address: String) -> Bool { | ||
AsstConnect(handle, adbPath, address, "General") | ||
} | ||
|
||
public func start() -> Bool { | ||
AsstStart(handle) | ||
} | ||
|
||
public func stop() -> Bool { | ||
AsstStop(handle) | ||
} | ||
|
||
public var running: Bool { | ||
AsstRunning(handle) | ||
} | ||
|
||
static func publishLogMessage(message: MaaMessage) { | ||
NotificationCenter.default.post(name: .MAAReceivedCallbackMessage, object: message) | ||
} | ||
} | ||
|
||
public extension Notification.Name { | ||
static let MAAReceivedCallbackMessage = Notification.Name("MAAReceivedCallbackMessage") | ||
} |
Oops, something went wrong.