Foure4

CallMenu

Nov 9th, 2018 (edited)
3,802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=============================================================================
  2.  *  CallMenu.js
  3.  *=============================================================================*/
  4.  
  5. var Imported = Imported || {};
  6. Imported.CallMenu = true;
  7.  
  8. /*:=============================================================================
  9. * @plugindesc v1.5 Call menu during messages\choices on map by pressing one of the standard menu keys ESC, X, Insert, NUM 0.
  10. * @author Krimer
  11. * @help
  12. * If you want call menu during choices just disallow cancel in choice command.
  13. * Place this plugin below non-standard message systems or choice windows in
  14. * plugin manager for better compatibility.
  15.  
  16. * =============================================================================*/
  17.  
  18. /*=============================================================================*/
  19. /* Alias */
  20. var _Game_Temp_initialize_Alias = Game_Temp.prototype.initialize;
  21. Game_Temp.prototype.initialize = function() {
  22.     _Game_Temp_initialize_Alias.call(this)
  23.     this._lastSelectedChoice = null;
  24. };
  25.  
  26. /* NEW */
  27. Game_Temp.prototype.setLastSelectedChoice = function(f) {
  28.     this._lastSelectedChoice = f
  29. };
  30. /* NEW */
  31. Game_Temp.prototype.getLastSelectedChoice = function() {
  32.     return this._lastSelectedChoice
  33. };
  34. /* Alias */
  35. var _Window_ChoiceList_callOkHandler = Window_ChoiceList.prototype.callOkHandler
  36. Window_ChoiceList.prototype.callOkHandler = function() {
  37.     $gameTemp.setLastSelectedChoice(null)
  38.     _Window_ChoiceList_callOkHandler.call(this);
  39. };
  40. /* Alias */
  41. var _Window_ChoiceList_callCancelHandler = Window_ChoiceList.prototype.callCancelHandler
  42. Window_ChoiceList.prototype.callCancelHandler = function() {
  43.     $gameTemp.setLastSelectedChoice(null)
  44.     _Window_ChoiceList_callCancelHandler.call(this);
  45. };
  46. /* Alias */
  47. var _Window_ChoiceList_selectDefault = Window_ChoiceList.prototype.selectDefault
  48. Window_ChoiceList.prototype.selectDefault = function() {
  49.     if ($gameTemp.getLastSelectedChoice() !== null){
  50.         this.select($gameTemp.getLastSelectedChoice());
  51.     } else {
  52.         _Window_ChoiceList_selectDefault.call(this);
  53.     }  
  54. };
  55. /* Alias*/
  56. var _Window_ChoiceList_update = Window_ChoiceList.prototype.update
  57. Window_ChoiceList.prototype.update = function() {
  58.     _Window_ChoiceList_update.call(this);
  59.      if ((Input.isTriggered('escape') || Input.isTriggered('menu') || TouchInput.isCancelled()) && $gameMessage.isBusy() && $gameSystem.isMenuEnabled()) {
  60.         $gameTemp.setLastSelectedChoice(this._index)
  61.     }
  62.  
  63. };
  64.  
  65. /* Alias */
  66. var _DataManager_makeSaveContents_Alias = DataManager.makeSaveContents;
  67. DataManager.makeSaveContents = function () {
  68.     var contents = _DataManager_makeSaveContents_Alias.call(this);
  69.     contents.message = $gameMessage;
  70.    
  71.     return contents;
  72. };
  73. /* Alias */
  74. var _DataManager_extractSaveContents_Alias = DataManager.extractSaveContents;
  75. DataManager.extractSaveContents = function (contents) {
  76.     _DataManager_extractSaveContents_Alias.call(this, contents);
  77.     $gameMessage = contents.message;
  78.     if ($gameMessage._choices.length !== 0) {
  79.         $gameMessage.setChoiceCallback(function(n) {
  80.            $gameMap._interpreter._branch[$gameMap._interpreter._indent] = n;
  81.         }.bind(this));
  82.     }
  83. };
  84. /* Alias */
  85. var _Scene_Map_update_Alias = Scene_Map.prototype.update;
  86. Scene_Map.prototype.update = function () {
  87.     _Scene_Map_update_Alias.call(this);
  88.     if ((Input.isTriggered('escape') || Input.isTriggered('menu') || TouchInput.isCancelled()) && $gameMessage.isBusy() && $gameSystem.isMenuEnabled()) {
  89.         this.callMenu();
  90.     }
  91. };
  92. /* OVERWRITE */
  93. Window_Message.prototype.isTriggered = function () {
  94.     return (Input.isRepeated('ok') || TouchInput.isRepeated());
  95. };
  96. /* Alias */
  97. var _Window_ChoiceList_WidthEx_Alias = Window_ChoiceList.prototype.textWidthEx;
  98. Window_ChoiceList.prototype.textWidthEx = function (text) {
  99.     if(!SceneManager._scene.isActive()) return;
  100.     return _Window_ChoiceList_WidthEx_Alias.call(this, text);
  101. };
  102. /* HIME_HiddenChoiceConditions Compatibility */
  103. var _Window_ChoiceList_makeCommandList_Alias = Window_ChoiceList.prototype.makeCommandList
  104. Window_ChoiceList.prototype.makeCommandList = function() {
  105.     if(!SceneManager._scene.isActive()) return;
  106.     _Window_ChoiceList_makeCommandList_Alias.call(this);
  107. }
  108. /* Galv_VisualNovelChoices Compatibility */
  109. if (Imported.Galv_VisualNovelChoices) {
  110.     var _Window_ChoiceList_drawItem_Alias = Window_ChoiceList.prototype.drawItem
  111.     Window_ChoiceList.prototype.drawItem = function(index) {
  112.     if(typeof this.choice_background === 'undefined'){
  113.         this.choice_background = [];
  114.     };
  115.         _Window_ChoiceList_drawItem_Alias.call(this, index);
  116.     };
  117. }
  118. /* SRD_TitleCommandCustomizer Compatibility */
  119. if (Imported["SumRndmDde Title Command Customizer"]) {
  120.     var _Scene_Title_createMessageWindow_Alias = Scene_Title.prototype.createMessageWindow
  121.     Scene_Title.prototype.createMessageWindow = function() {
  122.         $gameMessage.clear();
  123.         _Scene_Title_createMessageWindow_Alias.call(this)
  124.        
  125.     };
  126. }
  127.  
  128. /* End of File */
  129. /*=============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment