Class: Miyako::Yuki::CommandEx

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

Instance Method Summary collapse

Instance Method Details

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

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


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/Miyako/API/yuki.rb', line 104

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