Advertisement
Kakakadafi

[Overwrite] Options menu!

Oct 20th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.61 KB | None | 0 0
  1. #Basic Options Menu v1.4
  2. #----------#
  3. #Features: Provides a simple option menu for the player to do optiony stuff...
  4. #           Like volume effects for all, bgm, and se's. Fancy!
  5. #        
  6. #          Also additional options if you have Basic Window Resizer,
  7. #           Basic Message SE, and Basic Autosave.
  8. #
  9. #Usage:    Plug and play unless you want a bit more. Customization below.
  10. #
  11. #----------#
  12. #-- Script by: V.M of D.T Modified by Yin
  13. #
  14. #- Questions or comments can be:
  15. #    posted on the thread for the script
  16. #    given by email: sumptuaryspade@live.ca
  17. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  18. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  19. #
  20. #- Free to use in any project with credit given, donations always welcome!
  21.  
  22. #This lets you set the order of the windows via an array
  23. WINDOW_ORDER = [:input, :master, :bgm, :se, :resolution, :message_se]
  24. #Basic options are:
  25. #  :master - Master Volume               :bgm     - Background Music Volume
  26. #  :se     - Sound Effect Volume         :switch  - Allow the player to turn on/off a switch or global variable
  27. #
  28. #-- Additional Options are:
  29. #  :resolution     -   If you have Basic Window Resizer installed
  30. #  :message_se     -   If you have Basic Message SE installed
  31. #  :autosave       -   If you have Basic Autosave installed
  32.  
  33. #These are all the strings for the help window and headers:
  34. module OPT_STR
  35.   #When the command window is selected
  36.   COMMAND_HELP       = "Confirm and exit or simply exit"
  37.   #Details for :master
  38.   MASTER_VOLUME      = "Master Volume"
  39.   MASTER_VOLUME_HELP = "Set the volume of all sound"
  40.   #Details for :bgm
  41.   BGM_VOLUME         = "BGM Volume"
  42.   BGM_VOLUME_HELP    = "Set the volume of music"
  43.   #Details for :se
  44.   SE_VOLUME          = "SE Volume"
  45.   SE_VOLUME_HELP     = "Set the volume of sound effects"
  46.   #Details for :resolution
  47.   RESOLUTION         = "Resolution"
  48.   RESOLUTION_HELP    = "Change the resolution of the game window"
  49.   #Details for :autosave
  50.   AUTOSAVE           = "Autosave"
  51.   AUTOSAVE_HELP      = "Enable/Disable autosaving"
  52.   #Details for :message
  53.   MESSAGE_SE         = "Message SE"
  54.   MESSAGE_SE_HELP    = "Enable/Disable the message sound effect"
  55.   #Details for :input
  56.   INPUT              = "Controller Configuration"
  57.   INPUT_HELP         = "Change button configuration for controller"
  58.   #Details for :switch
  59.   SWITCH_DETAIL      = "$game_switches[5]"
  60.   SWITCH             = "Header"
  61.   SWITCH_HELP        = "Help Message"
  62.   SWITCH_COMMAND     = ["On","Off"]
  63. end
  64.  
  65. class Scene_Options < Scene_MenuBase
  66.   def start
  67.     super
  68.     $game_options.memorize_options
  69.     create_base_windows
  70.     @current_index = 1
  71.     @window_index = []
  72.     @size = 0
  73.     WINDOW_ORDER.each do |symbol|
  74.       create_resolution_window if symbol == :resolution
  75.       create_input_window      if symbol == :input
  76.       create_autosave_window   if symbol == :autosave
  77.       create_master_window     if symbol == :master
  78.       create_bgm_window        if symbol == :bgm
  79.       create_se_window         if symbol == :se
  80.       create_message_se_window if symbol == :message_se
  81.       create_window_switch     if symbol == :switch
  82.     end
  83.     create_command_window
  84.     @index = 0
  85.     @old_index = @index
  86.     activate_window(0)
  87.   end
  88.   def create_base_windows
  89.     @help_window = Window_Help.new(1)
  90.     @help_window.set_text("Options")
  91.     @back_window = Window_Options.new
  92.     @back_window.height = (WINDOW_ORDER.size + 1)* 48 + 24
  93.     @back_window.create_contents
  94.   end
  95.   def create_command_window
  96.     @window_command = Window_OCommand.new(48+24 * @current_index)
  97.     @window_command.set_handler(:ok, method(:command_ok))
  98.     @window_index.push(:command)
  99.     @back_window.draw_line(24 * (@current_index - 1))
  100.   end
  101.   def create_resolution_window
  102.     @window_resolution = Window_OR.new(48+24 * @current_index)
  103.     @window_resolution.set_handler(:ok, method(:resolution_ok))
  104.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::RESOLUTION)
  105.     @current_index += 2
  106.     @size += 1
  107.     @window_index.push(:resolution)
  108.   end
  109.   def create_input_window
  110.     @window_input = Window_OI.new(48+24 * @current_index)
  111.     @window_input.set_handler(:ok, method(:input_ok))
  112.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::INPUT)
  113.     @current_index += 2
  114.     @size += 1
  115.     @window_index.push(:input)
  116.   end
  117.   def create_autosave_window
  118.     if Module.const_defined?(:AUTOSAVE_FILE_NAME)
  119.       @window_autosave = Window_OAS.new(48+24 * @current_index)
  120.       @window_autosave.set_handler(:ok, method(:autosave_ok))
  121.       @back_window.add_text(24 * (@current_index - 1),OPT_STR::AUTOSAVE)
  122.       @current_index += 2
  123.       @size += 1
  124.       @window_index.push(:autosave)
  125.     end
  126.   end
  127.   def create_master_window
  128.     @window_masterbar = Window_OBar.new(48+24 * @current_index)
  129.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::MASTER_VOLUME)
  130.     @current_index += 2
  131.     @size += 1
  132.     @window_masterbar.refresh($game_options.master_volume)
  133.     @window_index.push(:master)
  134.   end
  135.   def create_bgm_window
  136.     @window_bgmbar = Window_OBar.new(48+24 * @current_index)
  137.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::BGM_VOLUME)
  138.     @current_index += 2
  139.     @size += 1
  140.     @window_bgmbar.refresh($game_options.bgm_volume)
  141.     @window_index.push(:bgm)
  142.   end
  143.   def create_se_window
  144.     @window_sebar = Window_OBar.new(48+24*@current_index)
  145.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::SE_VOLUME)
  146.     @current_index += 2
  147.     @size += 1
  148.     @window_sebar.refresh($game_options.se_volume)
  149.     @window_index.push(:se)
  150.   end
  151.   def create_message_se_window
  152.     if Window_Message.const_defined?(:DEFAULT_SE_FREQ)
  153.       @window_message = Window_OMSE.new(48+24 * @current_index)
  154.       @window_message.set_handler(:ok, method(:message_ok))
  155.       @back_window.add_text(24 * (@current_index - 1),OPT_STR::MESSAGE_SE)
  156.       @current_index += 2
  157.       @size += 1
  158.       @window_index.push(:message)
  159.     end
  160.   end
  161.   def create_window_switch
  162.     @window_switch = Window_OSW.new(48+24 * @current_index)
  163.     @window_switch.set_handler(:ok, method(:switch_ok))
  164.     @back_window.add_text(24 * (@current_index - 1),OPT_STR::SWITCH)
  165.     @current_index += 2
  166.     @size += 1
  167.     @window_index.push(:switch)
  168.   end
  169.   def activate_window(index)
  170.     case @window_index[index]
  171.     when :resolution
  172.       @window_resolution.select(0)
  173.       @window_resolution.activate
  174.       @help_window.set_text(OPT_STR::RESOLUTION_HELP)
  175.     when :input
  176.       @window_input.select(0)
  177.       @window_input.activate
  178.       @help_window.set_text(OPT_STR::INPUT_HELP)
  179.     when :autosave
  180.       @window_autosave.select(0)
  181.       @window_autosave.activate
  182.       @help_window.set_text(OPT_STR::AUTOSAVE_HELP)
  183.     when :master
  184.       @window_masterbar.select(0)
  185.       @window_masterbar.activate
  186.       @help_window.set_text(OPT_STR::MASTER_VOLUME_HELP)
  187.     when :bgm
  188.       @window_bgmbar.select(0)
  189.       @window_bgmbar.activate
  190.       @help_window.set_text(OPT_STR::BGM_VOLUME_HELP)
  191.     when :se
  192.       @window_sebar.select(0)
  193.       @window_sebar.activate
  194.       @help_window.set_text(OPT_STR::SE_VOLUME_HELP)
  195.     when :message
  196.       @window_message.select(0)
  197.       @window_message.activate
  198.       @help_window.set_text(OPT_STR::MESSAGE_SE_HELP)
  199.     when :command
  200.       @window_command.select(0)
  201.       @window_command.activate
  202.       @help_window.set_text(OPT_STR::COMMAND_HELP)
  203.     when :switch
  204.       @window_switch.select(0)
  205.       @window_switch.activate
  206.       @help_window.set_text(OPT_STR::SWITCH_HELP)
  207.     end
  208.   end
  209.   def deactivate_window(index)
  210.     case @window_index[index]
  211.     when :resolution
  212.       @window_resolution.select(-1)
  213.       @window_resolution.deactivate
  214.     when :input
  215.       @window_input.select(-1)
  216.       @window_input.deactivate
  217.     when :autosave
  218.       @window_autosave.select(-1)
  219.       @window_autosave.deactivate
  220.     when :master
  221.       @window_masterbar.select(-1)
  222.       @window_masterbar.deactivate
  223.     when :bgm
  224.       @window_bgmbar.select(-1)
  225.       @window_bgmbar.deactivate
  226.     when :se
  227.       @window_sebar.select(-1)
  228.       @window_sebar.deactivate
  229.     when :message
  230.       @window_message.select(-1)
  231.       @window_message.deactivate
  232.     when :command
  233.       @window_command.select(-1)
  234.       @window_command.deactivate
  235.     when :switch
  236.       @window_switch.select(-1)
  237.       @window_switch.deactivate
  238.     end
  239.   end
  240.   def update
  241.     super
  242.     update_input
  243.     update_index
  244.   end
  245. #~   def update_input
  246. #~     if Input.trigger?(:UP)
  247. #~       @index -= 1
  248. #~       @index = @size if @index < 0
  249. #~     elsif Input.trigger?(:DOWN)
  250. #~       @index += 1
  251. #~       @index = 0 if @index > @size
  252. #~     elsif Input.repeat?(:LEFT)
  253. #~       change_volume(@index, -0.01)
  254. #~     elsif Input.repeat?(:RIGHT)
  255. #~       change_volume(@index, 0.01)
  256. #~     elsif Input.trigger?(:B)
  257. #~       @index = @size
  258. #~     end
  259. #~   end
  260.  
  261. #~   def update_input
  262. #~     if PadConfig.move_up && PadConfig.move_up != :_up
  263. #~       if Input.trigger?(PadConfig.move_up)
  264. #~         @index -= 1
  265. #~         @index = @size if @index < 0
  266. #~       end
  267. #~     else
  268. #~       if Input.trigger?(:UP)
  269. #~         @index -= 1
  270. #~         @index = @size if @index < 0
  271. #~       end
  272. #~     end
  273. #~     if PadConfig.move_down && PadConfig.move_down != :_down
  274. #~       if Input.trigger?(PadConfig.move_down)
  275. #~         @index += 1
  276. #~         @index = 0 if @index > @size
  277. #~       end
  278. #~     else
  279. #~       if Input.trigger?(:DOWN)
  280. #~         @index += 1
  281. #~         @index = 0 if @index > @size
  282. #~       end
  283. #~     end
  284. #~     if PadConfig.move_left && PadConfig.move_left != :_left
  285. #~       change_volume(@index, -0.01) if Input.repeat?(PadConfig.move_left)
  286. #~     else
  287. #~       change_volume(@index, -0.01) if Input.repeat?(:LEFT)
  288. #~     end
  289. #~     if PadConfig.move_right && PadConfig.move_right != :_right
  290. #~       change_volume(@index, 0.01) if Input.repeat?(PadConfig.move_right)
  291. #~     else
  292. #~       change_volume(@index, 0.01) if Input.repeat?(:RIGHT)
  293. #~     end
  294. #~     if PadConfig.cancel && PadConfig.move_right != :_x
  295. #~       @index = @size if Input.trigger?(PadConfig.cancel)
  296. #~     else
  297. #~       @index = @size if Input.trigger?(:B)
  298. #~     end
  299. #~   end
  300.  
  301.   def update_input
  302.     if Input.trigger?(:UP) || Input.trigger?(PadConfig.move_up)
  303.       @index -= 1
  304.       @index = @size if @index < 0
  305.     elsif Input.trigger?(:DOWN) || Input.trigger?(PadConfig.move_down)
  306.       @index += 1
  307.       @index = 0 if @index > @size
  308.     elsif Input.repeat?(:LEFT) || Input.repeat?(PadConfig.move_left)
  309.       change_volume(@index, -0.01)
  310.     elsif Input.repeat?(:RIGHT) || Input.repeat?(PadConfig.move_right)
  311.       change_volume(@index, 0.01)
  312.     elsif Input.trigger?(:B) || Input.trigger?(PadConfig.cancel)
  313.       @index = @size
  314.     end
  315.   end
  316.  
  317.   def update_index
  318.     return if @index == @old_index
  319.     deactivate_window(@old_index)
  320.     activate_window(@index)
  321.     Sound.play_cursor
  322.     @old_index = @index
  323.   end
  324.   def change_volume(index, value)
  325.     return unless audio_index(index)
  326.     $game_options.set_volume(:master, value) if @window_index[index] == :master
  327.     $game_options.set_volume(:bgm, value) if @window_index[index] == :bgm
  328.     $game_options.set_volume(:se, value) if @window_index[index] == :se
  329.     @window_masterbar.refresh($game_options.master_volume)
  330.     @window_bgmbar.refresh($game_options.bgm_volume)
  331.     @window_sebar.refresh($game_options.se_volume)
  332.     Sound.play_cursor
  333.     $game_map.autoplay if $game_map && $game_map.map_id > 0
  334.   end
  335.   def audio_index(index)
  336.     return true if @window_index[index] == :master
  337.     return true if @window_index[index] == :bgm
  338.     return true if @window_index[index] == :se
  339.     return false
  340.   end
  341.   def resolution_ok
  342.     case @window_resolution.index
  343.     when 0
  344.       Graphics.windowed_mode && Graphics.ratio = 1
  345.     when 1
  346.       Graphics.windowed_mode && Graphics.ratio = 2
  347.     when 2
  348.       Graphics.fullscreen_mode && Graphics.ratio = 2
  349.     end
  350.     @window_resolution.refresh
  351.     @window_resolution.activate
  352.   end
  353.   def autosave_ok
  354.     $game_options.auto_save = true if @window_autosave.index == 0
  355.     $game_options.auto_save = false if @window_autosave.index == 1
  356.     @window_autosave.refresh
  357.     @window_autosave.activate
  358.   end
  359.   def message_ok
  360.     $game_options.message_se = true if @window_message.index == 0
  361.     $game_options.message_se = false if @window_message.index == 1
  362.     @window_message.refresh
  363.     @window_message.activate
  364.   end
  365.   def switch_ok
  366.     eval(OPT_STR::SWITCH_DETAIL + " = true") if @window_switch.index == 0
  367.     eval(OPT_STR::SWITCH_DETAIL + " = false") if @window_switch.index == 1
  368.     @window_switch.refresh
  369.     @window_switch.activate
  370.   end
  371.   def command_ok
  372.     case @window_command.index
  373.     when 0
  374.       $game_options.save_options
  375.       $game_options.clear_memorize
  376.       return_scene
  377.     when 1
  378.       $game_options.copy_memorize
  379.       $game_options.clear_memorize
  380.       return_scene
  381.     end
  382.   end
  383.   def input_ok
  384.     SceneManager.call(Scene_ButtonConfig)
  385.   end
  386. end
  387.  
  388. class Window_Options < Window_Base
  389.   def initialize
  390.     super((Graphics.width / 2) / 2,48,(Graphics.width / 2),416-48)
  391.     self.contents.font.color = Color.new(150,100,255,200)
  392.   end
  393.   def add_text(y,string)
  394.     draw_text(15,y,(Graphics.width / 2) - 24,24,string)
  395.   end
  396.   def draw_line(y)
  397.     contents.fill_rect(15,y+12,544-24,1,Color.new(75,75,75))
  398.   end
  399. end
  400.  
  401. class Window_OR < Window_Selectable
  402.   TEXT = ["Normal","Large","Full"]
  403.   def initialize(y)
  404.     super((Graphics.width / 2) / 2,y,(Graphics.width / 2),48)
  405.     refresh
  406.     self.opacity = 0
  407.   end
  408.   def spacing; return 0; end
  409.   def item_width; self.contents.width / 3; end
  410.   def item_max; return 3; end
  411.   def col_max; return item_max; end
  412.   def row_max; return 1; end
  413.   def draw_item(index)
  414.     rect = item_rect(index)
  415.     change_color(normal_color, index == $game_options.resolution_index)
  416.     draw_text(rect, TEXT[index],1)
  417.   end
  418. end
  419.  
  420. class Window_OI < Window_Selectable
  421.   def initialize(y)
  422.     super(24 + (Graphics.width / 2) / 2,y,(Graphics.width / 2) - 48,48)
  423.     refresh
  424.     self.opacity = 0
  425.   end
  426.   def item_max; return 1; end
  427.   def col_max; return item_max; end
  428.   def row_max; return 1; end
  429.   def draw_item(index)
  430.     rect = item_rect(index)
  431.     change_color(normal_color)
  432.     draw_text(rect, "Change Button Configuration",1)
  433.   end
  434. end
  435.  
  436. class Window_OAS < Window_Selectable
  437.   def initialize(y)
  438.     super(24 + (Graphics.width / 2) / 2,y,(Graphics.width / 2) - 48,48)
  439.     refresh
  440.     self.opacity = 0
  441.   end
  442.   def item_width; return 118; end
  443.   def item_max; return 2; end
  444.   def col_max; return item_max; end
  445.   def row_max; return 1; end
  446.   def draw_item(index)
  447.     rect = item_rect(index)
  448.     $game_options.auto_save ? id = 0 : id = 1
  449.     change_color(normal_color, id == index)
  450.     draw_text(rect, ["Yes","No"][index],1)
  451.   end
  452. end
  453.  
  454. class Window_OSW < Window_Selectable
  455.   def initialize(y)
  456.     super((Graphics.width / 2) / 2,y,(Graphics.width / 2),48)
  457.     refresh
  458.     self.opacity = 0
  459.   end
  460.   def item_max; return 2; end
  461.   def col_max; return item_max; end
  462.   def row_max; return 1; end
  463.   def draw_item(index)
  464.     rect = item_rect(index)
  465.     eval(OPT_STR::SWITCH_DETAIL) ? id = 0 : id = 1
  466.     change_color(normal_color, id == index)
  467.     draw_text(rect, [OPT_STR::SWITCH_COMMAND[0],OPT_STR::SWITCH_COMMAND[1]][index],1)
  468.   end
  469. end
  470.  
  471. class Window_OCommand < Window_Selectable
  472.   def initialize(y)
  473.     super((Graphics.width / 2) / 2,y,(Graphics.width / 2),48)
  474.     refresh
  475.     self.opacity = 0
  476.   end
  477.   def item_max; return 2; end
  478.   def col_max; return item_max; end
  479.   def row_max; return 1; end
  480.   def draw_item(index)
  481.     rect = item_rect(index)
  482.     draw_text(rect, ["Ok","Cancel"][index],1)
  483.   end
  484. end
  485.  
  486. class Window_OMSE < Window_Selectable
  487.   def initialize(y)
  488.     super((Graphics.width / 2) / 2,y,(Graphics.width / 2),48)
  489.     self.y = y
  490.     refresh
  491.     self.opacity = 0
  492.   end
  493.   def item_max; return 2; end
  494.   def col_max; return item_max; end
  495.   def row_max; return 1; end
  496.  
  497.   def draw_item(index)
  498.     rect = item_rect(index)
  499.     $game_options.message_se ? id = 0 : id = 1
  500.     change_color(normal_color, id == index)
  501.     draw_text(rect, ["Yes","No"][index],1)
  502.   end
  503. end
  504.  
  505. class Window_OBar < Window_Selectable
  506.   def initialize(y)
  507.     super(24 + (Graphics.width / 2) / 2,y,(Graphics.width / 2) - 48,48)
  508.     self.opacity = 0
  509.   end
  510.   def item_width; return contents.width; end
  511.   def item_max; return 1; end
  512.   def col_max; return item_max; end
  513.   def row_max; return 1; end
  514.   def refresh(temp_value)
  515.     contents.clear
  516.     temp_value *= 50
  517.     temp_value.to_i.times do |i|
  518.       rect = Rect.new(4+i*4,6,2,8)
  519.       contents.fill_rect(rect, Color.new(75,100,255))
  520.     end
  521.     (100-temp_value).to_i.times do |i|
  522.       rect = Rect.new(396-i*4,6,2,8)
  523.       contents.fill_rect(rect, Color.new(0,0,0))
  524.     end
  525.     draw_text(0,0,contents.width,24,(temp_value * 2).to_i.to_s + "%",2)
  526.   end
  527.   def update_mouse
  528.   end
  529. end
  530.  
  531. class Game_Options
  532.   attr_accessor  :fullscreen
  533.   attr_accessor  :resolution
  534.   attr_accessor  :master_volume
  535.   attr_accessor  :bgm_volume
  536.   attr_accessor  :se_volume
  537.   attr_accessor  :auto_save
  538.   attr_accessor  :message_se
  539.   attr_accessor  :game_controls
  540.   def default_options
  541.     @fullscreen = false
  542.     @resolution = [544,416]
  543.     @master_volume = 1.0
  544.     @bgm_volume = 1.0
  545.     @se_volume = 1.0
  546.     @auto_save = true
  547.     @message_se = true
  548.     @game_controls = {
  549.         :keyboard => {
  550.             :Confirm        => :_z,
  551.             :Cancel         => :_x,
  552.             :Dash           => :_shift,
  553.             :Attack         => :_a,
  554.             :Skill          => :_d,
  555.             :Skill2         => :_s,
  556.             :Move_Up        => :_up,
  557.             :Move_Down      => :_down,
  558.             :Move_Left      => :_left,
  559.             :Move_Right     => :_right,
  560. #~             :Page_Up        => :_q,
  561. #~             :Page_Down      => :_w
  562.  
  563.         },
  564.         :controller => {
  565.             :Confirm        => :A,
  566.             :Cancel         => :Y,
  567.             :Dash           => :R2,
  568.             :Attack         => :X,
  569.             :Skill          => :B,
  570.             :Skill2          => :L2,
  571.             :Move_Up        => :L_UP,
  572.             :Move_Down      => :L_DOWN,
  573.             :Move_Left      => :L_LEFT,
  574.             :Move_Right     => :L_RIGHT,
  575. #~             :Page_Up        => :R1,
  576. #~             :Page_Down      => :L1
  577.         }
  578.     }
  579.     save_options
  580.   end
  581.   def load_options
  582.     if FileTest.exist?("System/Options.dt")
  583.       File.open("System/Options.dt", "rb") do |file|
  584.         $game_options = Marshal.load(file)
  585.       end
  586.     else
  587.       default_options
  588.     end
  589.     reset_screen
  590.   end
  591.   def reset_screen
  592.     if Module.const_defined?(:Window_Resize)
  593.       if $game_options.fullscreen
  594.         Window_Resize.f
  595.       else
  596.         Window_Resize.r($game_options.resolution[0],$game_options.resolution[1])
  597.       end
  598.     end
  599.   end
  600.   def save_options
  601.     File.open("System/Options.dt", "wb") do |file|
  602.       Marshal.dump($game_options, file)
  603.     end
  604.   end
  605.   def memorize_options
  606.     @old_options = Marshal.load(Marshal.dump($game_options))
  607.   end
  608.   def copy_memorize
  609.     $game_options = Marshal.load(Marshal.dump(@old_options))
  610.     reset_screen
  611.   end
  612.   def clear_memorize
  613.     @old_options = nil
  614.   end
  615.   def resolution_index
  616.     return 2 if Graphics.fullscreen?
  617.     return 1 if !Graphics.fullscreen? && Graphics.ratio == 0
  618.     return 0
  619.   end
  620.   def set_resolution(w,h)
  621.     @resolution = [w,h]
  622.     @fullscreen = false
  623.     Window_Resize.window
  624.     15.times {|i| Graphics.update }
  625.     Window_Resize.r(@resolution[0],@resolution[1])
  626.   end
  627.   def set_fullscreen
  628.     @fullscreen = true
  629.     Window_Resize.f
  630.   end
  631.   def set_volume(symbol, value)
  632.     case symbol
  633.     when :master
  634.       @master_volume += value
  635.       @master_volume = [[@master_volume, 1].min, 0].max
  636.     when :bgm
  637.       @bgm_volume += value
  638.       @bgm_volume = [[@bgm_volume, 1].min, 0].max
  639.     when :se
  640.       @se_volume += value
  641.       @se_volume = [[@se_volume, 1].min, 0].max
  642.     end
  643.   end
  644.   def preset_volume(symbol, value)
  645.     if symbol == :master
  646.       @master_volume = value
  647.       @master_volume = [[@master_volume, 1].min, 0].max
  648.     end
  649.     if symbol == :bgm
  650.       @bgm_volume = value
  651.       @bgm_volume = [[@bgm_volume, 1].min, 0].max
  652.     end
  653.     if symbol == :se
  654.       @se_volume = value
  655.       @se_volume = [[@se_volume, 1].min, 0].max
  656.     end
  657.   end
  658. end
  659.  
  660. class RPG::BGM < RPG::AudioFile
  661.   def play(pos = 0)
  662.     if @name.empty?
  663.       Audio.bgm_stop
  664.       @@last = RPG::BGM.new
  665.     else
  666.       if $game_options
  667.         volume = @volume * $game_options.master_volume
  668.         volume *= $game_options.bgm_volume
  669.       else
  670.         volume = @volume
  671.       end
  672.       Audio.bgm_play('Audio/BGM/' + @name, volume.to_i, @pitch, pos)
  673.       @@last = self.clone
  674.     end
  675.   end
  676. end
  677.  
  678. class RPG::BGS < RPG::AudioFile
  679.   def play(pos = 0)
  680.     if @name.empty?
  681.       Audio.bgs_stop
  682.       @@last = RPG::BGS.new
  683.     else
  684.       if $game_options
  685.         volume = @volume * $game_options.master_volume
  686.         volume *= $game_options.bgm_volume
  687.       else
  688.         volume = @volume
  689.       end
  690.       Audio.bgs_play('Audio/BGS/' + @name, volume.to_i, @pitch, pos)
  691.       @@last = self.clone
  692.     end
  693.   end
  694. end
  695.  
  696. class RPG::ME < RPG::AudioFile
  697.   def play
  698.     if @name.empty?
  699.       Audio.me_stop
  700.     else
  701.       if $game_options
  702.         volume = @volume * $game_options.master_volume
  703.         volume *= $game_options.se_volume
  704.       else
  705.         volume = @volume
  706.       end
  707.       Audio.me_play('Audio/ME/' + @name, volume.to_i, @pitch)
  708.     end
  709.   end
  710. end
  711.  
  712. class RPG::SE < RPG::AudioFile
  713.   def play
  714.     unless @name.empty?
  715.       if $game_options
  716.         volume = @volume * $game_options.master_volume
  717.         volume *= $game_options.se_volume
  718.       else
  719.         volume = @volume
  720.       end
  721.       Audio.se_play('Audio/SE/' + @name, volume.to_i, @pitch)
  722.     end
  723.   end
  724. end
  725.  
  726. module SceneManager
  727.   def self.run
  728.     DataManager.init
  729.     Audio.setup_midi if use_midi?
  730.     $game_options = Game_Options.new
  731.     $game_options.load_options
  732.     @scene = first_scene_class.new
  733.     @scene.main while @scene
  734.   end
  735. end
  736.  
  737. class Window_MenuCommand < Window_Command
  738.   alias options_aoc add_original_commands
  739.   def add_original_commands
  740.     options_aoc
  741.     add_command("Options", :options)
  742.   end
  743. end
  744.  
  745. class Scene_Menu < Scene_MenuBase
  746.   alias options_create_command_window create_command_window
  747.   def create_command_window
  748.     options_create_command_window
  749.     @command_window.set_handler(:options,   method(:command_options))
  750.   end
  751.   def command_options
  752.     SceneManager.call(Scene_Options)
  753.   end
  754.  
  755.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement