Method: Fidgit::MenuPane#initialize

Defined in:
lib/fidgit/elements/menu_pane.rb

#initialize(options = {}, &block) ⇒ MenuPane

Returns a new instance of MenuPane.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :x (Float) — default: cursor x, if in a GuiState
  • :y (Float) — default: cursor y, if in a GuiState
  • :show (Boolean) — default: true

    Whether to show immediately (show later with #show).



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fidgit/elements/menu_pane.rb', line 75

def initialize(options = {}, &block)
  options = {
    background_color: default(:color),
    z: Float::INFINITY,
    show: true,
  }.merge! options

  state = $window.current_game_state
  if state.is_a? GuiState
    cursor = $window.current_game_state.cursor
    options = {
      x: cursor.x,
      y: cursor.y,
    }.merge! options
  end

  @items = nil

  super(options)

  @items = vertical spacing: 0, padding: 0

  if options[:show] and state.is_a? GuiState
    show
  end
end