mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-03-22 03:56:13 +00:00
Compare commits
3 Commits
master
...
16bd9168e4
| Author | SHA1 | Date | |
|---|---|---|---|
| 16bd9168e4 | |||
| b946d5efa6 | |||
| 4ce6c1f499 |
@@ -35,7 +35,7 @@ class Hello < CyberarmEngine::GuiState
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
|
|
||||||
stack do
|
stack do
|
||||||
label "Hello World!"
|
banner "Hello World!"
|
||||||
|
|
||||||
button "close" do
|
button "close" do
|
||||||
window.close
|
window.close
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ module CyberarmEngine
|
|||||||
include Common
|
include Common
|
||||||
|
|
||||||
attr_accessor :options, :global_pause
|
attr_accessor :options, :global_pause
|
||||||
attr_reader :game_objects, :timers
|
attr_reader :game_objects
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@options = options
|
@options = options
|
||||||
@game_objects = []
|
@game_objects = []
|
||||||
@timers = []
|
|
||||||
@global_pause = false
|
@global_pause = false
|
||||||
window.text_input = nil unless options[:preserve_text_input]
|
window.text_input = nil unless options[:preserve_text_input]
|
||||||
|
|
||||||
@@ -29,8 +28,6 @@ module CyberarmEngine
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@game_objects.each(&:update)
|
@game_objects.each(&:update)
|
||||||
@timers.each(&:update)
|
|
||||||
@timers.delete_if(&:dead?)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_redraw?
|
def needs_redraw?
|
||||||
@@ -123,9 +120,5 @@ module CyberarmEngine
|
|||||||
def add_game_object(object)
|
def add_game_object(object)
|
||||||
@game_objects << object
|
@game_objects << object
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_timer(timer)
|
|
||||||
@timers << timer
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,9 +19,5 @@ module CyberarmEngine
|
|||||||
@block.call if @block
|
@block.call if @block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dead?
|
|
||||||
@triggered && !@looping
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
module CyberarmEngine
|
module CyberarmEngine
|
||||||
module DSL
|
module DSL
|
||||||
def every(milliseconds, &block)
|
|
||||||
element_parent.gui_state.add_timer(
|
|
||||||
CyberarmEngine::Timer.new(milliseconds, true, &block)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def after(milliseconds, &block)
|
|
||||||
element_parent.gui_state.add_timer(
|
|
||||||
CyberarmEngine::Timer.new(milliseconds, false, &block)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def flow(options = {}, &block)
|
def flow(options = {}, &block)
|
||||||
container(CyberarmEngine::Element::Flow, options, &block)
|
container(CyberarmEngine::Element::Flow, options, &block)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -79,19 +79,7 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def caret_position_under_mouse(mouse_x, mouse_y)
|
def caret_position_under_mouse(mouse_x, mouse_y)
|
||||||
# get y scroll offset of element to get EditBox's selected row
|
active_line = row_at(mouse_y)
|
||||||
y_scroll_offset = 0
|
|
||||||
e = parent
|
|
||||||
while (e)
|
|
||||||
if e.is_a?(Container)
|
|
||||||
y_scroll_offset += e.scroll_position.y
|
|
||||||
|
|
||||||
# root element has no parent so loop will terminate
|
|
||||||
e = e.parent
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
active_line = row_at(mouse_y - y_scroll_offset)
|
|
||||||
right_offset = column_at(mouse_x, mouse_y)
|
right_offset = column_at(mouse_x, mouse_y)
|
||||||
|
|
||||||
buffer = @text_input.text.lines[0..active_line].join if active_line != 0
|
buffer = @text_input.text.lines[0..active_line].join if active_line != 0
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ module CyberarmEngine
|
|||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@options = options
|
@options = options
|
||||||
@game_objects = []
|
@game_objects = []
|
||||||
@timers = []
|
|
||||||
@global_pause = false
|
@global_pause = false
|
||||||
|
|
||||||
@down_keys = {}
|
@down_keys = {}
|
||||||
@@ -272,14 +271,10 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def redirect_scroll_jump_to(edge)
|
def redirect_scroll_jump_to(edge)
|
||||||
return if window.text_input
|
|
||||||
|
|
||||||
@mouse_over.publish(:"scroll_jump_to_#{edge}", window.mouse_x, window.mouse_y) if (@mouse_over && !@menu) || (@mouse_over && @mouse_over == @menu)
|
@mouse_over.publish(:"scroll_jump_to_#{edge}", window.mouse_x, window.mouse_y) if (@mouse_over && !@menu) || (@mouse_over && @mouse_over == @menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_scroll_page(edge)
|
def redirect_scroll_page(edge)
|
||||||
return if window.text_input
|
|
||||||
|
|
||||||
@mouse_over.publish(:"scroll_page_#{edge}", window.mouse_x, window.mouse_y) if (@mouse_over && !@menu) || (@mouse_over && @mouse_over == @menu)
|
@mouse_over.publish(:"scroll_page_#{edge}", window.mouse_x, window.mouse_y) if (@mouse_over && !@menu) || (@mouse_over && @mouse_over == @menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user