Flash MX additions
[swftools.git] / lib / modules / swftools.c
index deb1a7e..0178bf0 100644 (file)
@@ -99,10 +99,12 @@ U16 swf_GetDefineID(TAG * t)
     case ST_DEFINEFONT:
     case ST_DEFINEFONT2:
     case ST_DEFINEFONTINFO: //pseudodefine
+    case ST_DEFINEFONTINFO2: //pseudodefine
     case ST_DEFINETEXT:
     case ST_DEFINETEXT2:
     case ST_DEFINESOUND:
     case ST_DEFINESPRITE:
+    case ST_DEFINEVIDEOSTREAM:
     case ST_NAMECHARACTER: //pseudodefine
       id = swf_GetU16(t);
       break;
@@ -162,6 +164,7 @@ static int swf_definingtagids[] =
  ST_DEFINEBUTTON,
  ST_DEFINEBUTTON2,
  ST_DEFINESOUND,
+ ST_DEFINEVIDEOSTREAM,
  -1
 };
 
@@ -185,9 +188,11 @@ static int swf_spritetagids[] =
 static int swf_pseudodefiningtagids[] = 
 {
  ST_DEFINEFONTINFO,
+ ST_DEFINEFONTINFO2,
  ST_DEFINEBUTTONCXFORM,
  ST_DEFINEBUTTONSOUND,
  ST_NAMECHARACTER,
+ ST_DOINITACTION,
  -1
 };
 
@@ -291,6 +296,30 @@ char* swf_GetName(TAG * t)
     return name;
 }
 
+/* used in enumerateUsedIDs */
+void swf_GetMorphGradient(TAG * tag, GRADIENT * gradient1, GRADIENT * gradient2)
+{
+    GRADIENT dummy1;
+    GRADIENT dummy2;
+    int t;
+    if(!gradient1)
+       gradient1 = &dummy1;
+    if(!gradient2)
+       gradient2 = &dummy2;
+    gradient1->num = 
+    gradient2->num = swf_GetU8(tag);
+    for(t=0;t<gradient1->num;t++)
+    {
+       int s=t;
+       if(s>=8) //FIXME
+           s=7;
+       gradient1->ratios[t] = swf_GetU8(tag);
+       swf_GetRGBA(tag, &gradient1->rgba[t]);
+       gradient2->ratios[t] = swf_GetU8(tag);
+       swf_GetRGBA(tag, &gradient2->rgba[t]);
+    }
+}
+
 #define DEBUG_ENUMERATE if(0)
 
 static void enumerateUsedIDs_styles(TAG * tag, void (*callback)(TAG*, int, void*), void*callback_data, int num, int morph)
@@ -397,6 +426,16 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
            callback(tag, tag->pos + base, callback_data); //button id
        break;
 
+       case ST_EXPORTASSETS: {
+           int num =  swf_GetU16(tag);
+           int t;
+           for(t=0;t<num;t++) {
+               callback(tag, tag->pos + base, callback_data); //button id
+               swf_GetU16(tag); //id
+               while(swf_GetU8(tag)); //name
+           }
+       } break;
+
        case ST_FREECHARACTER: /* unusual tags, which all start with an ID */
        case ST_NAMECHARACTER:
        case ST_GENERATORTEXT:
@@ -538,11 +577,19 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
            break;
        }
        case ST_DEFINEFONTINFO:
+       case ST_DEFINEFONTINFO2:
+       case ST_VIDEOFRAME:
+           callback(tag, tag->pos + base, callback_data);
+       break;
+       case ST_DEFINEVIDEOSTREAM:
+       break;
+
+       case ST_DOINITACTION:
            callback(tag, tag->pos + base, callback_data);
        break;
 
        case ST_DEFINEMORPHSHAPE:
-       case ST_DEFINESHAPE3: // these thingies might have bitmap ids in their fillstyles
+       case ST_DEFINESHAPE3:
        num++; //fallthrough
        case ST_DEFINESHAPE2:
        num++; //fallthrough
@@ -550,24 +597,28 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
            int fillbits;
            int linebits;
            int id; 
+           int numshapes = 1;
            int morph = 0;
-           if(tag->id == ST_DEFINEMORPHSHAPE)
+           if(tag->id == ST_DEFINEMORPHSHAPE) {
+               numshapes = 2;
                morph = 1;
+           }
 
            id = swf_GetU16(tag); // id;
            swf_GetRect(tag, NULL); // bounds
            if(morph) {
+               swf_ResetReadBits(tag);
                swf_GetRect(tag, NULL); // bounds2
                swf_GetU32(tag); //offset to endedges
            }
-    
+   
            DEBUG_ENUMERATE printf("Tag:%d Name:%s ID:%d\n", tag->id, swf_TagGetName(tag), id);
 
            enumerateUsedIDs_styles(tag, callback, callback_data, num, morph);
            DEBUG_ENUMERATE printf("-------\n");
-           while(--morph>=0) /* morph shapes define two shapes */
+           while(--numshapes>=0) /* morph shapes define two shapes */
            {
-               swf_ResetReadBits(tag); //?
+               DEBUG_ENUMERATE printf("shape:%d\n", numshapes);
                fillbits = swf_GetBits(tag, 4);
                linebits = swf_GetBits(tag, 4);
                DEBUG_ENUMERATE printf("%d %d\n", fillbits, linebits);