Advertisement
rito_kun

Rito_GameEnd_Custom

Nov 22nd, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Rito_GameEnd_Custom.js
  3. //=============================================================================
  4. var Imported = Imported || {};
  5. Imported.Rito_GameEnd = true;
  6. var Rito = Rito || {};
  7.  
  8. /*:
  9.  * @plugindesc Version 1.02
  10.  * Adds custom background and pictures to your Game End menu.
  11.  * @author Rito
  12.  *
  13.  * @help Please credit me. Usage for commercial/free game.
  14.  *
  15.  * @param Background Filename
  16.  * @desc Change the file name of the background.
  17.  * Image : img\system\GameEnd.png
  18.  * @default GameEnd
  19.  *
  20.  * @param Yes X-Pos
  21.  * @desc X "Yes" position.
  22.  * Image : img\system\GameEnd_command_0.png
  23.  * @default 200
  24.  *
  25.  * @param Yes Y-Pos
  26.  * @desc Y "Yes" position.
  27.  * Image : img\system\GameEnd_command_0.png
  28.  * @default -150
  29.  *
  30.  * @param No X-Pos
  31.  * @desc X "No" position.
  32.  * Image : img\system\GameEnd_command_1.png
  33.  * @default -200
  34.  *
  35.  * @param No Y-Pos
  36.  * @desc Y "No" position.
  37.  * Image : img\system\GameEnd_command_1.png
  38.  * @default -150
  39.  *
  40.  * @param Alignement controls
  41.  * @desc Set alignement control in "Vertical" or "Horizontal" (with directionnal touch) - Default : "Horizontal"
  42.  * @default Horizontal
  43.  */
  44. var parameters = PluginManager.parameters('Rito_GameEnd_Custom');
  45.  
  46. Rito.Param = Rito.Param || {};
  47.  
  48. Rito.Param.GameEnd_pic_com_1_x = Number(parameters['Yes X-Pos'] || 200);
  49. Rito.Param.GameEnd_pic_com_1_y = Number(parameters['Yes Y-Pos'] || -150);
  50. Rito.Param.GameEnd_pic_com_2_x = Number(parameters['No X-Pos'] || -200);
  51. Rito.Param.GameEnd_pic_com_2_y = Number(parameters['No Y-Pos'] || -150);
  52. Rito.Param.Alignement_controls = String(parameters['Alignement controls'] || "Horizontal")
  53.  
  54.  
  55. var bg_gameEnd = parameters['Background Filename'];
  56.  
  57. var _alias_Window_GameEnd_updatePlacement = Window_GameEnd.prototype.updatePlacement;
  58. Window_GameEnd.prototype.updatePlacement = function() {
  59.    this.x = -Graphics.boxWidth;
  60.    this.y = -Graphics.boxheight;
  61.    this.visible = false;
  62. };
  63.  
  64. var _alias_Scene_GameEnd_create = Scene_GameEnd.prototype.create;
  65. Scene_GameEnd.prototype.create = function() {
  66.     this.createBackground();
  67.     _alias_Scene_GameEnd_create.call(this);
  68.     this.create_picture_commands();
  69. };
  70.  
  71. if (Rito.Param.Alignement_controls == "Horizontal") {
  72.     var _alias_Window_GameEnd_maxCols = Window_GameEnd.prototype.maxCols;
  73.     Window_GameEnd.prototype.maxCols = function() {
  74.         return 2;
  75.     };
  76. }
  77.  
  78. var _alias_Scene_GameEnd_CreateBackground = Scene_GameEnd.prototype.createBackground;
  79. Scene_GameEnd.prototype.createBackground = function() {
  80.     Scene_MenuBase.prototype.createBackground.call(this);
  81.     this._backgroundSprite = new Sprite();
  82.     this._backgroundSprite.bitmap = ImageManager.loadSystem(bg_gameEnd);
  83.     this.addChild(this._backgroundSprite); 
  84.    
  85.     if (Imported.Soul_Menu_Particles){ this.create_particles(); }
  86.    
  87.  
  88. };
  89.  
  90. Scene_GameEnd.prototype.create_picture_commands = function() { 
  91.     var _com_index_old = -2;
  92.     this._csel = false;
  93.     this._com_pictures = [];
  94.     this._com_sprites = [];
  95.     this._com_pictures_data = [];
  96.     for (i = 0; i < this._commandWindow._list.length; i++){
  97.         this._com_pictures.push(ImageManager.loadSystem("GameEnd_command_" + i));
  98.         this._com_sprites.push(new Sprite(this._com_pictures[i]));     
  99.         this.addChild(this._com_sprites[i]);   
  100.     };
  101. }
  102.  
  103. var _alias_Scene_GameEnd_update = Scene_GameEnd.prototype.update;
  104. Scene_GameEnd.prototype.update = function() {
  105.     _alias_Scene_GameEnd_update.call(this);
  106.     this.update_picture_commands();
  107. };
  108.  
  109. Scene_GameEnd.prototype.refresh_picture_command = function() {
  110.     this._com_index_old = this._commandWindow._index;
  111.     for (i = 0; i < this._com_sprites.length; i++){
  112.         if (this._commandWindow._index != i) {
  113.         var ch = this._com_pictures[i].height / 2;
  114.         }
  115.         else {
  116.         var ch = 0;
  117.         }
  118.         if (i == 0) {this.cpsx = [Rito.Param.GameEnd_pic_com_1_x ,Rito.Param.GameEnd_pic_com_1_y];}
  119.         else if (i == 1) {this.cpsx = [Rito.Param.GameEnd_pic_com_2_x ,Rito.Param.GameEnd_pic_com_2_y];}
  120.         this._com_sprites[i].setFrame(0, ch, this._com_pictures[i].width, this._com_pictures[i].height / 2);
  121.         this._com_sprites[i].x = ((Graphics.boxWidth / 2) - (this._com_pictures[i].width / 2)) + this.cpsx[0];
  122.         this._com_sprites[i].y = ((Graphics.boxHeight / 2) + (this._com_pictures[i].height / 2)) + this.cpsx[1];
  123.         this._com_pictures_data[i] = [this._com_sprites[i].x,this._com_pictures[i].width ,this._com_sprites[i].y,this._com_pictures[i].height / 2 ];
  124.     };
  125. }
  126.  
  127. Scene_GameEnd.prototype.update_picture_commands = function() {
  128.     if (this._com_index_old != this._commandWindow._index) { this.refresh_picture_command()};
  129.     if (TouchInput.isTriggered(true)) {
  130.         for (i = 0; i < this._com_sprites.length; i++){
  131.             if (this.on_picture_com(i) && !this._csel ) {              
  132.                 this._commandWindow._index = i;  this._commandWindow.processOk();
  133.                 if (this._commandWindow.isCommandEnabled(i)) {this._csel = true};
  134.            }           
  135.         }
  136.     }
  137. }
  138.  
  139. Scene_GameEnd.prototype.on_picture_com = function(index) {
  140.      if (TouchInput.x < this._com_pictures_data[index][0]) { return false};
  141.      if (TouchInput.x > this._com_pictures_data[index][0] + this._com_pictures_data[index][1]) { return false};
  142.      if (TouchInput.y < this._com_pictures_data[index][2]) { return false};
  143.      if (TouchInput.y > this._com_pictures_data[index][2] + this._com_pictures_data[index][3]) { return false};
  144.      return true;    
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement