class Window_Selectable FRAMES_FOR_MOVEMENT = 10 # should not be to big or to small ~(8-20) #-------------------------------------------------------------------------- # * Update cursor #-------------------------------------------------------------------------- def update_cursor if @new_rect.nil? if @index < 0 # If the cursor position is less than 0 self.cursor_rect.empty # Empty cursor else # If the cursor position is 0 or more row = @index / @column_max # Get current row if row < top_row # If before the currently displayed self.top_row = row # Scroll up end if row > bottom_row # If after the currently displayed self.bottom_row = row # Scroll down end rect = item_rect(@index) # Get rectangle of selected item rect.y -= self.oy # Match rectangle to scroll position @new_rect = self.cursor_rect == rect ? nil : rect if !@new_rect.nil? @pixel_to_move_x = ((@new_rect.x - self.cursor_rect.x)/FRAMES_FOR_MOVEMENT).to_i @pixel_to_move_y = ((@new_rect.y - self.cursor_rect.y)/FRAMES_FOR_MOVEMENT).to_i else @pixel_to_move_x = 0 @pixel_to_move_y = 0 end end else if self.cursor_rect != @new_rect if (self.cursor_rect.x - @new_rect.x).abs <= @pixel_to_move_x.abs self.cursor_rect.x += @pixel_to_move_x < 0 ? -(self.cursor_rect.x - @new_rect.x).abs : (self.cursor_rect.x - @new_rect.x).abs else self.cursor_rect.x += @pixel_to_move_x end if (self.cursor_rect.y - @new_rect.y).abs <= @pixel_to_move_y.abs self.cursor_rect.y += @pixel_to_move_y < 0 ? -(self.cursor_rect.y - @new_rect.y).abs : (self.cursor_rect.y - @new_rect.y).abs else self.cursor_rect.y += @pixel_to_move_y end else @new_rect = nil end end end alias index_slide_cursor index= unless $@ def index=(*args) index_slide_cursor(*args) rect = item_rect(@index) # Get rectangle of selected item rect.y -= self.oy # Match rectangle to scroll position self.cursor_rect = rect # Refresh cursor rectangle endend