X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=4aaa50eb0cce32270cf617b8b4f69a971f054816;hb=7b277f03f0e4db6ba147cddbf25334ba9b18c5a7;hp=a4102869b21c66d93ad5d555795601a30a698751;hpb=1b92dcdf739c6b827ac037ce74a9d9df0fc857a8;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index a410286..4aaa50e 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -42,12 +42,12 @@ static char * outputname = "output.swf"; static int verbose = 2; static int override_outputname = 0; -static struct options_t options[] = -{ - {"o","output"}, - {"v","verbose"}, - {"V","version"}, - {0,0} +static struct options_t options[] = { +{"h", "help"}, +{"V", "version"}, +{"v", "verbose"}, +{"o", "output"}, +{0,0} }; int args_callback_option(char*name,char*val) @@ -75,12 +75,16 @@ int args_callback_longoption(char*name,char*val) { return args_long2shortoption(options, name, val); } -void args_callback_usage(char*name) +void args_callback_usage(char *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"); + printf("\n"); + printf("Usage: %s [-o file.swf] file.sc\n", name); + printf("\n"); + printf("-h , --help Print short help message and exit\n"); + printf("-V , --version Print version info and exit\n"); + printf("-v , --verbose Increase verbosity. \n"); + printf("-o , --output Set output file to .\n"); + printf("\n"); } int args_callback_command(char*name,char*val) { @@ -121,7 +125,7 @@ static void warning(char*format, ...) va_end(arglist); printf("\"%s\", line %d column %d: warning- %s\n", filename, line, column, buf); } - + static void readToken() { type = file[pos].type; @@ -811,28 +815,16 @@ void dumpSWF(SWF*swf) void s_font(char*name, char*filename) { - int f; - SWF swf; SWFFONT* font; font = swf_LoadFont(filename); - - /*f = open(filename,O_RDONLY|O_BINARY); - if (f<0) { - warning("Couldn't open file \"%s\": %s", filename, strerror(errno)); + + if(font == 0) { + warning("Couldn't open font file \"%s\"", filename); font = (SWFFONT*)malloc(sizeof(SWFFONT)); memset(font, 0, sizeof(SWFFONT)); dictionary_put2(&fonts, name, font); return; } - font = 0; - if (swf_ReadSWF(f,&swf)>=0) { - swf_FontExtract(&swf, 0x4e46, &font); - swf_FreeTags(&swf); - } - close(f); - if (font==0) { - syntaxerror("File \"%s\" isn't a valid rfxswf font file", filename); - }*/ if(0) { @@ -965,6 +957,9 @@ void s_action(const char*text) { ActionTAG* a = 0; a = swf_ActionCompile(text, stack[0].swf->fileVersion); + if(!a) { + syntaxerror("Couldn't compile ActionScript"); + } tag = swf_InsertTag(tag, ST_DOACTION); @@ -1935,7 +1930,7 @@ static int c_primitive(map_t*args) int type=0; char* font; char* text; - char* outline; + char* outline=0; RGBA fill; if(!strcmp(command, "circle")) type = 1; @@ -2055,9 +2050,12 @@ int fakechar(map_t*args) static int c_egon(map_t*args) {return fakechar(args);} static int c_button(map_t*args) { + char*action = ""; readToken(); - if(type != RAWDATA) - syntaxerror("colon (:) expected"); + if(type == RAWDATA) + action = text; + else + pushBack(); return fakechar(args); } @@ -2073,8 +2071,9 @@ static int c_texture(map_t*args) {return 0;} static int c_action(map_t*args) { readToken(); - if(type != RAWDATA) + if(type != RAWDATA) { syntaxerror("colon (:) expected"); + } s_action(text); @@ -2123,15 +2122,15 @@ static struct { {"stop", c_stop, "sound"}, // object placement tags - {"put", c_put, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, - {"startclip", c_startclip, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, - {"change", c_change, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, - {"arcchange", c_arcchange, "name pivot= angle= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, - {"qchange", c_qchange, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, - {"jump", c_jump, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"put", c_put, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, + {"startclip", c_startclip, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, + {"change", c_change, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, + {"arcchange", c_arcchange, "name pivot= angle= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, + {"qchange", c_qchange, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, + {"jump", c_jump, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below="}, {"del", c_del, "name"}, // virtual object placement - {"buttonput", c_buttonput, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex=100% scaley=100% shear=0 rotate=0 above= below="}, + {"buttonput", c_buttonput, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex=100% scaley=100% shear=0 rotate=0 above= below="}, //TODO: ratio??? {"texture", c_texture, " x=0 y=0 scale= scalex=100% scaley=100% shear=0 rotate=0"}, // commands which start a block @@ -2313,6 +2312,8 @@ static void parseArgumentsForCommand(char*command) int t; map_t args; int nr = -1; + msg(" parse Command: %s (line %d)", command, line); + for(t=0;t