Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Menu Messages
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.0
- # * Updated: 21/11/2018
- # * Requires: --------
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (21/11/2018)
- # - Initial release.
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This script will let you add menu messages that look and work just like the
- # message window on the map.
- # * You can also use it as a "tutorial" making script, since it supports many
- # ways of changing the scene in real time.
- # ~ Deactivate/activate any windows (or other objects) before or after the
- # menu message(s).
- # ~ Trigger custom made methods before or after the menu message(s).
- # ~ Show consecutive menu messages that will trigger automatically.
- # * This script requires at least some scripting knowledge!
- #-------------------------------------------------------------------------------
- # * < Script Calls >
- #-------------------------------------------------------------------------------
- # * To activate a menu message for a scene, you will have to add the message
- # data to the variable that will store and process it. Do that with this
- # script call:
- #
- # $game_system.add_menu_msg('key',message_data)
- #
- # The 'key' should be the name of the scene you want the message to trigger
- # in. It must be a string!
- #
- # The message_data can be setup in two ways:
- # 1. Use a setting key from the 'MMsgs' setting area found in this script.
- # If you do this, the settings you have setup under that setting key will
- # be loaded automatically.
- # I recommend this way, since it's easier to setup the data in the script
- # than in that little script call box.
- # 2. Use a hash with the message settings. This hash must contain the same
- # options as the ones found in the 'Defaults' setting area in this script.
- # You can omit any option you want, in which case the mentioned default
- # option values will be loaded for them.
- #
- # If you use the current scene's class name in this script call for the 'key',
- # and set the :instant option to true in the message data, the message will
- # trigger immediately. Otherwise it will run the next time the player enters
- # the specified scene.
- #
- # Note that using 'Scene_Map' for the 'key' is something I did not test, since
- # this script is made to be used in menus mainly.
- # Regardless, I don't see a reason why it shouldn't work even on the map, so
- # go nuts with it if you want. :D
- #
- # Examples:
- #
- # $game_system.add_menu_msg('Scene_Menu','menu_part1')
- # $game_system.add_menu_msg('Scene_Item','item_part1')
- # $game_system.add_menu_msg('Scene_Skill','skill_spec')
- #
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * To clear a menu message, you can use this script call:
- #
- # $game_system.del_menu_msg('key')
- #
- # The 'key' should be a previously used scene name in the add_menu_msg script
- # call. If there is no menu message added with the specified key, nothing will
- # happen.
- #
- # Examples:
- #
- # $game_system.del('Scene_Save')
- # $game_system.del('Scene_Formation')
- # $game_system.del('MyCustomScene')
- #
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this scipt between Materials and Main!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities, but depending on the scene you use these menu
- # messages, things can happen.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- # * Well, if you don't have any scripting knowledge, you may have a hard time
- # with this script, but that can't be helped, sorry.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthMMsgs"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module MenuMsgD
- #-----------------------------------------------------------------------------
- # Default Settings:
- #-----------------------------------------------------------------------------
- # You can setup the default settings for your menu messages here.
- # If some option is missing from the message data you used in the add_menu_msg
- # script call, it will be loaded from here automatically.
- #
- # There are many options here, so lets check them all...
- #
- # :scroll_mode => false,
- # Lets get this out of the way quickly...
- # This setting is just here in case I decide to make it possible to use
- # scrolling menu messages. The chance of that happening is close to zero, so
- # don't hold your breath. :D
- # Bottom line, scrolling messages are NOT supported at the moment, so you
- # should NOT change this setting at all, nor should you use this option in
- # any of your message data settings!
- #
- # :pos => [x,y],
- # This will decide the position of the message window.
- # If you want to move around the message window in your menus, you will have
- # to trigger a new menu message or make your own methods for moving the menu
- # message window and trigger those methods with the :method1 or :method2
- # options (those options are explained somewhere below too).
- # Both the x and y must be an integer number!
- #
- # :size => [width,height],
- # The size of the menu message window.
- # Like with moving the window, if you want to resize the window, you either
- # trigger a new menu message, or use your own methods to do so.
- # Both the width and height must be an integer number!
- #
- # :z => value,
- # This is the Z level of the message window.
- # Depending on the scene the message window is, you may have to increase or,
- # in some rare cases, decrease this value.
- # This option must be set to an integer number!
- #
- # :view => '@viewport_name',
- # This option will let you assign a viewport to the message window.
- # Note that the viewport must be an instance variable of the scene the message
- # window is triggered in! You must use the name of the instance variable
- # storing the viewport.
- # If you use nil, the message window will use it's default viewport, which is
- # actually... nil. :D
- # Depending on the scene, you may need to set a viewport to the window.
- #
- # :background => type,
- # The background type of the message window.
- # It can be set to the following values:
- # 0 - "Normal Window" mode.
- # 1 - "Dim Background" mode.
- # 2 - "Transparent" mode.
- #
- # :skin => "windowskin_filename",
- # This will setup the windowskin used for the menu message.
- # The default windowskin is the "Window" image in any project that didn't
- # modify this part of the game, so I recommend you to leave this option with
- # that windowskin name here, and change it in your message data if needed.
- # All windowskin image files must be in the "Graphics/System/" folder of your
- # project!
- # The windowskin of the message window only matters if you have set the
- # :background option to 0.
- #
- # :back_color1 => Color.new(R,G,B,A),
- # :back_color2 => Color.new(R,G,B,A),
- # The colors of the "Dim Background" mode for the window.
- # One of them is the color in the center of the dim background sprite, and
- # the other is the edge of the sprite. Don't ask me which one is which, I
- # kinda forgot. :D
- # These colors only matter if you have set the :background option to 1.
- # Replace the R, G, B and A parts with integer numbers from 0 to 255.
- # These represent the color's red, green. blue and alpha values.
- #
- # :face_img => "face_image_name",
- # :face_index => face_index,
- # These options will setup the face graphic of the message window.
- # If you use an empty string ( "" ) for the :face_img option, no face graphic
- # will be used, otherwise it will load the image you specified from the
- # "Graphcis/Faces/" folder of your project.
- # The :face_index will decide which face will be shown from the image. It
- # must be an integer number from 0 to 7, which represent the 8 face images on
- # your image sheet.
- #
- # :namepos => [x,y],
- # The position of the name window if the message window got one.
- # This requires Yanfly's Ace Message System script!
- # The x and y must be an integer number!
- #
- # :text => "your text here, yay!",
- # The text of the message window. The window will show this text in the menu.
- # You can usse any message codes available for the regular message window on
- # the map here too.
- # The text will be shown the same way like the map message window would show
- # it, so depending on the size of your menu window, either all text is shown,
- # or just parts of it, and the player will need to press the confirm button to
- # proceed to the next page of the text.
- # Once all text is processed, the message window will close, and the scene
- # will start to process your :win2 and/or :method2 options if you used them
- # in your message data settings.
- #
- # :instant => true/false,
- # When you add a menu message with the same key as the current scene's name,
- # you have the option to run that message immediately or the next time the
- # player enters that scene.
- # Use true here to trigger it immediately, or false to trigger it the next
- # time the scene starts.
- #
- # :times => amount,
- # This will decide how many times the menu message will show up before it's
- # deleted from the menu message storage.
- # Most of the times it is pointless to set this higher than 1, since the main
- # point of this script is to make tutorials for your menus, but in case you
- # want repeated messages for something, you can setup how many times it will
- # repeat before it's deleted.
- # Use 0 to make the menu message premanent. Caution! It will trigger every
- # single time the specified scene is opened this way unless you remove the
- # menu message manually with the del_menu_msg script call!
- # Use integer numbers above 0 to set the repeat amount to that value.
- #
- # :win1 => '@window_name',
- # :win2 => '@window_name',
- # These options will let you deactivate and activate windows before and after
- # the menu message.
- # The :win1 option sets up the window to deactivate before the menu message.
- # The :win2 option sets up the window to activate after the menu message.
- # Both of them must be set to a valid instance variable name, and that
- # instance variable must be a window or some other object that has the methods
- # 'activate' and 'deactivate' defined.
- # Yuu will have to search for the correct window/object names in the scene
- # classes you want to show the menu message, there is no way around this.
- # You can also set them to nil, which means no window will get
- # deactivated/activated.
- #
- # :method1 => ['method_name', arg1, arg2, ...],
- # :method2 => ['method_name', arg1, arg2, ...],
- # These options will let you run your custom methods before or after the menu
- # message.
- # The method set for the :method1 option will run before the menu message.
- # The method set for the :method2 option will run after the menu message.
- # The 'method_name' must be the name of a valid method defined in the scene
- # or it's parent class(es) where the menu message is triggered.
- # The arg1, arg2, ... are the arguments passed for the specified method.
- # These arguments can be almost anything. Just be aware that they are
- # evaluated right on game startup, so you can't use certain variables that
- # are not yet defined at that time. You can still connect these arguments to
- # those variables in your method if needed, of course.
- # Setting these options to nil will disable this feature, so no methods will
- # run before and/or after the menu message.
- #
- # :next => "setting_key",
- # This option will let you trigger consecutive menu messages.
- # When the current message ends, and this option is set to something other
- # than nil, it will make the specified menu message trigger.
- # The "setting_key" must be a valid setting key used in the 'MMsgs' setting
- # area found right below this setting area.
- #
- # And these are all the options you can setup at the moment.
- # Note that any options loaded for the menu message window will stay until
- # you trigger another menu message window with different message data.
- # You can change the message window's position, size, background, etc by
- # triggering another menu message, or by using the :method1 and/or :method2
- # options (you can do anything in your methods, so of course, you can change
- # the properties of the menu message window in them too if you want).
- #
- #-----------------------------------------------------------------------------
- Defaults = {
- :scroll_mode => false, # Scrolling message is NOT supported, leave on false!
- :pos => [0,288],
- :size => [544,128],
- :z => 2000,
- :view => nil,
- :background => 1,
- :skin => "Window",
- :back_color1 => Color.new(0,0,0,250),
- :back_color2 => Color.new(0,0,0,200),
- :face_img => "",
- :face_index => 0,
- :namepos => [0,0],
- :text => "",
- :instant => false,
- :times => 1, # Amount of times the message is active
- :win1 => nil, # Deactivate this window before the message
- :win2 => nil, # Activate this window after the message
- :method1 => nil, # Method to run before the message
- :method2 => nil, # Method to run after the message
- :next => nil, # Triggers another message after the current one end
- }
- #-----------------------------------------------------------------------------
- # Menu Message Settings:
- #-----------------------------------------------------------------------------
- # You can setup pre-made menu message data here to be used in the add_menu_msg
- # script call.
- #
- # The format for a message data setting looks like this:
- #
- # 'setting_key' => { * message options go here * },
- #
- # The 'setting_key' must be a string!
- # It can be any string, just don't make duplicate key names!
- #
- # And the options are the same ones explained in the above setting area.
- # Any options you don't setup will be loaded from the 'Defaults' setting area
- # automatically, so you should only setup what you want to change from those
- # defaults to save some space.
- #
- # Note that it's possible to lock the player out from any inputs forever if
- # you are not careful, so use logic and common sense in your methods and
- # window activation changes!
- #
- # I made a few examples, so you can check how these settings work in the game.
- # Just use the "xxxx_part1" setting keys in the add_menu_msg script call, and
- # assign them to the correct scenes to trigger these in the game.
- #
- # You can see that I used a custom method named 'cursor_change' in the item
- # menu settings. That method will move the category window's cursor around.
- # I won't explain how that works, you can check the method in the script if
- # you are interested. I noted in the header of this script that you will need
- # scripting knowledge to use the more advanced features of this script.
- #-----------------------------------------------------------------------------
- MMsgs = {
- #-----------------------------------------------------------------------------
- 'menu_part1' => {
- :win1 => '@command_window',
- :pos => [(Graphics.width-400)/2,(Graphics.height-96)/2],
- :size => [400,96],
- :text => "Welcome to the menu tutorial!\n"+
- "This tutorial will explain how the menu works.\n"+
- "Lets get started!",
- :next => 'menu_part2',
- },
- 'menu_part2' => {
- :win2 => '@command_window',
- :pos => [(Graphics.width-400)/2,(Graphics.height-72)/2],
- :size => [400,72],
- :text => "Select a command from the list.\n"+
- "You will move to that part of the menu.",
- },
- #-----------------------------------------------------------------------------
- 'item_part1' => {
- :view => "@viewport",
- :win1 => '@category_window',
- :pos => [(Graphics.width-400)/2,(Graphics.height-72)/2],
- :size => [400,72],
- :text => "This menu will list all of your items currently owned.\n"+
- "Your items are categorized based on their type.",
- :next => 'item_part2',
- },
- 'item_part2' => {
- :view => "@viewport",
- :pos => [(Graphics.width-500)/2,(Graphics.height-96)/2],
- :size => [500,96],
- :text => "Your consumable items are listed under the \\c[17]Items\\c[0] category.\n"+
- "Use your items from this list if needed.\n"+
- "Note that certain items can only be used in battle, or not at all!",
- :method2 => ['cursor_change',['@category_window',1,30]], # Move to the next command
- :next => 'item_part3'
- },
- 'item_part3' => {
- :view => "@viewport",
- :pos => [(Graphics.width-530)/2,(Graphics.height-96)/2],
- :size => [530,96],
- :text => "All of your weapons are listed under the \\c[17]Weapons\\c[0] category.\n"+
- "You can check or discard (not really) your weapons from this list if needed.\n"+
- "Note that equipped weapons will not show up on the list!",
- :method2 => ['cursor_change',['@category_window',1,30]], # Move to the next command
- :next => 'item_part4'
- },
- 'item_part4' => {
- :view => "@viewport",
- :pos => [(Graphics.width-510)/2,(Graphics.height-96)/2],
- :size => [510,96],
- :text => "All of your armors are listed under the \\c[17]Armors\\c[0] category.\n"+
- "You can check or discard (not really) your armors from this list if needed.\n"+
- "Note that equipped armors will not show up on the list!",
- :method2 => ['cursor_change',['@category_window',1,30]], # Move to the next command
- :next => 'item_part5'
- },
- 'item_part5' => {
- :view => "@viewport",
- :pos => [(Graphics.width-560)/2,(Graphics.height-96)/2],
- :size => [560,96],
- :text => "Special items are listed under the \\c[17]Key Items\\c[0] category.\n"+
- "These items are needed for story progression or to trigger other special events.\n"+
- "You can use some of these items just like regular consumables.",
- :next => 'item_part6'
- },
- 'item_part6' => {
- :view => "@viewport",
- :win2 => '@category_window',
- :pos => [(Graphics.width-400)/2,(Graphics.height-72)/2],
- :size => [400,72],
- :text => "And that concludes our little tour of the item menu.\n"+
- "Exit the item menu to continue with the menu tutorial.",
- :method2 => ['cursor_change',['@category_window',-1,30],['@category_window',-1,30],['@category_window',-1,30]],
- },
- #-----------------------------------------------------------------------------
- # <-- Add more settings here if needed!
- }
- end
- #===============================================================================
- # End of settings! Editing anything below may lead to... you know it, right? o.o
- #===============================================================================
- class Game_System
- attr_accessor :menu_msg
- def menu_msg
- @menu_msg = {} if @menu_msg.nil?
- return @menu_msg
- end
- def add_menu_msg(mky,mdt={})
- unless mdt.is_a?(Hash)
- return unless MenuMsgD::MMsgs[mdt]
- mdt = MenuMsgD::MMsgs[mdt].clone
- end
- self.menu_msg[mky] = mdt
- cname = SceneManager.scene.class.to_s
- if mky == cname && mdt[:instant]
- win1 = menu_msg[mky][:win1]
- win2 = menu_msg[mky][:win2]
- SceneManager.scene.start_message(mky,$game_system.menu_msg[mky],win1,win2)
- end
- end
- def del_menu_msg(mky)
- self.menu_msg.delete(mky)
- end
- end
- class Game_Message
- attr_accessor :size, :name_pos, :skin, :z, :back_color1, :back_color2
- end
- class Scene_Base
- alias add_mmsg0017 post_start
- def post_start
- add_mmsg0017
- cname = self.class.to_s
- if $game_system.menu_msg[cname]
- win1 = $game_system.menu_msg[cname][:win1]
- win2 = $game_system.menu_msg[cname][:win2]
- start_message(cname,$game_system.menu_msg[cname],win1,win2)
- end
- end
- def start_message(mky,msg,win1,win2)
- @mky = mky
- setup_message(msg)
- create_msg_win(msg,win1,win2)
- end
- def setup_message(msg={})
- msg = MenuMsgD::Defaults.merge(msg)
- $game_message.face_name = msg[:face_img]
- $game_message.face_index = msg[:face_index]
- $game_message.background = msg[:background]
- $game_message.scroll_mode = msg[:scroll_mode]
- $game_message.position = msg[:pos]
- $game_message.name_pos = msg[:namepos]
- $game_message.size = msg[:size]
- $game_message.skin = msg[:skin]
- $game_message.z = msg[:z]
- $game_message.back_color1 = msg[:back_color1]
- $game_message.back_color2 = msg[:back_color2]
- $game_message.add(msg[:text])
- end
- def win_operation(win,*mtd)
- instance_variable_get(win).send(*mtd)
- end
- def cursor_change(*changes)
- changes.each do |change|
- rwin = instance_variable_get(change[0])
- rwin.select(rwin.index + change[1])
- Sound.play_cursor
- change[2].times { update }
- end
- end
- def create_msg_win(msg,win1=nil,win2=nil)
- send(*msg[:method1]) if msg[:method1]
- win_operation(win1,'deactivate') if win1
- @message = MenuMessageD.new(*$game_message.position,*$game_message.size)
- if msg[:view]
- view = instance_variable_get(msg[:view])
- @message.viewport = view
- end
- while $game_message.busy?
- update
- end
- until @message.openness <= 0
- update
- end
- @message.dispose
- @message = nil
- send(*msg[:method2]) if msg[:method2]
- win_operation(win2,'activate') if win2
- if $game_system.menu_msg[@mky] && $game_system.menu_msg[@mky][:times] > 0
- $game_system.menu_msg[@mky][:times] -= 1
- $game_system.menu_msg.delete(@mky) if $game_system.menu_msg[@mky][:times] <= 0
- end
- if msg[:next]
- nmsg = MenuMsgD::MMsgs[msg[:next]]
- start_message(msg[:next],nmsg,nmsg[:win1],nmsg[:win2])
- end
- end
- end
- class MenuMessageD < Window_Message
- def initialize(x,y,w,h)
- @fiber = nil
- super()
- self.x = @back_sprite.x = x
- self.y = @back_sprite.y = y
- self.width = w
- self.height = h
- self.windowskin = Cache.system($game_message.skin)
- self.z = $game_message.z
- create_contents
- end
- def window_width
- return $game_message.size[0]
- end
- def window_height
- return $game_message.size[1]
- end
- def viewport=(view)
- super
- @back_sprite.viewport = view
- end
- if $imported["YEA-MessageSystem"]
- def adjust_message_window_size
- start_name_window
- end
- end
- def update
- return if self.disposed?
- super
- end
- def update_placement
- # Removed!
- end
- def back_color1
- return $game_message.back_color1
- end
- def back_color2
- return $game_message.back_color2
- end
- end
- if $imported["YEA-MessageSystem"]
- class Window_NameMessage < Window_Base
- alias add_menupos9986 set_x_position
- def set_x_position(x_position)
- if SceneManager.scene_is?(ABSScene)
- self.x = $game_message.name_pos[0]
- else
- add_menupos9986(x_position)
- end
- end
- alias add_menupos1186 set_y_position
- def set_y_position
- if SceneManager.scene_is?(ABSScene)
- self.y = $game_message.name_pos[1]
- else
- add_menupos1186
- end
- end
- end
- end # YEA Msg check end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement