Skip to content

Commit 174d2e7

Browse files
committed
feat: Add DisplayParameter and related file management utilities; update dependencies for VRMKit
1 parent 070ae9b commit 174d2e7

File tree

9 files changed

+78
-48
lines changed

9 files changed

+78
-48
lines changed

app/xcode/Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/xcode/Package.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ let package = Package(
1717

1818
.library(name: "VCamStub", targets: ["VCamStub"]),
1919
],
20+
dependencies: [
21+
.package(url: "https://github.com/tattn/VRMKit", branch: "main"),
22+
],
2023
targets: [
2124
.target(name: "VCamUI", dependencies: [
2225
"VCamUIFoundation", "VCamTracking", "VCamCamera", "VCamData", "VCamLocalization", "VCamBridge", "VCamWorkaround",
@@ -48,10 +51,31 @@ let package = Package(
4851
swiftLanguageModes: [.v5]
4952
)
5053

54+
let isThree = true
55+
5156
for target in package.targets {
52-
target.swiftSettings = (target.swiftSettings ?? []) + [
57+
var swiftSettings = (target.swiftSettings ?? []) + [
5358
.enableUpcomingFeature("ExistentialAny", .when(configuration: .debug)),
5459
.define("ENABLE_MOCOPI"),
55-
.define("FEATURE_3"),
5660
]
61+
62+
if isThree {
63+
swiftSettings.append(contentsOf: [
64+
.define("FEATURE_3"),
65+
])
66+
} else {
67+
swiftSettings.append(contentsOf: [
68+
.define("ENABLE_ACCOUNT"),
69+
])
70+
}
71+
72+
target.swiftSettings = swiftSettings
73+
}
74+
75+
if isThree {
76+
if let vcamDataTarget = package.targets.first(where: { $0.name == "VCamData" }) {
77+
vcamDataTarget.dependencies.append(contentsOf: [
78+
.product(name: "VRMKit", package: "VRMKit"),
79+
])
80+
}
5781
}

app/xcode/Sources/VCamBridge/DisplayParameter.swift renamed to app/xcode/Sources/VCamData/DisplayParameter.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// DisplayParameter.swift
3-
//
4-
//
5-
// Created by Tatsuya Tanaka on 2022/03/22.
6-
//
7-
81
import Foundation
92
import SwiftUI
103
import AppKit
@@ -125,7 +118,7 @@ public final class DisplayParameterPresets {
125118
let file = DisplayParameterPresetsFile(parameters: parameters)
126119
let data = try JSONEncoder().encode(file)
127120
let directory = Self.fileURL.deletingLastPathComponent()
128-
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
121+
try FileManager.default.createDirectoryIfNeeded(at: directory)
129122
try data.write(to: Self.fileURL)
130123
} catch {
131124
print("Failed to save display parameters: \(error)")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
extension FileManager {
4+
public func createDirectoryIfNeeded(at url: URL) throws {
5+
if !fileExists(atPath: url.path) {
6+
try createDirectory(at: url, withIntermediateDirectories: true)
7+
}
8+
}
9+
}

app/xcode/Sources/VCamData/URL+Data.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
//
2-
// URL+Data.swift
3-
//
4-
//
5-
// Created by Tatsuya Tanaka on 2022/05/08.
6-
//
7-
81
import Foundation
92

103
public extension URL {
11-
static var applicationSupportDirectory: URL {
12-
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!.appendingPathComponent(Bundle.main.bundleIdentifier!)
4+
static var applicationSupportDirectoryWithBundleID: URL {
5+
URL.applicationSupportDirectory.appendingPathComponent(Bundle.main.bundleIdentifier!)
136
}
147

158
static var sceneMetadata: URL {
16-
applicationSupportDirectory.appendingPathComponent("scenes.json")
9+
applicationSupportDirectoryWithBundleID.appendingPathComponent("scenes.json")
1710
}
1811

1912
static var scenesDirectory: URL {
20-
applicationSupportDirectory.appendingPathComponent("scenes")
13+
applicationSupportDirectoryWithBundleID.appendingPathComponent("scenes")
2114
}
2215

2316
static func sceneRoot(sceneId id: Int32) -> URL {
@@ -29,11 +22,11 @@ public extension URL {
2922
}
3023

3124
static var shortcutMetadata: URL {
32-
applicationSupportDirectory.appendingPathComponent("shortcuts.json")
25+
applicationSupportDirectoryWithBundleID.appendingPathComponent("shortcuts.json")
3326
}
3427

3528
static var shortcutRootDirectory: URL {
36-
applicationSupportDirectory.appendingPathComponent("shortcuts")
29+
applicationSupportDirectoryWithBundleID.appendingPathComponent("shortcuts")
3730
}
3831

3932
static func shortcutDirectory(id: UUID) -> URL {

app/xcode/Sources/VCamData/VCamSceneDataStore.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// VCamSceneDataStore.swift
3-
//
4-
//
5-
// Created by Tatsuya Tanaka on 2023/03/29.
6-
//
7-
81
import Foundation
92
import VCamEntity
103
import VCamLocalization
@@ -32,7 +25,7 @@ public struct VCamSceneDataStore {
3225
}
3326

3427
public func save(_ scene: VCamScene) throws {
35-
try? FileManager.default.createDirectory(at: sceneRootURL, withIntermediateDirectories: true)
28+
try? FileManager.default.createDirectoryIfNeeded(at: sceneRootURL)
3629

3730
let url = sceneURL
3831
let encoder = JSONEncoder()
@@ -50,7 +43,7 @@ public struct VCamSceneDataStore {
5043
destination = dataURL(id: newUUID)
5144
uniDebugLog(destination.path)
5245

53-
try? FileManager.default.createDirectory(at: sceneRootURL, withIntermediateDirectories: true)
46+
try? FileManager.default.createDirectoryIfNeeded(at: sceneRootURL)
5447
do {
5548
try FileManager.default.copyItem(at: url, to: destination)
5649
} catch {

app/xcode/Sources/VCamData/VCamShortcutDataStore.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// VCamShortcutDataStore.swift
3-
//
4-
//
5-
// Created by Tatsuya Tanaka on 2023/03/29.
6-
//
7-
81
import Foundation
92
import VCamEntity
103

@@ -28,7 +21,7 @@ public struct VCamShortcutDataStore {
2821
let encoder = JSONEncoder()
2922
let data = try encoder.encode(shortcut)
3023

31-
try? FileManager.default.createDirectory(at: .shortcutDirectory(id: shortcut.id), withIntermediateDirectories: true)
24+
try? FileManager.default.createDirectoryIfNeeded(at: .shortcutDirectory(id: shortcut.id))
3225

3326
let url = URL.shortcutData(id: shortcut.id)
3427
try data.write(to: url)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public enum ModelType: String, Codable, Hashable, Sendable {
2+
#if FEATURE_3
3+
case vrm
4+
#else
5+
case live2d
6+
#endif
7+
8+
public var displayName: String {
9+
switch self {
10+
#if FEATURE_3
11+
case .vrm: return "VRM"
12+
#else
13+
case .live2d: return "Live2D"
14+
#endif
15+
}
16+
}
17+
}

app/xcode/Sources/VCamUI/Shortcut/VCamActionEditorCodeEditor.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// VCamActionEditorCodeEditor.swift
3-
//
4-
//
5-
// Created by Tatsuya Tanaka on 2023/04/16.
6-
//
7-
81
import SwiftUI
92
import VCamEntity
103

@@ -49,7 +42,7 @@ struct VCamActionEditorCodeEditor: View {
4942

5043
private func openScript() {
5144
if !FileManager.default.fileExists(atPath: url.path) {
52-
try? FileManager.default.createDirectory(at: .shortcutResourceActionDirectory(id: id, actionId: actionId), withIntermediateDirectories: true)
45+
try? FileManager.default.createDirectoryIfNeeded(at: .shortcutResourceActionDirectory(id: id, actionId: actionId))
5346
try? "".write(to: url, atomically: true, encoding: .utf8)
5447
}
5548
NSWorkspace.shared.open(url)

0 commit comments

Comments
 (0)