Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Window_Message
- #--------------------------------------------------------------------------
- # * Choice Input Processing
- #--------------------------------------------------------------------------
- def input_choice
- $limit_time = 0
- @choice_window.start
- Fiber.yield while @choice_window.active
- end
- end
- #==============================================================================
- # ** Window_ChoiceList
- #------------------------------------------------------------------------------
- # This window is used for the event command [Show Choices].
- #==============================================================================
- class Window_ChoiceList < Window_Command
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(message_window)
- @message_window = message_window
- super(0, 0)
- self.openness = 0
- deactivate
- end
- #--------------------------------------------------------------------------
- # * Start Input Processing
- #--------------------------------------------------------------------------
- def start
- self.opacity = 0
- update_placement
- refresh
- select(0)
- open
- activate
- end
- def update
- super
- if $limit_time && $limit_time < 120
- $limit_time += 1
- elsif $limit_time
- p "Time up"
- process_ok
- $limit_time = nil
- end
- end
- #--------------------------------------------------------------------------
- # * Update Window Position
- #--------------------------------------------------------------------------
- def update_placement
- self.width = [max_choice_width + 12, 96].max + padding * 2
- self.width = [width, Graphics.width].min
- self.height = fitting_height($game_message.choices.size)
- self.x = Graphics.width - width
- if @message_window.y >= Graphics.height / 2
- self.y = @message_window.y - height
- else
- self.y = @message_window.y + @message_window.height
- end
- @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
- des_x = (Graphics.width - choice_bitmap.width) * 0.5
- $game_message.choices.size.times do |i|
- c_sprite = Sprite.new
- c_sprite.x = i % 2 == 0 ? -choice_bitmap.width : Graphics.width
- c_sprite.start_x = x
- p c_sprite.x
- c_sprite.y = start_y + i*distance
- c_sprite.bitmap = choice_bitmap
- @choice_sprites << c_sprite
- end
- start_time = Graphics.frame_count
- while (current_time = Graphics.frame_count - start_time ) < 60
- @choice_sprites.each do |sprite|
- sprite.x = easeInOutQuad(current_time, sprite.start_x, des_x - sprite.start_x, 60)
- Fiber.yield
- end
- Graphics.update
- end
- 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
- #--------------------------------------------------------------------------
- # * Get Maximum Width of Choices
- #--------------------------------------------------------------------------
- def max_choice_width
- $game_message.choices.collect {|s| text_size(s).width }.max
- end
- #--------------------------------------------------------------------------
- # * Calculate Height of Window Contents
- #--------------------------------------------------------------------------
- def contents_height
- item_max * item_height
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- $game_message.choices.each do |choice|
- add_command(choice, :choice)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect_for_text(index)
- draw_text_ex(rect.x, rect.y, command_name(index))
- end
- #--------------------------------------------------------------------------
- # * Get Activation State of Cancel Processing
- #--------------------------------------------------------------------------
- def cancel_enabled?
- $game_message.choice_cancel_type > 0
- end
- #--------------------------------------------------------------------------
- # * Call OK Handler
- #--------------------------------------------------------------------------
- def call_ok_handler
- $game_message.choice_proc.call(index)
- close
- end
- #--------------------------------------------------------------------------
- # * Call Cancel Handler
- #--------------------------------------------------------------------------
- def call_cancel_handler
- $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
- close
- end
- end
- class Sprite
- attr_accessor :start_x
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement