mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
Fixed new label dsl methods requiring options to be provided, upgraded Image to accept either a path or an image and to enable replacing image using #value=
This commit is contained in:
@@ -25,7 +25,7 @@ module CyberarmEngine
|
||||
"Para",
|
||||
"Inscription"
|
||||
].each do |const|
|
||||
define_method(:"#{const.downcase}") do |text, options, &block|
|
||||
define_method(:"#{const.downcase}") do |text, options = {}, &block|
|
||||
options[:parent] = element_parent
|
||||
options[:theme] = current_theme
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
module CyberarmEngine
|
||||
class Element
|
||||
class Image < Element
|
||||
def initialize(path, options = {}, block = nil)
|
||||
def initialize(path_or_image, options = {}, block = nil)
|
||||
super(options, block)
|
||||
@path = path
|
||||
@path = path_or_image if path_or_image.is_a?(String)
|
||||
|
||||
@image = Gosu::Image.new(path_or_image, retro: @options[:retro], tileable: @options[:tileable]) if @path
|
||||
@image = path_or_image unless @path
|
||||
|
||||
@image = Gosu::Image.new(path, retro: @options[:image_retro])
|
||||
@scale_x = 1
|
||||
@scale_y = 1
|
||||
end
|
||||
@@ -48,6 +50,19 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def value
|
||||
@image
|
||||
end
|
||||
|
||||
def value=(path_or_image, retro: false, tileable: false)
|
||||
@path = path_or_image if path_or_image.is_a?(String)
|
||||
|
||||
@image = Gosu::Image.new(path_or_image, retro: retro, tileable: tileable) if @path
|
||||
@image = path_or_image unless @path
|
||||
|
||||
recalculate
|
||||
end
|
||||
|
||||
def path
|
||||
@path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,6 +103,7 @@ module CyberarmEngine
|
||||
|
||||
Image: { # < Element
|
||||
color: Gosu::Color::WHITE,
|
||||
tileable: false,
|
||||
retro: false
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user