From 55677a34451220f618eb927b76534f6f1a9926e7 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Sun, 17 Jan 2021 14:50:40 -0800 Subject: [PATCH] [twisty] Rename `experimental-start-setup` to `setup-alg`. --- src/cubing/twisty/dom/TwistyPlayer.ts | 27 +++++++++------------ src/cubing/twisty/dom/TwistyPlayerConfig.ts | 10 +++----- src/demo/twisty/2d-ll-stickering.html | 12 ++++----- src/demo/twisty/2d-stickering.ts | 2 +- src/demo/twisty/attributes.html | 10 ++++---- src/demo/twisty/attributes.ts | 12 ++++----- src/demo/twisty/cube3d-stickering.ts | 2 +- src/demo/twisty/simultaneous.ts | 2 +- src/demo/twisty/twisty-player.ts | 2 +- 9 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/cubing/twisty/dom/TwistyPlayer.ts b/src/cubing/twisty/dom/TwistyPlayer.ts index 9e13233e1..38c1a3465 100644 --- a/src/cubing/twisty/dom/TwistyPlayer.ts +++ b/src/cubing/twisty/dom/TwistyPlayer.ts @@ -119,7 +119,7 @@ export class TwistyPlayer extends ManagedCustomElement { set alg(seq: Sequence) { // TODO: do validation for other algs as well. if (seq?.type !== "sequence") { - // TODO: document `.setAttribute("experimental-start-setup", "R U R'")` as a workaround. + // TODO: document `.setAttribute("setup-alg", "R U R'")` as a workaround. console.warn( "`alg` for a `TwistyPlayer` was set using a string. It should be set using a `Sequence`!", ); @@ -133,23 +133,23 @@ export class TwistyPlayer extends ManagedCustomElement { return this.#config.attributes["alg"].value; } - set experimentalStartSetup(seq: Sequence) { + set setupAlg(seq: Sequence) { // TODO: do validation for other algs as well. if (seq?.type !== "sequence") { - // TODO: document `.setAttribute("experimental-start-setup", "R U R'")` as a workaround. + // TODO: document `.setAttribute("setup-alg", "R U R'")` as a workaround. console.warn( - "`experimentalStartSetup` for a `TwistyPlayer` was set using a string. It should be set using a `Sequence`!", + "`setupAlg` for a `TwistyPlayer` was set using a string. It should be set using a `Sequence`!", ); seq = parseAlg((seq as unknown) as string) as Sequence; } - this.#config.attributes["experimental-start-setup"].setValue(seq); + this.#config.attributes["setup-alg"].setValue(seq); if (this.cursor) { this.cursor.setStartState(this.cursor.algToState(seq)); // TODO } } - get experimentalStartSetup(): Sequence { - return this.#config.attributes["experimental-start-setup"].value; + get setupAlg(): Sequence { + return this.#config.attributes["setup-alg"].value; } set puzzle(puzzle: PuzzleID) { @@ -428,7 +428,7 @@ export class TwistyPlayer extends ManagedCustomElement { } private setCursor(cursor: AlgCursor): void { - cursor.setStartState(cursor.algToState(this.experimentalStartSetup)); + cursor.setStartState(cursor.algToState(this.setupAlg)); this.timeline.addCursor(cursor); if (this.cursor) { this.timeline.removeCursor(this.cursor); @@ -472,12 +472,7 @@ export class TwistyPlayer extends ManagedCustomElement { let cursor: AlgCursor; try { - cursor = new AlgCursor( - this.timeline, - def, - this.alg, - this.experimentalStartSetup, - ); // TODO: validate more directly if the alg is okay for the puzzle. + cursor = new AlgCursor(this.timeline, def, this.alg, this.setupAlg); // TODO: validate more directly if the alg is okay for the puzzle. } catch (e) { if (initial) { this.experimentalInvalidInitialAlgCallback(this.alg); @@ -486,11 +481,11 @@ export class TwistyPlayer extends ManagedCustomElement { this.timeline, def, new Sequence([]), - this.experimentalStartSetup, + this.setupAlg, ); } this.setCursor(cursor); - if (initial && this.experimentalStartSetup.nestedUnits.length === 0) { + if (initial && this.setupAlg.nestedUnits.length === 0) { this.timeline.jumpToEnd(); } switch (this.visualization) { diff --git a/src/cubing/twisty/dom/TwistyPlayerConfig.ts b/src/cubing/twisty/dom/TwistyPlayerConfig.ts index 92a6b2634..8dbfe316f 100644 --- a/src/cubing/twisty/dom/TwistyPlayerConfig.ts +++ b/src/cubing/twisty/dom/TwistyPlayerConfig.ts @@ -112,7 +112,7 @@ type AnyManagedAttribute = ManagedAttribute; interface TwistyPlayerAttributes extends Record { // Alg "alg": AlgAttribute; - "experimental-start-setup": AlgAttribute; + "setup-alg": AlgAttribute; // Puzzle "puzzle": StringEnumAttribute; @@ -131,7 +131,7 @@ interface TwistyPlayerAttributes extends Record { export interface TwistyPlayerConfigValues { alg: Sequence; - experimentalStartSetup: Sequence; + setupAlg: Sequence; puzzle: PuzzleID; visualization: VisualizationFormat; @@ -152,7 +152,7 @@ const twistyPlayerAttributeMap: Record< keyof TwistyPlayerConfigValues > = { "alg": "alg", - "experimental-start-setup": "experimentalStartSetup", + "setup-alg": "setupAlg", "puzzle": "puzzle", "visualization": "visualization", @@ -175,9 +175,7 @@ export class TwistyPlayerConfig { ) { this.attributes = { "alg": new AlgAttribute(initialValues.alg), - "experimental-start-setup": new AlgAttribute( - initialValues.experimentalStartSetup, - ), + "setup-alg": new AlgAttribute(initialValues.setupAlg), "puzzle": new StringEnumAttribute(puzzleIDs, initialValues.puzzle), "visualization": new StringEnumAttribute( diff --git a/src/demo/twisty/2d-ll-stickering.html b/src/demo/twisty/2d-ll-stickering.html index 994b7fb6e..9f6aeea6b 100644 --- a/src/demo/twisty/2d-ll-stickering.html +++ b/src/demo/twisty/2d-ll-stickering.html @@ -15,7 +15,7 @@

OLL

@@ -25,7 +25,7 @@

PLL

@@ -35,7 +35,7 @@

COLL

@@ -45,7 +45,7 @@

OCLL

@@ -55,7 +55,7 @@

ELL

@@ -65,7 +65,7 @@

CLS

diff --git a/src/demo/twisty/2d-stickering.ts b/src/demo/twisty/2d-stickering.ts index 7e2cfc250..9767b90f5 100644 --- a/src/demo/twisty/2d-stickering.ts +++ b/src/demo/twisty/2d-stickering.ts @@ -16,7 +16,7 @@ function demo(visualization: VisualizationFormat): void { const div = content.appendChild(document.createElement("div")); div.classList.add("case"); const twistyPlayer = new TwistyPlayer({ - experimentalStartSetup: invert(parseAlg(s)), + setupAlg: invert(parseAlg(s)), alg: parseAlg(s), visualization, experimentalStickering: stickering, diff --git a/src/demo/twisty/attributes.html b/src/demo/twisty/attributes.html index 610c7b4f9..65682b69e 100644 --- a/src/demo/twisty/attributes.html +++ b/src/demo/twisty/attributes.html @@ -55,15 +55,15 @@

alg="R U R' U R U2' R'"

- experimental-start-setup="(R U R' U R U2' R')'" + setup-alg="(R U R' U R U2' R')'"

-
+
DOM attributes: Constructor config object: Dynamic property setter:
@@ -170,7 +170,7 @@

camera-position="[-3, 4, 5]"

alg="R U R' U R U2' R'"
- experimental-start-setup="(R U R' U R U2' R')'"
+ setup-alg="(R U R' U R U2' R')'"
experimental-stickering="OLL"
background="none"
control-panel="none"
Dynamic property setter: