{"V", "version"},
{"v", "verbose"},
{"o", "output"},
-{"O", "optimize"},
{0,0}
};
r2.ymax = height;
tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
swf_ShapeNew(&s);
- if(linewidth)
- ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
+ if(linewidth) {
+ linewidth = linewidth>=20?linewidth-20:0;
+ ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+ }
if(texture)
fs1 = addFillStyle(s, &r2, texture);
swf_SetU16(tag,id);
- r.xmin = r2.xmin-linewidth-linewidth/2;
- r.ymin = r2.ymin-linewidth-linewidth/2;
- r.xmax = r2.xmax+linewidth+linewidth/2;
- r.ymax = r2.ymax+linewidth+linewidth/2;
+ r.xmin = r2.xmin-linewidth/2;
+ r.ymin = r2.ymin-linewidth/2;
+ r.xmax = r2.xmax+linewidth/2;
+ r.ymax = r2.ymax+linewidth/2;
swf_SetRect(tag,&r);
swf_SetShapeHeader(tag,s);
swf_ShapeSetAll(tag,s,0,0,ls1,fs1,0);
tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
swf_ShapeNew(&s);
- if(linewidth)
- ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
+ if(linewidth) {
+ linewidth = linewidth>=20?linewidth-20:0;
+ ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+ }
if(texture)
fs1 = addFillStyle(s, &r2, texture);
swf_SetU16(tag,id);
- rect.xmin = r2.xmin-linewidth-linewidth/2;
- rect.ymin = r2.ymin-linewidth-linewidth/2;
- rect.xmax = r2.xmax+linewidth+linewidth/2;
- rect.ymax = r2.ymax+linewidth+linewidth/2;
+ rect.xmin = r2.xmin-linewidth/2;
+ rect.ymin = r2.ymin-linewidth/2;
+ rect.xmax = r2.xmax+linewidth/2;
+ rect.ymax = r2.ymax+linewidth/2;
swf_SetRect(tag,&rect);
swf_SetShapeStyles(tag, s);
swf_ShapeCountBits(s,0,0);
- swf_RecodeShapeData(outline->shape->data, outline->shape->bitlen, 1, 1,
- &s->data, &s->bitlen, s->bits.fill, s->bits.line);
+ swf_RecodeShapeData(outline->shape->data, outline->shape->bitlen, outline->shape->bits.fill, outline->shape->bits.line,
+ &s->data, &s->bitlen, s->bits.fill, s->bits.line);
swf_SetShapeBits(tag, s);
swf_SetBlock(tag, s->data, (s->bitlen+7)/8);
swf_ShapeFree(s);
tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
swf_ShapeNew(&s);
- if(linewidth)
- ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
+ if(linewidth) {
+ linewidth = linewidth>=20?linewidth-20:0;
+ ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+ }
if(texture)
fs1 = addFillStyle(s, &r2, texture);
swf_SetU16(tag,id);
- rect.xmin = r2.xmin-linewidth-linewidth/2;
- rect.ymin = r2.ymin-linewidth-linewidth/2;
- rect.xmax = r2.xmax+linewidth+linewidth/2;
- rect.ymax = r2.ymax+linewidth+linewidth/2;
+ rect.xmin = r2.xmin-linewidth/2;
+ rect.ymin = r2.ymin-linewidth/2;
+ rect.xmax = r2.xmax+linewidth/2;
+ rect.ymax = r2.ymax+linewidth/2;
swf_SetRect(tag,&rect);
swf_SetShapeHeader(tag,s);
incrementid();
}
-void s_edittext(char*name, char*fontname, int size, int width, int height, char*text, RGBA*color, int maxlength, char*variable, int flags)
+void s_edittext(char*name, char*fontname, int size, int width, int height, char*text, RGBA*color, int maxlength, char*variable, int flags, int align)
{
SWFFONT*font = 0;
EditTextLayout layout;
}
tag = swf_InsertTag(tag, ST_DEFINEEDITTEXT);
swf_SetU16(tag, id);
- layout.align = 0;
+ layout.align = align;
layout.leftmargin = 0;
layout.rightmargin = 0;
layout.indent = 0;
font->id = id;
tag = swf_InsertTag(tag, ST_DEFINEFONT2);
swf_FontSetDefine2(tag, font);
+ tag = swf_InsertTag(tag, ST_EXPORTASSETS);
+ swf_SetU16(tag, 1);
+ swf_SetU16(tag, id);
+ swf_SetString(tag, name);
incrementid();
if(dictionary_lookup(&fonts, name))
U16*samples;
int numsamples;
int t;
+ int blocksize = 1152;
if(!readWAV(filename, &wav)) {
warning("Couldn't read wav file \"%s\"", filename);
}
#endif
}
+
+ if(numsamples%blocksize != 0)
+ {
+ // apply padding, so that block is a multiple of blocksize
+ int numblocks = (numsamples+blocksize-1)/blocksize;
+ int numsamples2;
+ U16* samples2;
+ numsamples2 = numblocks * blocksize;
+ samples2 = malloc(sizeof(U16)*numsamples2);
+ memcpy(samples2, samples, numsamples*sizeof(U16));
+ memset(&samples2[numsamples], 0, sizeof(U16)*(numsamples2 - numsamples));
+ numsamples = numsamples2;
+ samples = samples2;
+ }
tag = swf_InsertTag(tag, ST_DEFINESOUND);
swf_SetU16(tag, id); //id
swf_ActionFree(a);
}
+void s_initaction(const char*character, const char*text)
+{
+ ActionTAG* a = 0;
+ character_t*c = 0;
+ a = swf_ActionCompile(text, stack[0].swf->fileVersion);
+ if(!a) {
+ syntaxerror("Couldn't compile ActionScript");
+ }
+
+ c = (character_t*)dictionary_lookup(&characters, character);
+
+ tag = swf_InsertTag(tag, ST_DOINITACTION);
+ swf_SetU16(tag, c->id);
+ swf_ActionSet(tag, a);
+
+ swf_ActionFree(a);
+}
+
int s_swf3action(char*name, char*action)
{
ActionTAG* a = 0;
SHAPE2* shape2;
SRECT bounds;
+ //swf_Shape10DrawerInit(&draw, 0);
swf_Shape11DrawerInit(&draw, 0);
+
draw_string(&draw, source);
draw.finish(&draw);
shape = swf_ShapeDrawerToShape(&draw);
static int c_edittext(map_t*args)
{
- //"name font size width height text="" color=black maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0"},
+ //"name font size width height text="" color=black maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @autosize=0"},
char*name = lu(args, "name");
char*font = lu(args, "font");
int size = (int)(1024*parsePxOrPercent(font, lu(args, "size")));
char*noselectstr = lu(args, "noselect");
char*readonlystr = lu(args, "readonly");
char*borderstr = lu(args, "border");
+ char*autosizestr = lu(args, "autosize");
+ char*alignstr = lu(args, "align");
+ int align = -1;
int flags = 0;
if(!strcmp(passwordstr, "password")) flags |= ET_PASSWORD;
if(!strcmp(htmlstr, "html")) flags |= ET_HTML;
if(!strcmp(noselectstr, "noselect")) flags |= ET_NOSELECT;
if(!strcmp(borderstr, "border")) flags |= ET_BORDER;
-
- s_edittext(name, font, size, width, height, text, &color, maxlength, variable, flags);
+ if(!strcmp(autosizestr, "autosize")) flags |= ET_AUTOSIZE;
+ if(!strcmp(alignstr, "left") || !*alignstr) align = ET_ALIGN_LEFT;
+ else if(!strcmp(alignstr, "right")) align = ET_ALIGN_RIGHT;
+ else if(!strcmp(alignstr, "center")) align = ET_ALIGN_CENTER;
+ else if(!strcmp(alignstr, "justify")) align = ET_ALIGN_JUSTIFY;
+ else syntaxerror("Unknown alignment: %s", alignstr);
+
+ s_edittext(name, font, size, width, height, text, &color, maxlength, variable, flags, align);
return 0;
}
static int c_morphshape(map_t*args) {return fakechar(args);}
static int c_movie(map_t*args) {return fakechar(args);}
+static char* readfile(const char*filename)
+{
+ FILE*fi = fopen(filename, "rb");
+ int l;
+ char*text;
+ if(!fi)
+ syntaxerror("Couldn't find file %s: %s", filename, strerror(errno));
+ fseek(fi, 0, SEEK_END);
+ l = ftell(fi);
+ fseek(fi, 0, SEEK_SET);
+ text = rfx_alloc(l+1);
+ fread(text, l, 1, fi);
+ text[l]=0;
+ fclose(fi);
+ return text;
+}
+
static int c_action(map_t*args)
{
char* filename = map_lookup(args, "filename");
}
s_action(text);
} else {
- FILE*fi = fopen(filename, "rb");
- int l;
- char*text;
- if(!fi)
- syntaxerror("Couldn't find file %s: %s", filename, strerror(errno));
- fseek(fi, 0, SEEK_END);
- l = ftell(fi);
- fseek(fi, 0, SEEK_SET);
- text = rfx_alloc(l+1);
- fread(text, l, 1, fi);
- text[l]=0;
- fclose(fi);
+ s_action(readfile(filename));
+ }
+
+ return 0;
+}
- s_action(text);
+static int c_initaction(map_t*args)
+{
+ char* character = lu(args, "name");
+ char* filename = map_lookup(args, "filename");
+ if(!filename ||!*filename) {
+ readToken();
+ if(type != RAWDATA) {
+ syntaxerror("colon (:) expected");
+ }
+ s_initaction(character, text);
+ } else {
+ s_initaction(character, readfile(filename));
}
return 0;
{"egon", c_egon, "name vertices color=white line=1 @fill=none"},
{"text", c_text, "name text font size=100% color=white"},
- {"edittext", c_edittext, "name font= size=100% width height text="" color=white maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @border=0"},
+ {"edittext", c_edittext, "name font= size=100% width height text="" color=white maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @border=0 @autosize=0 align="},
{"morphshape", c_morphshape, "name start end"},
{"button", c_button, "name"},
{"show", c_show, "name x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below= as="},
//startclip (see above)
{"sprite", c_sprite, "name"},
{"action", c_action, "filename="},
+ {"initaction", c_initaction, "name filename="},
{"end", c_end, ""}
};