Advertisement
nio_kasgami

Message Bust Beta

Oct 28th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2. //==============================================================================
  3. // ■ Emoji Engine MV - Origin "Advance Message Bust"
  4. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  5.   @plugindesc Permit to have VN style Message system. It's also permit to
  6.   enchance more lively message.
  7.   id: EEMV::AdvanceMessageSystem
  8.   @author Nio Kasgami.
  9.   @Data : 2015/10/05
  10.   @Version : 1.0.0
  11.   @Require : EmojiBase
  12. //==============================================================================
  13.  
  14. //==============================================================================
  15. // ■ History
  16. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. // * 2015/10/29 - Begin and finish the plugin.
  18. //==============================================================================
  19.  
  20. //==============================================================================
  21. // ■ Introduction
  22. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. // * Permit to have more graphical enchancement for the message system.
  24. //==============================================================================
  25.  
  26. //==============================================================================
  27. //  ■ Plugin Parameter
  28. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. // this section handle the plugin parameter. Please do not edit unless you
  30. // want to add extra plugin command.
  31. //------------------------------------------------------------------------------
  32.    * @param Enable Bust
  33.    * @desc Enable the use of bust in your message bust and will preload it.
  34.    * @default true
  35.  
  36.    * @param Bust Folder
  37.    * @desc Set the folder for the bust.
  38.    * @default pictures
  39.  
  40.    * @param Bust Position
  41.    * @desc set the position of the bust.
  42.    * @default 100,100
  43.  
  44.    * @param Bust Priority
  45.    * @desc set the Z position of the bust. Use the word below or above.
  46.    * @default below
  47.  
  48.    * @param Enable Panorama
  49.    * @desc Enable the use of background and will preload it.
  50.    * @default true
  51.  
  52.    * @param Panorama Folder
  53.    * @desc set the folder for the panorama.
  54.    * @default pictures
  55. //==============================================================================
  56.  
  57. //==============================================================================
  58. // ■ Help File
  59. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. // This section serve for input the help file in the engine don't touch this
  61. // unless you want to input more information
  62. //------------------------------------------------------------------------------
  63.    * @help
  64.    * ==========================================================================
  65.    *  ■ Plugin Command
  66.    * ==========================================================================
  67.    * Emoji.setPanorama '[filename,hue]' : set the panorama filename and hue.
  68.    * Emoji.erasePanorama : erase the current panorama.
  69.    *
  70.    * Emoji.mirror true,false : will mirror the bust.
  71.    * --------------------------------------------------------------------------
  72.    *
  73.    * ==========================================================================
  74.    *  ■ Control Character
  75.    * ==========================================================================
  76.    * none for the moment.
  77.    *---------------------------------------------------------------------------
  78.  
  79. */
  80.  
  81. //==============================================================================
  82. // ■ Emoji_Engine
  83. //------------------------------------------------------------------------------
  84. // the class who handle all the base of my plugins. Can be access via $emoji.
  85. //==============================================================================
  86.  
  87. // anonymous function
  88. (function(){
  89.  
  90. //----------------------------------------------------------------------------
  91. // ○ alias function: get_pluginname
  92. //----------------------------------------------------------------------------
  93. var NP01 = Emoji_Engine.prototype.get_pluginname;
  94. Emoji_Engine.prototype.get_pluginname = function() {
  95.     NP01.call(this);
  96.     this.message_params = this.set_PluginID('EEMV::AdvanceMessageSystem');
  97. };
  98.  
  99. //----------------------------------------------------------------------------
  100. // ● alias function: get_params
  101. //----------------------------------------------------------------------------
  102. var NPN01 = Emoji_Engine.prototype.get_params;
  103. Emoji_Engine.prototype.get_params = function() {
  104.     NPN01.call(this);
  105. // Get Bust Parameters.
  106.     this.enableBust     = this.setBoolean(this.message_params,'Enable Bust');
  107.     this.bustFolder     = this.setString(this.message_params,'Bust Folder');
  108.     this.bustPos        = this.setArray(this.message_params,'Bust Position');
  109.     this.bustPriority   = this.setString(this.message_params,'Bust Priority');
  110. // Get Panorama Parameters.
  111.     this.enablePanorama = this.setBoolean(this.message_params,'Enable Panorama');
  112.     this.panoramaFolder = this.setString(this.message_params,'Panorama Folder');
  113. };
  114. //===============================================================================
  115. // => END : Emoji_Engine
  116. //===============================================================================
  117.  
  118. //==============================================================================
  119. // ■ Game_Message
  120. //------------------------------------------------------------------------------
  121. // The game object class for the state of the message window that displays text
  122. // or selections, etc.
  123. //==============================================================================
  124.  
  125. //----------------------------------------------------------------------------
  126. // ● alias function: clear
  127. //----------------------------------------------------------------------------
  128. var nio_message_clear = Game_Message.prototype.clear;
  129. Game_Message.prototype.clear = function() {
  130.     nio_message_clear.call(this);
  131.     this._bustName      = "";
  132.     this._bust_index    = "";
  133.   //  this._panoramaName  = "";
  134.     this._panorama_hue  = 0;
  135.     this._mirror        = false;
  136.     this._flag = false;
  137. };
  138.  
  139. //----------------------------------------------------------------------------
  140. // ○ new function: bustName
  141. //----------------------------------------------------------------------------
  142. Game_Message.prototype.bustName = function() {
  143.     return this._bustName;
  144. };
  145. //----------------------------------------------------------------------------
  146. // ○ new function: bustIndex
  147. //----------------------------------------------------------------------------
  148. Game_Message.prototype.bustIndex = function() {
  149.     return this._bust_index;
  150. };
  151.  
  152. //----------------------------------------------------------------------------
  153. // ○ new function: setBust
  154. //----------------------------------------------------------------------------
  155. Game_Message.prototype.setBust = function(filename,index) {
  156.     this._bustName  = filename;
  157.     this._bust_index = index;
  158. };
  159.  
  160. //----------------------------------------------------------------------------
  161. // ○ new function: panoramaName
  162. //----------------------------------------------------------------------------
  163. Game_Message.prototype.panoramaName = function() {
  164.     return this._panoramaName;
  165. };
  166.  
  167. //----------------------------------------------------------------------------
  168. // ○ new function: setPanorama
  169. //----------------------------------------------------------------------------
  170. Game_Message.prototype.setPanorama = function(p_filename,hue) {
  171.     this._panoramaName = p_filename;
  172.     this._panorama_hue  = hue;
  173. };
  174.  
  175. //----------------------------------------------------------------------------
  176. // ○ new function: ismirror
  177. //----------------------------------------------------------------------------
  178. Game_Message.prototype.isMirror = function() {
  179.     return this._mirror;
  180. };
  181.  
  182. //----------------------------------------------------------------------------
  183. // ○ new function: setMirror
  184. //----------------------------------------------------------------------------
  185. Game_Message.prototype.setMirror = function(flag) {
  186.   this._mirror = flag;
  187. };
  188.  
  189. //----------------------------------------------------------------------------
  190. // ○ new function: erasePanorama {obsolete}
  191. //----------------------------------------------------------------------------
  192. Game_Message.prototype.erasePanorama = function(flag) {
  193.   this._flag = flag;
  194. };
  195.  
  196. //----------------------------------------------------------------------------
  197. // ○ new function: callVoice
  198. //----------------------------------------------------------------------------
  199. Game_Message.prototype.callVoice = function(file,volume,pitch,pan) {
  200.   AudioManager.playSe(file,volume,pitch,pan);
  201. };
  202. //===============================================================================
  203. // => END : Game_Message
  204. //===============================================================================
  205.  
  206. //==============================================================================
  207. // ■ Window_Message
  208. //------------------------------------------------------------------------------
  209. // The window for displaying text messages.
  210. //==============================================================================
  211.  
  212. //----------------------------------------------------------------------------
  213. // ● alias function: initialize
  214. //----------------------------------------------------------------------------
  215. var NMW01 = Window_Message.prototype.initialize;
  216. Window_Message.prototype.initialize = function() {
  217.     NMW01.call(this);
  218.     this.createPanorama();    
  219.     this.createBust();
  220. };
  221.  
  222. //----------------------------------------------------------------------------
  223. // ● overwrite function: updateLoading
  224. //----------------------------------------------------------------------------
  225. Window_Message.prototype.updateLoading = function() {
  226.     if (this._faceBitmap) {
  227.         if (ImageManager.isReady()) {
  228.       // if enableBust is not enable draw default face and panorama
  229.           if(!$emoji.enableBust) {
  230.             this.drawMessageFace();
  231.             this.drawMessagePanorama();
  232.             this._faceBitmap = null;
  233.             this.panorama_graphics = null;
  234.             return false;
  235.           }else{
  236.       // else draw bust and panorma and ignoring face
  237.          if($gameMessage.isMirror()){
  238.               this.spritebust.mirror(true,false);
  239.             }else
  240.             {this.spritebust.mirror(false,false);}
  241.           if($gameMessage.erasePanorama()){
  242.             this.panorama.visible = false;
  243.           }else{
  244.             this.panorama.visible = true;
  245.           }
  246.             this.drawMessagePanorama();
  247.             this.drawMessageBust();
  248.             this.bust_graphics = null;
  249.             this.panorama_graphics = null;
  250.             return false;
  251.           }
  252.  
  253.         } else {
  254.             return true;
  255.         }
  256.     } else {
  257.         return false;
  258.     }
  259. };
  260.  
  261. //----------------------------------------------------------------------------
  262. // ● overwrite function: newPage
  263. //----------------------------------------------------------------------------
  264. Window_Message.prototype.newPage = function(textState) {
  265.     this.contents.clear();
  266.     this.resetFontSettings();
  267.     this.clearFlags();
  268.     this.loadMessageFace();
  269.     textState.x = this.newLineX();
  270.     textState.y = 0;
  271.     textState.left = this.newLineX();
  272.     textState.height = this.calcTextHeight(textState, false);
  273.     this.load_Panorama();
  274.     this.load_messagebust();
  275. };
  276.  
  277. //----------------------------------------------------------------------------
  278. // ○ new function: load_messagebust
  279. //----------------------------------------------------------------------------
  280. Window_Message.prototype.load_messagebust = function() {
  281.  if ($gameMessage.bustName() != "") {
  282.     this.bust_graphics = ImageManager.loadBust($gameMessage.bustName() + '_' + $gameMessage.bustIndex());
  283.  }
  284. };
  285.  
  286. //----------------------------------------------------------------------------
  287. // ○ new function: load_Panorama
  288. //----------------------------------------------------------------------------
  289. Window_Message.prototype.load_Panorama = function() {
  290.   if($gameMessage.panoramaName() != ""){
  291.     this.panorama_graphics = ImageManager.loadPanorama($gameMessage.panoramaName());
  292.   }else{
  293.     this.panorama_graphics = ImageManager.loadPanorama("");
  294.   }
  295. };
  296.  
  297. //----------------------------------------------------------------------------
  298. // ○ new function: create_panorama
  299. //----------------------------------------------------------------------------
  300. Window_Message.prototype.createPanorama = function() {
  301.     if($emoji.enablePanorama){  
  302.     this.panorama = new Sprite();
  303.     this.panorama.x = Graphics.width / 2;
  304.     this.panorama.y = (Graphics.height / 2) - 15;
  305.     this.panorama.setOrigin(0.5,1);
  306.     this.addChildAt(this.panorama, 0);
  307.     this.panorama.visible = false;
  308.     }
  309. };
  310. //----------------------------------------------------------------------------
  311. // ○ new function: drawMessagePanorama
  312. //----------------------------------------------------------------------------
  313. Window_Message.prototype.drawMessagePanorama = function() {
  314.     if($gameMessage.panoramaName() === ""){
  315.       if($gameMessage.erasePanorama){
  316.       this.panorama.bitmap = ImageManager.loadPanorama($gameMessage.panoramaName(),0);
  317.       this.panorama.visible = false;
  318.       }
  319.       } else {
  320.         this.panorama.visible = true;
  321.         this.panorama.bitmap = ImageManager.loadPanorama($gameMessage.panoramaName(),0);
  322.       }
  323. };
  324.  
  325. //----------------------------------------------------------------------------
  326. // ○ new function: createBust
  327. //----------------------------------------------------------------------------
  328. Window_Message.prototype.createBust = function() {
  329.     if($emoji.enableBust){    
  330.         this.spritebust = new Sprite();
  331.         this.spritebust.setOrigin(0.5,1);
  332.         this.spritebust.x = $emoji.bustPos[0];
  333.         this.spritebust.y = $emoji.bustPos[1];
  334.         this.spritebust.visible = false;
  335.       // set the z axis of the sprite.
  336.         switch($emoji.bustPriority.toLowerCase()){
  337.           case 'below' :
  338.            this.addChildAt(this.spritebust,1);
  339.            break;
  340.            case 'above' :
  341.            this.addChildAt(this.spritebust,3);
  342.            break;
  343.         }
  344.    }
  345. };
  346.  
  347. //----------------------------------------------------------------------------
  348. // ○ new function: drawMessageBust
  349. //----------------------------------------------------------------------------
  350. Window_Message.prototype.drawMessageBust = function() {
  351.     if ($gameMessage.bustName() != ""){
  352.         this.spritebust.bitmap  = ImageManager.loadBust($gameMessage.bustName() + '_' + $gameMessage.bustIndex());
  353.         this.spritebust.visible = true;
  354.     }else {
  355.         this.spritebust.bitmap  = ImageManager.loadBust("");
  356.         this.spritebust.visible = false;
  357.     }
  358. };
  359.  
  360. //----------------------------------------------------------------------------
  361. // ● overwrite function: newLineX
  362. //----------------------------------------------------------------------------
  363. Window_Message.prototype.newLineX = function() {
  364.   if($emoji.enableBust){
  365.     if($emoji.bustPriority === 'above'){
  366.       return $gameMessage.bustName() === '' ? 0 : 168;
  367.     } else{
  368.       return 0
  369.     }
  370.   }else{
  371.     return $gameMessage.faceName() === '' ? 0 : 168;
  372.   }
  373. };
  374. //===============================================================================
  375. // => END : Window_Message
  376. //===============================================================================
  377.  
  378. //==============================================================================
  379. // ■ ImageManager
  380. //------------------------------------------------------------------------------
  381. // The static class that loads images, creates bitmap objects and retains them.
  382. //==============================================================================
  383.  
  384. //----------------------------------------------------------------------------
  385. // ○ new function: loadBust
  386. //----------------------------------------------------------------------------
  387. ImageManager.loadBust = function(filename) {
  388.     var pathofile = $emoji.bustFolder;
  389.     return this.loadBitmap('img/'+ pathofile + '/', filename, 0, true);
  390. };
  391.  
  392. //----------------------------------------------------------------------------
  393. // ○ new function: loadPanorama
  394. //----------------------------------------------------------------------------
  395. ImageManager.loadPanorama = function(filename,hue) {
  396.     var pathofile = $emoji.panoramaFolder;
  397.     return this.loadBitmap('img/'+ pathofile + '/', filename,hue,true);
  398. };
  399. //===============================================================================
  400. // => END : ImageManager
  401. //===============================================================================
  402.  
  403. //==============================================================================
  404. // ■ Game_Interpreter
  405. //------------------------------------------------------------------------------
  406. // The interpreter for running event commands.
  407. //==============================================================================
  408.  
  409.  
  410. //----------------------------------------------------------------------------
  411. // ○ new function: inputPanorama
  412. //----------------------------------------------------------------------------
  413. Game_Interpreter.prototype.inputPanorama = function(filename,hue) {
  414.   $gameMessage.setPanorama(filename,hue);
  415.  
  416. };
  417.  
  418. //----------------------------------------------------------------------------
  419. // ○ new function: restartPanorama
  420. //----------------------------------------------------------------------------
  421. Game_Interpreter.prototype.restartPanorama = function() {
  422.   $gameMessage.setPanorama('',0);
  423. };
  424.  
  425. //----------------------------------------------------------------------------
  426. // ○ new function: mirrorBust
  427. //----------------------------------------------------------------------------
  428. Game_Interpreter.prototype.mirrorBust = function(flag) {
  429.   $gameMessage.setMirror(flag);
  430. };
  431.  
  432. //----------------------------------------------------------------------------
  433. // ○ new function: setMirror
  434. //----------------------------------------------------------------------------
  435. var NPC01 = Game_Interpreter.prototype.pluginCommand;
  436. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  437.   NPC01.call(this,command,args);
  438.   if(command === 'Emoji.setPanorama' && !$gameParty.inBattle()){
  439.     this.inputPanorama(args,0);
  440.   }
  441.   if(command === 'Emoji.erasePanorama'){
  442.     this.restartPanorama();
  443.   }
  444.   if(command === 'Emoji.mirror'){
  445.     this.mirrorBust(args)
  446.   }
  447. };
  448.  
  449. //----------------------------------------------------------------------------
  450. // ● overwrite function: command101
  451. //----------------------------------------------------------------------------
  452. Game_Interpreter.prototype.command101 = function() {
  453.     if (!$gameMessage.isBusy()) {
  454.         $gameMessage.setFaceImage(this._params[0], this._params[1]);
  455.         $gameMessage.setBackground(this._params[2]);
  456.         $gameMessage.setPositionType(this._params[3]);
  457.         $gameMessage.setBust(this._params[0],this._params[1]);
  458.         while (this.nextEventCode() === 401) {  // Text data
  459.             this._index++;
  460.             $gameMessage.add(this.currentCommand().parameters[0]);
  461.         }
  462.         switch (this.nextEventCode()) {
  463.         case 102:  // Show Choices
  464.             this._index++;
  465.             this.setupChoices(this.currentCommand().parameters);
  466.             break;
  467.         case 103:  // Input Number
  468.             this._index++;
  469.             this.setupNumInput(this.currentCommand().parameters);
  470.             break;
  471.         case 104:  // Select Item
  472.             this._index++;
  473.             this.setupItemChoice(this.currentCommand().parameters);
  474.             break;
  475.         }
  476.         this._index++;
  477.         this.setWaitMode('message');
  478.     }
  479.     return false;
  480. };
  481. })();
  482. //===============================================================================
  483. // => END : Game_Interpreter
  484. //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement