Message Window Hide

Discussion in 'JS Plugin Releases (RMMV)' started by Jatopian, Nov 23, 2016.

  1. Jatopian

    Jatopian Veteran Veteran

    Messages:
    44
    Likes Received:
    13
    First Language:
    English
    Message Window Hide
    by Jatopian​

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

    Features
    + Lets the player get a better look at your beautiful graphics in cutscenes.
    + Developer can configure what key is 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 config option lets the developer have the message window automatically return on each new page of text.

    How to Use
    Should be straightforward plug&play. Key that activates the feature is configurable as a parameter. I'm not aware of any bugs or compatibility issues.

    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.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.
    */
    
    (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,
        "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;
      }
     
      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;
          }
      }
     
    })();
     
    Last edited: Feb 6, 2017
    #1
    cedr777, mdqp, Kyuukon and 2 others like this.
  2. Jatopian

    Jatopian Veteran Veteran

    Messages:
    44
    Likes Received:
    13
    First Language:
    English
    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: Feb 6, 2017
    #2
  3. phamtruong1992

    phamtruong1992 Mage Art - Green Dragon Veteran

    Messages:
    146
    Likes Received:
    180
    Location:
    South Asia
    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.
     
    #3
  4. Jatopian

    Jatopian Veteran Veteran

    Messages:
    44
    Likes Received:
    13
    First Language:
    English
    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.
     
    #4
    uuuuuu1515 and phamtruong1992 like this.
  5. phamtruong1992

    phamtruong1992 Mage Art - Green Dragon Veteran

    Messages:
    146
    Likes Received:
    180
    Location:
    South Asia
    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.
     
    #5
  6. mdqp

    mdqp Veteran Veteran

    Messages:
    39
    Likes Received:
    8
    First Language:
    Italian
    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: Apr 26, 2018
    #6
  7. Jatopian

    Jatopian Veteran Veteran

    Messages:
    44
    Likes Received:
    13
    First Language:
    English
    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.
     
    #7
    mdqp likes this.
  8. mdqp

    mdqp Veteran Veteran

    Messages:
    39
    Likes Received:
    8
    First Language:
    Italian
    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.
     
    #8
  9. Dethroner

    Dethroner Villager Member

    Messages:
    12
    Likes Received:
    3
    Location:
    UK
    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!
     
    #9
  10. uuuuuu1515

    uuuuuu1515 Warper Member

    Messages:
    3
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    Never mind I saw it. Thanks, you guys!
     
    Last edited: Nov 30, 2018
    #10
  11. cedr777

    cedr777 Lead developer of "Charao Life" Veteran

    Messages:
    219
    Likes Received:
    51
    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.
    [​IMG]

    Edit: the problem is gone now, I don't know why. Must be another plugin I was using interfering with it.
     
    Last edited: Mar 7, 2019
    #11
  12. cedr777

    cedr777 Lead developer of "Charao Life" Veteran

    Messages:
    219
    Likes Received:
    51
    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: Mar 8, 2019
    #12
  13. thereportingbug

    thereportingbug Warper Member

    Messages:
    2
    Likes Received:
    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!
     
    #13
    cedr777 likes this.
  14. cedr777

    cedr777 Lead developer of "Charao Life" Veteran

    Messages:
    219
    Likes Received:
    51
    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
     
    #14
  15. kako05

    kako05 Veteran Veteran

    Messages:
    89
    Likes Received:
    4
    First Language:
    Australian
    Primarily Uses:
    RMMV
    Doesn't work with yanfly keyboard config. It would be great if it was fixed :)
     
    #15
  16. pasunna

    pasunna Veteran Veteran

    Messages:
    120
    Likes Received:
    18
    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;       
                }
            }
        }   
    })();
     
    #16
  17. thereportingbug

    thereportingbug Warper Member

    Messages:
    2
    Likes Received:
    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: Apr 26, 2019
    #17
  18. pasunna

    pasunna Veteran Veteran

    Messages:
    120
    Likes Received:
    18
    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
     
    #18
    thereportingbug likes this.

Share This Page