Skip to content

Commit

Permalink
Add readDefineButtonTag and readButtonRecord2
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine committed Aug 15, 2013
1 parent 3435940 commit f600bdf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 55 deletions.
83 changes: 39 additions & 44 deletions SWFWireDecompiler/src/com/swfwire/decompiler/SWF3Reader.as
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package com.swfwire.decompiler
import com.swfwire.decompiler.data.swf.tags.EndTag;
import com.swfwire.decompiler.data.swf.tags.SWFTag;
import com.swfwire.decompiler.data.swf2.records.FillStyleArrayRecord2;
import com.swfwire.decompiler.data.swf3.actions.ButtonCondAction;
import com.swfwire.decompiler.data.swf3.records.*;
import com.swfwire.decompiler.data.swf3.tags.*;

Expand Down Expand Up @@ -38,9 +39,6 @@ package com.swfwire.decompiler
case 45: tag = readSoundStreamHead2Tag(context, header);
case 46: tag = readDefineMorphShapeTag(context, header);
case 48: tag = readDefineFont2Tag(context, header);
case 34:
tag = readDefineButton2Tag(context, header);
break;
*/
case 12:
tag = readDoActionTag(context, header);
Expand All @@ -51,6 +49,9 @@ package com.swfwire.decompiler
case 32:
tag = readDefineShape3Tag(context, header);
break;
case 34:
tag = readDefineButton2Tag(context, header);
break;
case 35:
tag = readDefineBitsJPEG3Tag(context, header);
break;
Expand Down Expand Up @@ -339,60 +340,49 @@ package com.swfwire.decompiler
tag.buttonId = context.bytes.readUI16();
tag.reserved = context.bytes.readUB(7);
tag.trackAsMenu = context.bytes.readFlag();
var actionOffsetPosition:uint = context.bytes.getBytePosition();
tag.actionOffset = context.bytes.readUI16();
tag.characters = new Vector.<ButtonRecord2>();
while(true)
do
{
var reserved:uint = context.bytes.readUB(2);
var hasBlendMode:Boolean = context.bytes.readFlag();
var hasFilterList:Boolean = context.bytes.readFlag();
var stateHitTest:Boolean = context.bytes.readFlag();
var stateDown:Boolean = context.bytes.readFlag();
var stateOver:Boolean = context.bytes.readFlag();
var stateUp:Boolean = context.bytes.readFlag();
if(reserved == 0 &&
!hasBlendMode &&
!hasFilterList &&
!stateHitTest &&
!stateDown &&
!stateOver &&
!stateUp)
tag.characters.push(readButtonRecord2(context));
// Test if next byte is CharacterEndFlag
if (!context.bytes.readUI8())
{
break;
}
else
context.bytes.unreadBytes(1);
}
while(true);
tag.actions = new Vector.<ButtonCondAction>();
if (tag.actionOffset == 0)
{
return tag;
}
if ((actionOffsetPosition + tag.actionOffset) != context.bytes.getBytePosition())
{
throw new Error("Wrong ActionOffset value: " + tag.actionOffset + " instead of " + (context.bytes.getBytePosition() - actionOffsetPosition));
}
do
{
var actionPosition:uint = context.bytes.getBytePosition();
var action:ButtonCondAction = readButtonCondAction(context);
tag.actions.push(action);
if (action.condActionSize && ((actionPosition + action.condActionSize) != context.bytes.getBytePosition()))
{
tag.characters.push(readButtonRecord2(context, reserved, hasBlendMode, hasFilterList,
stateHitTest, stateDown, stateOver, stateUp));
throw new Error("Wrong CondActionSize value: " + action.condActionSize + " instead of " + (context.bytes.getBytePosition() - actionPosition));
}
}
//tag.actions = readButtonCondAction();
while(action.condActionSize)
return tag;
}

protected function readButtonRecord2(context:SWFReaderContext, reserved:uint, hasBlendMode:Boolean, hasFilterList:Boolean,
stateHitTest:Boolean, stateDown:Boolean, stateOver:Boolean, stateUp:Boolean):ButtonRecord2
{
var record:ButtonRecord2 = new ButtonRecord2();
record.reserved = reserved;
record.hasBlendMode = hasBlendMode;
record.hasFilterList = hasFilterList;
record.stateHitTest = stateHitTest;
record.stateDown = stateDown;
record.stateOver = stateOver;
record.stateUp = stateUp;
record.characterId = context.bytes.readUI16();
record.placeDepth = context.bytes.readUI16();
record.placeMatrix = readMatrixRecord(context);
protected function readButtonRecord2(context:SWFReaderContext):ButtonRecord2
{
var record:ButtonRecord2 = new ButtonRecord2(readButtonRecord(context));
record.colorTransform = readCXFormWithAlphaRecord(context);
if(hasFilterList)
{
record.filterList = readFilterListRecord(context);
}
if(hasBlendMode)
{
record.blendMode = context.bytes.readUI8();
}
record.filterList = readFilterListRecord(context);
record.blendMode = context.bytes.readUI8();
return record;
}

Expand Down Expand Up @@ -447,6 +437,11 @@ package com.swfwire.decompiler
return record;
}

protected function readButtonCondAction(context:SWFReaderContext):ButtonCondAction
{
throw new Error("Read ButtonCondAction not implemented.");
}

protected function readDefineSpriteTag(context:SWFReaderContext, header:TagHeaderRecord):DefineSpriteTag
{
var tag:DefineSpriteTag = new DefineSpriteTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ package com.swfwire.decompiler.data.swf3.records
{
import com.swfwire.decompiler.data.swf.records.*;

public class ButtonRecord2
public class ButtonRecord2 extends ButtonRecord
{
public var reserved:uint;
public var hasBlendMode:Boolean;
public var hasFilterList:Boolean;
public var stateHitTest:Boolean;
public var stateDown:Boolean;
public var stateOver:Boolean;
public var stateUp:Boolean;
public var characterId:uint;
public var placeDepth:uint;
public var placeMatrix:MatrixRecord;
public var colorTransform:CXFormWithAlphaRecord;
public var filterList:FilterListRecord;
public var blendMode:uint;

public function ButtonRecord2(record:ButtonRecord)
{
reserved = record.reserved;
buttonHasBlendMode = record.buttonHasBlendMode;
buttonHasFilterList = record.buttonHasFilterList;
stateHitTest = record.stateHitTest;
stateDown = record.stateDown;
stateOver = record.stateOver;
stateUp = record.stateUp;
characterId = record.characterId;
placeDepth = record.placeDepth;
placeMatrix = record.placeMatrix;
}
}
}

0 comments on commit f600bdf

Please sign in to comment.