Class: Cliptic::Interface::Menu
- Inherits:
-
Menu_Box
- Object
- Curses::Window
- Windows::Window
- Menu_Box
- Cliptic::Interface::Menu
- Defined in:
- lib/cliptic/interface.rb
Direct Known Subclasses
Menu_With_Stats, Yes_No_Menu, Main::Player::Menus::Pause, Main::Player::Menus::Puzzle_Complete, Menus::Main
Constant Summary
Constants included from Chars
Chars::Block, Chars::HL, Chars::LL, Chars::LS, Chars::LU, Chars::MS, Chars::Nums, Chars::RL, Chars::RS, Chars::RU, Chars::TD, Chars::TL, Chars::TR, Chars::TU, Chars::Tick, Chars::VL, Chars::XX
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Attributes inherited from Menu_Box
#bot_b, #draw_bars, #logo, #title, #top_b
Attributes inherited from Windows::Window
#centered_x, #centered_y, #col, #line, #x, #y
Instance Method Summary collapse
- #back(post_proc: ->{hide}) ⇒ Object
- #choose_opt ⇒ Object
- #ctrls ⇒ Object
- #enter(pre_proc: ->{hide}, post_proc: ->{show}) ⇒ Object
- #hide ⇒ Object
-
#initialize(height: opts.length+6, sel: Selector, sel_opts: opts.keys, tick: nil) ⇒ Menu
constructor
A new instance of Menu.
- #redraw ⇒ Object
- #reset_pos ⇒ Object
- #show ⇒ Object
Methods inherited from Menu_Box
Methods inherited from Windows::Window
#add_str, #bold, #clear, #color, #draw, #move, #refresh, #reset_attrs, #setpos, #standend, #standout, #time_str, #wrap_str
Methods included from Chars
Constructor Details
#initialize(height: opts.length+6, sel: Selector, sel_opts: opts.keys, tick: nil) ⇒ Menu
Returns a new instance of Menu.
169 170 171 172 173 174 175 |
# File 'lib/cliptic/interface.rb', line 169 def initialize(height:opts.length+6, sel:Selector, sel_opts:opts.keys, tick:nil, **) super(y:height, title:title) @height = height @selector = sel.new(opts:sel_opts, ctrls:ctrls, line:line+5, x:logo.x, tick:tick) end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
168 169 170 |
# File 'lib/cliptic/interface.rb', line 168 def height @height end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
168 169 170 |
# File 'lib/cliptic/interface.rb', line 168 def selector @selector end |
Instance Method Details
#back(post_proc: ->{hide}) ⇒ Object
186 187 188 189 |
# File 'lib/cliptic/interface.rb', line 186 def back(post_proc:->{hide}) selector.stop post_proc.call if post_proc end |
#choose_opt ⇒ Object
176 177 178 179 |
# File 'lib/cliptic/interface.rb', line 176 def choose_opt show selector.select end |
#ctrls ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/cliptic/interface.rb', line 196 def ctrls { ?j => ->{selector.cursor += 1}, ?k => ->{selector.cursor -= 1}, 258 => ->{selector.cursor += 1}, 259 => ->{selector.cursor -= 1}, 10 => ->{enter}, ?q => ->{back}, 3 => ->{back}, Curses::KEY_RESIZE => ->{Screen.redraw(cb:->{redraw})} } end |
#enter(pre_proc: ->{hide}, post_proc: ->{show}) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/cliptic/interface.rb', line 180 def enter(pre_proc:->{hide}, post_proc:->{show}) pre_proc.call if pre_proc opts.values[selector.cursor]&.call reset_pos post_proc.call if post_proc end |
#hide ⇒ Object
193 194 195 |
# File 'lib/cliptic/interface.rb', line 193 def hide clear end |
#redraw ⇒ Object
213 214 215 216 |
# File 'lib/cliptic/interface.rb', line 213 def redraw reset_pos draw end |
#reset_pos ⇒ Object
209 210 211 212 |
# File 'lib/cliptic/interface.rb', line 209 def reset_pos super selector.move(line:line+5) end |
#show ⇒ Object
190 191 192 |
# File 'lib/cliptic/interface.rb', line 190 def show draw end |