From 90cdff7846bea7b5a2c9dae70723724bee960309 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Thu, 5 Oct 2023 21:45:25 +0200 Subject: [PATCH] Adding universe based functions --- src/API.ts | 20 +++++++++++++++++++- src/documentation/interface.ts | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/API.ts b/src/API.ts index 85bb809..87da292 100644 --- a/src/API.ts +++ b/src/API.ts @@ -265,7 +265,7 @@ export class UserAPI { }; s = this.script; - clear_script = (script: number): void => { + delete_script = (script: number): void => { /** * Clears a local script * @@ -292,6 +292,24 @@ export class UserAPI { }; cps = this.copy_script; + copy_universe = (from: string, to: string): void => { + this.app.universes[to] = { + ...this.app.universes[from], + }; + }; + + delete_universe = (universe: string): void => { + if (this.app.selected_universe === universe) { + this.app.selected_universe = "Default"; + } + delete this.app.universes[universe]; + this.app.settings.saveApplicationToLocalStorage( + this.app.universes, + this.app.settings + ); + this.app.updateKnownUniversesView(); + }; + // ============================================================= // MIDI related functions // ============================================================= diff --git a/src/documentation/interface.ts b/src/documentation/interface.ts index 7ab56b8..1574a02 100644 --- a/src/documentation/interface.ts +++ b/src/documentation/interface.ts @@ -51,6 +51,11 @@ flip(4) :: beat([.5, .25].beat(16)) :: script([5,6,7,8].loop($(2))) )} +There are some useful functions to help you manage your scripts: + +- copy_script(from: number, to: number): copy the content of a script to another. +- delete_script(index: number): clear the content of a script. Warning: this is irreversible! + ## Universes A set of files is called a _universe_. Topos can store several universes and switch immediately from one to another. You can switch between universes by pressing ${key_shortcut( @@ -60,6 +65,11 @@ A set of files is called a _universe_. Topos can store several universes and swi Switching between universes will not stop the transport nor reset the clock. You are switching the context but time keeps flowing. This can be useful to prepare immediate transitions between songs and parts. Think of universes as an algorithmic set of music. All scripts in a given universe are aware about how many times they have been runned already. You can reset that value programatically. You can clear the current universe by pressing the flame button on the top right corner of the interface. This will clear all the scripts and the note file. **Note:** there is no shortcut for clearing a universe. We do not want to loose your work by mistake! + +There are some useful functions to help you manage your universes: + +- copy_universe(from: string, to: string): copy the content of a universe to another. This is useful to create a backup of your work. +- delete_universe(name: string): delete a universe. Warning: this is irreversible! # Sharing your work