The cursor appears to jump back to the start of the selectable column, before gliding down to the last selected option. Is there a way to fix this so that it appears on the last selected option?
(To see this for yourself, go into the menu, scroll down to something like items/formation, then select that option, then press esc to leave that option and return to the main menu - by which point, the cursor will jump.)
Thanks!
(P.S: I cannot find the original topic where I got it from - apologies :S)
(To see this for yourself, go into the menu, scroll down to something like items/formation, then select that option, then press esc to leave that option and return to the main menu - by which point, the cursor will jump.)
Thanks!
(P.S: I cannot find the original topic where I got it from - apologies :S)
Code:
#==============================================================================# ** Zane - Smooth Cursor# Version 1.0.0#------------------------------------------------------------------------------# * Release History:# - 1.0.0 Wrote Script#------------------------------------------------------------------------------# * Features:# - Smooth moving cursor#------------------------------------------------------------------------------# * How to Use:# Paste below materials but above main.#------------------------------------------------------------------------------# * License:# - Do not distribute this work anywhere. PM me if your going Commercial.# If you really want to share it, post a link back to the original thread.#============================================================================== #==============================================================================# ** Serialize script into Global#------------------------------------------------------------------------------($imported ||= {}) [:Zane_Smooth_Cursor] = true#============================================================================== #==============================================================================# ** Rect#------------------------------------------------------------------------------# This is the super class of Rectangle.#============================================================================== class Rect #-------------------------------------------------------------------------- # * Determine if Rectangle is empty #-------------------------------------------------------------------------- def empty? ; x == 0 and y == 0 and width == 0 and height == 0 endend #==============================================================================# ** Window_Selectable#------------------------------------------------------------------------------# This window class contains cursor movement and scroll functions.#============================================================================== class Window_Selectable < Window_Base #-------------------------------------------------------------------------- # * Create Struct Class to hold initialize settings #-------------------------------------------------------------------------- Rect_Ani_Settings = Struct.new(:x, :y, :width, :height, :real_x, :real_y, :real_width, :real_height, :x_speed, :y_speed, :width_speed, :height_speed) #-------------------------------------------------------------------------- # * Alias Methods #-------------------------------------------------------------------------- alias :zane_smooth_cursor_initialize :initialize alias :zane_smooth_cursor_cursor_movable? :cursor_movable? alias :zane_smooth_cursor_process_handling :process_handling alias :zane_smooth_cursor_update :update alias :zane_smooth_cursor_update_cursor :update_cursor #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(*args, &block) zane_smooth_cursor_initialize(*args, &block) end #-------------------------------------------------------------------------- # * Determine if Cursor is Moveable #-------------------------------------------------------------------------- def cursor_movable?(*args, &block) return false if cursor_rect_moving? zane_smooth_cursor_cursor_movable?(*args, &block) end #-------------------------------------------------------------------------- # * Handling Processing for OK and Cancel Etc. #-------------------------------------------------------------------------- def process_handling(*args, &block) return if cursor_rect_moving? zane_smooth_cursor_process_handling(*args, &block) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update(*args, &block) zane_smooth_cursor_update(*args, &block) update_cursor_rect_movement end #-------------------------------------------------------------------------- # * Update Cursor #-------------------------------------------------------------------------- def update_cursor(*args, &block) if @cursor_all cursor_rect.set(0, 0, contents.width, row_max * item_height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible move_cursor_rect(item_rect(@index), cursor_rect.empty? ? 0 : 6) end else zane_smooth_cursor_update_cursor(*args, &block) end #-------------------------------------------------------------------------- # * Instantly Update Cursor #-------------------------------------------------------------------------- def instantly_update_cursor zane_smooth_cursor_update_cursor end #-------------------------------------------------------------------------- # * Instantly Select Item #-------------------------------------------------------------------------- def instantly_select(index) self.index = index if index instantly_update_cursor @cursor_rect_movement = nil end #-------------------------------------------------------------------------- # * Determine if Cursor is Moving #-------------------------------------------------------------------------- def cursor_rect_moving? return false if @cursor_rect_movement.nil? move = @cursor_rect_movement return (move.real_x != move.x or move.real_y != move.y or move.real_width != move.width or move.real_height != move.height) end #-------------------------------------------------------------------------- # * Update Cursor Rect Movement #-------------------------------------------------------------------------- def update_cursor_rect_movement return if @cursor_rect_movement.nil? move = @cursor_rect_movement cursor_rect.x = move.real_x = [move.real_x - move.x_speed, move.x].max if move.real_x > move.x cursor_rect.x = move.real_x = [move.real_x + move.x_speed, move.x].min if move.real_x < move.x cursor_rect.y = move.real_y = [move.real_y - move.y_speed, move.y].max if move.real_y > move.y cursor_rect.y = move.real_y = [move.real_y + move.y_speed, move.y].min if move.real_y < move.y cursor_rect.width = move.real_width = [move.real_width - move.width_speed, move.width].max if move.real_width > move.width cursor_rect.width = move.real_width = [move.real_width + move.width_speed, move.width].min if move.real_width < move.width cursor_rect.height = move.real_height = [move.real_height - move.height_speed, move.height].max if move.real_height > move.height cursor_rect.height = move.real_height = [move.real_height + move.height_speed, move.height].min if move.real_height < move.height @cursor_rect_movement = nil if !cursor_rect_moving? end #-------------------------------------------------------------------------- # * Move Cursor Rect #-------------------------------------------------------------------------- def move_cursor_rect(rect, dur = 6) return cursor_rect.set(rect) if dur <= 0 @cursor_rect_movement = Rect_Ani_Settings.new @cursor_rect_movement.x = rect.x @cursor_rect_movement.y = rect.y @cursor_rect_movement.height = rect.height @cursor_rect_movement.width = rect.width @cursor_rect_movement.real_x = cursor_rect.x @cursor_rect_movement.real_y = cursor_rect.y @cursor_rect_movement.real_width = cursor_rect.width @cursor_rect_movement.real_height = cursor_rect.height @cursor_rect_movement.x_speed = (cursor_rect.x - rect.x).abs.to_f / dur @cursor_rect_movement.y_speed = (cursor_rect.y - rect.y).abs.to_f / dur @cursor_rect_movement.width_speed = (cursor_rect.width - rect.width).abs.to_f / dur @cursor_rect_movement.height_speed = (cursor_rect.height - rect.height).abs.to_f / dur endend