Adding universe based functions

This commit is contained in:
2023-10-05 21:45:25 +02:00
parent 0f9c33d2df
commit 90cdff7846
2 changed files with 29 additions and 1 deletions

View File

@ -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
// =============================================================

View File

@ -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:
- <ic>copy_script(from: number, to: number)</ic>: copy the content of a script to another.
- <ic>delete_script(index: number)</ic>: 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(
@ -61,6 +66,11 @@ Switching between universes will not stop the transport nor reset the clock. You
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:
- <ic>copy_universe(from: string, to: string)</ic>: copy the content of a universe to another. This is useful to create a backup of your work.
- <ic>delete_universe(name: string)</ic>: delete a universe. Warning: this is irreversible!
# Sharing your work
**Click on the Topos logo in the top bar**. Your URL will change to something much longer and complex. The same URL will be copied to your clipboard. Send this link to your friends to share the universe you are currently working on with them.