Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ╔══════════════════════════════════╗
- # ║ ▼ Dark's Options Menu ║
- # ║ ▼ Author: Nhat Nguyen (Dark Sky) ║
- # ║ ▼ Release Date: March 11th 2016 ║
- # ╚══════════════════════════════════╝
- #-------------------------------------------------------------------------------
- # Version 1.0: Release!
- #-------------------------------------------------------------------------------
- # Require: Basic Mouse System v2.7g
- #===============================================================================
- module DarkOptions
- Disable_Map_Mouse = true
- #$auto_save = false
- HELP_WINDOW_INFO = {
- :master_volume => "Điều chỉnh âm lượng của tòan bộ Game",
- :bgm_volume => "Điều chỉnh âm lượng nhạc nền của Game",
- :se_volume => "Điều chỉnh âm lượng hiệu ứng của Game",
- :full_screen => "Bật/Tắt chế độ tòan màn hình",
- :auto_save => "Bật/Tắt Autosave",
- }
- end
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- alias dark_create_command_window_option create_command_window
- def create_command_window
- dark_create_command_window_option
- @command_window.set_handler(:darkoptions, method(:command_options))
- end
- #--------------------------------------------------------------------------
- # * Command options
- #--------------------------------------------------------------------------
- def command_options
- SceneManager.call(Scene_MenuOptions)
- end
- end
- #==============================================================================
- # ** Scene_Base
- #------------------------------------------------------------------------------
- class Scene_Base
- alias darkscene_base_update update
- def update
- darkscene_base_update
- $game_options.auto_save = $game_system.auto_save_option
- $auto_save = $game_system.auto_save_option
- end
- end
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # This command window appears on the menu screen.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Add Original Commands to List
- #--------------------------------------------------------------------------
- alias dark_add_original_commands add_original_commands
- def add_original_commands
- dark_add_original_commands
- add_command("Options", :darkoptions, true)
- end
- end
- module Mouse
- class << self
- alias dark_mouse_update update
- end
- def self.update
- if SceneManager.scene_is?(Scene_Map) && DarkOptions::Disable_Map_Mouse == true
- @enabled = false
- else
- if $game_switches[MOUSE_SWITCH] != true && USE_MOUSE_SWITCH == true
- @enabled = true
- end
- end
- dark_mouse_update
- end
- end
- class Scene_MenuOptions < Scene_Base
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- create_background
- create_options
- create_help_window
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- def create_options
- @opt_window = Window_MenuOptions.new(0,0)
- @opt_window.y = Graphics.height/2 - @opt_window.height/2
- @opt_window.refresh
- end
- #--------------------------------------------------------------------------
- # * Create Help Window
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- @help_window.width = @opt_window.width
- @help_window.x = @opt_window.x
- @help_window.y = @opt_window.y - @opt_window.height + 25 + 62
- @help_window.height -= 15
- @help_window.create_contents
- @help_window.refresh
- @help_window.set_text(DarkOptions::HELP_WINDOW_INFO[@opt_window.current_symbol])
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- @help_window.set_text(DarkOptions::HELP_WINDOW_INFO[@opt_window.current_symbol])
- if Input.trigger?(:B) or Mouse.rclick?
- return_scene
- end
- end
- end
- class Window_MenuOptions < Window_Command
- def initialize(x,y)
- rect1 = Rect.new(233,176,185,17)
- rect2 = Rect.new(233,200,185,17)
- rect3 = Rect.new(233,200+200-176,185,17) #256,42 #350,42
- @volume_rect = [rect1,rect2,rect3]
- @delta = 0
- super(x,y)
- self.x = Graphics.width / 2 - window_width / 2
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return 400
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- @sym = @list[@index][:symbol]
- if Mouse.lclick?
- if [:master_volume,:bgm_volume,:se_volume].include?(@list[index][:symbol])
- if Mouse.pos?[0] >= @volume_rect[@index-1].x and Mouse.pos?[0] <= @volume_rect[@index-1].x + @volume_rect[@index-1].width
- rate1 = (((Mouse.pos?[0]-233).to_f / 185)*100).to_i
- rate2 = (Mouse.pos?[0]-233).to_f / 185
- $game_options.dark_set_volume(@sym,rate2)
- Audio.se_stop
- sound = RPG::SE.new("Barrier")
- sound.play
- refresh
- end
- else
- case @sym
- when :full_screen
- if Mouse.pos?[0] >= 256 and Mouse.pos?[0] <= 256 + 42
- $game_system.full_screen_option = true
- Window_Resize.full
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- end
- if Mouse.pos?[0] >= 350 and Mouse.pos?[0] <= 350 + 42
- $game_system.full_screen_option = false
- Window_Resize.window
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- end
- when :auto_save
- if Mouse.pos?[0] >= 256 and Mouse.pos?[0] <= 256 + 42
- $game_system.auto_save_option = true
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- end
- if Mouse.pos?[0] >= 350 and Mouse.pos?[0] <= 350 + 42
- $game_system.auto_save_option = false
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- end
- end
- end
- end
- if Input.press?(:RIGHT)
- if [:master_volume,:bgm_volume,:se_volume].include?(@list[index][:symbol])
- if $game_options.get_volume(@sym) < 1.0
- $game_options.change_volume(@sym,0.01)
- refresh
- end
- end
- end
- if Input.trigger?(:RIGHT) or Input.trigger?(:LEFT)
- if [:master_volume,:bgm_volume,:se_volume].include?(@list[index][:symbol])
- Audio.se_stop
- sound = RPG::SE.new("Barrier")
- sound.play
- end
- case @sym
- when :full_screen
- $game_system.full_screen_option = !$game_system.full_screen_option
- Window_Resize.toggle
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- when :auto_save
- $game_system.auto_save_option = !$game_system.auto_save_option
- sound = RPG::SE.new("Cursor1")
- sound.play
- refresh
- end
- end
- if Input.press?(:LEFT)
- if [:master_volume,:bgm_volume,:se_volume].include?(@list[index][:symbol])
- if $game_options.get_volume(@sym) > 0
- $game_options.change_volume(@sym,-0.01)
- refresh
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Get Number of Lines to Show
- #--------------------------------------------------------------------------
- def visible_line_number
- 5
- end
- #--------------------------------------------------------------------------
- # * Update Mouse
- #--------------------------------------------------------------------------
- def update_mouse
- @timer -= 1
- @mouse_all_rects = []
- item_max.times {|i|
- rect = item_rect(i)
- rect.x += self.x + standard_padding - self.ox
- rect.y += self.y + standard_padding - self.oy
- if !self.viewport.nil?
- rect.x += self.viewport.rect.x - self.viewport.ox
- rect.y += self.viewport.rect.y - self.viewport.oy
- end
- @mouse_all_rects.push(rect) }
- item_max.times {|i|
- next if @timer > 0
- next unless Mouse.within?(@mouse_all_rects[i])
- @timer = 10 if i > top_row * 2 + page_item_max - 1
- @timer = 10 if i < top_row * 2
- self.index = i }
- return if MOUSE_CLICK_WITHIN && !within_index
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_main_commands
- end
- #--------------------------------------------------------------------------
- # * Add Main Commands to List
- #--------------------------------------------------------------------------
- def add_main_commands
- add_command("Master Volume", :master_volume, true)
- add_command("BGM Volume", :bgm_volume, true)
- add_command("SE Volume", :se_volume, true)
- add_command("Full Screen", :full_screen, true)
- add_command("Autosave", :auto_save, true)
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- if [:master_volume,:bgm_volume,:se_volume].include?(@list[index][:symbol])
- colors = [Color.new(100,241,40),Color.new(255,171,0),Color.new(0,188,255)]
- color1 = Color.new(255,255,255)
- color2 = colors[index-1]
- sym = @list[index][:symbol]
- cc = ($game_options.get_volume(sym)*100).to_i
- rate = $game_options.get_volume(sym)
- change_color(normal_color, command_enabled?(index))
- draw_text(item_rect_for_text(index), command_name(index), alignment)
- contents.fill_rect(147,item_rect_for_text(index).y+1,191,19+3, Color.new(25,25,25,200))
- contents.gradient_fill_rect( 150,item_rect_for_text(index).y+4,185*rate,15, color1, color2)
- draw_text(item_rect_for_text(index),cc, 2)
- else
- change_color(normal_color, command_enabled?(index))
- rect = item_rect_for_text(index)
- draw_text(item_rect_for_text(index), command_name(index), alignment)
- sym = @list[index][:symbol]
- case sym
- when :full_screen
- change_color(normal_color, $game_system.full_screen_option)
- draw_text(147 + 32,rect.y-2,50,32,"Yes")
- change_color(normal_color, !$game_system.full_screen_option)
- draw_text(147 + 32 + 96,rect.y-2,50,32,"No")
- when :auto_save
- change_color(normal_color, $game_system.auto_save_option)
- draw_text(147 + 32,rect.y-2,50,32,"Yes")
- change_color(normal_color, !$game_system.auto_save_option)
- draw_text(147 + 32 + 96,rect.y-2,50,32,"No")
- end
- end
- end
- end
- class Game_Options
- attr_accessor :fullscreen
- attr_accessor :resolution
- attr_accessor :master_volume
- attr_accessor :bgm_volume
- attr_accessor :se_volume
- attr_accessor :auto_save
- attr_accessor :message_se
- def default_options
- @fullscreen = false
- @resolution = [544,416]
- @master_volume = 1.0
- @bgm_volume = 1.0
- @se_volume = 1.0
- @auto_save = false
- @message_se = true
- save_options
- end
- def get_volume(type)
- case type
- when :bgm_volume
- @bgm_volume
- when :se_volume
- @se_volume
- when :master_volume
- @master_volume
- end
- end
- def dark_set_volume(type,value)
- case type
- when :bgm_volume
- @bgm_volume = value
- when :se_volume
- @se_volume = value
- when :master_volume
- @master_volume = value
- end
- end
- def change_volume(type,value)
- case type
- when :bgm_volume
- @bgm_volume += value
- when :se_volume
- @se_volume += value
- when :master_volume
- @master_volume += value
- end
- end
- def load_options
- if FileTest.exist?("System/Options.dt")
- File.open("System/Options.dt", "rb") do |file|
- $game_options = Marshal.load(file)
- end
- else
- default_options
- end
- reset_screen
- end
- def reset_screen
- if Module.const_defined?(:Window_Resize)
- if $game_options.fullscreen
- Window_Resize.f
- else
- Window_Resize.r($game_options.resolution[0],$game_options.resolution[1])
- end
- end
- end
- def save_options
- File.open("System/Options.dt", "wb") do |file|
- Marshal.dump($game_options, file)
- end
- end
- def memorize_options
- @old_options = Marshal.load(Marshal.dump($game_options))
- end
- def copy_memorize
- $game_options = Marshal.load(Marshal.dump(@old_options))
- reset_screen
- end
- def clear_memorize
- @old_options = nil
- end
- def resolution_index
- return 2 if @fullscreen
- return 1 if @resolution[0] == 544*2
- return 0
- end
- def set_resolution(w,h)
- @resolution = [w,h]
- @fullscreen = false
- Window_Resize.window
- 15.times {|i| Graphics.update }
- Window_Resize.r(@resolution[0],@resolution[1])
- end
- def set_fullscreen
- @fullscreen = true
- Window_Resize.f
- end
- def set_volume(symbol, value)
- case symbol
- when :master
- @master_volume += value
- @master_volume = [[@master_volume, 1].min, 0].max
- when :bgm
- @bgm_volume += value
- @bgm_volume = [[@bgm_volume, 1].min, 0].max
- when :se
- @se_volume += value
- @se_volume = [[@se_volume, 1].min, 0].max
- end
- end
- def preset_volume(symbol, value)
- if symbol == :master
- @master_volume = value
- @master_volume = [[@master_volume, 1].min, 0].max
- end
- if symbol == :bgm
- @bgm_volume = value
- @bgm_volume = [[@bgm_volume, 1].min, 0].max
- end
- if symbol == :se
- @se_volume = value
- @se_volume = [[@se_volume, 1].min, 0].max
- end
- end
- end
- class RPG::BGM < RPG::AudioFile
- def play(pos = 0)
- if @name.empty?
- Audio.bgm_stop
- @@last = RPG::BGM.new
- else
- if $game_options
- volume = @volume * $game_options.master_volume
- volume *= $game_options.bgm_volume
- else
- volume = @volume
- end
- Audio.bgm_play('Audio/BGM/' + @name, volume.to_i, @pitch, pos)
- @@last = self.clone
- end
- end
- end
- class RPG::BGS < RPG::AudioFile
- def play(pos = 0)
- if @name.empty?
- Audio.bgs_stop
- @@last = RPG::BGS.new
- else
- if $game_options
- volume = @volume * $game_options.master_volume
- volume *= $game_options.bgm_volume
- else
- volume = @volume
- end
- Audio.bgs_play('Audio/BGS/' + @name, volume.to_i, @pitch, pos)
- @@last = self.clone
- end
- end
- end
- class RPG::ME < RPG::AudioFile
- def play
- if @name.empty?
- Audio.me_stop
- else
- if $game_options
- volume = @volume * $game_options.master_volume
- volume *= $game_options.se_volume
- else
- volume = @volume
- end
- Audio.me_play('Audio/ME/' + @name, volume.to_i, @pitch)
- end
- end
- end
- class RPG::SE < RPG::AudioFile
- def play
- unless @name.empty?
- if $game_options
- volume = @volume * $game_options.master_volume
- volume *= $game_options.se_volume
- else
- volume = @volume
- end
- Audio.se_play('Audio/SE/' + @name, volume.to_i, @pitch)
- end
- end
- end
- module SceneManager
- def self.run
- DataManager.init
- Audio.setup_midi if use_midi?
- $game_options = Game_Options.new
- $game_options.load_options
- @scene = first_scene_class.new
- @scene.main while @scene
- end
- end
- class Game_System
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :full_screen_option
- attr_accessor :auto_save_option
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias darkoption_game_system_init initialize
- def initialize
- @full_screen_option = false
- @auto_save_option = false
- darkoption_game_system_init
- end
- #--------------------------------------------------------------------------
- # * Post-Load Processing
- #--------------------------------------------------------------------------
- def on_after_load
- Graphics.frame_count = @frames_on_save
- @bgm_on_save.play
- @bgs_on_save.play
- Window_Resize.full if @full_screen_option == true
- $game_options.auto_save = @auto_save_option
- end
- end
- #==============================================================================
- # ** Scene_Save
- #------------------------------------------------------------------------------
- # This class performs save screen processing.
- #==============================================================================
- class Scene_Save < Scene_File
- def on_save_success
- $game_options.save_options
- Sound.play_save
- return_scene
- end
- end
- #===============================================================================
- # END OF SCRIPT
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment