// SPDX-License-Identifier: GPL-3.0-or-later import SwiftUI #if !VCC_COMPANION_CLIENT struct SoftwareLibraryLaunchPreviewView: View { let preview: LibraryLaunchPreview let confirm: () -> Void let cancel: () -> Void private var plan: SoftwareLibraryLaunchPlan { preview.plan } private var setupName: String { switch plan.profile { case .diskBasic: return "Disk BASIC" case .romCartridge: return plan.cartridgeDevice == .orchestra90 ? "Orchestra-90" : "ROM Cartridge" case .cocoSDC: return "CoCo SDC" } } var body: some View { VStack(alignment: .leading, spacing: 18) { Label(plan.automaticallyStarts ? "Start Software" : "Set Up Software", systemImage: "play.rectangle") .font(.title2.weight(.semibold)) Text(plan.title).font(.title3.weight(.medium)) ScrollView { VStack(alignment: .leading, spacing: 14) { LabeledContent("Machine", value: "Color Computer 3") LabeledContent("Processor", value: plan.use6309 ? "Hitachi 6309" : "Motorola 6809") LabeledContent("Memory", value: plan.ramKiB >= 1024 ? "\(plan.ramKiB / 1024) MB" : "\(plan.ramKiB) KB") LabeledContent("Setup", value: setupName) LabeledContent("Video", value: DisplayOutput(rawValue: preview.prepared.profile.videoOutput)?.label ?? "Current signal") if let previous = preview.prepared.previousSetup { ForEach([1, 0], id: \.self) { port in if previous.input[port].source != preview.prepared.profile.input[port].source { Text((port == 0 ? "Right" : "Left") + " joystick input will change for this title’s controls.") .font(.callout).foregroundStyle(.secondary) } } } Divider() if let cart = plan.cartridgeURL { LabeledContent(plan.cartridgeDevice == .orchestra90 ? "Orchestra-90" : "ROM cartridge", value: cart.lastPathComponent) } if let tape = plan.cassetteURL { Label(tape.lastPathComponent, systemImage: "recordingtape") } ForEach(plan.floppyURLs.keys.sorted(), id: \.self) { drive in LabeledContent("FD\(drive)", value: plan.floppyURLs[drive]!.lastPathComponent) } if let folder = plan.sdcFolderURL { Label("SD card folder: " + folder.lastPathComponent, systemImage: "sdcard") } if !plan.compatibilityNotes.isEmpty { Text(plan.compatibilityNotes.joined(separator: "\n\n")).font(.callout).foregroundStyle(.secondary) } if !plan.automaticallyStarts { Label("Manual loading", systemImage: "keyboard").font(.headline) Text(plan.manualInstructions).font(.callout).textSelection(.enabled) } else if !plan.commands.isEmpty { DisclosureGroup("Loading commands") { Text(plan.commands.joined(separator: "\n")).font(.system(.callout, design: .monospaced)).textSelection(.enabled) } } }.frame(maxWidth: .infinity, alignment: .leading) }.frame(maxHeight: 330) Text("Starting this setup restarts the CoCo and clears its current program. Unsaved media must be saved first.") .font(.callout).fixedSize(horizontal: false, vertical: true) if preview.prepared.previousSetup == nil { Text("The current setup could not be captured for return. Your installed files will remain available.").font(.caption).foregroundStyle(.secondary) } HStack { Button("Cancel", role: .cancel, action: cancel).keyboardShortcut(.cancelAction).accessibilityIdentifier("library-cancel-play") Spacer() Button(plan.automaticallyStarts ? "Start" : "Set Up", action: confirm) .buttonStyle(.borderedProminent).keyboardShortcut(.defaultAction).accessibilityIdentifier("library-confirm-play") } }.padding(24).frame(width: 490) } } #endif struct SoftwareLibraryMediaChoiceView: View { let choice: LibraryMediaChoice let choose: (String) -> Void let cancel: () -> Void @State private var selection: String? var body: some View { VStack(alignment: .leading, spacing: 16) { Label("Choose Starting Media", systemImage: "externaldrive").font(.title2.weight(.semibold)) Text("This collection has more than one possible starting file. Choose the one described by its loading instructions.") .font(.callout) List(selection: $selection) { ForEach(choice.candidates, id: \.path) { candidate in Text(candidate.path).tag(candidate.path) } }.frame(height: 240).accessibilityIdentifier("library-starting-media") Text(choice.release.setup.instructions).font(.callout).foregroundStyle(.secondary).lineLimit(6) HStack { Button("Cancel", role: .cancel, action: cancel).keyboardShortcut(.cancelAction) Spacer() Button("Continue") { if let selection { choose(selection) } } .disabled(selection == nil).keyboardShortcut(.defaultAction) } }.padding(24).frame(width: 520) } }