mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 22:36:03 +00:00
Anim Editor: added NoUser property, added buttons to duplicate/delete particle and delete single commands
This commit is contained in:
@@ -14,13 +14,14 @@ class UIControls::ControlsContainer
|
||||
OFFSET_FROM_LABEL_X = 90
|
||||
OFFSET_FROM_LABEL_Y = 0
|
||||
|
||||
def initialize(x, y, width, height)
|
||||
def initialize(x, y, width, height, right_margin = 0)
|
||||
@viewport = Viewport.new(x, y, width, height)
|
||||
@viewport.z = 99999
|
||||
@x = x
|
||||
@y = y
|
||||
@width = width
|
||||
@height = height
|
||||
@right_margin = right_margin
|
||||
@label_offset_x = OFFSET_FROM_LABEL_X
|
||||
@label_offset_y = OFFSET_FROM_LABEL_Y
|
||||
@controls = []
|
||||
@@ -193,7 +194,7 @@ class UIControls::ControlsContainer
|
||||
|
||||
def control_size(has_label = false)
|
||||
if has_label
|
||||
return @width - @label_offset_x, LINE_SPACING - @label_offset_y
|
||||
return @width - @label_offset_x - @right_margin, LINE_SPACING - @label_offset_y
|
||||
end
|
||||
return @width, LINE_SPACING
|
||||
end
|
||||
|
||||
@@ -41,9 +41,14 @@ class UIControls::NumberTextBox < UIControls::TextBox
|
||||
self.invalidate
|
||||
end
|
||||
|
||||
# TODO: If current value is 0, replace it with ch instead of inserting ch?
|
||||
def insert_char(ch)
|
||||
self.value = @value.to_s.insert(@cursor_pos, ch).to_i
|
||||
def insert_char(ch, index = -1)
|
||||
old_val = @value
|
||||
if @value == 0
|
||||
@value = ch.to_i
|
||||
else
|
||||
self.value = @value.to_s.insert((index >= 0) ? index : @cursor_pos, ch).to_i
|
||||
end
|
||||
return if @value == old_val
|
||||
@cursor_pos += 1
|
||||
@cursor_pos = @cursor_pos.clamp(0, @value.to_s.length)
|
||||
@cursor_timer = System.uptime
|
||||
@@ -107,17 +112,20 @@ class UIControls::NumberTextBox < UIControls::TextBox
|
||||
def update_text_entry
|
||||
ret = false
|
||||
Input.gets.each_char do |ch|
|
||||
next if !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-"].include?(ch)
|
||||
if ch == "-"
|
||||
next if @min_value >= 0 || @cursor_pos > 1 || (@cursor_pos > 0 && @value >= 0)
|
||||
if @value < 0
|
||||
case ch
|
||||
when "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||
insert_char(ch)
|
||||
ret = true
|
||||
when "-", "+"
|
||||
if @value > 0 && @min_value < 0 && ch == "-"
|
||||
insert_char(ch, 0) # Add a negative sign at the start
|
||||
ret = true
|
||||
elsif @value < 0
|
||||
delete_at(0) # Remove the negative sign
|
||||
ret = true
|
||||
next
|
||||
end
|
||||
next
|
||||
end
|
||||
insert_char(ch)
|
||||
ret = true
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
class UIControls::BitmapButton < UIControls::Button
|
||||
BUTTON_PADDING = 4
|
||||
|
||||
def initialize(x, y, viewport, button_bitmap)
|
||||
def initialize(x, y, viewport, button_bitmap, disabled_bitmap = nil)
|
||||
super(button_bitmap.width + (BUTTON_PADDING * 2), button_bitmap.height + (BUTTON_PADDING * 2), viewport)
|
||||
self.x = x
|
||||
self.y = y
|
||||
@button_bitmap = button_bitmap
|
||||
@disabled_bitmap = disabled_bitmap
|
||||
end
|
||||
|
||||
def set_interactive_rects
|
||||
@@ -24,7 +25,12 @@ class UIControls::BitmapButton < UIControls::Button
|
||||
def refresh
|
||||
super
|
||||
# Draw button bitmap
|
||||
self.bitmap.blt(BUTTON_PADDING, BUTTON_PADDING, @button_bitmap,
|
||||
Rect.new(0, 0, @button_bitmap.width, @button_bitmap.height))
|
||||
if @disabled_bitmap && disabled?
|
||||
self.bitmap.blt(BUTTON_PADDING, BUTTON_PADDING, @disabled_bitmap,
|
||||
Rect.new(0, 0, @disabled_bitmap.width, @disabled_bitmap.height))
|
||||
else
|
||||
self.bitmap.blt(BUTTON_PADDING, BUTTON_PADDING, @button_bitmap,
|
||||
Rect.new(0, 0, @button_bitmap.width, @button_bitmap.height))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user