Navest

PlaytimeWindow

Apr 10th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Playtime.js
  3. //
  4. // (c)2015 Mirai
  5. //=============================================================================
  6. /*:
  7.  * @plugindesc Add Playtime Window in Menu.
  8.  * @author Mirai
  9. */
  10.  
  11. (function () {
  12.  
  13.  
  14. Scene_Menu.prototype.update = function(){
  15.     this._playtimeWindow.refresh();
  16. };
  17.  
  18. var _SceneMenu_create = Scene_Menu.prototype.create
  19. Scene_Menu.prototype.create = function() {
  20.     _SceneMenu_create.call(this);
  21.     this.createPlaytimeWindow();
  22. };
  23.  
  24. Scene_Menu.prototype.createPlaytimeWindow = function() {
  25.     this._playtimeWindow = new Window_Playtime(0, 0);
  26.     this._playtimeWindow.y = Graphics.boxHeight - this._playtimeWindow.height - this._goldWindow.height;
  27.     this.addWindow(this._playtimeWindow);
  28. };
  29.  
  30. //-----------------------------------------------------------------------------
  31. // Window_Playtime
  32. //
  33.  
  34. function Window_Playtime() {
  35.     this.initialize.apply(this, arguments);
  36. }
  37.  
  38. Window_Playtime.prototype = Object.create(Window_Base.prototype);
  39. Window_Playtime.prototype.constructor = Window_Playtime;
  40.  
  41. Window_Playtime.prototype.initialize = function(x, y) {
  42.     var width = this.windowWidth();
  43.     var height = this.windowHeight();
  44.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  45.     this.refresh();
  46. };
  47.  
  48. Window_Playtime.prototype.windowWidth = function() {
  49.     return 240;
  50. };
  51.  
  52. Window_Playtime.prototype.windowHeight = function() {
  53.     return this.fittingHeight(1);
  54. };
  55.  
  56. Window_Playtime.prototype.refresh = function() {
  57.     var x = this.textPadding();
  58.     var width = this.contents.width - this.textPadding() * 2;
  59.     this.contents.clear();
  60.     this.drawText($gameSystem.playtimeText(), x, 0, width, 'right');
  61. };
  62.  
  63. Window_Playtime.prototype.open = function() {
  64.     this.refresh();
  65.     Window_Base.prototype.open.call(this);
  66. };
  67. })();
Advertisement
Add Comment
Please, Sign In to add comment