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

[转载发布] Advanced Menus (huge mouse navigation improvements!) [BETA]

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

    连续签到: 2 天

    [LV.7]常住居民III

    8037

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式
    What is this?


        Welcome to the Advanced Menus plugin in a beta version which provides enhanced menu functionality for better mouse/touch navigation.


    Features:


    • makes menus activate with single click even when another menu item is selected. (places like the item list where you need to be able to select items to read their detail description are exempted) No more awkward clicking twice everywhere.
    • makes many inactive menus clickable and "does the right thing", so you aren't forced to back out of submenus first before e.g. changing the Item Category with a click in the Items screen. This vastly improves the intuitiveness of mouse navigation.

                  Please note this is enabled on a case-by-case basis, so if one menu isn't clickable in a specific situation where you'd expect it to, I probably missed it - drop me a note.
    • adds back buttons all over the important places. This essentially makes the entire game and all menus usable with just left clicks, you just still need Escape and/or right-click to enter the ingame escape menu and for nothing else.

                  This again makes for much more intuitive and comfortable mouse navigation.

    !! COMPATIBILITY WARNING !!


        Please note this plugin is rather intrusive, so if you use any other plugin that modifies the menus and which isn't aware of this plugin, then it might possibly not work.


        To increase compatibility, you can try those two things: 1. Put this plugin after the other unaware plugin in the plugin manager, and if that doesn't help 2. disable back buttons in the plugin options.


        If none of those helps, you will probably need to contact the plugin author to ask them to make his/her plugin compatible with Advanced Menus.


        Note to plugin authors: You can detect this plugin by checking for Imported.AdvancedMenus being present. You can make use of inactive menus becoming clickable yourself by implementing ._activateWhenOutOfFocus for your own menus (see the source code for examples) to make Advanced Menus allow them to be activated.


    Script Contents / Download:


        Here are the plugin contents, for license terms please read the embedded license at the top:


    (just copy & paste the code below in a file named AdvancedMenus.js and put it in your js/plugins/ folder to use it)

    Spoiler                Code:       
    1. // Advanced Menus
    2. // by orlando, BigTaro (rpgmakerweb.com forums)
    3. // Date: 25/03/2017
    4. var Imported = Imported || {};
    5. Imported.AdvancedMenus = "1.0.3";
    6. // LICENSE PLEASE READ:
    7. // ====================
    8. //
    9. // Copyright (C) 2015-2017 orlando, BigTaro (rpgmakerweb.com forums)
    10. //
    11. // This software is provided 'as-is', without any express or implied
    12. // warranty. In no event will the authors be held liable for any damages
    13. // arising from the use of this software.
    14. //
    15. // Permission is granted to anyone to use this software for any purpose,
    16. // including commercial applications, and to alter it and redistribute it
    17. // freely, subject to the following restrictions:
    18. //
    19. // 1. The origin of this software must not be misrepresented; you must not
    20. //    claim that you wrote the original software. If you use this software
    21. //    in a product, an acknowledgement in the product documentation would be
    22. //    appreciated but is not required.
    23. // 2. Altered source versions must be plainly marked as such, and must not be
    24. //    misrepresented as being the original software.
    25. // 3. This notice may not be removed or altered from any source distribution.
    26. //===========================================================================
    27. /*:
    28. * @plugindesc 1.0.3 Advanced Menus to fix countless details with mouse/touch navigation   id:AdvancedMenus
    29. *
    30. * @param Add back buttons
    31. * @desc Alter common menus to include back buttons. Disable if you use any plugin that does intrusive modifications to the ingame menu
    32. * @default true
    33. *
    34. * @param Back Text
    35. * @desc The text used for the back buttons
    36. * @default Back...
    37. *
    38. * @param Cancel Text
    39. * @desc The text used for the item change cancel button
    40. * @default Cancel...
    41. *
    42. * @author orlando (rpgmakerweb.com forums)
    43. */
    44. (function() {
    45. var parameters = $plugins.filter(function(p){return p.description.contains("id:AdvancedMenus")})[0].parameters;
    46. var back_buttons = Boolean((parameters['Add back buttons'] === 'true') || false);
    47. var back_text = String(parameters['Back Text']);
    48. var cancel_text = String(parameters['Cancel Text']);
    49. AdvancedMenus = function() {
    50.     throw("this is a static class");
    51. }
    52. AdvancedMenus.menuSoundsMuted = false;
    53. AdvancedMenus.backText = back_text;
    54. AdvancedMenus.cancelText = cancel_text;
    55. // ---- SPECIFIC MENUS EXPANDED TO HAVE A BACK BUTTON (IF ENABLED) ----
    56. if (back_buttons) {
    57.     // Window_ItemCategory "Back..." button:
    58.     Window_ItemCategory.prototype._preAdvancedMenus_makeCommandList =
    59.         Window_ItemCategory.prototype.makeCommandList;
    60.     Window_ItemCategory.prototype.makeCommandList = function() {
    61.         // Detect if we are inside a shop. If yes, don't add "Back...":
    62.         var is_shop = false;
    63.         var windows = AdvancedMenus.listOfWindows();
    64.         for (var j = 0; j < windows.length; j++) {
    65.             if (Window_ShopCommand.prototype.isPrototypeOf(windows[j])) {
    66.                 is_shop = true;
    67.                 break;
    68.             }
    69.         }
    70.         this._preAdvancedMenus_makeCommandList();
    71.         
    72.         // Add if not a shop:
    73.         if (!is_shop) {
    74.             this.addCommand(AdvancedMenus.backText, 'cancel');
    75.         }
    76.         
    77.     };
    78.     // Make room for back button in Window_ItemCategory:
    79.     Window_ItemCategory.prototype._preAdvancedMenus_maxCols =
    80.         Window_ItemCategory.prototype.maxCols;
    81.     Window_ItemCategory.prototype.maxCols = function() {
    82.         // Detect if we are inside a shop. If yes, nothing needs to be added:
    83.         var is_shop = false;
    84.         var windows = AdvancedMenus.listOfWindows();
    85.         for (var j = 0; j < windows.length; j++) {
    86.             if (Window_ShopCommand.prototype.isPrototypeOf(windows[j])) {
    87.                 is_shop = true;
    88.                 break;
    89.             }
    90.         }
    91.         if (is_shop) {
    92.             return this._preAdvancedMenus_maxCols();
    93.         } else {
    94.             return this._preAdvancedMenus_maxCols() + 1;
    95.         }
    96.     };
    97.     // Window_SkillType "Back..." button:
    98.     Window_SkillType.prototype._preAdvancedMenus_makeCommandList =
    99.         Window_SkillType.prototype.makeCommandList;
    100.     Window_SkillType.prototype.makeCommandList = function() {
    101.         this._preAdvancedMenus_makeCommandList();
    102.         
    103.         if (this._actor) {
    104.             this.addCommand(AdvancedMenus.backText, 'cancel');
    105.         }
    106.         
    107.     };
    108.     // Main command list "Back..." button:
    109.     Window_MenuCommand.prototype._preAdvancedMenus_makeCommandList =
    110.         Window_MenuCommand.prototype.makeCommandList;
    111.     Window_MenuCommand.prototype.makeCommandList = function() {
    112.         this._preAdvancedMenus_makeCommandList();
    113.         this.addCommand(AdvancedMenus.backText, 'cancel', true);
    114.         
    115.     };
    116.     // Window_EquipCommand "Back..." button:
    117.     Window_EquipCommand.prototype._preAdvancedMenus_makeCommandList =
    118.         Window_EquipCommand.prototype.makeCommandList;
    119.     Window_EquipCommand.prototype.makeCommandList = function() {
    120.         this._preAdvancedMenus_makeCommandList();
    121.         this.addCommand(AdvancedMenus.backText, 'cancel');
    122.     };
    123.     // Note: no need to make room for back button in Window_EquipCommand,
    124.     // since we remove the "Equip" button later
    125.     // Make down/up go from Window_EquipCommand to Window_EquipSlot
    126.     Window_EquipCommand.prototype._preAdvancedMenus_cursorDown =
    127.         Window_EquipCommand.prototype.cursorDown;
    128.     Window_EquipCommand.prototype.cursorDown = function() {
    129.         this.select(-1);
    130.         SoundManager.playCursor();
    131.         this.updateInputData();
    132.         this.deactivate();
    133.         SceneManager._scene.commandEquip();
    134.     }
    135.     Window_EquipCommand.prototype._preAdvancedMenus_cursorUp =
    136.         Window_EquipCommand.prototype.cursorUp;
    137.     Window_EquipCommand.prototype.cursorUp = function() {
    138.         this.select(-1);
    139.         SoundManager.playCursor();
    140.         this.updateInputData();
    141.         this.deactivate();
    142.         SceneManager._scene.commandEquip();
    143.         // make sure last item is selected in Window_EquipSlot:
    144.         var windows = AdvancedMenus.listOfWindows();
    145.         for (var j = 0; j < windows.length; j++) {
    146.             if (Window_EquipSlot.prototype.isPrototypeOf(windows[j])) {
    147.                 windows[j].select(windows[j].maxItems() - 1);
    148.                 windows[j].refresh();
    149.                 break;
    150.             }
    151.         }
    152.     }
    153.     // Make down/up go from Window_EquipSlot to Window_EquipCommand if current
    154.     // item is last/first:
    155.     Window_EquipSlot.prototype._preAdvancedMenus_cursorDown =
    156.         Window_EquipSlot.prototype.cursorDown;
    157.     Window_EquipSlot.prototype.cursorDown = function(wrap) {
    158.         if (this.index() >= this.maxItems() - 1 && wrap) {
    159.             SoundManager.playCursor();
    160.             this.updateInputData();
    161.             this.deactivate();
    162.             this.callCancelHandler();
    163.             return;
    164.         } else {
    165.             return this._preAdvancedMenus_cursorDown(wrap);
    166.         }
    167.     }
    168.     Window_EquipSlot.prototype._preAdvancedMenus_cursorUp =
    169.         Window_EquipSlot.prototype.cursorUp;
    170.     Window_EquipSlot.prototype.cursorUp = function(wrap) {
    171.         if (this.index() <= 0 && wrap) {
    172.             SoundManager.playCursor();
    173.             this.updateInputData();
    174.             this.deactivate();
    175.             this.callCancelHandler();
    176.             return;
    177.         } else {
    178.             return this._preAdvancedMenus_cursorUp(wrap);
    179.         }
    180.     }
    181.     // Make sure leaving Window_EquipSlot will set a visible focus on the
    182.     // menu Window_EquipCommand (instead of no selection):
    183.     Window_EquipCommand.prototype._preAdvancedMenus_activate =
    184.         Window_EquipCommand.prototype.activate;
    185.     Window_EquipCommand.prototype.activate = function() {
    186.         // make sure Window_ItemList is no longer active:
    187.         var windows = AdvancedMenus.listOfWindows();
    188.         for (var j = 0; j < windows.length; j++) {
    189.             if (Window_ItemList.prototype.isPrototypeOf(windows[j]) &&
    190.                     windows[j].active && windows[j].visible) {
    191.                 windows[j].select(-1);
    192.                 windows[j].deactivate();
    193.                 windows[j]._data = [];
    194.                 windows[j].refresh();
    195.                 break;
    196.             }
    197.         }
    198.         // ensure visible selection:
    199.         this._preAdvancedMenus_activate();
    200.         if (this._index < 0) {
    201.             this.select(0);
    202.         }
    203.     }
    204.     // Remove "Equip" button from Window_EquipCommand:
    205.     Window_EquipCommand.prototype._preAdvancedMenus_addCommand =
    206.         Window_EquipCommand.prototype.addCommand;
    207.     Window_EquipCommand.prototype.addCommand = function(name, symbol, enabled, ext) {
    208.         if (name == "Equip") {
    209.             return;
    210.         }
    211.         this._preAdvancedMenus_addCommand(name, symbol, enabled, ext);
    212.     }
    213.     // Note: no need to remove space from removal in Window_EquipCommand,
    214.     // since we added the "Back..." button earlier
    215.     // Options menu "Back..." button:
    216.     Window_Options.prototype._preAdvancedMenus_makeCommandList =
    217.         Window_Options.prototype.makeCommandList;
    218.     Window_Options.prototype.makeCommandList = function() {
    219.         this._preAdvancedMenus_makeCommandList();
    220.         this.addCommand(AdvancedMenus.backText, 'cancel', true);
    221.     };
    222.     // Make sure no option value is drawn for the Options menu "Back" button:
    223.     Window_Options.prototype._preAdvancedMenus_statusText =
    224.         Window_Options.prototype.statusText;
    225.     Window_Options.prototype.statusText = function(index) {
    226.         if (this.commandName(index) != AdvancedMenus.backText) {
    227.             return this._preAdvancedMenus_statusText(index);
    228.         }
    229.         return "";
    230.     };
    231.     // Make Options menu "Back" button trigger the escape:
    232.     Window_Options.prototype._preAdvancedMenus_changeValue =
    233.         Window_Options.prototype.changeValue;
    234.     Window_Options.prototype.changeValue = function(symbol, value) {
    235.         if (symbol != "cancel") {
    236.             return this._preAdvancedMenus_changeValue(symbol, value);
    237.         }
    238.         this.playOkSound();
    239.         this.callCancelHandler();
    240.     };
    241.     // Provide a new menu with "Back..." button for the Scene_Status screen:
    242.     function Window_StatusBackButton() {
    243.         this.initialize.apply(this, arguments);
    244.     }
    245.     Window_StatusBackButton.prototype = Object.create(Window_Command.prototype);
    246.     Window_StatusBackButton.prototype.constructor = Window_StatusBackButton;
    247.     Window_StatusBackButton.prototype.initialize = function(x, y) {
    248.         Window_Command.prototype.initialize.call(this, x, y);
    249.         this._margin = 0;
    250.         this._refreshAllParts();
    251.         this.refresh();
    252.     }
    253.     Window_StatusBackButton.prototype.makeCommandList = function() {
    254.         this.addCommand(AdvancedMenus.backText, "cancel", true);
    255.     }
    256.     // Modify Scene_Status to show our "Back..." menu:
    257.     Scene_Status.prototype._preAdvancedMenus_create =
    258.         Scene_Status.prototype.create;
    259.     Scene_Status.prototype.create = function() {
    260.         this._preAdvancedMenus_create();
    261.         // disable focus of actual status window:
    262.         this._statusWindow.deactivate();
    263.         this._statusWindow.refresh();
    264.         // add "Back..." menu on top:
    265.         this._statusWindowBackButton = new Window_StatusBackButton(
    266.             Graphics.width - 240, 0);
    267.         this._statusWindowBackButton.setHandler('cancel',
    268.             this.popScene.bind(this));
    269.         this.addWindow(this._statusWindowBackButton);
    270.     }
    271.     // Provide a new menu with "Cancel..." button for the Scene_EventItem
    272.     // screen:
    273.     function Window_EventItemCancelButton() {
    274.         this.initialize.apply(this, arguments);
    275.     }
    276.     Window_EventItemCancelButton.prototype = Object.create(
    277.         Window_Command.prototype);
    278.     Window_EventItemCancelButton.prototype.constructor =
    279.         Window_EventItemCancelButton;
    280.     Window_EventItemCancelButton.prototype.initialize = function(
    281.             x, y) {
    282.         Window_Command.prototype.initialize.call(this, x, y);
    283.         this._margin = 0;
    284.         this._refreshAllParts();
    285.         this.refresh();
    286.     }
    287.     Window_EventItemCancelButton.prototype.makeCommandList = function() {
    288.         this.addCommand(AdvancedMenus.cancelText, "cancel", true);
    289.     }
    290.     // Make the new "Cancel..." for Window_EventItem cancel the item choice:
    291.     Window_EventItemCancelButton.prototype._activateWhenOutOfFocus =
    292.             function() {
    293.         var x = this.canvasToLocalX(TouchInput.x);
    294.         var y = this.canvasToLocalY(TouchInput.y);
    295.         var hitIndex = this.hitTest(x, y);
    296.         if (hitIndex == 0) {
    297.             var windows = AdvancedMenus.listOfWindows();
    298.             for (var j = 0; j < windows.length; j++) {
    299.                 if (Window_EventItem.prototype.isPrototypeOf(windows[j]) &&
    300.                         windows[j].active && windows[j].visible) {
    301.                     windows[j].processCancel();
    302.                     return true;
    303.                 }
    304.             }
    305.         }
    306.     }
    307.     // Helper function to adjust the placement of "Cancel..." according to the
    308.     // Window_Message window
    309.     var adjustEventItemCancelButtonPos = function(win) {
    310.         if (typeof(win._eventItemCancelButtonWindow) == "undefined") {
    311.             return;
    312.         }
    313.         var yPos = 0;
    314.         if ((win._y || 0) <= 100) {
    315.             yPos = Math.max(win._y || 0, 0) + Math.max(win._height || 0,
    316.                 200);
    317.         }
    318.         var evCancel = win._eventItemCancelButtonWindow;
    319.         evCancel.move(0, yPos, evCancel._width, evCancel._height);
    320.         evCancel._x = 0;
    321.         evCancel._y = yPos;
    322.         evCancel.refresh();
    323.     }
    324.     // When Window_Message moves, move the "Cancel..." too:
    325.     Window_Message.prototype._preAdvancedMenus_move =
    326.         Window_Message.prototype.move;
    327.     Window_Message.prototype.move = function() {
    328.         var retvalue = Window_Message.prototype.
    329.             _preAdvancedMenus_move.apply(
    330.             this, arguments);
    331.         adjustEventItemCancelButtonPos(this);
    332.         return retvalue;
    333.     };
    334.     // When Window_Message is hidden, hide the "Cancel...":
    335.     Window_Message.prototype._preAdvancedMenus_hide =
    336.         Window_Message.prototype.hide;
    337.     Window_Message.prototype.hide = function() {
    338.         var retvalue = Window_Message.prototype.
    339.             _preAdvancedMenus_hide.apply(this, arguments);
    340.         if (typeof(this._eventItemCancelButtonWindow) != "undefined") {
    341.             this._eventItemCancelButtonWindow.deactivate();
    342.             SceneManager._scene._windowLayer.removeChild(
    343.                 this._eventItemCancelButtonWindow);
    344.             this._eventItemCancelButtonWindow = undefined;
    345.         }
    346.         return retvalue;
    347.     };
    348.     // When Window_Message is closed, hide the "Cancel...":
    349.     Window_Message.prototype._preAdvancedMenus_close =
    350.         Window_Message.prototype.close;
    351.     Window_Message.prototype.close = function() {
    352.         var retvalue = Window_Message.prototype.
    353.             _preAdvancedMenus_close.apply(this, arguments);
    354.         if (typeof(this._eventItemCancelButtonWindow) != "undefined") {
    355.             this._eventItemCancelButtonWindow.deactivate();
    356.             SceneManager._scene._windowLayer.removeChild(
    357.                 this._eventItemCancelButtonWindow);
    358.             this._eventItemCancelButtonWindow = undefined;
    359.         }
    360.         return retvalue;
    361.     };
    362.     // Modify Window_Message's startInput code to show our "Cancel..." menu or
    363.     // to hide it accordingly:
    364.     Window_Message.prototype._preAdvancedMenus_startInput =
    365.         Window_Message.prototype.startInput;
    366.     Window_Message.prototype.startInput = function() {
    367.         var retvalue = Window_Message.prototype.
    368.             _preAdvancedMenus_startInput.apply(this, arguments);
    369.         if (retvalue && !$gameMessage.isItemChoice() &&
    370.                 typeof(this._eventItemCancelButtonWindow) != "undefined") {
    371.             this._eventItemCancelButtonWindow.destroy();
    372.             this._eventItemCancelButtonWindow = undefined;
    373.         }
    374.         if (retvalue && $gameMessage.isItemChoice() &&
    375.                 typeof(this._eventItemCancelButtonWindow) == "undefined") {
    376.             this._eventItemCancelButtonWindow =
    377.                 new Window_EventItemCancelButton(0, 0);
    378.             this._eventItemCancelButtonWindow.show();
    379.             this._eventItemCancelButtonWindow.select(-1);
    380.             this._eventItemCancelButtonWindow.deactivate();
    381.             this._eventItemCancelButtonWindow.refresh();
    382.             SceneManager._scene.addWindow(
    383.                 this._eventItemCancelButtonWindow);
    384.             adjustEventItemCancelButtonPos(this);
    385.         }
    386.         return retvalue;
    387.     };
    388. }
    389. // ---- SOUND MANAGER ALTERATIONS TO MUTE TEMPORARILY ----
    390. SoundManager._oldPreAdvancedMenus_playCursor = SoundManager.playCursor;
    391. SoundManager.playCursor = function() {
    392.     if (!AdvancedMenus.menuSoundsMuted) {
    393.         SoundManager._oldPreAdvancedMenus_playCursor();
    394.     }
    395. };
    396. SoundManager._oldPreAdvancedMenus_playOk = SoundManager.playOk;
    397. SoundManager.playOk = function() {
    398.     if (!AdvancedMenus.menuSoundsMuted) {
    399.         SoundManager._oldPreAdvancedMenus_playOk();
    400.     }
    401. };
    402. SoundManager._oldPreAdvancedMenus_playCancel = SoundManager.playCancel;
    403. SoundManager.playCancel = function() {
    404.     if (!AdvancedMenus.menuSoundsMuted) {
    405.         SoundManager._oldPreAdvancedMenus_playCancel();
    406.     }
    407. };
    408. // ---- WINDOW LIST HELPER FUNCTION ----
    409. AdvancedMenus.listOfWindows = function() {
    410.     var debugList = false;
    411.     if (debugList) {
    412.         console.log("");
    413.         console.log("");
    414.         console.log("--- window list ---");
    415.     }
    416.     var windows = [];
    417.     var addChildren = function(win) {
    418.         for (var j = 0; j < win.children.length; j++) {
    419.             windows.push(win.children[j]);
    420.             if (debugList) {
    421.                 console.log("Found window:");
    422.                 console.log(win.children[j]);
    423.             }
    424.             if (typeof(win.children[j].children) != "undefined") {
    425.                 addChildren(win.children[j]);
    426.             }
    427.         }
    428.     }
    429.     addChildren(SceneManager._scene._windowLayer);
    430.     return windows;
    431. }
    432. // ---- SPECIFIC EXISTING MENUS CHANGED TO ALLOW INACTIVE INTERACTION ----
    433. // Fix Scene_Equip sometimes not initializing Window_EquipItem to slot:
    434. Scene_Equip.prototype._preAdvancedMenu_onSlotOk =
    435.     Scene_Equip.prototype.onSlotOk;
    436. Scene_Equip.prototype.onSlotOk = function() {
    437.     this._slotWindow.update();
    438.     return this._preAdvancedMenu_onSlotOk();
    439. };
    440. // Make sure there is no target enemy selection sticking around when leaving
    441. // the targeting menu:
    442. Window_ActorCommand.prototype._preAdvancedMenu_activate =
    443.     Window_ActorCommand.prototype.activate;
    444. Window_ActorCommand.prototype.activate = function() {
    445.     var windows = AdvancedMenus.listOfWindows();
    446.     for (var j = 0; j < windows.length; j++) {
    447.         if (Window_BattleEnemy.prototype.isPrototypeOf(windows[j]) &&
    448.                 windows[j].active && windows[j].visible) {   
    449.             windows[j].deactivate();
    450.             windows[j].visible = false;
    451.             break;
    452.         }
    453.     }
    454.     return this._preAdvancedMenu_activate();
    455. }
    456. // Allow clicking ActorCommand while various sub menu popups are open:
    457. Window_ActorCommand.prototype._activateWhenOutOfFocus = function() {
    458.     var windows = AdvancedMenus.listOfWindows();
    459.     // Submenu "Attack":
    460.     for (var j = 0; j < windows.length; j++) {
    461.         if (Window_BattleEnemy.prototype.isPrototypeOf(windows[j]) &&
    462.                 windows[j].active && windows[j].visible) {
    463.             windows[j].processCancel();
    464.             return true;
    465.         }
    466.     }
    467.     // Submenu "Items":
    468.     for (var j = 0; j < windows.length; j++) {
    469.         if (Window_ItemList.prototype.isPrototypeOf(windows[j]) &&
    470.                 windows[j].active && windows[j].visible) {
    471.             windows[j].processCancel();
    472.             return true;
    473.         }
    474.     }
    475.     // Submenu for any skill:
    476.     for (var j = 0; j < windows.length; j++) {
    477.         if (Window_SkillList.prototype.isPrototypeOf(windows[j]) &&
    478.                 windows[j].active && windows[j].visible) {
    479.             windows[j].processCancel();
    480.             return true;
    481.         }
    482.     }
    483.     return false;
    484. }
    485. // Allow clicking specific equpiment slots while Window_EquipCommand (further
    486. // outside) has focus or while Window_EquipSlot (deeper inside) has focus
    487. Window_EquipSlot.prototype._activateWhenOutOfFocus = function() {
    488.     var windows = AdvancedMenus.listOfWindows();
    489.     // clicking when Window_EquipCommand active:
    490.     for (var j = 0; j < windows.length; j++) {
    491.         if (Window_EquipCommand.prototype.isPrototypeOf(windows[j]) &&
    492.                 windows[j].active && windows[j].visible) {
    493.             // set the submenu Window_EquipSlot active:
    494.             windows[j].deactivate();
    495.             SceneManager._scene.commandEquip();
    496.             SceneManager._scene.refreshActor();
    497.             if (back_buttons == true) {
    498.                 windows[j].select(-1);
    499.             } else {
    500.                 windows[j].select(0);
    501.             }
    502.             return true;
    503.         }
    504.     }
    505.     // clicking when Window_EquipSlot active:
    506.     for (var j = 0; j < windows.length; j++) {
    507.         if (Window_EquipItem.prototype.isPrototypeOf(windows[j]) &&
    508.                 windows[j].active && windows[j].visible) {
    509.             windows[j].processCancel();
    510.             return true;
    511.         }
    512.     }
    513.     return false;
    514. }
    515. // Allow clicking Window_EquipCommand while deeper inside the equip submenus
    516. Window_EquipCommand.prototype._activateWhenOutOfFocus = function() {
    517.     // Back out of item list:
    518.     var windows = AdvancedMenus.listOfWindows();
    519.     for (var j = 0; j < windows.length; j++) {
    520.         if (Window_ItemList.prototype.isPrototypeOf(windows[j]) &&
    521.                 windows[j].active && windows[j].visible) {
    522.             windows[j].processCancel();
    523.             windows[j].select(-1);
    524.             windows[j].deactivate();
    525.         }
    526.     }
    527.     // Back out of having selected a specific equipment slot:
    528.     var windows = AdvancedMenus.listOfWindows();
    529.     for (var j = 0; j < windows.length; j++) {
    530.         if (Window_EquipSlot.prototype.isPrototypeOf(windows[j]) &&
    531.                 windows[j].active && windows[j].visible) {
    532.             windows[j].processCancel();
    533.             return true;
    534.         }
    535.     }
    536.     return false;
    537. }
    538. // Allow changing from buy to sell or back, while somewhere in the submenus:
    539. Window_ShopCommand.prototype._activateWhenOutOfFocus = function() {
    540.     var windows = AdvancedMenus.listOfWindows();
    541.     // SELL/BUY: exit number quantity screen for detail sell/buy if opened:
    542.     for (var j = 0; j < windows.length; j++) {
    543.         if (Window_ShopNumber.prototype.isPrototypeOf(windows[j]) &&
    544.                 windows[j].active && windows[j].visible) {
    545.             windows[j].processCancel();
    546.             break;
    547.         }
    548.     }
    549.     // BUY: close buy list if opened:
    550.     for (var j = 0; j < windows.length; j++) {
    551.         if (Window_ShopBuy.prototype.isPrototypeOf(windows[j]) &&
    552.                 windows[j].active && windows[j].visible) {
    553.             windows[j].processCancel();
    554.             return true;
    555.         }
    556.     }
    557.     // SELL: first, close inner item list window if found:
    558.     for (var j = 0; j < windows.length; j++) {
    559.         if (Window_ItemList.prototype.isPrototypeOf(windows[j]) &&
    560.                 windows[j].active && windows[j].visible) {
    561.             windows[j].processCancel();
    562.             break;
    563.         }
    564.     }
    565.     // SELL: if we find an active item category menu, back out and done
    566.     for (var j = 0; j < windows.length; j++) {
    567.         if (Window_ItemCategory.prototype.isPrototypeOf(windows[j]) &&
    568.                 windows[j].active && windows[j].visible) {
    569.             windows[j].processCancel();
    570.             return true;
    571.         }
    572.     }
    573.     return false;
    574. }
    575. // Allow changing skill category while in the skill details list:
    576. Window_SkillType.prototype._activateWhenOutOfFocus = function() {
    577.     // If skill list is open and Window_MenuActor is active, we are in the
    578.     // item use target selection -> back out
    579.     var windows = AdvancedMenus.listOfWindows();
    580.     var inSkillList = false;
    581.     for (var j = 0; j < windows.length; j++) {
    582.         if (Window_SkillList.prototype.isPrototypeOf(windows[j]) &&
    583.                 windows[j].visible) {
    584.             inSkillList = true;
    585.         }
    586.     }
    587.     if (inSkillList) {
    588.         for (var j = 0; j < windows.length; j++) {
    589.             if (Window_MenuActor.prototype.isPrototypeOf(windows[j]) &&
    590.                     windows[j].active && windows[j].visible) {
    591.                 windows[j].processCancel();
    592.                 windows[j].select(-1);
    593.                 windows[j].deactivate();
    594.                 break;
    595.             }
    596.         }
    597.     }
    598.     // Back out of SkillList when active:
    599.     var windows = AdvancedMenus.listOfWindows();
    600.     for (var j = 0; j < windows.length; j++) {
    601.         if (Window_SkillList.prototype.isPrototypeOf(windows[j]) &&
    602.                 windows[j].active && windows[j].visible) {
    603.             windows[j].processCancel();
    604.             return true;
    605.         }
    606.     }
    607.     return false;
    608. }
    609. // Allow changing game menu category while Window_MenuStatus selection active:
    610. Window_MenuCommand.prototype._activateWhenOutOfFocus = function() {
    611.     var windows = AdvancedMenus.listOfWindows();
    612.     for (var j = 0; j < windows.length; j++) {
    613.         if (Window_MenuStatus.prototype.isPrototypeOf(windows[j]) &&
    614.                 windows[j].visible && windows[j].active) {
    615.             windows[j].processCancel();
    616.             return true;
    617.         }
    618.     }
    619.     return false;
    620. }
    621. // Allow changing ItemCategory while the ItemList is active:
    622. Window_ItemCategory.prototype._activateWhenOutOfFocus = function() {
    623.     // If item list is open and Window_MenuActor is active, we are in the
    624.     // item use target selection -> back out, but only if clicking
    625.     // at the left-most button.
    626.     var x = this.canvasToLocalX(TouchInput.x);
    627.     var y = this.canvasToLocalY(TouchInput.y);
    628.     var hitIndex = this.hitTest(x, y);
    629.     if (hitIndex == 0) {
    630.         var windows = AdvancedMenus.listOfWindows();
    631.         var inItemList = false;
    632.         for (var j = 0; j < windows.length; j++) {
    633.             if (Window_ItemList.prototype.isPrototypeOf(windows[j]) &&
    634.                     windows[j].visible) {
    635.                 inItemList = true;
    636.             }
    637.         }
    638.         if (inItemList) {
    639.             for (var j = 0; j < windows.length; j++) {
    640.                 if (Window_MenuActor.prototype.isPrototypeOf(windows[j]) &&
    641.                         windows[j].active && windows[j].visible) {
    642.                     windows[j].processCancel();
    643.                     windows[j].select(-1);
    644.                     windows[j].deactivate();
    645.                     break;
    646.                 }
    647.             }
    648.         }
    649.     }
    650.     // Make sure the item use target choice isn't open:
    651.     var windows = AdvancedMenus.listOfWindows();
    652.     for (var j = 0; j < windows.length; j++) {
    653.         if (Window_MenuActor.prototype.isPrototypeOf(windows[j]) &&
    654.                 windows[j].visible) {
    655.             return false;
    656.         }
    657.     }
    658.     // Close item list so we can change category:
    659.     for (var j = 0; j < windows.length; j++) {
    660.         if (Window_ItemList.prototype.isPrototypeOf(windows[j])
    661.                 && windows[j].active && windows[j].visible) {
    662.             windows[j].processCancel();
    663.             return true;
    664.         }
    665.     }
    666.     return false;
    667. }
    668. // Fix the displayed item help sometimes getting surprised by our changes:
    669. Window_ItemCategory.prototype.processTouch = function() {
    670.     Window_Selectable.prototype.processTouch.apply(this, []);
    671.     // make sure the item help display follows our changes:
    672.     var windows = AdvancedMenus.listOfWindows();
    673.     for (var j = 0; j < windows.length; j++) {
    674.         if (Window_ItemList.prototype.isPrototypeOf(windows[j])) {
    675.             windows[j].updateHelp();
    676.         }
    677.     }
    678. }
    679. // Fix the displayed menu help sometimes getting surprised by our changes:
    680. Window_SkillType.prototype.processTouch = function() {
    681.     Window_Selectable.prototype.processTouch.apply(this, []);
    682.     // make sure the item help display follows our changes:
    683.     var windows = AdvancedMenus.listOfWindows();
    684.     for (var j = 0; j < windows.length; j++) {
    685.         if (Window_SkillList.prototype.isPrototypeOf(windows[j])
    686.                 && windows[j].visible && windows[j].active) {
    687.             windows[j].updateHelp();
    688.         }
    689.     }
    690. }
    691. // ---- GENERAL CODE FOR ONE-CLICK NAVIGATION AND INACTIVE INTERACTION ----
    692. // Allow activating menus that aren't active if this._activateWhenOutOfFocus
    693. // is defined on them:
    694. Window_Selectable.prototype.processTouch = function() {
    695.     if (this.isOpenAndActive() ||
    696.             typeof(this._activateWhenOutOfFocus) != "undefined") {
    697.         if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
    698.             this._touching = true;
    699.             this.onTouch(true);
    700.         } else if (TouchInput.isCancelled()) {
    701.             if (this.isCancelEnabled() && this.isOpenAndActive()) {
    702.                 this.processCancel();
    703.             }
    704.         }
    705.         if (this._touching) {
    706.             if (TouchInput.isPressed()) {
    707.                 this.onTouch(false);
    708.             } else {
    709.                 this._touching = false;
    710.             }
    711.         }
    712.     } else {
    713.         this._touching = false;
    714.     }
    715. };
    716. // Allow confirming menus with just one mouse click and possibly to click
    717. // when menu is inactive:
    718. Window_Selectable.prototype.onTouch = function(triggered) {
    719.     var lastIndex = this.index();
    720.     var x = this.canvasToLocalX(TouchInput.x);
    721.     var y = this.canvasToLocalY(TouchInput.y);
    722.     var hitIndex = this.hitTest(x, y);
    723.     var muteSelect = false;
    724.     var self = this;
    725.     var menuHasSelectInfo = function() {
    726.         if (Window_EquipItem.prototype.isPrototypeOf(self)) {
    727.             return true;
    728.         }
    729.         if (Window_SkillList.prototype.isPrototypeOf(self)) {
    730.             return true;
    731.         }
    732.         if (Window_ItemList.prototype.isPrototypeOf(self)) {
    733.             return true;
    734.         }
    735.         return false;
    736.     }
    737.     var tryActivate = function() {
    738.         if (self.isOpenAndActive()) {
    739.             // console.log("tryActivate: ALLOW IN FOCUS");
    740.             return true;
    741.         }
    742.         AdvancedMenus.menuSoundsMuted = true;
    743.         if (typeof(self._activateWhenOutOfFocus) != "undefined"
    744.                 && self._activateWhenOutOfFocus()) {
    745.             AdvancedMenus.menuSoundsMuted = false;
    746.             // console.log("tryActivate: ALLOW OUT OF FOCUS");
    747.             return true;
    748.         }
    749.         AdvancedMenus.menuSoundsMuted = false;
    750.         // console.log("tryActivate: DISALLOW");
    751.         return false;
    752.     }
    753.     if (hitIndex >= 0) {
    754.         if (hitIndex === this.index()) {
    755.             if (triggered && this.isTouchOkEnabled()) {
    756.                 if (tryActivate()) {
    757.                     this.processOk();
    758.                     return;
    759.                 }
    760.             }
    761.         } else if (this.isCursorMovable() ||
    762.                 typeof(this._activateWhenOutOfFocus) != "undefined") {
    763.             if (!tryActivate()) {
    764.                 return;
    765.             }
    766.             this.select(hitIndex);
    767.             // Allow direct click unless it matches a few well-known menus
    768.             // with per-selection descriptions:
    769.             if (!menuHasSelectInfo()) {
    770.                 if (triggered && this.isTouchOkEnabled()) {
    771.                     muteSelect = true;
    772.                     this.processOk();
    773.                 }
    774.             }
    775.         }
    776.     } else if (this._stayCount >= 10) {
    777.         if (y < this.padding) {
    778.             if (tryActivate()) {
    779.                 this.cursorUp();
    780.             }
    781.         } else if (y >= this.height - this.padding) {
    782.             if (tryActivate()) {
    783.                 this.cursorDown();
    784.             }
    785.         }
    786.     }
    787.     if (this.index() !== lastIndex && !muteSelect) {
    788.         SoundManager.playCursor();
    789.     }
    790. };
    791. })();
    复制代码










    Changelog:


    1.0.0 - 12/6/2015 Initial release


    1.0.1 - 12/19/2015 Added support for clicking "Back..." inside the use item/use skill on party member menus, and added a clickable "Cancel..." button for the item chooser dialog which can be triggered through a map event

    1.0.3 - 25/03/2017 Incorporate changes by @BigTaro which allow Cancel.../Back... to have configurable texts (plugin options) and which moves them to the bottom. Fix "Choices" window positioning being broken by plugin. Fix selection & activation sound playing both when clicking unselected menu entries


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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 10:42 , Processed in 0.086214 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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