mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-18 22:02:34 +00:00
Added all the callbacks to Window and GameState, removed all but one usage of global variables ().
This commit is contained in:
@@ -6,6 +6,16 @@ module CyberarmEngine
|
||||
attr_accessor :stroke_color, :fill_color
|
||||
attr_reader :children, :gui_state, :scroll_position
|
||||
|
||||
def self.current_container
|
||||
@@current_container
|
||||
end
|
||||
|
||||
def self.current_container=(container)
|
||||
raise ArgumentError, "Expected container to an an instance of CyberarmEngine::Element::Container, got #{container.class}" unless container.is_a?(CyberarmEngine::Element::Container)
|
||||
|
||||
@@current_container = container
|
||||
end
|
||||
|
||||
def initialize(options = {}, block = nil)
|
||||
@gui_state = options.delete(:gui_state)
|
||||
super
|
||||
@@ -35,23 +45,23 @@ module CyberarmEngine
|
||||
def clear(&block)
|
||||
@children.clear
|
||||
|
||||
old_container = $__current_container__
|
||||
old_container = CyberarmEngine::Element::Container.current_container
|
||||
|
||||
$__current_container__ = self
|
||||
CyberarmEngine::Element::Container.current_container = self
|
||||
block.call(self) if block
|
||||
|
||||
$__current_container__ = old_container
|
||||
CyberarmEngine::Element::Container.current_container = old_container
|
||||
|
||||
root.gui_state.request_recalculate
|
||||
end
|
||||
|
||||
def append(&block)
|
||||
old_container = $__current_container__
|
||||
old_container = CyberarmEngine::Element::Container.current_container
|
||||
|
||||
$__current_container__ = self
|
||||
CyberarmEngine::Element::Container.current_container = self
|
||||
block.call(self) if block
|
||||
|
||||
$__current_container__ = old_container
|
||||
CyberarmEngine::Element::Container.current_container = old_container
|
||||
|
||||
root.gui_state.request_recalculate
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user