Guest User

Window_Alert

a guest
Aug 8th, 2016
67
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._windowAlertBmp) {
  27.             this._windowAlertBmp = ImageManager.loadPicture("kevinicon");
  28.         }
  29.        
  30.         this.contents.blt(  this._windowAlertBmp, 0, 0,
  31.                             this._windowAlertBmp.width,
  32.                             this._windowAlertBmp.height,
  33.                             (
  34.                                 Math.floor(this.windowWidth() / 2) -
  35.                                 Math.floor(this._windowAlertBmp.width / 2)
  36.                             ),
  37.                             0,
  38.                             this._windowAlertBmp.width,
  39.                             this._windowAlertBmp.height);
  40.        
  41.         var width = this.windowWidth() - this.standardPadding() * 2;
  42.         var height = this.windowHeight() - this.standardPadding() * 2;
  43.         this.contents.drawText("ALERTS", 0, 0, width, height, "center");
  44. };
  45.  
  46. Scene_Menu.prototype.createAlertWindow = function() {
  47.     this._alertWindow = new Window_Alert(0, 0);
  48.     this._alertWindow.y = Graphics.boxHeight - this._alertWindow.height;
  49.     this.addWindow(this._alertWindow);
  50. };
  51.  
  52. //not sure where you're trying to create the window so I've put it in here...
  53. var sceneMenuCreate = Scene_Menu.prototype.create;
  54. Scene_Menu.prototype.create = function() {
  55.     sceneMenuCreate.call(this);
  56.     this.createAlertWindow();
  57. };
  58.  
  59. //forgot about this one
  60. Scene_Menu.prototype.update = function() {
  61.     Scene_Base.prototype.update.call(this);
  62.     this._alertWindow.refresh();
  63. };
RAW Paste Data