Smooth Cursor Movement
Updates
18.11.2010: Publish
Was macht das Script?
Das Script überarbeitet die bisherige Bewegung des Cursors, der Klasse Window_Selectable. (Also fast alle Menüs.) Der Cursor springt nicht von Punkt zu Punkt, sondern bewegt sich von einem Punkt zum nächsten.
Wie nutze ich das Script?
Die Benutzung ist sehr einfach. Man muss nur die Anzahl an Frames auswählen, in denen sich der Cursor auf den neuen Punkt bewegen muss.
Schon kann es losgehen.
Demo
n.A.
Video
n.A.
Screenshots
n.A.
Das Script
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
end
end
Schlusswort
Bitte meldet alle Bugs, so kann das System optimiert werden. Es gibt keine bekannten Fehler, aber da eine Methode überschrieben wird, würde ich empfehlen, das Script möglichst weit oben einzufügen, wenn möglich direkt unter Window_Selectable.
MfG
Deity