Added the animation properties pop-up window

This commit is contained in:
Maruno17
2023-12-02 01:39:43 +00:00
parent b69f1fc5a6
commit b4e7b765d1
247 changed files with 203 additions and 1245 deletions

View File

@@ -13,11 +13,12 @@
# don't think is ideal.
#===============================================================================
class UIControls::ControlsContainer
attr_reader :x, :y
attr_reader :controls
attr_reader :values
attr_reader :visible
attr_reader :viewport
attr_reader :x, :y
attr_accessor :label_offset_x, :label_offset_y
attr_reader :controls
attr_reader :values
attr_reader :visible
attr_reader :viewport
LINE_SPACING = 28
OFFSET_FROM_LABEL_X = 90
@@ -30,6 +31,8 @@ class UIControls::ControlsContainer
@y = y
@width = width
@height = height
@label_offset_x = OFFSET_FROM_LABEL_X
@label_offset_y = OFFSET_FROM_LABEL_Y
@controls = []
@row_count = 0
@pixel_offset = 0
@@ -196,7 +199,7 @@ class UIControls::ControlsContainer
def control_size(has_label = false)
if has_label
return @width - OFFSET_FROM_LABEL_X, LINE_SPACING - OFFSET_FROM_LABEL_Y
return @width - @label_offset_x, LINE_SPACING - @label_offset_y
end
return @width, LINE_SPACING
end
@@ -213,9 +216,9 @@ class UIControls::ControlsContainer
i = @controls.length
row_x = 0
row_y = (add_offset ? @row_count - 1 : @row_count) * LINE_SPACING
ctrl_x = row_x + (add_offset ? OFFSET_FROM_LABEL_X : 0)
ctrl_x = row_x + (add_offset ? @label_offset_x : 0)
ctrl_x += 4 if control.is_a?(UIControls::List)
ctrl_y = row_y + (add_offset ? OFFSET_FROM_LABEL_Y : 0) + @pixel_offset
ctrl_y = row_y + (add_offset ? @label_offset_y : 0) + @pixel_offset
add_control_at(id, control, ctrl_x, ctrl_y)
@row_count += rows if !add_offset
@pixel_offset -= (LINE_SPACING - UIControls::List::ROW_HEIGHT) * (rows - 1) if control.is_a?(UIControls::List)

View File

@@ -1,4 +1,3 @@
# TODO: Add "disabled" greying out/non-editable.
# TODO: Add indicator of whether the control's value is "lerping" between frames
# (use yellow somehow?).

View File

@@ -2,19 +2,19 @@
#
#===============================================================================
class UIControls::Label < UIControls::BaseControl
attr_reader :label
attr_reader :text
LABEL_END_X = 80
TEXT_OFFSET_Y = 5
def initialize(width, height, viewport, label)
def initialize(width, height, viewport, text)
super(width, height, viewport)
@label = label
@text = text
@header = false
end
def label=(value)
@label = value
def text=(value)
@text = value
refresh
end
@@ -26,11 +26,11 @@ class UIControls::Label < UIControls::BaseControl
def refresh
super
if @header
draw_text_centered(self.bitmap, 0, TEXT_OFFSET_Y, width, @label)
text_size = self.bitmap.text_size(@label)
draw_text_centered(self.bitmap, 0, TEXT_OFFSET_Y, width, @text)
text_size = self.bitmap.text_size(@text)
self.bitmap.fill_rect((width - text_size.width) / 2, TEXT_OFFSET_Y + text_size.height, text_size.width, 1, TEXT_COLOR)
else
draw_text(self.bitmap, 4, TEXT_OFFSET_Y, @label)
draw_text(self.bitmap, 4, TEXT_OFFSET_Y, @text)
end
end
end

View File

@@ -7,7 +7,7 @@
#===============================================================================
class UIControls::TextBox < UIControls::BaseControl
TEXT_BOX_X = 2
TEXT_BOX_WIDTH = 172
TEXT_BOX_WIDTH = 200
TEXT_BOX_HEIGHT = 24
TEXT_BOX_PADDING = 4 # Gap between sides of text box and text
TEXT_OFFSET_Y = 5

View File

@@ -3,18 +3,21 @@
#===============================================================================
class UIControls::DropdownList < UIControls::BaseControl
TEXT_BOX_X = 2
TEXT_BOX_WIDTH = 172
TEXT_BOX_WIDTH = 200
TEXT_BOX_HEIGHT = 24
TEXT_BOX_PADDING = 4 # Gap between sides of text box and text
TEXT_OFFSET_Y = 5
MAX_LIST_ROWS = 8
attr_accessor :max_rows
def initialize(width, height, viewport, options, value)
# NOTE: options is a hash: keys are symbols, values are display names.
super(width, height, viewport)
@options = options
@value = value
@toggling_dropdown_list = false
@max_rows = MAX_LIST_ROWS
end
def dispose
@@ -46,7 +49,7 @@ class UIControls::DropdownList < UIControls::BaseControl
#-----------------------------------------------------------------------------
def make_dropdown_menu
menu_height = UIControls::List::ROW_HEIGHT * [@options.length, MAX_LIST_ROWS].min
menu_height = UIControls::List::ROW_HEIGHT * [@options.length, @max_rows].min
# Draw menu's background
@dropdown_menu_bg = BitmapSprite.new(@button_rect.width, menu_height + 4, self.viewport)
@dropdown_menu_bg.x = self.x + @button_rect.x