mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 05:34:58 +00:00
Anim Editor: added Insert/Delete keyboard shortcuts
This commit is contained in:
@@ -744,10 +744,40 @@ class AnimationEditor
|
||||
|
||||
def update_input
|
||||
if Input.triggerex?(:S)
|
||||
# Swap battler sides
|
||||
@settings[:user_opposes] = !@settings[:user_opposes]
|
||||
refresh
|
||||
elsif Input.triggerex?(:SPACE)
|
||||
# Play animation
|
||||
@ready_to_play = true
|
||||
elsif Input.triggerex?(:INSERT)
|
||||
# Insert empty keyframe for selected particle or all particles
|
||||
this_frame = keyframe
|
||||
if this_frame >= 0 && this_frame < @components[:particle_list].duration
|
||||
if Input.pressex?(:LSHIFT) || Input.pressex?(:RSHIFT)
|
||||
@anim[:particles].each do |particle|
|
||||
AnimationEditor::ParticleDataHelper.insert_frame(particle, this_frame)
|
||||
end
|
||||
else
|
||||
AnimationEditor::ParticleDataHelper.insert_frame(@anim[:particles][particle_index], this_frame)
|
||||
end
|
||||
@components[:particle_list].set_particles(@anim[:particles])
|
||||
refresh
|
||||
end
|
||||
elsif Input.triggerex?(:DELETE)
|
||||
# Delete keyframe for selected particle or all particles
|
||||
this_frame = keyframe
|
||||
if this_frame >= 0 && this_frame < @components[:particle_list].duration
|
||||
if Input.pressex?(:LSHIFT) || Input.pressex?(:RSHIFT)
|
||||
@anim[:particles].each do |particle|
|
||||
AnimationEditor::ParticleDataHelper.remove_frame(particle, this_frame)
|
||||
end
|
||||
else
|
||||
AnimationEditor::ParticleDataHelper.remove_frame(@anim[:particles][particle_index], this_frame)
|
||||
end
|
||||
@components[:particle_list].set_particles(@anim[:particles])
|
||||
refresh
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ module AnimationEditor::ParticleDataHelper
|
||||
def get_particle_commands_timeline(particle)
|
||||
ret = []
|
||||
durations = []
|
||||
particle.each_pair do |property, value|
|
||||
next if !value.is_a?(Array)
|
||||
value.each do |cmd|
|
||||
particle.each_pair do |property, values|
|
||||
next if !values.is_a?(Array) || values.empty?
|
||||
values.each do |cmd|
|
||||
ret[cmd[0]] = true
|
||||
if cmd[1] > 0
|
||||
ret[cmd[0] + cmd[1]] = true
|
||||
@@ -224,7 +224,7 @@ module AnimationEditor::ParticleDataHelper
|
||||
# * SetXYZ and MoveXYZ start - delete SetXYZ (leave MoveXYZ alone)
|
||||
# * SetXYZ and MoveXYZ end - (unlikely) delete both
|
||||
# * SetXYZ and MoveXYZ start and end - (unlikely) delete SetXYZ, merge Moves together
|
||||
def delete_command(particle, property, frame)
|
||||
def delete_command(particle, property, frame, full_delete = false)
|
||||
# Find all relevant commands
|
||||
set_now = nil
|
||||
move_ending_now = nil
|
||||
@@ -246,7 +246,7 @@ module AnimationEditor::ParticleDataHelper
|
||||
particle[property].delete(move_starting_now)
|
||||
elsif move_ending_now # Delete MoveXYZ ending now
|
||||
particle[property].delete(move_ending_now)
|
||||
elsif move_starting_now && !set_now # Turn into SetXYZ at its end point
|
||||
elsif move_starting_now && (full_delete || !set_now) # Turn into SetXYZ at its end point
|
||||
move_starting_now[0] += move_starting_now[1]
|
||||
move_starting_now[1] = 0
|
||||
move_starting_now[3] = nil
|
||||
@@ -457,6 +457,45 @@ module AnimationEditor::ParticleDataHelper
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Inserts an empty frame at the given frame. Delays all commands at or after
|
||||
# the given frame by 1, and increases the duration of all commands that
|
||||
# overlap the given frame.
|
||||
def insert_frame(particle, frame)
|
||||
particle.each_pair do |property, values|
|
||||
next if !values.is_a?(Array) || values.empty?
|
||||
values.each do |cmd|
|
||||
if cmd[0] >= frame
|
||||
cmd[0] += 1
|
||||
elsif cmd[0] < frame && cmd[0] + cmd[1] > frame
|
||||
cmd[1] += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Removes a frame at the given frame. Deletes all commands in that frame, then
|
||||
# brings all commands after the given frame earlier by 1, and reduces the
|
||||
# duration of all commands that overlap the given frame.
|
||||
def remove_frame(particle, frame)
|
||||
particle.keys.each do |property|
|
||||
next if !particle[property].is_a?(Array) || particle[property].empty?
|
||||
delete_command(particle, property, frame, true)
|
||||
end
|
||||
particle.delete_if { |property, values| values.is_a?(Array) && values.empty? }
|
||||
particle.each_pair do |key, values|
|
||||
next if !values.is_a?(Array) || values.empty?
|
||||
values.each do |cmd|
|
||||
if cmd[0] > frame
|
||||
cmd[0] -= 1
|
||||
elsif cmd[0] < frame && cmd[0] + cmd[1] > frame
|
||||
cmd[1] -= 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Creates a new particle and inserts it at index. If there is a particle above
|
||||
# the new one, the new particle will inherit its focus; otherwise it gets a
|
||||
# default focus of :foreground.
|
||||
|
||||
@@ -642,7 +642,7 @@ class AnimationEditor::Canvas < Sprite
|
||||
if GameData::Animation::FOCUS_TYPES_WITH_USER.include?(particle[:focus])
|
||||
relative_to_index = user_index
|
||||
elsif GameData::Animation::FOCUS_TYPES_WITH_TARGET.include?(particle[:focus])
|
||||
relative_to_index = target_idx
|
||||
relative_to_index = first_target_index
|
||||
end
|
||||
end
|
||||
new_pos *= -1 if relative_to_index >= 0 && relative_to_index.odd? && particle[:foe_invert_x]
|
||||
@@ -679,7 +679,7 @@ class AnimationEditor::Canvas < Sprite
|
||||
if GameData::Animation::FOCUS_TYPES_WITH_USER.include?(particle[:focus])
|
||||
relative_to_index = user_index
|
||||
elsif GameData::Animation::FOCUS_TYPES_WITH_TARGET.include?(particle[:focus])
|
||||
relative_to_index = target_idx
|
||||
relative_to_index = first_target_index
|
||||
end
|
||||
end
|
||||
new_pos *= -1 if relative_to_index >= 0 && relative_to_index.odd? && particle[:foe_invert_y]
|
||||
|
||||
Reference in New Issue
Block a user