Explorar o código

Allow printing the name of classes

Reddo %!s(int64=5) %!d(string=hai) anos
pai
achega
c6387fe5a5
Modificáronse 1 ficheiros con 13 adicións e 8 borrados
  1. 13 8
      app/Elements/Classes/Say.ts

+ 13 - 8
app/Elements/Classes/Say.ts

@@ -230,16 +230,21 @@ class Say {
             } else if (seq == Say.RUN_PARAGRAPH_OFF) {
                 this.skipbreaks = false;
             } else if (typeof seq == "function") {
-                let fObj = (<(s: Say) => any> seq)(this);
-                if (Array.isArray(fObj)) {
-                    for (let k = fObj.length - 1; k >= 0; k--) {
-                        this.sequence.splice(this.sequenceRunner + 1, 0, fObj[k]);
+                // not a function, but a class
+                if (seq.prototype != undefined) {
+                    this.currentParagraph.push(document.createTextNode(seq.name));
+                } else {
+                    let fObj = (<(s: Say) => any>seq)(this);
+                    if (Array.isArray(fObj)) {
+                        for (let k = fObj.length - 1; k >= 0; k--) {
+                            this.sequence.splice(this.sequenceRunner + 1, 0, fObj[k]);
+                        }
+                    } else if (fObj != undefined) {
+                        this.sequence.splice(this.sequenceRunner + 1, 0, fObj);
                     }
-                } else if (fObj != undefined) {
-                    this.sequence.splice(this.sequenceRunner + 1, 0, fObj);
+                    this.sequence.splice(this.sequenceRunner, 1);
+                    this.sequenceRunner--;
                 }
-                this.sequence.splice(this.sequenceRunner, 1);
-                this.sequenceRunner--;
             } else if (seq.constructor == this.constructor) {
                 for (let k = (<Say> seq).sequence.length - 1; k >= 0; k--) {
                     this.sequence.splice(this.sequenceRunner + 1, 0, (<Say> seq).sequence[k]);