X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=a4102869b21c66d93ad5d555795601a30a698751;hb=2689b541f1a0f9a767ac8fe55909183d2c9a7347;hp=e248874442f071280cfd3392f4f5f032e14cd1e3;hpb=b52d3471652c8872497ff81ff46de4fda543298c;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index e248874..a410286 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -28,6 +28,7 @@ #include #include "../config.h" #include "../lib/rfxswf.h" +#include "../lib/drawer.h" #include "../lib/log.h" #include "../lib/args.h" #include "../lib/q.h" @@ -76,7 +77,7 @@ int args_callback_longoption(char*name,char*val) } void args_callback_usage(char*name) { - printf("Usage: %s [-o filename] file.wav\n", name); + printf("Usage: %s [-o filename] file.sc\n", name); printf("\t-v , --verbose\t\t\t Be more verbose\n"); printf("\t-o , --output filename\t\t set output filename (default: output.swf)\n"); printf("\t-V , --version\t\t\t Print program version and exit\n"); @@ -720,12 +721,13 @@ void s_textshape(char*name, char*fontname, char*_text) outline->bbox = font->layout->bounds[g]; { - SWFSHAPEDRAWER draw; - swf_DrawerInit(&draw,0); + drawer_t draw; + swf_Shape11DrawerInit(&draw, 0); swf_DrawText(&draw, font, _text); - swf_DrawerFinish(&draw); - outline->shape = swf_DrawerToShape(&draw); - outline->bbox = draw.bbox; + draw.finish(&draw); + outline->shape = swf_ShapeDrawerToShape(&draw); + outline->bbox = swf_ShapeDrawerGetBBox(&draw); + draw.dealloc(&draw); } if(dictionary_lookup(&outlines, name)) @@ -812,7 +814,9 @@ void s_font(char*name, char*filename) int f; SWF swf; SWFFONT* font; - f = open(filename,O_RDONLY|O_BINARY); + font = swf_LoadFont(filename); + + /*f = open(filename,O_RDONLY|O_BINARY); if (f<0) { warning("Couldn't open file \"%s\": %s", filename, strerror(errno)); font = (SWFFONT*)malloc(sizeof(SWFFONT)); @@ -828,7 +832,7 @@ void s_font(char*name, char*filename) close(f); if (font==0) { syntaxerror("File \"%s\" isn't a valid rfxswf font file", filename); - } + }*/ if(0) { @@ -922,13 +926,15 @@ GRADIENT parseGradient(const char*str) memset(&gradient, 0, sizeof(GRADIENT)); while(*p) { char*posstr,*colorstr; + float pos; + RGBA color; posstr = gradient_getToken(&p); if(!*posstr) break; - float pos = parsePercent(posstr); + pos = parsePercent(posstr); if(!*p) syntaxerror("Error in shape data: Color expected after %s", posstr); colorstr = gradient_getToken(&p); - RGBA color = parseColor(colorstr); + color = parseColor(colorstr); if(gradient.num == sizeof(gradient.ratios)/sizeof(gradient.ratios[0])) { warning("gradient record too big- max size is 8, rest ignored"); break; @@ -955,22 +961,36 @@ void s_gradient(char*name, const char*text, int radial) dictionary_put2(&gradients, name, gradient); } +void s_action(const char*text) +{ + ActionTAG* a = 0; + a = swf_ActionCompile(text, stack[0].swf->fileVersion); + + tag = swf_InsertTag(tag, ST_DOACTION); + + swf_ActionSet(tag, a); + + swf_ActionFree(a); +} + void s_outline(char*name, char*format, char*source) { outline_t* outline; - SWFSHAPEDRAWER draw; + drawer_t draw; SHAPE* shape; SHAPE2* shape2; SRECT bounds; - swf_DrawerInit(&draw, 0); - swf_DrawString(&draw, source); - swf_DrawerFinish(&draw); - shape = swf_DrawerToShape(&draw); - shape2 = swf_ShapeToShape2(shape); - bounds = swf_GetShapeBoundingBox(shape2); + swf_Shape11DrawerInit(&draw, 0); + draw_string(&draw, source); + draw.finish(&draw); + shape = swf_ShapeDrawerToShape(&draw); + //shape2 = swf_ShapeToShape2(shape); + //bounds = swf_GetShapeBoundingBox(shape2); //swf_Shape2Free(shape2); + bounds = swf_ShapeDrawerGetBBox(&draw); + draw.dealloc(&draw); outline = (outline_t*)malloc(sizeof(outline_t)); memset(outline, 0, sizeof(outline_t)); @@ -2034,7 +2054,13 @@ int fakechar(map_t*args) } static int c_egon(map_t*args) {return fakechar(args);} -static int c_button(map_t*args) {return fakechar(args);} +static int c_button(map_t*args) { + readToken(); + if(type != RAWDATA) + syntaxerror("colon (:) expected"); + + return fakechar(args); +} static int c_edittext(map_t*args) {return fakechar(args);} static int c_morphshape(map_t*args) {return fakechar(args);} @@ -2043,7 +2069,17 @@ static int c_movie(map_t*args) {return fakechar(args);} static int c_buttonsounds(map_t*args) {return 0;} static int c_buttonput(map_t*args) {return 0;} static int c_texture(map_t*args) {return 0;} -static int c_action(map_t*args) {return 0;} + +static int c_action(map_t*args) +{ + readToken(); + if(type != RAWDATA) + syntaxerror("colon (:) expected"); + + s_action(text); + + return 0; +} static struct { char*command; @@ -2303,7 +2339,7 @@ static void parseArgumentsForCommand(char*command) (*arguments[nr].func)(&args); - if(!strcmp(command, "button") || + /*if(!strcmp(command, "button") || !strcmp(command, "action")) { while(1) { readToken(); @@ -2316,7 +2352,7 @@ static void parseArgumentsForCommand(char*command) } } } - } + }*/ map_clear(&args); return;