Compare commits

..

3 Commits

Author SHA1 Message Date
16bd9168e4 Bump version 2026-01-28 18:02:18 -06:00
b946d5efa6 Added Result class to make writing failure resistant code easier 2026-01-28 18:02:18 -06:00
4ce6c1f499 Update README 2026-01-09 09:39:40 -06:00
6 changed files with 3 additions and 43 deletions

View File

@@ -35,7 +35,7 @@ class Hello < CyberarmEngine::GuiState
background Gosu::Color::GRAY
stack do
label "Hello World!"
banner "Hello World!"
button "close" do
window.close

View File

@@ -3,12 +3,11 @@ module CyberarmEngine
include Common
attr_accessor :options, :global_pause
attr_reader :game_objects, :timers
attr_reader :game_objects
def initialize(options = {})
@options = options
@game_objects = []
@timers = []
@global_pause = false
window.text_input = nil unless options[:preserve_text_input]
@@ -29,8 +28,6 @@ module CyberarmEngine
def update
@game_objects.each(&:update)
@timers.each(&:update)
@timers.delete_if(&:dead?)
end
def needs_redraw?
@@ -123,9 +120,5 @@ module CyberarmEngine
def add_game_object(object)
@game_objects << object
end
def add_timer(timer)
@timers << timer
end
end
end

View File

@@ -19,9 +19,5 @@ module CyberarmEngine
@block.call if @block
end
end
def dead?
@triggered && !@looping
end
end
end

View File

@@ -1,17 +1,5 @@
module CyberarmEngine
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)
container(CyberarmEngine::Element::Flow, options, &block)
end

View File

@@ -79,19 +79,7 @@ module CyberarmEngine
end
def caret_position_under_mouse(mouse_x, mouse_y)
# get y scroll offset of element to get EditBox's selected row
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)
active_line = row_at(mouse_y)
right_offset = column_at(mouse_x, mouse_y)
buffer = @text_input.text.lines[0..active_line].join if active_line != 0

View File

@@ -6,7 +6,6 @@ module CyberarmEngine
def initialize(options = {})
@options = options
@game_objects = []
@timers = []
@global_pause = false
@down_keys = {}
@@ -272,14 +271,10 @@ module CyberarmEngine
end
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)
end
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)
end