Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions MeoAsstMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
92EB82872A0CD315006DD9D2 /* SystemSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92EB82862A0CD315006DD9D2 /* SystemSettingsView.swift */; };
92F78D4D2A0A7B2E00999BD0 /* TaskTimerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92F78D4C2A0A7B2E00999BD0 /* TaskTimerView.swift */; };
92F78D4F2A0B361C00999BD0 /* TaskTimerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92F78D4E2A0B361C00999BD0 /* TaskTimerManager.swift */; };
9BEBD1002DD3CA3C006D212B /* CopilotListConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEBD0FF2DD3CA3C006D212B /* CopilotListConfiguration.swift */; };
9BEBD1012DD3CA3C006D212B /* CopilotItemConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEBD0FE2DD3CA3C006D212B /* CopilotItemConfiguration.swift */; };
9BEBD1052DD3CBB2006D212B /* MapHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEBD1042DD3CBB2006D212B /* MapHelper.swift */; };
9BEBD1082DD3CD52006D212B /* RegularCopilotList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEBD1072DD3CD52006D212B /* RegularCopilotList.swift */; };
9BEBD1092DD3CD52006D212B /* CopilotList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEBD1062DD3CD52006D212B /* CopilotList.swift */; };
9BC2EEB32E3F188D0039C4DB /* MiniGameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BC2EEB22E3F188D0039C4DB /* MiniGameView.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -215,6 +220,11 @@
92EB82862A0CD315006DD9D2 /* SystemSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemSettingsView.swift; sourceTree = "<group>"; };
92F78D4C2A0A7B2E00999BD0 /* TaskTimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTimerView.swift; sourceTree = "<group>"; };
92F78D4E2A0B361C00999BD0 /* TaskTimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTimerManager.swift; sourceTree = "<group>"; };
9BEBD0FE2DD3CA3C006D212B /* CopilotItemConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopilotItemConfiguration.swift; sourceTree = "<group>"; };
9BEBD0FF2DD3CA3C006D212B /* CopilotListConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopilotListConfiguration.swift; sourceTree = "<group>"; };
9BEBD1042DD3CBB2006D212B /* MapHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapHelper.swift; sourceTree = "<group>"; };
9BEBD1062DD3CD52006D212B /* CopilotList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopilotList.swift; sourceTree = "<group>"; };
9BEBD1072DD3CD52006D212B /* RegularCopilotList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegularCopilotList.swift; sourceTree = "<group>"; };
9BC2EEB22E3F188D0039C4DB /* MiniGameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiniGameView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -261,6 +271,8 @@
83264A3429EBEE8D0074E33A /* AwardConfiguration.swift */,
8341194F29EC249E00044F45 /* RoguelikeConfiguration.swift */,
8341195429EC55C600044F45 /* CopilotConfiguration.swift */,
9BEBD0FE2DD3CA3C006D212B /* CopilotItemConfiguration.swift */,
9BEBD0FF2DD3CA3C006D212B /* CopilotListConfiguration.swift */,
832985AF29EEF483009F7ED5 /* ReclamationConfiguration.swift */,
83782A2A2CFFAF2900A32BDD /* LegacyConfigurations.swift */,
);
Expand Down Expand Up @@ -329,10 +341,12 @@
832985B829EF9D50009F7ED5 /* MAAContent.swift */,
832985BC29EFA43B009F7ED5 /* MAADetail.swift */,
8355E7B329E918A2005D5A1C /* TasksContent.swift */,
8341195C29EC719B00044F45 /* CopilotContent.swift */,
832985AD29EEE672009F7ED5 /* UtilityContent.swift */,
832985BA29EFA26D009F7ED5 /* TaskDetail.swift */,
9BEBD1072DD3CD52006D212B /* RegularCopilotList.swift */,
9BEBD1062DD3CD52006D212B /* CopilotList.swift */,
8341195C29EC719B00044F45 /* CopilotContent.swift */,
8329858929ED121A009F7ED5 /* CopilotDetail.swift */,
832985AD29EEE672009F7ED5 /* UtilityContent.swift */,
832985C029EFB665009F7ED5 /* UtilityDetail.swift */,
);
path = Navigation;
Expand Down Expand Up @@ -456,6 +470,7 @@
92CDF6202A065E20005669EC /* Utils */ = {
isa = PBXGroup;
children = (
9BEBD1042DD3CBB2006D212B /* MapHelper.swift */,
92CDF6212A065E55005669EC /* Codeable+JSON.swift */,
92F78D4E2A0B361C00999BD0 /* TaskTimerManager.swift */,
8347B5AE2CDF925400AEB627 /* URLSession+downloadProgress.swift */,
Expand Down Expand Up @@ -566,6 +581,8 @@
9BC2EEB32E3F188D0039C4DB /* MiniGameView.swift in Sources */,
832985BB29EFA26D009F7ED5 /* TaskDetail.swift in Sources */,
834DEC122C4D94BD0073B5D4 /* ClosedownConfiguration.swift in Sources */,
9BEBD1082DD3CD52006D212B /* RegularCopilotList.swift in Sources */,
9BEBD1092DD3CD52006D212B /* CopilotList.swift in Sources */,
83477CB429FEA7A500A5FF99 /* TaskButtons.swift in Sources */,
8355E7B829E9E2B2005D5A1C /* Sidebar.swift in Sources */,
83661E2C29F77CFF007793CA /* VideoRecogView.swift in Sources */,
Expand Down Expand Up @@ -606,6 +623,7 @@
832985B629EF1890009F7ED5 /* MAADepot.swift in Sources */,
83D3283928F3048E00018D10 /* RoguelikeSettingsView.swift in Sources */,
92EB82872A0CD315006DD9D2 /* SystemSettingsView.swift in Sources */,
9BEBD1052DD3CBB2006D212B /* MapHelper.swift in Sources */,
8315B0BD290E48F300AE7FDC /* StartupSettingsView.swift in Sources */,
83264A3529EBEE8D0074E33A /* AwardConfiguration.swift in Sources */,
832985BD29EFA43B009F7ED5 /* MAADetail.swift in Sources */,
Expand All @@ -626,6 +644,8 @@
838FF82729FDD0F9000566A0 /* GachaView.swift in Sources */,
83782A2B2CFFAF2900A32BDD /* LegacyConfigurations.swift in Sources */,
83264A2F29EBEE140074E33A /* RecruitConfiguration.swift in Sources */,
9BEBD1002DD3CA3C006D212B /* CopilotListConfiguration.swift in Sources */,
9BEBD1012DD3CA3C006D212B /* CopilotItemConfiguration.swift in Sources */,
8341195029EC249E00044F45 /* RoguelikeConfiguration.swift in Sources */,
83264A2B29EBED780074E33A /* StartupConfiguration.swift in Sources */,
);
Expand Down
18 changes: 10 additions & 8 deletions MeoAsstMac/Core/Maa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ actor MAAHandle {

private let callback: AsstApiCallback = { msg, details_json, custom_arg in
guard let details_json, let custom_arg,
let detailString = String(cString: details_json, encoding: .utf8)
let detailString = String(cString: details_json, encoding: .utf8)
else {
return
}
Expand All @@ -43,9 +43,10 @@ actor MAAHandle {
let message = MaaMessage(code: Int(msg), details: details)
let uuid = custom_arg.assumingMemoryBound(to: UUID.self).pointee

NotificationCenter.default.post(name: .MAAReceivedCallbackMessage,
object: message,
userInfo: ["uuid": uuid])
NotificationCenter.default.post(
name: .MAAReceivedCallbackMessage,
object: message,
userInfo: ["uuid": uuid])
}

init(options: MAAInstanceOptions = [:]) throws {
Expand Down Expand Up @@ -103,8 +104,9 @@ actor MAAHandle {

let data = Data(bytesNoCopy: buffer, count: size, deallocator: .free)
guard let provider = CGDataProvider(data: data as CFData),
let image = CGImage(pngDataProviderSource: provider, decode: nil,
shouldInterpolate: false, intent: .defaultIntent)
let image = CGImage(
pngDataProviderSource: provider, decode: nil,
shouldInterpolate: false, intent: .defaultIntent)
else {
throw MaaCoreError.getImageFailed
}
Expand Down Expand Up @@ -175,8 +177,8 @@ extension JSON {
}
}

private extension AsstBool {
var isTrue: Bool { self != 0 }
extension AsstBool {
fileprivate var isTrue: Bool { self != 0 }
}

struct MAAResourceVersion: Codable {
Expand Down
29 changes: 27 additions & 2 deletions MeoAsstMac/Core/MaaMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,24 @@ extension MAAViewModel {
logError("TaskError \(taskChain)")
if isCopilot {
logError("CombatError")
if isCopilotListRunning {
Task { try await stop() }
self.copilotListConfig = copilotListConfig
if let stage = getCurrentCopilotStageName() {
logError("战斗出错:\(stage)")
}
isCopilotListRunning = false
logError("CopilotListError")
}
}

case .TaskChainStart:
if let id = taskID(taskDetails: message.details) {
taskStatus[id] = .running
}
if isCopilot, let stage = getCurrentCopilotStageName() {
logInfo("开始关卡:\(stage)")
}
logTrace("StartTask \(taskChain)")

case .TaskChainCompleted:
Expand Down Expand Up @@ -173,13 +185,26 @@ extension MAAViewModel {

if isCopilot {
logInfo("CompleteCombat")
if isCopilotListRunning {
if let stage = getCurrentCopilotStageName() {
logInfo("完成关卡:\(stage)")
}
if let idx = copilotListConfig.items.firstIndex(where: { $0.enabled }) {
copilotListConfig.items[idx].enabled = false
self.copilotListConfig = copilotListConfig
}
}
}

case .TaskChainExtraInfo:
break

case .AllTasksCompleted:
logTrace("AllTasksComplete")
if isCopilotListRunning {
logInfo("CopilotListCompleted")
isCopilotListRunning = false
}
resetStatus()

default:
Expand Down Expand Up @@ -557,7 +582,7 @@ extension MAAViewModel {
}
}

// MARK: Recruit Recoginition
// MARK: - Recruit Recoginition

private func processRecruitMessage(details: JSON) {
guard let what = details["what"].string else {
Expand All @@ -579,7 +604,7 @@ extension MAAViewModel {
}
}

// MARK: Video Recognition
// MARK: - Video Recognition

private func processVideoMessage(details: JSON) {
guard let what = details["what"].string else {
Expand Down
20 changes: 11 additions & 9 deletions MeoAsstMac/Core/MaaToolClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ actor MaaToolClient {
init?(address: String) async {
let parts = address.split(separator: ":")
guard parts.count >= 2,
let portNumber = UInt16(parts[1]),
let port = NWEndpoint.Port(rawValue: portNumber)
let portNumber = UInt16(parts[1]),
let port = NWEndpoint.Port(rawValue: portNumber)
else {
return nil
}
Expand Down Expand Up @@ -62,13 +62,15 @@ actor MaaToolClient {
let data = Data([0x4d, 0x41, 0x41, 0x00, 0x00, 0x04, 0x54, 0x45, 0x52, 0x4d])

return try await withCheckedThrowingContinuation { continuation in
connection.send(content: data, completion: .contentProcessed { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume()
}
})
connection.send(
content: data,
completion: .contentProcessed { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume()
}
})
}
}
}
2 changes: 2 additions & 0 deletions MeoAsstMac/MAADev.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<true/>
<key>com.apple.security.device.usb</key>
<true/>
<key>com.apple.security.files.downloads.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
Expand Down
3 changes: 2 additions & 1 deletion MeoAsstMac/Main Menu/CheckForUpdatesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct CheckForUpdatesView: View {
}

struct CheckForUpdatesView_Previews: PreviewProvider {
private static let updateController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
private static let updateController = SPUStandardUpdaterController(
startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)

static var previews: some View {
CheckForUpdatesView(updater: updateController.updater)
Expand Down
2 changes: 2 additions & 0 deletions MeoAsstMac/MeoAsstMac.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<true/>
<key>com.apple.security.device.usb</key>
<true/>
<key>com.apple.security.files.downloads.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
Expand Down
10 changes: 9 additions & 1 deletion MeoAsstMac/Model/MAACopilot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@

import Foundation

enum DifficultyFlags: Int, Codable {
case none = 0
case normal = 1
case raid = 2
case normal_raid = 3
}

struct MAACopilot: Codable, Equatable {
let stage_name: String
let opers: [Operator]
let groups: [Group]?
let minimum_required: String
let doc: Documentation?
var difficulty: DifficultyFlags? = nil

// MARK: SSS
// MARK: - SSS

let type: String?
let equipment: [String]?
Expand Down
10 changes: 5 additions & 5 deletions MeoAsstMac/Model/MAADepot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ struct MAADepot: Codable {
let done: Bool
let arkplanner: Arkplanner
let lolicon: Lolicon

struct Arkplanner: Codable {
let object: ArkplannerObject
let data: String
}

struct ArkplannerObject: Codable {
let items: [ArkplannerItem]
}

struct ArkplannerItem: Codable {
let id: String
let have: Int
let name: String
}

struct Lolicon: Codable {
let object: [String: Int]
let data: String
Expand All @@ -39,7 +39,7 @@ extension MAADepot: CustomStringConvertible {
.sorted { $0.id < $1.id }
.map { "\($0.name): \($0.have)" }
}

var description: String {
contents.joined(separator: "\n")
}
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Model/MAAOperBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension MAAOperBox.OwnedOper: Comparable {
{ $0.elite > $1.elite },
{ $0.level > $1.level },
{ $0.rarity > $1.rarity },
{ $0.id < $1.id }
{ $0.id < $1.id },
]
}

Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Model/MAATask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extension MAATaskType: Codable, CustomStringConvertible {
}
}

// MARK: Task Persistance
// MARK: - Task Persistance

struct DailyTask: Codable, Equatable, Identifiable {
let id: UUID
Expand Down
Loading