Anim Editor: added FoeFlip property, Space to play, S to swap sides, P to show/hide property lines for selected particle

This commit is contained in:
Maruno17
2024-04-18 22:35:15 +01:00
parent 15033d6114
commit 4480def33c
23 changed files with 264 additions and 161 deletions

View File

@@ -457,6 +457,7 @@ class AnimationEditor
break
end
end
break if Input.triggerex?(:SPACE)
break if anim_player.finished?
end
anim_player.dispose
@@ -741,6 +742,15 @@ class AnimationEditor
end
end
def update_input
if Input.triggerex?(:S)
@settings[:user_opposes] = !@settings[:user_opposes]
refresh
elsif Input.triggerex?(:SPACE)
@ready_to_play = true
end
end
def update
old_keyframe = keyframe
old_particle_index = particle_index
@@ -769,6 +779,7 @@ class AnimationEditor
break
end
end
update_input
end
#-----------------------------------------------------------------------------

View File

@@ -58,7 +58,7 @@ class AnimationEditor
ret = btn[0]
break
end
ret = :cancel if Input.trigger?(Input::BACK)
ret = :cancel if Input.triggerex?(:ESCAPE)
break if ret
buttons.each { |btn| btn[1].repaint }
end
@@ -110,7 +110,7 @@ class AnimationEditor
end
anim_properties.clear_changed
end
break if !anim_properties.busy? && Input.trigger?(Input::BACK)
break if !anim_properties.busy? && Input.triggerex?(:ESCAPE)
anim_properties.repaint
end
# Dispose and return
@@ -242,10 +242,13 @@ class AnimationEditor
end
graphic_chooser.clear_changed
end
ret = selected if !graphic_chooser.busy? && Input.trigger?(Input::BACK)
break if ret
graphic_chooser.repaint
end
if !graphic_chooser.busy? && Input.triggerex?(:ESCAPE)
ret = selected
break
end
end
# Dispose and return
bg_bitmap.dispose
@@ -315,13 +318,14 @@ class AnimationEditor
end
audio_chooser.clear_changed
end
if !audio_chooser.busy? && Input.trigger?(Input::BACK)
ret = selected
cance = true
end
break if ret
audio_chooser.repaint
end
if !audio_chooser.busy? && Input.triggerex?(:ESCAPE)
ret = selected
cancel = true
break
end
end
vol = (cancel) ? volume : audio_chooser.get_control(:volume).value
ptch = (cancel) ? pitch : audio_chooser.get_control(:pitch).value
@@ -332,5 +336,4 @@ class AnimationEditor
audio_chooser.visible = false
return [ret, vol, ptch]
end
end

View File

@@ -480,6 +480,12 @@ AnimationEditor::SidePanes.add_property(:particle_pane, :graphic, {
new_file = editor.choose_graphic_file(editor.anim[:particles][p_index][:graphic])
if editor.anim[:particles][p_index][:graphic] != new_file
editor.anim[:particles][p_index][:graphic] = new_file
if ["USER", "USER_BACK", "USER_FRONT", "USER_OPP",
"TARGET", "TARGET_FRONT", "TARGET_BACK", "TARGET_OPP"].include?(new_file)
editor.anim[:particles][p_index].delete(:frame)
editor.components[:particle_list].set_particles(editor.anim[:particles])
editor.refresh_component(:particle_list)
end
editor.refresh_component(:particle_pane)
editor.refresh_component(:canvas)
end
@@ -552,6 +558,20 @@ AnimationEditor::SidePanes.add_property(:particle_pane, :foe_invert_y, {
}
})
AnimationEditor::SidePanes.add_property(:particle_pane, :foe_flip, {
:new => proc { |pane, editor|
pane.add_labelled_checkbox(:foe_flip, _INTL("Flip Sprite"), false)
},
:refresh_value => proc { |control, editor|
focus = editor.anim[:particles][editor.particle_index][:focus]
if GameData::Animation::FOCUS_TYPES_WITH_USER.include?(focus) == GameData::Animation::FOCUS_TYPES_WITH_TARGET.include?(focus)
control.disable
else
control.enable
end
}
})
AnimationEditor::SidePanes.add_property(:particle_pane, :duplicate, {
:new => proc { |pane, editor|
pane.add_button(:duplicate, _INTL("Duplicate this particle"))

View File

@@ -194,7 +194,7 @@ class AnimationEditor::AnimationSelector
ret = btn[0]
break
end
ret = :cancel if Input.trigger?(Input::BACK)
ret = :cancel if Input.triggerex?(:ESCAPE)
break if ret
buttons.each { |btn| btn[1].repaint }
end

View File

@@ -475,6 +475,7 @@ class AnimationEditor::Canvas < Sprite
spr.zoom_y = values[:zoom_y] / 100.0
spr.angle = values[:angle]
spr.mirror = values[:flip]
spr.mirror = !spr.mirror if relative_to_index >= 0 && relative_to_index.odd? && particle[:foe_flip]
spr.blend_type = values[:blending]
# Set color and tone
spr.color.set(values[:color_red], values[:color_green], values[:color_blue], values[:color_alpha])

View File

@@ -5,9 +5,9 @@ class AnimationEditor::PlayControls < UIControls::ControlsContainer
attr_reader :slowdown, :looping
ROW_HEIGHT = 28
PLAY_BUTTON_X = 241
PLAY_BUTTON_Y = 13
PLAY_BUTTON_SIZE = 22
PLAY_BUTTON_X = 231
PLAY_BUTTON_Y = 3
PLAY_BUTTON_SIZE = 42
LOOP_BUTTON_X = PLAY_BUTTON_X + PLAY_BUTTON_SIZE + 12
LOOP_BUTTON_Y = 16
LOOP_BUTTON_SIZE = 16
@@ -34,7 +34,8 @@ class AnimationEditor::PlayControls < UIControls::ControlsContainer
end
def dispose
@bitmaps.each { |b| b&.dispose }
@bitmaps.each_value { |b| b&.dispose }
@bitmaps.clear
super
end
@@ -43,12 +44,12 @@ class AnimationEditor::PlayControls < UIControls::ControlsContainer
def generate_button_bitmaps
@bitmaps = {}
play_button = Bitmap.new(PLAY_BUTTON_SIZE, PLAY_BUTTON_SIZE)
(PLAY_BUTTON_SIZE - 2).times do |j|
play_button.fill_rect(PLAY_BUTTON_SIZE / 4, j + 1, (j >= (PLAY_BUTTON_SIZE - 2) / 2) ? PLAY_BUTTON_SIZE - j : j + 3, 1, ICON_COLOR)
(PLAY_BUTTON_SIZE - 10).times do |j|
play_button.fill_rect(11, j + 5, (j >= (PLAY_BUTTON_SIZE - 10) / 2) ? PLAY_BUTTON_SIZE - j - 4 : j + 7, 1, ICON_COLOR)
end
@bitmaps[:play_button] = play_button
stop_button = Bitmap.new(PLAY_BUTTON_SIZE, PLAY_BUTTON_SIZE)
stop_button.fill_rect(4, 4, PLAY_BUTTON_SIZE - 8, PLAY_BUTTON_SIZE - 8, ICON_COLOR)
stop_button.fill_rect(8, 8, PLAY_BUTTON_SIZE - 16, PLAY_BUTTON_SIZE - 16, ICON_COLOR)
@bitmaps[:stop_button] = stop_button
# Loop button
play_once_button = Bitmap.new(LOOP_BUTTON_SIZE, LOOP_BUTTON_SIZE)
@@ -79,6 +80,22 @@ class AnimationEditor::PlayControls < UIControls::ControlsContainer
end
def add_play_controls
# Slowdown label
duration_label = UIControls::Label.new(200, ROW_HEIGHT, self.viewport, _INTL("Slowdown factor"))
duration_label.x = SLOWDOWN_BUTTON_X + (SLOWDOWN_FACTORS.length * (SLOWDOWN_BUTTON_WIDTH + SLOWDOWN_BUTTON_SPACING) / 2)
duration_label.x -= (duration_label.text_width / 2) + 5
duration_label.y = SLOWDOWN_LABEL_Y
@controls.push([:slowdown_label, duration_label])
# Slowdown factor buttons
SLOWDOWN_FACTORS.each_with_index do |value, i|
button = UIControls::Button.new(SLOWDOWN_BUTTON_WIDTH, ROW_HEIGHT, self.viewport, value.to_s)
button.set_fixed_size
button.x = SLOWDOWN_BUTTON_X + ((SLOWDOWN_BUTTON_WIDTH + SLOWDOWN_BUTTON_SPACING) * i)
button.y = SLOWDOWN_BUTTON_Y
button.set_interactive_rects
button.set_highlighted if value == @slowdown
@controls.push([("slowdown" + value.to_s).to_sym, button])
end
# Play button
play_button = UIControls::BitmapButton.new(PLAY_BUTTON_X, PLAY_BUTTON_Y, self.viewport, @bitmaps[:play_button])
play_button.set_interactive_rects
@@ -98,22 +115,6 @@ class AnimationEditor::PlayControls < UIControls::ControlsContainer
unloop_button.set_interactive_rects
unloop_button.visible = false if !@looping
@controls.push([:unloop, unloop_button])
# Slowdown label
duration_label = UIControls::Label.new(200, ROW_HEIGHT, self.viewport, _INTL("Slowdown factor"))
duration_label.x = SLOWDOWN_BUTTON_X + (SLOWDOWN_FACTORS.length * (SLOWDOWN_BUTTON_WIDTH + SLOWDOWN_BUTTON_SPACING) / 2)
duration_label.x -= (duration_label.text_width / 2) + 5
duration_label.y = SLOWDOWN_LABEL_Y
@controls.push([:slowdown_label, duration_label])
# Slowdown factor buttons
SLOWDOWN_FACTORS.each_with_index do |value, i|
button = UIControls::Button.new(SLOWDOWN_BUTTON_WIDTH, ROW_HEIGHT, self.viewport, value.to_s)
button.set_fixed_size
button.x = SLOWDOWN_BUTTON_X + ((SLOWDOWN_BUTTON_WIDTH + SLOWDOWN_BUTTON_SPACING) * i)
button.y = SLOWDOWN_BUTTON_Y
button.set_interactive_rects
button.set_highlighted if value == @slowdown
@controls.push([("slowdown" + value.to_s).to_sym, button])
end
# Duration label
duration_label = UIControls::Label.new(200, ROW_HEIGHT, self.viewport, _INTL("Duration"))
duration_label.x = DURATION_TEXT_X - (duration_label.text_width / 2)

View File

@@ -175,7 +175,8 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
@particle_line_sprite.dispose
@controls.each { |c| c[1].dispose }
@controls.clear
@bitmaps.each { |b| b&.dispose }
@bitmaps.each_value { |b| b&.dispose }
@bitmaps.clear
dispose_listed_sprites
@list_viewport.dispose
@commands_bg_viewport.dispose
@@ -433,16 +434,16 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
#-----------------------------------------------------------------------------
def calculate_duration
@duration = AnimationPlayer::Helper.get_duration(@particles)
@duration += DURATION_BUFFER
end
def calculate_all_commands_and_durations
calculate_duration
calculate_all_commands
end
def calculate_duration
@duration = AnimationPlayer::Helper.get_duration(@particles)
@duration += DURATION_BUFFER
end
def calculate_all_commands
@commands = {}
@particles.each_with_index do |particle, index|
@@ -1024,13 +1025,13 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
def update_input
# Left/right to change current keyframe
if Input.repeat?(Input::LEFT)
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
if @keyframe > 0
@keyframe -= 1
scroll_to_keyframe(@keyframe)
set_changed
end
elsif Input.repeat?(Input::RIGHT)
elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT)
if @keyframe < @duration - 1
@keyframe += 1
scroll_to_keyframe(@keyframe)
@@ -1038,7 +1039,7 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
end
end
# Up/down to change selected particle
if Input.repeat?(Input::UP)
if Input.triggerex?(:UP) || Input.repeatex?(:UP)
if @row_index > 0
loop do
@row_index -= 1
@@ -1047,7 +1048,7 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
scroll_to_row(@row_index)
set_changed
end
elsif Input.repeat?(Input::DOWN)
elsif Input.triggerex?(:DOWN) || Input.repeatex?(:DOWN)
if @row_index < @particle_list.length - 1
old_row_index = @row_index
loop do
@@ -1064,6 +1065,18 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
end
end
end
if Input.triggerex?(:P)
idx_particle = @particle_list[@row_index]
idx_particle = idx_particle[0] if idx_particle.is_a?(Array)
if @row_index >= 0 && @particles[idx_particle][:name] != "SE"
if @expanded_particles.include?(idx_particle) # Contract
@expanded_particles.delete(idx_particle)
else # Expand
@expanded_particles.push(idx_particle)
end
set_particles(@particles)
end
end
# Mouse scroll wheel
mouse_x, mouse_y = mouse_pos
if mouse_x && mouse_y