Guest User

Window_Alert

a guest
Aug 8th, 2016
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Window_Alert() {
  2.     this.initialize.apply(this, arguments);
  3. }
  4.  
  5. Window_Alert.prototype = Object.create(Window_Base.prototype);
  6. Window_Alert.prototype.constructor = Window_Alert;
  7.  
  8. Window_Alert.prototype.initialize = function(x, y) {
  9.     var width = Math.floor(Graphics.boxWidth * 0.263);
  10.     var height = Math.floor(Graphics.boxHeight / 3.69);
  11.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  12.     this.refresh();
  13. };
  14.  
  15. Window_Alert.prototype.windowWidth = function() {
  16.     return Math.floor(Graphics.boxWidth * 0.263);
  17. };
  18.  
  19. Window_Alert.prototype.windowHeight = function() {
  20.     return Math.floor(Graphics.boxHeight / 3.69);;
  21. };
  22.  
  23. Window_Alert.prototype.refresh = function() {
  24.         this.contents.clear();
  25.        
  26.         if(!this._windowAlertSprite) {
  27.             this._windowAlertSprite = new Sprite_Base();
  28.             this._windowAlertSprite.bitmap = ImageManager.loadPicture("kevinicon");
  29.         }
  30.        
  31.         this._windowAlertSprite.x = (0.5 * this.windowWidth()) - (0.5 * this._windowAlertSprite.width);
  32.         this.addChild(this._windowAlertSprite);
  33.        
  34.         var width = this.contents.width - this.standardPadding() * 2;
  35.         var height = this.contents.height - this.standardPadding() * 2;
  36.         this.contents.drawText("ALERTS", 0, 0, width, height, "center");
  37. };
  38.  
  39. Scene_Menu.prototype.createAlertWindow = function() {
  40.     this._alertWindow = new Window_Alert(0, 0);
  41.     this._alertWindow.y = Graphics.boxHeight - this._alertWindow.height;
  42.     this.addWindow(this._alertWindow);
  43. };
  44.  
  45. //not sure where you're trying to create the window so I've put it in here...
  46. var sceneMenuCreate = Scene_Menu.prototype.create;
  47. Scene_Menu.prototype.create = function() {
  48.     sceneMenuCreate.call(this);
  49.     this.createAlertWindow();
  50. };
RAW Paste Data