mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 12:42:34 +00:00
Added Text#text_width method, Text#width now returns value of Text#markup_width
This commit is contained in:
@@ -61,7 +61,7 @@ module CyberarmEngine
|
||||
Gosu::Color::WHITE
|
||||
)
|
||||
|
||||
@title.x = window.width / 2 - @title.width / 2
|
||||
@title.x = window.width / 2 - @title.text_width / 2
|
||||
@title.y = (window.height / 2 + (@spacer_height / 2) + @padding) * @animators[1].transition
|
||||
@title.text = "Powered By"
|
||||
|
||||
@@ -115,14 +115,14 @@ module CyberarmEngine
|
||||
height = @title_size + @caption_size + @spacer_height + 2 * @padding + @spacer_height
|
||||
|
||||
Gosu.record(width.ceil, height.ceil) do
|
||||
@title.x = (width - @padding * 2) / 2 - @title.width / 2
|
||||
@title.x = (width - @padding * 2) / 2 - @title.text_width / 2
|
||||
@title.y = @padding
|
||||
@title.draw
|
||||
|
||||
Gosu.draw_rect(0, @padding + @title_size + @padding, @spacer_width, @spacer_height, Gosu::Color::WHITE)
|
||||
Gosu.draw_rect(1, @padding + @title_size + @padding + 1, @spacer_width - 2, @spacer_height - 2, color_hint)
|
||||
|
||||
@caption.x = (width - @padding * 2) / 2 - @caption.width / 2
|
||||
@caption.x = (width - @padding * 2) / 2 - @caption.text_width / 2
|
||||
@caption.y = @padding + @title_size + @padding + @spacer_height + @padding
|
||||
@caption.draw
|
||||
end
|
||||
|
||||
@@ -128,6 +128,10 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def width(text = @text)
|
||||
markup_width(text)
|
||||
end
|
||||
|
||||
def text_width(text = @text)
|
||||
textobject.text_width(text) + @border_size + @shadow_size
|
||||
end
|
||||
|
||||
@@ -152,8 +156,9 @@ module CyberarmEngine
|
||||
|
||||
_x = @border_size
|
||||
_y = @border_size
|
||||
_width = method == :draw_markup ? text_width : markup_width
|
||||
|
||||
@rendered_border ||= Gosu.render((width + (border_size * 2)).ceil, (height + (@border_size * 2)).ceil) do
|
||||
@rendered_border ||= Gosu.render((_width + (border_size * 2)).ceil, (height + (@border_size * 2)).ceil) do
|
||||
@textobject.send(method, @text, _x - @border_size, _y, @z, @factor_x, @factor_y, white, @mode)
|
||||
@textobject.send(method, @text, _x - @border_size, _y - @border_size, @z, @factor_x, @factor_y, white, @mode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user