diff --git a/src/config.rb b/src/config.rb index 48a7375..6cc7bf5 100644 --- a/src/config.rb +++ b/src/config.rb @@ -4,7 +4,7 @@ WORLD_SEED = 123456789 # UI WINDOW_WIDTH = 1600 WINDOW_HEIGHT = 900 -WINDOW_FULLSCREEN = true +WINDOW_FULLSCREEN = false MAIN_FONT = "monospace" # Keybinds diff --git a/src/lib/ui.rb b/src/lib/ui.rb index 289335e..2353e37 100644 --- a/src/lib/ui.rb +++ b/src/lib/ui.rb @@ -42,7 +42,7 @@ class UI end class Button < UI - attr_accessor :selected, :menu, :colors + attr_accessor :selected, :menu, :colors, :events attr_reader :text, :width, :height, :text_width, :text_height, :font, :zindex, :padding def initialize(window, menu, text, font, x=0, y=0, padding={x:32, y:2}, zindex=0) super window, x, y, width, height, zindex, menu.uiscale @@ -80,12 +80,13 @@ class Button < UI self.selected = inx && iny end - def method_ptr=(new_ptr) - # TODO: make a method pointer for button presses etc + def add_event(event_sym, method_ptr) + self.events[event_sym] = method_ptr end - def onclick(id, *args, **kwargs) - self.method_ptr.call(id, *args, **kwargs) + def onevent(event_sym, *args, **kwargs) + # self.method_ptr.call(id, *args, **kwargs) + self.events[event_sym].(*args, **kwargs) end def render @@ -103,6 +104,10 @@ class MainMenu < UI @show = show end + def quit_game + self.window.close! + end + def render if( @show ) then self.draw_rect(0, 0, self.width, self.height, 0xaa_111015)