Anim Editor: added NoUser property, added buttons to duplicate/delete particle and delete single commands

This commit is contained in:
Maruno17
2024-02-29 00:54:01 +00:00
parent 67acf46859
commit f0fae4b9ec
10 changed files with 229 additions and 62 deletions

View File

@@ -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

View File

@@ -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