Files
pokerfreak/mac/Sources/Cockpit/Orte.swift
T
mmintel f2650dc3be Cockpit and runner 5.11. late: no ESC stop, hidden tables stay open, gapless tiling, teacher core
- ESC no longer triggers the emergency stop (an ESC in another app stopped the run at 20:29);
  stopping only via ctrl-opt-cmd-S or the stop button
- a table whose program runs counts as open even when its window is not visible (other
  desktop, Cockpit without screen recording): no reopening, no giving up, correct table
  count; teardown and closing a full table work over the channel
- Cockpit checks and requests the screen recording permission
- gapless tiling (sicht/kacheln.py): tables fill the full height, the Cockpit bar takes the
  rest and never goes below its minimum width; own animated resize no longer stored as minimum
- earlier today: top-up safety net, leave after the hand (sit out next hand), tournament lock,
  waitlist left on close, Cockpit start lock, warning throttle, preflop raise-war reading,
  Bomb Pot practice, tournament break and level-up on the stage
- teacher core for the streamer mode (betrieb/lehrer.py, betrieb/grund_lesen.py) and its plan
2026-11-05 22:39:41 +01:00

63 lines
3.4 KiB
Swift

import CockpitKern
import Foundation
/// Wo die Huelle liegt und welche Dateien der Vertrag mit dem Laeufer sind
/// (der Treffpunkt: betrieb/scratch, docs/SCHNITTSTELLE.md).
enum Orte {
/// Die Reihenfolge entscheidet `Quellbaum.waehlen` (CockpitKern): QUELLBAUM, der beim Bauen
/// eingetragene Pfad (Info.plist), sonst der Baum, aus dem diese Datei kompiliert wurde.
static let shell: URL = {
let gebaut = URL(filePath: #filePath).deletingLastPathComponent() // Sources/Cockpit
.deletingLastPathComponent().deletingLastPathComponent() // mac
.deletingLastPathComponent() // der Quellbaum
let pfad = Quellbaum.waehlen(umgebung: ProcessInfo.processInfo.environment,
eingetragen: Bundle.main.object(forInfoDictionaryKey: "Quellbaum") as? String,
gebaut: gebaut.path(percentEncoded: false))
return URL(filePath: pfad, directoryHint: .isDirectory)
}()
// Der Treffpunkt: betrieb/scratch, und ohne betrieb/ das eigene scratch/ (dieselbe Regel wie in
// client/umgebung.py - der Baum ohne betrieb-Ordner heisst dort anders).
static var scratch: URL {
let mit = shell.appending(path: "betrieb/scratch", directoryHint: .isDirectory)
return FileManager.default.fileExists(atPath: shell.appending(path: "betrieb").path) ? mit
: shell.appending(path: "scratch", directoryHint: .isDirectory)
}
static let startSkript = shell.appending(path: "sicht/start.py")
/// Rahmen des Panels fuer hand/act.py (Klickschutz) und sicht/tische.py (Anordnen).
static let cockpitRahmen = scratch.appending(path: "cockpit.json")
/// sicht/tische.py: so breit soll die Leiste werden - der Rest neben den lueckenlosen Kacheln.
static let cockpitZiel = scratch.appending(path: "cockpit_ziel.json")
/// hand/act.py legt sie an, bevor ein Laeufer-Klick unter dem Panel landet.
static let ausweichen = scratch.appending(path: "ausweichen")
/// Du hast Maus oder Tastatur benutzt (nicht der Laeufer): der Läufer lässt dir den Vortritt.
static let eingriff = scratch.appending(path: "eingriff")
/// Alter einer Datei in Sekunden, nil wenn es sie nicht gibt.
static func alter(_ url: URL, jetzt: Date = Date()) -> Double? {
guard let a = try? FileManager.default.attributesOfItem(atPath: url.path(percentEncoded: false)),
let m = a[.modificationDate] as? Date else { return nil }
return jetzt.timeIntervalSince(m)
}
}
/// Was schiefging, fuer die Fehlersuche: stderr (sichtbar bei `swift run Cockpit`) und das Systemprotokoll.
/// Was geschah, fuer die Fehlersuche: stderr (sichtbar bei `swift run Cockpit`) und
/// betrieb/scratch/cockpit.log (auch fuer die installierte App).
enum Protokoll {
static let datei = Orte.scratch.appending(path: "cockpit.log")
static func schreiben(_ text: String) {
let zeile = "\(Date().formatted(.iso8601)) \(text)\n"
FileHandle.standardError.write(Data(("Cockpit: " + text + "\n").utf8))
if let h = try? FileHandle(forWritingTo: datei) {
_ = try? h.seekToEnd()
h.write(Data(zeile.utf8))
try? h.close()
} else {
try? FileManager.default.createDirectory(at: Orte.scratch, withIntermediateDirectories: true)
try? Data(zeile.utf8).write(to: datei)
}
}
}