Advertisement
TheSixth

Benji01's Addons by Sixth

Feb 25th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.87 KB | None | 0 0
  1. # Made by: Sixth
  2.  
  3. module AddCommsS
  4.  
  5.   # Settings for the command button on the skill menu
  6.   #
  7.   # :name = the text displayed for the button
  8.   # :enable = The enable condition of the button
  9.   # :show = The show condition of the button
  10.   #
  11.   # The :enable and :show settings can be:
  12.   # - true/false = true sets it to be always enabled, false will never be enabled
  13.   # - integer number = This would tie a switch for the button. If that switch
  14.   #                    is ON, the command is enabled, otherwise it is disanled.
  15.   # - :symbol = This would call the method named like the symbol.
  16.   #             The method needs to be defined in the Window_SkillCommand class,
  17.   #             and it must return true or false.
  18.   # - "string" = The string will be evaluated as a ruby code.
  19.   #              The code must return true or false.
  20.   SkillAdd = {
  21.     :name => "Tools", :enable => true, :show => true,
  22.   }
  23.  
  24.   # Setting for the new button on the options scene.
  25.   #
  26.   # The :name, :enable and :show settings are the same as above.
  27.   #
  28.   # :help1 = Text shown above the button
  29.   # :help2 = Text shown in the help window on the top of the screen
  30.   # :img = The image shown when the command is selected
  31.   # :pos = The X and Y position for the image shown
  32.   # :z = The Z value for the image shown
  33.   # :opa = The opacity value for the image shown
  34.   SettingAdd = {
  35.     :name => "Controls", :enable => true, :show => true,
  36.     :help1 => "Check the controls",
  37.     :help2 => "Hit the confirm button to check the controls!",
  38.     :img => "controls", :pos => [0,0], :z => 2000, :opa => 255,
  39.   }
  40.  
  41. end
  42. # End of settings! o.o
  43.  
  44. class Window_SkillCommand < Window_Command
  45.  
  46.   alias add_common_evs8863 make_command_list
  47.   def make_command_list
  48.     add_commevs if SceneManager.scene_is?(Scene_Skill)
  49.     add_common_evs8863 if check_cmd(AddCommsS::SkillAdd,:show)
  50.   end
  51.  
  52.   def add_commevs
  53.     return unless @actor
  54.     dt = AddCommsS::SkillAdd
  55.     add_command(dt[:name],:tools,check_cmd(dt,:enable))
  56.   end
  57.    
  58.   def check_cmd(dt,type)
  59.     case dt[type]
  60.     when Integer
  61.       return $game_switches[dt[type]]
  62.     when Symbol
  63.       return method(dt[type]).call
  64.     when String
  65.       return eval(dt[type])
  66.     else
  67.       return dt[type]
  68.     end
  69.   end
  70.  
  71. end
  72.  
  73. class Scene_Skill < Scene_ItemBase
  74.  
  75.   alias add_cmnev_method8864 create_command_window
  76.   def create_command_window
  77.     add_cmnev_method8864
  78.     @command_window.set_handler(:tools, method(:call_tool_scene))
  79.   end
  80.  
  81.   def call_tool_scene
  82.     SceneManager.call(Scene_QuickTool)
  83.   end
  84.  
  85. end
  86.  
  87. class Scene_Options < Scene_MenuBase
  88.  
  89.   alias add_cmnev8864 create_message_se_window
  90.   def create_message_se_window
  91.     add_cmnev8864
  92.     create_controls_win if check_cmd(AddCommsS::SettingAdd,:show)
  93.   end
  94.  
  95.   def create_controls_win
  96.     @controlwin = Window_CmnEv.new(48+24 * @current_index)
  97.     @controlwin.set_handler(:ok, method(:show_img))
  98.     @back_window.add_text(24 * (@current_index - 1),AddCommsS::SettingAdd[:help1])
  99.     @current_index += 2
  100.     @size += 1
  101.     @window_index.push(:control_img)
  102.   end
  103.    
  104.   def show_img
  105.     @controlwin.deactivate
  106.     img = Sprite.new
  107.     img.bitmap = Cache.picture(AddCommsS::SettingAdd[:img])
  108.     img.x = AddCommsS::SettingAdd[:pos][0]
  109.     img.y = AddCommsS::SettingAdd[:pos][1]
  110.     img.z = AddCommsS::SettingAdd[:z]
  111.     img.opacity = AddCommsS::SettingAdd[:opa]
  112.     until Input.trigger?(:C)
  113.       Input.update
  114.       Graphics.update
  115.     end
  116.     Sound.play_ok
  117.     img.bitmap.dispose
  118.     img.dispose
  119.     @controlwin.activate
  120.   end
  121.    
  122.   alias add_contrimg8864 activate_window
  123.   def activate_window(index)
  124.     add_contrimg8864(index)
  125.     case @window_index[index]
  126.     when :control_img
  127.       @controlwin.select(0)
  128.       @controlwin.activate
  129.       @help_window.set_text(AddCommsS::SettingAdd[:help2])
  130.     end
  131.   end
  132.  
  133.   alias add_contrimg4464 deactivate_window
  134.   def deactivate_window(index)
  135.     add_contrimg4464(index)
  136.     case @window_index[index]
  137.     when :control_img
  138.       @controlwin.select(-1)
  139.       @controlwin.deactivate
  140.     end
  141.   end
  142.    
  143.   def check_cmd(dt,type)
  144.     case dt[type]
  145.     when Integer
  146.       return $game_switches[dt[type]]
  147.     when Symbol
  148.       return method(dt[type]).call
  149.     when String
  150.       return eval(dt[type])
  151.     else
  152.       return dt[type]
  153.     end
  154.   end
  155.  
  156. end
  157.  
  158. class Window_CmnEv < Window_Command
  159.  
  160.   def initialize(y)
  161.     super(24,y)
  162.     self.opacity = 0
  163.     select(-1)
  164.     deactivate
  165.   end
  166.  
  167.   def make_command_list
  168.     name = AddCommsS::SettingAdd[:name]
  169.     add_command(name,:ok,check_cmd(AddCommsS::SettingAdd,:enable))
  170.   end
  171.    
  172.   def check_cmd(dt,type)
  173.     case dt[type]
  174.     when Integer
  175.       return $game_switches[dt[type]]
  176.     when Symbol
  177.       return method(dt[type]).call
  178.     when String
  179.       return eval(dt[type])
  180.     else
  181.       return dt[type]
  182.     end
  183.   end
  184.  
  185. end
  186. # End of script! o.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement