Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/src/js/jgame.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 83 by tsugehara, Tue Apr 16 10:57:53 2013 UTC revision 84 by tsugehara, Sun Apr 21 13:36:33 2013 UTC
# Line 5643  var EffectScene = (function (_super) { Line 5643  var EffectScene = (function (_super) {
5643      };      };
5644      return EffectScene;      return EffectScene;
5645  })(Scene);  })(Scene);
5646  var MessageWindow = (function (_super) {  var UIWindow = (function (_super) {
5647      __extends(MessageWindow, _super);      __extends(UIWindow, _super);
5648      function MessageWindow(size, noDefault) {      function UIWindow(width, height, bgImage, padding) {
5649          _super.call(this);          _super.call(this);
5650          this.width = size.width;          this.width = width;
5651          this.height = size.height;          this.height = height;
5652          this.textClip = new Shape(this.width, this.height);          this.padding = padding ? padding : new Rectangle(8, 8, 8, 8);
5653          this.textClip.setClip(true);          this.entities = [];
5654          this.padding = new Rectangle(8, 8, 8, 8);          if(bgImage) {
5655          this.entities = [              var bg;
5656              null,              if(bgImage instanceof E) {
5657              null,                  bg = bgImage;
5658              this.textClip,              } else {
5659              null                  bg = new Sprite(bgImage.width, bgImage.height, bgImage);
5660          ];              }
5661          if(!noDefault) {              this.setBg(this.createBgImage(bg));
5662            } else {
5663              this.defaultSkin();              this.defaultSkin();
5664          }          }
5665        }
5666        UIWindow.prototype.getBg = function () {
5667            return this.entities[0];
5668        };
5669        UIWindow.prototype.setBg = function (bg) {
5670            if(this.bg) {
5671                this.bg.remove();
5672            }
5673            this.bg = bg;
5674            this.insert(bg, 0);
5675        };
5676        UIWindow.prototype.createBgImage = function (e, srcPadding, buf) {
5677            if(!buf) {
5678                var buf = new BufferedRenderer(e);
5679            }
5680            buf.renderUnit(e);
5681            if(buf.filter) {
5682                buf.applyFilter(buf.c, buf.size);
5683            }
5684            var bg = new E();
5685            bg.width = this.width;
5686            bg.height = this.height;
5687            bg.entities = [];
5688            var s4_1 = buf.createSprite({
5689                x: 0,
5690                y: 0,
5691                width: this.padding.left,
5692                height: this.padding.top
5693            });
5694            s4_1.moveTo(0, 0);
5695            bg.append(s4_1);
5696            var s4_2 = buf.createSprite({
5697                x: e.width - this.padding.right,
5698                y: 0,
5699                width: this.padding.right,
5700                height: this.padding.top
5701            });
5702            s4_2.moveTo(this.width - this.padding.right, 0);
5703            bg.append(s4_2);
5704            var s4_3 = buf.createSprite({
5705                x: e.width - this.padding.right,
5706                y: e.height - this.padding.bottom,
5707                width: this.padding.right,
5708                height: this.padding.bottom
5709            });
5710            s4_3.moveTo(this.width - this.padding.right, this.height - this.padding.bottom);
5711            bg.append(s4_3);
5712            var s4_4 = buf.createSprite({
5713                x: 0,
5714                y: e.height - this.padding.bottom,
5715                width: this.padding.left,
5716                height: this.padding.bottom
5717            });
5718            s4_4.moveTo(0, this.height - this.padding.bottom);
5719            bg.append(s4_4);
5720            var h4_1 = buf.createSprite({
5721                x: this.padding.left,
5722                y: 0,
5723                width: e.width - this.padding.right - this.padding.left,
5724                height: this.padding.top
5725            });
5726            h4_1.moveTo(this.padding.left, 0);
5727            h4_1.width = this.width - this.padding.right - this.padding.left;
5728            bg.append(h4_1);
5729            var h4_2 = buf.createSprite({
5730                x: e.width - this.padding.right,
5731                y: this.padding.top,
5732                width: this.padding.right,
5733                height: e.height - this.padding.top - this.padding.bottom
5734            });
5735            h4_2.moveTo(this.width - this.padding.right, this.padding.top);
5736            h4_2.height = this.height - this.padding.top - this.padding.bottom;
5737            bg.append(h4_2);
5738            var h4_3 = buf.createSprite({
5739                x: this.padding.left,
5740                y: e.height - this.padding.bottom,
5741                width: e.width - this.padding.right - this.padding.left,
5742                height: this.padding.bottom
5743            });
5744            h4_3.moveTo(this.padding.left, this.height - this.padding.bottom);
5745            h4_3.width = this.width - this.padding.right - this.padding.left;
5746            bg.append(h4_3);
5747            var h4_4 = buf.createSprite({
5748                x: 0,
5749                y: this.padding.top,
5750                width: this.padding.left,
5751                height: e.height - this.padding.top - this.padding.bottom
5752            });
5753            h4_4.moveTo(0, this.padding.top);
5754            h4_4.height = this.height - this.padding.top - this.padding.bottom;
5755            bg.append(h4_4);
5756            var center = buf.createSprite({
5757                x: this.padding.left,
5758                y: this.padding.top,
5759                width: e.width - this.padding.left - this.padding.right,
5760                height: e.height - this.padding.top - this.padding.bottom
5761            });
5762            center.moveTo(this.padding.left, this.padding.top);
5763            center.width = this.width - this.padding.left - this.padding.right;
5764            center.height = this.height - this.padding.top - this.padding.bottom;
5765            bg.append(center);
5766            return bg.createSprite();
5767        };
5768        UIWindow.prototype.defaultSkin = function () {
5769            if(this.bg) {
5770                this.bg.remove();
5771            }
5772            var bgColor = JGUtil.createLinearGradient(new Rectangle(0, 0, this.width, this.height), [
5773                "rgba(138,193,255,0.5)",
5774                "rgba(222, 235, 250, 0.5)"
5775            ]);
5776            var dummy = new E();
5777            dummy.width = this.width;
5778            dummy.height = this.height;
5779            dummy.entities = [];
5780            var bg = new Shape(this.width, this.height, ShapeStyle.Fill, bgColor);
5781            dummy.append(bg);
5782            var textBg = new Shape(this.width - (this.padding.left + this.padding.right) + 4, this.height - (this.padding.top + this.padding.bottom) + 4, ShapeStyle.Fill, "rgba(45,73,136,0.2)");
5783            textBg.moveTo(this.padding.left - 2, this.padding.top - 2);
5784            dummy.append(textBg);
5785            this.setBg(dummy.createSprite());
5786        };
5787        return UIWindow;
5788    })(E);
5789    var MessageWindow = (function (_super) {
5790        __extends(MessageWindow, _super);
5791        function MessageWindow(width, height, bgImage, padding) {
5792            _super.call(this, width, height, bgImage, padding);
5793          this.normalSpeed = 400;          this.normalSpeed = 400;
5794          this.fastSpeed = 800;          this.fastSpeed = 800;
5795          this.readed = new Trigger();          this.readed = new Trigger();
5796          this.isReaded = true;          this.isReaded = true;
5797          this.hasNextCursor = false;          this.hasNextCursor = false;
5798            var textArea = new MultilineText({
5799                width: this.width - this.padding.left - this.padding.right,
5800                height: this.height - this.padding.top - this.padding.bottom
5801            }, {
5802                x: this.padding.left,
5803                y: this.padding.top
5804            });
5805            this.setTextArea(textArea);
5806            var cursor = new Line({
5807                x: 0,
5808                y: 0
5809            }, {
5810                x: 6,
5811                y: 8
5812            });
5813            cursor.addLine(12, 0);
5814            cursor.closePath = true;
5815            cursor.fill = true;
5816            cursor.setFillColor("rgba(255, 255, 255, 0.8)");
5817            cursor.width = 12;
5818            cursor.height = 8;
5819            this.nextCursor = cursor;
5820      }      }
     MessageWindow.prototype._activate = function (e) {  
         e.scene = this.scene;  
         e.parent = this;  
         e.activate();  
     };  
     MessageWindow.prototype.getBg = function () {  
         return this.entities[0];  
     };  
     MessageWindow.prototype.setBg = function (bg) {  
         if(this.entities[0]) {  
             this.entities[0].destroy();  
         }  
         this.entities[0] = bg;  
         this._activate(bg);  
     };  
     MessageWindow.prototype.getTextBg = function () {  
         return this.entities[1];  
     };  
     MessageWindow.prototype.setTextBg = function (textWindow) {  
         if(this.entities[1]) {  
             this.entities[1].destroy();  
         }  
         this.entities[1] = textWindow;  
         this._activate(textWindow);  
     };  
     MessageWindow.prototype.getTextArea = function () {  
         return this.entities[3];  
     };  
5821      MessageWindow.prototype.setTextArea = function (textArea) {      MessageWindow.prototype.setTextArea = function (textArea) {
5822          if(this.entities[3]) {          if(this.textArea) {
5823              this.entities[3].destroy();              this.textArea.remove();
5824                this.textClip.remove();
5825          }          }
5826          this.entities[3] = textArea;          textArea.animated.handle(this, this.onAnimated);
5827            this.textArea = textArea;
5828            this.textClip = new Shape(this.width, this.height);
5829            this.textClip.setClip(true);
5830          this.textClip.moveTo(textArea.x, textArea.y);          this.textClip.moveTo(textArea.x, textArea.y);
5831          this.textClip.width = textArea.width;          this.append(this.textClip);
5832          this.textClip.height = textArea.height;          this.append(textArea);
         this._activate(textArea);  
5833      };      };
5834      MessageWindow.prototype.getNextCursor = function () {      MessageWindow.prototype.getNextCursor = function () {
5835          return this.nextCursor;          return this.nextCursor;
# Line 5712  var MessageWindow = (function (_super) { Line 5838  var MessageWindow = (function (_super) {
5838          this.nextCursor = cursor;          this.nextCursor = cursor;
5839      };      };
5840      MessageWindow.prototype.setText = function (text, offset) {      MessageWindow.prototype.setText = function (text, offset) {
5841          var textArea = this.getTextArea();          var textArea = this.textArea;
5842          this.scriptOffset = textArea.setText(text, offset);          this.scriptOffset = textArea.setText(text, offset);
5843          this.script = textArea.script;          this.script = textArea.script;
5844          textArea.hideAll();          textArea.hideAll();
# Line 5721  var MessageWindow = (function (_super) { Line 5847  var MessageWindow = (function (_super) {
5847          return this.scriptOffset;          return this.scriptOffset;
5848      };      };
5849      MessageWindow.prototype.setScript = function (script, offset) {      MessageWindow.prototype.setScript = function (script, offset) {
5850          var textArea = this.getTextArea();          var textArea = this.textArea;
5851          this.script = script;          this.script = script;
5852          this.scriptOffset = textArea.setScript(script, offset);          this.scriptOffset = textArea.setScript(script, offset);
5853          textArea.hideAll();          textArea.hideAll();
# Line 5729  var MessageWindow = (function (_super) { Line 5855  var MessageWindow = (function (_super) {
5855          this.isReaded = false;          this.isReaded = false;
5856          return this.scriptOffset;          return this.scriptOffset;
5857      };      };
     MessageWindow.prototype.defaultSkin = function () {  
         if(this.entities) {  
             var childEntity;  
             while(childEntity = this.entities.pop()) {  
                 childEntity.destroy();  
             }  
         }  
         var bgColor = JGUtil.createLinearGradient(new Rectangle(0, 0, this.width, this.height), [  
             "rgba(138,193,255,0.5)",  
             "rgba(222, 235, 250, 0.5)"  
         ]);  
         var bg = new Shape(this.width, this.height, ShapeStyle.Fill, bgColor);  
         this.setBg(bg);  
         var textBg = new Shape(this.width - (this.padding.left + this.padding.right), this.height - (this.padding.top + this.padding.bottom), ShapeStyle.Fill, "rgba(45,73,136,0.2)");  
         textBg.moveTo(this.padding.left, this.padding.top);  
         this.setTextBg(textBg);  
         var textArea = new MultilineText({  
             width: textBg.width - 8,  
             height: textBg.height - 4  
         }, {  
             x: textBg.x + 4,  
             y: textBg.y + 2  
         });  
         textArea.animated.handle(this, this.onAnimated);  
         this.setTextArea(textArea);  
         var cursor = new Line({  
             x: 0,  
             y: 0  
         }, {  
             x: 6,  
             y: 8  
         });  
         cursor.addLine(12, 0);  
         cursor.closePath = true;  
         cursor.fill = true;  
         cursor.setFillColor("rgba(255, 255, 255, 0.8)");  
         cursor.width = 12;  
         cursor.height = 8;  
         this.nextCursor = cursor;  
     };  
5858      MessageWindow.prototype.showNextCursor = function () {      MessageWindow.prototype.showNextCursor = function () {
5859          if(this.hasNextCursor) {          if(this.hasNextCursor) {
5860              return;              return;
5861          }          }
5862          var nextCursor = this.nextCursor.createSprite();          var nextCursor = this.nextCursor.createSprite();
5863          var textArea = this.getTextArea();          var textArea = this.textArea;
5864          var lastLine = textArea.lines[textArea.lines.length - 1];          var lastLine = textArea.lines[textArea.lines.length - 1];
5865          nextCursor.moveTo(this.width / 2 - nextCursor.width / 2, this.height - nextCursor.height - this.padding.bottom - 4);          nextCursor.moveTo(this.width / 2 - nextCursor.width / 2, this.height - nextCursor.height - this.padding.bottom - 4);
5866          nextCursor.tl().moveBy(0, 4, 500).moveBy(0, -4, 500).delay(500).loop();          nextCursor.tl().moveBy(0, 4, 500).moveBy(0, -4, 500).delay(500).loop();
5867          this.append(nextCursor);          this.append(nextCursor);
5868          this.hasNextCursor = true;          this.hasNextCursor = true;
5869            this._nextCursor = nextCursor;
5870      };      };
5871      MessageWindow.prototype.deleteNextCursor = function () {      MessageWindow.prototype.deleteNextCursor = function () {
5872          if(this.hasNextCursor) {          if(this.hasNextCursor) {
5873              this.entities[4].remove();              this._nextCursor.remove();
5874                delete this._nextCursor;
5875              this.hasNextCursor = false;              this.hasNextCursor = false;
5876          }          }
5877      };      };
# Line 5802  var MessageWindow = (function (_super) { Line 5890  var MessageWindow = (function (_super) {
5890          }          }
5891      };      };
5892      MessageWindow.prototype.showText = function () {      MessageWindow.prototype.showText = function () {
5893          var textArea = this.getTextArea();          this.textArea.startAnimation();
         textArea.startAnimation();  
5894      };      };
5895      MessageWindow.prototype.fastMode = function () {      MessageWindow.prototype.fastMode = function () {
5896          var textArea = this.getTextArea();          this.textArea.animeSpeed = this.fastSpeed;
         textArea.animeSpeed = this.fastSpeed;  
5897      };      };
5898      MessageWindow.prototype.normalMode = function () {      MessageWindow.prototype.normalMode = function () {
5899          var textArea = this.getTextArea();          this.textArea.animeSpeed = this.normalSpeed;
         textArea.animeSpeed = this.normalSpeed;  
5900      };      };
5901      MessageWindow.prototype.showAll = function () {      MessageWindow.prototype.showAll = function () {
5902          var textArea = this.getTextArea();          this.textArea.showAll();
         textArea.showAll();  
5903      };      };
5904      MessageWindow.prototype.next = function () {      MessageWindow.prototype.next = function () {
5905          if(this.scriptOffset < 0) {          if(this.scriptOffset < 0) {
5906              return false;              return false;
5907          }          }
5908            this.oldWipeOut();
5909            this.setScript(this.script, this.scriptOffset);
5910            this.textArea.startAnimation();
5911      };      };
5912      MessageWindow.prototype.oldWipeOut = function (time) {      MessageWindow.prototype.oldWipeOut = function (time) {
5913          if(time === undefined) {          if(time === undefined) {
5914              time = 800;              time = 800;
5915          }          }
5916          var textArea = this.getTextArea();          var textArea = this.textArea;
5917          var old = textArea.createSprite();          var old = textArea.createSprite();
5918          old.moveTo(textArea.x, textArea.y);          old.moveTo(textArea.x, textArea.y);
5919          this.append(old);          this.append(old);
# Line 5840  var MessageWindow = (function (_super) { Line 5927  var MessageWindow = (function (_super) {
5927          if(time === undefined) {          if(time === undefined) {
5928              time = 500;              time = 500;
5929          }          }
5930          var textArea = this.getTextArea();          var textArea = this.textArea;
5931          var old = textArea.createSprite();          var old = textArea.createSprite();
5932          old.moveTo(textArea.x, textArea.y);          old.moveTo(textArea.x, textArea.y);
5933          this.append(old);          this.append(old);
# Line 5855  var MessageWindow = (function (_super) { Line 5942  var MessageWindow = (function (_super) {
5942          this.readed.fire(hasNext);          this.readed.fire(hasNext);
5943      };      };
5944      return MessageWindow;      return MessageWindow;
5945  })(E);  })(UIWindow);
5946  var Pixel = (function (_super) {  var Pixel = (function (_super) {
5947      __extends(Pixel, _super);      __extends(Pixel, _super);
5948      function Pixel(width, height, srcImage, scale) {      function Pixel(width, height, srcImage, scale) {

Legend:
Removed from v.83  
changed lines
  Added in v.84

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26