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

[转载发布] Menu Command Manager

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

    连续签到: 2 天

    [LV.7]常住居民III

    5778

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 20:20 | 显示全部楼层 |阅读模式

    Menu Command Manager
    by
    MobiusXVI


    Release Notes
    Sep 2015 - v. 1.0 Initial Release
    Jan 2016 - v. 1.5 Support for Common Events
    Aug 2017 - v. 1.6 Fixed bugged paralysis states not working
    Apr 2023 - v. 1.7 Add ability to disable commands via switches

    Introduction
    This script allows you to add custom commands to the menu, remove existing commands, and order them however you like!

    Features
    - Easily add new commands to the menu
    - Remove un-needed commands from the menu
    - Helps custom scripts come back to the menu correctly
    - Add Common Event calls to your menu

    How to Use
    Copy the script into the script editor below the default scripts but above Main. If you're using other scripts which affect the menu, I recommend placing this script above them in the script editor. Follow the instructions and configuration guidance within the script itself.

    Script

    Spoiler                Code:       
    1. #===============================================================================
    2. # Mobius' Menu Command Manager
    3. # Author: Mobius XVI
    4. # Version: 1.7
    5. # Date: 20 APR 2023
    6. #===============================================================================
    7. #
    8. # Introduction:
    9. #
    10. #   This script allows you to add custom commands to the menu, remove existing
    11. #   commands, and order them however you like. The script can also help
    12. #   custom commands come back to the menu correctly.
    13. #
    14. # Instructions:
    15. #
    16. #  - Place this script below all the default scripts but above main.
    17. #    If you're using other scripts which affect the menu, I recommend
    18. #    placing this script above them in the script editor.
    19. #
    20. #  - The customization section below has additional instructions on
    21. #    how to set up and organize the commands.
    22. #
    23. # Issues/Bugs/Possible Bugs:
    24. #
    25. #   - As this script replaces the default menu system scripts, it
    26. #     may be incompatible with other menu system scripts.
    27. #
    28. #
    29. #  Credits/Thanks:
    30. #    - Mobius XVI, author
    31. #    - Zeus81, for his 'Bitmap Export' script which brought the background_sprite
    32. #      snapshot functionality to RMXP
    33. #
    34. #  License
    35. #
    36. #    This script is available in its entirety for commercial and non-commercial
    37. #    use. View the specific license terms below.
    38. #
    39. #    The portions of this script written by me is licensed under the MIT License:
    40. #
    41. #    The MIT License (MIT)
    42. #
    43. #      Copyright (c) 2023 darmes
    44. #
    45. #       Permission is hereby granted, free of charge, to any person obtaining a copy
    46. #       of this software and associated documentation files (the "Software"), to deal
    47. #       in the Software without restriction, including without limitation the rights
    48. #       to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    49. #       copies of the Software, and to permit persons to whom the Software is
    50. #       furnished to do so, subject to the following conditions:
    51. #
    52. #       The above copyright notice and this permission notice shall be included in all
    53. #       copies or substantial portions of the Software.
    54. #
    55. #       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    56. #       IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    57. #       FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    58. #       AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    59. #       LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    60. #       OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    61. #       SOFTWARE.
    62. #
    63. #      Further, if you do decide to use this script in a commercial product,
    64. #      I'd ask that you let me know via a forum post or a PM. Thanks.
    65. #
    66. #    Zeus81's script is licensed under CC BY 4.0. View the full license text here:
    67. #    http://creativecommons.org/licenses/by/4.0/
    68. #    The script is only a portion of the original as I removed those features
    69. #    that weren't necessary for this script to function. You can get the full
    70. #    script here:
    71. #    http://forums.rpgmakerweb.com/index.php?/topic/21633-bitmap-export/
    72. #
    73. #==============================================================================
    74. # ** CUSTOMIZATION START
    75. #==============================================================================
    76. module Mobius
    77.   module Menu_Commands
    78.     # MENU LOOK OPTIONS #
    79.     # These options let you change how the menu looks
    80.     # MENU_OPACITY is used to make the menu somewhat transparent so that
    81.     # the background can be seen behind it. You can set this to an interger
    82.     # value between 0 (completely transparent) and 255 (completely opaque).
    83.     MENU_OPACITY = 128
    84.     # The BACKGROUND_BLENDING_COLOR is used to darken the background map
    85.     # picture so that it is less intrusive. I recommend leaving this as is,
    86.     # but if you want to change it, you can set the four numbers to any
    87.     # integer values in the range 0-255. The numbers are RGBA.
    88.     BACKGROUND_BLENDING_COLOR = Color.new(16, 16, 16, 128)
    89.     ######################################################################
    90.     # COMMAND OPTIONS #
    91.     # These options allow you to configure all of the menu commands.
    92.     # Big picture: Every command has a 'command key' associated it with.
    93.     # This allows you to link several different settings to the same command.
    94.     # The keys are all of the type ':key_name'. That is a colon followed
    95.     # by the key's name. As a rule, the keys should be all lowercase.
    96.     # Additionally every command will need a key placed in the COMMAND_ORDER,
    97.     # COMMAND_NAMES, and COMMAND_CALLS options below. It's optional for
    98.     # COMMAND_ACTOR_SELECT, and COMMAND_ACTOR_REQUIRED.
    99.     # Order of Commands #
    100.     # Place all of your command keys in between the two square brackets.
    101.     # Each key should be separated from the others with a comma.
    102.     # The order in which these keys are placed will determine their order
    103.     # in game, i.e. the first (top) key will be the first (top) command.
    104.     COMMAND_ORDER = [
    105.                     :item,
    106.                     :skill,                  
    107.                     :equip,
    108.                     :status,
    109.                     :save,
    110.                     :common_event,
    111.                     :end_game,                  
    112.                     ]
    113.     # Command Display Names #
    114.     # This links your command keys to their display text in game.
    115.     # In general, these will be the same but they might vary a little.
    116.     # Think of this like setting a 'word' in the database. In fact,
    117.     # this overwrites the database setting, so be sure to define them here.
    118.     # Each entry is a pair like this - :command_key => "Display Name"
    119.     # Separate entries with commas. The order of these entries does NOT
    120.     # affect the order in game.
    121.     COMMAND_NAMES = {
    122.                     :item         => "Item",
    123.                     :skill        => "Skill",
    124.                     :equip        => "Equip",
    125.                     :status       => "Status",
    126.                     :save         => "Save",
    127.                     :common_event => "Common Event 1",
    128.                     :end_game     => "End Game",                  
    129.                     }
    130.                
    131.     # Command Script Calls #
    132.     # This links your command keys to their script call.
    133.     # In general, these will be very similar to their key.
    134.     # If a script says you can call it by doing this:
    135.     # $scene = Scene_CustomScript.new
    136.     # You will likely need the 'Scene_CustomScript' part.
    137.     # You can also use numbers to indicate that you want to call
    138.     # a common event. Simply put the ID (as seen in the database) of
    139.     # the common event you want to call instead of a script call.
    140.     # Each entry is a pair like this - :command_key => Script_Call
    141.     # Separate entries with commas. The order of these entries does NOT
    142.     # affect the order in game.
    143.     COMMAND_CALLS = {
    144.                     :item         => Scene_Item,
    145.                     :skill        => Scene_Skill,
    146.                     :equip        => Scene_Equip,
    147.                     :status       => Scene_Status,
    148.                     :save         => Scene_Save,
    149.                     :end_game     => Scene_End,
    150.                     :common_event => 1,
    151.                     }
    152.     # Does Command Need Actor Select? #
    153.     # This sets which commands need to select an actor in the menu
    154.     # before moving to the next scene. In the default scripts, the
    155.     # skills, equip, and status commands need to know which actor
    156.     # you want to set before they move to their scenes. It's possible
    157.     # some custom commands may need this as well. Just place the
    158.     # command keys that need it here. If it doesn't need it, just
    159.     # leave it out. The order of these entries does NOT affect
    160.     # the order in game.
    161.     COMMAND_ACTOR_SELECT = [
    162.                            :skill,
    163.                            :equip,
    164.                            :status,
    165.                            ]
    166.     # Disable Command When Party Size Is Zero? #
    167.     # This sets which commands should be disabled when the party size
    168.     # is zero. In the default scripts, the item, skills, equip, and
    169.     # status commands are disabled when this is the case.
    170.     # It's possible some custom commands may need this as well.
    171.     # Just place the command keys that need it here. If it doesn't
    172.     # need it, just leave it out. The order of these entries
    173.     # does NOT affect the order in game.
    174.     COMMAND_ACTOR_REQUIRED = [
    175.                              :item,
    176.                              :skill,
    177.                              :equip,
    178.                              :status,
    179.                              ]
    180.     # Disable Actor Abilities when paralyzed ? #
    181.     # This sets which commands should be disabled when an actor is 'paralyzed'
    182.     # (or has a similar type of state). In the default scripts, the skills
    183.     # command is disabled when this is the case.
    184.     # It's possible some custom commands may need this as well.
    185.     # Just place the command keys that need it here. If it doesn't
    186.     # need it, just leave it out. The order of these entries
    187.     # does NOT affect the order in game.
    188.     COMMAND_ACTOR_ABILITIES = [
    189.                               :skill
    190.                               ]
    191.     # Disable Commands Via Switches #
    192.     # This allows you to disable individual commands via a switch.
    193.     # Adding an entry here will link the command to the chosen switch
    194.     # so that when you toggle the switch via events, it will enable
    195.     # or disable the connected command.
    196.     # Note that a switch being set to ON means that a command is ENABLED.
    197.     # If you don't need to disable a command then you can omit it.
    198.     # Each entry is a pair like this - :command_key => Switch_ID
    199.     # Separate entries with commas. The order of these entries does NOT
    200.     # affect the order in game.
    201.     COMMAND_DISABLE_SWITCH = {
    202.                              :skill => 1,
    203.                              }
    204.     # Save Command Key Is? #
    205.     # This sets which command key is the 'save' command key, so
    206.     # that it can be disabled whenever you disable saving via events.
    207.     # In general, you can leave the default save key alone in the
    208.     # above options and therefore leave this one alone too.
    209.     SAVE_COMMAND = :save
    210.   end
    211. end
    212. #==============================================================================
    213. # ** CUSTOMIZATION END
    214. #------------------------------------------------------------------------------
    215. # ** EDIT BELOW THIS LINE AT OWN RISK!!!
    216. #==============================================================================
    217. #==============================================================================
    218. # ** Scene_Base
    219. #==============================================================================
    220. class Scene_Base
    221.   #--------------------------------------------------------------------------
    222.   # * Play Decision SE
    223.   #--------------------------------------------------------------------------
    224.   def play_decision_se
    225.     $game_system.se_play($data_system.decision_se)
    226.   end
    227.   #--------------------------------------------------------------------------
    228.   # * Play Cancel SE
    229.   #--------------------------------------------------------------------------
    230.   def play_cancel_se
    231.     $game_system.se_play($data_system.cancel_se)
    232.   end
    233.   #--------------------------------------------------------------------------
    234.   # * Play Buzzer SE
    235.   #--------------------------------------------------------------------------
    236.   def play_buzzer_se
    237.     $game_system.se_play($data_system.buzzer_se)
    238.   end
    239. end
    240. #==============================================================================
    241. # ** Scene_Menu
    242. #==============================================================================
    243. class Scene_Menu < Scene_Base
    244.   #--------------------------------------------------------------------------
    245.   # * Configuration Binding
    246.   #--------------------------------------------------------------------------
    247.   include Mobius::Menu_Commands
    248.   #--------------------------------------------------------------------------
    249.   # * Object Initialization
    250.   #     menu_index : command cursor's initial position
    251.   #--------------------------------------------------------------------------
    252.   def initialize(menu_index = 0)
    253.     @menu_index = determine_starting_menu_index(menu_index)
    254.     @disabled_commands = []
    255.   end
    256.   #--------------------------------------------------------------------------
    257.   # * Main Processing
    258.   #--------------------------------------------------------------------------
    259.   def main
    260.     # Create all windows
    261.     create_windows
    262.     # Disable commands that apply
    263.     disable_commands
    264.     # Execute transition
    265.     Graphics.transition
    266.     # Main loop
    267.     loop do
    268.       # Update game screen
    269.       Graphics.update
    270.       # Update input information
    271.       Input.update
    272.       # Frame update
    273.       update
    274.       # Abort loop if screen is changed
    275.       if $scene != self
    276.         break
    277.       end
    278.     end
    279.     # Prepare for transition
    280.     Graphics.freeze
    281.     # Dispose of windows
    282.     dispose_windows
    283.   end
    284.   #--------------------------------------------------------------------------
    285.   # * Frame Update
    286.   #--------------------------------------------------------------------------
    287.   def update
    288.     # Update windows
    289.     @command_window.update
    290.     @gold_window.update
    291.     @status_window.update
    292.     # If command window is active: call update_command
    293.     if @command_window.active
    294.       update_command
    295.       return
    296.     end
    297.     # If status window is active: call update_status
    298.     if @status_window.active
    299.       update_status
    300.       return
    301.     end
    302.   end
    303.   #--------------------------------------------------------------------------
    304.   # * Frame Update (when command window is active)
    305.   #--------------------------------------------------------------------------
    306.   def update_command
    307.     # If B button was pressed
    308.     if Input.trigger?(Input::B)
    309.       on_exit
    310.       return
    311.     end
    312.     # If C button was pressed
    313.     if Input.trigger?(Input::C)
    314.       on_command
    315.     end
    316.   end
    317.   #--------------------------------------------------------------------------
    318.   # * Frame Update (when status window is active)
    319.   #--------------------------------------------------------------------------
    320.   def update_status
    321.     # If B button was pressed
    322.     if Input.trigger?(Input::B)
    323.       on_status_exit
    324.       return
    325.     end
    326.     # If C button was pressed
    327.     if Input.trigger?(Input::C)
    328.       on_status_command
    329.       return
    330.     end
    331.   end
    332.   #--------------------------------------------------------------------------
    333.   # * On Exit
    334.   #--------------------------------------------------------------------------
    335.   def on_exit
    336.     # Play cancel SE
    337.     play_cancel_se
    338.     # Switch to map screen
    339.     $scene = Scene_Map.new
    340.   end
    341.   #--------------------------------------------------------------------------
    342.   # * On Command
    343.   #--------------------------------------------------------------------------
    344.   def on_command
    345.     # Get index and key
    346.     index = @command_window.index
    347.     key = command_index_to_key(index)
    348.     # Exit processing if command is disabled
    349.     if command_disabled?(index)
    350.       command_fail
    351.     else
    352.       command_success(key)
    353.     end   
    354.   end
    355.   #--------------------------------------------------------------------------
    356.   # * Command Success
    357.   #--------------------------------------------------------------------------
    358.   def command_success(key)
    359.     play_decision_se
    360.     # If command needs actor selection
    361.     if COMMAND_ACTOR_SELECT.include?(key)
    362.       # Make status window active
    363.       activate_status_window
    364.     else
    365.       # Switch to new screen
    366.       process_command_call(key)
    367.     end
    368.   end
    369.   #--------------------------------------------------------------------------
    370.   # * Command Fail
    371.   #--------------------------------------------------------------------------
    372.   def command_fail
    373.     play_buzzer_se
    374.   end
    375.   #--------------------------------------------------------------------------
    376.   # * Activate Status Window
    377.   #--------------------------------------------------------------------------
    378.   def activate_status_window
    379.     @command_window.active = false
    380.     @status_window.active  = true
    381.     @status_window.index   = 0
    382.   end
    383.   #--------------------------------------------------------------------------
    384.   # * On Status Exit
    385.   #--------------------------------------------------------------------------
    386.   def on_status_exit
    387.     play_cancel_se
    388.     # Make command window active
    389.     @command_window.active = true
    390.     @status_window.active = false
    391.     @status_window.index = -1
    392.   end
    393.   #--------------------------------------------------------------------------
    394.   # * On Status Command
    395.   #--------------------------------------------------------------------------
    396.   def on_status_command
    397.     # Get index and key
    398.     index = @command_window.index
    399.     key = command_index_to_key(index)
    400.     # If this actor's action limit is 2 or more
    401.     if actor_unable?(key)
    402.       # Play buzzer SE
    403.       $game_system.se_play($data_system.buzzer_se)
    404.       return
    405.     end
    406.     # Play decision SE
    407.     play_decision_se     
    408.     # Switch to new screen
    409.     process_command_call(key, true)
    410.   end
    411. #--------------------------------------------------------------------------
    412.   # * Actor Able?
    413.   #--------------------------------------------------------------------------
    414.   def actor_unable?(key)
    415.     # If this command should be disabled when the actor is 'paralyzed'
    416.     # and if the actor's action limit is 2 or more (is paralyzed)
    417.     (COMMAND_ACTOR_ABILITIES.include?(key)) and
    418.     ($game_party.actors[@status_window.index].restriction >= 2)
    419.   end
    420.   #--------------------------------------------------------------------------
    421.   # * Process Command Call
    422.   #--------------------------------------------------------------------------
    423.   def process_command_call(key, status_window = false)
    424.     # Get command call
    425.     call = COMMAND_CALLS[key]
    426.     # If call is a Class, treat as a scene class
    427.     if call.is_a?(Class)
    428.       # If call was made from the status window, pass in the status window index
    429.       if status_window
    430.         $scene = call.new(@status_window.index)
    431.       else
    432.         $scene = call.new
    433.       end
    434.     # If call is a number, treat as a Common Event ID
    435.     elsif call.is_a?(Integer) and call > 0
    436.       # Common event call reservation
    437.       $game_temp.common_event_id = call
    438.       # Switch to map screen
    439.       $scene = Scene_Map.new
    440.       return
    441.     end
    442.   end
    443.   #--------------------------------------------------------------------------
    444.   # * Create Windows
    445.   #--------------------------------------------------------------------------
    446.   def create_windows
    447.     create_command_window
    448.     create_status_window
    449.     create_gold_window
    450.     create_background_sprite
    451.   end
    452.   #--------------------------------------------------------------------------
    453.   # * Create Command Window
    454.   #--------------------------------------------------------------------------
    455.   def create_command_window
    456.     commands = COMMAND_ORDER.collect { |cmd| COMMAND_NAMES[cmd] }
    457.     # Make command window
    458.     @command_window = Window_Command.new(160, commands)
    459.     @command_window.index = @menu_index
    460.     @command_window.opacity = MENU_OPACITY
    461.   end
    462.   #--------------------------------------------------------------------------
    463.   # * Create Status Window
    464.   #--------------------------------------------------------------------------
    465.   def create_status_window
    466.     # Make status window
    467.     @status_window = Window_MenuStatus.new
    468.     @status_window.x = 160
    469.     @status_window.y = 0
    470.     @status_window.opacity = MENU_OPACITY
    471.   end
    472.   #--------------------------------------------------------------------------
    473.   # * Create Gold Window
    474.   #--------------------------------------------------------------------------
    475.   def create_gold_window
    476.     # Make gold window
    477.     @gold_window = Window_Gold.new
    478.     @gold_window.x = 0
    479.     @gold_window.y = 416
    480.     @gold_window.opacity = MENU_OPACITY
    481.   end
    482.   #--------------------------------------------------------------------------
    483.   # * Create Background Sprite
    484.   #--------------------------------------------------------------------------
    485.   def create_background_sprite
    486.     @background_sprite = Sprite.new
    487.     @background_sprite.bitmap = $game_temp.background_sprite
    488.     @background_sprite.color = BACKGROUND_BLENDING_COLOR
    489.   end
    490.   #--------------------------------------------------------------------------
    491.   # * Dispose Windows
    492.   #--------------------------------------------------------------------------
    493.   def dispose_windows
    494.     # Dispose of windows
    495.     @command_window.dispose
    496.     @gold_window.dispose
    497.     @status_window.dispose   
    498.     @background_sprite.dispose
    499.   end
    500.   #--------------------------------------------------------------------------
    501.   # * Disable Commands
    502.   #--------------------------------------------------------------------------
    503.   def disable_commands
    504.     # Check/Execute disable of party items
    505.     disable_on_zero_party?
    506.     # Check/Execute disable of saving
    507.     disable_save?
    508.     # Disable arbitrary commands if they have a switch
    509.     disable_switched?
    510.   end
    511.   #--------------------------------------------------------------------------
    512.   # * Disable On Zero Party
    513.   #--------------------------------------------------------------------------
    514.   def disable_on_zero_party?
    515.     # If number of party members is 0
    516.     if $game_party.actors.size == 0
    517.       # Disable all items in command_actor_required
    518.       COMMAND_ACTOR_REQUIRED.each { |cmd_key| disable_command(cmd_key) }
    519.     end
    520.   end
    521.   #--------------------------------------------------------------------------
    522.   # * Disable Save?
    523.   #--------------------------------------------------------------------------
    524.   def disable_save?
    525.     # If save is forbidden
    526.     if $game_system.save_disabled
    527.       # Disable save
    528.       save_command_key = SAVE_COMMAND
    529.       disable_command(save_command_key)
    530.     end
    531.   end
    532.   #--------------------------------------------------------------------------
    533.   # * Disable Switched?
    534.   #--------------------------------------------------------------------------
    535.   def disable_switched?
    536.     COMMAND_DISABLE_SWITCH.each do |cmd_key, switch_id|
    537.       if not $game_switches[switch_id]
    538.         disable_command(cmd_key)
    539.       end
    540.     end
    541.   end
    542.   #--------------------------------------------------------------------------
    543.   # * Disable Command
    544.   #--------------------------------------------------------------------------
    545.   def disable_command(key)
    546.     # Get command index
    547.     index = command_key_to_index(key)
    548.     # Set text to disabled
    549.     @command_window.disable_item(index)
    550.     # Add index to disabled commands
    551.     @disabled_commands.push(index).uniq!
    552.   end
    553.   #--------------------------------------------------------------------------
    554.   # * Enable Command
    555.   #--------------------------------------------------------------------------
    556.   def enable_command(key)
    557.     # Get comand index
    558.     index = command_key_to_index(key)
    559.     # Set text to disabled
    560.     @command_window.disable_item(index)
    561.     # Add index to disabled commands
    562.     @disabled_commands.delete(index)
    563.   end
    564.   #--------------------------------------------------------------------------
    565.   # * Command Disabled?
    566.   #--------------------------------------------------------------------------
    567.   def command_disabled?(index)
    568.     return @disabled_commands.include?(index)
    569.   end
    570.   #--------------------------------------------------------------------------
    571.   # * Command Key to Index
    572.   #--------------------------------------------------------------------------
    573.   def command_key_to_index(key)
    574.     return COMMAND_ORDER.index(key)
    575.   end
    576.   #--------------------------------------------------------------------------
    577.   # * Command Index to Key
    578.   #--------------------------------------------------------------------------
    579.   def command_index_to_key(index)
    580.     return COMMAND_ORDER.at(index)
    581.   end
    582.   #--------------------------------------------------------------------------
    583.   # * Determine Starting Menu Index
    584.   #--------------------------------------------------------------------------
    585.   def determine_starting_menu_index(menu_index)
    586.     # Get the previous scene type
    587.     last_scene = $scene.class
    588.     # Does the previous scene type match one
    589.     # of the command calls that we know?
    590.     if COMMAND_CALLS.has_value?(last_scene)
    591.       # Get the key for that scene type
    592.       key = COMMAND_CALLS.index(last_scene)
    593.       # Use key to get menu index
    594.       return COMMAND_ORDER.index(key)
    595.     else
    596.       # return whatever was passed/the default value of 0
    597.       return menu_index
    598.     end
    599.   end
    600. end
    601. #==============================================================================
    602. # ** Game_Temp
    603. #==============================================================================
    604. class Game_Temp
    605.   #--------------------------------------------------------------------------
    606.   # * Public Instance Variables
    607.   #--------------------------------------------------------------------------
    608.   attr_accessor :background_sprite # for saving a snapshot of the game map
    609.   #--------------------------------------------------------------------------
    610.   # * Object Initialization
    611.   #--------------------------------------------------------------------------
    612.   alias mobius_initialize initialize
    613.   def initialize
    614.     mobius_initialize
    615.     @background_sprite = nil
    616.   end
    617. end
    618. #==============================================================================
    619. # ** Scene_Map
    620. #==============================================================================
    621. class Scene_Map
    622.   #--------------------------------------------------------------------------
    623.   # * Menu Call
    624.   #--------------------------------------------------------------------------
    625.   alias mobius_call_menu call_menu
    626.   def call_menu
    627.     mobius_call_menu
    628.     $game_temp.background_sprite = Graphics.snap_to_bitmap
    629.   end
    630. end
    631. # Bitmap Export v5.4 for XP, VX and VXace by Zeus81
    632. # Free for commercial use
    633. # Licence : http://creativecommons.org/licenses/by/4.0/
    634. # Contact : zeusex81@gmail.com
    635. # Original script trimmed to just 'Graphics.snap_to_bitmap'
    636. module Graphics
    637.   FindWindow             = Win32API.new('user32', 'FindWindow'            , 'pp'       , 'i')
    638.   GetDC                  = Win32API.new('user32', 'GetDC'                 , 'i'        , 'i')
    639.   ReleaseDC              = Win32API.new('user32', 'ReleaseDC'             , 'ii'       , 'i')
    640.   BitBlt                 = Win32API.new('gdi32' , 'BitBlt'                , 'iiiiiiiii', 'i')
    641.   CreateCompatibleBitmap = Win32API.new('gdi32' , 'CreateCompatibleBitmap', 'iii'      , 'i')
    642.   CreateCompatibleDC     = Win32API.new('gdi32' , 'CreateCompatibleDC'    , 'i'        , 'i')
    643.   DeleteDC               = Win32API.new('gdi32' , 'DeleteDC'              , 'i'        , 'i')
    644.   DeleteObject           = Win32API.new('gdi32' , 'DeleteObject'          , 'i'        , 'i')
    645.   GetDIBits              = Win32API.new('gdi32' , 'GetDIBits'             , 'iiiiipi'  , 'i')
    646.   SelectObject           = Win32API.new('gdi32' , 'SelectObject'          , 'ii'       , 'i')
    647.   def self.snap_to_bitmap
    648.     bitmap  = Bitmap.new(width, height)
    649.     info    = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
    650.     hDC     = GetDC.call(hwnd)
    651.     bmp_hDC = CreateCompatibleDC.call(hDC)
    652.     bmp_hBM = CreateCompatibleBitmap.call(hDC, width, height)
    653.     bmp_obj = SelectObject.call(bmp_hDC, bmp_hBM)
    654.     BitBlt.call(bmp_hDC, 0, 0, width, height, hDC, 0, 0, 0xCC0020)
    655.     GetDIBits.call(bmp_hDC, bmp_hBM, 0, height, bitmap.last_row_address, info, 0)
    656.     SelectObject.call(bmp_hDC, bmp_obj)
    657.     DeleteObject.call(bmp_hBM)
    658.     DeleteDC.call(bmp_hDC)
    659.     ReleaseDC.call(hwnd, hDC)
    660.     bitmap
    661.   end
    662.   class << self
    663.     def hwnd() @hwnd ||= FindWindow.call('RGSS Player', nil) end
    664.     def width()  640 end unless method_defined?(:width)
    665.     def height() 480 end unless method_defined?(:height)
    666.   end
    667. end
    668. class Bitmap
    669.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ppi', 'i')
    670.   def last_row_address
    671.     return 0 if disposed?
    672.     RtlMoveMemory.call(buf=[0].pack('L'), __id__*2+16, 4)
    673.     RtlMoveMemory.call(buf, buf.unpack('L')[0]+8 , 4)
    674.     RtlMoveMemory.call(buf, buf.unpack('L')[0]+16, 4)
    675.     buf.unpack('L')[0]
    676.   end
    677. end
    复制代码








    FAQ
    Q. Can this do _______?
    A. Maybe! Leave a post on the forum, and I might just add the feature if it can't already do it.

    Q. My persistent states don't work properly anymore. Help!
    A. This was a known bug in previous versions. This was fixed in version 1.6; update to it to fix this problem!

    Credits and Thanks
    - MobiusXVI, author
    - Zeus81, for his 'Bitmap Export' script

    License
    This script is available in its entirety for commercial and non-commercial use. View the full license terms in the script header.


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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-26 02:42 , Processed in 0.147637 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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