diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/menu.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/menu.rb b/lib/menu.rb index 801b5a7..47e9646 100644 --- a/lib/menu.rb +++ b/lib/menu.rb @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Frederico de Oliveira Linhares +# Copyright 2022-2025 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. @@ -89,24 +89,21 @@ module CandyGear } end - def draw(view, x, y, width, height) + def draw(x, y, width, height) num_horizontal_sprites = width / @border_width + 1; num_horizontal_sprites += 1 if width % @border_width > 0; num_vertical_sprites = height / @border_height; num_vertical_sprites += 1 if height % @border_height > 0; # Draw the corners. - @sprites[:box_top_left].draw(view, x, y, border_width, border_height); + @sprites[:box_top_left].draw(x, y, border_width, border_height); @sprites[:box_top_right].draw( - view, @border_width * (num_horizontal_sprites + 1) + x, y, border_width, border_height); @sprites[:box_bottom_left].draw( - view, x, @border_height * (num_vertical_sprites + 1) + y, border_width, border_height); @sprites[:box_bottom_right].draw( - view, @border_width * (num_horizontal_sprites + 1) + x, @border_height * (num_vertical_sprites + 1) + y, border_width, border_height); @@ -115,22 +112,19 @@ module CandyGear num_horizontal_sprites.times do |i| # Top @sprites[:box_top].draw( - view, @border_width * (i + 1) + x, y, - border_width, border_height); + @border_width * (i + 1) + x, y, border_width, border_height); # Bottom @sprites[:box_bottom].draw( - view, @border_width * (i + 1) + x, + @border_width * (i + 1) + x, @border_height * (num_vertical_sprites + 1) + y, border_width, border_height); end num_vertical_sprites.times do |i| # Left @sprites[:box_left].draw( - view, x, @border_height * (i + 1) + y, border_width, border_height); # Right @sprites[:box_right].draw( - view, @border_width * (num_horizontal_sprites + 1) + x, @border_height * (i + 1) + y, border_width, border_height); @@ -152,8 +146,7 @@ module CandyGear attr_reader(:width, :height); - def initialize(view, menu_view, pos_x, pos_y, options) - @view = view; + def initialize(menu_view, pos_x, pos_y, options) @menu_view = menu_view; @pos_x = pos_x; @@ -205,11 +198,10 @@ module CandyGear end def draw() - @menu_view.draw(@view, @pos_x, @pos_y, @width, @height); + @menu_view.draw(@pos_x, @pos_y, @width, @height); @options.each_with_index do |opt, i| opt.text.draw( - @view, @pos_x + @menu_view.border_width + @menu_view.border_width, @pos_y + @menu_view.border_height + @@ -218,7 +210,6 @@ module CandyGear end @menu_view.sprites[:arrow_select].draw( - @view, @pos_x + @menu_view.border_width, @pos_y + @menu_view.border_height + @option_max_height * @current_option, |