summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/menu.rb20
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);