Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Image Grid Menu
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.4
- # * Updated: 27/05/2016
- # * Requires: -------
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (04/03/2016)
- # - Initial release.
- # * Version 1.1 (04/03/2016)
- # - The cursor sound will not play anymore if the cursor can't move in the
- # pressed direction.
- # - Added a new option which enables you to show a special "command" when the
- # regular command list is empty. This can only happen if all of the commands
- # are hidden when the grid menu is opened.
- # - The above new feature fixes the crashing issues when the list is empty.
- # - Added a new feature which lets you skip columns and rows forcibly after a
- # command. Can be useful in some menu types.
- # * Version 1.2 (14/03/2016)
- # - Added an optional feature which lets you set up texts for the help images.
- # * Version 1.3 (19/03/2016)
- # - Added some new options for setting up the position of the grid and images.
- # This will allow you to make dynamic position settings based on the current
- # resolution of your game. These settings should work with all resolution
- # changing scripts.
- # * Version 1.4 (27/05/2016)
- # - Fixed a crash issue with the dynamic position settings (from v1.3).
- # - Fixed a specific crash issue which happens with grid "windows" disposed
- # before the termination of the scene (when the 'update' method is running).
- # - Fixed numerous visual errors regarding the image animations.
- # - The grid commands can now scroll in any directions on their own viewport.
- # This makes it possible to show infinite amount of commands without them
- # getting out of screen. Arrow pointers will indicate if the commands can
- # be scrolled in a specific direction or not.
- # - You can now use horizontal and vertical image sheets as well for your
- # animated images. This setting is not a global setting, so you can mix
- # horizontal and vertical image sheets if you want.
- # - Added a new setting which lets you set specific/additional horizontal and
- # vertical spacing for each of your commands. Now you can make not so
- # grid-like command lists too if you want.
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This script will let you make a new scene which can be whatever you want it
- # to be. For example, it can be a menu for:
- # - Displaying help information / game manual.
- # - Displaying achievements in your game.
- # - Stage selection.
- # - Quick travel menu.
- # And there can be many other uses as well...
- # Some examples above require scripting knowledge!
- # * The menu is fully image based!
- # * The menu can be fully animated with many effects available!
- # * You can make unlimited amount of these new grid menus!
- # Want one for game manual, one for quick travel menu and another one for
- # achievements? No problem, you can do it! That is, if you don't mind to
- # setup all of them. :P
- # * People with some scripting knowledge can trigger any method/code for any
- # command button! This makes the grid menu a pretty versatile one.
- # * Advanced scripters can re-use the new classes from this script to make their
- # own menu with one or even more grid selection command "windows".
- #-------------------------------------------------------------------------------
- # * < Script Calls >
- #-------------------------------------------------------------------------------
- # * To open the new image grid menu, use this script call:
- #
- # open_grid_menu(module_name)
- #
- # The argument 'module_name' is an optional one.
- # If you don't plan to make more image grid menus you can ignore it.
- #
- # If you want, however, you can copy the module settings in the script (the
- # entire settings area enclosed with the module name and the 'end' line) and
- # paste it into it's own slot in the script editor (or below the default
- # settings, but that would kill your scroll button on your mouse, right? :P).
- # After this, just rename the name of the module to whatever you want (just
- # make sure that no other script uses that name for any class/module), and
- # set up the settings for it however you want.
- # With this done, now you can open the new menu you just set up by using it's
- # module name as an argument in the above mentioned script call.
- #
- # Examples:
- #
- # open_grid_menu
- # Opens the default grid menu (which uses the 'SGridMenu' module name).
- #
- # open_grid_menu(SGridMenu_2)
- # Opens a grid menu using the settings in the 'SGridMenu_2' module.
- #-------------------------------------------------------------------------------
- # * < Image Setup >
- #-------------------------------------------------------------------------------
- # * The command images can be animated by using a sprite-sheet.
- # This sprite-sheet must follow some rules or else the animation will look
- # weird or flat out bad.
- # These rules are:
- # - The animation frames must be lined up vertically or horizontally
- # on the sprite-sheet.
- # - These frames are indexed, and these indexes are used in the animation
- # settings in the script.
- # The first image frame's index is 0 (top one for horizontal sheets and
- # left-most one for vertical sheets), the second is 1, and so on!
- # - All frames on the sprite-sheet must use the same dimensions!
- # If the 1st frame is 32x32 (width x height), all the others must use the
- # same dimensions!
- # - A sprite-sheet can have unlimited number of frames!
- # * A little visual representation showing the index numbers of the image
- # frames on a sprite-sheet:
- # - Correct sprite-sheet: - Incorrect sprite-sheet:
- # * Same frame dimensions! * Different frame dimensions!
- # ----- ----------------- ----- -------------------
- # | 0 | | 0 | 1 | 2 | 3 | | 0 | | 0 | 1 | 2 | 3 |
- # ----- ----------------- ----- -------------------
- # | 1 | Horizontal | 1 | Horizontal
- # ----- Sheet | | Sheet
- # | 2 | -----
- # ----- Vertical | 2 | Vertical
- # | 3 | Sheet | | Sheet
- # ----- -----
- # * It is not mandatory to animate your command buttons. You can make simple
- # images, set up the settings to disable the animation for them, and your
- # commands will not be animated.
- # * Almost all images (with the exception of regular background images) are
- # centered! This means, when you set their X and Y position, that position
- # will be the center of the image on the screen and NOT their top left corner!
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this script between Materials and Main!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- # * This script does NOT use ANY default Window class/sub-class components!
- # For that reason, mouse scripts which only check for the default selectable
- # windows (mostly all of them) will NOT work on any SpriteGrid class without
- # a patch!
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < 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["SixthImgGridMenu"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module SGridMenu
- #-----------------------------------------------------------------------------
- # Image Folder Settings:
- #-----------------------------------------------------------------------------
- # Set up the folders which contains the images used for the grid menu.
- # All of the images used must be in these folders!
- #
- # :cmds = Folder containing the command images for the grid menu.
- # In addition, the background for the grid "window" goes here too,
- # as well as the scroll indicator images (arrows usually).
- # :help = Folder containing the help images for the grid menu.
- # :back = Folder containing the backgrounds for the grid menu.
- #-----------------------------------------------------------------------------
- ImgFolders = {
- :cmds => "Graphics/GridMenu/Commands/",
- :help => "Graphics/GridMenu/Helps/",
- :back => "Graphics/GridMenu/Backgrounds/",
- }
- #-----------------------------------------------------------------------------
- # Background Settings:
- #-----------------------------------------------------------------------------
- # This is the place to setup your background images for the grid menu.
- #
- # You can either make scrolling images, static images, or combine them both!
- # If you have set a :scroll setting for the background, it will be a scrolling
- # background, if you omit that setting, it will be a static one!
- # You can make as many backgrounds as you want!
- #
- # Format:
- #
- # key => {
- # :img => "file name",
- # :pos => [x,y], # Only for static backgrounds!
- # :opa => value,
- # :z => value,
- # :scroll => [x_scroll,y_scroll], # Only for scrolling backgrounds!
- # },
- #
- # key => {
- # This is the key for the background. You can set this to anything you want,
- # strings, numbers, symbols, arrays of data, and so on. The only thing you
- # need to take care is that there can be no duplicate keys in the settings!
- #
- # :img => "file name",
- # The image used for the background.
- # All images must be in the folder you have set up in the above setting!
- #
- # :pos => [x,y],
- # The X and Y position of the background.
- # This only needs to be set for static backgrounds!
- # NEW FEATURE:
- # From v1.3, you have a few new options to set a dynamic position based on
- # the game's resolution. You can set up the X and Y position separately with
- # these new options:
- # :center = This will make the image centered on the specified axis.
- # [value] = This will automatically center the image AND will add the value
- # you have used in the array to that position.
- # You can still use the old fashioned way of setting the position up (with a
- # direct co-ordinate on the screen). In fact, only some specific resolution
- # changing scripts require these new features (like Dekita+Venka's Resolution
- # Selection script). If you don't use these scripts, you can stick to the
- # Graphics.width and Graphics.height value for using the game's resolution
- # in your position settings.
- # Examples: [:center,130] - Centers horizontally, Y will be set to 130.
- # [[-50],100] - X will be 50 pixels to the left from the horizontal
- # center of the game's screen, Y will be set to 100.
- #
- # :opa => value,
- # The opacity value for the background image. Valid values: 0 - 255.
- #
- # :z => value,
- # The Z value for the background.
- #
- # :scroll => [x_scroll,y_scroll],
- # The scrolling speed of the background.
- # The higher the values, the quicker it will scroll!
- # The 1st value is the scrolling on the X axis, the 2nd is for the Y axis!
- # Only add this setting if you want the background to be a scrolling one!
- #
- # NOTE:
- # If you don't want any background, leave the setting hash empty, but do NOT
- # remove or comment it out!
- #-----------------------------------------------------------------------------
- Backgrounds = {
- :back1 => {
- :img => "menuback1", :pos => [0,0], :opa => 255, :z => 0,
- },
- # Add more background settings here!
- }
- #-----------------------------------------------------------------------------
- # Help Image Settings:
- #-----------------------------------------------------------------------------
- # A help image can be shown for each command on the grid.
- # Different images can be shown for enabled and disabled commands.
- #
- # Details:
- #
- # :pos => [x,y],
- # The X and Y position of the help images.
- # Note that all help images will be displayed at this position!
- # NEW FEATURE:
- # From v1.3, you have a few new options to set a dynamic position based on
- # the game's resolution. You can set up the X and Y position separately with
- # these new options. For more on this, read the position setting explanation
- # in the 'Backgrounds' settings details!
- #
- # :opa => value,
- # The opacity value of the image.
- #
- # :z => value,
- # The Z value of the image.
- #
- # :locked => "text",
- # Like I already mentioned, different help images can be shown for enabled and
- # disabled commands. The image displayed for disabled commands will use the
- # same file name as the image for the enabled command, plus this text added at
- # the end of that name.
- # Example with this setting set to "_locked":
- # Enabled: "stage2-3" *#* Disabled: "stage2-3_locked"
- # And by knowing this, if you want to show the same image for enabled and
- # disabled commands alike, you can simply set this to be an empty string
- # ( "" )!
- #
- # NEW SETTINGS (from v1.2 update):
- #
- # As of v1.2, you can set up plain texts to be shown for your help display.
- # I added a few settings for the text display.
- # Note that the help display still requires an image to be set up for your
- # commands! The text for your commands will be drawn on that image!
- #
- # :tpos => [x,y],
- # The position of the text INSIDE the help image.
- # The Y position will set the Y position of the help text's first line.
- # If the help text got more than 1 lines, those will be placed below the 1st.
- # The X position setting will be applied to all lines!
- #
- # :lheight => height,
- # The height reserved for one line.
- # You can set up more than one line for your help texts. Each new line will
- # be drawn this many pixels below the previous one. So, this is the vertical
- # spacing of the help lines.
- #
- # :talign => value,
- # The alignment of the help text. Can be:
- # 0 - Left, 1 - Middle, 2 - Right.
- # All lines will use the same alignment!
- #
- # :font => {
- # :type => "font type name",
- # :size => size,
- # :color => Color.new(R,G,B,A),
- # },
- # The font properties of the help text.
- # These are kinda self-explanatory, right? :P
- #-----------------------------------------------------------------------------
- Help = {
- :pos => [:center,65], :opa => 255, :z => 200, :locked => "_locked",
- :tpos => [10,10], :lheight => 24, :talign => 1,
- :font => {
- :type => "Tw Cen MT Condensed",
- :size => 24, :color => Color.new(155,255,255,255),
- },
- }
- #-----------------------------------------------------------------------------
- # Grid Settings:
- #-----------------------------------------------------------------------------
- # These settings will determine where your grid of images will show, how many
- # columns it has, how big the reserved size is for a cell on the grid, and
- # how many space is left between the cells.
- #
- # Details:
- #
- # :view => {:pos => [x,y], :size => [width,height], :z => value},
- # This is a new setting from v1.4. From now on, this will determine the
- # position and size of the viewport on which your image commands will appear.
- # The position settings (:pos) work the same like all position settings
- # explained in the above setting explanations, so check it's options there
- # if you need!
- # The :size setting will simply set the width and height of the viewport.
- # Basically, this will determine how many command images will be shown maximum
- # at once on the screen. If there are some images which can't fit into the
- # viewport, the viewport becomes scrollable, just like a regular window would
- # scroll if there are more items than the window can show. The difference is
- # that in this case, the viewport can scroll in all directions if needed (so,
- # not only horizontal or only vertical scroll), and it will actually scroll
- # to the selected command gradually with a movement animation (so, it won't
- # just teleport to the selection at once).
- # The :z setting will set the viewport's Z value. This should be higher than
- # the Z value for your backgrounds, for example, so that your commands appear
- # on top of your backrounds.
- #
- # :padding => {:l => pixels, :r => pixels, :u => pixels, :d => pixels},
- # This will be the padding used for the viewport. The symbols mean:
- # :l = Padding on the left side of the viewport.
- # :r = Padding on the right side of the viewport.
- # :u = Padding on the top of the viewport.
- # :d = Padding on the bottom of the viewport.
- # Depending on your command images used, and the :isize settings used, you
- # might need to adjust the padding settings, so that your images won't get
- # cut down on any sides. If you notice that your images are cut down on a
- # side of the viewport, increase the padding on that side.
- #
- # :scroll_time => frames,
- # The scrolling time, which will actually decide the scrolling speed of the
- # viewport. The scrolling animation will be this many frames (in time) long
- # regardless how much the viewport needs to scroll itself.
- # 60 frames means 1 second!
- #
- # :max_cols => number,
- # The amount of maximum columns shown.
- # A new row will be created automatically if it is needed based on this
- # setting.
- #
- # :isize => [width,height],
- # The width and height reserved for one command image.
- # Because it is a grid based menu, all command images got the same dimension
- # reserved, but that doesn't mean that the images used must be the same size!
- # Although, using big and small images might look awkward because of the extra
- # space between some commands that way.
- #
- # :spacing => [horizontal,vertical],
- # The horizontal and vertical spacing between each commands.
- # In case you want some space between your images, you can use this setting
- # to add some.
- # The grid will automatically adjust the spacing for all images!
- #
- # NEW SETTING:
- # From v1.3, this new setting is added:
- #
- # :max_rows => number,
- # A setting which is only needed for calculating the correct Y position with
- # the new position setting features. If you don't plan on using the new
- # position setting option for the Y position, you might as well ignore this.
- # If you are using that feature, set this to the maximum number of rows your
- # grid can have.
- # From v1.4, you should set up this setting, regardless if you want to use
- # the dynamic position settings or not! This is mandatory for the scrolling
- # function, and will decide when your UP/DOWN scroll indicators appear.
- #-----------------------------------------------------------------------------
- Grid = {
- :view => {:pos => [:center,180], :size => [220,90], :z => 100},
- :padding => {:l => 16, :r => 20, :u => 8, :d => 10},
- :scroll_time => 60,
- :max_cols => 8,
- :max_rows => 6,
- :isize => [32,30],
- :spacing => [6,6],
- }
- #-----------------------------------------------------------------------------
- # Command Background Settings:
- #-----------------------------------------------------------------------------
- # You can choose to show a background image for the command images if you
- # want. This is almost the same as a regular background, but in addition,
- # this one can be animated.
- # The animation will only play if the grid "window" is active!
- # By default, it is always active, but in case you want to do other things
- # with this, it is good to know how it works, right? :P
- #
- # Details:
- #
- # :img => "filename"
- # The name of the image you want to use. This image, regardless of being a
- # background, needs to be in the same folder as your command images are!
- # Also, you can set this to an empty string ( "" ) if you don't want to show
- # an animated background at all.
- #
- # :pos => [x,y],
- # Okay, starting to get redundant, right?
- # You should already know what this is. :P
- # NEW FEATURE:
- # From v1.3, you have a few new options to set a dynamic position based on
- # the game's resolution. You can set up the X and Y position separately with
- # these new options. For more on this, read the position setting explanation
- # in the 'Backgrounds' settings details!
- #
- # :opa => value,
- # Same as above...
- #
- # :z => value,
- # And yet again, same as above...
- #
- # :rows => number,
- # * or *
- # :cols => number, # <-- From v1.4!
- # This is used to show the correct image frame from your sprite-sheet.
- # Enter the total amount of image frames (rows or columns) on your
- # sprite-sheet.
- # If you don't want to animate your command, enter 1 for this!
- # If you use :rows, your image-sheet must be vertical, if you use :cols,
- # your image-sheet must be horizontal!
- # Do NOT use both :rows and :cols settings, only one of them!
- #
- # :frames => [f1, f2, f3, ...],
- # This is the setting which will determine the animation sequence played.
- # You can enter as many frame indexes into the array as you want!
- # These will determine which image frame will be shown in what order during
- # the animation. When all the frames are played, it will re-start the
- # animation from the beginning!
- # You can re-use the same image frames from your sprite-sheet multiple times!
- # If you don't want to animate the background, just set this to [0]!
- # Although, if you don't want to animate it, you are better off using a
- # regular background...
- #
- # :wait => frames,
- # This is the amount of frames (meaning time here, 60 frames = 1 second!)
- # each image frame is shown before switching to the next one.
- # In short, this is the speed of the animation itself.
- # Lower numbers mean quicker animation, while higher ones will make a slow
- # animation (almost like a slide-show if high enough).
- # If you don't animate your background, enter a higher number for this (like
- # 60 or higher), so that it won't check for the image frames too often in
- # vain. But again, if you don't animate it, you really shouldn't use this
- # feature.
- #
- # :zoom => true/false,
- # I mentioned at the beginning, that if the grid "window" is active, it will
- # be animated, but if it is NOT active, it will NOT be animated.
- # Well, a similar function is to zoom in/out the background when it is
- # active/inactive. Combine this with the button zoom feature, and you can
- # make the whole grid "window" slowly (or quickly) zoom out if inactive or
- # zoom in if active. This is, of course, just an example why this option was
- # made.
- # But since this feature is not always needed, it can be turned ON or OFF with
- # this setting. Set it to true to turn it ON, or false to turn it OFF.
- #
- # :zspeed => [x_axis,y_axis],
- # If the above zoom feature is enabled, this will control the speed of the
- # zooming. You can set up a separate speed for the X and Y axis.
- # The X axis setting will set the horizontal zoom speed, while the Y axis
- # setting will set the vertical zoom speed.
- # The lower the values here, the slower the zooming will be!
- # Note that the default zoom value is 1.0 for all images! Higher values will
- # make the image bigger, lower values will make it smaller!
- #-----------------------------------------------------------------------------
- CmdBack = {
- :img => "storyback1", :pos => [:center,150], :opa => 255, :z => 180,
- :rows => 1, :frames => [0], :wait => 60,
- :zoom => true, :zspeed => [0.05,0.05],
- }
- #-----------------------------------------------------------------------------
- # Command Settings:
- #-----------------------------------------------------------------------------
- # And this is where you can set up all the stuffs for your commands.
- # You got many options, so lets check them all!
- # But before that, there is something that needs to be cleared first...
- #
- # The command images got several different states. These are:
- # - active = When the "cursor" is currently on the command,
- # but NOT yet triggered!
- # - inactive = When the "cursor" is not on the command.
- # - selected = When the "cursor" is currently on the command, AND it has been
- # triggered. This state is only possible if you added a custom
- # method for your command button which makes the grid "window"
- # inactive. This state can NOT happen when the grid "window" is
- # active!
- #
- # In addition to the above, make sure to read how to set up your image-sheets
- # correctly if you want to animate your command buttons! You can find all the
- # info you need about this in the header of this script!
- #
- # Now that these are out of the way, lets see the details!
- #
- # Details:
- #
- # key => { *settings inside* },
- # The key is the key component here (this sounded way cooler in my head).
- # So, that key can be anything from integers across symbols and strings to
- # arrays of data. The only thing you need to keep in mind that you can NOT
- # make duplicate keys, all of them must be unique!
- # I used symbols in the sample settings, because I like those the most (they
- # can be named however I want, but unlike strings, they require only one extra
- # character - the : sign), but you can name them however you want.
- # Note that these keys can be accessed in the trigger and cancel methods you
- # set up for your command buttons in the methods which trigger upon
- # confirming/canceling on a command button. More on this a bit later below...
- # The *settings inside* are basically every setting for the command button.
- # All of them are explained below.
- # NEW NOTE:
- # As of v1.1, :empty as a key is reserved! The command settings with that key
- # will be automatically loaded when there are no shown command images at all
- # on the grid menu.
- # If you won't have that situation, feel free to use that key for any command
- # if you want, but if it can happen, make sure to reserve that key for the
- # purpose of showing something for the player when the grid menu is opened!
- #
- # :ea => "file name",
- # The name of the image you want to use when the command is active AND
- # enabled (enabled + active = :ea).
- #
- # :ei => "file name",
- # The name of the image you want to use when the command is NOT active but
- # still enabled (enabled + inactive = :ei).
- #
- # :da => "file name",
- # The name of the image you want to use when the command is active BUT
- # NOT enabled (disabled + active = :da).
- #
- # :di => "file name",
- # The name of the image you want to use when the command is NOT active AND
- # NOT enabled (disabled + inactive = :di).
- #
- # :help => "file name",
- # The name of the image you want to show as a "help image" for the command.
- # You can use an empty string ( "" ) if you don't want to show any help image
- # for the command.
- # NOTE:
- # The help image will use a different image for disabled commands than for
- # enabled ones! The disabled help images must be named the same, and at the
- # end of their name, you must add the text you specified in the 'Help' setting
- # above! More info on this can be found in the mentioned setting above!
- #
- # :opa => [enabled,disabled],
- # The opacity value for the command.
- # You can set two values up, the first one is for when the command is enabled,
- # while the second one is for when the command is disabled.
- #
- # :z => [active,inactive],
- # The Z value of the command image.
- # You can enter 2 settings here as well. The first one will be used if the
- # command is active, and the second one is used if the command is inactive.
- # This can prevent some awkward clipping issues when the images are close
- # to each other, the selected one can be set to be show above the inactive
- # ones always.
- #
- # :rows => number,
- # * or *
- # :cols => number, # <-- From v1.4!
- # This is used to show the correct image frame from your sprite-sheet.
- # Enter the total amount of image frames (rows or columns) on your
- # sprite-sheet.
- # If you don't want to animate your command, enter 1 for this!
- # If you use :rows, your image-sheet must be vertical, if you use :cols,
- # your image-sheet must be horizontal!
- # Do NOT use both :rows and :cols settings, only one of them!
- #
- # :frames => [f1, f2, f3, ...],
- # This is the setting which will determine the animation sequence played.
- # You can enter as many frame indexes into the array as you want!
- # These will determine which image frame will be shown in what order during
- # the animation. When all the frames are played, it will re-start the
- # animation from the beginning!
- # You can re-use the same image frames from your sprite-sheet multiple times!
- # If you don't want to animate the command, just set this to [0]!
- #
- # :wait => frames,
- # This is the amount of frames (meaning time here, 60 frames = 1 second!)
- # each image frame is shown before switching to the next one.
- # In short, this is the speed of the animation itself.
- # Lower numbers mean quicker animation, while higher ones will make a slow
- # animation (almost like a slide-show if high enough).
- # If you don't want to animate your command, enter a higher number for this
- # (like 60 or higher), so that it won't check for the image frames too often
- # in vain.
- #
- # :enable => enable_setting,
- # This is the setting which will determine when the command is enabled and
- # when it is disabled. You can set this one up in a few different ways:
- # 1. Enter an integer number to tie the enable state of the command to a
- # game switch. The integer number will be the ID of the switch. When that
- # switch is ON, the command will be enabled, when it is OFF, the command
- # will be disabled.
- # Example: :enable => 12,
- # 2. Set it to a symbol if you want to run a defined method found in the
- # SpriteGrid class. The result of that method will determine whether the
- # command will be enabled or not. This requires scripting knowledge to be
- # of any use for the developers! If you do have some coding knowledge, you
- # can make a method in the mentioned class, and use the name of that method
- # (as a symbol) here to call it. The method must return true or false!
- # The method also can't have any mandatory arguments!
- # Example: :enable => :check_cost,
- # 3. Enter a valid ruby code as a string, and the evaluation of that code will
- # determine whether the command button is enabled or not. As with the above
- # option, this requires scripting knowledge too! The result of the
- # evaluated code must return true or false!
- # Example: :enable => "$game_party.gold >= 1000000",
- # 4. You can use an array with two elements: a method name as a symbol, and
- # another array which will be the arguments of the method.
- # This is the same as the second option, but with this, you can use some
- # basic arguments for your used method (still, these can only be static
- # arguments, since they are evaluated in the module settings and not in the
- # SpriteGrid class, so keep this in mind!). Again, this requires scripting
- # knowledge!
- # Example: :enable => [:check_levels,[2,4,8,16]],
- # 5. Set it to either true or false. Setting it to true will make the command
- # be always enabled, while setting it to false will make it disabled
- # forever. No idea why would you do the latter, but the option is there. :P
- # Example: :enable => true,
- #
- # :show => show_setting,
- # This setting will determine whether the command will be shown or hidden.
- # You got the same options here like in the :enable setting above!
- # Hidden commands will not how up at all until they become shown!
- # If there are commands after the hidden command(s), the rest of the shown
- # commands will line up on the grid continuously, so even if some commands are
- # hidden, there won't be empty holes on the grid, because the rest of the
- # shown commands will fill the "holes", just like a regular command window
- # would do!
- #
- # :method => method_setting,
- # This setting requires scripting knowledge!
- # If this setting is set to nil or omitted completely, the command button
- # won't do anything at all aside from playing the confirm/buzzer sound effect
- # and showing a flash effect when it is triggered.
- # However, you can run any method from the scene class where the SpriteGrid
- # class is made or you can run a direct ruby code too!
- # The method/code will be executed when the button is triggered.
- # The layout of the setting is the same as some options from the :enable
- # setting, specifically, you can use these:
- # - Option 2: Symbol (method without arguments),
- # - Option 3: String (string to evaluate as code),
- # - Option 4: Array (method with static arguments).
- # Note that the grid "window" will NOT be deactivated or activated
- # automatically upon using any of these options, so if you want that to
- # happen, you must include it in your method/code!
- # These methods and codes will be run/evaluated in the current scene class!
- # The method which triggers these methods/codes got some built-in variables
- # which you can use if you want/need. These are:
- # - key = This is the key identifier of the grid "window" where the triggered
- # command button is. This is completely useless if you are using only
- # one grid "windows", but if you use multiple of them in the same
- # scene, this can be useful, because regardless in which one the
- # triggered button is, the same method is run.
- # - sym = The "symbol" of the triggered button. Actually, this is the key
- # identifier of the triggered command button, but since I didn't want
- # to use "key2" or other very similar variable names (to avoid mixing
- # them up), I settled with "sym". Although it can be anything, not
- # just symbols (depends what kind of key did you used for the command
- # buttons in the module settings).
- # In addition to these, you can, of course, use any instance/global variables
- # found in the scene/anywhere. I won't write those down, obviously. :P
- #
- # :cancel => cancel_method_settings,
- # This is the same as the above, but this will happen when the cancel button
- # is pressed on a command button.
- # You can use the same config options as for the :method setting.
- # I set this to :return_scene by default, which will make the player exit the
- # scene when the cancel button is pressed.
- #
- # Phew! I hope, I wrote all setting explanation down! *.*
- #
- # NEW SETTINGS:
- # Or maybe not... Some new options are added with v1.1. These are:
- #
- # :skip_col => amount,
- # Skips the amount of columns AFTER the command image which got this option,
- # which will be reflected in the placement of the subsequent command images.
- # Note that the regular order will still be counted, and if it happens to be
- # that the command image with this setting is in the last column, no columns
- # will be skipped, and the command will be placed on the first column of the
- # next row! Same happens if the columns skipped would place the next command
- # outside of the range of maximum columns available, it will simply skip the
- # maximum columns possible and start the next row instead of placing the
- # command outside of the grid layout.
- # This option is fully optional, you can omit it if you want!
- #
- # :skip_row => amount,
- # This will make the next command skip the amount of rows you set up here.
- # Regardless if the next command is on the 1st column or in the middle, it
- # will skip all subsequent columns and jumps to the start of the next row.
- # If you enter a higher amount than 1, it will skip additional rows as well.
- # Note that the regular order is still maintained, so if a command image on
- # the last column got this option, it will jump to the next row automatically
- # (because it reached the maximum columns available) AND it will skip the
- # amount of rows you set up here additionally!
- #
- # EVEN NEWER SETTINGS:
- # The v1.2 update brings you these new settings:
- #
- # :help_txt => {
- # :enabled => [ # Only shows if the command is enabled.
- # "help text - line 1",
- # "help text - line 2",
- # ...
- # ],
- # :disabled => [ # Only shows if the command is disabled.
- # "help text - line 1",
- # "help text - line 2",
- # ...
- # ],
- # },
- # This will set up help texts for your command buttons. These texts will be
- # drawn on the command's help image, so you still have to use a help image!
- # Each separate string set up in the arrays will show up on a new line!
- # You can add as many lines as you want!
- # And as you can see, you can make a separate text setting for enabled and
- # disabled command states.
- # This settings is optional! If it is not set, no text will be drawn on the
- # command's help image!
- # Also, you don't have to set up both the enabled and disabled texts. The
- # text type which is not set up will simply not show anything.
- # For example, a text setting with only the :enabled option set up will show
- # the help text only when the command is enabled, not when it is disabled!
- #
- # SOME MORE SETTINGS:
- # The following new (optional) settings are added with the v1.4 update:
- #
- # :add_pos => [x,y],
- # This will make your command image appear this many pixels from it's original
- # grid position. In other words, these are offset position settings.
- # This is optional, you don't have to use it!
- # If you use this, note that ALL of your command images after the image with
- # this setting will be shifted this many pixels, so, not just the next image!
- # Also, if you use this in more than one command settings, it will add up ALL
- # the additional positions you added with this option, and use that for
- # setting the position of ALL subsequent command images.
- # An example:
- # 3rd command settings got this additional position setting:
- # :add_pos => [16,0]
- # This will shift the 4th command image 16 pixels to the right, as well as any
- # other command images after the 4th one.
- # The 7th command image got this additional position setting:
- # :add_pos => [-8,6],
- # Now, the 4th, 5th, 6th and 7th command images will be moved 16 pixels to the
- # right (because of the setting found in the 3rd command settings), and the
- # 8th and any other command images after will be moved 8 pixels to the right
- # (16 - 8 = 8) and 6 pixels down (0 + 6 = 6).
- # In short, all of these settings are additive!
- #
- # :add_reset => [:x,:y],
- # This setting is related to the above one, like the name suggests it.
- # If you use this one, ALL of the additional position settings will be reset
- # on the choosen axis (X or Y, meaning horizontal or vertical).
- # In other words, this will reset the position of ALL of the command images
- # coming after to the original grid position (in short, sets the :add_pos
- # setting to [0,0], it's initial value, regardless of what value it had
- # before).
- # You can insert :x into the array setting to reset the additional X position
- # and you can insert :y to reset the additional Y position.
- # You can use both if you want, or only one.
- # Note that the reset happens before the :add_pos setting is added, so you can
- # reset it and add a new value for it immediately in the same command button
- # setting if you want!
- #
- # CHANGE OF SETTINGS:
- #
- # From v1.4, the position of the :empty command will be automatically centered
- # on the viewport of the grid! So, the :pos setting for the :empty command
- # is not required anymore, in fact, it does nothing!
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Just for some examples, I wrote 2 methods which can be called with arguments
- # in the scene. Feel free to test them out!
- #
- # Example 1 - Teleport:
- #
- # Obviously, this can be quite awesome for a stage selection or a quick travel
- # menu. Here is how you can use it:
- #
- # :method => [:teleport,[map_id,x,y,dir,fade_type]],
- #
- # The :teleport is the name of the method which will do the automated "hard"
- # work in the script.
- # map_id = The ID of the map to teleport to.
- # x,y = The X and Y position on the map to teleport to.
- # dir = The player's direction after the teleport.
- # (2 = Down, 4 = Left, 6 = Right, 8 = Up)
- # fade_type = The fade type used for the teleport.
- # (0 = Black, 1 = White, 2 = None)
- #
- # I took the liberty to set up an actual example setting for the 1st command,
- # so, if you trigger that button, it will teleport you to the designated
- # place. Yay!
- #
- # Example 2 - Show Image:
- #
- # A basic way to show custom images upon selecting a command.
- # The image will appear at the same place the command button is, and will
- # move to the designated position within the given time.
- # In addition, the image will start on zoom level 0.0, and will get to 1.0
- # at the same time when the destination is reached.
- # The image will stay there until the player presses the confirm button again.
- #
- # Here is how to use this method:
- #
- # :method => [:show_image,["file name","folder",x,y,time]],
- #
- # The :show_image is the name of the method which will do the automated hard
- # work in the script.
- # "file name" = The name of the image file to show.
- # "folder" = The folder path to the image file used.
- # x,y = The destination co-ordinates where the image should travel.
- # time = The time it takes the image to travel to the destination point.
- #
- # I made an example setup for this method too for the 2nd command, so if you
- # trigger that one, it will show an image like I described above. Cool!
- #
- # Alright, that's all for the example methods!
- # Feel free to check these methods in the script itself to see how they work,
- # or create your own ones!
- #-----------------------------------------------------------------------------
- Commands = {
- :s01 => {
- :ea => "0-1a", :ei => "0-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "0-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => [:teleport,[4,8,14,2,1]],
- :cancel => :return_scene,
- :help_txt => {
- :enabled => [
- "Just a text for testing.",
- "Lets see how this shows up...",
- "Three lines for the win! And for the bunnies!",
- ],
- :disabled => [
- "This shows only if the command is disabled!",
- ],
- },
- },
- :s02 => {
- :ea => "0-2a", :ei => "0-2b", :da => "disabled1a", :di => "disabled1b",
- :help => "0-2helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, #:skip_row => 1,
- :method => [:show_image,["pl2name_down",ImgFolders[:back],320,400,120]],
- :cancel => :return_scene,
- :help_txt => {
- :enabled => ["Another sample text. Only if the command is enabled. Yay!"],
- },
- },
- :s11 => {
- :ea => "1-1a", :ei => "1-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "1-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- :help_txt => {
- :disabled => ["This command is disabled, ohh noes!"],
- },
- },
- :s12 => {
- :ea => "1-2a", :ei => "1-2b", :da => "disabled1a", :di => "disabled1b",
- :help => "1-2helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s13 => {
- :ea => "1-3a", :ei => "1-3b", :da => "disabled1a", :di => "disabled1b",
- :help => "1-3helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s14 => {
- :ea => "1-4a", :ei => "1-4b", :da => "disabled1a", :di => "disabled1b",
- :help => "1-4helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s15 => {
- :ea => "1-5a", :ei => "1-5b", :da => "disabled1a", :di => "disabled1b",
- :help => "1-5helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s21 => {
- :ea => "2-1a", :ei => "2-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "2-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s22 => {
- :ea => "2-2a", :ei => "2-2b", :da => "disabled1a", :di => "disabled1b",
- :help => "2-2helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s23 => {
- :ea => "2-3a", :ei => "2-3b", :da => "disabled1a", :di => "disabled1b",
- :help => "2-3helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s24 => {
- :ea => "2-4a", :ei => "2-4b", :da => "disabled1a", :di => "disabled1b",
- :help => "2-4helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s25 => {
- :ea => "2-5a", :ei => "2-5b", :da => "disabled1a", :di => "disabled1b",
- :help => "2-5helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s31 => {
- :ea => "3-1a", :ei => "3-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "3-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s32 => {
- :ea => "3-2a", :ei => "3-2b", :da => "disabled1a", :di => "disabled1b",
- :help => "3-2helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s33 => {
- :ea => "3-3a", :ei => "3-3b", :da => "disabled1a", :di => "disabled1b",
- :help => "3-3helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s34 => {
- :ea => "3-4a", :ei => "3-4b", :da => "disabled1a", :di => "disabled1b",
- :help => "3-4helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6, #:skip_row => 1,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s41 => {
- :ea => "4-1a", :ei => "4-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "4-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s42 => {
- :ea => "4-2a", :ei => "4-2b", :da => "disabled1a", :di => "disabled1b",
- :help => "4-2helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s43 => {
- :ea => "4-3a", :ei => "4-3b", :da => "disabled1a", :di => "disabled1b",
- :help => "4-3helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6, #:skip_row => 1,
- :enable => true, :show => true, :method => nil, :cancel => :return_scene,
- },
- :s51 => {
- :ea => "5-1a", :ei => "5-1b", :da => "disabled1a", :di => "disabled1b",
- :help => "5-1helpa", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- :empty => { # Reserved key! This will only appear if the list is empty!
- :pos => [:center,250],
- :ea => "empty1a", :ei => "empty1b", :da => "empty1a", :di => "empty1b",
- :help => "emptyhelp1a", :opa => [255,255], :z => [300,250],
- :rows => 4, :frames => [0,1,2,3,2,1], :wait => 6,
- :enable => false, :show => true, :method => nil, :cancel => :return_scene,
- },
- }
- #-----------------------------------------------------------------------------
- # Arrow Settings:
- #-----------------------------------------------------------------------------
- # These settings are new settings from v1.4!
- #
- # If your viewport for the grid commands can't display all command images at
- # once (because the size of the viewport is too small for it), these arrow
- # images will indicate that you can scroll the commands in the specified
- # directions. They will only appear if the viewport can be scrolled in the
- # direction, otherwise, they will be hidden from the player.
- #
- # The settings here use the same layout as the image settings for your command
- # images (in the 'Commands' settings above).
- # There are a few differences (the settings here got only one :opa and :z
- # settings, and all of the images got a :pos setting), but I guess, these are
- # still obvious ones, so I won't explain them again.
- #
- # Note that if you don't want a scroll indicator for a direction, you can set
- # it to nil, or just simply omit it from the 'Arrows' setting as well.
- # If you don't want or need any scroll indicators, you can set this whole
- # setting to nil too.
- #-----------------------------------------------------------------------------
- Arrows = {
- :up => { # Shows up when you can scroll upwards.
- :img => "arrowup2", :opa => 255, :z => 400, :pos => [:center,168],
- :rows => 3, :frames => [0,1,2,1], :wait => 6,
- },
- :down => { # Shows up when you can scroll downwards.
- :img => "arrowdown2", :opa => 255, :z => 400, :pos => [:center,282],
- :rows => 3, :frames => [2,1,0,1], :wait => 6,
- },
- :left => { # Shows up when you can scroll left.
- :img => "arrowleft2", :opa => 255, :z => 400, :pos => [[-124],225],
- :cols => 3, :frames => [0,1,2,1], :wait => 6,
- },
- :right => { # Shows up when you can scroll right.
- :img => "arrowright2", :opa => 255, :z => 400, :pos => [[124],225],
- :cols => 3, :frames => [2,1,0,1], :wait => 6,
- },
- }
- #-----------------------------------------------------------------------------
- # Flash Settings:
- #-----------------------------------------------------------------------------
- # You can set up flash effects which will play when the button is triggered.
- # Depending on the state of the command button (enabled or disabled), a
- # different flash effect can be shown.
- #
- # Details:
- #
- # :color => Colow.new(R,G,B,A),
- # The color used for the flash effect. Uses RGBA codes!
- #
- # :dur => frames,
- # The duration of the flash effect in frames. 60 frames = 1 second!
- #
- # I guess, I don't need to write down what :enabled and :disabled means here,
- # right? :P
- #
- # Ohh, be sure to keep the brackets and commas everywhere!
- # Except if you don't want to use any flash effects, in which case you can set
- # the whole :enabled or :disabled setting to be nil. Looks like:
- # :enabled => nil, *or* :disabled => nil,
- #-----------------------------------------------------------------------------
- Flash = {
- :enabled => {:color => Color.new(255,255,50,250), :dur => 20},
- :disabled => {:color => Color.new(255,50,50,250), :dur => 20},
- }
- #-----------------------------------------------------------------------------
- # Zoom Settings:
- #-----------------------------------------------------------------------------
- # Depending on the state of the command buttons and the grid "window" itself,
- # you can show different zooming effects for your button images and for the
- # grid "window" background.
- #
- # :grid => {:active => [x_zoom,y_zoom], :inactive => [x_zoom,y_zoom]},
- # This setting will affect the whole grid "window", including all the command
- # buttons and it's background!
- # :active sets the overall zoom level for when the grid "window" is active
- # (and it is always active by default, unless you change it, which requires
- # scripting knowledge), and :inactive sets the zoom level when it's... well,
- # inactive, obviously.
- # This means that the :limit settings you will set in the other settings here
- # will be multiplied by these values, and the result will be the overall zoom
- # level for the command images (the background will directly use these values
- # as it's zoom level).
- #
- # :ea => {:speed => [x_speed,y_speed], :limit => [x_zoom,y_zoom]},
- # When a command is enabled and active, these settings will be applied.
- # So, the zoom level will change to the :limit setting you set up here either
- # slowly or quickly depending on the :speed settings.
- # The lower the :speed setting is, the slower it will change the zoom level.
- # The lower the :limit setting is, the smaller the image gets.
- # Remember that the default zoom level is 1.0 for all images!
- # And make sure to keep all the brackets and commas here!
- #
- # :ei => {:speed => [x_speed,y_speed], :limit => [x_zoom,y_zoom]},
- # :da => {:speed => [x_speed,y_speed], :limit => [x_zoom,y_zoom]},
- # :di => {:speed => [x_speed,y_speed], :limit => [x_zoom,y_zoom]},
- # :sel => {:speed => [x_speed,y_speed], :limit => [x_zoom,y_zoom]},
- # These all use the same layout as the above setting, but these will take over
- # when the button is:
- # :ei = Enabled AND inactive.
- # :da = Disabled AND active.
- # :di = Disabled AND inactive.
- # :sel = Selected (so it must have been enabled AND active as well).
- # If you don't know what these command button states mean, feel free to
- # refresh your memory at the top of the 'Commands' settings explanation!
- #
- # NOTE:
- # To disable all kind of zooming effects, you can set all of the :limit and
- # :grid settings to [1.0,1.0]!
- #-----------------------------------------------------------------------------
- Zoom = {
- :grid => {:active => [1.0,1.0], :inactive => [0.8,0.8]},
- :ea => {:speed => [0.05,0.05], :limit => [1.0,1.0]},
- :ei => {:speed => [0.05,0.05], :limit => [0.75,0.75]},
- :da => {:speed => [0.05,0.05], :limit => [1.0,1.0]},
- :di => {:speed => [0.05,0.05], :limit => [0.75,0.75]},
- :sel => {:speed => [0.05,0.05], :limit => [1.0,1.0]},
- }
- #-----------------------------------------------------------------------------
- # Move Settings:
- #-----------------------------------------------------------------------------
- # You can move the selected command somewhere if you want with these settings.
- # When the command is selected, it will move to the original position plus
- # the :dist setting you set up here, and when it is not selected, it will move
- # back to it's original position.
- # The movement speed of the command image depends on the :speed settings.
- # The higher it is, the quicker will the image move to it's destination.
- #
- # Note that by default, no command button can be in the "selected" state, so
- # if you don't plan to use some of the advanced features this script got and
- # stick to the default :method and :cancel settings, you can completely
- # ignore these settings!
- #
- # The default settings will not move the command images anywhere!
- #-----------------------------------------------------------------------------
- Move = {
- :speed => [1,1], :dist => [0,0],
- }
- #-----------------------------------------------------------------------------
- # Audio Settings:
- #-----------------------------------------------------------------------------
- # These settings are kinda self-explanatory, but just in case:
- # :confirm = Plays when triggering an enabled button.
- # :disabled = Plays when triggering a disabled button.
- # :cancel = Plays when the cancel button is pressed on a button.
- # :cursor = Plays when changing buttons (when the "cursor" position changes).
- #
- # Format:
- #
- # :key => RPG::SE.new("file name",volume,pitch),
- #
- # If you don't want a sound effect for something, just set the file name for
- # it to an empty string ( "" )!
- #-----------------------------------------------------------------------------
- Sound = {
- :confirm => RPG::SE.new("Decision1",80,100),
- :disabled => RPG::SE.new("Buzzer1",80,100),
- :cancel => RPG::SE.new("Cancel2",80,100),
- :cursor => RPG::SE.new("Cursor1",80,100),
- }
- #-----------------------------------------------------------------------------
- # Button Settings:
- #-----------------------------------------------------------------------------
- # You can make your own controls for your grid "windows" here.
- # I think, it is pretty clear what the below settings do, so I won't write my
- # usual wall of text here. :P
- # For the default available button symbols, you can look up the help files
- # of RPG Maker VX Ace.
- # Aside from the default buttons, you can use custom ones if you use a custom
- # input script.
- #-----------------------------------------------------------------------------
- Buttons = {
- :confirm => :C, :cancel => :B,
- :prev_row => :UP, :next_row => :DOWN,
- :prev_col => :LEFT, :next_col => :RIGHT,
- }
- end
- #===============================================================================
- # End of settings! Editing anything below may lead to... you know it, right? o.o
- #===============================================================================
- module Cache
- def self.custom_imgs(filename,folder)
- load_bitmap(folder,filename)
- end
- end
- module DynXY
- def self.get_x(xx,ww,extra=nil)
- case xx
- when Array
- x = (Graphics.width-ww)/2
- x += xx[0]
- x += extra if extra
- when :center
- x = (Graphics.width-ww)/2
- x += extra if extra
- else
- x = xx
- end
- p "X: #{x}"
- return x
- end
- def self.get_y(yy,hh,extra=nil)
- case yy
- when Array
- y = (Graphics.height-hh)/2
- y += yy[0]
- y += extra if extra
- when :center
- y = (Graphics.height-hh)/2
- y += extra if extra
- else
- y = yy
- end
- p "Y: #{y}"
- return y
- end
- end
- class Game_Interpreter
- def open_grid_menu(mod=SGridMenu)
- SceneManager.call(Grid_Menu)
- SceneManager.scene.prepare(mod)
- end
- end
- class Grid_Menu < Scene_Base
- def start
- super
- init_sprites
- end
- def prepare(mod)
- @mod = mod
- end
- def init_sprites
- init_backgrounds
- init_help_img
- init_grid_commands
- end
- def init_backgrounds
- @backs = {}
- folder = @mod::ImgFolders[:back]
- @mod::Backgrounds.each do |sym,data|
- @backs[sym] = data[:scroll].nil? ? Sprite.new : Plane.new
- @backs[sym].bitmap = Cache.custom_imgs(data[:img],folder)
- if @backs[sym].is_a?(Sprite)
- x = DynXY.get_x(data[:pos][0],@backs[sym].bitmap.width,@backs[sym].ox)
- y = DynXY.get_y(data[:pos][1],@backs[sym].bitmap.height,@backs[sym].oy)
- @backs[sym].x = x
- @backs[sym].y = y
- end
- @backs[sym].opacity = data[:opa]
- @backs[sym].z = data[:z]
- end
- end
- def init_help_img
- data = @mod::Help
- folder = @mod::ImgFolders[:help]
- @helpy = SpriteHelp.new(data,folder,"")
- end
- def init_grid_commands
- grid = @mod::Grid
- data = @mod::Commands
- folder = @mod::ImgFolders[:cmds]
- flash = @mod::Flash
- zoom = @mod::Zoom
- move = @mod::Move
- sound = @mod::Sound
- back = @mod::CmdBack
- buttons = @mod::Buttons
- arrows = @mod::Arrows
- @grid = SpriteGrid.new(:grid,grid,data,folder,flash,zoom,move,sound,buttons,arrows,back,true)
- @grid.show
- @grid.update_help
- end
- def trigger_command(key,sym)
- case key
- when :grid
- if @grid.data[sym][:method]
- run_method(key,sym,:method)
- else
- @grid.activate
- end
- end
- end
- def cancel_command(key,sym)
- case key
- when :grid
- if @grid.commands.size <= 0
- return_scene
- elsif @grid.data[sym][:cancel]
- run_method(key,sym,:cancel)
- else
- @grid.deactivate
- end
- end
- end
- def run_method(key,sym,type)
- case key
- when :grid
- mtd = @grid.data[sym][type]
- end
- case mtd
- when Symbol
- method(mtd).call
- when Array
- method(mtd[0]).call(*mtd[1])
- when String
- eval(mtd)
- end
- end
- def update_help(key,sym)
- case key
- when :grid
- if @grid.commands.size <= 0
- img = ""; txt = nil
- elsif @grid.enabled[@grid.index]
- img = @grid.data[sym][:help]
- if @grid.data[sym][:help_txt]
- txt = @grid.data[sym][:help_txt][:enabled]
- end
- else
- img = @grid.data[sym][:help] + @helpy.data[:locked]
- txt = @grid.data[sym][:help_txt][:disabled] if @grid.data[sym][:help_txt]
- end
- img = "" if img == @helpy.data[:locked]
- @helpy.set_img(img,@mod::ImgFolders[:help],txt)
- end
- end
- def teleport(map_id,x,y,dir,f_type) # Example 1 for custom method calls.
- @grid.deactivate
- RPG::SE.new("Darkness8",80,100).play
- trigger_time = Graphics.frame_count
- until Graphics.frame_count >= trigger_time + 30
- Graphics.update
- @grid.update
- end
- return_scene
- $game_player.reserve_transfer(map_id, x, y, dir)
- $game_temp.fade_type = f_type
- end
- def show_image(img_n,folder,x,y,time) # Example 2 for custom method calls.
- @grid.deactivate([1.0,1.0]) # Got a bit carried away here, sorry! :P
- img = Sprite.new
- img.bitmap = Cache.custom_imgs(img_n,folder)
- img.x = ox = @grid.imgs[@grid.index].x
- img.y = oy = @grid.imgs[@grid.index].y
- img.ox = img.bitmap.width/2
- img.oy = img.bitmap.height/2
- img.opacity = 255
- img.z = 400
- img.zoom_x = img.zoom_y = 0.0
- inc_x = (x - img.x)/time.to_f
- inc_y = (y - img.y)/time.to_f
- inc_z = 1.0/time.to_f
- ax = ay = 0
- until img.zoom_x >= 1.0 && img.y == y && img.x == x
- Graphics.update
- Input.update
- @grid.update
- mult = Input.press?(:C) ? 2 : 1
- img.zoom_x += inc_z * mult if img.zoom_x != 1.0
- img.zoom_y += inc_z * mult if img.zoom_y != 1.0
- img.zoom_x = 1.0 if img.zoom_x > 1.0
- img.zoom_y = 1.0 if img.zoom_y > 1.0
- ax += inc_x * mult
- ay += inc_y * mult
- img.x = ox + ax
- img.y = oy + ay
- img.x = x if (inc_x > 0 && img.x > x) || (inc_x < 0 && img.x < x)
- img.y = y if (inc_y > 0 && img.y > y) || (inc_y < 0 && img.y < y)
- end
- until Input.trigger?(:C)
- Graphics.update
- Input.update
- @grid.update
- end
- RPG::SE.new("Bell3",80,100).play
- ax = ay = 0
- ox = img.x
- oy = img.y
- inc_x = -inc_x
- inc_y = -inc_y
- xx = @grid.imgs[@grid.index].x
- yy = @grid.imgs[@grid.index].y
- until img.zoom_x <= 0.0 && img.x == xx && img.y == yy
- Graphics.update
- Input.update
- @grid.update
- mult = Input.press?(:C) ? 2 : 1
- img.zoom_x -= inc_z * mult if img.zoom_x > 0.0
- img.zoom_y -= inc_z * mult if img.zoom_y > 0.0
- ax += inc_x * mult
- ay += inc_y * mult
- img.x = ox + ax
- img.y = oy + ay
- img.x = xx if (inc_x > 0 && img.x > xx) || (inc_x < 0 && img.x < xx)
- img.y = yy if (inc_y > 0 && img.y > yy) || (inc_y < 0 && img.y < yy)
- end
- img.bitmap.dispose
- img.dispose
- @grid.activate
- end
- def update
- super
- update_scrolling_backs
- @grid.update
- end
- def update_scrolling_backs
- @backs.each do |sym,sprite|
- next if @mod::Backgrounds[sym][:scroll].nil?
- sprite.ox += @mod::Backgrounds[sym][:scroll][0]
- sprite.oy += @mod::Backgrounds[sym][:scroll][1]
- end
- end
- def dispose_all_windows
- @grid.dispose
- @helpy.dispose
- @backs.each_value {|s| s.bitmap.dispose; s.dispose}
- super
- end
- end
- class SpriteGrid
- attr_accessor :key, :data, :index, :commands, :imgs,
- :current, :current_sym, :active, :visible, :enabled
- def initialize(key,grid,data,folder,flash,zoom,move,sound,buttons,arrows,
- back=nil,active=true,init_index=[0,0])
- @key = key # The identifier for the grid "window".
- @grid = grid # The grid settings.
- @data = data # The command settings.
- @folder = folder # The image folder used for images.
- @flash = flash # The flash settings.
- @zoom = zoom # The zoom settings.
- @move = move # The move settings.
- @sound = sound # The sound settings.
- @buttons = buttons # The button settings.
- @arrows = arrows # The arrow settings.
- @back = back if back[:img] != "" # The background settings.
- @active = active
- @visible = false
- @index = init_index # The current position - [row,col].
- zt = @active == true ? :active : :inactive
- @zoom_level = @zoom[:grid][zt].clone
- @counter = {}; @pattern = {}
- [:back,:cmds].each {|sym| @counter[sym] = 0; @pattern[sym] = 0}
- [:left,:right,:up,:down].each {|sym| @counter[sym] = 0; @pattern[sym] = 0}
- init_viewport
- init_back if @back
- init_commands
- init_imgs
- if @commands.size > 0
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- end
- init_arrows
- end
- def init_viewport
- ww = @grid[:view][:size][0]
- hh = @grid[:view][:size][1]
- xx = DynXY.get_x(@grid[:view][:pos][0],ww)
- yy = DynXY.get_y(@grid[:view][:pos][1],hh)
- @view = Viewport.new(xx,yy,ww,hh)
- @view.z = @grid[:view][:z]
- @vhorz = {:top => 0, :bottom => horz_imax - 1, :dest => 0, :spd => 0.0, :add => 0.0}
- @vvert = {:top => 0, :bottom => vert_imax - 1, :dest => 0, :spd => 0.0, :add => 0.0}
- end
- def init_back
- @bimg = Sprite.new
- @bimg.bitmap = Cache.custom_imgs(@back[:img],@folder)
- if @back[:cols]
- @bimg.src_rect.width = @bimg.bitmap.width / @back[:cols]
- @bimg.oy = @bimg.bitmap.height / 2
- @bimg.ox = @bimg.src_rect.width / 2
- ww = @bimg.src_rect.width
- hh = @bimg.bitmap.height
- @bimg.src_rect.x = @back[:frames][@pattern[:back]] * @bimg.src_rect.width
- else
- @bimg.src_rect.height = @bimg.bitmap.height / @back[:rows]
- @bimg.ox = @bimg.bitmap.width / 2
- @bimg.oy = @bimg.src_rect.height / 2
- ww = @bimg.bitmap.width
- hh = @bimg.src_rect.height
- @bimg.src_rect.y = @back[:frames][@pattern[:back]] * @bimg.src_rect.height
- end
- x = DynXY.get_x(@back[:pos][0],ww,@bimg.ox)
- y = DynXY.get_y(@back[:pos][1],hh,@bimg.oy)
- if @back[:zoom]
- @bimg.zoom_x = @zoom_level[0]
- @bimg.zoom_y = @zoom_level[1]
- end
- @bimg.x = x
- @bimg.y = y
- @bimg.opacity = @back[:opa]
- @bimg.z = @back[:z]
- end
- def init_commands
- @commands = []; @show = {}
- @data.each do |k,dt|
- next if k == :empty
- @commands << k if check_info(k,:show)
- end
- if @commands.empty?
- @commands << :empty
- end
- end
- def init_imgs
- @imgs = {}; @enabled = {}; row = col = 0; @iopa = {}; @add_pos = [0,0]
- @ipos = {}; @sym_pos = {}; @get_sym = {}; @max_row = {}; @max_col = {}
- @commands.each do |sym|
- dt = @data[sym]
- init_img(sym,dt,row,col)
- col += 1
- col += dt[:skip_col] if dt[:skip_col]
- @add_pos[0] = 0 if dt[:add_reset] && dt[:add_reset].include?(:x)
- @add_pos[1] = 0 if dt[:add_reset] && dt[:add_reset].include?(:y)
- if dt[:add_pos]
- @add_pos[0] += dt[:add_pos][0]
- @add_pos[1] += dt[:add_pos][1]
- end
- if col > @grid[:max_cols] - 1
- col = 0; row += 1
- end
- if dt[:skip_row]
- row += dt[:skip_row]; col = 0
- end
- end
- end
- def init_img(sym,dt,row,col)
- @imgs[[row,col]] = SpriteCmd.new(@view)
- @enabled[[row,col]] = check_info(sym,:enable)
- if @enabled[[row,col]]
- pic = @index == [[row,col]] ? :ea : :ei
- else
- pic = @index == [[row,col]] ? :da : :di
- end
- @imgs[[row,col]].bitmap = Cache.custom_imgs(dt[pic],@folder).clone
- @imgs[[row,col]].bitmap_name = dt[pic]
- if dt[:cols]
- @imgs[[row,col]].src_rect.width = @imgs[[row,col]].bitmap.width / dt[:cols]
- @imgs[[row,col]].oy = @imgs[[row,col]].bitmap.height/2
- @imgs[[row,col]].ox = @imgs[[row,col]].src_rect.width/2
- @imgs[[row,col]].src_rect.x = dt[:frames][@pattern[:cmds]] * @imgs[[row,col]].src_rect.width
- else
- @imgs[[row,col]].src_rect.height = @imgs[[row,col]].bitmap.height / dt[:rows]
- @imgs[[row,col]].ox = @imgs[[row,col]].bitmap.width/2
- @imgs[[row,col]].oy = @imgs[[row,col]].src_rect.height/2
- @imgs[[row,col]].src_rect.y = dt[:frames][@pattern[:cmds]] * @imgs[[row,col]].src_rect.height
- end
- if sym == :empty
- x = @view.rect.width/2
- y = @view.rect.height/2
- else
- x = col * (@grid[:isize][0] + @grid[:spacing][0]) + @grid[:isize][0]/2 + @grid[:padding][:l]
- y = row * (@grid[:isize][1] + @grid[:spacing][1]) + @grid[:isize][1]/2 + @grid[:padding][:u]
- end
- @imgs[[row,col]].x = x + @add_pos[0]
- @imgs[[row,col]].y = y + @add_pos[1]
- if row.between?(@vvert[:top],@vvert[:bottom]) &&
- col.between?(@vhorz[:top],@vhorz[:bottom])
- @imgs[[row,col]].opacity = dt[:opa][@enabled[[row,col]] ? 0 : 1]
- else
- @imgs[[row,col]].opacity = 0
- end
- @imgs[[row,col]].z = dt[:z][@index == [[row,col]] ? 0 : 1]
- @imgs[[row,col]].zoom_x = @zoom[pic][:limit][0] * @zoom_level[0]
- @imgs[[row,col]].zoom_y = @zoom[pic][:limit][1] * @zoom_level[1]
- # Grid variables:
- @ipos[[row,col]] = [@imgs[[row,col]].x,@imgs[[row,col]].y]
- @iopa[[row,col]] = {:dest => @imgs[[row,col]].opacity, :spd => 0, :add => 0}
- @sym_pos[sym] = [row,col]
- @get_sym[[row,col]] = sym
- @max_row[col] = row
- @max_col[row] = col
- end
- def init_arrows
- @aimgs = {}
- return if @arrows.nil?
- @arrows.each do |key,dt|
- next if dt.nil?
- @aimgs[key] = Sprite.new
- @aimgs[key].bitmap = Cache.custom_imgs(dt[:img],@folder)
- if dt[:cols]
- @aimgs[key].src_rect.width = @aimgs[key].bitmap.width / dt[:cols]
- @aimgs[key].oy = @aimgs[key].bitmap.height / 2
- @aimgs[key].ox = @aimgs[key].src_rect.width / 2
- ww = @aimgs[key].src_rect.width
- hh = @aimgs[key].bitmap.height
- @aimgs[key].src_rect.x = dt[:frames][@pattern[key]] * @aimgs[key].src_rect.width
- else
- @aimgs[key].src_rect.height = @aimgs[key].bitmap.height / dt[:rows]
- @aimgs[key].ox = @aimgs[key].bitmap.width / 2
- @aimgs[key].oy = @aimgs[key].src_rect.height / 2
- ww = @aimgs[key].bitmap.width
- hh = @aimgs[key].src_rect.height
- @aimgs[key].src_rect.y = dt[:frames][@pattern[key]] * @aimgs[key].src_rect.height
- end
- x = DynXY.get_x(dt[:pos][0],ww,@aimgs[key].ox)
- y = DynXY.get_y(dt[:pos][1],hh,@aimgs[key].oy)
- @aimgs[key].x = x
- @aimgs[key].y = y
- @aimgs[key].z = dt[:z]
- @aimgs[key].opacity = dt[:opa]
- set_arrow_vis(@aimgs[key],key)
- end
- end
- def width
- return @view.rect.width
- end
- def height
- return @view.rect.height
- end
- def max_cols
- return @max_col.values.max
- end
- def max_rows
- return @max_row.values.max
- end
- def horz_size
- @view.rect.width - (@grid[:padding][:l] + @grid[:padding][:r]) + @grid[:spacing][0]
- end
- def vert_size
- @view.rect.height - (@grid[:padding][:u] + @grid[:padding][:d]) + @grid[:spacing][1]
- end
- def horz_imax # max visible columns
- horz_size / (@grid[:isize][0] + @grid[:spacing][0])
- end
- def vert_imax # max visible rows
- vert_size / (@grid[:isize][1] + @grid[:spacing][1])
- end
- def x=(val)
- @view.rect.x = val
- end
- def y=(val)
- @view.rect.y = val
- end
- def check_zoom(val)
- return @imgs[@index].zoom_x == val[0] && @imgs[@index].zoom_y == val[1]
- end
- def set_arrow_vis(img,key)
- if !@visible
- img.visible = false if img.visible
- return
- end
- case key
- when :up
- if @vvert[:top] > 0
- img.visible = true if !img.visible
- else
- img.visible = false if img.visible
- end
- when :down
- if @vvert[:bottom] < self.max_rows
- img.visible = true if !img.visible
- else
- img.visible = false if img.visible
- end
- when :left
- if @vhorz[:top] > 0
- img.visible = true if !img.visible
- else
- img.visible = false if img.visible
- end
- when :right
- if @vhorz[:bottom] < self.max_cols
- img.visible = true if !img.visible
- else
- img.visible = false if img.visible
- end
- end
- end
- def check_info(sym,type)
- case @data[sym][type]
- when Integer
- return $game_switches[@data[sym][type]]
- when Symbol
- return method(@data[sym][type]).call
- when String
- return eval(@data[sym][type])
- when Array
- return method(@data[sym][type][0]).call(*@data[sym][type][1])
- else
- return @data[sym][type]
- end
- end
- def activate(z_lvl=nil,u_help=false)
- zx = z_lvl.nil? ? @zoom[:grid][:active][0] : z_lvl[0]
- zy = z_lvl.nil? ? @zoom[:grid][:active][1] : z_lvl[1]
- @zoom_level[0] = zx
- @zoom_level[1] = zy
- @active = true
- update_help if u_help
- end
- def deactivate(z_lvl=nil)
- zx = z_lvl.nil? ? @zoom[:grid][:inactive][0] : z_lvl[0]
- zy = z_lvl.nil? ? @zoom[:grid][:inactive][1] : z_lvl[1]
- @zoom_level[0] = zx
- @zoom_level[1] = zy
- @active = false
- reset_frame
- end
- def show
- @imgs.each do |key,img|
- set_img_visibility(key,img,true)
- end
- @bimg.visible = true if @back
- @visible = true
- @aimgs.each {|key,img| set_arrow_vis(img,key) } if @aimgs
- end
- def hide
- @imgs.each do |key,img|
- set_img_visibility(key,img,false)
- end
- @bimg.visible = false if @back
- @visible = false
- @aimgs.each {|key,img| img.visible = false } if @aimgs
- end
- def set_img_visibility(key,img,state)
- img.visible = state
- end
- def select_sym(sym)
- before = @index
- b_sym = @current_sym
- reset_frame
- @index = @sym_pos[sym]
- @index = before if @index.nil?
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- @aimgs.each {|key,img| set_arrow_vis(img,key) } if @aimgs
- update_help if before != @index || b_sym != @current_sym
- end
- def refresh
- before = @index
- b_sym = @current_sym
- @imgs.each {|k,sp| sp.dispose}
- init_commands
- init_imgs
- @index = before
- @index = [0,0] if @index.nil?
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- @aimgs.each {|key,img| set_arrow_vis(img,key) } if @aimgs
- update_help if before != @index || b_sym != @current_sym
- end
- def update
- return if @disposed || !@visible
- update_command_images if @commands.size > 0
- update_back_img if @back && @back[:zoom]
- update_view
- update_arrows if @aimgs
- if @active == true
- update_back_frames if @back
- update_sprite_frames if @commands.size > 0
- update_cursor if @commands.size > 0
- update_confirm if Input.trigger?(@buttons[:confirm])
- update_cancel if Input.trigger?(@buttons[:cancel])
- end
- end
- def update_back_img
- if @bimg.zoom_x < @zoom_level[0]
- @bimg.zoom_x += @back[:zspeed][0]
- @bimg.zoom_x = @zoom_level[0] if @bimg.zoom_x > @zoom_level[0]
- elsif @bimg.zoom_x > @zoom_level[0]
- @bimg.zoom_x -= @back[:zspeed][0]
- @bimg.zoom_x = @zoom_level[0] if @bimg.zoom_x < @zoom_level[0]
- end
- if @bimg.zoom_y < @zoom_level[1]
- @bimg.zoom_y += @back[:zspeed][1]
- @bimg.zoom_y = @zoom_level[1] if @bimg.zoom_y > @zoom_level[1]
- elsif @bimg.zoom_y > @zoom_level[1]
- @bimg.zoom_y -= @back[:zspeed][1]
- @bimg.zoom_y = @zoom_level[1] if @bimg.zoom_y < @zoom_level[1]
- end
- end
- def update_cursor
- move_left if Input.trigger?(@buttons[:prev_col]) || Input.repeat?(@buttons[:prev_col])
- move_right if Input.trigger?(@buttons[:next_col]) || Input.repeat?(@buttons[:next_col])
- move_up if Input.trigger?(@buttons[:prev_row]) || Input.repeat?(@buttons[:prev_row])
- move_down if Input.trigger?(@buttons[:next_row]) || Input.repeat?(@buttons[:next_row])
- end
- def correct_ox
- @vhorz[:dest] = @vhorz[:top] * (@grid[:isize][0] + @grid[:spacing][0])
- @vhorz[:spd] = (@vhorz[:dest] - @view.ox)/@grid[:scroll_time].to_f
- @vhorz[:add] = 0
- correct_imgs_opa
- @aimgs.each {|key,img| set_arrow_vis(img,key) } if @aimgs
- end
- def correct_oy
- @vvert[:dest] = @vvert[:top] * (@grid[:isize][1] + @grid[:spacing][1])
- @vvert[:spd] = (@vvert[:dest] - @view.oy)/@grid[:scroll_time].to_f
- @vvert[:add] = 0
- correct_imgs_opa
- @aimgs.each {|key,img| set_arrow_vis(img,key) } if @aimgs
- end
- def correct_imgs_opa
- @imgs.each do |key,img|
- if key[0].between?(@vvert[:top],@vvert[:bottom]) &&
- key[1].between?(@vhorz[:top],@vhorz[:bottom])
- ori_opa = @data[@get_sym[key]][:opa][@enabled[key] ? 0 : 1]
- @iopa[key][:dest] = ori_opa
- @iopa[key][:spd] = (@iopa[key][:dest] - img.opacity)/@grid[:scroll_time].to_f
- @iopa[key][:add] = 0
- else
- @iopa[key][:dest] = 0
- @iopa[key][:spd] = (@iopa[key][:dest] - img.opacity)/@grid[:scroll_time].to_f
- @iopa[key][:add] = 0
- end
- end
- end
- def update_opacity(key,img)
- if img.opacity < @iopa[key][:dest]
- @iopa[key][:add] += @iopa[key][:spd]
- img.opacity = img.opacity + @iopa[key][:add]
- img.opacity = @iopa[key][:dest] if img.opacity > @iopa[key][:dest]
- elsif img.opacity > @iopa[key][:dest]
- @iopa[key][:add] += @iopa[key][:spd]
- img.opacity = img.opacity + @iopa[key][:add]
- img.opacity = @iopa[key][:dest] if img.opacity < @iopa[key][:dest]
- end
- end
- def update_view
- if @view.ox < @vhorz[:dest]
- @vhorz[:add] += @vhorz[:spd]
- @view.ox = @view.ox + @vhorz[:add]
- @view.ox = @vhorz[:dest] if @view.ox > @vhorz[:dest]
- elsif @view.ox > @vhorz[:dest]
- @vhorz[:add] += @vhorz[:spd]
- @view.ox = @view.ox + @vhorz[:add]
- @view.ox = @vhorz[:dest] if @view.ox < @vhorz[:dest]
- end
- if @view.oy < @vvert[:dest]
- @vvert[:add] += @vvert[:spd]
- @view.oy = @view.oy + @vvert[:add]
- @view.oy = @vvert[:dest] if @view.oy > @vvert[:dest]
- elsif @view.oy > @vvert[:dest]
- @vvert[:add] += @vvert[:spd]
- @view.oy = @view.oy + @vvert[:add]
- @view.oy = @vvert[:dest] if @view.oy < @vvert[:dest]
- end
- end
- def move_left
- return if @max_col[@index[0]] <= 0
- @sound[:cursor].play
- reset_frame
- @index[1] -= 1
- if @index[1] < 0
- @index[1] = @max_col[@index[0]]
- force = true
- end
- while @imgs[@index].nil?
- @index[1] -= 1
- if @index[1] < 0
- @index[1] = @max_col[@index[0]]
- force = true
- end
- end
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- if force
- @vhorz[:bottom] = @index[1]
- @vhorz[:bottom] = horz_imax - 1 if @vhorz[:bottom] < horz_imax - 1
- @vhorz[:top] = @index[1] - (horz_imax - 1)
- @vhorz[:top] = 0 if @vhorz[:top] < 0
- correct_ox
- elsif !@index[1].between?(@vhorz[:top],@vhorz[:bottom])
- @vhorz[:top] = @index[1]
- @vhorz[:bottom] = @index[1] + horz_imax - 1
- @vhorz[:bottom] = self.max_cols if @vhorz[:bottom] > self.max_cols
- correct_ox
- end
- update_help
- end
- def move_right
- return if @max_col[@index[0]] <= 0
- @sound[:cursor].play
- reset_frame
- @index[1] += 1
- if @index[1] > @max_col[@index[0]]
- @index[1] = 0
- force = true
- end
- while @imgs[@index].nil?
- @index[1] += 1
- if @index[1] > @max_col[@index[0]]
- @index[1] = 0
- force = true
- end
- end
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- if force
- @vhorz[:top] = @index[1]
- @vhorz[:bottom] = @index[1] + horz_imax - 1
- @vhorz[:bottom] = self.max_cols if @vhorz[:bottom] > self.max_cols
- correct_ox
- elsif !@index[1].between?(@vhorz[:top],@vhorz[:bottom])
- @vhorz[:bottom] = @index[1]
- @vhorz[:bottom] = horz_imax - 1 if @vhorz[:bottom] < horz_imax - 1
- @vhorz[:top] = @index[1] - (horz_imax - 1)
- @vhorz[:top] = 0 if @vhorz[:top] < 0
- correct_ox
- end
- update_help
- end
- def move_up
- return if @max_row[@index[1]] <= 0
- @sound[:cursor].play
- reset_frame
- @index[0] -= 1
- if @index[0] < 0
- @index[0] = @max_row[@index[1]]
- force = true
- end
- while @imgs[@index].nil?
- @index[0] -= 1
- if @index[0] < 0
- @index[0] = @max_row[@index[1]]
- force = true
- end
- end
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- if force
- @vvert[:bottom] = @index[0]
- @vvert[:bottom] = vert_imax - 1 if @vvert[:bottom] < vert_imax - 1
- @vvert[:top] = @index[0] - (vert_imax - 1)
- @vvert[:top] = 0 if @vvert[:top] < 0
- correct_oy
- elsif !@index[0].between?(@vvert[:top],@vvert[:bottom])
- @vvert[:top] = @index[0]
- @vvert[:bottom] = @index[0] + vert_imax - 1
- @vvert[:bottom] = self.max_rows if @vvert[:bottom] > self.max_rows
- correct_oy
- end
- update_help
- end
- def move_down
- return if @max_row[@index[1]] <= 0
- @sound[:cursor].play
- reset_frame
- @index[0] += 1
- if @index[0] > @max_row[@index[1]]
- @index[0] = 0
- force = true
- end
- while @imgs[@index].nil?
- @index[0] += 1
- if @index[0] > @max_row[@index[1]]
- @index[0] = 0
- force = true
- end
- end
- @current_sym = @sym_pos.find {|sym,pos| pos == @index}[0]
- if force
- @vvert[:top] = @index[0]
- @vvert[:bottom] = @index[0] + vert_imax - 1
- @vvert[:bottom] = self.max_rows if @vvert[:bottom] > self.max_rows
- correct_oy
- elsif !@index[0].between?(@vvert[:top],@vvert[:bottom])
- @vvert[:bottom] = @index[0]
- @vvert[:bottom] = vert_imax - 1 if @vvert[:bottom] < vert_imax - 1
- @vvert[:top] = @index[0] - (vert_imax - 1)
- @vvert[:top] = 0 if @vvert[:top] < 0
- correct_oy
- end
- update_help
- end
- def update_confirm
- if @enabled[@index] && @commands.size > 0
- @sound[:confirm].play
- Input.update
- @imgs[@index].flash(*@flash[:enabled].values) if @flash[:enabled]
- SceneManager.scene.trigger_command(@key,@current_sym)
- else
- @sound[:disabled].play
- return if @commands.size <= 0
- @imgs[@index].flash(*@flash[:disabled].values) if @flash[:disabled]
- end
- end
- def update_cancel
- @sound[:cancel].play
- Input.update
- SceneManager.scene.cancel_command(@key,@current_sym)
- end
- def update_command_images
- @imgs.each do |key,img|
- next if img.nil? || img.disposed?
- update_img(key,img)
- end
- end
- def update_arrows
- @aimgs.each do |key,img|
- next if img.nil? || img.disposed?
- update_arrow_frames(key)
- end
- end
- def reset_frame
- @counter[:cmds] = 0; @pattern[:cmds] = 0
- if @data[@current_sym][:cols]
- @imgs[@index].src_rect.x = @data[@current_sym][:frames][@pattern[:cmds]] * @imgs[@index].src_rect.width
- else
- @imgs[@index].src_rect.y = @data[@current_sym][:frames][@pattern[:cmds]] * @imgs[@index].src_rect.height
- end
- end
- def reset_img(key,img,type)
- return if img.bitmap_name == @data[@get_sym[key]][type]
- img.bitmap.dispose unless img.bitmap.disposed?
- img.bitmap = Cache.custom_imgs(@data[@get_sym[key]][type],@folder).clone
- img.bitmap_name = @data[@get_sym[key]][type]
- if @data[@get_sym[key]][:cols]
- img.src_rect.width = img.bitmap.width / @data[@get_sym[key]][:cols]
- img.oy = img.bitmap.height/2
- img.ox = img.src_rect.width/2
- img.src_rect.x = @data[@get_sym[key]][:frames][@pattern[:cmds]] * img.src_rect.width
- else
- img.src_rect.height = img.bitmap.height / @data[@get_sym[key]][:rows]
- img.ox = img.bitmap.width/2
- img.oy = img.src_rect.height/2
- img.src_rect.y = @data[@get_sym[key]][:frames][@pattern[:cmds]] * img.src_rect.height
- end
- end
- def update_zoom_eff(img,type)
- if img.zoom_x > @zoom[type][:limit][0] * @zoom_level[0]
- img.zoom_x -= @zoom[type][:speed][0]
- img.zoom_x = @zoom[type][:limit][0] * @zoom_level[0] if img.zoom_x < @zoom[type][:limit][0] * @zoom_level[0]
- elsif img.zoom_x < @zoom[type][:limit][0] * @zoom_level[0]
- img.zoom_x += @zoom[type][:speed][0]
- img.zoom_x = @zoom[type][:limit][0] * @zoom_level[0] if img.zoom_x > @zoom[type][:limit][0] * @zoom_level[0]
- end
- if img.zoom_y > @zoom[type][:limit][1] * @zoom_level[1]
- img.zoom_y -= @zoom[type][:speed][1]
- img.zoom_y = @zoom[type][:limit][1] * @zoom_level[1] if img.zoom_y < @zoom[type][:limit][1] * @zoom_level[1]
- elsif img.zoom_y < @zoom[type][:limit][1] * @zoom_level[1]
- img.zoom_y += @zoom[type][:speed][1]
- img.zoom_y = @zoom[type][:limit][1] * @zoom_level[1] if img.zoom_y > @zoom[type][:limit][1] * @zoom_level[1]
- end
- end
- def update_img(key,img)
- img.update
- update_opacity(key,img)
- if @index == key
- if @enabled[key] == true
- reset_img(key,img,:ea)
- elsif @enabled[key] == false
- reset_img(key,img,:da)
- end
- img.z = @data[@get_sym[key]][:z][0] if img.z != @data[@get_sym[key]][:z][0]
- if @active == true
- update_zoom_eff(img,:ea)
- if img.x != @ipos[key][0]
- img.x -= @move[:speed][0] if img.x > @ipos[key][0]
- img.x += @move[:speed][0] if img.x < @ipos[key][0]
- end
- if img.y != @ipos[key][1]
- img.y -= @move[:speed][1] if img.y > @ipos[key][1]
- img.y += @move[:speed][1] if img.y < @ipos[key][1]
- end
- else
- update_zoom_eff(img,:sel)
- if img.x != @ipos[key][0] + @move[:dist][0]
- img.x -= @move[:speed][0] if img.x > @ipos[key][0] + @move[:dist][0]
- img.x += @move[:speed][0] if img.x < @ipos[key][0] + @move[:dist][0]
- end
- if img.y != @ipos[key][1] + @move[:dist][1]
- img.y -= @move[:speed][1] if img.y > @ipos[key][1] + @move[:dist][1]
- img.y += @move[:speed][1] if img.y < @ipos[key][1] + @move[:dist][1]
- end
- end
- else
- if @enabled[key] == true
- reset_img(key,img,:ei)
- elsif @enabled[key] == false
- reset_img(key,img,:di)
- end
- img.z = @data[@get_sym[key]][:z][1] if img.z != @data[@get_sym[key]][:z][1]
- update_zoom_eff(img,:ei)
- if img.x != @ipos[key][0]
- img.x -= @move[:speed][0] if img.x > @ipos[key][0]
- img.x += @move[:speed][0] if img.x < @ipos[key][0]
- end
- if img.y != @ipos[key][1]
- img.y -= @move[:speed][1] if img.y > @ipos[key][1]
- img.y += @move[:speed][1] if img.y < @ipos[key][1]
- end
- end
- end
- def update_sprite_frames
- @counter[:cmds] += 1
- if @counter[:cmds] % @data[@current_sym][:wait] == 0
- @pattern[:cmds] += 1
- @pattern[:cmds] = 0 if @pattern[:cmds] >= @data[@current_sym][:frames].size
- if @data[@current_sym][:cols]
- @imgs[@index].src_rect.x = @data[@current_sym][:frames][@pattern[:cmds]] * @imgs[@index].src_rect.width
- else
- @imgs[@index].src_rect.y = @data[@current_sym][:frames][@pattern[:cmds]] * @imgs[@index].src_rect.height
- end
- end
- end
- def update_arrow_frames(key)
- @counter[key] += 1
- if @counter[key] % @arrows[key][:wait] == 0
- @pattern[key] += 1
- @pattern[key] = 0 if @pattern[key] >= @arrows[key][:frames].size
- if @arrows[key][:cols]
- @aimgs[key].src_rect.x = @arrows[key][:frames][@pattern[key]] * @aimgs[key].src_rect.width
- else
- @aimgs[key].src_rect.y = @arrows[key][:frames][@pattern[key]] * @aimgs[key].src_rect.height
- end
- end
- end
- def update_back_frames
- @counter[:back] += 1
- if @counter[:back] % @back[:wait] == 0
- @pattern[:back] += 1
- @pattern[:back] = 0 if @pattern[:back] >= @back[:frames].size
- if @back[:cols]
- @bimg.src_rect.x = @back[:frames][@pattern[:back]] * @bimg.src_rect.width
- else
- @bimg.src_rect.y = @back[:frames][@pattern[:back]] * @bimg.src_rect.height
- end
- end
- end
- def update_help
- SceneManager.scene.update_help(@key,@current_sym)
- end
- def disposed?
- return @disposed
- end
- def dispose
- @imgs.each_value {|sp| sp.dispose}
- if @back
- @bimg.bitmap.dispose
- @bimg.dispose
- end
- @aimgs.each_value {|img| img.bitmap.dispose; img.dispose }
- @view.dispose
- @disposed = true
- end
- end
- class SpriteCmd < Sprite
- attr_accessor :bitmap_name
- def dispose
- self.bitmap.dispose if self.bitmap
- super
- end
- end
- class SpriteHelp
- attr_accessor :data
- def initialize(data,folder="",init_pic="")
- @data = data; @folder = folder
- init_pic = init_pic.to_s unless init_pic.is_a?(String)
- @pic = init_pic
- init_img
- end
- def init_img
- @img = Sprite.new
- @img.z = @data[:z]
- @img.opacity = @data[:opa]
- unless @pic.empty? || @folder.empty?
- @img.bitmap = Cache.custom_imgs(@pic,@folder)
- @img.ox = @img.bitmap.width/2
- @img.oy = @img.bitmap.height/2
- end
- if @img.bitmap
- x = DynXY.get_x(@data[:pos][0],@img.bitmap.width,@img.ox)
- y = DynXY.get_y(@data[:pos][1],@img.bitmap.height,@img.oy)
- @img.x = x; @img.y = y
- end
- end
- def hide
- @img.visible = false if @img
- end
- def show
- @img.visible = true if @img
- end
- def set_img(pic,folder,txt=nil)
- @pic = pic; @folder = folder
- @pic = @pic.to_s unless @pic.is_a?(String)
- @img.bitmap.dispose if @img.bitmap && !@img.bitmap.disposed?
- return if @pic.empty?
- @img.bitmap = Cache.custom_imgs(@pic,@folder)
- @img.ox = @img.bitmap.width/2
- @img.oy = @img.bitmap.height/2
- if @img.bitmap && !@img.bitmap.disposed?
- x = DynXY.get_x(@data[:pos][0],@img.bitmap.width,@img.ox)
- y = DynXY.get_y(@data[:pos][1],@img.bitmap.height,@img.oy)
- @img.x = x; @img.y = y
- end
- if txt
- @img.bitmap.font.name = @data[:font][:type]
- @img.bitmap.font.size = @data[:font][:size]
- @img.bitmap.font.color = @data[:font][:color]
- y = @data[:tpos][1]; th = @data[:lheight]; al = @data[:talign]
- txt.each do |text|
- @img.bitmap.draw_text(@data[:tpos][0],y,@img.bitmap.width,th,text,al)
- y += th
- end
- end
- end
- def update
- @img.update
- end
- def dispose
- if @img && !@img.disposed?
- @img.bitmap.dispose if @img.bitmap && !@img.bitmap.disposed?
- @img.dispose
- end
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement