Class: Miyako::Yuki::Command

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

Overview

コマンド構造体

body

コマンドの名称(移動する、調べるなど、アイコンなどの画像も可)

body_selected

選択時コマンドの名称(移動する、調べるなど、アイコンなどの画像も可)(省略時は、bodyと同一)

body_disable

選択不可時コマンドの名称(移動する、調べるなど、アイコンなどの画像も可)(省略時は、bodyと同一)

enabe

コマンド選択の時はtrue、選択不可の時はfalseを設定

condition

表示条件(ブロック)。評価の結果、trueのときのみ表示

result

選択結果(移動先シーンクラス名、シナリオ(メソッド)名他のオブジェクト)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def body
  @body
end

#body_disableObject

Returns the value of attribute body_disable

Returns:

  • (Object)

    the current value of body_disable


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def body_disable
  @body_disable
end

#body_selectedObject

Returns the value of attribute body_selected

Returns:

  • (Object)

    the current value of body_selected


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def body_selected
  @body_selected
end

#conditionObject

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def condition
  @condition
end

#enableObject

Returns the value of attribute enable

Returns:

  • (Object)

    the current value of enable


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def enable
  @enable
end

#resultObject

Returns the value of attribute result

Returns:

  • (Object)

    the current value of result


52
53
54
# File 'lib/Miyako/API/yuki.rb', line 52

def result
  @result
end

Instance Method Details

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

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


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/Miyako/API/yuki.rb', line 56

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, {}, lambda{}, 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