Path: blob/a-new-beginning/Folium-iOS/Enumerations/Core.swift
2 views
//
// Core.swift
// Folium-iOS
//
// Created by Jarrod Norwell on 10/7/2025.
//
import Foundation
import UIKit
enum Core : String, CaseIterable, Codable, Comparable, Hashable, @unchecked Sendable {
static func < (lhs: Core, rhs: Core) -> Bool {
lhs.string.localizedCaseInsensitiveCompare(rhs.string) == .orderedAscending
}
case cherry = "Cherry",
cytrus = "Cytrus",
grape = "Grape",
guava = "Guava",
kiwi = "Kiwi",
mandarine = "Mandarine",
mango = "Mango",
plum = "Plum",
tomato = "Tomato"
case generic = "Generic"
var string: String { rawValue }
var information: Information {
let plate = if #available(iOS 17, *) { "licenseplate" } else { "123.rectangle" }
return switch self {
case .cherry:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Nacho Sanchez Gines", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/drhelius/gearcoleco"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/cherry"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .cytrus:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Azahar/Citra Team", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/azahar-emu/azahar"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/cytrus"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .grape:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Arisotura", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/melonds-emu/melonds"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/grape"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .guava:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Angelo", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "Unavailable", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/angelo-wf/vlotnes"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/guava"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .kiwi:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Sinamas", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "Unavailable", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: "Unavailable", subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in }
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/kiwi"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .mandarine:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jakub Czekański", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv2", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/jaczekanski/avocado"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv2", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/mandarine"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .mango:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Angelo", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/angelo-wf/lakesnes"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/mango"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .plum:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Clownacy", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "0BSD", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/clownacy/clowncd"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "0BSD", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/plum"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .tomato:
Information(menu: UIMenu(children: [
UIMenu(title: .localized(for: .core), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Mireille", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/nba-emu/nanoboyadvance"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
]),
UIMenu(title: .localized(for: .extensions), image: UIImage(systemName: "puzzlepiece.extension"),
children: extensions.map { `extension` in
UIAction(title: `extension`.string.uppercased()) { _ in }
}),
UIMenu(title: .localized(for: .features), image: UIImage(systemName: "checklist"), children: features.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .unsupportedFeatures), image: UIImage(systemName: "checklist"), children: unsupportedFeatures.map { feature in
UIAction(title: feature.string, image: feature.image) { _ in }
}),
UIMenu(title: .localized(for: .port), image: UIImage(systemName: "ellipsis.curlybraces"), children: [
UIAction(title: "Jarrod Norwell", subtitle: .localized(for: .developer), image: UIImage(systemName: "person")) { _ in },
UIAction(title: "GPLv3", subtitle: .localized(for: .license), image: UIImage(systemName: plate)) { _ in },
UIAction(title: .localized(for: .tapToBrowse), subtitle: .localized(for: .repository),
image: UIImage(systemName: "network")) { _ in
guard let url = URL(string: "https://github.com/folium-app/tomato"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
}
])
]))
case .generic:
Information(menu: UIMenu(children: [
]))
}
}
var console: String {
switch self {
case .cherry:
"ColecoVision"
case .cytrus:
"Nintendo 3DS, New 3DS"
case .grape:
"Nintendo DS, DSi"
case .guava:
"Nintendo Entertainment System"
case .kiwi:
"Game Boy, Game Boy Color"
case .mandarine:
"PlayStation 1"
case .mango:
"Super Nintendo Entertainment System"
case .plum:
"SEGA Genesis, Mega Drive"
case .tomato:
"Game Boy Advance"
case .generic:
"Generic"
}
}
var consoleShort: String {
switch self {
case .cherry:
"ColecoVision"
case .cytrus:
"3DS, New 3DS"
case .grape:
"DS,DSi"
case .guava:
"NES"
case .kiwi:
"GB, GBC"
case .mandarine:
"PS1"
case .mango:
"SNES"
case .plum:
"GENESIS, MD"
case .tomato:
"GBA"
case .generic:
""
}
}
var features: [Feature] {
switch self {
case .cherry:
[]
case .cytrus:
[
.camera,
.keyboard,
.microphone,
.multiplayer,
.saveStates
]
case .grape:
[
.camera,
.gameControllers,
.microphone,
.saveStates
]
case .guava:
[
.gameControllers,
.saveStates,
.twoPlayers
]
case .kiwi:
[
.gameControllers,
.saveStates,
.twoPlayers
]
case .mandarine:
[
.gameControllers,
.twoPlayers
]
case .mango:
[
.gameControllers,
.twoPlayers
]
case .tomato:
[
.gameControllers,
.saveStates,
.twoPlayers
]
case .plum:
[
.gameControllers,
.twoPlayers
]
case .generic: []
}
}
var unsupportedFeatures: [Feature] {
switch self {
case .cherry:
[
.audio,
.gameControllers
]
case .cytrus:
[]
case .grape:
[]
case .guava:
[]
case .kiwi:
[]
case .mandarine:
[]
case .mango:
[]
case .tomato:
[]
case .plum:
[]
case .generic: []
}
}
var isBeta: Bool {
switch self {
case .cherry, .mango, .plum: true
default: false
}
}
var localized: LocalizedStringResource {
switch self {
case .cherry: .cherry
case .cytrus: .cytrus
case .grape: .grape
case .guava: .guava
case .kiwi: .kiwi
case .mandarine: .mandarine
case .mango: .mango
case .plum: .plum
case .tomato: .tomato
case .generic: .generic
}
}
var nintendo: Bool {
[
.cytrus,
.grape,
.guava,
.kiwi,
.mango,
.tomato
].contains(self)
}
static let cores: [Core] = Core.allCases.dropLast()
static let coresAsStrings: [String] = cores.map { $0.string }
var extensions: [SupportedFormat] {
switch self {
case .cherry:
[.col]
case .cytrus:
[.`3ds`, .app, .cci, .cia, .cxi]
case .grape:
[.nds, .srl]
case .guava:
[.nes]
case .kiwi:
[.gb, .gbc]
case .mandarine:
[.chd, .cue, .exe, .img, .iso]
case .mango:
[.sfc, .smc]
case .plum:
[.bin, .gen, .md, .smd]
case .tomato:
[.gba]
case .generic:
[]
}
}
static func cores(for format: SupportedFormat) -> [Core] {
switch format {
case .col:
[.cherry]
case .`3ds`,
.app,
.cci,
.cia,
.cxi:
[.cytrus]
case .nds,
.srl:
[.grape]
case .nes:
[.guava]
case .gb,
.gbc:
[.kiwi]
case .chd,
.exe,
.img,
.iso:
[.mandarine]
case .cue:
[.mandarine, .plum]
case .sfc,
.smc:
[.mango]
case .bin:
[.plum]
case .gen,
.md,
.smd:
[.plum]
case .gba:
[.tomato]
}
}
}