// Cotton Story's calls into the core (apps/story/CORE.md and // assets/design/story/CONTRACT.md): the rules of a screenplay live in Rust, // once (`story.*`); the phone names the methods here and in `StoryBook`, and // decides nothing itself. import CottonFaces import CottonKit import CottonValues import Foundation /// The `story.*` methods, by name. enum StoryMethod { static let sceneWrite = "story.scene.write" static let sceneNear = "story.scene.near" static let start = "story.start" static let sceneMove = "story.scene.move" static let sceneNew = "story.scene.new" static let sceneDuplicate = "story.scene.duplicate" static let recordsUpdate = "records.update" static let recordsDelete = "records.delete" } /// The tables Story keeps, by id. enum StoryTable { static let story = "story_story" static let scene = "story_scene" static let place = "story_place" } /// The whole story laid out by screenplay rules (`story.script`): the paper, /// the title page, every page's lines already wrapped and indented, and /// where each scene begins. The reader and the PDF draw it as it is. struct StoryScript: Decodable, Equatable { struct Paper: Decodable, Equatable { struct Margins: Decodable, Equatable { let top, bottom, left, right: Double } let name: String let width: Double let height: Double let margins: Margins enum CodingKeys: String, CodingKey { case name case width = "width_pt" case height = "height_pt" case margins = "margins_pt" } } struct TitlePage: Decodable, Equatable { let title: String let credit: String? let author: String? let lines: [String]? } struct Line: Decodable, Equatable { struct Scene: Decodable, Equatable { let id: String; let number: Int } /// An element's kind, `blank`, or `more` for `(MORE)`. let kind: String let text: String /// Characters from the left margin. let indent: Int let scene: Scene? } struct Page: Decodable, Equatable { let number: Int let lines: [Line] } struct SceneStart: Decodable, Equatable { let id: String let number: Int let page: Int } let paper: Paper let titlePage: TitlePage? let pages: [Page] let scenes: [SceneStart] enum CodingKeys: String, CodingKey { case paper, pages, scenes case titlePage = "title_page" } }