-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
7 changed files
with
179 additions
and
28 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
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
26 changes: 26 additions & 0 deletions
26
app/xcode/Sources/VCamUI/Extensions/ExternalStateBinding+UI.swift
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,26 @@ | ||
// | ||
// ExternalStateBinding+UI.swift | ||
// | ||
// | ||
// Created by Tatsuya Tanaka on 2023/10/20. | ||
// | ||
|
||
import Foundation | ||
import VCamEntity | ||
import VCamBridge | ||
|
||
extension ExternalState { | ||
public static var typedScreenResolution: ExternalState<ScreenResolution> { | ||
.init(id: .externalState(\.4, type: UniBridge.ArrayType.screenResolution), get: { | ||
let size = UniBridge.shared.screenResolution.wrappedValue | ||
guard size.count == 2 else { return .init(width: 1920, height: 1280) } // an empty array after disposal | ||
return ScreenResolution(width: Int(size[0]), height: Int(size[1])) | ||
}, set: { | ||
let isLandscape = MainTexture.shared.isLandscape | ||
UniBridge.shared.screenResolution.wrappedValue = [Int32($0.size.width), Int32($0.size.height)] | ||
if isLandscape != MainTexture.shared.isLandscape { | ||
SceneManager.shared.changeAspectRatio() | ||
} | ||
}) | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
app/xcode/Sources/VCamUI/Settings/VCamSettingGeneralView.swift
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,63 @@ | ||
// | ||
// VCamSettingGeneralView.swift | ||
// | ||
// | ||
// Created by Tatsuya Tanaka on 2023/02/14. | ||
// | ||
|
||
import SwiftUI | ||
import VCamLocalization | ||
import VCamBridge | ||
|
||
public struct VCamSettingGeneralView: View { | ||
public init() {} | ||
|
||
@AppStorage(key: .useHMirror) var useHMirror | ||
@AppStorage(key: .useAutoConvertVRM1) var useAutoConvertVRM1 | ||
@AppStorage(key: .locale) var locale | ||
|
||
@ExternalStateBinding(.useAutoMode) private var useAutoMode: Bool | ||
@ExternalStateBinding(.useCombineMesh) private var useCombineMesh: Bool | ||
@ExternalStateBinding(.useAddToMacOSMenuBar) private var useAddToMacOSMenuBar: Bool | ||
|
||
public var body: some View { | ||
GroupBox { | ||
Form { | ||
Toggle(isOn: $useAutoMode) { | ||
Text(L10n.playIdleMotions.key, bundle: .localize) | ||
} | ||
Toggle(isOn: $useCombineMesh) { | ||
Text(L10n.optimizeMeshes.key, bundle: .localize) | ||
} | ||
.help(L10n.helpMesh.text) | ||
Toggle(isOn: $useAutoConvertVRM1) { | ||
Text(L10n.enableAutoConvertingToVRM1.key, bundle: .localize) | ||
} | ||
Toggle(isOn: $useHMirror) { | ||
Text(L10n.flipScreen.key, bundle: .localize) | ||
} | ||
Toggle(isOn: $useAddToMacOSMenuBar) { | ||
Text(L10n.addToMacOSMenuBar.key, bundle: .localize) | ||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.onChange(of: useAddToMacOSMenuBar) { newValue in | ||
WindowManager.shared.isMacOSMenubarVisible = newValue | ||
} | ||
|
||
GroupBox { | ||
Form { | ||
Picker("Language / 言語", selection: $locale.map(get: LanguageList.init(locale:), set: \.rawValue)) { | ||
ForEach(LanguageList.allCases) { lang in | ||
Text(lang.name).tag(lang.rawValue) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
VCamSettingGeneralView() | ||
} |
71 changes: 71 additions & 0 deletions
71
app/xcode/Sources/VCamUI/Settings/VCamSettingRenderingView.swift
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,71 @@ | ||
// | ||
// VCamSettingRenderingView.swift | ||
// | ||
// | ||
// Created by Tatsuya Tanaka on 2023/02/14. | ||
// | ||
|
||
import SwiftUI | ||
import VCamEntity | ||
import VCamBridge | ||
import VCamLocalization | ||
|
||
public struct VCamSettingRenderingView: View { | ||
public init() {} | ||
|
||
@ExternalStateBinding(.typedScreenResolution) private var typedScreenResolution | ||
@ExternalStateBinding(.qualityLevel) private var qualityLevel | ||
@ExternalStateBinding(.fps) private var fps | ||
@ExternalStateBinding(.useVSync) private var useVSync | ||
|
||
public var body: some View { | ||
VStack { | ||
GroupBox { | ||
Form { | ||
Picker(selection: $typedScreenResolution) { | ||
ForEach(ScreenResolution.allCases) { | ||
Text($0.description) | ||
.tag($0) | ||
} | ||
} label: { | ||
Text(L10n.screenResolution.key, bundle: .localize) | ||
} | ||
Picker(selection: $qualityLevel) { | ||
ForEach(QualityLevel.allCases) { | ||
Text($0.localizedName, bundle: .localize) | ||
.tag($0.rawValue) | ||
} | ||
} label: { | ||
Text(L10n.renderingQuality.key, bundle: .localize) | ||
} | ||
|
||
ValueEditField(L10n.fpsScreen.key, value: $fps, type: .slider(10...60)) | ||
.disabled(useVSync) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension ScreenResolution { | ||
var description: String { | ||
"\(size.width) x \(size.height) \(shortDescription) \(videoType)" | ||
} | ||
|
||
private var videoType: String { | ||
isLandscape ? L10n.asHorizontalVideo.text : L10n.asVerticalVideo.text | ||
} | ||
|
||
private var shortDescription: String { | ||
switch self { | ||
case .resolution2160p: return "[4K]" | ||
case .resolution1080p, .resolutionVertical1080p: return "[1080p]" | ||
case .resolution720p: return "[720p]" | ||
case .resolution540p: return "[540p]" | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
VCamSettingRenderingView() | ||
} |
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