Compare commits

...

2 Commits

Author SHA1 Message Date
Jill 49ce6885ea
turns out trying to access the position of a closed window results in an x error
who could've known
2023-06-02 15:37:38 +03:00
Jill 7fcf926426
remove the concept of a main context
app closes when all contexts close now
2023-06-02 15:34:52 +03:00
3 changed files with 6 additions and 4 deletions

View File

@ -40,7 +40,9 @@ class Funfriend::ChatterContext < Funfriend::WindowContext
def update_position
if parent
p = parent.not_nil!
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
if !p.closed
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
end
end
end

View File

@ -28,17 +28,15 @@ module Funfriend
LOG = ::Log.for("")
@@contexts = [] of WindowContext
@@main_context : WindowContext?
def self.should_close?
@@main_context && @@main_context.not_nil!.window.should_close?
@@contexts.size == 0
end
def self.init_contexts
ConfigMan.config["buddies"]["types"].as(String).split(",").each do |buddy_name|
add_context(BuddyContext.new(make_buddy(buddy_name)))
end
@@main_context = @@contexts[0]
at_exit { contexts.each &.destroy }
end

View File

@ -5,6 +5,7 @@ GLFW_FOCUS_ON_SHOW = 0x0002000C
class Funfriend::WindowContext
getter window : CrystGLFW::Window
property closed : Bool = false
DEFAULT_HINTS = {
# supposedly required on MacOS
@ -43,6 +44,7 @@ class Funfriend::WindowContext
def close
window.destroy
@closed = true
end
def clean_up