Class: SwfRuby::AsVarReplaceTarget
- Inherits:
-
ReplaceTarget
- Object
- ReplaceTarget
- SwfRuby::AsVarReplaceTarget
- Defined in:
- lib/swf_ruby/replace_target.rb
Instance Attribute Summary collapse
-
#do_action_offset ⇒ Object
Returns the value of attribute do_action_offset.
-
#parent_sprite_offset ⇒ Object
Returns the value of attribute parent_sprite_offset.
-
#str ⇒ Object
Returns the value of attribute str.
Attributes inherited from ReplaceTarget
Class Method Summary collapse
-
.build_by_var_name(swf_dumper, var_name) ⇒ Object
指定したAS変数名に対するAsVarReplaceTargetのリストを生成する.
-
.generate_as_var_replace_target_by_do_action(var_name, swf_dumper, do_action_index, sprite_dumper = nil, parent_sprite_offset = nil) ⇒ Object
指定したインデックス(SWFまたはSpriteの先頭からカウント)にあるDoAction以下を走査し、 指定したAS変数名の代入部分を発見し、AsVarReplaceTargetのリストを生成する.
Instance Method Summary collapse
-
#initialize(action_push_offset, do_action_offset, str, parent_sprite_offset = nil) ⇒ AsVarReplaceTarget
constructor
A new instance of AsVarReplaceTarget.
Constructor Details
#initialize(action_push_offset, do_action_offset, str, parent_sprite_offset = nil) ⇒ AsVarReplaceTarget
Returns a new instance of AsVarReplaceTarget.
114 115 116 117 118 119 |
# File 'lib/swf_ruby/replace_target.rb', line 114 def initialize(action_push_offset, do_action_offset, str, parent_sprite_offset = nil) @offset = action_push_offset @do_action_offset = do_action_offset @str = str @parent_sprite_offset = parent_sprite_offset end |
Instance Attribute Details
#do_action_offset ⇒ Object
Returns the value of attribute do_action_offset.
110 111 112 |
# File 'lib/swf_ruby/replace_target.rb', line 110 def do_action_offset @do_action_offset end |
#parent_sprite_offset ⇒ Object
Returns the value of attribute parent_sprite_offset.
112 113 114 |
# File 'lib/swf_ruby/replace_target.rb', line 112 def parent_sprite_offset @parent_sprite_offset end |
#str ⇒ Object
Returns the value of attribute str.
111 112 113 |
# File 'lib/swf_ruby/replace_target.rb', line 111 def str @str end |
Class Method Details
.build_by_var_name(swf_dumper, var_name) ⇒ Object
指定したAS変数名に対するAsVarReplaceTargetのリストを生成する
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/swf_ruby/replace_target.rb', line 122 def self.build_by_var_name(swf_dumper, var_name) as_var_replace_targets = [] swf_dumper..each_with_index do |t, i| if t.code == 39 # DefineSprite sd = SpriteDumper.new sd.dump(t) sd..each_with_index do |u, j| if u.code == 12 # DoAction in DefineSprite as_var_replace_targets += AsVarReplaceTarget.generate_as_var_replace_target_by_do_action(var_name, swf_dumper, j, sd, swf_dumper.[i]) end end end if t.code == 12 # DoAction as_var_replace_targets += AsVarReplaceTarget.generate_as_var_replace_target_by_do_action(var_name, swf_dumper, i) end end as_var_replace_targets end |
.generate_as_var_replace_target_by_do_action(var_name, swf_dumper, do_action_index, sprite_dumper = nil, parent_sprite_offset = nil) ⇒ Object
指定したインデックス(SWFまたはSpriteの先頭からカウント)にあるDoAction以下を走査し、指定したAS変数名の代入部分を発見し、AsVarReplaceTargetのリストを生成する.
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 172 173 174 175 176 177 178 179 |
# File 'lib/swf_ruby/replace_target.rb', line 146 def self.generate_as_var_replace_target_by_do_action(var_name, swf_dumper, do_action_index, sprite_dumper = nil, parent_sprite_offset = nil) as_var_replace_targets = [] action_records = [] do_action_offset = 0 dad = DoActionDumper.new if sprite_dumper do_action_offset = parent_sprite_offset + sprite_dumper.[do_action_index] dad.dump(swf_dumper.swf[do_action_offset, sprite_dumper.[do_action_index].length]) else do_action_offset = swf_dumper.[do_action_index] dad.dump(swf_dumper.swf[do_action_offset, swf_dumper.[do_action_index].length]) end dad.actions.each_with_index do |ar, i| # ActionPush, ActionPush, SetVariableの並びを検出したら変数名をチェック. action_records.shift if action_records.length > 2 action_records << ar if ar.code == 29 and action_records[0] and action_records[0].code == 150 and action_records[0].data.delete("\0") == var_name and action_records[1].code == 150 # 対象の代入式を発見. ap = Swf::ActionPush.new(action_records[1]) as_var_replace_targets << AsVarReplaceTarget.new( do_action_offset + dad.actions_addresses[i] - action_records[1].length, do_action_offset, "", parent_sprite_offset ) end end as_var_replace_targets end |