Advertisement
TheSixth

Animated Command Buttons by Sixth

Sep 2nd, 2015
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 62.39 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Animated Commands
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 17/06/2015
  7. # * Requires: ------
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (17/06/2015)
  12. #   - Initial release.
  13. # * Version 1.1 (17/06/2015)
  14. #   - Made it possible to move the cursor even before the entering animation
  15. #     is finished (optional).
  16. #-------------------------------------------------------------------------------
  17. # * < Description >
  18. #-------------------------------------------------------------------------------
  19. # * This script is part of my unreleased menu engine!
  20. # * This script is mainly a scripters tool, keep that in mind!
  21. # * This script changes the way how command windows are displayed entirely.
  22. # * The sole purpose of this script is to add better visuals and animations for
  23. #   your command windows using pictures and "built-in" animation methods.
  24. #   This script only changes the main menu commands, but it can be used for
  25. #   any command window you want, if you know your way in scripting, that is!
  26. # * You can set up an entering, an exiting and a selection animation too!
  27. # * You can set up animations on a per command button basis, so you can create
  28. #   non-linear and complex animations "easily"!
  29. #   Two commands flying in from the left, two from above, two fading in, and
  30. #   three zooming in at their place in the meanwhile, sounds fun, right? :P
  31. # * You can create the following types of animations and effects and combine
  32. #   them freely:
  33. #   - Moving animation
  34. #   - Fade in/fade out animation
  35. #   - Zoom in/zoom out animation
  36. #   - Tone changing animation (changes during command selection)
  37. #   - Blending mode changes (changes during command selection)
  38. #   - Picture based animation (only active while the command is selected)
  39. #   - Flashing animation (only active while the command is selected)
  40. # * Each animation and effect got separate speed settings (if applicable), so
  41. #   you can synchronize your animations the way you want!
  42. # * In addition to the above cool things, you can place your command buttons
  43. #   wherever you want on your screen! 2 in each of the corners? No problem! :)
  44. # * As a bonus, this script can act as a menu command organizer too, since you
  45. #   get complete control over your commands and what they do! This means you can:
  46. #   - Add/remove default/custom command buttons easily!
  47. #   - Order your commands how you want!
  48. #   - Change their enable and show conditions how you want!
  49. #     Tie them to switches, add a script requirement or call already coded in
  50. #     methods to define their enable/show states!
  51. #     Or simply turn them ON or OFF forever, but where is the fun in that, right?
  52. #   - Make your own command buttons for common events or even for script calls!
  53. #   - And more! ... No actually there are no more... Ohh, well... :P
  54. #-------------------------------------------------------------------------------
  55. # * < Instructions for Scripters >
  56. #-------------------------------------------------------------------------------
  57. # * The new class created is named 'SpriteCommands'.
  58. #   This class takes two arguments for it's initialization method:
  59. #     1. The module data for your command setup.
  60. #     2. The folder path to the images used for the command sprites.
  61. #     3. The selection settings (important for cursor behavior).
  62. #   Knowing this, you can easily create your own command window settings:
  63. #     1. Replace the old command window with this class in your scene.
  64. #     2. Paste your command settings as the first argument.
  65. #     3. Paste your image folder settings as the second argument.
  66. #     4. Paste your selection settings as the second argument.
  67. #     5. Set up the handlers for the window in the scene just like I did here
  68. #        (should not be hard, basically it is just copy/paste and change the
  69. #        module/setting names).
  70. #     6. Copy the 'init_exiting' and 'exit_now' methods to your own scene.
  71. #     7. If you want common event or script command buttons, copy and paste the
  72. #        related methods from this script into your own scene class!
  73. #        The method names for these are kinda hard to miss... :D
  74. #     8. Copy any missing or new methods from your old window class into the
  75. #        new class.
  76. #   Note that the layout of your command and selection settings must follow the
  77. #   same layout found in this script!
  78. #   If you have any questions, you can ask me anytime in the topic you found
  79. #   this script!
  80. #-------------------------------------------------------------------------------
  81. # * < Installation >
  82. #-------------------------------------------------------------------------------
  83. # * In the script editor, place this script below Materials but above Main!
  84. # * If you are using any custom menu scripts, place this script below them!
  85. #-------------------------------------------------------------------------------
  86. # * < Compatibility Info >
  87. #-------------------------------------------------------------------------------
  88. # * No known incompatibilities, but since I have overwritten some methods for
  89. #   the visuals, there might be problems with other menu scripts.
  90. # * Overwritten methods:
  91. #   - In the Scene_Menu class:
  92. #     ~ create_command_window,
  93. #     ~ create_status_window (thanks to Enterbrain's way of positioning windows) -.-
  94. # * I replaced Window_MenuCommand with my new class called SpriteCommands in
  95. #   Scene_Menu.
  96. #   The good news is that I inherit from Window_MenuCommand, so any method
  97. #   defined there (such as custom enable checks, for example) will be there!
  98. # * I disabled the 'update_cursor' method in the new class, since it is not
  99. #   needed anymore.
  100. # * Also the new class got it's own method of 'make_command_list' and the only
  101. #   way your custom buttons will show up is to add them through the command
  102. #   settings in the module!
  103. #-------------------------------------------------------------------------------
  104. # * < Known Issues >
  105. #-------------------------------------------------------------------------------
  106. # * No known issues.
  107. #-------------------------------------------------------------------------------
  108. # * < Terms of Use >
  109. #-------------------------------------------------------------------------------
  110. # * Free to use for whatever purposes you want.
  111. # * Credit me (Sixth) in your game, pretty please! :P
  112. # * Posting modified versions of this script is allowed as long as you notice me
  113. #   about it with a link to it!
  114. #===============================================================================
  115. module MCommands
  116.   #--------------------------------------------------------------------------  
  117.   # Image Folder Settings:
  118.   #--------------------------------------------------------------------------
  119.   # Setup the folders used for your images here.
  120.   # This demo uses the :main folder settings!
  121.   # All images used must be in the folder you set up here!
  122.   #--------------------------------------------------------------------------
  123.   ImgFolder = { # <-- No touchy-touchy!
  124.     :main => "Graphics/MenuHUD/Main/",
  125.   } # <-- No touchy-touchy!
  126.  
  127.   #--------------------------------------------------------------------------  
  128.   # Status WIndow Settings:
  129.   #--------------------------------------------------------------------------
  130.   # In case you need to change these settings for your status window to
  131.   # account for the changes in your command window, you can do it here.
  132.   # What each of them does should be obvious.
  133.   #--------------------------------------------------------------------------
  134.   StatusWindow = { # <-- No touchy-touchy!
  135.     :pos => [200,0],
  136.     :size => [400,400],
  137.     :opa => 0,
  138.   } # <-- No touchy-touchy!
  139.  
  140.   #--------------------------------------------------------------------------  
  141.   # Selection Settings:
  142.   #--------------------------------------------------------------------------
  143.   # These settings are important for the cursor's behaviour during command
  144.   # selection.
  145.   # For example, having two command pictures on the left and two on the right
  146.   # with the :max_col setting set to 1 will only let you select the commands
  147.   # with the up and down arrows. But if you set that to 2, you can use the left
  148.   # and right buttons too for selection.
  149.   # If your commands are lined up horizontally, set the :max_col settings to the
  150.   # number of commands you can have at max, and set the :horizontal setting
  151.   # to true. That will ensure that only the left and right buttons are available
  152.   # for selection, and the cursor will be able to wrap around if you set the
  153.   # :horizontal setting to true.
  154.   #--------------------------------------------------------------------------
  155.   Selection = { # <-- No touchy-touchy!
  156.     :max_col => 1,
  157.     :horizontal => false,
  158.     :eselect => true,
  159.   } # <-- No touchy-touchy!
  160.  
  161.   #--------------------------------------------------------------------------  
  162.   # Command Settings:
  163.   #--------------------------------------------------------------------------    
  164.   # Well, you set up your commands here.
  165.   # The entire purpose of this script is to let you animate your command
  166.   # buttons the way you want to, and to make that possible to do on a per
  167.   # command button basis, so if you want, you can design a different animation
  168.   # for each of your command buttons separately!
  169.   #
  170.   # There are a lot to set up, so if you are not willing to read the descriptions
  171.   # of these settings, than you might as well delete this script, because without
  172.   # knowing what these settings do, you won't be able to make your own animations,
  173.   # you might even screw up the whole game! So, please, read the stuffs below!
  174.   #
  175.   # Let's start with the easier settings first...
  176.   # I ordered the settings this way:
  177.   # Non-animation settings first, animation settings later.
  178.   # Most of the animation settings can be omitted (but NOT ALL of them!), so
  179.   # it is best to place them lower on the list.
  180.   #
  181.   # So, the settings start with a unique identifier for the command button.
  182.   # I will refer to that by "command ID" from now on!
  183.   # These command IDs must be unique (so no duplicates), but aside from that,
  184.   # they can be just about everything (integers, strings, symbols). I used
  185.   # simple integers, those are easy to follow.
  186.   #
  187.   # The order how you set your command buttons up in the main setting's hash
  188.   # will decide in which order they will appear on the scene. This is important
  189.   # for the animation settings (in case you want to design delayed animations),
  190.   # and this will also decide which command will be selected upon a button press.
  191.   # So, it is important, in short, and should not be neglected!
  192.   #
  193.   # Okay, now for the details:
  194.   #
  195.   #   :name => "text",
  196.   # The name of the command button. This is not used yet, you can even omit it,
  197.   # if you want, I just put it in for possible later usage.
  198.   #
  199.   #   :symbol => :command_symbol,
  200.   # This is the symbol of the command button. Needed for processing the correct
  201.   # code when the command is selected (pressing the confirm button on it).
  202.   # If you want to add your own custom buttons, but don't know what symbol some
  203.   # scripts use, you will have to ask the author of the script about it!
  204.   # In case you want to make your own common event or script command buttons,
  205.   # you can enter your own symbols, doesn't matter how you name your symbols,
  206.   # but there can be NO duplicates! If one command button got :event for it's
  207.   # :symbol setting, no other command button can have it's :symbol setting set
  208.   # to :event!
  209.   # If you want to set up a common event or script command button, you will need
  210.   # to set up a new setting called :extra for the command button too!
  211.   #
  212.   #   :extra => event_id, # <-- For common event command buttons.
  213.   #   :extra => "code to evaluate", # <-- For script command buttons.
  214.   # This is the extra settings needed for common event or script command buttons.
  215.   # If you need this for a common event, enter the ID of the common event from
  216.   # the database. If you need this for a script command button, enter the ruby
  217.   # code to evaluate as a string.
  218.   # In the case of a script command button, the command window will NOT get
  219.   # activated automatically, so if you want that to happen after your code, you
  220.   # must enter this at the end of your script string: "@command_window.activate".
  221.   # If the command button is neither a common event, nor a script command button,
  222.   # you can omit this setting!
  223.   #
  224.   #   :method => :method_symbol,
  225.   # The method to run upon selecting this command. You must know the correct
  226.   # method symbol for the command here. Again, if you have a custom scrript and
  227.   # you have trouble finding out what symbol to enter here, you will need to ask
  228.   # the author of that custom script about it!
  229.   # If the command is a common event or script command button, you must set this
  230.   # to :do_the_event or :do_the_script repectively!
  231.   #
  232.   #   :enable => condition,
  233.   # The condition that must be true for the command to be enabled.
  234.   # You have several options here:
  235.   # 1. Enter an integer number and it will check for the switch with that ID.
  236.   #    If the switch is turned ON, it will be enabled, if not, it will be disabled.
  237.   # 2. Enter a symbol, and a method with that name will be run to determine the
  238.   #    state of the command button. The method must be defined in any of these
  239.   #    classes: Window_Base, Window_Selectable, Window_Command,
  240.   #             Window_MenuCommand, SpriteCommands (the new class of this script).
  241.   # 3. Enter a string, and it will be treated as a ruby code, and the evaluation
  242.   #    of that code will decide if the command will be enabled or not. The code
  243.   #    entered must return either true or false!
  244.   # 4. Simply enter true, and it will always be enabled.
  245.   #
  246.   #   :show => condition,
  247.   # This is the same as the :enable setting, but this one will decide if the
  248.   # command button will show up or not. You have the same options available here
  249.   # like at the :enable settings.
  250.   #
  251.   #   :z => value,
  252.   # The Z value of the image used for the command button. No idea if this is
  253.   # useful or not, but I added it just in case.
  254.   #
  255.   #   :pic => {
  256.   #     :e => "file name", :d => "file name", :h => "file name",
  257.   #     :anim => {:frames => [frame list], :wait => value, :rows => number},
  258.   #   },
  259.   # This is the image setup for the command button. The images you set up here
  260.   # will be shown on the scene. You can set up 3 kinds of images, one will show
  261.   # up when the command is enabled (:e, as 'enabled'), one will show up if the
  262.   # command is disabled (:d, as 'disabled'), and the last one will be shown if
  263.   # the command is hidden (:h, as 'hidden'), aka "not shown".
  264.   # The command is hidden if it's show condition is not true!
  265.   # If the command is hidden, it can not be selected, but you can still show an
  266.   # image for it if you want! If you don't want to show an image for hidden
  267.   # commands, you can make a transparent image and use that!
  268.   # Now, the :anim settings are there for you to make even more complex
  269.   # animations using a series of pictures from a sheet.
  270.   # You will need an image sheet to do this. Each picture on the sheet must be
  271.   # below the other, so the final sheet will be a series of pictures ordered
  272.   # vertically! These pictures than will get an index from the top to bottom.
  273.   # The index numbers start with 0 and goes to infinity!
  274.   # The :frames setting is an array of integer numbers. These numbers will decide
  275.   # the order of the animation pictures shown from the command image sheet.
  276.   # You can enter as many numbers into the array as you wish, making it possible
  277.   # to design really detailed animations! The numbers represent picture indexes
  278.   # from the image sheet used! Once the last picture is shown from the sheet,
  279.   # it starts over from the first picture index!
  280.   # The :wait setting decides how quickly the images will cycle from the sheet.
  281.   # Lower values mean slower change, higher values mean quicker change (which
  282.   # usually makes smoother animations). It is measured in frames!
  283.   # The :rows setting is the number of pictures you use on your image sheet.
  284.   # So, you can have less rows than your actual :frames size, and you can re-use
  285.   # the pictures from your sheet as many times as you want without forcing you
  286.   # to add duplicate pictures on the sheet.
  287.   # Note that if you decide to use this kind of animation, the top picture must
  288.   # be the initial picture which you want to show up when the command pictures
  289.   # are created and the entering animation plays!
  290.   #
  291.   #   :tone => {:a => [r,g,b,gr], :i => [r,g,b,gr], :speed => value},
  292.   # The tone of the pictures used. As before, :a stands for 'active' and :i
  293.   # stands for 'inactive'. Enter the red, green, blue and gray values of the
  294.   # tone you want in the array settings. The tone change between the active and
  295.   # inactive state will change smoothly, depending on the :speed settings.
  296.   # The lower your :speed setting is, the smoother and slower will the change be,
  297.   # and if you set it a higher value, the change will happeen more quickly.
  298.   #
  299.   #   :blend => {:a => type, :i => type, :da => type, :di => type},
  300.   # The blend mode of the pictures. There are several settings, these are:
  301.   #   :a = enabled active command
  302.   #   :i = enabled inactive command
  303.   #   :da = disabled active command
  304.   #   :di = disabled inactive command
  305.   # You can set a separate blending mode for each of the states from above.
  306.   # 3 types of modes are available:
  307.   # 0 = normal, 1 = addition, 2 = subtraction.
  308.   # I don't think I can explain what each type does exactly, so you will have to
  309.   # experiment on your own with these, sorry!
  310.   #
  311.   #   :flash => {:color => [r,g,b,a], :dur => value, :wait => value},
  312.   # Settings for the flashing animation. You can set up a color for it with
  313.   # RGBA values. Each color value goes from 0 to 255!
  314.   # The :dur option decides how long will the flashing last.
  315.   # The :wait option decides how long it should wait for the next flash effect
  316.   # after a flashing. This value must be higher than the :dur value!
  317.   # The image will be flashing once when it's activation animation (if any) is
  318.   # completed automatically. After that, it will flash periodically, once after
  319.   # each :wait frames.
  320.   #
  321.   # This ends the easier part of the configuration.
  322.   # The following configurations are all related to the animations of the
  323.   # command buttons!
  324.   #
  325.   # You got 3 separate settings for your animation needs:
  326.   #   :enter = This will be played upon opening the scene, and only once!
  327.   #   :exit = This plays upon exiting the scene.
  328.   #   :anim = This plays when the command button is selected. If the button is
  329.   #           selected, the animation settings set up here will be performed
  330.   #           on the selected button image, and if the button is no longer
  331.   #           selected, the animation set up here will be performed again, but
  332.   #           this time, it will reverse any effect.
  333.   #           The player does not have to wait for the full animation to finish
  334.   #           to select another command, so don't worry about that!
  335.   #
  336.   # Some settingss can and some settings can NOT be omitted. Here are the ones
  337.   # which needs to be set up:
  338.   # The whole :enter animation setting! This will determine the initial values
  339.   # for your command button, so this must be set up!
  340.   # The rest is optional, but if you want some cool animations during command
  341.   # selection, and upon exiting the scene, you will need to set them up!
  342.   #  
  343.   # Let's see the animation options in detail now:
  344.   #
  345.   # For the :enter and :exit animation settings:
  346.   #   :pos => {:start => [x,y], :end => [x,y], :speed => [xspeed,yspeed]},
  347.   # For the :anim settings:
  348.   #   :pos => {:move => [x,y], :speed => [xspeed,yspeed]},
  349.   # Like the name suggests, this will give you a move animation.
  350.   # In the case of :enter and :exit animations, the X and Y values in the :start
  351.   # and :end settings are direct positions on the screen. The image will move
  352.   # from the :start position to the :end position. When it reaches the :end
  353.   # position, the :enter/:exit animation phase is finished.
  354.   # In the case of :anim settings, the X and Y values are the offset values for
  355.   # the animation. The image will move that many pixels on the X/Y axis when
  356.   # selected from it's original position. The command images' original position
  357.   # is the X and Y position of the :enter animation's :end settings!
  358.   # The speed at which the image will move is controlled by the :speed settings.
  359.   # The first is the move speed on the X axis, and the second is the move speed
  360.   # on the Y axis. 1 means that the image will be moved by 1 pixel at a frame!
  361.   # Entering higher numbers yields quicker move speed!
  362.   # You don't have to worry about the image ending up in wrong positions, the
  363.   # final position of the image can never be more than what you enter in the
  364.   # relative settings, regardless if it is a negative or positive value!
  365.   #
  366.   #   :opa => {:start => value, :end => value, :speed => value},
  367.   # This will give a fade in/fade out animation.
  368.   # All three animation settings use the same format!
  369.   # The image's opacity will start on the opacity value entered for the :start
  370.   # setting, and will gradually increase/decrease depending on the :speed
  371.   # setting. Like above, the :speed determines how much will get added/subtracted
  372.   # to/from the image's opacity at each frame.
  373.   # Remember that the minimum opacity is 0 and the maximum is 255, with 0 being
  374.   # fully transparent!
  375.   #
  376.   #   :zoom => {
  377.   #     :x => {:start => value, :end => value, :speed => value},
  378.   #     :y => {:start => value, :end => value, :speed => value},
  379.   #   },
  380.   # This will give a zoom in/zoom out animation.
  381.   # You can set the zoom level on the X and Y axis separately.
  382.   # If you have been reading the above two setting decriptions, you should
  383.   # already know what each of these settings do.
  384.   # Remember that the normal zoom level is 1.0! Lower values will zoom out the
  385.   # image, while higher values will zoom in! Setting the zoom level to 0.0 will
  386.   # effectively make the image disappear completely!
  387.   #
  388.   # And these were the currently available animation settings!
  389.   # Final notes:
  390.   # - The initial position, opacity and zoom levels of the command images will
  391.   #   be the same what you have set up for the :enter animation setting's :end
  392.   #   values! You should design your :exit and :anim animations with this in mind!
  393.   # - The :enter and :exit animations will only be set as "finished" if ALL of
  394.   #   the set up animations are finished executing! You will not be able to
  395.   #   select any command before the :enter animation is finished, and the scene
  396.   #   will not exit until the :exit animation is finished (if any)!
  397.   # - The :symbol setting MUST be a unique symbol! You can NOT have duplicates!
  398.   #   The button images will get the :symbol as their identifiers, so if there
  399.   #   are duplicates, some images will be missing!
  400.   # - Do not forget the commas in the settings! Seriously, DON'T FORGET THEM! :P
  401.   #--------------------------------------------------------------------------    
  402.   Commands = { # <-- No touchy-touchy!
  403.     0 => { # 1st command - Settings start!
  404.       :name => "Items",
  405.       :symbol => :item,
  406.       :method => :command_item,
  407.       :enable => :main_commands_enabled,
  408.       :show => true,
  409.       :z => 100,
  410.       :pic => {
  411.         :e => "Items1", :d => "Items1", :h => "Hidden1",
  412.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  413.       },
  414.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255],:speed => 10},
  415.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  416.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  417.       :enter => { # Enter animation settings start!
  418.         :pos => {:start => [-100,-30], :end => [80,30], :speed => [5,1]},
  419.         :opa => {:start => 100, :end => 255, :speed => 2},
  420.         :zoom => {
  421.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  422.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  423.         },
  424.       }, # Enter animation settings end!
  425.       :anim => { # Selection animation settings start!
  426.         :pos => {:move => [40,0], :speed => [2,1]},
  427.         :opa => {:start => 255, :end => 255, :speed => 1},
  428.         :zoom => {
  429.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  430.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  431.         },
  432.       }, # Selection animation settings end!
  433.       :exit => { # Exit animation settings start!
  434.         :pos => {:start => [80,30], :end => [80,30], :speed => [5,1]},
  435.         :opa => {:start => 255, :end => 0, :speed => 15},
  436.         :zoom => {
  437.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  438.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  439.         },
  440.       }, # Exit animation settings end!
  441.     }, # 1st command - Settings end!
  442.     1 => { # 2nd command - Settings start!
  443.       :name => "Skills",
  444.       :symbol => :skill,
  445.       :method => :command_personal,
  446.       :enable => :main_commands_enabled,
  447.       :show => true,
  448.       :z => 100,
  449.       :pic => {
  450.         :e => "Skills1", :d => "Skills1", :h => "Hidden1",
  451.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  452.       },
  453.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  454.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  455.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  456.       :enter => {
  457.         :pos => {:start => [-130,-60], :end => [80,60], :speed => [5,2]},
  458.         :opa => {:start => 100, :end => 255, :speed => 2},
  459.         :zoom => {
  460.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  461.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  462.         },
  463.       },
  464.       :anim => {
  465.         :pos => {:move => [40,0], :speed => [2,1]},
  466.         :opa => {:start => 255, :end => 255, :speed => 1},
  467.         :zoom => {
  468.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  469.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  470.         },
  471.       },
  472.       :exit => {
  473.         :pos => {:start => [80,60], :end => [80,60], :speed => [5,1]},
  474.         :opa => {:start => 255, :end => 0, :speed => 15},
  475.         :zoom => {
  476.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  477.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  478.         },
  479.       },
  480.     }, # 2nd command - Settings end!
  481.     2 => { # 3rd command - Settings start!
  482.       :name => "Equipment",
  483.       :symbol => :equip,
  484.       :method => :command_personal,
  485.       :enable => :main_commands_enabled,
  486.       :show => true,
  487.       :z => 100,
  488.       :pic => {
  489.         :e => "Equipment1", :d => "Equipment1", :h => "Hidden1",
  490.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  491.       },
  492.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  493.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  494.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  495.       :enter => {
  496.         :pos => {:start => [-160,-90], :end => [80,90], :speed => [5,3]},
  497.         :opa => {:start => 100, :end => 255, :speed => 2},
  498.         :zoom => {
  499.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  500.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  501.         },
  502.       },
  503.       :anim => {
  504.         :pos => {:move => [40,0], :speed => [2,1]},
  505.         :opa => {:start => 255, :end => 255, :speed => 1},
  506.         :zoom => {
  507.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  508.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  509.         },
  510.       },
  511.       :exit => {
  512.         :pos => {:start => [80,90], :end => [80,90], :speed => [5,1]},
  513.         :opa => {:start => 255, :end => 0, :speed => 15},
  514.         :zoom => {
  515.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  516.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  517.         },
  518.       },
  519.     }, # 3rd command - Settings end!
  520.     3 => { # 4th command - Settings start!
  521.       :name => "Gems",
  522.       :symbol => :gems,
  523.       :method => :command_personal,
  524.       :enable => true,
  525.       :show => true,
  526.       :z => 100,
  527.       :pic => {
  528.         :e => "Gems1", :d => "Gems1", :h => "Hidden1",
  529.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  530.       },
  531.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  532.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  533.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  534.       :enter => {
  535.         :pos => {:start => [-190,-120], :end => [80,120], :speed => [5,4]},
  536.         :opa => {:start => 100, :end => 255, :speed => 2},
  537.         :zoom => {
  538.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  539.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  540.         },
  541.       },
  542.       :anim => {
  543.         :pos => {:move => [40,0], :speed => [2,1]},
  544.         :opa => {:start => 255, :end => 255, :speed => 1},
  545.         :zoom => {
  546.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  547.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  548.         },
  549.       },
  550.       :exit => {
  551.         :pos => {:start => [80,120], :end => [80,120], :speed => [5,1]},
  552.         :opa => {:start => 255, :end => 0, :speed => 15},
  553.         :zoom => {
  554.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  555.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  556.         },
  557.       },
  558.     }, # 4th command - Settings end!
  559.     4 => { # 5th command - Settings start!
  560.       :name => "Status",
  561.       :symbol => :status,
  562.       :method => :command_personal,
  563.       :enable => :main_commands_enabled,
  564.       :show => true,
  565.       :z => 100,
  566.       :pic => {
  567.         :e => "Status1", :d => "Status1", :h => "Hidden1",
  568.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  569.       },
  570.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  571.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  572.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  573.       :enter => {
  574.         :pos => {:start => [-220,-150], :end => [80,150], :speed => [5,5]},
  575.         :opa => {:start => 100, :end => 255, :speed => 2},
  576.         :zoom => {
  577.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  578.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  579.         },
  580.       },
  581.       :anim => {
  582.         :pos => {:move => [40,0], :speed => [2,1]},
  583.         :opa => {:start => 255, :end => 255, :speed => 1},
  584.         :zoom => {
  585.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  586.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  587.         },
  588.       },
  589.       :exit => {
  590.         :pos => {:start => [80,150], :end => [80,150], :speed => [5,1]},
  591.         :opa => {:start => 255, :end => 0, :speed => 15},
  592.         :zoom => {
  593.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  594.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  595.         },
  596.       },
  597.     }, # 5th command - Settings end!
  598.     5 => { # 6th command - Settings start!
  599.       :name => "Formation",
  600.       :symbol => :formation,
  601.       :method => :command_formation,
  602.       :enable => :formation_enabled,
  603.       :show => true,
  604.       :z => 100,
  605.       :pic => {
  606.         :e => "Formation1", :d => "Formation1", :h => "Hidden1",
  607.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  608.       },
  609.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  610.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  611.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  612.       :enter => {
  613.         :pos => {:start => [-250,-180], :end => [80,180], :speed => [5,6]},
  614.         :opa => {:start => 100, :end => 255, :speed => 2},
  615.         :zoom => {
  616.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  617.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  618.         },
  619.       },
  620.       :anim => {
  621.         :pos => {:move => [40,0], :speed => [2,1]},
  622.         :opa => {:start => 255, :end => 255, :speed => 1},
  623.         :zoom => {
  624.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  625.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  626.         },
  627.       },
  628.       :exit => {
  629.         :pos => {:start => [80,180], :end => [80,180], :speed => [5,1]},
  630.         :opa => {:start => 255, :end => 0, :speed => 15},
  631.         :zoom => {
  632.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  633.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  634.         },
  635.       },
  636.     }, # 6th command - Settings end!
  637.     6 => { # 7th command - Settings start!
  638.       :name => "Save",
  639.       :symbol => :save,
  640.       :method => :command_save,
  641.       :enable => :save_enabled,
  642.       :show => true,
  643.       :z => 100,
  644.       :pic => {
  645.         :e => "Save1", :d => "Save1", :h => "Hidden1",
  646.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  647.       },
  648.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  649.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  650.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  651.       :enter => {
  652.         :pos => {:start => [-280,-210], :end => [80,210], :speed => [5,7]},
  653.         :opa => {:start => 100, :end => 255, :speed => 2},
  654.         :zoom => {
  655.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  656.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  657.         },
  658.       },
  659.       :anim => {
  660.         :pos => {:move => [40,0], :speed => [2,1]},
  661.         :opa => {:start => 255, :end => 255, :speed => 1},
  662.         :zoom => {
  663.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  664.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  665.         },
  666.       },
  667.       :exit => {
  668.         :pos => {:start => [80,210], :end => [80,210], :speed => [5,1]},
  669.         :opa => {:start => 255, :end => 0, :speed => 15},
  670.         :zoom => {
  671.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  672.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  673.         },
  674.       },
  675.     }, # 7th command - Settings end!
  676.     7 => { # 8th command - Settings start!
  677.       :name => "Game End",
  678.       :symbol => :game_end,
  679.       :method => :command_game_end,
  680.       :enable => true,
  681.       :show => true,
  682.       :z => 100,
  683.       :pic => {
  684.         :e => "Game End1", :d => "Game End1", :h => "Hidden1",
  685.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  686.       },
  687.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  688.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  689.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  690.       :enter => {
  691.         :pos => {:start => [-310,-240], :end => [80,240], :speed => [5,8]},
  692.         :opa => {:start => 100, :end => 255, :speed => 2},
  693.         :zoom => {
  694.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  695.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  696.         },
  697.       },
  698.       :anim => {
  699.         :pos => {:move => [40,0], :speed => [2,1]},
  700.         :opa => {:start => 255, :end => 255, :speed => 1},
  701.         :zoom => {
  702.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  703.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  704.         },
  705.       },
  706.       :exit => {
  707.         :pos => {:start => [80,240], :end => [80,240], :speed => [5,1]},
  708.         :opa => {:start => 255, :end => 0, :speed => 15},
  709.         :zoom => {
  710.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  711.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  712.         },
  713.       },
  714.     }, # 8th command - Settings end!
  715.     8 => { # 9th command - Settings start!
  716.       :name => "Common Event 1",
  717.       :symbol => :common_event1,
  718.       :method => :do_the_event,
  719.       :extra => 9,
  720.       :enable => true,
  721.       :show => true,
  722.       :z => 100,
  723.       :pic => {
  724.         :e => "Event 1", :d => "Event 1", :h => "Hidden1",
  725.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  726.       },
  727.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  728.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  729.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  730.       :enter => {
  731.         :pos => {:start => [-340,-270], :end => [80,270], :speed => [5,9]},
  732.         :opa => {:start => 100, :end => 255, :speed => 2},
  733.         :zoom => {
  734.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  735.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  736.         },
  737.       },
  738.       :anim => {
  739.         :pos => {:move => [40,0], :speed => [2,1]},
  740.         :opa => {:start => 255, :end => 255, :speed => 1},
  741.         :zoom => {
  742.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  743.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  744.         },
  745.       },
  746.       :exit => {
  747.         :pos => {:start => [80,270], :end => [80,270], :speed => [5,1]},
  748.         :opa => {:start => 255, :end => 0, :speed => 15},
  749.         :zoom => {
  750.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  751.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  752.         },
  753.       },
  754.     }, # 9th command - Settings end!
  755.     9 => { # 10th command - Settings start!
  756.       :name => "Scrip 1",
  757.       :symbol => :script1,
  758.       :method => :do_the_script,
  759.       :extra => "$game_party.gain_gold(rand(3333));
  760.                 @gold_window.refresh;
  761.                 @command_window.activate",
  762.       :enable => true,
  763.       :show => true,
  764.       :z => 100,
  765.       :pic => {
  766.         :e => "Script 1", :d => "Script 1", :h => "Hidden1",
  767.         :anim => {:frames => [0,1,2,1,0,3,4,3], :wait => 6, :rows => 5},
  768.       },
  769.       :tone => {:a => [0,0,0,0], :i => [0,0,0,255], :speed => 10},
  770.       :blend => {:a => 0, :i => 1, :da => 2, :di => 2},
  771.       :flash => {:color => [255,255,0,200], :dur => 60, :wait => 180},
  772.       :enter => {
  773.         :pos => {:start => [-370,-300], :end => [80,300], :speed => [5,10]},
  774.         :opa => {:start => 100, :end => 255, :speed => 2},
  775.         :zoom => {
  776.           :x => {:start => 0.1, :end => 0.6, :speed => 0.1},
  777.           :y => {:start => 0.1, :end => 0.6, :speed => 0.1},
  778.         },
  779.       },
  780.       :anim => {
  781.         :pos => {:move => [40,0], :speed => [2,1]},
  782.         :opa => {:start => 255, :end => 255, :speed => 1},
  783.         :zoom => {
  784.           :x => {:start => 0.6, :end => 1.0, :speed => 0.02},
  785.           :y => {:start => 0.6, :end => 1.0, :speed => 0.02},
  786.         },
  787.       },
  788.       :exit => {
  789.         :pos => {:start => [80,300], :end => [80,300], :speed => [5,1]},
  790.         :opa => {:start => 255, :end => 0, :speed => 15},
  791.         :zoom => {
  792.           :x => {:start => 1.0, :end => 0.0, :speed => 0.05},
  793.           :y => {:start => 1.0, :end => 0.0, :speed => 0.05},
  794.         },
  795.       },
  796.     }, # 10th command - Settings end!
  797.    
  798.     # <-- Add more command setups here!
  799.    
  800.   } # <-- No touchy-touchy!
  801.  
  802. end
  803. #===============================================================================
  804. # End of Settings Part!
  805. # Editing below may lead to malfunctioning brain-cells! You have been warned!
  806. #===============================================================================
  807.  
  808. $imported = {} if $imported.nil?
  809. $imported["SixthAnimCommands"] = true
  810.  
  811. module Cache
  812.  
  813.   def self.menuhud(filename,folder)
  814.     load_bitmap(folder, filename)
  815.   end
  816.  
  817. end
  818.  
  819. class Scene_Base
  820.  
  821.   # This is needed for the exit animation, do not remove!
  822.   def exit_now
  823.     # Anti-crasher!
  824.   end
  825.  
  826. end
  827.  
  828. class SpriteCommands < Window_MenuCommand
  829.  
  830.   # The 'data' is the command button setup.
  831.   # The 'folder' is the image folder used for the sprites.
  832.   # This way you can add your own data and folder settings from your own
  833.   # custom scripts too, if needed!
  834.   def initialize(data,folder,selection)
  835.     @data = data; @folder = folder; @esel = selection[:eselect]
  836.     @cols = selection[:max_col]; @horz = selection[:horizontal]
  837.     @entered = false; @flasher = 0
  838.     @animater = 0; @picid = 0; @prate = -1
  839.     super()
  840.     deactivate unless @esel
  841.     self.hide # No need for windows!
  842.   end
  843.  
  844.   def window_width
  845.     1 # The smaller, the better!
  846.   end
  847.  
  848.   def window_height
  849.     1 # The smaller, the better!
  850.   end
  851.    
  852.   def col_max
  853.     return @cols ? @cols : super
  854.   end
  855.  
  856.   def horizontal?
  857.     return @horz ? @horz : super
  858.   end
  859.  
  860.   # Setting correct animation phases for the sprites here!
  861.   # Also ensuring that the flashing of the command sprite will happen after
  862.   # it's activation animation, and that the picture animation resets.
  863.   def select(index)
  864.     if index
  865.       if current_symbol && @entered
  866.         @cpics_state[current_symbol] = :inactive
  867.         @cpics[current_symbol].src_rect.y = 0
  868.       end
  869.       super
  870.       if current_symbol && @entered
  871.         info = @data.find {|key,item| item[:symbol] == current_symbol }
  872.         info = info[1]
  873.         if !info[:pic][:anim].nil?
  874.           @prate = info[:pic][:anim][:wait]
  875.           @pframes = info[:pic][:anim][:frames]
  876.           @cpics[current_symbol].src_rect.y = 0
  877.           @animater = 0; @picid = 0
  878.         else
  879.           @prate = -1
  880.           @pframes = -1
  881.         end
  882.         @flasher = 999999
  883.         @cpics_state[current_symbol] = :active
  884.       end
  885.     end
  886.   end
  887.    
  888.   def cursor_pagedown
  889.     # Since the width and height is 1, this must be rewritten to avoid weird
  890.     # behaviors. I have set it so it always selects the last command.
  891.     select(item_max-1) if index != item_max-1
  892.   end
  893.  
  894.   def cursor_pageup
  895.     # Since the width and height is 1, this must be rewritten to avoid weird
  896.     # behaviors. I have set it so it always selects th first command.
  897.     select(0) if index != 0
  898.   end
  899.  
  900.   def update
  901.     super
  902.     do_sprite_anim
  903.     check_enter_exit_state
  904.   end
  905.    
  906.   def update_cursor
  907.     # No need for this so I might as well disable it, right?
  908.   end
  909.  
  910.   def start_exit_anim
  911.     select(-1) # Unselect any active command!
  912.     # Wait until all commands are at their initial position!
  913.     until @cpics_state.all? {|sym,dt| dt == :idle }
  914.       Graphics.update
  915.       do_sprite_anim
  916.     end
  917.     @cpics_state.each do |sym,state| # Start the exit animation!
  918.       @cpics_state[sym] = :exit
  919.     end
  920.   end
  921.  
  922.   def check_enter_exit_state
  923.     # Activate the window IF the entering animation is finished!
  924.     if @cpics_state.all? {|sym,dt| dt != :enter } && !@entered
  925.       @entered = true
  926.       if @esel
  927.         info = @data.find {|key,item| item[:symbol] == current_symbol }
  928.         if !info.nil?
  929.           info = info[1]
  930.           if !info[:pic][:anim].nil?
  931.             @prate = info[:pic][:anim][:wait]
  932.             @pframes = info[:pic][:anim][:frames]
  933.             @cpics[current_symbol].src_rect.y = 0
  934.             @animater = 0; @picid = 0
  935.           else
  936.             @prate = -1
  937.             @pframes = -1
  938.           end
  939.           @flasher = 999999
  940.           @cpics_state[current_symbol] = :active
  941.         end
  942.       else
  943.         activate; select_last
  944.       end
  945.     end
  946.     # Exit the scene IF the exit animation is finished!
  947.     if @cpics_state.all? {|sym,dt| dt == :exit_now }
  948.       SceneManager.scene.exit_now
  949.     end
  950.   end
  951.  
  952.   # Update picture animation if applicable!
  953.   def do_pic_anim
  954.     if current_symbol && @cpics_state[current_symbol] == :idle && @entered
  955.       return if @prate == -1
  956.       @animater += 1
  957.       if @animater % @prate == 0
  958.         @picid += 1
  959.         patt = @pframes[@picid % @pframes.size]
  960.         @cpics[current_symbol].src_rect.y = patt*@cpics[current_symbol].src_rect.height
  961.       end
  962.     end
  963.   end
  964.  
  965.   # Update periodical flashing if applicable!
  966.   def do_flash_anim
  967.     if current_symbol && @cpics_state[current_symbol] == :idle && @entered
  968.       info = @data.find {|key,item| item[:symbol] == current_symbol }
  969.       info = info[1]
  970.       return if info[:flash].nil?
  971.       if @flasher > info[:flash][:wait]
  972.         @flasher = 0
  973.         @cpics[current_symbol].flash(Color.new(*info[:flash][:color]),info[:flash][:dur])
  974.       end
  975.       @flasher += 1
  976.     end
  977.   end
  978.  
  979.   # Update any animation and command button sprites!
  980.   def do_sprite_anim
  981.     @cpics.each do |sym,sprite|
  982.       case @cpics_state[sym]
  983.       when :enter
  984.         do_inout_anim(sym,sprite,:enter)
  985.       when :active
  986.         do_activation_anim(sym,sprite) if @cpics_state[sym] != :exit
  987.       when :inactive
  988.         do_deactivation_anim(sym,sprite) if @cpics_state[sym] != :exit
  989.       when :exit
  990.         do_inout_anim(sym,sprite,:exit)
  991.       end
  992.       sprite.update
  993.     end
  994.     do_pic_anim
  995.     do_flash_anim
  996.   end
  997.  
  998.   # The entering and exiting animation logic!
  999.   def do_inout_anim(sym,sprite,type)
  1000.     info = @data.find {|key,item| item[:symbol] == sym }
  1001.     info = info[1]
  1002.     info[type] = {} if info[type].nil?
  1003.     return @cpics_state[sym] = :exit_now if info[type].nil? && type == :exit
  1004.     # Moving on X axis:
  1005.     if info[type][:pos] && sprite.x != info[type][:pos][:end][0]
  1006.       if info[type][:pos][:start][0] < info[type][:pos][:end][0]
  1007.         sprite.x += info[type][:pos][:speed][0]
  1008.         sprite.x = [sprite.x,info[type][:pos][:end][0]].min
  1009.       elsif info[type][:pos][:start][0] > info[type][:pos][:end][0]
  1010.         sprite.x -= info[type][:pos][:speed][0]
  1011.         sprite.x = [sprite.x,info[type][:pos][:end][0]].max
  1012.       end
  1013.     else
  1014.       x_move_end = true
  1015.     end
  1016.     # Moving on Y axis:
  1017.     if info[type][:pos] && sprite.y != info[type][:pos][:end][1]
  1018.       if info[type][:pos][:start][1] < info[type][:pos][:end][1]
  1019.         sprite.y += info[type][:pos][:speed][1]
  1020.         sprite.y = [sprite.y,info[type][:pos][:end][1]].min
  1021.       elsif info[type][:pos][:start][1] > info[type][:pos][:end][1]
  1022.         sprite.y -= info[type][:pos][:speed][1]
  1023.         sprite.y = [sprite.y,info[type][:pos][:end][1]].max
  1024.       end
  1025.     else
  1026.       y_move_end = true
  1027.     end
  1028.     # Setting opacity :
  1029.     if info[type][:opa] && sprite.opacity != info[type][:opa][:end]
  1030.       if info[type][:opa][:start] < info[type][:opa][:end]
  1031.         sprite.opacity += info[type][:opa][:speed]
  1032.         sprite.opacity = [sprite.opacity,info[type][:opa][:end]].min
  1033.       elsif info[type][:opa][:start] > info[type][:opa][:end]
  1034.         sprite.opacity -= info[type][:opa][:speed]
  1035.         sprite.opacity = [sprite.opacity,info[type][:opa][:end]].max
  1036.       end
  1037.     else
  1038.       opa_end = true
  1039.     end
  1040.     # Setting zoom_x :
  1041.     if info[type][:zoom] && info[type][:zoom][:x] && sprite.zoom_x != info[type][:zoom][:x][:end]
  1042.       if info[type][:zoom][:x][:start] < info[type][:zoom][:x][:end]
  1043.         sprite.zoom_x += info[type][:zoom][:x][:speed]
  1044.         sprite.zoom_x = [sprite.zoom_x,info[type][:zoom][:x][:end]].min
  1045.       elsif info[type][:zoom][:x][:start] > info[type][:zoom][:x][:end]
  1046.         sprite.zoom_x -= info[type][:zoom][:x][:speed]
  1047.         sprite.zoom_x = [sprite.zoom_x,info[type][:zoom][:x][:end]].max
  1048.       end
  1049.     else
  1050.       zoom_x_end = true
  1051.     end
  1052.     # Setting zoom_y :
  1053.     if info[type][:zoom] && info[type][:zoom][:y] && sprite.zoom_y != info[type][:zoom][:y][:end]
  1054.       if info[type][:zoom][:y][:start] < info[type][:zoom][:y][:end]
  1055.         sprite.zoom_y += info[type][:zoom][:y][:speed]
  1056.         sprite.zoom_y = [sprite.zoom_y,info[type][:zoom][:y][:end]].min
  1057.       elsif info[type][:zoom][:y][:start] > info[type][:zoom][:y][:end]
  1058.         sprite.zoom_y -= info[type][:zoom][:y][:speed]
  1059.         sprite.zoom_y = [sprite.zoom_y,info[type][:zoom][:y][:end]].max
  1060.       end
  1061.     else
  1062.       zoom_y_end = true
  1063.     end
  1064.     # Checking if entering/exiting animation is finished:
  1065.     if [x_move_end,y_move_end,opa_end,zoom_x_end,zoom_y_end].all? {|dt| !dt.nil? && dt == true}
  1066.       case type
  1067.       when :enter
  1068.         @cpics_state[sym] = :idle
  1069.       when :exit
  1070.         SceneManager.scene.exit_now
  1071.       end
  1072.     end
  1073.   end
  1074.    
  1075.   # The activation animation logic!
  1076.   def do_activation_anim(sym,sprite) # activation animation
  1077.     info = @data.find {|key,item| item[:symbol] == sym }
  1078.     info = info[1]
  1079.     info[:anim] = {} if info[:anim].nil?
  1080.     # Setting correct blending mode:
  1081.     ss = check_cmd?(info[:enable]) ? :a : :da
  1082.     if info[:blend] && sprite.blend_type != info[:blend][ss]
  1083.       sprite.blend_type = info[:blend][ss]
  1084.     end
  1085.     # Adjusting X pos:
  1086.     if info[:anim][:pos] && sprite.x != info[:enter][:pos][:end][0] + info[:anim][:pos][:move][0]
  1087.       if info[:anim][:pos][:move][0] > 0
  1088.         sprite.x += info[:anim][:pos][:speed][0]
  1089.         sprite.x = [sprite.x,info[:enter][:pos][:end][0] + info[:anim][:pos][:move][0]].min
  1090.       elsif info[:anim][:pos][:move][0] < 0
  1091.         sprite.x -= info[:anim][:pos][:speed][0]
  1092.         sprite.x = [sprite.x,info[:enter][:pos][:end][0] + info[:anim][:pos][:move][0]].max
  1093.       end
  1094.     else
  1095.       x_move_end = true
  1096.     end
  1097.     # Adjusting Y pos:
  1098.     if info[:anim][:pos] && sprite.y != info[:enter][:pos][:end][1] + info[:anim][:pos][:move][1]
  1099.       if info[:anim][:pos][:move][1] > 0
  1100.         sprite.y += info[:anim][:pos][:speed][1]
  1101.         sprite.y = [sprite.y,info[:enter][:pos][:end][1] + info[:anim][:pos][:move][1]].min
  1102.       elsif info[:anim][:pos][:move][1] < 0
  1103.         sprite.y -= info[:anim][:pos][:speed][1]
  1104.         sprite.y = [sprite.y,info[:enter][:pos][:end][1] + info[:anim][:pos][:move][1]].max
  1105.       end
  1106.     else
  1107.       y_move_end = true
  1108.     end
  1109.     # Adjusting opacity:
  1110.     if info[:anim][:opa] && sprite.opacity != info[:anim][:opa][:end]
  1111.       if info[:anim][:opa][:start] < info[:anim][:opa][:end]
  1112.         sprite.opacity += info[:anim][:opa][:speed]
  1113.         sprite.opacity = [sprite.opacity,info[:anim][:opa][:end]].min
  1114.       elsif info[:anim][:opa][:start] > info[:anim][:opa][:end]
  1115.         sprite.opacity -= info[:anim][:opa][:speed]
  1116.         sprite.opacity = [sprite.opacity,info[:anim][:opa][:end]].max
  1117.       end
  1118.     else
  1119.       opa_end = true
  1120.     end
  1121.     # Setting zoom_x :
  1122.     if info[:anim][:zoom] && info[:anim][:zoom][:x] && sprite.zoom_x != info[:anim][:zoom][:x][:end]
  1123.       if info[:anim][:zoom][:x][:start] < info[:anim][:zoom][:x][:end]
  1124.         sprite.zoom_x += info[:anim][:zoom][:x][:speed]
  1125.         sprite.zoom_x = [sprite.zoom_x,info[:anim][:zoom][:x][:end]].min
  1126.       elsif info[:anim][:zoom][:x][:start] > info[:anim][:zoom][:x][:end]
  1127.         sprite.zoom_x -= info[:anim][:zoom][:x][:speed]
  1128.         sprite.zoom_x = [sprite.zoom_x,info[:anim][:zoom][:x][:end]].max
  1129.       end
  1130.     else
  1131.       zoom_x_end = true
  1132.     end
  1133.     # Setting zoom_y :
  1134.     if info[:anim][:zoom] && info[:anim][:zoom][:y] && sprite.zoom_y != info[:anim][:zoom][:y][:end]
  1135.       if info[:anim][:zoom][:y][:start] < info[:anim][:zoom][:y][:end]
  1136.         sprite.zoom_y += info[:anim][:zoom][:y][:speed]
  1137.         sprite.zoom_y = [sprite.zoom_y,info[:anim][:zoom][:y][:end]].min
  1138.       elsif info[:anim][:zoom][:y][:start] > info[:anim][:zoom][:y][:end]
  1139.         sprite.zoom_y -= info[:anim][:zoom][:y][:speed]
  1140.         sprite.zoom_y = [sprite.zoom_y,info[:anim][:zoom][:y][:end]].max
  1141.       end
  1142.     else
  1143.       zoom_y_end = true
  1144.     end
  1145.     # Setting red tone:
  1146.     if info[:tone] && sprite.tone.red != info[:tone][:a][0]
  1147.       if info[:tone][:a][0] > info[:tone][:i][0]
  1148.         sprite.tone.red += info[:tone][:speed]
  1149.         sprite.tone.red = [sprite.tone.red,info[:tone][:a][0]].min
  1150.       elsif info[:tone][:a][0] < info[:tone][:i][0]
  1151.         sprite.tone.red -= info[:tone][:speed]
  1152.         sprite.tone.red = [sprite.tone.red,info[:tone][:a][0]].max
  1153.       end
  1154.     else
  1155.       r_done = true
  1156.     end
  1157.     # Setting green tone:
  1158.     if info[:tone] && sprite.tone.green != info[:tone][:a][1]
  1159.       if info[:tone][:a][1] > info[:tone][:i][1]
  1160.         sprite.tone.green += info[:tone][:speed]
  1161.         sprite.tone.green = [sprite.tone.green,info[:tone][:a][1]].min
  1162.       elsif info[:tone][:a][1] < info[:tone][:i][1]
  1163.         sprite.tone.green -= info[:tone][:speed]
  1164.         sprite.tone.green = [sprite.tone.green,info[:tone][:a][1]].max
  1165.       end
  1166.     else
  1167.       g_done = true
  1168.     end
  1169.     # Setting blue tone:
  1170.     if info[:tone] && sprite.tone.blue != info[:tone][:a][2]
  1171.       if info[:tone][:a][2] > info[:tone][:i][2]
  1172.         sprite.tone.blue += info[:tone][:speed]
  1173.         sprite.tone.blue = [sprite.tone.blue,info[:tone][:a][2]].min
  1174.       elsif info[:tone][:a][2] < info[:tone][:i][2]
  1175.         sprite.tone.blue -= info[:tone][:speed]
  1176.         sprite.tone.blue = [sprite.tone.blue,info[:tone][:a][2]].max
  1177.       end
  1178.     else
  1179.       b_done = true
  1180.     end
  1181.     # Setting gray tone:
  1182.     if info[:tone] && sprite.tone.gray != info[:tone][:a][3]
  1183.       if info[:tone][:a][3] > info[:tone][:i][3]
  1184.         sprite.tone.gray += info[:tone][:speed]
  1185.         sprite.tone.gray = [sprite.tone.gray,info[:tone][:a][3]].min
  1186.       elsif info[:tone][:a][3] < info[:tone][:i][3]
  1187.         sprite.tone.gray -= info[:tone][:speed]
  1188.         sprite.tone.gray = [sprite.tone.gray,info[:tone][:a][3]].max
  1189.       end
  1190.     else
  1191.       gr_done = true
  1192.     end
  1193.     # Checking if activation animation is finished:
  1194.     if [x_move_end,y_move_end,opa_end,zoom_x_end,zoom_y_end,r_done,g_done,b_done,gr_done].all? {|dt| !dt.nil? && dt == true}
  1195.       @cpics_state[sym] = :idle
  1196.     end
  1197.   end
  1198.  
  1199.   # The deactivation animation logic!
  1200.   def do_deactivation_anim(sym,sprite) # deactivation animation
  1201.     info = @data.find {|key,item| item[:symbol] == sym }
  1202.     info = info[1]
  1203.     info[:anim] = {} if info[:anim].nil?
  1204.     # Setting correct blending mode:
  1205.     ss = check_cmd?(info[:enable]) ? :i : :di
  1206.     if info[:blend] && sprite.blend_type != info[:blend][ss]
  1207.       sprite.blend_type = info[:blend][ss]
  1208.     end
  1209.     # Adjusting X pos:
  1210.     if info[:anim][:pos] && sprite.x != info[:enter][:pos][:end][0]
  1211.       if info[:anim][:pos][:move][0] > 0
  1212.         sprite.x -= info[:anim][:pos][:speed][0]
  1213.         sprite.x = [sprite.x,info[:enter][:pos][:end][0]].max
  1214.       elsif info[:anim][:pos][:move][0] < 0
  1215.         sprite.x += info[:anim][:pos][:speed][0]
  1216.         sprite.x = [sprite.x,info[:enter][:pos][:end][0]].min
  1217.       end
  1218.     else
  1219.       x_move_end = true
  1220.     end
  1221.     # Adjusting Y pos:
  1222.     if info[:anim][:pos] && sprite.y != info[:enter][:pos][:end][1]
  1223.       if info[:anim][:pos][:move][1] > 0
  1224.         sprite.y -= info[:anim][:pos][:speed][1]
  1225.         sprite.y = [sprite.y,info[:enter][:pos][:end][1]].max
  1226.       elsif info[:anim][:pos][:move][1] < 0
  1227.         sprite.y += info[:anim][:pos][:speed][1]
  1228.         sprite.y = [sprite.y,info[:enter][:pos][:end][1]].min
  1229.       end
  1230.     else
  1231.       y_move_end = true
  1232.     end
  1233.     # Adjusting opacity:
  1234.     if info[:anim][:opa] && sprite.opacity != info[:anim][:opa][:start]
  1235.       if info[:anim][:opa][:start] < info[:anim][:opa][:end]
  1236.         sprite.opacity -= info[:anim][:opa][:speed]
  1237.         sprite.opacity = [sprite.opacity,info[:anim][:opa][:start]].max
  1238.       elsif info[:anim][:opa][:start] > info[:anim][:opa][:end]
  1239.         sprite.opacity += info[:anim][:opa][:speed]
  1240.         sprite.opacity = [sprite.opacity,info[:anim][:opa][:start]].min
  1241.       end
  1242.     else
  1243.       opa_end = true
  1244.     end
  1245.     # Setting zoom_x :
  1246.     if info[:anim][:zoom] && info[:anim][:zoom][:x] && sprite.zoom_x != info[:anim][:zoom][:x][:start]
  1247.       if info[:anim][:zoom][:x][:start] < info[:anim][:zoom][:x][:end]
  1248.         sprite.zoom_x -= info[:anim][:zoom][:x][:speed]
  1249.         sprite.zoom_x = [sprite.zoom_x,info[:anim][:zoom][:x][:start]].max
  1250.       elsif info[:anim][:zoom][:x][:start] > info[:anim][:zoom][:x][:end]
  1251.         sprite.zoom_x += info[:anim][:zoom][:x][:speed]
  1252.         sprite.zoom_x = [sprite.zoom_x,info[:anim][:zoom][:x][:start]].min
  1253.       end
  1254.     else
  1255.       zoom_x_end = true
  1256.     end
  1257.     # Setting zoom_y :
  1258.     if info[:anim][:zoom] && info[:anim][:zoom][:y] && sprite.zoom_y != info[:anim][:zoom][:y][:start]
  1259.       if info[:anim][:zoom][:y][:start] < info[:anim][:zoom][:y][:end]
  1260.         sprite.zoom_y -= info[:anim][:zoom][:y][:speed]
  1261.         sprite.zoom_y = [sprite.zoom_y,info[:anim][:zoom][:y][:start]].max
  1262.       elsif info[:anim][:zoom][:y][:start] > info[:anim][:zoom][:y][:end]
  1263.         sprite.zoom_y += info[:anim][:zoom][:y][:speed]
  1264.         sprite.zoom_y = [sprite.zoom_y,info[:anim][:zoom][:y][:start]].min
  1265.       end
  1266.     else
  1267.       zoom_y_end = true
  1268.     end
  1269.     # Setting red tone:
  1270.     if info[:tone] && sprite.tone.red != info[:tone][:i][0]
  1271.       if info[:tone][:i][0] > info[:tone][:a][0]
  1272.         sprite.tone.red += info[:tone][:speed]
  1273.         sprite.tone.red = [sprite.tone.red,info[:tone][:i][0]].min
  1274.       elsif info[:tone][:i][0] < info[:tone][:a][0]
  1275.         sprite.tone.red -= info[:tone][:speed]
  1276.         sprite.tone.red = [sprite.tone.red,info[:tone][:i][0]].max
  1277.       end
  1278.     else
  1279.       r_done = true
  1280.     end
  1281.     # Setting green tone:
  1282.     if info[:tone] && sprite.tone.green != info[:tone][:i][1]
  1283.       if info[:tone][:i][1] > info[:tone][:a][1]
  1284.         sprite.tone.green += info[:tone][:speed]
  1285.         sprite.tone.green = [sprite.tone.green,info[:tone][:i][1]].min
  1286.       elsif info[:tone][:i][1] < info[:tone][:a][1]
  1287.         sprite.tone.green -= info[:tone][:speed]
  1288.         sprite.tone.green = [sprite.tone.green,info[:tone][:i][1]].max
  1289.       end
  1290.     else
  1291.       g_done = true
  1292.     end
  1293.     # Setting blue tone:
  1294.     if info[:tone] && sprite.tone.blue != info[:tone][:i][2]
  1295.       if info[:tone][:i][2] > info[:tone][:a][2]
  1296.         sprite.tone.blue += info[:tone][:speed]
  1297.         sprite.tone.blue = [sprite.tone.blue,info[:tone][:i][2]].min
  1298.       elsif info[:tone][:i][2] < info[:tone][:a][2]
  1299.         sprite.tone.blue -= info[:tone][:speed]
  1300.         sprite.tone.blue = [sprite.tone.blue,info[:tone][:i][2]].max
  1301.       end
  1302.     else
  1303.       b_done = true
  1304.     end
  1305.     # Setting gray tone:
  1306.     if info[:tone] && sprite.tone.gray != info[:tone][:i][3]
  1307.       if info[:tone][:i][3] > info[:tone][:a][3]
  1308.         sprite.tone.gray += info[:tone][:speed]
  1309.         sprite.tone.gray = [sprite.tone.gray,info[:tone][:i][3]].min
  1310.       elsif info[:tone][:i][3] < info[:tone][:a][3]
  1311.         sprite.tone.gray -= info[:tone][:speed]
  1312.         sprite.tone.gray = [sprite.tone.gray,info[:tone][:i][3]].max
  1313.       end
  1314.     else
  1315.       gr_done = true
  1316.     end
  1317.     # Checking if deactivation animation is finished:
  1318.     if [x_move_end,y_move_end,opa_end,zoom_x_end,zoom_y_end,r_done,g_done,b_done,gr_done].all? {|dt| !dt.nil? && dt == true}
  1319.       @cpics_state[sym] = :idle
  1320.     end
  1321.   end
  1322.    
  1323.   # Making 'em commands and command sprites!
  1324.   def make_command_list
  1325.     @cpics = {} if @cpics.nil?; @cpics_state = {} if @cpics_state.nil?
  1326.     @data.each do |id,data|
  1327.       # Making the sprite if there is no sprite with the :symbol yet!
  1328.       if @cpics[data[:symbol]].nil?
  1329.         @cpics_state[data[:symbol]] = :enter
  1330.         if check_cmd?(data[:show]) && check_cmd?(data[:enable])
  1331.           pic = Cache.menuhud(data[:pic][:e],@folder)
  1332.         elsif check_cmd?(data[:show]) && !check_cmd?(data[:enable])
  1333.           pic = Cache.menuhud(data[:pic][:d],@folder)
  1334.         else
  1335.           pic = Cache.menuhud(data[:pic][:h],@folder)
  1336.         end
  1337.         @cpics[data[:symbol]] = Sprite.new
  1338.         @cpics[data[:symbol]].x = data[:enter][:pos][:start][0]
  1339.         @cpics[data[:symbol]].y = data[:enter][:pos][:start][1]
  1340.         @cpics[data[:symbol]].z = data[:z]
  1341.         @cpics[data[:symbol]].opacity = data[:enter][:opa][:start]
  1342.         @cpics[data[:symbol]].zoom_x = data[:enter][:zoom][:x][:start]
  1343.         @cpics[data[:symbol]].zoom_y = data[:enter][:zoom][:y][:start]
  1344.         @cpics[data[:symbol]].tone = Tone.new(*data[:tone][:i])
  1345.         @cpics[data[:symbol]].bitmap = pic
  1346.         row = data[:pic][:anim] ? data[:pic][:anim][:rows] : 1
  1347.         height = @cpics[data[:symbol]].bitmap.height/row
  1348.         @cpics[data[:symbol]].src_rect.height = height
  1349.         @cpics[data[:symbol]].ox = @cpics[data[:symbol]].bitmap.width/2
  1350.         @cpics[data[:symbol]].oy = height/2
  1351.         bl = check_cmd?(data[:enable]) ? data[:blend][:i] : data[:blend][:di]
  1352.         @cpics[data[:symbol]].blend_type = bl
  1353.       end
  1354.       next unless check_cmd?(data[:show])
  1355.       # Adding the commands:
  1356.       add_command(data[:name],data[:symbol],check_cmd?(data[:enable]),data[:extra])
  1357.     end
  1358.   end
  1359.  
  1360.   # Checking method for enable and show states!
  1361.   def check_cmd?(data)
  1362.     case data
  1363.     when Integer
  1364.       return $game_switches[data]
  1365.     when Symbol
  1366.       return method(data).call
  1367.     when String
  1368.       return eval(data)
  1369.     else
  1370.       return data
  1371.     end
  1372.   end
  1373.  
  1374.   # Disposing the command sprites!
  1375.   def dispose_cmd_pics
  1376.     @cpics.each_value do |sprite|
  1377.       sprite.bitmap.dispose
  1378.       sprite.dispose
  1379.     end
  1380.   end
  1381.  
  1382.   def dispose
  1383.     dispose_cmd_pics
  1384.     super
  1385.   end
  1386.  
  1387.   # Correcting this method now!
  1388.   def select_last
  1389.     select_symbol(@@last_command_symbol) if !@@last_command_symbol.nil?
  1390.     select(0) if @@last_command_symbol.nil?
  1391.   end
  1392.  
  1393. end
  1394.  
  1395. class Window_MenuStatus < Window_Selectable
  1396.  
  1397.   def window_width
  1398.     MCommands::StatusWindow[:size][0]
  1399.   end
  1400.  
  1401.   def window_height
  1402.     MCommands::StatusWindow[:size][1]
  1403.   end
  1404.  
  1405. end
  1406.  
  1407. class Scene_Menu < Scene_MenuBase
  1408.  
  1409.   # Remaking the command window and setting correct handlers!
  1410.   # NOTE: The cancel handler has been changed!
  1411.   def create_command_window
  1412.     @command_window = SpriteCommands.new(MCommands::Commands,
  1413.                               MCommands::ImgFolder[:main],MCommands::Selection)
  1414.     MCommands::Commands.each do |id,data|
  1415.       @command_window.set_handler(data[:symbol],method(data[:method]))
  1416.     end
  1417.     @command_window.set_handler(:cancel,method(:init_exiting))
  1418.   end
  1419.  
  1420.   # Duhh...
  1421.   def create_status_window
  1422.     pos = MCommands::StatusWindow[:pos]
  1423.     @status_window = Window_MenuStatus.new(pos[0],pos[1])
  1424.     @status_window.opacity = MCommands::StatusWindow[:opa]
  1425.   end
  1426.  
  1427.   # Executing the script command if any!
  1428.   def do_the_script
  1429.     data = @command_window.current_ext
  1430.     if !data.nil? && data.is_a?(String)
  1431.       eval(data)
  1432.     else
  1433.       @command_window.activate
  1434.     end
  1435.   end
  1436.  
  1437.   # Executing the common event command if any!
  1438.   def do_the_event
  1439.     data = @command_window.current_ext
  1440.     if !data.nil? && data.is_a?(Integer)
  1441.       $game_temp.reserve_common_event(data)
  1442.       init_exiting
  1443.     else
  1444.       @command_window.activate
  1445.     end
  1446.   end
  1447.  
  1448.   # The new :cancel handler!
  1449.   # This initiates the exiting animation for the command window.
  1450.   def init_exiting
  1451.     @command_window.start_exit_anim
  1452.   end
  1453.  
  1454.   # This gets executed after the exiting animation is finished to exit the
  1455.   # scene for real.
  1456.   def exit_now
  1457.     if $game_temp.common_event_reserved?
  1458.       SceneManager.goto(Scene_Map)
  1459.     else
  1460.       return_scene
  1461.     end
  1462.   end
  1463.  
  1464. end
  1465. #==============================================================================
  1466. # !!END OF SCRIPT!!
  1467. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement