设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 89|回复: 0

[转载发布] Message Window Hide

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7948

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29903
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38745

    灌水之王

    发表于 12 小时前 | 显示全部楼层 |阅读模式
    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.

    Spoiler                Code:       
    1. //=============================================================================
    2. // MessageHide.js                                                            
    3. //=============================================================================
    4. /*:
    5. @plugindesc v1.3.1 Define buttons the player can press to toggle whether the message window is shown.
    6. @author Jatopian
    7. @param key
    8. @desc Keys/buttons that toggle message window visibility when pressed. Separate values with a space. See help for list.
    9. @default pageup h
    10. @param right click
    11. @desc Whether right click can toggle message window visibility. true / false
    12. @default true
    13. @param show on new page
    14. @desc Whether the message window automatically becomes visible on a new page of dialogue. true / false
    15. @default true
    16. @help
    17. Message window visibility is reset by pressing the key again,
    18. or resetting the game.
    19. Game events can also make it happen with plugin command: ShowMessageWindow
    20. With "show on new page" param true, visibility is reset for each new message window page.
    21. "key" parameter takes multiple values separated by a space.
    22. For example: "pageup h" will define H and PageUp keys (and keys synonymous with PageUp like gamepad side buttons).
    23. Gamepad-compatible values:
    24. ok       //      A
    25. cancel   //      B
    26. shift    //      X
    27. menu     //      Y
    28. pageup   //      LB
    29. pagedown //      RB
    30. up
    31. down
    32. left
    33. right
    34. Keyboard-only values:
    35. a-z
    36. 0-9
    37. tab
    38. enter
    39. shift
    40. ctrl
    41. alt
    42. space
    43. semicolon
    44. comma
    45. period
    46. quote
    47. Installation:
    48. Place after Yanfly Message Core, or NameBox hiding won't work.
    49. Terms of Use:
    50. - Free for commercial and non-commercial use.
    51. - Please give credit in a trivially accessible place.
    52. - OK to modify, but if you redistribute the modified version,
    53.   please make clear that you modified it, and how.
    54. - If you add features that could be useful to others,
    55.   please at least consider sharing them with me and the community.
    56. Changelog:
    57. 1.3.1:
    58. Right-click fixes.
    59. Compatibility note about Yanfly Message Core NameBox.
    60. 1.3.0:
    61. Parameter to hide window with right-click. (Thanks Magnus0808 || Magnus Rubin Peterson.)
    62. 1.2.0:
    63. Ability to define multiple keys.
    64. Defaults to "show on new page" behavior rather than undefined behavior if param not set.
    65. Gamepad support fixes.
    66. Yanfly Message Core NameBox compatibility. (Thanks mdqp!)
    67. 1.1.0:
    68. Show/hide now persists between maps and when bringing up the menu.
    69. "show on new page" feature.
    70. */
    71. (function() {
    72.   var params = PluginManager.parameters("MessageHide");
    73.   var pKey = String(params["key"]).toLowerCase().split(" ");
    74.   var pRightClick = (function() {  
    75.     var p = String(params["right click"]).toLowerCase();
    76.     if (p.match(/false/i)) {
    77.       return false;
    78.     }
    79.     return true;
    80.   })();
    81.   var pNewPage = (function() {  
    82.     var p = String(params["show on new page"]).toLowerCase();
    83.     if (p.match(/false/i)) {
    84.       return false;
    85.     }
    86.     return true;
    87.   })();
    88.   
    89.   var key_ids = {
    90.     "tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"space":32,
    91.     "pageup":33,"pagedown":34,
    92.     "0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":57,
    93.     "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,
    94.     "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,
    95.     "semicolon":186,"comma":188,"period":190,"quote":222,
    96.   };
    97.   
    98.   for (var p of pKey) {
    99.     console.log("MessageHide button defined: " + p);
    100.     if (key_ids[p]) { // if key is listed in key_ids
    101.       if (!Input.keyMapper[key_ids[p]]) { // if key isn't already registered with keyMapper
    102.         Input.keyMapper[key_ids[p]] = p; // add it to keyMapper, with label from key_ids
    103.       }
    104.     } else {
    105.       if (!Input.keyMapper[p]) { // if key is not already registered with keyMapper and also not in key_ids
    106.         console.log("Unrecognized MessageHide button defined - deleting: " + p);
    107.         delete pKey[p]; // delete value from pKey so it isn't fruitlessly checked later
    108.       }
    109.     }
    110.   }
    111.   //global variables!
    112.   MessageHide_messageWindowShowNext = false;
    113.   MessageHide_messageWindowVisible = true; //global to persist between maps
    114.   
    115.   //=============================================================================
    116.   // Window Message
    117.   //=============================================================================
    118.   
    119.   Window_Message.prototype.isToggleHide = function() {
    120.     for (var p of pKey) {
    121.       if (Input.isTriggered(p)) return true;
    122.     }
    123.     return false;
    124.   }
    125.   
    126.   var alias_wm_ud = Window_Message.prototype.update;
    127.   Window_Message.prototype.update = function() {
    128.     alias_wm_ud.call(this);
    129.     if (MessageHide_messageWindowShowNext === true) {
    130.       MessageHide_messageWindowVisible = true;
    131.       MessageHide_messageWindowShowNext = false;
    132.     } else if (this.isToggleHide()) {
    133.       MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
    134.     }
    135.     this.visible = MessageHide_messageWindowVisible;
    136.   }
    137.   
    138.   if (pRightClick) { // conditional alias
    139.     var mrp_hiderightclick_wm_update_old = Window_Message.prototype.update;
    140.     Window_Message.prototype.update = function() {
    141.       mrp_hiderightclick_wm_update_old.call(this);
    142.       this.processRightClick();
    143.     }
    144.    
    145.     Window_Message.prototype.processRightClick = function() {
    146.       if (this.isOpen() && this.active && TouchInput.isCancelled()) {
    147.         MessageHide_messageWindowVisible = !MessageHide_messageWindowVisible;
    148.       }
    149.     }
    150.   }
    151.   
    152.   if (pNewPage) { // conditional alias
    153.     var alias_wm_np = Window_Message.prototype.newPage;
    154.     Window_Message.prototype.newPage = function(textState) {
    155.       alias_wm_np.call(this, textState);
    156.       MessageHide_messageWindowVisible = true;
    157.     }
    158.   }
    159.   
    160.   //=============================================================================
    161.   // Game Interpreter
    162.   //=============================================================================
    163.   
    164.   var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    165.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
    166.       alias_Game_Interpreter_pluginCommand.call(this, command, args);
    167.       if (command === "ShowMessageWindow") {
    168.         MessageHide_messageWindowShowNext = true;
    169.       }
    170.   }
    171.   
    172.   //=============================================================================
    173.   // Window NameBox (Yanfly Message Core compatibility)
    174.   //=============================================================================
    175.   
    176.   if (Imported.YEP_MessageCore) { // conditional alias
    177.     var alias_wm_nb = Window_NameBox.prototype.update;
    178.     Window_NameBox.prototype.update = function() {
    179.       alias_wm_nb.call(this);
    180.       if ($gameMessage.isToggleHide) {
    181.         this.visible = MessageHide_messageWindowVisible;
    182.       }
    183.     }
    184.    
    185.     if (pRightClick) { // conditional alias
    186.       var mrp_hiderightclick_wnb_update = Window_NameBox.prototype.update;
    187.       Window_NameBox.prototype.update = function() {
    188.         mrp_hiderightclick_wnb_update.call(this);       
    189.         if (this._parentWindow.isOpen() && this.isOpen()) {
    190.           this.visible = this._parentWindow.visible;                       
    191.         }
    192.       }
    193.     }
    194.   }
    195.   
    196. })();
    复制代码








    本贴来自国际rpgmaker官方论坛作者:Jatopian处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/message-window-hide.71337/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-31 22:39 , Processed in 0.120321 second(s), 51 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表