diff --git a/src/frontend/swiftui/EmulationToolbarItems.swift b/src/frontend/swiftui/EmulationToolbarItems.swift index 37c0eac1..8887b161 100644 --- a/src/frontend/swiftui/EmulationToolbarItems.swift +++ b/src/frontend/swiftui/EmulationToolbarItems.swift @@ -4,6 +4,7 @@ struct EmulationToolbarItems: ToolbarContent { @EnvironmentObject var globalState: GlobalState @State private var isRunning: Bool = false + @State private var isFramerateUnlocked = false var body: some ToolbarContent { #if os(macOS) @@ -30,22 +31,74 @@ struct EmulationToolbarItems: ToolbarContent { } ToolbarItemGroup(placement: .confirmationAction) { - Button("Console Mode", systemImage: "inset.filled.tv") { - globalState.isHandheldMode.toggle() + if isFramerateUnlocked { + Button{ + isFramerateUnlocked.toggle() + } label: { + ZStack { + Image(systemName: "square.stack.3d.down.forward") + Image(systemName: "lock") + .symbolVariant(.none) + .font(.footnote) + .offset(x: 10, y: 5) + } + } + .help("Lock Framerate to 60fps") + } else { + Button{ + isFramerateUnlocked.toggle() + } label: { + ZStack { + Image(systemName: "square.stack.3d.down.forward") + Image(systemName: "lock.open") + .symbolVariant(.none) + .font(.footnote) + .offset(x: 10, y: 5) + } + } + .help("Unlock Framerate") + } + } + + // This compiler check is only needed when compiling on a macOS version earlier than 26 + #if compiler(>=6.2.3) + if #available(macOS 26.0, *) { + ToolbarSpacer(.fixed) } - .disabled(!globalState.isHandheldMode) - .help("Change to Console mode") - - Button("Handheld Mode", systemImage: "formfitting.gamecontroller.fill") { - globalState.isHandheldMode.toggle() + #endif + + if #available(macOS 26.0, *) { + ToolbarItemGroup(placement: .confirmationAction) { + Button("Console Mode", systemImage: "inset.filled.tv") { + globalState.isHandheldMode.toggle() + } + .disabled(!globalState.isHandheldMode) + .help("Change to Console mode") + + Button("Handheld Mode", systemImage: "formfitting.gamecontroller.fill") { + globalState.isHandheldMode.toggle() + } + .disabled(globalState.isHandheldMode) + .help("Change to Handheld mode") + } + } else { + ToolbarItemGroup(placement: .confirmationAction) { + if globalState.isHandheldMode { + Button("Console Mode", systemImage: "inset.filled.tv") { + globalState.isHandheldMode.toggle() + } + .help("Change to Console mode") + } else { + Button("Handheld Mode", systemImage: "formfitting.gamecontroller.fill") { + globalState.isHandheldMode.toggle() + } + .help("Change to Handheld mode") + } } - .disabled(globalState.isHandheldMode) - .help("Change to Handheld mode") } #else // TODO: options ToolbarItemGroup(placement: .principal) {} #endif } - }