mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4af377b93c | |||
| cc97077b0f |
@@ -13,7 +13,6 @@ require_relative "cyberarm_engine/background"
|
||||
|
||||
require_relative "cyberarm_engine/objects/text"
|
||||
require_relative "cyberarm_engine/objects/timer"
|
||||
require_relative "cyberarm_engine/objects/multi_line_text"
|
||||
|
||||
require_relative "cyberarm_engine/ui/theme"
|
||||
require_relative "cyberarm_engine/ui/event"
|
||||
|
||||
@@ -48,10 +48,12 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
super
|
||||
current_state.button_down(id) if current_state
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
super
|
||||
current_state.button_up(id) if current_state
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ module CyberarmEngine
|
||||
|
||||
setup
|
||||
|
||||
@debug_text = MultiLineText.new("", color: @debug_color, y: @position.y-(self.height*self.scale), z: 9999)
|
||||
@debug_text = Text.new("", color: @debug_color, y: @position.y-(self.height*self.scale), z: 9999)
|
||||
@debug_text.x = @position.x
|
||||
if @radius == 0 || @radius == nil
|
||||
@radius = options[:radius] ? options[:radius] : defined?(@image.width) ? ((@image.width+@image.height)/4)*scale : 1
|
||||
@@ -121,11 +121,11 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def width
|
||||
@image ? @image.width : 0
|
||||
@image ? @image.width * self.scale : 0
|
||||
end
|
||||
|
||||
def height
|
||||
@image ? @image.height : 0
|
||||
@image ? @image.height * self.scale : 0
|
||||
end
|
||||
|
||||
def pause
|
||||
|
||||
@@ -9,6 +9,7 @@ module CyberarmEngine
|
||||
@options = options
|
||||
@game_objects = []
|
||||
@global_pause = false
|
||||
$window.text_input = nil unless options[:preserve_text_input]
|
||||
|
||||
@down_keys = {}
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
module CyberarmEngine
|
||||
class MultiLineText
|
||||
attr_accessor :options, :x, :y, :width, :height
|
||||
|
||||
def initialize(text, options={})
|
||||
@texts = []
|
||||
text.split("\n").each_with_index do |line, i|
|
||||
_options = options
|
||||
_options[:y]+=_options[:size]
|
||||
@texts << Text.new(line, _options)
|
||||
end
|
||||
@options = options
|
||||
@x = @texts.first ? @texts.first.x : 0
|
||||
@y = @texts.first ? @texts.first.y : 0
|
||||
@width = 0
|
||||
@height = 0
|
||||
calculate_boundry
|
||||
end
|
||||
|
||||
def draw
|
||||
@texts.each(&:draw)
|
||||
end
|
||||
|
||||
def text
|
||||
string = ""
|
||||
@texts.each {|t| string << t.text}
|
||||
return string
|
||||
end
|
||||
|
||||
def text=(text)
|
||||
|
||||
if text.lines.count < @texts.count
|
||||
range = ((@texts.count - @text.lines.count)-1)..@texts.count-1
|
||||
p range
|
||||
@texts.slice!(range)
|
||||
end
|
||||
|
||||
text.split("\n").each_with_index do |line, i|
|
||||
if @texts[i]
|
||||
@texts[i].text = line
|
||||
else
|
||||
@texts << Text.new(line, @options)
|
||||
end
|
||||
end
|
||||
|
||||
self.y = @y
|
||||
calculate_boundry
|
||||
end
|
||||
|
||||
def x=(int)
|
||||
@x = int
|
||||
@texts.each {|t| t.x = int}
|
||||
end
|
||||
|
||||
def y=(int)
|
||||
@y = int
|
||||
@texts.each_with_index {|t, i| t.y=int+(i*t.size)}
|
||||
end
|
||||
|
||||
def calculate_boundry
|
||||
@width = 0
|
||||
@height= 0
|
||||
@texts.each {|t| @width = t.width if t.width > @width}
|
||||
@texts.each {|t| @height+=t.height}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,7 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def height
|
||||
textobject.height
|
||||
@text.lines.count * textobject.height
|
||||
end
|
||||
|
||||
def draw
|
||||
@@ -91,6 +91,14 @@ module CyberarmEngine
|
||||
@textobject.draw_markup(@text, @x, @y, @z, @factor_x, @factor_y, @color)
|
||||
end
|
||||
|
||||
def alpha=(n)
|
||||
@color = Gosu::Color.new(@color.red, @color.green, @color.blue, n)
|
||||
end
|
||||
|
||||
def alpha
|
||||
@color.alpha
|
||||
end
|
||||
|
||||
def update; end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module CyberarmEngine
|
||||
NAME = "InDev"
|
||||
VERSION = "0.1.0"
|
||||
VERSION = "0.2.0"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user