Makeratore

Chapter Window

Jun 29th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----------------------------------------------------------------------------
  2. // Chapter Window by Makeratore
  3. // BEFORE INSTALLING THE PLUGIN, PLEASE MAKE SURE THAT THE PLUGIN FILE NAME IS "chapterWindow", OTHERWISE IT WON'T WORK!
  4. // This plugin provides a new simple window to display a text for a chapter name or whatever.
  5. //-----------------------------------------------------------------------------
  6. //  For: RPG Maker MV
  7. //  chapterWindow.js
  8. //-----------------------------------------------------------------------------
  9. //  15/07/2016 - Version 4.0 - Compatible with Galv's plugin
  10. //  07/07/2016 - Version 3.0 - Unified the gold window with the chapter window and added a new parameter for the background type
  11. //  30/06/2016 - Version 2.2 - Bug fix of play time
  12. //  30/06/2016 - Version 2.1 - Bug fix and added a parameter for the window position
  13. //  30/06/2016 - Version 2.0 - Adds new plugin commands and new icons
  14. //  29/06/2016 - Version 1.0 - Release
  15. //-----------------------------------------------------------------------------
  16. // TERMS AND CONDITIONS
  17. // You can use this plugin in commercial and non-commercial projects.
  18. // Please, provide credits to Makeratore.
  19. //
  20. // This plugin can be found at:
  21. // http://www.rpg2s.net/forum/
  22. //-----------------------------------------------------------------------------
  23.  
  24. var Imported = Imported || {};
  25. Imported.chapterWindow = true;
  26.  
  27. //-----------------------------------------------------------------------------
  28. /*:
  29. *
  30. * @plugindesc This plugin provides a new simple window to display a text for a chapter name or whatever. Version: 4.0
  31. *
  32. * @author Makeratore
  33. *
  34. * @param Additional text
  35. * @desc Insert here the first line of text to be displayed. Default: Chapter:.
  36. * @default Chapter:
  37. *
  38. * @param Initial chapter text
  39. * @desc This is the second line of text. Default: A new adventure.
  40. * @default A new adventure
  41. *
  42. * @param Use Icon
  43. * @desc Set this parameter to "true" or "false" if you want to display the first icon or not. Default: false.
  44. * @default false
  45. *
  46. * @param Use Icon 2
  47. * @desc Set this parameter to "true" or "false" if you want to display the second icon or not. Default: false.
  48. * @default false
  49. *
  50. * @param Use Icon 3
  51. * @desc Set this parameter to "true" or "false" if you want to display the third icon or not. Default: false.
  52. * @default false
  53. *
  54. * @param Icon
  55. * @desc Set the second icon. Insert a valid icon index number. Default: 79.
  56. * @default 79
  57. *
  58. * @param Icon 2
  59. * @desc Set the first icon. Insert a valid icon index number. Default: 87.
  60. * @default 87
  61. *
  62. * @param Icon 3
  63. * @desc Set a custom third icon for the play time. Insert a valid icon index number. Default: 83.
  64. * @default 83
  65. *
  66. * @param Font size
  67. * @desc Set a custom font size for the text. Default: 25.
  68. * @default 25
  69. *
  70. * @param Window position
  71. * @desc You can set a custom window position. Higher the number, higher the window will be. Default: 0
  72. * @default 0
  73. *
  74. * @param Background type
  75. * @desc Set a custom background type for the chapter window. It can be 1 or 0. Default: 0
  76. * @default 0
  77. *
  78. * @param Use with Galv's plugin
  79. * @desc If you're also using the Galv's plugin, set this parameter to true. Default: false
  80. * @default false
  81. *
  82. * @param Single text
  83. * @desc If you're using the Galv's plugin, write here the text. Default: text
  84. * @default text
  85. *
  86. * @help TERMS AND CONDITIONS
  87. * You can use this plugin in commercial and non-commercial projects.
  88. * Please, provide credits to Makeratore.
  89. *
  90. * BEFORE INSTALLING THE PLUGIN, PLEASE MAKE SURE THAT THE
  91. * PLUGIN FILE NAME IS "chapterWindow", OTHERWISE IT WON'T WORK!
  92. *
  93. * INSTRUCTIONS
  94. * There are 12 plugin commands.
  95. * - "changeAdditionalText X": changes the first line of text.
  96. * Set X to a text to be displayed.
  97. * - "changeAdditionalTextIcon X": changes the icon for the first line of text.
  98. * Set X to a valid icon index number.
  99. * - "changeChapterUseIcon X": makes the first icon display or not.
  100. * Set X to "true" or "false".
  101. * - "changeChapterName X": changes the second line of text.
  102. * Change X to a text to be displayed.
  103. * - "changeChapterIcon X": changes the second icon.
  104. * Change X to a valid icon index number.
  105. * -"changeUseIcon2 X": makes the second icon display or not.
  106. * Set X to "true" or "false".
  107. * - "changeIcon3 X": changes the third icon
  108. * Set X to a valid icon index number.
  109. * - "changeUseIcon3 X": makes the third icon display or not.
  110. * Set X to "true" or "false".
  111. * - "changeFontSize X": changes the font size for the text.
  112. * Set X to a custom number to change the size.
  113. * -"changeChapterWindowPosition X": changes the chapter window position.
  114. * Higher the number, higher the window will be. Set X to a custom number.
  115. * -"changeChapterBackgroundType X": changes the window background type.
  116. * Set X to 1 or 0.
  117. * -"changeChapterSingleText X": type here the text to be displayed.
  118. * Set X to the text you want.
  119. *
  120. */
  121. //-----------------------------------------------------------------------------
  122.  
  123. //-----------------------------------------------------------------------------
  124. // Code
  125. //-----------------------------------------------------------------------------
  126.  
  127. (function() {
  128.  
  129. var parameters = PluginManager.parameters('chapterWindow');
  130. var additionalText = String(parameters['Additional text']);
  131. var chapterName = String(parameters['Initial chapter text']);
  132. var iconIndex = Number(parameters['Icon']);
  133. var iconAdditionalText = Number(parameters['Icon 2']);
  134. var icon3 = Number(parameters['Icon 3']);
  135. var useIcon = String(parameters['Use Icon']).trim() == "true";
  136. var useIcon2 = String(parameters['Use Icon 2']).trim() == "true";
  137. var useIcon3 = String(parameters['Use Icon 3']).trim() == "true";
  138. var fontSize = Number(parameters['Font size']);
  139. var windowPosition = Number(parameters['Window position']);
  140. var varBackgroundType = Number(parameters['Background type']);
  141. var useGalvPlugin = String(parameters["Use with Galv's plugin"]).trim() == "true";
  142. var singleText = String(parameters['Single text']);
  143.  
  144. var textHere = chapterName;
  145.  
  146. var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  147. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  148.     _Game_Interpreter_pluginCommand.call(this, command, args);
  149.  
  150.     if(command == "changeChapterName") {
  151.         textHere = "";
  152.         for(i = 0; i < args.length; i++) {
  153.             textHere += String(args[i]);
  154.             textHere += " ";
  155.         }
  156.     } else if (command == "changeChapterIcon") {
  157.         iconIndex = Number(args);
  158.     } else if (command == "changeChapterUseIcon") {
  159.         useIcon = String(args).trim() == "true";
  160.     } else if (command == "changeFontSize") {
  161.         fontSize = Number(args);
  162.     } else if (command == "changeAdditionalText") {
  163.         additionalText = "";
  164.         for(i = 0; i < args.length; i++) {
  165.             additionalText += String(args[i]);
  166.             additionalText += " ";
  167.         }
  168.     } else if (command == "changeAdditionalTextIcon") {
  169.         iconAdditionalText = Number(args);
  170.     } else if (command == "changeUseIcon2") {
  171.         useIcon2 = String(args).trim() == "true";
  172.     } else if (command == "changeUseIcon3") {
  173.         useIcon3 = String(args).trim() == "true";
  174.     } else if (command == "changeIcon3") {
  175.         icon3 = Number(args);
  176.     } else if (command == "changeChapterWindowPosition") {
  177.         windowPosition = Number(args);
  178.     } else if (command == "changeChapterBackgroundType") {
  179.         varBackgroundType = Number(args);
  180.     } else if (command == "changeChapterSingleText") {
  181.         singleText = "";
  182.         for (i = 0; i < args.length; i++) {
  183.             singleText += String(args[i]);
  184.             singleText += " ";
  185.         }
  186.     }
  187. };
  188.  
  189. Window_MenuStatus.prototype.windowHeight = function() {
  190.     if (!useGalvPlugin) {
  191.         return Graphics.boxHeight;
  192.     } else {
  193.         return Graphics.boxHeight - 70;
  194.     }
  195. };
  196.  
  197. function Window_Chapter() {
  198.     this.initialize.apply(this, arguments);
  199. }
  200.  
  201. Window_Chapter.prototype = Object.create(Window_Base.prototype);
  202. Window_Chapter.prototype.constructor = Window_Chapter;
  203.  
  204. Window_Chapter.prototype.initialize = function(x, y) {
  205.     var width = this.windowWidth();
  206.     var height = this.windowHeight();
  207.     Window_Base.prototype.initialize.call(this, x, y, width, height);  
  208.     this.setBackgroundType(varBackgroundType);
  209.     this.refresh();
  210. };
  211.  
  212. Window_Chapter.prototype.windowWidth = function() {  
  213.     if (!useGalvPlugin) {
  214.         return 240
  215.     } else {
  216.         return Graphics.boxWidth;
  217.     }
  218. };
  219.  
  220. Window_Chapter.prototype.windowHeight = function() {
  221.     if (!useGalvPlugin) {
  222.         return 170;
  223.     } else {
  224.         return 70;
  225.     }
  226. };
  227.  
  228. Window_Chapter.prototype.standardFontSize = function() {
  229.     return fontSize;
  230. };
  231.  
  232. Window_Chapter.prototype.value = function() {
  233.     return $gameParty.gold();
  234. };
  235.  
  236. Window_Chapter.prototype.currencyUnit = function() {
  237.     return TextManager.currencyUnit;
  238. };
  239.  
  240. Window_Chapter.prototype.refresh = function() {
  241.     var x = this.textPadding();
  242.     var width = this.contents.width - this.textPadding() * 2;
  243.     this.contents.clear();
  244.     if (!useGalvPlugin) {
  245.     if (useIcon) {
  246.     this.drawIcon(iconAdditionalText, 0, 0);
  247.     this.drawTextEx(additionalText, 40, 0);
  248.     } else if (!useIcon) {
  249.         this.drawTextEx(additionalText, 0, 0);
  250.     }
  251.     if (useIcon2) {
  252.         this.drawIcon(iconIndex, 0, 35);
  253.         this.drawTextEx(textHere, 40, 35);
  254.     } else if(!useIcon2) {
  255.         this.drawTextEx(textHere, 0, 35);
  256.     }
  257.     if (useIcon3) {
  258.         this.drawIcon(icon3, 0, 70);
  259.         this.drawTextEx($gameSystem.playtimeText(), 40, 70);
  260.     } else if (!useIcon3) {
  261.         this.drawTextEx($gameSystem.playtimeText(), 0, 70);
  262.     }
  263.     this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 100, width);
  264.     } else {
  265.     if (useIcon) {
  266.     this.drawIcon(iconAdditionalText, 0, 0);
  267.     this.drawTextEx(singleText, 40, 0);
  268.     } else if (!useIcon) {
  269.         this.drawTextEx(singleText, 0, 0);
  270.     }
  271.     if (useIcon3) {
  272.         this.drawIcon(icon3, Graphics.boxWidth / 2 - 40, 0);
  273.         this.drawTextEx($gameSystem.playtimeText(), Graphics.boxWidth / 2, 0);
  274.     } else if (!useIcon3) {
  275.         this.drawTextEx($gameSystem.playtimeText(), Graphics.boxWidth / 2, 0);
  276.     }
  277.     this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 0, width);
  278.     }
  279. };
  280.  
  281. // Window_Chapter.prototype.refresh = function() {
  282. //     var x = this.textPadding();
  283. //     var width = this.contents.width - this.textPadding() * 2;
  284. //     this.contents.clear();
  285. //  if (useIcon) {
  286. //     this.drawIcon(iconAdditionalText, 0, 0);
  287. //     this.drawTextEx(additionalText, 40, 0);
  288. //  } else if (!useIcon) {
  289. //      this.drawTextEx(additionalText, 0, 0);
  290. //  }
  291. //  if (useIcon2) {
  292. //      this.drawIcon(iconIndex, 0, 35);
  293. //      this.drawTextEx(textHere, 40, 35);
  294. //  } else if(!useIcon2) {
  295. //      this.drawTextEx(textHere, 0, 35);
  296. //  }
  297. //  if (useIcon3) {
  298. //      this.drawIcon(icon3, 0, 70);
  299. //      this.drawTextEx($gameSystem.playtimeText(), 40, 70);
  300. //  } else if (!useIcon3) {
  301. //      this.drawTextEx($gameSystem.playtimeText(), 0, 70);
  302. //  }
  303. //  this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 100, width);
  304. // };
  305.  
  306. Window_Chapter.prototype.open = function() {
  307.     this.refresh();
  308.     Window_Base.prototype.open.call(this);
  309. };
  310.  
  311. Scene_Menu.prototype.create = function() {
  312.     Scene_MenuBase.prototype.create.call(this);
  313.     this.createCommandWindow();
  314.     this.createStatusWindow();
  315.     this.createChapterWindow();
  316. };
  317.  
  318. var _Scene_Menu_update = Scene_Menu.prototype.update;
  319. Scene_Menu.prototype.update = function() {
  320.     _Scene_Menu_update.call(this);
  321.     this._chapterWindow.refresh();
  322. };
  323.  
  324. Scene_Menu.prototype.createChapterWindow = function() {
  325.     this._chapterWindow = new Window_Chapter(0, 0);
  326.     this._chapterWindow.y = Graphics.boxHeight - this._chapterWindow.height - windowPosition;
  327.     this.addWindow(this._chapterWindow);
  328. };
  329.  
  330. })();
  331.  
  332. //-----------------------------------------------------------------------------
  333. // End of plugin
  334. //-----------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment