Advertisement
Double_X

DoubleX RMMV Reverse Input v100c

Dec 30th, 2015 (edited)
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Reverse Input                                            
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      You shall keep this plugin's Plugin Info part's contents intact      
  9.  *      You shalln't claim that this plugin's written by anyone other than    
  10.  *      DoubleX or his aliases                                                
  11.  *      None of the above applies to DoubleX or his aliases                  
  12.  *----------------------------------------------------------------------------
  13.  *    # Prerequisites                                                        
  14.  *      Abilities:                                                            
  15.  *      1. Some Javascript coding proficiency to fully utilize this plugin    
  16.  *----------------------------------------------------------------------------
  17.  *    # Links                                                                
  18.  *      This plugin:                                                          
  19.  *      1. http://pastebin.com/FLyVjEcJ                                      
  20.  *      Mentioned Patreon Supporters:
  21.  *      https://www.patreon.com/posts/71738797
  22.  *----------------------------------------------------------------------------
  23.  *    # Author                                                                
  24.  *      DoubleX                                                              
  25.  *----------------------------------------------------------------------------
  26.  *    # Changelog                                                            
  27.  *      v1.00c(GMT 1200 30-1-2016):                                          
  28.  *      1. Fixed reading meta from null equip bug                            
  29.  *      2. Fixed only reading state notetags bug                              
  30.  *      3. Changed from using klass to using prototypes                      
  31.  *      v1.00b(GMT 1300 24-1-2016):                                          
  32.  *      1. Fixed undefined lines in DataManager.loadReverseInputNotes bug    
  33.  *      v1.00a(GMT 1300 30-12-2015):                                          
  34.  *      1. 1st version of this plugin finished                                
  35.  *============================================================================*/
  36. /*:
  37.  * @plugindesc Lets users set some actors reversing the assigned window inputs
  38.  * @author DoubleX
  39.  *
  40.  * @help
  41.  *============================================================================
  42.  *    ## Notetag Info                                                        
  43.  *----------------------------------------------------------------------------
  44.  *    # Actor/Class/Equip/State Notetags:                                    
  45.  *      State notetags take the highest priority, followed by weapon, armor,  
  46.  *      class and actor                                                      
  47.  *      1. <reverse input: proto, downUp, rightLeft, pagedownPageup, okCancel>
  48.  *         - This notetag only works for windows assigned to 1 actor at a time
  49.  *           The below prototypes in default RMMV setting meet the condition:
  50.  *           Window_SkillType.prototype                                      
  51.  *           Window_SkillList.prototype                                      
  52.  *           Window_EquipSlot.prototype                                      
  53.  *           Window_EquipItem.prototype                                      
  54.  *           Window_Status.prototype                                          
  55.  *           Window_ActorCommand.prototype                                    
  56.  *         - This notetag will work for windows belonging to proto or having  
  57.  *           proto in its prototype chain                                    
  58.  *           Both the Window_ and .prototype part doesn't need to be included
  59.  *           in proto                                                        
  60.  *           For example: Status stands for Window_Status.prototype          
  61.  *           proto only accepts prototypes starting with Window_              
  62.  *         - The inputs corresponding to down and up selection commands will  
  63.  *           be reversed if downUp is t                                      
  64.  *         - The inputs corresponding to right and left selection commands    
  65.  *           will be reversed if rightLeft is t                              
  66.  *         - The inputs corresponding to pagedown and pageup selection        
  67.  *           commands will be reversed if pagedownPageup is t                
  68.  *         - The inputs corresponding to ok and cancel selection commands will
  69.  *           be reversed if okCancel is t                                    
  70.  *         - Only the working notetag with the highest priority will be used  
  71.  *============================================================================
  72.  *    ## Plugin Call Info                                                    
  73.  *----------------------------------------------------------------------------
  74.  *    # Actor/Class/Equip/State manipulations                                
  75.  *      1. meta.reverseInput                                                  
  76.  *         - Returns the reverse input flags in the form of {                
  77.  *               proto: proto,                                                
  78.  *               downUp: b,                                                  
  79.  *               rightLeft: b,                                                
  80.  *               pagedownPageup: b,                                          
  81.  *               okCancel: b                                                  
  82.  *           } with proto and b being the window prototype and booleans      
  83.  *      2. meta.reverseInput = {                                              
  84.  *               proto: proto,                                                
  85.  *               downUp: b,                                                  
  86.  *               rightLeft: b,                                                
  87.  *               pagedownPageup: b,                                          
  88.  *               okCancel: b                                                  
  89.  *           }                                                                
  90.  *         - Sets the reverse input flags in the form of {                    
  91.  *               proto: proto,                                                
  92.  *               downUp: b,                                                  
  93.  *               rightLeft: b,                                                
  94.  *               pagedownPageup: b,                                          
  95.  *               okCancel: b                                                  
  96.  *           } with proto and b being the window prototype and booleans      
  97.  *         - All meta.reverseInput changes can be saved if                    
  98.  *           DoubleX RMMV Dynamic Data is used                                
  99.  *============================================================================
  100.  */
  101.  
  102. "use strict";
  103. var DoubleX_RMMV = DoubleX_RMMV || {};
  104. DoubleX_RMMV["Reverse Input"] = "v1.00c";
  105.  
  106. /*============================================================================
  107.  *    ## Plugin Implementations                                              
  108.  *       You need not edit this part as it's about how this plugin works      
  109.  *----------------------------------------------------------------------------
  110.  *    # Plugin Support Info:                                                  
  111.  *      1. Prerequisites                                                      
  112.  *         - Some Javascript coding proficiency to fully comprehend this      
  113.  *           plugin                                                          
  114.  *      2. Function documentation                                            
  115.  *         - The 1st part describes why this function's rewritten/extended for
  116.  *           rewritten/extended functions or what the function does for new  
  117.  *           functions                                                        
  118.  *         - The 2nd part describes what the arguments of the function are    
  119.  *         - The 3rd part informs which version rewritten, extended or created
  120.  *           this function                                                    
  121.  *         - The 4th part informs whether the function's rewritten or new    
  122.  *         - The 5th part informs whether the function's a real or potential  
  123.  *           hotspot                                                          
  124.  *         - The 6th part describes how this function works for new functions
  125.  *           only, and describes the parts added, removed or rewritten for    
  126.  *           rewritten or extended functions only                            
  127.  *         Example:                                                          
  128.  * /*----------------------------------------------------------------------
  129.  *  *    Why rewrite/extended/What this function does                      
  130.  *  *----------------------------------------------------------------------*/
  131. /* // arguments: What these arguments are                                    
  132.  * functionName = function(arguments) { // Version X+; New/Rewrite; Hotspot  
  133.  *     // Added/Removed/Rewritten to do something/How this function works    
  134.  *     functionContents                                                      
  135.  *     //                                                                    
  136.  * } // functionName                                                          
  137.  *----------------------------------------------------------------------------*/
  138.  
  139. DataManager.isDatabaseLoadedReverseInput = DataManager.isDatabaseLoaded;
  140. DataManager.isDatabaseLoaded = function() {
  141.     // Rewritten
  142.     if (!this.isDatabaseLoadedReverseInput.apply(this, arguments)) {
  143.         return false;
  144.     }
  145.     this.loadAllReverseInputNotes();
  146.     return true;
  147.     //
  148. }; // DataManager.isDatabaseLoaded
  149.  
  150. DataManager.loadAllReverseInputNotes = function() { // New
  151.     var ts = [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates];
  152.     ts.forEach(function(type) {
  153.         type.forEach(function(data) {
  154.             if (data) { this.loadReverseInputNotes(data); }
  155.         }, this);
  156.     }, this);
  157. }; // DataManager.loadAllReverseInputNotes
  158.  
  159. // data: The data to have its notetags read
  160. DataManager.loadReverseInputNotes = function(data) { // New
  161.     data.meta.reverseInput = {};
  162.     var rI = data.meta.reverseInput;
  163.     var regex =
  164.     /< *reverse +input *: *(\w+) *, *(\w+) *, *(\w+) *, *(\w+) *, *(\w+) *>/i;
  165.     data.note.split(/[\r\n]+/).forEach(function(line) {
  166.         if (!line.match(regex)) { return; }
  167.         rI.proto = "Window_" + RegExp.$1 + ".prototype";
  168.         rI.downUp = RegExp.$2 === "t";
  169.         rI.rightLeft = RegExp.$3 === "t";
  170.         rI.pagedownPageup = RegExp.$4 === "t";
  171.         rI.okCancel = RegExp.$5 === "t";
  172.     });
  173. }; // DataManager.loadReverseInputNotes
  174.  
  175. /* window: The window used by the actor to check if the input's reversed
  176.  * command: The command to check if the correseponding input's reversed
  177.  */
  178. Game_Actor.prototype.isReverseInput = function(window, command) {
  179. // New; Potential Hotspot
  180.     var equips = this.equips().filter(function(equip) { return equip; }), proto;
  181.     var types = [this.states(), equips, [this.currentClass()], [this.actor()]];
  182.     for (var index = 0, length = types.length; index < length; index++) {
  183.         for (var data = types[index], i = 0, l = data.length; i < l; i++) {
  184.             proto = eval(data[i].meta.reverseInput.proto);
  185.             if (!proto || !proto.isPrototypeOf(window)) { continue; }
  186.             return data[i].meta.reverseInput[command];
  187.         }
  188.     }
  189.     return false;
  190. }; // Game_Actor.prototype.isReverseInput
  191.  
  192. Window_Selectable.prototype.cursorDownReverseInput =
  193. Window_Selectable.prototype.cursorDown;
  194. Window_Selectable.prototype.cursorUpReverseInput =
  195. Window_Selectable.prototype.cursorUp;
  196. Window_Selectable.prototype.cursorRightReverseInput =
  197. Window_Selectable.prototype.cursorRight;
  198. Window_Selectable.prototype.cursorLeftReverseInput =
  199. Window_Selectable.prototype.cursorLeft;
  200. Window_Selectable.prototype.cursorPagedownReverseInput =
  201. Window_Selectable.prototype.cursorPagedown;
  202. Window_Selectable.prototype.cursorPageupReverseInput =
  203. Window_Selectable.prototype.cursorPageup;
  204. Window_Selectable.prototype.processPagedownReverseInput =
  205. Window_Selectable.prototype.processPagedown;
  206. Window_Selectable.prototype.processPageupReverseInput =
  207. Window_Selectable.prototype.processPageup;
  208. Window_Selectable.prototype.processOkReverseInput =
  209. Window_Selectable.prototype.processOk;
  210. Window_Selectable.prototype.processCancelReverseInput =
  211. Window_Selectable.prototype.processCancel;
  212.  
  213. Window_Selectable.prototype.cursorDown = function(wrap) { // Potential Hotspot
  214.     // Added
  215.     if (this._actor && this._actor.isReverseInput(this, "downUp")) {
  216.         return this.cursorUpReverseInput(wrap);
  217.     }
  218.     //
  219.     return this.cursorDownReverseInput(wrap);
  220. }; // Window_Selectable.prototype.cursorDown
  221.  
  222. Window_Selectable.prototype.cursorUp = function(wrap) { // Potential Hotspot
  223.     // Added
  224.     if (this._actor && this._actor.isReverseInput(this, "downUp")) {
  225.         return this.cursorDownReverseInput(wrap);
  226.     }
  227.     //
  228.     return this.cursorUpReverseInput(wrap);
  229. }; // Window_Selectable.prototype.cursorUp
  230.  
  231. Window_Selectable.prototype.cursorRight = function(wrap) { // Potential Hotspot
  232.     // Added
  233.     if (this._actor && this._actor.isReverseInput(this, "rightLeft")) {
  234.         return this.cursorLeftReverseInput(wrap);
  235.     }
  236.     //
  237.     return this.cursorRightReverseInput(wrap);
  238. }; // Window_Selectable.prototype.cursorRight
  239.  
  240. Window_Selectable.prototype.cursorLeft = function(wrap) { // Potential Hotspot
  241.     // Added
  242.     if (this._actor && this._actor.isReverseInput(this, "rightLeft")) {
  243.         return this.cursorRightReverseInput(wrap);
  244.     }
  245.     //
  246.     return this.cursorLeftReverseInput(wrap);
  247. }; // Window_Selectable.prototype.cursorLeft
  248.  
  249. Window_Selectable.prototype.cursorPagedown = function() {
  250.     // Added
  251.     if (this._actor && this._actor.isReverseInput(this, "pagedownPageup")) {
  252.         return this.cursorPageupReverseInput();
  253.     }
  254.     //
  255.     return this.cursorPagedownReverseInput();
  256. }; // Window_Selectable.prototype.cursorPagedown
  257.  
  258. Window_Selectable.prototype.cursorPageup = function() {
  259.     // Added
  260.     if (this._actor && this._actor.isReverseInput(this, "pagedownPageup")) {
  261.         return this.cursorPagedownReverseInput();
  262.     }
  263.     //
  264.     return this.cursorPageupReverseInput();
  265. }; // Window_Selectable.prototype.cursorPageup
  266.  
  267. Window_Selectable.prototype.processPageup = function() {
  268.     // Added
  269.     if (this._actor && this._actor.isReverseInput(this, "pagedownPageup")) {
  270.         return this.processPagedownReverseInput();
  271.     }
  272.     //
  273.     return this.processPageupReverseInput();
  274. }; // Window_Selectable.prototype.processPageup
  275.  
  276. Window_Selectable.prototype.processPagedown = function() {
  277.     // Added
  278.     if (this._actor && this._actor.isReverseInput(this, "pagedownPageup")) {
  279.         return this.processPageupReverseInput();
  280.     }
  281.     //
  282.     return this.processPagedownReverseInput();
  283. }; // Window_Selectable.prototype.processPagedown
  284.  
  285. Window_Selectable.prototype.processOk = function() {
  286.     // Added
  287.     if (this._actor && this._actor.isReverseInput(this, "okCancel")) {
  288.         return this.processCancelReverseInput();
  289.     }
  290.     //
  291.     return this.processOkReverseInput();
  292. }; // Window_Selectable.prototype.processOk
  293.  
  294. Window_Selectable.prototype.processCancel = function() {
  295.     // Added
  296.     if (this._actor && this._actor.isReverseInput(this, "okCancel")) {
  297.         return this.processOkReverseInput();
  298.     }
  299.     //
  300.     return this.processCancelReverseInput();
  301. }; // Window_Selectable.prototype.processCancel
  302.  
  303. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement