Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Custom Choices
- # -- Last Updated: 2017.03.13
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- # -- Conmission for: The007who
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-CustomChoices"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.03.12 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- # Put this below "Sixth Menu Add Ons"! <- IMPORTANT!
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Script Call: None
- #==============================================================================
- module DSIVER144
- module AUTOMATIC_CHOICE
- TOGGLE_SWITCH = 15 # Turn on this switch will activate script.
- DEFAULT_CHOICE_WAIT_TIME = 60*3 # 3 Seconds. Don't change this.
- RESET_CHOICE_WAIT_TIME = true # Auto set wait time to default each time
- # using Show Choice Command.
- #--------------------------------------------------------------------------
- # * new method: automatic?
- #--------------------------------------------------------------------------
- def self.automatic?
- return $game_switches[TOGGLE_SWITCH] == true
- end
- end # AUTOMATIC_CHOICE
- end # DSIVER144
- class Window_Message
- include DSIVER144
- #--------------------------------------------------------------------------
- # * Choice Input Processing
- #--------------------------------------------------------------------------
- alias_method(:dsi_input_choice_automatic, :input_choice)
- def input_choice
- $limit_time = 0 if AUTOMATIC_CHOICE.automatic?
- dsi_input_choice_automatic
- end
- end # Window_Message
- #==============================================================================
- # ** Window_ChoiceList
- #------------------------------------------------------------------------------
- # This window is used for the event command [Show Choices].
- #==============================================================================
- class Window_ChoiceList < Window_Command
- include DSIVER144
- alias_method(:dsi_start_choice_list, :start)
- #--------------------------------------------------------------------------
- # * Start Input Processing
- #--------------------------------------------------------------------------
- def start
- if AUTOMATIC_CHOICE.automatic?
- self.opacity = 0
- self.contents_opacity = 0
- update_placement
- refresh
- select(0)
- open
- activate
- else
- self.opacity = 255
- self.contents_opacity = 255
- dsi_start_choice_list
- end
- end
- #--------------------------------------------------------------------------
- # * method: update
- #--------------------------------------------------------------------------
- alias_method(:dsi_update_autmatic, :update)
- def update
- dsi_update_autmatic
- @cursor_sprite.y = @cursor_baseY + self.index*@cursor_distance if @cursor_sprite && @begin_count
- if $limit_time && $limit_time < ($game_system.choiceWaitTime ? $game_system.choiceWaitTime : AUTOMATIC_CHOICE::DEFAULT_CHOICE_WAIT_TIME) && @begin_count
- $limit_time += 1
- if @timer_sprite
- sec = $limit_time / 60 % 60
- @timer_sprite.bitmap = Cache.system("timer#{sec}") if sec < 3
- end
- elsif $limit_time && @begin_count
- select(0)
- @cursor_sprite.y = @cursor_baseY + 0*@cursor_distance if @cursor_sprite
- process_ok
- $limit_time = nil
- @begin_count = nil
- $game_system.choiceWaitTime = nil if AUTOMATIC_CHOICE::RESET_CHOICE_WAIT_TIME
- end
- end
- #--------------------------------------------------------------------------
- # * alias method: update_placement
- #--------------------------------------------------------------------------
- alias_method(:dsi_update_placement_choice, :update_placement)
- def update_placement
- dsi_update_placement_choice
- return unless AUTOMATIC_CHOICE.automatic?
- @choice_sprites ||= []
- @choice_sprites.each do |sprite|
- sprite.dispose
- end
- @choice_sprites.clear
- choice_bitmap = Cache.system("Choice")
- distance = 48
- start_y = ((Graphics.height - (choice_bitmap.height)*$game_message.choices.size)) * 0.5 - 40
- @cursor_baseY = start_y
- @cursor_distance = distance
- des_x = (Graphics.width - choice_bitmap.width) * 0.5
- $game_message.choices.each_with_index do |choice,i|
- c_sprite = Sprite.new
- c_sprite.x = i % 2 == 0 ? -choice_bitmap.width : Graphics.width
- c_sprite.start_x = c_sprite.x
- c_sprite.change_x = des_x - c_sprite.start_x
- c_sprite.y = start_y + i*distance
- c_sprite.bitmap = choice_bitmap.clone
- c_sprite.bitmap.draw_text(0,0,choice_bitmap.width,choice_bitmap.height,choice,1)
- @choice_sprites << c_sprite
- end
- @cursor_sprite = Sprite.new
- @cursor_sprite.bitmap = Cache.system("Cursor")
- @cursor_sprite.x = des_x
- @cursor_sprite.y = @cursor_baseY
- @cursor_sprite.z = 100
- @cursor_sprite.opacity = 0
- @timer_sprite = Sprite.new
- @timer_sprite.bitmap = Cache.system("timer0")
- @timer_sprite.x = -50
- @timer_sprite.y = 0
- @timer_sprite.opacity = 0
- start_time = Graphics.frame_count
- while (current_time = Graphics.frame_count - start_time ) < 45
- @choice_sprites.each do |sprite|
- sprite.x = easeInOutQuad(current_time, sprite.start_x, sprite.change_x, 45)
- @cursor_sprite.opacity = easeInOutQuad(current_time, 0, 255, 45)
- @timer_sprite.x = easeInOutQuad(current_time, -50, 50, 45)
- @timer_sprite.opacity = easeInOutQuad(current_time, 0, 255, 45)
- end
- Fiber.yield
- end
- @choice_sprites.each_with_index do |sprite,i|
- sprite.start_x = sprite.x
- des_x = i % 2 == 0 ? Graphics.width : -choice_bitmap.width
- sprite.change_x = des_x - sprite.start_x
- end
- @begin_count = true
- end
- #-------------------------------------------------------------------------
- # * new method: easeInOutQuad
- #-------------------------------------------------------------------------
- def easeInOutQuad(t, b, c, d)
- t = t / (d/2.0)
- if (t < 1)
- return c/2*t*t + b
- end
- t -= 1
- return -c/2.0 * (t*(t-2) - 1) + b
- end
- #--------------------------------------------------------------------------
- # * Call OK Handler
- #--------------------------------------------------------------------------
- def call_ok_handler
- $limit_time = nil
- @begin_count = nil
- $game_system.choiceWaitTime = nil if AUTOMATIC_CHOICE::RESET_CHOICE_WAIT_TIME
- $game_message.choice_proc.call(index)
- update_move_choice
- close
- end
- #--------------------------------------------------------------------------
- # * Call Cancel Handler
- #--------------------------------------------------------------------------
- def call_cancel_handler
- $limit_time = nil
- @begin_count = nil
- $game_system.choiceWaitTime = nil if AUTOMATIC_CHOICE::RESET_CHOICE_WAIT_TIME
- $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
- update_move_choice
- close
- end
- #--------------------------------------------------------------------------
- # * new method: dispose_choice_sprites
- #--------------------------------------------------------------------------
- def dispose_choice_sprites
- return if @choice_sprites.size > 0
- @choice_sprites.each do |sprite|
- sprite.bitmap.dispose
- sprite.dispose
- end
- @timer_sprite.bitmap.dispose
- @timer_sprite.dispose
- @timer_sprite = nil
- @cursor_sprite.bitmap.dispose
- @cursor_sprite.dispose
- @cursor_sprite = nil
- @choice_sprites.clear
- @choice_sprites = nil
- end
- #--------------------------------------------------------------------------
- # * new method: update_move_choice
- #--------------------------------------------------------------------------
- def update_move_choice
- return unless AUTOMATIC_CHOICE.automatic?
- start_time = Graphics.frame_count
- while (current_time = Graphics.frame_count - start_time ) < 45
- @choice_sprites.each do |sprite|
- sprite.x = easeInOutQuad(current_time, sprite.start_x, sprite.change_x, 45)
- @cursor_sprite.opacity = easeInOutQuad(current_time, 255, -255, 45)
- @timer_sprite.x = easeInOutQuad(current_time, 0, -50, 45)
- @timer_sprite.opacity = easeInOutQuad(current_time, 255, -255, 45)
- end
- Graphics.update
- end
- dispose_choice_sprites
- end
- end # Window_ChoiceList
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * new method: setChoiceWaitTime
- #--------------------------------------------------------------------------
- def setChoiceWaitTime(wait_time)
- $game_system.choiceWaitTime = wait_time
- end
- end
- class Game_System
- attr_accessor :choiceWaitTime
- end # Game_System
- class Sprite
- attr_accessor :start_x
- attr_accessor :change_x
- end # Sprite
- #===============================================================================
- # * END OF FILE
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement