Advertisement
Astfgl

QTEAddonSPW

Nov 10th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // QTE Addon: Skill possibilities window
  3. // by Astfgl
  4. // Date: 09/11/2016  
  5. //
  6. //=============================================================================
  7.  
  8.  
  9. /*:
  10.  * @plugindesc Creates a window to display the skill possibilities and their
  11.  * sequence, to use with the QTEWindow plugin.
  12.  * @author Astfgl
  13.  *
  14.  * @param x
  15.  * @desc The default x coordinate of the window
  16.  * @default 0  
  17.  *
  18.  * @param y
  19.  * @desc the default y coordinate of the window
  20.  * @default 0
  21.  *
  22.  * @param width
  23.  * @desc The default width of the window in pixels
  24.  * @default 300
  25.  *
  26.  * @param height
  27.  * @desc The default height of the window in lines
  28.  * @default 5
  29.  *
  30.  * @param textWidth
  31.  * @desc The width of the text area in pixels
  32.  * @default 100
  33.  *
  34.  * @param iconWidth
  35.  * @desc The width of the icon area in pixels
  36.  * @default 200
  37.  *
  38.  * @param maxInputs
  39.  * @desc The default number of max Inputs
  40.  * @default 5
  41.  *
  42.  * @param minInputs
  43.  * @desc The default number of minimum inputs
  44.  * @default 1
  45.  *
  46.  */
  47.  
  48. function Window_SPW() {
  49.     this.initialize.apply(this, arguments);
  50. }
  51.  
  52. Window_SPW.prototype = Object.create(Window_Base.prototype);
  53. Window_SPW.prototype.constructor = Window_SPW;
  54.  
  55. Window_SPW.prototype.initialize = function() {
  56.     Window_Base.prototype.initialize.call(this,0,0,1000,1000);
  57.     var parameters = PluginManager.parameters('QTEAddonSPW');
  58.     this.x = eval(parameters.x);
  59.     this.y = eval(parameters.y);
  60.     this.width = eval(parameters.width);
  61.     this.height = eval(parameters.height) * this.lineHeight();
  62.     this._txtWidth = eval(parameters.textWidth);
  63.     this._iconWidth = eval(parameters.iconWidth);
  64.     this._maxInputs = eval(parameters.maxInputs);
  65.     this._minInputs = eval(parameters.minInputs);
  66.     this._actor = $gameActors.actor(1);
  67.     this._lineHeight = this.lineHeight();
  68.     this.update();
  69. }
  70.  
  71. Window_SPW.prototype.update = function() {
  72.     this.contents.clear();
  73.     if (this._actor !== 0) {
  74.         var list = this.createSkillList();
  75.         var i, ii, index, txt
  76.         for (i = 0; i < list.length; i++) {
  77.             txt = "";
  78.             txt+= list[i].name;
  79.             txt+= ":";
  80.             this.drawText(txt, 0, this._lineHeight * i, this._txtWidth, "left");
  81.             for (ii = 0; ii < eval(list[i].meta.qteSeq).length; ii++) {
  82.                 index = SceneManager._scene._QTEWindow.getIconIndex(eval(list[i].meta.qteSeq)[ii])
  83.                 this.drawIcon(index, this._txtWidth + 36 * ii, this._lineHeight * i)
  84.             }
  85.         }
  86.     }
  87. }
  88.  
  89. Window_SPW.prototype.clear = function() {
  90.     this.initialize();
  91. }
  92.  
  93. Window_SPW.prototype.createSkillList = function() {
  94.     var list = []
  95.     if (this._actor !== 0) {
  96.         var skills = this._actor.skills();
  97.         for (var i = 0; i < skills.length; i++) {
  98.             if (skills[i].meta.qteSeq) {
  99.                 if (eval(skills[i].meta.qteSeq).length <= this._maxInputs && eval(skills[i].meta.qteSeq).length >= this._minInputs) {
  100.                     list.push(skills[i]);
  101.                 }
  102.             }
  103.         }
  104.     }
  105.     return list
  106. }
  107.  
  108. Game_Map.prototype.createSPW = function(actorId, maxInputs, minInputs) {
  109.     var scene = SceneManager._scene
  110.     var win = new Window_SPW
  111.     scene._SPWindow = win
  112.     scene._SPWindow._actor = $gameActors.actor(actorId);
  113.     if (maxInputs) {scene._SPWindow._maxInputs = maxInputs};
  114.     if (minInputs) {scene._SPWindow._minInputs}
  115.     scene.addChild(scene._SPWindow);
  116.     scene._SPWindow.show();
  117. }
  118.  
  119. Game_Map.prototype.removeSPW = function() {
  120.     SceneManager._scene.removeChild(SceneManager._scene._SPWindow);
  121.     SceneManager._scene._SPWindow.clear()
  122. }
  123.  
  124. Game_Map.prototype.setSPWCoord = function(x,y) {
  125.     SceneManager._scene._SPWindow.x = x;
  126.     SceneManager._scene._SPWindow.y = y;
  127. }
  128.  
  129. Game_Map.prototype.setSPWSize = function(x,y) {
  130.     SceneManager._scene._SPWindow.width = x;
  131.     SceneManager._scene._SPWindow.height = (y+1) * SceneManager._scene._SPWindow._lineHeight;
  132. }
  133.  
  134. Game_Map.prototype.setSPWText = function(x,y) {
  135.     SceneManager._scene._SPWindow._txtWidth = x;
  136.     SceneManager._scene._SPWindow._iconWidth = y;
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement