Class: Miyako::InitiativeYuki::CommandEx

Inherits:
Object
  • Object
show all
Defined in:
lib/Miyako/API/i_yuki.rb

Instance Method Summary collapse

Instance Method Details

#to_choice(font = Font.sans_serif, size = 16, color = Color[:white]) ⇒ Object

Command構造体をChoice構造体に変換する


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/Miyako/API/i_yuki.rb', line 139

def to_choice(font=Font.sans_serif, size=16, color=Color[:white])
  org_font_color = font.color
  org_font_size = font.size

  font.color = color
  tmp = self[:body]
  body = tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)

  font.color = Color[:red]
  tmp = self[:body_selected]
  body_selected = tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body

  font.color = Color[:dark_gray]
  tmp = self[:body_disable]
  body_disable= tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body

  cond = self[:condition] || ALL_TRUE

  choice = Choice.new(body, body_selected, body_disable,
                      cond, self[:enable], false, self[:result],
                      nil, nil, nil, nil,
                      nil, {}, self[:end_select_proc], nil)
  choice.left = choice
  choice.right = choice
  choice.up = choice
  choice.down = choice
  choice.name = choice.__id__.to_s

  font.color = org_font_color
  font.size  = org_font_size

  choice
end