Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
55
Reaction score
18
First Language
English
Primarily Uses
Message Window Hide
by Jatopian​

Introduction
This plugin lets the player toggle whether or not the message window is shown, by pressing a button.

Features
+ Lets the player get a better look at your beautiful graphics in cutscenes.
+ Developer can configure what buttons are used to toggle.
+ Plugin command allows game events to turn message window back on - can be used to help with forgetful players wondering why they can't see NPC dialogue.
+ For even more foolproof design, a parameter option lets the developer have the message window automatically return on each new page of text.

How to Use
Should be straightforward plug&play. Button(s) that activates the feature is configurable as parameters.

Terms of Use
* Free for commercial and non-commercial use.
* Please give credit in a trivially accessible place.
* OK to modify, but if you redistribute the modified version, please make clear that you modified it, and how.
* If you add features that could be useful to others, please at least consider sharing them with the community.

Code:
//=============================================================================
// MessageHide.js                                                             
//=============================================================================
 
/*:
@plugindesc v1.3.0 Define buttons the player can press to toggle whether the message window is shown.
@author Jatopian

@param key
@desc Keys/buttons that toggle message window visibility when pressed. Separate values with a space. See help for list.
@default pageup h

@param right click
@desc Whether right click can toggle message window visibility. true / false
@default true

@param show on new page
@desc Whether the message window automatically becomes visible on a new page of dialogue. true / false
@default true

@help
Message window visibility is reset by pressing the key again, 
or resetting the game.
Game events can also make it happen with plugin command: ShowMessageWindow
With "show on new page" param true, visibility is reset for each new message window page.

"key" parameter takes multiple values separated by a space.
For example: "pageup h" will define H and PageUp keys (and keys synonymous with PageUp like gamepad side buttons).
Gamepad-compatible values:
ok       //      A
cancel   //      B
shift    //      X
menu     //      Y
pageup   //      LB
pagedown //      RB
up
down
left
right
Keyboard-only values: 
a-z
0-9
tab
enter
shift
ctrl
alt
space
semicolon
comma
period
quote

Terms of Use:
- Free for commercial and non-commercial use.
- Please give credit in a trivially accessible place.
- OK to modify, but if you redistribute the modified version, 
  please make clear that you modified it, and how.
- If you add features that could be useful to others, 
  please at least consider sharing them with me and the community.

Changelog:
1.3.0: 
Parameter to hide window with right click. (Thanks Magnus0808 || Magnus Rubin Peterson.)
1.2.0:
Ability to define multiple keys.
Defaults to "show on new page" behavior rather than undefined behavior if param not set.
Gamepad support fixes.
Yanfly Message Core NameBox compatibility. (Thanks mdqp!)
1.1.0: 
Show/hide now persists between maps and when bringing up the menu.
"show on new page" feature.
*/

(function() {
  var params = PluginManager.parameters("MessageHide");
  var pKey = String(params["key"]).toLowerCase().split(" ");
  var pRightClick = (function() {  
    var p = String(params["right click"]).toLowerCase();
    if (p.match(/false/i)) {
      return false;
    }
    return true;
  })();
  var pNewPage = (function() {  
    var p = String(params["show on new page"]).toLowerCase();
    if (p.match(/false/i)) {
      return false;
    }
    return true;
  })();
  
  var key_ids = {
    "tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"space":32,
    "0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":57,
    "a":65,"b":66,"c":67,"d":68,"e":69,"f":70,"g":71,"h":72,"i":73,"j":74,"k":75,"l":76,"m":77,
    "n":78,"o":79,"p":80,"q":81,"r":82,"s":83,"t":84,"u":85,"v":86,"w":87,"x":88,"y":89,"z":90,
    "semicolon":186,"comma":188,"period":190,"quote":222,
    "pageup":33,"pagedown":34,
  };
  
  for (var p of pKey) {
    console.log("MessageHide button defined: " + p);
    if (key_ids[p]) { // if key is listed in key_ids
      if (!Input.keyMapper[key_ids[p]]) { // if key isn't already registered with keyMapper
        Input.keyMapper[key_ids[p]] = p; // add it to keyMapper, with label from key_ids
      }
    } else {
      if (!Input.keyMapper[p]) { // if key is not already registered with keyMapper and also not in key_ids
        console.log("Unrecognized MessageHide button defined - deleting: " + p);
        delete pKey[p]; // delete value from pKey so it isn't fruitlessly checked later
      }
    }
  }
  //global variables!
  MessageHide_messageWindowShowNext = false;
  MessageHide_messageWindowVisible = true; //global to persist between maps
  
  //===========================================================================
  // Window Message
  //===========================================================================
  
  Window_Message.prototype.isToggleHide = function() {
    for (var p of pKey) {
      if (Input.isTriggered(p)) return true;
    }
    return false;
  }
  
  var alias_wm_ud = Window_Message.prototype.update;
  Window_Message.prototype.update = function() {
    alias_wm_ud.call(this);
    if (MessageHide_messageWindowShowNext === true) {
      MessageHide_messageWindowVisible = true;
      MessageHide_messageWindowShowNext = false;
    } else if (this.isToggleHide()) {
      MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
    }
    this.visible = MessageHide_messageWindowVisible;
  }
  
  var alias_wm_np = Window_Message.prototype.newPage;
  Window_Message.prototype.newPage = function(textState) {
    alias_wm_np.call(this, textState);
    if (pNewPage) MessageHide_messageWindowVisible = true;
  }
  
  //===========================================================================
  // Game Interpreter
  //===========================================================================
  
  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
      alias_Game_Interpreter_pluginCommand.call(this, command, args);
      if (command === "ShowMessageWindow") {
        MessageHide_messageWindowShowNext = true;
      }
  }
  
  //===========================================================================
  // Window NameBox (Yanfly Message Core compatibility)
  //===========================================================================
  
  if (Imported.YEP_MessageCore) {
    var alias_wm_nb = Window_NameBox.prototype.update;
    Window_NameBox.prototype.update = function() {
      alias_wm_nb.call(this);
      if ($gameMessage.isToggleHide) {
        this.visible = MessageHide_messageWindowVisible;
      }
    }
  }
  
  if (pRightClick) {
    var MRP_HIDERIGHTCLICK_WM_UPDATE_OLD = Window_Message.prototype.update;
    Window_Message.prototype.update = function() {
      MRP_HIDERIGHTCLICK_WM_UPDATE_OLD.call(this);
      this.processRightClick();
    };
    
    Window_Message.prototype.processRightClick = function() {
      if(this.isOpen() && this.active && TouchInput.isCancelled()){
        MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
      }
    };
    
    if(Imported.YEP_MessageCore){
      var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
      Window_NameBox.prototype.update = function() {
        MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);    
        if(this._parentWindow.isOpen() && this.isOpen())
        {
          this.visible = this._parentWindow.visible;            
        } 
      }
    }
  }
})();
 
Last edited:

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
55
Reaction score
18
First Language
English
Primarily Uses
In response to some private feedback, I have updated the script to version 1.1.0.

The message window no longer resets to visibility on opening the menu or changing maps.

I have also added a config option that makes the message window automatically return on each new page of text, for devs extra worried about forgetful players.
 
Last edited:

phamtruong1992

Green Dragon
Veteran
Joined
Nov 22, 2015
Messages
207
Reaction score
234
First Language
English
Primarily Uses
RMMV
It sounds interesting so i downloaded it for testing purpose, but it didn't work anymore, dude. I'm kind of wanting to see it in action too.
 

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
55
Reaction score
18
First Language
English
Primarily Uses
It sounds interesting so i downloaded it for testing purpose, but it didn't work anymore, dude.
The last version was included in a commercial project, so a lot of players tested it. I do not know why it does not work for you, but you may want to try the plugin support forum, paying special attention to this thread.
 

phamtruong1992

Green Dragon
Veteran
Joined
Nov 22, 2015
Messages
207
Reaction score
234
First Language
English
Primarily Uses
RMMV
Wow, 1 like for your quick reply. I guess I will have to try to turn off some related plugins to see if it works.
 

mdqp

Veteran
Veteran
Joined
Jun 2, 2014
Messages
45
Reaction score
8
First Language
Italian
Primarily Uses
Hello there! I like this script a lot and I am considering using it. Am I right that to make it work with Yanfly's message plugin, I'd just need to alias his "name window" in a manner similar to how you alias the message box, so that both disappear when the right key is pressed?

Edit: I figured it out on my own! Thanks again for this great plugin. :)
 
Last edited:

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
55
Reaction score
18
First Language
English
Primarily Uses
Hello there! I like this script a lot and I am considering using it. Am I right that to make it work with Yanfly's message plugin, I'd just need to alias his "name window" in a manner similar to how you alias the message box, so that both disappear when the right key is pressed?

Edit: I figured it out on my own! Thanks again for this great plugin. :)
Hey, sorry for not replying. This busy week has been something of a blur for me, and I missed the notification initially. Glad to hear you figured it out! If you don't mind sharing your solution and which Yanfly script you mean, I'd be interested in improving compatibility with Yanfly scripts, as so many people use them.
 

mdqp

Veteran
Veteran
Joined
Jun 2, 2014
Messages
45
Reaction score
8
First Language
Italian
Primarily Uses
Hey, sorry for not replying. This busy week has been something of a blur for me, and I missed the notification initially. Glad to hear you figured it out! If you don't mind sharing your solution and which Yanfly script you mean, I'd be interested in improving compatibility with Yanfly scripts, as so many people use them.

Sure! The problem was with Yanfly's message core. Most of it is fine without changes, but it gives you the option to add a "name window" on top of the normal message window (to show the name of whoever is talking). Since it's a separate window, it didn't hide together with the message window. All I did was copy paste parts of your plugin, and tweak them as needed:

Code:
var alias_wm_nb = Window_NameBox.prototype.update;
  Window_NameBox.prototype.update = function() {
    alias_wm_nb.call(this);
    if (Input.isTriggered("messageHide") === true) {
     this.visible = MessageHide_messageWindowVisible;
    }
  }

I butchered it, as I was just interested in a quick solution to my issue, but it works just fine.
 

Dethroner

Villager
Member
Joined
Jun 21, 2016
Messages
12
Reaction score
3
First Language
Rus
Primarily Uses
RMMV
Hi! Your plugin is just what I need.
But I have a question: is it possible to trigger hide/show window by command or script call without using keys?
Thank you!
 

uuuuuu1515

Warper
Member
Joined
Jul 7, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
Never mind I saw it. Thanks, you guys!
 
Last edited:

cedr777

Veteran
Veteran
Joined
Feb 22, 2018
Messages
267
Reaction score
62
First Language
Not English
Primarily Uses
RMMV
Bug report. Did the code above but sometimes a blank box would appear at the top left of the screen.
DLHNoR4.png


Edit: the problem is gone now, I don't know why. Must be another plugin I was using interfering with it.
 
Last edited:

cedr777

Veteran
Veteran
Joined
Feb 22, 2018
Messages
267
Reaction score
62
First Language
Not English
Primarily Uses
RMMV
If anyone is interested, I made a request here, to have this plugin support mouse button right click as if it was in a visual novel.

all credit goes to Magnus0808
 
Last edited:
Joined
Apr 18, 2019
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Curious if this could be made to be compatible with YEP_KeyboardConfig?
YEP_KeyboardConfig seems to prevent this from working but it does work with the mouse right click support made by Magnus0808 so I suspect something is messing with the input capture.

While playing with this I noticed a problem similar to what cedr777 had posted on Feb 17, 2019 with the odd box in the top corner which seems to be caused by a blank Window_NameBox from YEP_MessageCore being told to be visible. Changed Magnus0808's plugin slightly to correct that issue:

Code:
    if(Imported.YEP_MessageCore){
        var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
        Window_NameBox.prototype.update = function() {
            MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);
            if(this._lastNameText != '') // Changed to check if Namebox has content
            {
                this.visible = this._parentWindow.visible;        
            }
        }
    }

Thanks for the nice plugin!
 

cedr777

Veteran
Veteran
Joined
Feb 22, 2018
Messages
267
Reaction score
62
First Language
Not English
Primarily Uses
RMMV
Worked like a charm, thanks.
To those wondering where to put the code. It's supposed to go in MRP_MessageHideOnRightClick.js
 

kako05

Veteran
Veteran
Joined
Sep 11, 2017
Messages
187
Reaction score
28
First Language
Australian
Primarily Uses
RMMV
Doesn't work with yanfly keyboard config. It would be great if it was fixed :)
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
531
Reaction score
278
First Language
thai
Primarily Uses
RMMV
hi thereportingbug cedr777
I try to edit code like this
but the still there could you please check out what I done wrong
or upload the work version please
thank you

Code:
//=============================================================================
// Message Hide On Right Click
// MRP_MessageHideOnRightClick.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

var Imported = Imported || {};

/*:
 * @plugindesc MessageHide Extension. Hide message on right click.
 * @author Magnus0808
 *
 * @help Plug and play. Put after MessageHide.
*/

(function(){
    var MRP_HIDERIGHTCLICK_WM_UPDATE_OLD = Window_Message.prototype.update;
    Window_Message.prototype.update = function() {
        MRP_HIDERIGHTCLICK_WM_UPDATE_OLD.call(this);
        this.processRightClick();
    };
    
    Window_Message.prototype.isOpenAndActive = function() {
        return this.isOpen() && this.active;
    };
    
    var MRP_HIDERIGHTCLICK_WM_UPDATEINPUT_OLD = Window_Message.prototype.updateInput;
    Window_Message.prototype.updateInput = function() {
        if(this.pause && this.isTriggered() && !this.visible) {
            return true;
        }
        return MRP_HIDERIGHTCLICK_WM_UPDATEINPUT_OLD.call(this);
    };
    
    Window_Message.prototype.processRightClick = function() {
        if(this.isOpenAndActive() && TouchInput.isCancelled()){
            MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
        }
    };
    
    /*if(Imported.YEP_MessageCore){
        var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
        Window_NameBox.prototype.update = function() {
            MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);   
            if(this._parentWindow.isOpen())
            {
                this.visible = this._parentWindow.visible;           
            }
        }
    }*/
    if(Imported.YEP_MessageCore){       
       var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
        Window_NameBox.prototype.update = function() {
            MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);
            this.visible = this._parentWindow.visible;
            if(this._lastNameText != '') // Changed to check if Namebox has content
            {
                this.visible = this._parentWindow.visible;       
            }
        }
    }   
})();
 
Joined
Apr 18, 2019
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Well pasunna, it looks like you are setting visibility for the NameBox twice in the block if(Imported.YEP_MessageCore) (1st just going with whatever the parent window is then 2nd doing so only if the NameBox contains something so the 1st will always change visibility regardless of if it should)

Here are the current scripts I have (modified from the originals)

MessageHide.js
Code:
//=============================================================================
// MessageHide.js                                                         
//=============================================================================
 
/*:
@plugindesc v1.1.0 Define a key the player can press to toggle whether the message window is shown.
@author Jatopian

@param key
@desc Key that toggles message window visibility when pressed. See help for list.
@default ctrl

@param show on new page
@desc Whether the message window automatically becomes visible on a new page of dialogue. true / false
@default false

@help
Message window visibility is reset by pressing the key again,
or resetting the game.
Game events can also make it happen with plugin command: ShowMessageWindow
With "show on new page" param true,
visibility is reset for each new message window page.

"key" parameter takes values:
a-z
0-9
tab
enter
shift
ctrl
alt
space
semicolon
comma
period
quote
And also gamepad-compatible values:
ok       //      A
cancel   //      B
shift    //      X
menu     //      Y
pageup   //      LB
pagedown //      RB
up       //      D-pad up
down     //      D-pad down
left     //      D-pad left
right    //      D-pad right

Terms of Use:
- Free for commercial and non-commercial use.
- Please give credit in a trivially accessible place.
- OK to modify, but if you redistribute the modified version,
  please make clear that you modified it, and how.
- If you add features that could be useful to others,
  please at least consider sharing them with me and the community.

Changelog:
1.1.0:
Show/hide now persists between maps and when bringing up the menu.
"show on new page" feature.
*/

var Imported = Imported || {};
Imported.MessageHide = true;

(function() {
  var params = PluginManager.parameters("MessageHide");
  var pKey = String(params["key"]).toLowerCase();
  var pNewPage = (function() {
    var p = String(params["show on new page"]).toLowerCase();
    if (p.match(/true/i)) {
      return true;
    } else if (p.match(/false/i)) {
      return false;
    } else {
      return Utils.isNwjs();
    }
  })();
 
  var key_ids = {
    "tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"space":32,"home":36,
    "0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":57,
    "a":65,"b":66,"c":67,"d":68,"e":69,"f":70,"g":71,"h":72,"i":73,"j":74,"k":75,"l":76,"m":77,
    "n":78,"o":79,"p":80,"q":81,"r":82,"s":83,"t":84,"u":85,"v":86,"w":87,"x":88,"y":89,"z":90,
    "semicolon":186,"comma":188,"period":190,"quote":222,
  };
 
  Input.keyMapper[key_ids[pKey]] = "messageHide";
 
  //global variables!
  MessageHide_messageWindowShowNext = false;
  MessageHide_messageWindowVisible = true; //global to persist between maps
 
  //=============================================================================
  // Window Message
  //=============================================================================
 
  var alias_wm_ud = Window_Message.prototype.update;
  Window_Message.prototype.update = function() {
    alias_wm_ud.call(this);
    if (MessageHide_messageWindowShowNext === true) {
      MessageHide_messageWindowVisible = true;
      MessageHide_messageWindowShowNext = false;
    } else if (Input.isTriggered("messageHide") === true) {
      MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
    }
    this.visible = MessageHide_messageWindowVisible;
  }

 if(Imported.YEP_MessageCore){
   var alias_wm_nb = Window_NameBox.prototype.update;
   Window_NameBox.prototype.update = function() {
     alias_wm_nb.call(this);
     if (Input.isTriggered("messageHide") === true) {
      if(this._lastNameText != '') // Changed to check if Namebox has content
      {
       this.visible = MessageHide_messageWindowVisible;
      }
     }
   }
 }
 
  var alias_wm_np = Window_Message.prototype.newPage;
  Window_Message.prototype.newPage = function(textState) {
    alias_wm_np.call(this, textState);
    if (pNewPage) MessageHide_messageWindowVisible = true;
  }
 
  //=============================================================================
  // Game Interpreter
  //=============================================================================
 
  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
      alias_Game_Interpreter_pluginCommand.call(this, command, args);
      if (command === "ShowMessageWindow") {
        MessageHide_messageWindowShowNext = true;
      }
  }
 
})();
MRP_MessageHideOnRightClick.js
Code:
//=============================================================================
// Message Hide On Right Click
// MRP_MessageHideOnRightClick.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

var Imported = Imported || {};

/*:
 * @plugindesc MessageHide Extension. Hide message on right click.
 * @author Magnus0808
 *
 * @help Plug and play. Put after MessageHide.
*/

(function(){
    var MRP_HIDERIGHTCLICK_WM_UPDATE_OLD = Window_Message.prototype.update;
    Window_Message.prototype.update = function() {
        MRP_HIDERIGHTCLICK_WM_UPDATE_OLD.call(this);
        this.processRightClick();
    };
 
    Window_Message.prototype.isOpenAndActive = function() {
        return this.isOpen() && this.active;
    };
 
    var MRP_HIDERIGHTCLICK_WM_UPDATEINPUT_OLD = Window_Message.prototype.updateInput;
    Window_Message.prototype.updateInput = function() {
        if(this.pause && this.isTriggered() && !this.visible) {
            return true;
        }
        return MRP_HIDERIGHTCLICK_WM_UPDATEINPUT_OLD.call(this);
    };
 
    Window_Message.prototype.processRightClick = function() {
        if(this.isOpenAndActive() && TouchInput.isCancelled()){
            MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
        }
    };
 
    if(Imported.YEP_MessageCore){
        var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
        Window_NameBox.prototype.update = function() {
            MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);
            if(this._lastNameText != '') // Changed to check if Namebox has content
            {
                this.visible = this._parentWindow.visible;       
            }
        }
    }

})();
 
Last edited:

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
531
Reaction score
278
First Language
thai
Primarily Uses
RMMV
thank you thereportingbug
sorry I forgot to delete that line I'm testing it
but now I use your code it's still there too
then... I find out...
I have two set of copy of these plugins in my editer -....-
just delet one of them and the problem is solve now
thank you
 

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
55
Reaction score
18
First Language
English
Primarily Uses
Doesn't work with yanfly keyboard config. It would be great if it was fixed
Oh hey, I was unsubscribed from my own thread somehow. Uh, I don't know if this will fix your problem, or if you even still care, but I've just updated the plugin version to 1.2.0 and I think the way it works under the hood should be more compatible with other plugins in general.

Other changes in this version:
Ability to define multiple keys.
Yanfly Message Core NameBox compatibility. (Thanks mdqp!)
Gamepad support fixes.
Defaults to "show on new page" behavior rather than undefined behavior if param not set.
 

masterdragonson

Villager
Member
Joined
Dec 8, 2014
Messages
10
Reaction score
3
First Language
English
Primarily Uses
Small tweak in the event someone wants the message to remain paused until the user restores visibility.
Mostly added this in the event I Right Click then Left Click.

Added parameter "pause until visible"
When set to "true" prevents the message window from advancing to the next line unless the user makes the window visible.

You can use something like WinMerge to compare the changes to the original.
The main addition is
JavaScript:
  var alias_wm_udInput = Window_Message.prototype.updateInput;
  Window_Message.prototype.updateInput = function() {
    if (pPauseTransition) {
      if(this.pause && this.isTriggered() && !this.visible) {
        return true;
      }
    }
    return alias_wm_udInput.call(this);
  };

Full Code
JavaScript:
//=============================================================================
// MessageHide.js                                                             
//=============================================================================
 
/*:
@plugindesc v1.3.0 Define buttons the player can press to toggle whether the message window is shown.
@author Jatopian

@param key
@desc Keys/buttons that toggle message window visibility when pressed. Separate values with a space. See help for list.
@default pageup h

@param right click
@desc Whether right click can toggle message window visibility. true / false
@default true

@param show on new page
@desc Whether the message window automatically becomes visible on a new page of dialogue. true / false
@default true

@param pause until visible
@desc Whether the message window advances while invisible to a new page of dialogue. true / false
@default false

@help
Message window visibility is reset by pressing the key again, 
or resetting the game.
Game events can also make it happen with plugin command: ShowMessageWindow
With "show on new page" param true, visibility is reset for each new message window page.
With "pause until visible" param true, visibility is required to advance to a new message window page.

"key" parameter takes multiple values separated by a space.
For example: "pageup h" will define H and PageUp keys (and keys synonymous with PageUp like gamepad side buttons).
Gamepad-compatible values:
ok       //      A
cancel   //      B
shift    //      X
menu     //      Y
pageup   //      LB
pagedown //      RB
up
down
left
right
Keyboard-only values: 
a-z
0-9
tab
enter
shift
ctrl
alt
space
semicolon
comma
period
quote

Terms of Use:
- Free for commercial and non-commercial use.
- Please give credit in a trivially accessible place.
- OK to modify, but if you redistribute the modified version, 
  please make clear that you modified it, and how.
- If you add features that could be useful to others, 
  please at least consider sharing them with me and the community.

Changelog:
1.3.0: 
Parameter to hide window with right click. (Thanks Magnus0808 || Magnus Rubin Peterson.)
1.2.0:
Ability to define multiple keys.
Defaults to "show on new page" behavior rather than undefined behavior if param not set.
Gamepad support fixes.
Yanfly Message Core NameBox compatibility. (Thanks mdqp!)
1.1.0: 
Show/hide now persists between maps and when bringing up the menu.
"show on new page" feature.
*/

(function() {
  var params = PluginManager.parameters("MessageHide");
  var pKey = String(params["key"]).toLowerCase().split(" ");
  var pRightClick = (function() {  
    var p = String(params["right click"]).toLowerCase();
    if (p.match(/false/i)) {
      return false;
    }
    return true;
  })();
  var pNewPage = (function() {  
    var p = String(params["show on new page"]).toLowerCase();
    if (p.match(/false/i)) {
      return false;
    }
    return true;
  })();
  var pPauseTransition = (function() {  
    var p = String(params["pause until visible"]).toLowerCase();
    if (p.match(/false/i)) {
      return false;
    }
    return true;
  })();
  
  var key_ids = {
    "tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"space":32,
    "0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":57,
    "a":65,"b":66,"c":67,"d":68,"e":69,"f":70,"g":71,"h":72,"i":73,"j":74,"k":75,"l":76,"m":77,
    "n":78,"o":79,"p":80,"q":81,"r":82,"s":83,"t":84,"u":85,"v":86,"w":87,"x":88,"y":89,"z":90,
    "semicolon":186,"comma":188,"period":190,"quote":222,
    "pageup":33,"pagedown":34,
  };
  
  for (var p of pKey) {
    console.log("MessageHide button defined: " + p);
    if (key_ids[p]) { // if key is listed in key_ids
      if (!Input.keyMapper[key_ids[p]]) { // if key isn't already registered with keyMapper
        Input.keyMapper[key_ids[p]] = p; // add it to keyMapper, with label from key_ids
      }
    } else {
      if (!Input.keyMapper[p]) { // if key is not already registered with keyMapper and also not in key_ids
        console.log("Unrecognized MessageHide button defined - deleting: " + p);
        delete pKey[p]; // delete value from pKey so it isn't fruitlessly checked later
      }
    }
  }
  //global variables!
  MessageHide_messageWindowShowNext = false;
  MessageHide_messageWindowVisible = true; //global to persist between maps
  
  //===========================================================================
  // Window Message
  //===========================================================================
  
  Window_Message.prototype.isToggleHide = function() {
    for (var p of pKey) {
      if (Input.isTriggered(p)) return true;
    }
    return false;
  }
  
  var alias_wm_udInput = Window_Message.prototype.updateInput;
  Window_Message.prototype.updateInput = function() {
    if (pPauseTransition) {
      if(this.pause && this.isTriggered() && !this.visible) {
        return true;
      }
    }
    return alias_wm_udInput.call(this);
  };
  
  var alias_wm_ud = Window_Message.prototype.update;
  Window_Message.prototype.update = function() {
    alias_wm_ud.call(this);
    if (MessageHide_messageWindowShowNext === true) {
      MessageHide_messageWindowVisible = true;
      MessageHide_messageWindowShowNext = false;
    } else if (this.isToggleHide()) {
      MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
    }
    this.visible = MessageHide_messageWindowVisible;
  }
  
  var alias_wm_np = Window_Message.prototype.newPage;
  Window_Message.prototype.newPage = function(textState) {
    alias_wm_np.call(this, textState);
    if (pNewPage) MessageHide_messageWindowVisible = true;
  }
  
  //===========================================================================
  // Game Interpreter
  //===========================================================================
  
  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
      alias_Game_Interpreter_pluginCommand.call(this, command, args);
      if (command === "ShowMessageWindow") {
        MessageHide_messageWindowShowNext = true;
      }
  }
  
  //===========================================================================
  // Window NameBox (Yanfly Message Core compatibility)
  //===========================================================================
  
  if (Imported.YEP_MessageCore) {
    var alias_wm_nb = Window_NameBox.prototype.update;
    Window_NameBox.prototype.update = function() {
      alias_wm_nb.call(this);
      if ($gameMessage.isToggleHide) {
        this.visible = MessageHide_messageWindowVisible;
      }
    }
  }
  
  if (pRightClick) {
    var MRP_HIDERIGHTCLICK_WM_UPDATE_OLD = Window_Message.prototype.update;
    Window_Message.prototype.update = function() {
      MRP_HIDERIGHTCLICK_WM_UPDATE_OLD.call(this);
      this.processRightClick();
    };
    
    Window_Message.prototype.processRightClick = function() {
      if(this.isOpen() && this.active && TouchInput.isCancelled()){
        MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
      }
    };
    
    if(Imported.YEP_MessageCore){
      var MRP_HIDERIGHTCLICK_WNB_UPDATE = Window_NameBox.prototype.update;
      Window_NameBox.prototype.update = function() {
        MRP_HIDERIGHTCLICK_WNB_UPDATE.call(this);    
        if(this._parentWindow.isOpen() && this.isOpen())
        {
          this.visible = this._parentWindow.visible;            
        } 
      }
    }
  }
})();
 

Latest Threads

Latest Posts

Latest Profile Posts

Feel free to check out our "Touch the Stars" gamejam submission, "Starlight, Starbright!"
just finished playing one shot. im kinda disappointed with return the sun ending ngl. i was hoping there would be some after credits scene that would play with my emotions
So apparently the surprise Google Search page browser game saves your progress when you close the browser.

This really makes me miss the golden age of Flash gaming.
ohh man im ending oneshot now (im doing the last stepping puzzle rn) and the music is so...sad...like...ive been thinking recently about how fast moments pass and...my anxious thoughts combined with that music and nostalgia...like...im comfortably sad...and want to cry internally
We're playing one of the Touch the Stars game jam entries, come join us!

Forum statistics

Threads
113,551
Messages
1,075,788
Members
147,549
Latest member
Rob_Rodrigues
Top