mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Add menu bar to Animation Editor, some refactoring
This commit is contained in:
@@ -40,4 +40,22 @@ class AnimationEditor::Canvas < Sprite
|
||||
@message_bar_sprite.bitmap = RPG::Cache.load_bitmap("Graphics/Battlebacks/", @bg_name + "_message")
|
||||
@message_bar_sprite.y = Settings::SCREEN_HEIGHT - @message_bar_sprite.height
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def busy?
|
||||
return false
|
||||
end
|
||||
|
||||
def changed?
|
||||
return false
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def repaint
|
||||
end
|
||||
|
||||
def refresh
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,8 +77,8 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
@commands_bg_sprites = []
|
||||
@commands_sprites = []
|
||||
# Scrollbar positions
|
||||
@left_pos = 0
|
||||
@top_pos = 0
|
||||
@left_pos = 0
|
||||
@duration = 0
|
||||
# Selected things
|
||||
@keyframe = 0
|
||||
@@ -93,8 +93,6 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
|
||||
def draw_control_background
|
||||
self.bitmap.clear
|
||||
# Background
|
||||
self.bitmap.fill_rect(0, 0, width, height, Color.white)
|
||||
# Separator lines
|
||||
self.bitmap.fill_rect(0, TIMELINE_HEIGHT, width, VIEWPORT_SPACING, Color.black)
|
||||
self.bitmap.fill_rect(LIST_WIDTH, 0, VIEWPORT_SPACING, height, Color.black)
|
||||
@@ -132,21 +130,6 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
return (ret.is_a?(Array)) ? ret[0] : ret
|
||||
end
|
||||
|
||||
def left_pos=(val)
|
||||
old_val = @left_pos
|
||||
total_width = (@duration * KEYFRAME_SPACING) + TIMELINE_LEFT_BUFFER + 1
|
||||
if total_width <= @commands_viewport.rect.width
|
||||
@left_pos = 0
|
||||
else
|
||||
@left_pos = val
|
||||
@left_pos = @left_pos.clamp(0, total_width - @commands_viewport.rect.width)
|
||||
end
|
||||
if @left_pos != old_val
|
||||
refresh_position_line
|
||||
invalidate_time
|
||||
end
|
||||
end
|
||||
|
||||
def top_pos=(val)
|
||||
old_val = @top_pos
|
||||
total_height = (@particle_list.length * ROW_HEIGHT) + 1
|
||||
@@ -165,6 +148,21 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
end
|
||||
end
|
||||
|
||||
def left_pos=(val)
|
||||
old_val = @left_pos
|
||||
total_width = (@duration * KEYFRAME_SPACING) + TIMELINE_LEFT_BUFFER + 1
|
||||
if total_width <= @commands_viewport.rect.width
|
||||
@left_pos = 0
|
||||
else
|
||||
@left_pos = val
|
||||
@left_pos = @left_pos.clamp(0, total_width - @commands_viewport.rect.width)
|
||||
end
|
||||
if @left_pos != old_val
|
||||
refresh_position_line
|
||||
invalidate_time
|
||||
end
|
||||
end
|
||||
|
||||
def set_particles(particles)
|
||||
@particles = particles
|
||||
calculate_all_commands_and_durations
|
||||
@@ -204,8 +202,8 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
# Set scrollbars to the correct lengths
|
||||
@list_scrollbar.range = (@particle_list.length * ROW_HEIGHT) + 1
|
||||
@time_scrollbar.range = (@duration * KEYFRAME_SPACING) + TIMELINE_LEFT_BUFFER + 1
|
||||
self.left_pos = @left_pos
|
||||
self.top_pos = @top_pos
|
||||
self.top_pos = @list_scrollbar.position
|
||||
self.left_pos = @time_scrollbar.position
|
||||
# Redraw all sprites
|
||||
invalidate
|
||||
end
|
||||
@@ -576,6 +574,7 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
end
|
||||
|
||||
def refresh
|
||||
@old_top_pos = nil if @invalid
|
||||
draw_area_highlight
|
||||
refresh_timeline if @invalid || @invalid_time
|
||||
each_visible_particle do |i|
|
||||
@@ -719,8 +718,8 @@ class AnimationEditor::ParticleList < UIControls::BaseControl
|
||||
@time_scrollbar.update
|
||||
super
|
||||
# Refresh sprites if a scrollbar has been moved
|
||||
self.left_pos = @time_scrollbar.position
|
||||
self.top_pos = @list_scrollbar.position
|
||||
self.left_pos = @time_scrollbar.position
|
||||
# Update the current keyframe line's position
|
||||
refresh_position_line
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#===============================================================================
|
||||
# TODO: Ideally the menu buttons (add_button) will be replaced by a proper
|
||||
# menu control (basically multiple DropdownList controls where the headers
|
||||
# have fixed names and, while captured, hovering over a header changes
|
||||
# which list is displayed). The menu control should go under UI controls
|
||||
# rather than be unique to the Animation Editor.
|
||||
#===============================================================================
|
||||
class AnimationEditor::MenuBar < UIControls::ControlsContainer
|
||||
MENU_BUTTON_WIDTH = 80
|
||||
NAME_BUTTON_WIDTH = 400 # The animation's name
|
||||
|
||||
def initialize(x, y, width, height, viewport)
|
||||
super(x, y, width, height)
|
||||
@viewport.z = viewport.z + 10 # So that it appears over the canvas
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def add_button(id, button_text)
|
||||
ctrl = UIControls::Button.new(MENU_BUTTON_WIDTH, @height, @viewport, button_text)
|
||||
ctrl.set_fixed_size
|
||||
add_control(id, ctrl)
|
||||
end
|
||||
|
||||
def add_name_button(id, button_text)
|
||||
ctrl = UIControls::Button.new(NAME_BUTTON_WIDTH, @height, @viewport, button_text)
|
||||
ctrl.set_fixed_size
|
||||
add_control(id, ctrl)
|
||||
end
|
||||
|
||||
def anim_name=(val)
|
||||
ctrl = get_control(:name)
|
||||
ctrl.set_text(val) if ctrl
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
private
|
||||
|
||||
def add_control(id, control, add_offset = false)
|
||||
i = @controls.length
|
||||
control_x = (add_offset ? @row_count - 1 : @row_count) * MENU_BUTTON_WIDTH
|
||||
control_x = @width - control.width if control.width == NAME_BUTTON_WIDTH
|
||||
@control_rects[i] = Rect.new(control_x, 0, control.width, control.height)
|
||||
control.x = @control_rects[i].x + (add_offset ? OFFSET_FROM_LABEL_X : 0)
|
||||
control.y = @control_rects[i].y + (add_offset ? OFFSET_FROM_LABEL_Y : 0)
|
||||
control.set_interactive_rects
|
||||
@controls[i] = [id, control]
|
||||
@row_count += 1 if !add_offset
|
||||
repaint
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user