diff options
author | Frederico Linhares <fred@linhares.blue> | 2022-05-11 13:31:21 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2022-05-11 13:31:21 -0300 |
commit | e6b96284b24cef174ec963c5073e57eb4e95d96a (patch) | |
tree | e3005e95fd3a4a1ba4f74dd70eaf42fe1973830e /lib | |
parent | 418f45f78bbf743021c53030da2ad2158fa355d2 (diff) |
feat Create Menu::Stack
Diffstat (limited to 'lib')
-rw-r--r-- | lib/menu.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/menu.rb b/lib/menu.rb index a3f1533..11c8715 100644 --- a/lib/menu.rb +++ b/lib/menu.rb @@ -1,4 +1,4 @@ -# Copyright 2021 Frederico de Oliveira Linhares +# Copyright 2022 Frederico de Oliveira Linhares # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,24 @@ module CandyGear class Menu + class Stack + def initialize(menu) + @stack = []; + @stack << menu; + end + + def current_menu() = @stack[-1]; + + def push(menu) = @stack << menu; + + def pop() + @stack.pop() if @stack.size > 1; + end + + def draw() = @stack.each {_1.draw();} + def size() = @stack.size; + end + class BorderlessView attr_reader(:texture, :font, :text_color, :bg_color, :sprites); |